Skip to content

Commit b2b4087

Browse files
authored
Merge pull request #604 from multiversx/TOOL-563-fix-result-parsing-based-on-provider
Update smart contract result data parsing
2 parents 1ac54a4 + f249972 commit b2b4087

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 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
@@ -1,6 +1,6 @@
11
{
22
"name": "@multiversx/sdk-core",
3-
"version": "14.0.3",
3+
"version": "14.0.4",
44
"description": "MultiversX SDK for JavaScript and TypeScript",
55
"author": "MultiversX",
66
"homepage": "https://multiversx.com",

src/core/transactionOnNetwork.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ export class TransactionOnNetwork {
7676
const result = TransactionOnNetwork.fromHttpResponse(txHash, response);
7777
result.smartContractResults =
7878
response.smartContractResults?.map(
79-
(result: Partial<SmartContractResult>) =>
79+
(result: any) =>
8080
new SmartContractResult({
8181
...result,
8282
receiver: result.receiver ? new Address(result.receiver) : undefined,
8383
sender: result.sender ? new Address(result.sender) : undefined,
84+
data: Buffer.from(result.data ?? "", "utf-8"),
8485
raw: result,
8586
}),
8687
) ?? [];
@@ -142,11 +143,12 @@ export class TransactionOnNetwork {
142143
const result = TransactionOnNetwork.fromHttpResponse(txHash, response);
143144
result.smartContractResults =
144145
response.results?.map(
145-
(result: Partial<SmartContractResult>) =>
146+
(result: any) =>
146147
new SmartContractResult({
147148
...result,
148149
receiver: result.receiver ? new Address(result.receiver) : undefined,
149150
sender: result.sender ? new Address(result.sender) : undefined,
151+
data: Buffer.from(result.data ?? "", "base64"),
150152
raw: result,
151153
}),
152154
) ?? [];
@@ -167,7 +169,6 @@ export class TransactionOnNetwork {
167169
result.gasPrice = BigInt(response.gasPrice) || 0n;
168170
result.gasLimit = BigInt(response.gasLimit) || 0n;
169171
result.function = response.function || "";
170-
result.data = Buffer.from(response.data || "", "base64");
171172
result.version = response.version || 1;
172173
result.options = response.options || 0;
173174
result.data = Buffer.from(response.data || "", "base64");

src/networkProviders/apiNetworkProvider.dev.net.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe("ApiNetworkProvider Tests", function () {
162162
assert.isTrue(transaction.status.isCompleted());
163163
});
164164

165-
it("should fetch smart contract invoking transaction", async () => {
165+
it("should fetch smart contract invoking transaction with expected data", async () => {
166166
const transaction = await apiProvider.getTransaction(
167167
"6fe05e4ca01d42c96ae5182978a77fe49f26bcc14aac95ad4f19618173f86ddb",
168168
);
@@ -175,6 +175,10 @@ describe("ApiNetworkProvider Tests", function () {
175175
"issue@54455354546f6b656e@54455354@016345785d8a0000@06@63616e4368616e67654f776e6572@74727565@63616e55706772616465@74727565@63616e4164645370656369616c526f6c6573@74727565",
176176
),
177177
);
178+
assert.deepEqual(
179+
transaction.smartContractResults[0].data,
180+
Buffer.from("ESDTSetBurnRoleForAll@544553542d666631353565"),
181+
);
178182
assert.equal(Buffer.from(transaction.logs.events[0].topics[0]).toString("hex"), "544553542d666631353565");
179183
assert.equal(Buffer.from(transaction.logs.events[0].topics[1]).toString("hex"), "");
180184
assert.equal(Buffer.from(transaction.logs.events[0].topics[2]).toString("hex"), "63616e4368616e67654f776e6572");

src/networkProviders/proxyNetworkProvider.dev.net.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe("ProxyNetworkProvider Tests", function () {
168168
assert.isTrue(transaction.status.isCompleted());
169169
});
170170

171-
it("should fetch smart contract invoking transaction", async () => {
171+
it("should fetch smart contract invoking transaction with expected data", async () => {
172172
const transaction = await proxy.getTransaction(
173173
"6fe05e4ca01d42c96ae5182978a77fe49f26bcc14aac95ad4f19618173f86ddb",
174174
);
@@ -181,6 +181,10 @@ describe("ProxyNetworkProvider Tests", function () {
181181
"issue@54455354546f6b656e@54455354@016345785d8a0000@06@63616e4368616e67654f776e6572@74727565@63616e55706772616465@74727565@63616e4164645370656369616c526f6c6573@74727565",
182182
),
183183
);
184+
assert.deepEqual(
185+
transaction.smartContractResults[0].data,
186+
Buffer.from("ESDTSetBurnRoleForAll@544553542d666631353565"),
187+
);
184188
assert.equal(Buffer.from(transaction.logs.events[0].topics[0]).toString("hex"), "544553542d666631353565");
185189
assert.equal(Buffer.from(transaction.logs.events[0].topics[1]).toString("hex"), "");
186190
assert.equal(Buffer.from(transaction.logs.events[0].topics[2]).toString("hex"), "63616e4368616e67654f776e6572");

0 commit comments

Comments
 (0)