Skip to content

Cookbook: Add actual implementation for load abi and load bytecode - #646

Merged
danielailie merged 5 commits into
feat/nextfrom
TOOL-647-update-documentation-for-load-abi-and-contract-code
Jul 25, 2025
Merged

Cookbook: Add actual implementation for load abi and load bytecode#646
danielailie merged 5 commits into
feat/nextfrom
TOOL-647-update-documentation-for-load-abi-and-contract-code

Conversation

@danielailie

Copy link
Copy Markdown
Contributor

No description provided.

@danielailie danielailie self-assigned this Jul 24, 2025
@andreibancioiu
andreibancioiu requested a review from Copilot July 24, 2025 13:15

This comment was marked as outdated.

@andreibancioiu
andreibancioiu requested a review from Copilot July 24, 2025 13:30

This comment was marked as outdated.

andreibancioiu
andreibancioiu previously approved these changes Jul 24, 2025
Comment thread cookbook/smartContracts.ts Outdated
Comment on lines +519 to +520
const json = JSON.parse(jsonContent);
const abi = Abi.create(json);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we are in the cookbook, we can also use a one-liner:

const abi = Abi.create(JSON.parse(jsonContent));

Comment thread src/multisig/index.ts
@@ -1,3 +1,5 @@
export * from "./multisigController";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

popenta
popenta previously approved these changes Jul 25, 2025
andreibancioiu
andreibancioiu previously approved these changes Jul 25, 2025
@andreibancioiu
andreibancioiu requested a review from Copilot July 25, 2025 09:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces test utility functions with direct file system operations for loading ABI files and bytecode, making the cookbook examples self-contained without external test utilities. The changes include a version bump to 15.0.0-beta.0 and new exports from the multisig module.

Key changes:

  • Replace loadAbiRegistry() and loadContractCode() test utilities with direct fs.promises.readFile() calls
  • Update import statements to use fs module instead of test utilities
  • Add new exports for multisig controller and outcome parser

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/multisig/index.ts Adds exports for multisigController and multisigTransactionsOutcomeParser
package.json Bumps version from 14.2.9 to 15.0.0-beta.0
cookbook/smartContracts.ts Replaces test utility functions with direct fs operations for ABI/bytecode loading
cookbook/multisig.ts Replaces test utility functions with direct fs operations for ABI/bytecode loading
cookbook/cookbook.md Updates documentation to reflect the new fs-based approach

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", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Suggested change
const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", {
const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", {

Copilot uses AI. Check for mistakes.
// 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", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Suggested change
const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", {
const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", {

Copilot uses AI. Check for mistakes.

// 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", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Copilot uses AI. Check for mistakes.

// 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", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Suggested change
const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", {
const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", {

Copilot uses AI. Check for mistakes.
// 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", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Suggested change
const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", {
const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", {

Copilot uses AI. Check for mistakes.
// ```js
{
const abi = await loadAbiRegistry("../src/testdata/multisig-full.abi.json");
const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Suggested change
const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", {
const jsonContent: string = await fs.promises.readFile("../src/testData/multisig-full.abi.json", {

Copilot uses AI. Check for mistakes.
// ```js
{
const abi = await loadAbiRegistry("../src/testdata/multisig-full.abi.json");
const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Suggested change
const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", {
const jsonContent: string = await fs.promises.readFile("../src/testData/multisig-full.abi.json", {

Copilot uses AI. Check for mistakes.
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", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Suggested change
const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", {
const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", {

Copilot uses AI. Check for mistakes.

// load the abi
const abi = await loadAbiRegistry("../src/testdata/adder.abi.json");
const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Suggested change
const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", {
const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", {

Copilot uses AI. Check for mistakes.

// load the abi
const abi = await loadAbiRegistry("../src/testdata/adder.abi.json");
const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", {

Copilot AI Jul 25, 2025

Copy link

Choose a reason for hiding this comment

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

Inconsistent path casing: this uses 'testdata' (lowercase) while other occurrences in the same file use 'testData' (camelCase). This could cause file not found errors on case-sensitive file systems.

Copilot uses AI. Check for mistakes.
@andreibancioiu andreibancioiu changed the title Add actual implementation for load abi and load bytecode Cookbook: Add actual implementation for load abi and load bytecode Jul 25, 2025
@danielailie
danielailie dismissed stale reviews from andreibancioiu and popenta via 8d5f178 July 25, 2025 11:25
@danielailie
danielailie merged commit 8a7adf9 into feat/next Jul 25, 2025
@danielailie
danielailie deleted the TOOL-647-update-documentation-for-load-abi-and-contract-code branch July 25, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants