Skip to content

Commit 3700c5f

Browse files
committed
update API to sdk-core
1 parent abd2efd commit 3700c5f

File tree

4 files changed

+57
-20
lines changed

4 files changed

+57
-20
lines changed

package-lock.json

Lines changed: 42 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"dependencies": {
8787
"@aws-sdk/client-s3": "^3.54.0",
8888
"@golevelup/nestjs-rabbitmq": "^4.0.0",
89-
"@multiversx/sdk-core": "^13.2.2",
89+
"@multiversx/sdk-core": "^15.0.0",
9090
"@multiversx/sdk-exchange": "^0.2.21",
9191
"@multiversx/sdk-nestjs-auth": "6.0.0",
9292
"@multiversx/sdk-nestjs-cache": "6.0.0",

src/common/protocol/protocol.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class ProtocolService {
9393
}
9494

9595
const shardCount = await this.getShardCount();
96-
const addressHex = new Address(address).hex();
96+
const addressHex = new Address(address).toHex();
9797

9898
return AddressUtils.computeShard(addressHex, shardCount);
9999
}

src/endpoints/transactions.batch/transactions.batch.service.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
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";
32
import { BinaryUtils } from "@multiversx/sdk-nestjs-common";
43
import { CacheService } from "@multiversx/sdk-nestjs-cache";
54
import { Injectable, Logger } from "@nestjs/common";
@@ -19,12 +18,14 @@ import { TransactionCreate } from "../transactions/entities/transaction.create";
1918
@Injectable()
2019
export 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

Comments
 (0)