Skip to content

Commit

Permalink
feat: update to latest bitbox lib build
Browse files Browse the repository at this point in the history
  • Loading branch information
refi93 committed Oct 11, 2024
1 parent f2b4d67 commit 98510cd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
28 changes: 21 additions & 7 deletions app/frontend/wallet/shelley/shelley-bitbox02-crypto-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ import {
CryptoProviderType,
Network,
TxCertificate,
TxDRepType,
TxInput,
TxOutput,
TxShelleyWitness,
TxVoteDelegationCert,
} from '../types'
import {encodeCbor} from '../helpers/cbor'
import {safeAssertUnreachable} from '../../helpers/common'

import type {
CardanoAssetGroup,
CardanoCertificate,
CardanoDrepType,
CardanoInput,
CardanoOutput,
CardanoShelleyWitness,
Expand Down Expand Up @@ -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
Expand All @@ -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',
Expand Down
5 changes: 3 additions & 2 deletions app/libs/bitbox-api/bitbox_api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ type CardanoOutput = {
scriptConfig?: CardanoScriptConfig;
assetGroups?: CardanoAssetGroup[];
}
type CardanoDrepType = 'keyHash' | 'scriptHash' | 'alwaysAbstain' | 'alwaysNoConfidence'
type CardanoCertificate =
| {
stakeRegistration: {
Expand All @@ -155,8 +156,8 @@ type CardanoCertificate =
| {
voteDelegation: {
keypath: Keypath
type: number
drepCredhash: Uint8Array | undefined | null
type: CardanoDrepType
drepCredHash?: Uint8Array
}
};
type CardanoWithdrawal = {
Expand Down
2 changes: 1 addition & 1 deletion app/libs/bitbox-api/bitbox_api_bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
Binary file modified app/libs/bitbox-api/bitbox_api_bg.wasm
Binary file not shown.

0 comments on commit 98510cd

Please sign in to comment.