From 6fc6789033684adf93f9fe53c9b46dcf84757cf3 Mon Sep 17 00:00:00 2001 From: danielailie Date: Thu, 24 Jul 2025 16:11:02 +0300 Subject: [PATCH 1/5] Add actual implementation for load abi and load bytecode --- cookbook/cookbook.md | 111 +++++++++++++++++++++++++++++-------- cookbook/multisig.ts | 39 +++++++++---- cookbook/smartContracts.ts | 80 +++++++++++++++++++------- src/multisig/index.ts | 2 + 4 files changed, 179 insertions(+), 53 deletions(-) diff --git a/cookbook/cookbook.md b/cookbook/cookbook.md index 2225d758..5061375f 100644 --- a/cookbook/cookbook.md +++ b/cookbook/cookbook.md @@ -845,7 +845,7 @@ While interactions with the contract are possible without the ABI, they are much #### Loading the ABI from a file ```js { - let abiJson = await promises.readFile("../src/testData/adder.abi.json", { encoding: "utf8" }); + let abiJson = await fs.promises.readFile("../src/testData/adder.abi.json", { encoding: "utf8" }); let abiObj = JSON.parse(abiJson); let abi = Abi.create(abiObj); } @@ -916,9 +916,13 @@ This allows arguments to be passed as native Javascript values. If the ABI is no sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the contract bytecode - const bytecode = await promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); // load the abi file - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const controller = entrypoint.createSmartContractController(abi); @@ -954,8 +958,11 @@ let args = [new U32Value(42), "hello", { foo: "bar" }, new TokenIdentifierValue( ```js { // We use the transaction hash we got when broadcasting the transaction - - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const entrypoint = new DevnetEntrypoint(); const controller = entrypoint.createSmartContractController(abi); const outcome = await controller.awaitCompletedDeploy("txHash"); // waits for transaction completion and parses the result @@ -988,7 +995,7 @@ Even before broadcasting, at the moment you know the sender's address and the no { const entrypoint = new DevnetEntrypoint(); const factory = entrypoint.createSmartContractTransactionsFactory(); - const bytecode = await promises.readFile("../contracts/adder.wasm"); + const bytecode = await fs.promises.readFile("../contracts/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: let args: any[] = [new BigUIntValue(42)]; @@ -1021,7 +1028,7 @@ After the transaction is created the nonce needs to be properly set and the tran const factory = entrypoint.createSmartContractTransactionsFactory(); // load the contract bytecode - const bytecode = await promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: let args: any[] = [new BigUIntValue(42)]; @@ -1077,7 +1084,11 @@ In this section we'll see how we can call an endpoint of our previously deployed sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the abi file - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const controller = entrypoint.createSmartContractController(abi); const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); @@ -1129,7 +1140,11 @@ Both EGLD and ESDT tokens or a combination of both can be sent. This functionali sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the abi file - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // get the smart contracts controller const controller = entrypoint.createSmartContractController(abi); @@ -1219,7 +1234,11 @@ As said before, the `add` endpoint we called does not return anything, but we co { // load the abi file const entrypoint = new DevnetEntrypoint(); - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const parser = new SmartContractTransactionsOutcomeParser({ abi }); const txHash = "b3ae88ad05c464a74db73f4013de05abcfcb4fb6647c67a262a6cfdf330ef4a9"; const transactionOnNetwork = await entrypoint.getTransaction(txHash); @@ -1238,7 +1257,11 @@ First, we load the abi file, then we fetch the transaction, we extract the event { // load the abi files const entrypoint = new DevnetEntrypoint(); - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const parser = new TransactionEventsParser({ abi }); const txHash = "b3ae88ad05c464a74db73f4013de05abcfcb4fb6647c67a262a6cfdf330ef4a9"; const transactionOnNetwork = await entrypoint.getTransaction(txHash); @@ -1253,7 +1276,11 @@ Whenever needed, the contract ABI can be used for manually encoding or decoding Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/multiversx/mx-contracts-rs/tree/main/contracts/multisig) contract) into binary data. ```js { - const abi = await loadAbiRegistry("../src/testdata/multisig-full.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const paymentType = abi.getStruct("EsdtTokenPayment"); const codec = new BinaryCodec(); @@ -1272,7 +1299,11 @@ Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/ Now let's decode a struct using the ABI. ```js { - const abi = await loadAbiRegistry("../src/testdata/multisig-full.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const actionStructType = abi.getEnum("Action"); const data = Buffer.from( "0500000000000000000500d006f73c4221216fa679bc559005584c4f1160e569e1000000012a0000000003616464000000010000000107", @@ -1295,7 +1326,11 @@ In this example, we will query the **adder smart contract** by calling its `getS { const entrypoint = new DevnetEntrypoint(); const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the controller const controller = entrypoint.createSmartContractController(abi); @@ -1313,7 +1348,11 @@ This approach achieves the same result as the previous example. const entrypoint = new DevnetEntrypoint(); // load the abi - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // the contract address we'll query const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); @@ -1346,13 +1385,17 @@ However, in this case, the contract address is already known. Like deploying a s sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the abi - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the controller const controller = entrypoint.createSmartContractController(abi); // load the contract bytecode; this is the new contract code, the one we want to upgrade to - const bytecode = await promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: let args: any[] = [new U32Value(42)]; @@ -2646,8 +2689,12 @@ These operations can be performed using both the **controller** and the **factor #### Deploying a Multisig Smart Contract using the controller ```js { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); - const bytecode = await loadContractCode("src/testdata/multisig-full.wasm"); + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); + const bytecode = await fs.promises.readFile("src/testdata/multisig-full.wasm"); // create the entrypoint and the multisig controller const entrypoint = new DevnetEntrypoint(); @@ -2682,8 +2729,12 @@ These operations can be performed using both the **controller** and the **factor #### Deploying a Multisig Smart Contract using the factory ```js { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); - const bytecode = await loadContractCode("src/testdata/multisig-full.wasm"); + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); + const bytecode = await fs.promises.readFile("src/testdata/multisig-full.wasm"); // create the entrypoint and the multisig factory const entrypoint = new DevnetEntrypoint(); @@ -2718,9 +2769,13 @@ The id can be used later for signing and performing the proposal. ```js { + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the entrypoint and the multisig controller const entrypoint = new DevnetEntrypoint(); - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); const controller = entrypoint.createMultisigController(abi); const filePath = path.join("../src", "testdata", "testwallets", "alice.pem"); @@ -2755,7 +2810,11 @@ Proposing an action for a multisig contract using the MultisigFactory is very si ```js { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the entrypoint and the multisig factory const entrypoint = new DevnetEntrypoint(); @@ -2801,7 +2860,11 @@ Let's query the contract to get all board members. ```js { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the entrypoint and the multisig controller const entrypoint = new DevnetEntrypoint(); diff --git a/cookbook/multisig.ts b/cookbook/multisig.ts index c76ef873..cedd9c27 100644 --- a/cookbook/multisig.ts +++ b/cookbook/multisig.ts @@ -1,7 +1,6 @@ +import * as fs from "fs"; // md-ignore import path from "path"; // md-ignore -import { Account, Address, DevnetEntrypoint, TransactionWatcher } from "../src"; // md-ignore -import { MultisigTransactionsOutcomeParser } from "../src/multisig/multisigTransactionsOutcomeParser"; -import { loadAbiRegistry, loadContractCode } from "../src/testutils"; +import { Abi, Account, Address, DevnetEntrypoint, MultisigTransactionsOutcomeParser, TransactionWatcher } from "../src"; // md-ignore // md-start (async () => { // ### Multisig @@ -17,8 +16,12 @@ import { loadAbiRegistry, loadContractCode } from "../src/testutils"; // #### Deploying a Multisig Smart Contract using the controller // ```js { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); - const bytecode = await loadContractCode("src/testdata/multisig-full.wasm"); + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); + const bytecode = await fs.promises.readFile("src/testdata/multisig-full.wasm"); // create the entrypoint and the multisig controller // md-as-comment const entrypoint = new DevnetEntrypoint(); @@ -53,8 +56,12 @@ import { loadAbiRegistry, loadContractCode } from "../src/testutils"; // #### Deploying a Multisig Smart Contract using the factory // ```js { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); - const bytecode = await loadContractCode("src/testdata/multisig-full.wasm"); + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); + const bytecode = await fs.promises.readFile("src/testdata/multisig-full.wasm"); // create the entrypoint and the multisig factory // md-as-comment const entrypoint = new DevnetEntrypoint(); @@ -89,9 +96,13 @@ import { loadAbiRegistry, loadContractCode } from "../src/testutils"; // ```js { + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the entrypoint and the multisig controller // md-as-comment const entrypoint = new DevnetEntrypoint(); - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); const controller = entrypoint.createMultisigController(abi); const filePath = path.join("../src", "testdata", "testwallets", "alice.pem"); @@ -126,7 +137,11 @@ import { loadAbiRegistry, loadContractCode } from "../src/testutils"; // ```js { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the entrypoint and the multisig factory // md-as-comment const entrypoint = new DevnetEntrypoint(); @@ -172,7 +187,11 @@ import { loadAbiRegistry, loadContractCode } from "../src/testutils"; // ```js { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); + const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the entrypoint and the multisig controller // md-as-comment const entrypoint = new DevnetEntrypoint(); diff --git a/cookbook/smartContracts.ts b/cookbook/smartContracts.ts index 6118b60a..b01922bf 100644 --- a/cookbook/smartContracts.ts +++ b/cookbook/smartContracts.ts @@ -1,5 +1,5 @@ import axios from "axios"; // md-ignore -import { promises } from "fs"; // md-ignore +import * as fs from "fs"; // md-ignore import path from "path"; // md-ignore import { Abi, @@ -20,7 +20,6 @@ import { U32Value, U64Value, } from "../src"; // md-ignore -import { loadAbiRegistry } from "../src/testutils"; // md-start (async () => { // ### Smart Contracts @@ -33,7 +32,7 @@ import { loadAbiRegistry } from "../src/testutils"; // #### Loading the ABI from a file // ```js { - let abiJson = await promises.readFile("../src/testData/adder.abi.json", { encoding: "utf8" }); + let abiJson = await fs.promises.readFile("../src/testData/adder.abi.json", { encoding: "utf8" }); let abiObj = JSON.parse(abiJson); let abi = Abi.create(abiObj); } @@ -104,9 +103,13 @@ import { loadAbiRegistry } from "../src/testutils"; sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the contract bytecode - const bytecode = await promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); // load the abi file - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const controller = entrypoint.createSmartContractController(abi); @@ -142,8 +145,11 @@ import { loadAbiRegistry } from "../src/testutils"; // ```js { // We use the transaction hash we got when broadcasting the transaction - - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const entrypoint = new DevnetEntrypoint(); const controller = entrypoint.createSmartContractController(abi); const outcome = await controller.awaitCompletedDeploy("txHash"); // waits for transaction completion and parses the result @@ -176,7 +182,7 @@ import { loadAbiRegistry } from "../src/testutils"; { const entrypoint = new DevnetEntrypoint(); const factory = entrypoint.createSmartContractTransactionsFactory(); - const bytecode = await promises.readFile("../contracts/adder.wasm"); + const bytecode = await fs.promises.readFile("../contracts/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: // md-as-comment let args: any[] = [new BigUIntValue(42)]; @@ -209,7 +215,7 @@ import { loadAbiRegistry } from "../src/testutils"; const factory = entrypoint.createSmartContractTransactionsFactory(); // load the contract bytecode - const bytecode = await promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: // md-as-comment let args: any[] = [new BigUIntValue(42)]; @@ -265,7 +271,11 @@ import { loadAbiRegistry } from "../src/testutils"; sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the abi file - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const controller = entrypoint.createSmartContractController(abi); const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); @@ -317,7 +327,11 @@ import { loadAbiRegistry } from "../src/testutils"; sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the abi file - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // get the smart contracts controller const controller = entrypoint.createSmartContractController(abi); @@ -407,7 +421,11 @@ import { loadAbiRegistry } from "../src/testutils"; { // load the abi file const entrypoint = new DevnetEntrypoint(); - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const parser = new SmartContractTransactionsOutcomeParser({ abi }); const txHash = "b3ae88ad05c464a74db73f4013de05abcfcb4fb6647c67a262a6cfdf330ef4a9"; const transactionOnNetwork = await entrypoint.getTransaction(txHash); @@ -426,7 +444,11 @@ import { loadAbiRegistry } from "../src/testutils"; { // load the abi files const entrypoint = new DevnetEntrypoint(); - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const parser = new TransactionEventsParser({ abi }); const txHash = "b3ae88ad05c464a74db73f4013de05abcfcb4fb6647c67a262a6cfdf330ef4a9"; const transactionOnNetwork = await entrypoint.getTransaction(txHash); @@ -441,7 +463,11 @@ import { loadAbiRegistry } from "../src/testutils"; // Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/multiversx/mx-contracts-rs/tree/main/contracts/multisig) contract) into binary data. // ```js { - const abi = await loadAbiRegistry("../src/testdata/multisig-full.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const paymentType = abi.getStruct("EsdtTokenPayment"); const codec = new BinaryCodec(); @@ -460,7 +486,11 @@ import { loadAbiRegistry } from "../src/testutils"; // Now let's decode a struct using the ABI. // ```js { - const abi = await loadAbiRegistry("../src/testdata/multisig-full.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); const actionStructType = abi.getEnum("Action"); const data = Buffer.from( "0500000000000000000500d006f73c4221216fa679bc559005584c4f1160e569e1000000012a0000000003616464000000010000000107", @@ -483,7 +513,11 @@ import { loadAbiRegistry } from "../src/testutils"; { const entrypoint = new DevnetEntrypoint(); const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the controller const controller = entrypoint.createSmartContractController(abi); @@ -501,7 +535,11 @@ import { loadAbiRegistry } from "../src/testutils"; const entrypoint = new DevnetEntrypoint(); // load the abi - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // the contract address we'll query const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); @@ -534,13 +572,17 @@ import { loadAbiRegistry } from "../src/testutils"; sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the abi - const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); + const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + encoding: "utf8", + }); + const json = JSON.parse(jsonContent); + const abi = Abi.create(json); // create the controller const controller = entrypoint.createSmartContractController(abi); // load the contract bytecode; this is the new contract code, the one we want to upgrade to - const bytecode = await promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: // md-as-comment let args: any[] = [new U32Value(42)]; diff --git a/src/multisig/index.ts b/src/multisig/index.ts index 7af23fc9..f5aa16bb 100644 --- a/src/multisig/index.ts +++ b/src/multisig/index.ts @@ -1,3 +1,5 @@ +export * from "./multisigController"; export * from "./multisigTransactionsFactory"; +export * from "./multisigTransactionsOutcomeParser"; export * from "./proposeTransferExecuteContractInput"; export * from "./resources"; From 9a31c58449439280d96ce630f61f21eeabb28855 Mon Sep 17 00:00:00 2001 From: danielailie Date: Thu, 24 Jul 2025 16:19:12 +0300 Subject: [PATCH 2/5] Fix abi path --- cookbook/cookbook.md | 4 ++-- cookbook/smartContracts.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cookbook/cookbook.md b/cookbook/cookbook.md index 5061375f..b4b87b13 100644 --- a/cookbook/cookbook.md +++ b/cookbook/cookbook.md @@ -1276,7 +1276,7 @@ Whenever needed, the contract ABI can be used for manually encoding or decoding Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/multiversx/mx-contracts-rs/tree/main/contracts/multisig) contract) into binary data. ```js { - const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi", { encoding: "utf8", }); const json = JSON.parse(jsonContent); @@ -1299,7 +1299,7 @@ Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/ Now let's decode a struct using the ABI. ```js { - const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + const jsonContent: string = await fs.promises.readFile("../src/testdata//multisig-full.abi", { encoding: "utf8", }); const json = JSON.parse(jsonContent); diff --git a/cookbook/smartContracts.ts b/cookbook/smartContracts.ts index b01922bf..89fb1997 100644 --- a/cookbook/smartContracts.ts +++ b/cookbook/smartContracts.ts @@ -463,7 +463,7 @@ import { // Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/multiversx/mx-contracts-rs/tree/main/contracts/multisig) contract) into binary data. // ```js { - const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi", { encoding: "utf8", }); const json = JSON.parse(jsonContent); @@ -486,7 +486,7 @@ import { // Now let's decode a struct using the ABI. // ```js { - const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { + const jsonContent: string = await fs.promises.readFile("../src/testdata//multisig-full.abi", { encoding: "utf8", }); const json = JSON.parse(jsonContent); From bcabbddc77b7f64b55272c82cbe1ca9847663c62 Mon Sep 17 00:00:00 2001 From: danielailie Date: Fri, 25 Jul 2025 12:24:33 +0300 Subject: [PATCH 3/5] Fix documentation --- cookbook/cookbook.md | 55 +++++++++++++------------------------- cookbook/multisig.ts | 15 ++++------- cookbook/smartContracts.ts | 40 ++++++++++----------------- 3 files changed, 38 insertions(+), 72 deletions(-) diff --git a/cookbook/cookbook.md b/cookbook/cookbook.md index b4b87b13..5bf3b1fb 100644 --- a/cookbook/cookbook.md +++ b/cookbook/cookbook.md @@ -846,8 +846,7 @@ While interactions with the contract are possible without the ABI, they are much ```js { let abiJson = await fs.promises.readFile("../src/testData/adder.abi.json", { encoding: "utf8" }); - let abiObj = JSON.parse(abiJson); - let abi = Abi.create(abiObj); + const abi = Abi.create(JSON.parse(abiJson)); } ``` @@ -921,8 +920,7 @@ This allows arguments to be passed as native Javascript values. If the ABI is no const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const controller = entrypoint.createSmartContractController(abi); @@ -961,8 +959,7 @@ let args = [new U32Value(42), "hello", { foo: "bar" }, new TokenIdentifierValue( const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const entrypoint = new DevnetEntrypoint(); const controller = entrypoint.createSmartContractController(abi); const outcome = await controller.awaitCompletedDeploy("txHash"); // waits for transaction completion and parses the result @@ -1087,8 +1084,7 @@ In this section we'll see how we can call an endpoint of our previously deployed const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const controller = entrypoint.createSmartContractController(abi); const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); @@ -1143,8 +1139,7 @@ Both EGLD and ESDT tokens or a combination of both can be sent. This functionali const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // get the smart contracts controller const controller = entrypoint.createSmartContractController(abi); @@ -1237,8 +1232,7 @@ As said before, the `add` endpoint we called does not return anything, but we co const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const parser = new SmartContractTransactionsOutcomeParser({ abi }); const txHash = "b3ae88ad05c464a74db73f4013de05abcfcb4fb6647c67a262a6cfdf330ef4a9"; const transactionOnNetwork = await entrypoint.getTransaction(txHash); @@ -1260,8 +1254,7 @@ First, we load the abi file, then we fetch the transaction, we extract the event const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const parser = new TransactionEventsParser({ abi }); const txHash = "b3ae88ad05c464a74db73f4013de05abcfcb4fb6647c67a262a6cfdf330ef4a9"; const transactionOnNetwork = await entrypoint.getTransaction(txHash); @@ -1276,11 +1269,10 @@ Whenever needed, the contract ABI can be used for manually encoding or decoding Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/multiversx/mx-contracts-rs/tree/main/contracts/multisig) contract) into binary data. ```js { - const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi", { + const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const paymentType = abi.getStruct("EsdtTokenPayment"); const codec = new BinaryCodec(); @@ -1299,11 +1291,10 @@ Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/ Now let's decode a struct using the ABI. ```js { - const jsonContent: string = await fs.promises.readFile("../src/testdata//multisig-full.abi", { + const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const actionStructType = abi.getEnum("Action"); const data = Buffer.from( "0500000000000000000500d006f73c4221216fa679bc559005584c4f1160e569e1000000012a0000000003616464000000010000000107", @@ -1329,8 +1320,7 @@ In this example, we will query the **adder smart contract** by calling its `getS const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the controller const controller = entrypoint.createSmartContractController(abi); @@ -1351,8 +1341,7 @@ This approach achieves the same result as the previous example. const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // the contract address we'll query const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); @@ -1388,8 +1377,7 @@ However, in this case, the contract address is already known. Like deploying a s const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the controller const controller = entrypoint.createSmartContractController(abi); @@ -2692,8 +2680,7 @@ These operations can be performed using both the **controller** and the **factor const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const bytecode = await fs.promises.readFile("src/testdata/multisig-full.wasm"); // create the entrypoint and the multisig controller @@ -2732,8 +2719,7 @@ These operations can be performed using both the **controller** and the **factor const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const bytecode = await fs.promises.readFile("src/testdata/multisig-full.wasm"); // create the entrypoint and the multisig factory @@ -2772,8 +2758,7 @@ The id can be used later for signing and performing the proposal. const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the entrypoint and the multisig controller const entrypoint = new DevnetEntrypoint(); const controller = entrypoint.createMultisigController(abi); @@ -2813,8 +2798,7 @@ Proposing an action for a multisig contract using the MultisigFactory is very si const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the entrypoint and the multisig factory const entrypoint = new DevnetEntrypoint(); @@ -2863,8 +2847,7 @@ Let's query the contract to get all board members. const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the entrypoint and the multisig controller const entrypoint = new DevnetEntrypoint(); diff --git a/cookbook/multisig.ts b/cookbook/multisig.ts index cedd9c27..f552c388 100644 --- a/cookbook/multisig.ts +++ b/cookbook/multisig.ts @@ -19,8 +19,7 @@ import { Abi, Account, Address, DevnetEntrypoint, MultisigTransactionsOutcomePar const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const bytecode = await fs.promises.readFile("src/testdata/multisig-full.wasm"); // create the entrypoint and the multisig controller // md-as-comment @@ -59,8 +58,7 @@ import { Abi, Account, Address, DevnetEntrypoint, MultisigTransactionsOutcomePar const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const bytecode = await fs.promises.readFile("src/testdata/multisig-full.wasm"); // create the entrypoint and the multisig factory // md-as-comment @@ -99,8 +97,7 @@ import { Abi, Account, Address, DevnetEntrypoint, MultisigTransactionsOutcomePar const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the entrypoint and the multisig controller // md-as-comment const entrypoint = new DevnetEntrypoint(); const controller = entrypoint.createMultisigController(abi); @@ -140,8 +137,7 @@ import { Abi, Account, Address, DevnetEntrypoint, MultisigTransactionsOutcomePar const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the entrypoint and the multisig factory // md-as-comment const entrypoint = new DevnetEntrypoint(); @@ -190,8 +186,7 @@ import { Abi, Account, Address, DevnetEntrypoint, MultisigTransactionsOutcomePar const jsonContent: string = await fs.promises.readFile("src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the entrypoint and the multisig controller // md-as-comment const entrypoint = new DevnetEntrypoint(); diff --git a/cookbook/smartContracts.ts b/cookbook/smartContracts.ts index 89fb1997..480a470a 100644 --- a/cookbook/smartContracts.ts +++ b/cookbook/smartContracts.ts @@ -33,8 +33,7 @@ import { // ```js { let abiJson = await fs.promises.readFile("../src/testData/adder.abi.json", { encoding: "utf8" }); - let abiObj = JSON.parse(abiJson); - let abi = Abi.create(abiObj); + const abi = Abi.create(JSON.parse(abiJson)); } // ``` @@ -108,8 +107,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const controller = entrypoint.createSmartContractController(abi); @@ -148,8 +146,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const entrypoint = new DevnetEntrypoint(); const controller = entrypoint.createSmartContractController(abi); const outcome = await controller.awaitCompletedDeploy("txHash"); // waits for transaction completion and parses the result @@ -274,8 +271,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const controller = entrypoint.createSmartContractController(abi); const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); @@ -330,8 +326,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // get the smart contracts controller const controller = entrypoint.createSmartContractController(abi); @@ -424,8 +419,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const parser = new SmartContractTransactionsOutcomeParser({ abi }); const txHash = "b3ae88ad05c464a74db73f4013de05abcfcb4fb6647c67a262a6cfdf330ef4a9"; const transactionOnNetwork = await entrypoint.getTransaction(txHash); @@ -447,8 +441,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const parser = new TransactionEventsParser({ abi }); const txHash = "b3ae88ad05c464a74db73f4013de05abcfcb4fb6647c67a262a6cfdf330ef4a9"; const transactionOnNetwork = await entrypoint.getTransaction(txHash); @@ -463,11 +456,10 @@ import { // Let's encode a struct called EsdtTokenPayment (of [multisig](https://github.com/multiversx/mx-contracts-rs/tree/main/contracts/multisig) contract) into binary data. // ```js { - const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi", { + const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const paymentType = abi.getStruct("EsdtTokenPayment"); const codec = new BinaryCodec(); @@ -486,11 +478,10 @@ import { // Now let's decode a struct using the ABI. // ```js { - const jsonContent: string = await fs.promises.readFile("../src/testdata//multisig-full.abi", { + const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); const actionStructType = abi.getEnum("Action"); const data = Buffer.from( "0500000000000000000500d006f73c4221216fa679bc559005584c4f1160e569e1000000012a0000000003616464000000010000000107", @@ -516,8 +507,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the controller const controller = entrypoint.createSmartContractController(abi); @@ -538,8 +528,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // the contract address we'll query const contractAddress = Address.newFromBech32("erd1qqqqqqqqqqqqqpgq7cmfueefdqkjsnnjnwydw902v8pwjqy3d8ssd4meug"); @@ -575,8 +564,7 @@ import { const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", }); - const json = JSON.parse(jsonContent); - const abi = Abi.create(json); + const abi = Abi.create(JSON.parse(jsonContent)); // create the controller const controller = entrypoint.createSmartContractController(abi); From 5b875d80cb906b8f7ccf9939bf33bcabfd1822e0 Mon Sep 17 00:00:00 2001 From: danielailie Date: Fri, 25 Jul 2025 12:26:37 +0300 Subject: [PATCH 4/5] Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 90590dc9..2b5112cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@multiversx/sdk-core", - "version": "14.2.9", + "version": "15.0.0-beta.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@multiversx/sdk-core", - "version": "14.2.9", + "version": "15.0.0-beta.0", "license": "MIT", "dependencies": { "@multiversx/sdk-transaction-decoder": "1.0.2", diff --git a/package.json b/package.json index a93e045d..8b365aa6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@multiversx/sdk-core", - "version": "14.2.9", + "version": "15.0.0-beta.0", "description": "MultiversX SDK for JavaScript and TypeScript", "author": "MultiversX", "homepage": "https://multiversx.com", From 8d5f178ec02ae31a3fab2ebcf87bf89c11bf2250 Mon Sep 17 00:00:00 2001 From: danielailie Date: Fri, 25 Jul 2025 14:25:02 +0300 Subject: [PATCH 5/5] fix path inconsistency --- cookbook/cookbook.md | 8 ++++---- cookbook/smartContracts.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cookbook/cookbook.md b/cookbook/cookbook.md index 5bf3b1fb..1d912627 100644 --- a/cookbook/cookbook.md +++ b/cookbook/cookbook.md @@ -845,7 +845,7 @@ While interactions with the contract are possible without the ABI, they are much #### Loading the ABI from a file ```js { - let abiJson = await fs.promises.readFile("../src/testData/adder.abi.json", { encoding: "utf8" }); + let abiJson = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8" }); const abi = Abi.create(JSON.parse(abiJson)); } ``` @@ -915,7 +915,7 @@ This allows arguments to be passed as native Javascript values. If the ABI is no sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the contract bytecode - const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testdata/adder.wasm"); // load the abi file const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", @@ -1025,7 +1025,7 @@ After the transaction is created the nonce needs to be properly set and the tran const factory = entrypoint.createSmartContractTransactionsFactory(); // load the contract bytecode - const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testdata/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: let args: any[] = [new BigUIntValue(42)]; @@ -1383,7 +1383,7 @@ However, in this case, the contract address is already known. Like deploying a s const controller = entrypoint.createSmartContractController(abi); // load the contract bytecode; this is the new contract code, the one we want to upgrade to - const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testdata/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: let args: any[] = [new U32Value(42)]; diff --git a/cookbook/smartContracts.ts b/cookbook/smartContracts.ts index 480a470a..afe9bafb 100644 --- a/cookbook/smartContracts.ts +++ b/cookbook/smartContracts.ts @@ -32,7 +32,7 @@ import { // #### Loading the ABI from a file // ```js { - let abiJson = await fs.promises.readFile("../src/testData/adder.abi.json", { encoding: "utf8" }); + let abiJson = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8" }); const abi = Abi.create(JSON.parse(abiJson)); } // ``` @@ -102,7 +102,7 @@ import { sender.nonce = await entrypoint.recallAccountNonce(sender.address); // load the contract bytecode - const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testdata/adder.wasm"); // load the abi file const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { encoding: "utf8", @@ -212,7 +212,7 @@ import { const factory = entrypoint.createSmartContractTransactionsFactory(); // load the contract bytecode - const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testdata/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: // md-as-comment let args: any[] = [new BigUIntValue(42)]; @@ -570,7 +570,7 @@ import { const controller = entrypoint.createSmartContractController(abi); // load the contract bytecode; this is the new contract code, the one we want to upgrade to - const bytecode = await fs.promises.readFile("../src/testData/adder.wasm"); + const bytecode = await fs.promises.readFile("../src/testdata/adder.wasm"); // For deploy arguments, use "TypedValue" objects if you haven't provided an ABI to the factory: // md-as-comment let args: any[] = [new U32Value(42)];