Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-core",
"version": "13.17.0",
"version": "13.17.1",
"description": "MultiversX SDK for JavaScript and TypeScript",
"author": "MultiversX",
"homepage": "https://multiversx.com",
Expand Down
38 changes: 38 additions & 0 deletions src/networkProviders/providers.dev.net.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { AxiosHeaders } from "axios";
import { assert } from "chai";
import { Address } from "../address";
import { loadTestWallet } from "../testutils";
import { MockQuery } from "../testutils/dummyQuery";
import { TransactionComputer } from "../transactionComputer";
import { ApiNetworkProvider } from "./apiNetworkProvider";
import { INetworkProvider, ITransactionNext } from "./interface";
import { ProxyNetworkProvider } from "./proxyNetworkProvider";
Expand Down Expand Up @@ -192,6 +194,42 @@ describe("test network providers on devnet: Proxy and API", function () {
proxyResponse.decimals = 0;
}

it("should be able to send transaction with relayer", async function () {
this.timeout(5000);
const grace = await loadTestWallet("grace");
const relayer = await loadTestWallet("alice");
const transactionComputer = new TransactionComputer();
const nonce = (await apiProvider.getAccount(grace.getAddress())).nonce;
const transaction: ITransactionNext = {
receiver: grace.getAddress().bech32(),
sender: grace.getAddress().bech32(),
gasPrice: BigInt(1000000000),
gasLimit: BigInt(150000),
chainID: "D",
version: 1,
nonce: BigInt(nonce),
relayer: relayer.getAddress(),
value: BigInt(1),
senderUsername: "",
receiverUsername: "",
guardian: "",
guardianSignature: new Uint8Array(),
options: 0,
data: new Uint8Array(),
signature: new Uint8Array(),
relayerSignature: new Uint8Array(),
};
transaction.signature = await grace.signer.sign(transactionComputer.computeBytesForSigning(transaction));

const buffer = transactionComputer.computeBytesForSigning(transaction);

const signature = await relayer.signer.sign(Buffer.from(buffer));
transaction.relayerSignature = signature;

const hash = await proxyProvider.sendTransaction(transaction);
assert.isNotNull(hash);
});

it("should be able to send transaction(s)", async function () {
this.timeout(5000);

Expand Down
5 changes: 5 additions & 0 deletions src/networkProviders/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export function prepareTransactionForBroadcasting(transaction: ITransaction | IT
version: transaction.version,
options: transaction.options,
guardian: transaction.guardian || undefined,
relayer: transaction.relayer.toBech32() || undefined,
relayerSignature:
transaction.relayerSignature.length === 0
? undefined
: Buffer.from(transaction.relayerSignature).toString("hex"),
signature: Buffer.from(transaction.signature).toString("hex"),
guardianSignature:
transaction.guardianSignature.length === 0
Expand Down
Loading