diff --git a/app/frontend/wallet/shelley/shelley-bitbox02-crypto-provider.ts b/app/frontend/wallet/shelley/shelley-bitbox02-crypto-provider.ts index 409cfe8771..e04a0c64fa 100644 --- a/app/frontend/wallet/shelley/shelley-bitbox02-crypto-provider.ts +++ b/app/frontend/wallet/shelley/shelley-bitbox02-crypto-provider.ts @@ -8,9 +8,11 @@ import { CryptoProviderType, Network, TxCertificate, + TxDRepType, TxInput, TxOutput, TxShelleyWitness, + TxVoteDelegationCert, } from '../types' import {encodeCbor} from '../helpers/cbor' import {safeAssertUnreachable} from '../../helpers/common' @@ -18,6 +20,7 @@ import {safeAssertUnreachable} from '../../helpers/common' import type { CardanoAssetGroup, CardanoCertificate, + CardanoDrepType, CardanoInput, CardanoOutput, CardanoShelleyWitness, @@ -175,6 +178,23 @@ const ShelleyBitBox02CryptoProvider = async ({ } } + const prepareVoteDelegation = ( + voteDelegation: TxVoteDelegationCert, + addressToAbsPathMapper: AddressToPathMapper + ): CardanoCertificate => { + switch (voteDelegation.dRep.type) { + case TxDRepType.ALWAYS_ABSTAIN: + return { + voteDelegation: { + keypath: addressToAbsPathMapper(voteDelegation.stakingAddress), + type: 'alwaysAbstain', + }, + } + default: + return safeAssertUnreachable(voteDelegation.dRep.type) + } + } + const prepareCertificate = ( certificate: TxCertificate, addressToAbsPathMapper: AddressToPathMapper @@ -200,13 +220,7 @@ const ShelleyBitBox02CryptoProvider = async ({ }, } case CertificateType.VOTE_DELEGATION: - return { - voteDelegation: { - keypath: addressToAbsPathMapper(certificate.stakingAddress), - type: certificate.dRep.type, - drepCredhash: null, - }, - } + return prepareVoteDelegation(certificate, addressToAbsPathMapper) case CertificateType.STAKEPOOL_REGISTRATION: throw new UnexpectedError(UnexpectedErrorReason.UnsupportedOperationError, { message: 'Stakepool registration not supported', diff --git a/app/libs/bitbox-api/bitbox_api.d.ts b/app/libs/bitbox-api/bitbox_api.d.ts index 332ea361a3..acaed3cf06 100644 --- a/app/libs/bitbox-api/bitbox_api.d.ts +++ b/app/libs/bitbox-api/bitbox_api.d.ts @@ -135,6 +135,7 @@ type CardanoOutput = { scriptConfig?: CardanoScriptConfig; assetGroups?: CardanoAssetGroup[]; } +type CardanoDrepType = 'keyHash' | 'scriptHash' | 'alwaysAbstain' | 'alwaysNoConfidence' type CardanoCertificate = | { stakeRegistration: { @@ -155,8 +156,8 @@ type CardanoCertificate = | { voteDelegation: { keypath: Keypath - type: number - drepCredhash: Uint8Array | undefined | null + type: CardanoDrepType + drepCredHash?: Uint8Array } }; type CardanoWithdrawal = { diff --git a/app/libs/bitbox-api/bitbox_api_bg.js b/app/libs/bitbox-api/bitbox_api_bg.js index aa12fd23a2..a0a01002fd 100644 --- a/app/libs/bitbox-api/bitbox_api_bg.js +++ b/app/libs/bitbox-api/bitbox_api_bg.js @@ -1238,7 +1238,7 @@ export function __wbindgen_memory() { return addHeapObject(ret); }; -export function __wbindgen_closure_wrapper2347(arg0, arg1, arg2) { +export function __wbindgen_closure_wrapper2355(arg0, arg1, arg2) { const ret = makeMutClosure(arg0, arg1, 247, __wbg_adapter_52); return addHeapObject(ret); }; diff --git a/app/libs/bitbox-api/bitbox_api_bg.wasm b/app/libs/bitbox-api/bitbox_api_bg.wasm index 8662c61a0d..684d2ca5c9 100644 Binary files a/app/libs/bitbox-api/bitbox_api_bg.wasm and b/app/libs/bitbox-api/bitbox_api_bg.wasm differ