Skip to content

Commit bd7d70d

Browse files
fix: allow Trezor to delegate vote with cip129
1 parent 9195bee commit bd7d70d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

source/renderer/app/utils/shelleyTrezor.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import { utils } from '@cardano-foundation/ledgerjs-hw-app-cardano';
22
import { Messages } from '@trezor/transport';
33
import { CardanoDRep, PROTO } from '@trezor/connect';
44
import { map } from 'lodash';
5+
import { Cardano } from '@cardano-sdk/core';
56
import {
6-
derivationPathToString,
77
CERTIFICATE_TYPE,
8+
derivationPathToString,
89
groupTokensByPolicyId,
910
} from './hardwareWalletUtils';
1011
import type {
12+
CoinSelectionAssetsType,
13+
CoinSelectionCertificate,
1114
CoinSelectionInput,
1215
CoinSelectionOutput,
13-
CoinSelectionCertificate,
1416
CoinSelectionWithdrawal,
15-
CoinSelectionAssetsType,
1617
} from '../api/transactions/types';
1718

1819
export const TrezorTransactionSigningMode = {
@@ -67,18 +68,18 @@ const parseVoteDelegation = (cert: CoinSelectionCertificate): CardanoDRep => {
6768
};
6869
}
6970

70-
const voteHash = utils.bech32_decodeAddress(cert.vote).toString('hex');
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: PROTO.CardanoDRepType.SCRIPT_HASH,
75-
scriptHash: voteHash,
76+
scriptHash: hash,
7677
};
7778
}
7879

7980
return {
8081
type: PROTO.CardanoDRepType.KEY_HASH,
81-
keyHash: voteHash,
82+
keyHash: hash,
8283
};
8384
};
8485

0 commit comments

Comments
 (0)