1
1
import { StaticChangeAddressResolver , roundRobinRandomImprove } from '@cardano-sdk/input-selection' ;
2
2
3
+ import { Bip32Account , SignTransactionContext , util } from '@cardano-sdk/key-management' ;
3
4
import { Cardano , Serialization } from '@cardano-sdk/core' ;
5
+ import { Ed25519KeyHashHex } from '@cardano-sdk/crypto' ;
4
6
import { GreedyTxEvaluator } from './GreedyTxEvaluator' ;
5
7
import { InitializeTxProps , InitializeTxResult } from '../types' ;
6
8
import { RedeemersByType , defaultSelectionConstraints } from '../input-selection' ;
7
9
import { TxBuilderDependencies } from './types' ;
8
10
import { createPreInputSelectionTxBody , includeChangeAndInputs } from '../createTransactionInternals' ;
9
11
import { ensureValidityInterval } from '../ensureValidityInterval' ;
10
- import { util } from '@cardano-sdk/key-management' ;
12
+
13
+ const dRepPublicKeyHash = async ( addressManager ?: Bip32Account ) : Promise < Ed25519KeyHashHex | undefined > =>
14
+ addressManager && ( await ( await addressManager . derivePublicKey ( util . DREP_KEY_DERIVATION_PATH ) ) . hash ( ) ) . hex ( ) ;
11
15
12
16
export const initializeTx = async (
13
17
props : InitializeTxProps ,
@@ -72,9 +76,7 @@ export const initializeTx = async (
72
76
witness : props . witness as Cardano . Witness
73
77
} ) ;
74
78
75
- const dRepPublicKey = addressManager
76
- ? ( await addressManager . derivePublicKey ( util . DREP_KEY_DERIVATION_PATH ) ) . hex ( )
77
- : undefined ;
79
+ const dRepKeyHashHex = await dRepPublicKeyHash ( addressManager ) ;
78
80
79
81
const transaction = new Serialization . Transaction (
80
82
Serialization . TransactionBody . fromCore ( unwitnessedTx . body ) ,
@@ -84,8 +86,8 @@ export const initializeTx = async (
84
86
auxiliaryData ? Serialization . AuxiliaryData . fromCore ( auxiliaryData ) : undefined
85
87
) ;
86
88
87
- const signingContext = {
88
- dRepPublicKey ,
89
+ const signingContext : SignTransactionContext = {
90
+ ... ( dRepKeyHashHex && { dRepKeyHashHex } ) ,
89
91
handleResolutions : props . handleResolutions ?? [ ] ,
90
92
knownAddresses : addresses ,
91
93
txInKeyPathMap : await util . createTxInKeyPathMap ( unwitnessedTx . body , addresses , inputResolver )
0 commit comments