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
17 changes: 9 additions & 8 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.1",
"version": "14.0.0-beta.0",
"description": "MultiversX SDK for JavaScript and TypeScript",
"author": "MultiversX",
"homepage": "https://multiversx.com",
Expand Down
11 changes: 4 additions & 7 deletions src/abi/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SmartContractQueryResponse } from "../core/smartContractQuery";
import { Token, TokenTransfer } from "../core/tokens";
import { Transaction } from "../core/transaction";
import { SmartContractController } from "../smartContracts";
import { loadAbiRegistry, MockNetworkProvider, setupUnitTestWatcherTimeouts } from "../testutils";
import { loadAbiRegistry, MockNetworkProvider } from "../testutils";
import { getTestWalletsPath } from "../testutils/utils";
import { ContractFunction } from "./function";
import { Interaction } from "./interaction";
Expand Down Expand Up @@ -204,8 +204,7 @@ describe("test smart contract interactor", function () {
});

it("should interact with 'answer'", async function () {
setupUnitTestWatcherTimeouts();

this.timeout(30000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains unit tests - we can skip setting the timeout.

let abiRegistry = await loadAbiRegistry("src/testdata/answer.abi.json");
let contract = new SmartContract({ address: dummyAddress, abi: abiRegistry });
let controller = new SmartContractController({ chainID: "D", networkProvider: provider, abi: abiRegistry });
Expand Down Expand Up @@ -270,8 +269,7 @@ describe("test smart contract interactor", function () {
});

it("should interact with 'counter'", async function () {
setupUnitTestWatcherTimeouts();

this.timeout(30000);
let abi = await loadAbiRegistry("src/testdata/counter.abi.json");
let contract = new SmartContract({ address: dummyAddress, abi: abi });
let controller = new SmartContractController({ chainID: "D", networkProvider: provider, abi: abi });
Expand Down Expand Up @@ -339,8 +337,7 @@ describe("test smart contract interactor", function () {
});

it("should interact with 'lottery-esdt'", async function () {
setupUnitTestWatcherTimeouts();

this.timeout(30000);
let abiRegistry = await loadAbiRegistry("src/testdata/lottery-esdt.abi.json");
let contract = new SmartContract({ address: dummyAddress, abi: abiRegistry });
let controller = new SmartContractController({ chainID: "D", networkProvider: provider, abi: abiRegistry });
Expand Down
27 changes: 10 additions & 17 deletions src/abi/smartContract.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ describe("test on local testnet", function () {
bob = await Account.newFromPem(`${getTestWalletsPath()}/bob.pem`);
carol = await Account.newFromPem(`${getTestWalletsPath()}/carol.pem`);

watcher = new TransactionWatcher({
getTransaction: async (hash: string) => {
return await provider.getTransaction(hash);
watcher = new TransactionWatcher(
{
getTransaction: async (hash: string) => {
return await provider.getTransaction(hash);
},
},
});
{
pollingIntervalMilliseconds: 5000,
timeoutMilliseconds: 50000,
},
);
parser = new SmartContractTransactionsOutcomeParser();
});

it("counter: should deploy, then simulate transactions using SmartContractTransactionsFactory", async function () {
this.timeout(60000);

TransactionWatcher.DefaultPollingInterval = 5000;
TransactionWatcher.DefaultTimeout = 50000;

let network = await provider.getNetworkConfig();

const config = new TransactionsFactoryConfig({ chainID: network.chainID });
Expand Down Expand Up @@ -121,9 +124,6 @@ describe("test on local testnet", function () {
it("counter: should deploy, call and query contract using SmartContractTransactionsFactory", async function () {
this.timeout(80000);

TransactionWatcher.DefaultPollingInterval = 5000;
TransactionWatcher.DefaultTimeout = 50000;

let network = await provider.getNetworkConfig();

const config = new TransactionsFactoryConfig({ chainID: network.chainID });
Expand Down Expand Up @@ -187,9 +187,6 @@ describe("test on local testnet", function () {
it("erc20: should deploy, call and query contract using SmartContractTransactionsFactory", async function () {
this.timeout(60000);

TransactionWatcher.DefaultPollingInterval = 5000;
TransactionWatcher.DefaultTimeout = 50000;

let network = await provider.getNetworkConfig();

const config = new TransactionsFactoryConfig({ chainID: network.chainID });
Expand Down Expand Up @@ -277,10 +274,6 @@ describe("test on local testnet", function () {

it("lottery: should deploy, call and query contract using SmartContractTransactionsFactory", async function () {
this.timeout(60000);

TransactionWatcher.DefaultPollingInterval = 5000;
TransactionWatcher.DefaultTimeout = 50000;

let network = await provider.getNetworkConfig();
alice.nonce = (await provider.getAccount(alice.address)).nonce;

Expand Down
26 changes: 13 additions & 13 deletions src/abi/smartContract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import { Address } from "../core/address";
import { TransactionComputer } from "../core/transactionComputer";
import { TransactionStatus } from "../core/transactionStatus";
import { TransactionWatcher } from "../core/transactionWatcher";
import {
getTestWalletsPath,
MarkCompleted,
MockNetworkProvider,
setupUnitTestWatcherTimeouts,
Wait,
} from "../testutils";
import { getTestWalletsPath, MarkCompleted, MockNetworkProvider, Wait } from "../testutils";
import { Code } from "./code";
import { ContractFunction } from "./function";
import { SmartContract } from "./smartContract";
Expand Down Expand Up @@ -41,8 +35,10 @@ describe("test contract", () => {
});

it("should deploy", async () => {
setupUnitTestWatcherTimeouts();
let watcher = new TransactionWatcher(provider);
let watcher = new TransactionWatcher(provider, {
pollingIntervalMilliseconds: 42,
timeoutMilliseconds: 42 * 42,
});

let contract = new SmartContract();
let deployTransaction = contract.deploy({
Expand Down Expand Up @@ -87,8 +83,10 @@ describe("test contract", () => {
});

it("should call", async () => {
setupUnitTestWatcherTimeouts();
let watcher = new TransactionWatcher(provider);
let watcher = new TransactionWatcher(provider, {
pollingIntervalMilliseconds: 42,
timeoutMilliseconds: 42 * 42,
});

let contract = new SmartContract({
address: new Address("erd1qqqqqqqqqqqqqpgqak8zt22wl2ph4tswtyc39namqx6ysa2sd8ss4xmlj3"),
Expand Down Expand Up @@ -154,8 +152,10 @@ describe("test contract", () => {
});

it("should upgrade", async () => {
setupUnitTestWatcherTimeouts();
let watcher = new TransactionWatcher(provider);
let watcher = new TransactionWatcher(provider, {
pollingIntervalMilliseconds: 42,
timeoutMilliseconds: 42 * 42,
});

let contract = new SmartContract();
contract.setAddress(Address.newFromBech32("erd1qqqqqqqqqqqqqpgq3ytm9m8dpeud35v3us20vsafp77smqghd8ss4jtm0q"));
Expand Down
20 changes: 10 additions & 10 deletions src/abi/smartContractResults.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ describe("fetch transactions from local testnet", function () {

before(async function () {
alice = await Account.newFromPem(`${getTestWalletsPath()}/alice.pem`);
watcher = new TransactionWatcher({
getTransaction: async (hash: string) => {
return await provider.getTransaction(hash);
watcher = new TransactionWatcher(
{
getTransaction: async (hash: string) => {
return await provider.getTransaction(hash);
},
},
});
{
pollingIntervalMilliseconds: 5000,
timeoutMilliseconds: 50000,
},
);

parser = new SmartContractTransactionsOutcomeParser();
});

it("counter smart contract", async function () {
this.timeout(60000);

TransactionWatcher.DefaultPollingInterval = 5000;
TransactionWatcher.DefaultTimeout = 50000;

let network = await provider.getNetworkConfig();
alice.nonce = (await provider.getAccount(alice.address)).nonce;

Expand Down Expand Up @@ -78,9 +81,6 @@ describe("fetch transactions from local testnet", function () {
it("interact with counter smart contract using SmartContractTransactionsFactory", async function () {
this.timeout(60000);

TransactionWatcher.DefaultPollingInterval = 5000;
TransactionWatcher.DefaultTimeout = 50000;

let network = await provider.getNetworkConfig();

const config = new TransactionsFactoryConfig({ chainID: network.chainID });
Expand Down
25 changes: 20 additions & 5 deletions src/accountManagement/accountController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IAccount } from "../accounts/interfaces";
import { Address } from "../core";
import { Transaction } from "../core/transaction";
import { TransactionComputer } from "../core/transactionComputer";
import { TransactionsFactoryConfig } from "../core/transactionsFactoryConfig";
Expand All @@ -19,10 +20,12 @@ export class AccountController {
async createTransactionForSavingKeyValue(
sender: IAccount,
nonce: bigint,
options: SaveKeyValueInput,
options: SaveKeyValueInput & { guardian?: Address; relayer?: Address },
): Promise<Transaction> {
const transaction = this.factory.createTransactionForSavingKeyValue(sender.address, options);

transaction.guardian = options.guardian ?? Address.empty();
transaction.relayer = options.relayer ?? Address.empty();
transaction.nonce = nonce;
transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction));

Expand All @@ -32,28 +35,40 @@ export class AccountController {
async createTransactionForSettingGuardian(
sender: IAccount,
nonce: bigint,
options: SetGuardianInput,
options: SetGuardianInput & { guardian?: Address; relayer?: Address },
): Promise<Transaction> {
const transaction = this.factory.createTransactionForSettingGuardian(sender.address, options);

transaction.guardian = options.guardian ?? Address.empty();
transaction.relayer = options.relayer ?? Address.empty();
transaction.nonce = nonce;
transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction));

return transaction;
}

async createTransactionForGuardingAccount(sender: IAccount, nonce: bigint): Promise<Transaction> {
async createTransactionForGuardingAccount(
sender: IAccount,
nonce: bigint,
options: { relayer?: Address },
): Promise<Transaction> {
const transaction = this.factory.createTransactionForGuardingAccount(sender.address);

transaction.relayer = options.relayer ?? Address.empty();
transaction.nonce = nonce;
transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction));

return transaction;
}

async createTransactionForUnguardingAccount(sender: IAccount, nonce: bigint): Promise<Transaction> {
async createTransactionForUnguardingAccount(
sender: IAccount,
nonce: bigint,
options: { guardian: Address; relayer?: Address },
): Promise<Transaction> {
const transaction = this.factory.createTransactionForUnguardingAccount(sender.address);

transaction.guardian = options.guardian ?? Address.empty();
transaction.relayer = options.relayer ?? Address.empty();
transaction.nonce = nonce;
transaction.signature = await sender.sign(this.txComputer.computeBytesForSigning(transaction));

Expand Down
Loading
Loading