Skip to content

Commit 572911a

Browse files
authored
Merge pull request #562 from multiversx/TOOL-438-fix-relayed-v-3-bug
Tool 438 fix relayed v 3 bug
2 parents 3fe389c + 8ea8045 commit 572911a

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
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": "13.17.0",
3+
"version": "13.17.1",
44
"description": "MultiversX SDK for JavaScript and TypeScript",
55
"author": "MultiversX",
66
"homepage": "https://multiversx.com",

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { AxiosHeaders } from "axios";
22
import { assert } from "chai";
33
import { Address } from "../address";
4+
import { loadTestWallet } from "../testutils";
45
import { MockQuery } from "../testutils/dummyQuery";
6+
import { TransactionComputer } from "../transactionComputer";
57
import { ApiNetworkProvider } from "./apiNetworkProvider";
68
import { INetworkProvider, ITransactionNext } from "./interface";
79
import { ProxyNetworkProvider } from "./proxyNetworkProvider";
@@ -192,6 +194,42 @@ describe("test network providers on devnet: Proxy and API", function () {
192194
proxyResponse.decimals = 0;
193195
}
194196

197+
it("should be able to send transaction with relayer", async function () {
198+
this.timeout(5000);
199+
const grace = await loadTestWallet("grace");
200+
const relayer = await loadTestWallet("alice");
201+
const transactionComputer = new TransactionComputer();
202+
const nonce = (await apiProvider.getAccount(grace.getAddress())).nonce;
203+
const transaction: ITransactionNext = {
204+
receiver: grace.getAddress().bech32(),
205+
sender: grace.getAddress().bech32(),
206+
gasPrice: BigInt(1000000000),
207+
gasLimit: BigInt(150000),
208+
chainID: "D",
209+
version: 1,
210+
nonce: BigInt(nonce),
211+
relayer: relayer.getAddress(),
212+
value: BigInt(1),
213+
senderUsername: "",
214+
receiverUsername: "",
215+
guardian: "",
216+
guardianSignature: new Uint8Array(),
217+
options: 0,
218+
data: new Uint8Array(),
219+
signature: new Uint8Array(),
220+
relayerSignature: new Uint8Array(),
221+
};
222+
transaction.signature = await grace.signer.sign(transactionComputer.computeBytesForSigning(transaction));
223+
224+
const buffer = transactionComputer.computeBytesForSigning(transaction);
225+
226+
const signature = await relayer.signer.sign(Buffer.from(buffer));
227+
transaction.relayerSignature = signature;
228+
229+
const hash = await proxyProvider.sendTransaction(transaction);
230+
assert.isNotNull(hash);
231+
});
232+
195233
it("should be able to send transaction(s)", async function () {
196234
this.timeout(5000);
197235

src/networkProviders/transactions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export function prepareTransactionForBroadcasting(transaction: ITransaction | IT
2828
version: transaction.version,
2929
options: transaction.options,
3030
guardian: transaction.guardian || undefined,
31+
relayer: transaction.relayer.toBech32() || undefined,
32+
relayerSignature:
33+
transaction.relayerSignature.length === 0
34+
? undefined
35+
: Buffer.from(transaction.relayerSignature).toString("hex"),
3136
signature: Buffer.from(transaction.signature).toString("hex"),
3237
guardianSignature:
3338
transaction.guardianSignature.length === 0

0 commit comments

Comments
 (0)