1- import * as CardanoWasm from '@emurgo/cardano-serialization-lib-nodejs' ;
21import {
32 Address ,
43 BigNum ,
54 Certificate ,
65 Certificates ,
6+ CoinSelectionStrategyCIP2 ,
77 Ed25519KeyHash ,
8- LinearFee , PublicKey ,
8+ Ed25519Signature ,
9+ hash_transaction ,
10+ LinearFee ,
11+ PublicKey ,
912 RewardAddress ,
1013 StakeCredential ,
1114 StakeDelegation ,
1215 StakeRegistration ,
1316 Transaction ,
1417 TransactionBuilder ,
1518 TransactionBuilderConfigBuilder ,
19+ TransactionHash ,
20+ TransactionInput ,
1621 TransactionOutput ,
1722 TransactionOutputs ,
18- Value , Vkey , VRFVKey ,
23+ TransactionUnspentOutput ,
24+ TransactionUnspentOutputs ,
25+ TransactionWitnessSet ,
26+ Value ,
27+ Vkey , Vkeywitness , Vkeywitnesses ,
1928} from '@emurgo/cardano-serialization-lib-nodejs' ;
20- import { mnemonicToEntropy } from 'bip39' ;
2129import { Service } from "./service" ;
2230import { AdaStakeOptions , InternalAdaConfig , UTXO } from "../types/ada" ;
2331import {
@@ -125,10 +133,10 @@ export class AdaService extends Service {
125133 BigNum . from_str ( CARDANO_PARAMS . MIN_FEE_B ) ,
126134 ) ,
127135 )
128- . pool_deposit ( CardanoWasm . BigNum . from_str ( CARDANO_PARAMS . POOL_DEPOSIT ) )
129- . key_deposit ( CardanoWasm . BigNum . from_str ( CARDANO_PARAMS . KEY_DEPOSIT ) )
136+ . pool_deposit ( BigNum . from_str ( CARDANO_PARAMS . POOL_DEPOSIT ) )
137+ . key_deposit ( BigNum . from_str ( CARDANO_PARAMS . KEY_DEPOSIT ) )
130138 . coins_per_utxo_word (
131- CardanoWasm . BigNum . from_str ( CARDANO_PARAMS . COINS_PER_UTXO_WORD ) ,
139+ BigNum . from_str ( CARDANO_PARAMS . COINS_PER_UTXO_WORD ) ,
132140 )
133141 . max_value_size ( CARDANO_PARAMS . MAX_VALUE_SIZE )
134142 . max_tx_size ( CARDANO_PARAMS . MAX_TX_SIZE )
@@ -144,29 +152,29 @@ export class AdaService extends Service {
144152 ( u : any ) => ! u . amount . find ( ( a : any ) => a . unit !== 'lovelace' ) ,
145153 ) ;
146154
147- const unspentOutputs = CardanoWasm . TransactionUnspentOutputs . new ( ) ;
155+ const unspentOutputs = TransactionUnspentOutputs . new ( ) ;
148156 for ( const utxo of lovelaceUtxos ) {
149157 const amount = utxo . amount . find (
150158 ( a : any ) => a . unit === 'lovelace' ,
151159 ) ?. quantity ;
152160
153161 if ( ! amount ) continue ;
154162
155- const inputValue = CardanoWasm . Value . new (
156- CardanoWasm . BigNum . from_str ( amount . toString ( ) ) ,
163+ const inputValue = Value . new (
164+ BigNum . from_str ( amount . toString ( ) ) ,
157165 ) ;
158166
159- const input = CardanoWasm . TransactionInput . new (
160- CardanoWasm . TransactionHash . from_bytes ( Buffer . from ( utxo . tx_hash , 'hex' ) ) ,
167+ const input = TransactionInput . new (
168+ TransactionHash . from_bytes ( Buffer . from ( utxo . tx_hash , 'hex' ) ) ,
161169 utxo . output_index ,
162170 ) ;
163- const output = CardanoWasm . TransactionOutput . new ( Address . from_bech32 ( changeAddress ) , inputValue ) ;
164- unspentOutputs . add ( CardanoWasm . TransactionUnspentOutput . new ( input , output ) ) ;
171+ const output = TransactionOutput . new ( Address . from_bech32 ( changeAddress ) , inputValue ) ;
172+ unspentOutputs . add ( TransactionUnspentOutput . new ( input , output ) ) ;
165173 }
166174
167175 txBuilder . add_inputs_from (
168176 unspentOutputs ,
169- CardanoWasm . CoinSelectionStrategyCIP2 . LargestFirst ,
177+ CoinSelectionStrategyCIP2 . LargestFirst ,
170178 ) ;
171179
172180 // Outputs
@@ -247,7 +255,7 @@ export class AdaService extends Service {
247255 throw new InvalidIntegration ( `Could not retrieve fireblocks signer.` ) ;
248256 }
249257
250- const message = CardanoWasm . hash_transaction ( transaction . body ( ) ) . to_hex ( ) ;
258+ const message = hash_transaction ( transaction . body ( ) ) . to_hex ( ) ;
251259
252260 const payload = {
253261 rawMessageData : {
@@ -264,15 +272,15 @@ export class AdaService extends Service {
264272
265273 const fbTx = await this . fbSigner . signWithFB ( payload , this . testnet ? 'ADA_TEST' : 'ADA' ) ;
266274
267- const pubKey = CardanoWasm . PublicKey . from_hex ( fbTx . signedMessages ! [ 0 ] . publicKey ) ;
268- const vKey = CardanoWasm . Vkey . new ( pubKey ) ;
269- const signature = CardanoWasm . Ed25519Signature . from_hex ( fbTx . signedMessages ! [ 0 ] . signature . fullSig ) ;
270- const witnesses = CardanoWasm . TransactionWitnessSet . new ( ) ;
271- const vkeyWitnesses = CardanoWasm . Vkeywitnesses . new ( ) ;
272- const vkeyWitness = CardanoWasm . Vkeywitness . new ( vKey , signature ) ;
275+ const pubKey = PublicKey . from_hex ( fbTx . signedMessages ! [ 0 ] . publicKey ) ;
276+ const vKey = Vkey . new ( pubKey ) ;
277+ const signature = Ed25519Signature . from_hex ( fbTx . signedMessages ! [ 0 ] . signature . fullSig ) ;
278+ const witnesses = TransactionWitnessSet . new ( ) ;
279+ const vkeyWitnesses = Vkeywitnesses . new ( ) ;
280+ const vkeyWitness = Vkeywitness . new ( vKey , signature ) ;
273281 vkeyWitnesses . add ( vkeyWitness ) ;
274282 witnesses . set_vkeys ( vkeyWitnesses ) ;
275- return CardanoWasm . Transaction . new ( transaction . body ( ) , witnesses ) ;
283+ return Transaction . new ( transaction . body ( ) , witnesses ) ;
276284 }
277285
278286 /**
0 commit comments