@@ -136,11 +136,20 @@ class LazyTxSigner implements UnwitnessedTx {
136
136
tx,
137
137
ctx : {
138
138
signingContext : { knownAddresses, handleResolutions } ,
139
- auxiliaryData
139
+ auxiliaryData,
140
+ witness
140
141
} ,
141
142
inputSelection
142
143
} = await this . #build( ) ;
143
- return { ...tx , auxiliaryData, handleResolutions, inputSelection, ownAddresses : knownAddresses } ;
144
+
145
+ return {
146
+ ...tx ,
147
+ auxiliaryData,
148
+ handleResolutions,
149
+ inputSelection,
150
+ ownAddresses : knownAddresses ,
151
+ witness : witness as Cardano . Witness
152
+ } ;
144
153
}
145
154
146
155
async sign ( ) : Promise < WitnessedTx > {
@@ -528,12 +537,9 @@ export class GenericTxBuilder implements TxBuilder {
528
537
}
529
538
530
539
const costModels = getDefaultCostModelsForVersions ( [ ...scriptVersions ] ) ;
531
- body . scriptIntegrityHash = computeScriptDataHash (
532
- costModels ,
533
- [ ...scriptVersions ] ,
534
- witness . redeemers ,
535
- witness . datums
536
- ) ;
540
+ body . scriptIntegrityHash = computeScriptDataHash ( costModels , [ ...scriptVersions ] , witness . redeemers , [
541
+ ...this . #knownDatums. values ( )
542
+ ] ) ;
537
543
538
544
const serializableBody = Serialization . TransactionBody . fromCore ( body ) ;
539
545
@@ -903,12 +909,23 @@ export class GenericTxBuilder implements TxBuilder {
903
909
inputs . set ( inputId , [ { ...input , address : resolvedInput . address } , resolvedInput ] ) ;
904
910
}
905
911
912
+ // eslint-disable-next-line sonarjs/cognitive-complexity
906
913
#addScriptInput( input : Cardano . TxIn | Cardano . Utxo , scriptUnlockProps : ScriptUnlockProps ) {
907
914
let txId : TxIdWithIndex ;
908
915
909
916
if ( Array . isArray ( input ) ) {
910
917
txId = `${ input [ 0 ] . txId } #${ input [ 0 ] . index } ` ;
911
918
this . #mustSpendInputs. set ( txId , input ) ;
919
+
920
+ if ( input [ 1 ] . datum ) {
921
+ const hash = Serialization . PlutusData . fromCore ( input [ 1 ] . datum ) . hash ( ) ;
922
+ this . #knownDatums. set ( hash , input [ 1 ] . datum ) ;
923
+ this . #knownInlineDatums. add ( hash ) ;
924
+ }
925
+
926
+ if ( input [ 1 ] . datumHash ) {
927
+ this . #unresolvedDatums. push ( input [ 1 ] . datumHash ) ;
928
+ }
912
929
} else {
913
930
txId = `${ input . txId } #${ input . index } ` ;
914
931
@@ -943,7 +960,6 @@ export class GenericTxBuilder implements TxBuilder {
943
960
} else {
944
961
const hash = Serialization . PlutusData . fromCore ( scriptUnlockProps . datum ) . hash ( ) ;
945
962
this . #knownDatums. set ( hash , scriptUnlockProps . datum ) ;
946
- this . #knownInlineDatums. add ( hash ) ;
947
963
}
948
964
}
949
965
}
0 commit comments