1- import { Address , Transaction as ErdJsTransaction , TransactionHash , TransactionOptions , TransactionPayload , TransactionVersion } from "@multiversx/sdk-core/out" ;
2- import { Signature } from "@multiversx/sdk-core/out/signature" ;
1+ import { Address , Transaction as ErdJsTransaction , TransactionComputer } from "@multiversx/sdk-core/out" ;
32import { BinaryUtils } from "@multiversx/sdk-nestjs-common" ;
43import { CacheService } from "@multiversx/sdk-nestjs-cache" ;
54import { Injectable , Logger } from "@nestjs/common" ;
@@ -19,12 +18,14 @@ import { TransactionCreate } from "../transactions/entities/transaction.create";
1918@Injectable ( )
2019export class TransactionsBatchService {
2120 private readonly logger : Logger ;
21+ private readonly transactionComputer : TransactionComputer ;
2222
2323 constructor (
2424 private readonly cachingService : CacheService ,
2525 private readonly transactionService : TransactionService ,
2626 ) {
2727 this . logger = new Logger ( TransactionsBatchService . name ) ;
28+ this . transactionComputer = new TransactionComputer ( ) ;
2829 }
2930
3031 async startTransactionBatch ( batch : TransactionBatch , sourceIp : string ) : Promise < TransactionBatch > {
@@ -37,26 +38,26 @@ export class TransactionsBatchService {
3738 const tx = item . transaction . tx ;
3839
3940 const trans = new ErdJsTransaction ( {
40- nonce : tx . nonce ,
41- value : tx . value ,
41+ nonce : BigInt ( tx . nonce ) ,
42+ value : BigInt ( tx . value || 0 ) ,
4243 receiver : new Address ( tx . receiver ) ,
43- gasPrice : tx . gasPrice ,
44- gasLimit : tx . gasLimit ,
45- data : tx . data ? new TransactionPayload ( BinaryUtils . base64Decode ( tx . data ?? '' ) ) : undefined ,
44+ gasPrice : BigInt ( tx . gasPrice ) ,
45+ gasLimit : BigInt ( tx . gasLimit ) ,
46+ data : tx . data ? new Uint8Array ( Buffer . from ( BinaryUtils . base64Decode ( tx . data ?? '' ) , 'utf8' ) ) : new Uint8Array ( ) ,
4647 chainID : tx . chainID ,
47- version : new TransactionVersion ( tx . version ) ,
48- options : tx . options ? new TransactionOptions ( tx . options ) : undefined ,
48+ version : tx . version ,
49+ options : tx . options || 0 ,
4950 guardian : tx . guardian ? new Address ( tx . guardian ) : undefined ,
5051 sender : new Address ( tx . sender ) ,
5152 } ) ;
5253
5354 if ( tx . guardianSignature ) {
54- trans . applyGuardianSignature ( new Signature ( tx . guardianSignature ) ) ;
55+ trans . guardianSignature = new Uint8Array ( Buffer . from ( tx . guardianSignature , 'hex' ) ) ;
5556 }
5657
57- trans . applySignature ( new Signature ( tx . signature ) ) ;
58+ trans . signature = new Uint8Array ( Buffer . from ( tx . signature , 'hex' ) ) ;
5859
59- item . transaction . hash = TransactionHash . compute ( trans ) . toString ( ) ;
60+ item . transaction . hash = this . transactionComputer . computeTransactionHash ( trans ) ;
6061 }
6162 }
6263
0 commit comments