@@ -2,17 +2,18 @@ import { utils } from '@cardano-foundation/ledgerjs-hw-app-cardano';
22import { Messages } from '@trezor/transport' ;
33import { CardanoDRep , PROTO } from '@trezor/connect' ;
44import { map } from 'lodash' ;
5+ import { Cardano } from '@cardano-sdk/core' ;
56import {
6- derivationPathToString ,
77 CERTIFICATE_TYPE ,
8+ derivationPathToString ,
89 groupTokensByPolicyId ,
910} from './hardwareWalletUtils' ;
1011import type {
12+ CoinSelectionAssetsType ,
13+ CoinSelectionCertificate ,
1114 CoinSelectionInput ,
1215 CoinSelectionOutput ,
13- CoinSelectionCertificate ,
1416 CoinSelectionWithdrawal ,
15- CoinSelectionAssetsType ,
1617} from '../api/transactions/types' ;
1718
1819export 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