Skip to content

Commit 9195bee

Browse files
feat: enable cip-129 for hardware wallets
1 parent 295cf77 commit 9195bee

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

source/renderer/app/utils/dataSerialization.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import blakejs from 'blakejs';
33
import { encode } from 'borc';
44
import { utils } from '@cardano-foundation/ledgerjs-hw-app-cardano';
55
import { base58_decode } from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/utils/address';
6+
import { Cardano } from '@cardano-sdk/core';
67
import { AddressStyles } from '../domains/WalletAddress';
78
import {
89
derivationPathToLedgerPath,
@@ -182,11 +183,12 @@ const parseVoteDelegation = (vote: string): [number] | [number, Buffer] => {
182183
if (vote === 'abstain') return [2];
183184
if (vote === 'no_confidence') return [3];
184185

185-
const voteHash = Buffer.from(
186-
utils.buf_to_hex(utils.bech32_decodeAddress(vote)),
187-
'hex'
188-
);
189-
return [vote.includes('_script') ? 1 : 0, voteHash];
186+
const { type, hash } = Cardano.DRepID.toCredential(Cardano.DRepID(vote));
187+
188+
return [
189+
type === Cardano.CredentialType.ScriptHash ? 1 : 0,
190+
Buffer.from(hash, 'hex'),
191+
];
190192
};
191193

192194
export function toTxCertificate(cert: {

source/renderer/app/utils/shelleyLedger.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
base58_decode,
1414
str_to_path,
1515
} from '@cardano-foundation/ledgerjs-hw-app-cardano/dist/utils/address';
16+
import { Cardano } from '@cardano-sdk/core';
1617
import {
1718
CATALYST_VOTING_REGISTRATION_TYPE,
1819
CERTIFICATE_TYPE,
@@ -67,18 +68,18 @@ const parseVoteDelegation = (
6768
};
6869
}
6970

70-
const votHash = utils.buf_to_hex(utils.bech32_decodeAddress(cert.vote));
71+
const { type, hash } = Cardano.DRepID.toCredential(Cardano.DRepID(cert.vote));
7172

72-
if (cert.vote.includes('_script')) {
73+
if (type === Cardano.CredentialType.ScriptHash) {
7374
return {
7475
type: DRepParamsType.SCRIPT_HASH,
75-
scriptHashHex: votHash,
76+
scriptHashHex: hash,
7677
};
7778
}
7879

7980
return {
8081
type: DRepParamsType.KEY_HASH,
81-
keyHashHex: votHash,
82+
keyHashHex: hash,
8283
};
8384
};
8485

0 commit comments

Comments
 (0)