1
1
import * as Cardano from '../../Cardano' ;
2
- import * as util from '../../Cardano/ util/primitives ' ;
2
+ import { Base64Blob , Hash32ByteBase16 , HexBlob , ManagedFreeableScope , usingAutoFree } from '@cardano-sdk/ util' ;
3
3
import { CML } from '../CML' ;
4
- import { ManagedFreeableScope , usingAutoFree } from '@cardano-sdk/util' ;
5
4
import { PlutusLanguageVersion , ScriptType } from '../../Cardano' ;
6
5
import { ScriptKind } from '@dcspark/cardano-multiplatform-lib-nodejs' ;
7
6
import { SerializationError , SerializationFailure } from '../../errors' ;
@@ -157,14 +156,14 @@ export const getCoreScript = (scope: ManagedFreeableScope, script: CML.Script):
157
156
case ScriptKind . PlutusScriptV1 :
158
157
coreScriptRef = {
159
158
__type : ScriptType . Plutus ,
160
- bytes : util . HexBlob . fromBytes ( scope . manage ( script . as_plutus_v1 ( ) ! ) . to_bytes ( ) ) ,
159
+ bytes : HexBlob . fromBytes ( scope . manage ( script . as_plutus_v1 ( ) ! ) . to_bytes ( ) ) ,
161
160
version : PlutusLanguageVersion . V1
162
161
} ;
163
162
break ;
164
163
case ScriptKind . PlutusScriptV2 :
165
164
coreScriptRef = {
166
165
__type : ScriptType . Plutus ,
167
- bytes : util . HexBlob . fromBytes ( scope . manage ( script . as_plutus_v2 ( ) ! ) . to_bytes ( ) ) ,
166
+ bytes : HexBlob . fromBytes ( scope . manage ( script . as_plutus_v2 ( ) ! ) . to_bytes ( ) ) ,
168
167
version : PlutusLanguageVersion . V2
169
168
} ;
170
169
break ;
@@ -189,7 +188,7 @@ export const txOut = (output: CML.TransactionOutput): Cardano.TxOut =>
189
188
return {
190
189
address : Cardano . Address ( address ) ,
191
190
datum : inlineDatum ? bytesToHex ( inlineDatum ) : undefined ,
192
- datumHash : dataHashBytes ? Cardano . util . Hash32ByteBase16 . fromHexBlob ( bytesToHex ( dataHashBytes ) ) : undefined ,
191
+ datumHash : dataHashBytes ? Hash32ByteBase16 . fromHexBlob ( bytesToHex ( dataHashBytes ) ) : undefined ,
193
192
scriptReference : scriptRef ? getCoreScript ( scope , scope . manage ( scriptRef . script ( ) ) ) : undefined ,
194
193
value : value ( scope . manage ( output . amount ( ) ) )
195
194
} ;
@@ -282,7 +281,7 @@ export const txBody = (body: CML.TransactionBody): Cardano.TxBody =>
282
281
referenceInputs : cslReferenceInputs ? txInputs ( cslReferenceInputs ) : undefined ,
283
282
requiredExtraSignatures : txRequiredExtraSignatures ( scope . manage ( body . required_signers ( ) ) ) ,
284
283
scriptIntegrityHash :
285
- cslScriptDataHash && Cardano . util . Hash32ByteBase16 ( Buffer . from ( cslScriptDataHash . to_bytes ( ) ) . toString ( 'hex' ) ) ,
284
+ cslScriptDataHash && Hash32ByteBase16 ( Buffer . from ( cslScriptDataHash . to_bytes ( ) ) . toString ( 'hex' ) ) ,
286
285
totalCollateral : cslTotalCollateral ? BigInt ( cslTotalCollateral . to_str ( ) ) : undefined ,
287
286
validityInterval : validityInterval ( scope , body ) ,
288
287
withdrawals : txWithdrawals ( scope . manage ( body . withdrawals ( ) ) )
@@ -298,8 +297,8 @@ export const txWitnessBootstrap = (bootstraps?: CML.BootstrapWitnesses): Cardano
298
297
const attributes = scope . manage ( bootstrap . attributes ( ) ) . to_bytes ( ) ;
299
298
const chainCode = bootstrap . chain_code ( ) ;
300
299
result . push ( {
301
- addressAttributes : attributes ?. length > 0 ? Cardano . util . Base64Blob . fromBytes ( attributes ) : undefined ,
302
- chainCode : chainCode ?. length > 0 ? Cardano . util . HexBlob . fromBytes ( chainCode ) : undefined ,
300
+ addressAttributes : attributes ?. length > 0 ? Base64Blob . fromBytes ( attributes ) : undefined ,
301
+ chainCode : chainCode ?. length > 0 ? HexBlob . fromBytes ( chainCode ) : undefined ,
303
302
key : Cardano . Ed25519PublicKey (
304
303
Buffer . from ( scope . manage ( scope . manage ( bootstrap . vkey ( ) ) . public_key ( ) ) . as_bytes ( ) ) . toString ( 'hex' )
305
304
) ,
@@ -324,7 +323,7 @@ export const txWitnessRedeemers = (redeemers?: CML.Redeemers): Cardano.Redeemer[
324
323
const redeemerTagKind = scope . manage ( reedeemer . tag ( ) ) . kind ( ) ;
325
324
326
325
result . push ( {
327
- data : Cardano . util . HexBlob . fromBytes ( scope . manage ( reedeemer . data ( ) ) . to_bytes ( ) ) ,
326
+ data : HexBlob . fromBytes ( scope . manage ( reedeemer . data ( ) ) . to_bytes ( ) ) ,
328
327
executionUnits : {
329
328
memory : Number ( scope . manage ( exUnits . mem ( ) ) . to_str ( ) ) ,
330
329
steps : Number ( scope . manage ( exUnits . steps ( ) ) . to_str ( ) )
@@ -341,7 +340,7 @@ export const txWitnessDatums = (datums?: CML.PlutusList): Cardano.Datum[] | unde
341
340
if ( ! datums ) return ;
342
341
const result : Cardano . Datum [ ] = [ ] ;
343
342
for ( let j = 0 ; j < datums . len ( ) ; j ++ ) {
344
- result . push ( Cardano . util . HexBlob . fromBytes ( scope . manage ( datums . get ( j ) ) . to_bytes ( ) ) ) ;
343
+ result . push ( HexBlob . fromBytes ( scope . manage ( datums . get ( j ) ) . to_bytes ( ) ) ) ;
345
344
}
346
345
return result ;
347
346
} ) ;
@@ -357,7 +356,7 @@ export const txWitnessScripts = (witnessSet: CML.TransactionWitnessSet): Cardano
357
356
for ( let i = 0 ; i < plutusScriptsV1 . len ( ) ; ++ i ) {
358
357
scripts . push ( {
359
358
__type : Cardano . ScriptType . Plutus ,
360
- bytes : Cardano . util . HexBlob ( scope . manage ( plutusScriptsV1 . get ( i ) ) . to_js_value ( ) ) ,
359
+ bytes : HexBlob ( scope . manage ( plutusScriptsV1 . get ( i ) ) . to_js_value ( ) ) ,
361
360
version : Cardano . PlutusLanguageVersion . V1
362
361
} ) ;
363
362
}
@@ -366,7 +365,7 @@ export const txWitnessScripts = (witnessSet: CML.TransactionWitnessSet): Cardano
366
365
for ( let i = 0 ; i < plutusScriptsV2 . len ( ) ; ++ i ) {
367
366
scripts . push ( {
368
367
__type : Cardano . ScriptType . Plutus ,
369
- bytes : Cardano . util . HexBlob ( scope . manage ( plutusScriptsV2 . get ( i ) ) . to_js_value ( ) ) ,
368
+ bytes : HexBlob ( scope . manage ( plutusScriptsV2 . get ( i ) ) . to_js_value ( ) ) ,
370
369
version : Cardano . PlutusLanguageVersion . V2
371
370
} ) ;
372
371
}
0 commit comments