Skip to content

Commit

Permalink
Reference newer network providers & wallet (dev-dependencies, for tes…
Browse files Browse the repository at this point in the history
…ts).
  • Loading branch information
andreibancioiu committed Mar 21, 2024
1 parent ae3e389 commit c72db77
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 44 deletions.
28 changes: 14 additions & 14 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"keccak": "3.0.2"
},
"devDependencies": {
"@multiversx/sdk-network-providers": "2.3.0",
"@multiversx/sdk-wallet": "4.2.0",
"@multiversx/sdk-network-providers": "2.4.0",
"@multiversx/sdk-wallet": "4.4.0",
"@types/assert": "1.4.6",
"@types/chai": "4.2.11",
"@types/mocha": "9.1.0",
Expand Down
8 changes: 4 additions & 4 deletions src/message.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from "chai";
import { Message, MessageComputer } from "./message";
import { loadTestWallets, TestWallet } from "./testutils";
import { UserVerifier } from "@multiversx/sdk-wallet";
import { assert } from "chai";
import { DEFAULT_MESSAGE_VERSION } from "./constants";
import { Message, MessageComputer } from "./message";
import { TestWallet, loadTestWallets } from "./testutils";

describe("test message", () => {
let alice: TestWallet;
Expand Down Expand Up @@ -35,7 +35,7 @@ describe("test message", () => {
address: alice.getAddress(),
});

message.signature = await alice.signer.sign(Buffer.from(messageComputer.computeBytesForSigning(message)));
message.signature = await alice.signer.sign(messageComputer.computeBytesForSigning(message));

assert.equal(
Buffer.from(message.signature).toString("hex"),
Expand Down
4 changes: 1 addition & 3 deletions src/transaction.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ describe("test transaction", function () {
transaction.nonce = BigInt(alice.account.nonce.valueOf());

const transactionComputer = new TransactionComputer();
transaction.signature = await alice.signer.sign(
Buffer.from(transactionComputer.computeBytesForSigning(transaction)),
);
transaction.signature = await alice.signer.sign(transactionComputer.computeBytesForSigning(transaction));

const txHash = await provider.sendTransaction(transaction);
await watcher.awaitCompleted(txHash);
Expand Down
8 changes: 3 additions & 5 deletions src/transaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { ProtoSerializer } from "./proto";
import { TestWallet, loadTestWallets } from "./testutils";
import { TokenTransfer } from "./tokenTransfer";
import { Transaction } from "./transaction";
import { TransactionPayload } from "./transactionPayload";
import { TransactionComputer } from "./transactionComputer";
import { TransactionPayload } from "./transactionPayload";

describe("test transaction", async () => {
let wallets: Record<string, TestWallet>;
Expand Down Expand Up @@ -129,7 +129,7 @@ describe("test transaction", async () => {
});

transaction.signature = await wallets.carol.signer.sign(
Buffer.from(transactionComputer.computeBytesForSigning(transaction)),
transactionComputer.computeBytesForSigning(transaction),
);

assert.equal(
Expand Down Expand Up @@ -382,9 +382,7 @@ describe("test transaction", async () => {
guardian: "erd1x23lzn8483xs2su4fak0r0dqx6w38enpmmqf2yrkylwq7mfnvyhsxqw57y",
});
transaction.guardianSignature = new Uint8Array(64);
transaction.signature = new Uint8Array(
await alice.signer.sign(Buffer.from(transactionComputer.computeBytesForSigning(transaction))),
);
transaction.signature = await alice.signer.sign(transactionComputer.computeBytesForSigning(transaction));

const serializer = new ProtoSerializer();
const buffer = serializer.serializeTransaction(transaction);
Expand Down
32 changes: 16 additions & 16 deletions src/transactionsFactories/relayedTransactionsFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assert } from "chai";
import { TestWallet, loadTestWallets } from "../testutils";
import { Transaction } from "../transaction";
import { TransactionComputer } from "../transactionComputer";
import { RelayedTransactionsFactory } from "./relayedTransactionsFactory";
import { TransactionsFactoryConfig } from "./transactionsFactoryConfig";
import { TransactionComputer } from "../transactionComputer";

describe("test relayed v1 transaction builder", function () {
const config = new TransactionsFactoryConfig({ chainID: "T" });
Expand Down Expand Up @@ -49,7 +49,7 @@ describe("test relayed v1 transaction builder", function () {
});

const serializedInnerTransaction = transactionComputer.computeBytesForSigning(innerTransaction);
innerTransaction.signature = await bob.signer.sign(Buffer.from(serializedInnerTransaction));
innerTransaction.signature = await bob.signer.sign(serializedInnerTransaction);

const relayedTransaction = factory.createRelayedV1Transaction({
innerTransaction: innerTransaction,
Expand All @@ -58,7 +58,7 @@ describe("test relayed v1 transaction builder", function () {
relayedTransaction.nonce = 2627n;

const serializedRelayedTransaction = transactionComputer.computeBytesForSigning(relayedTransaction);
relayedTransaction.signature = await alice.signer.sign(Buffer.from(serializedRelayedTransaction));
relayedTransaction.signature = await alice.signer.sign(serializedRelayedTransaction);

assert.equal(
Buffer.from(relayedTransaction.data).toString(),
Expand All @@ -83,7 +83,7 @@ describe("test relayed v1 transaction builder", function () {
});

const serializedInnerTransaction = transactionComputer.computeBytesForSigning(innerTransaction);
innerTransaction.signature = await carol.signer.sign(Buffer.from(serializedInnerTransaction));
innerTransaction.signature = await carol.signer.sign(serializedInnerTransaction);

const relayedTransaction = factory.createRelayedV1Transaction({
innerTransaction: innerTransaction,
Expand All @@ -92,7 +92,7 @@ describe("test relayed v1 transaction builder", function () {
relayedTransaction.nonce = 715n;

const serializedRelayedTransaction = transactionComputer.computeBytesForSigning(relayedTransaction);
relayedTransaction.signature = await frank.signer.sign(Buffer.from(serializedRelayedTransaction));
relayedTransaction.signature = await frank.signer.sign(serializedRelayedTransaction);

assert.equal(
Buffer.from(relayedTransaction.data).toString(),
Expand All @@ -117,7 +117,7 @@ describe("test relayed v1 transaction builder", function () {
});

const serializedInnerTransaction = transactionComputer.computeBytesForSigning(innerTransaction);
innerTransaction.signature = await carol.signer.sign(Buffer.from(serializedInnerTransaction));
innerTransaction.signature = await carol.signer.sign(serializedInnerTransaction);

const relayedTransaction = factory.createRelayedV1Transaction({
innerTransaction: innerTransaction,
Expand All @@ -126,7 +126,7 @@ describe("test relayed v1 transaction builder", function () {
relayedTransaction.nonce = 715n;

const serializedRelayedTransaction = transactionComputer.computeBytesForSigning(relayedTransaction);
relayedTransaction.signature = await frank.signer.sign(Buffer.from(serializedRelayedTransaction));
relayedTransaction.signature = await frank.signer.sign(serializedRelayedTransaction);

assert.equal(
Buffer.from(relayedTransaction.data).toString(),
Expand All @@ -152,8 +152,8 @@ describe("test relayed v1 transaction builder", function () {
});

const serializedInnerTransaction = transactionComputer.computeBytesForSigning(innerTransaction);
innerTransaction.signature = await bob.signer.sign(Buffer.from(serializedInnerTransaction));
innerTransaction.guardianSignature = await grace.signer.sign(Buffer.from(serializedInnerTransaction));
innerTransaction.signature = await bob.signer.sign(serializedInnerTransaction);
innerTransaction.guardianSignature = await grace.signer.sign(serializedInnerTransaction);

const relayedTransaction = factory.createRelayedV1Transaction({
innerTransaction: innerTransaction,
Expand All @@ -162,7 +162,7 @@ describe("test relayed v1 transaction builder", function () {
relayedTransaction.nonce = 2627n;

const serializedRelayedTransaction = transactionComputer.computeBytesForSigning(relayedTransaction);
relayedTransaction.signature = await alice.signer.sign(Buffer.from(serializedRelayedTransaction));
relayedTransaction.signature = await alice.signer.sign(serializedRelayedTransaction);

assert.equal(
Buffer.from(relayedTransaction.data).toString(),
Expand All @@ -188,8 +188,8 @@ describe("test relayed v1 transaction builder", function () {
});

const serializedInnerTransaction = transactionComputer.computeBytesForSigning(innerTransaction);
innerTransaction.signature = await bob.signer.sign(Buffer.from(serializedInnerTransaction));
innerTransaction.guardianSignature = await grace.signer.sign(Buffer.from(serializedInnerTransaction));
innerTransaction.signature = await bob.signer.sign(serializedInnerTransaction);
innerTransaction.guardianSignature = await grace.signer.sign(serializedInnerTransaction);

const relayedTransaction = factory.createRelayedV1Transaction({
innerTransaction: innerTransaction,
Expand All @@ -200,8 +200,8 @@ describe("test relayed v1 transaction builder", function () {
relayedTransaction.guardian = frank.address.bech32();

const serializedRelayedTransaction = transactionComputer.computeBytesForSigning(relayedTransaction);
relayedTransaction.signature = await alice.signer.sign(Buffer.from(serializedRelayedTransaction));
relayedTransaction.guardianSignature = await frank.signer.sign(Buffer.from(serializedRelayedTransaction));
relayedTransaction.signature = await alice.signer.sign(serializedRelayedTransaction);
relayedTransaction.guardianSignature = await frank.signer.sign(serializedRelayedTransaction);

assert.equal(
Buffer.from(relayedTransaction.data).toString(),
Expand Down Expand Up @@ -255,7 +255,7 @@ describe("test relayed v1 transaction builder", function () {
});

const serializedInnerTransaction = transactionComputer.computeBytesForSigning(innerTransaction);
innerTransaction.signature = await bob.signer.sign(Buffer.from(serializedInnerTransaction));
innerTransaction.signature = await bob.signer.sign(serializedInnerTransaction);

const relayedTransaction = factory.createRelayedV2Transaction({
innerTransaction: innerTransaction,
Expand All @@ -265,7 +265,7 @@ describe("test relayed v1 transaction builder", function () {
relayedTransaction.nonce = 37n;

const serializedRelayedTransaction = transactionComputer.computeBytesForSigning(relayedTransaction);
relayedTransaction.signature = await alice.signer.sign(Buffer.from(serializedRelayedTransaction));
relayedTransaction.signature = await alice.signer.sign(serializedRelayedTransaction);

assert.equal(relayedTransaction.version, 2);
assert.equal(relayedTransaction.options, 0);
Expand Down

0 comments on commit c72db77

Please sign in to comment.