Cookbook: Add actual implementation for load abi and load bytecode - #646
Conversation
| const json = JSON.parse(jsonContent); | ||
| const abi = Abi.create(json); |
There was a problem hiding this comment.
Since we are in the cookbook, we can also use a one-liner:
const abi = Abi.create(JSON.parse(jsonContent));
| @@ -1,3 +1,5 @@ | |||
| export * from "./multisigController"; | |||
There was a problem hiding this comment.
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()andloadContractCode()test utilities with directfs.promises.readFile()calls - Update import statements to use
fsmodule 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", { |
There was a problem hiding this comment.
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.
| const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { | |
| const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", { |
| // 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", { |
There was a problem hiding this comment.
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.
| const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { | |
| const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", { |
|
|
||
| // 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", { |
There was a problem hiding this comment.
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.
|
|
||
| // 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", { |
There was a problem hiding this comment.
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.
| const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { | |
| const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", { |
| // 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", { |
There was a problem hiding this comment.
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.
| const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { | |
| const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", { |
| // ```js | ||
| { | ||
| const abi = await loadAbiRegistry("../src/testdata/multisig-full.abi.json"); | ||
| const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", { |
There was a problem hiding this comment.
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.
| 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", { |
| // ```js | ||
| { | ||
| const abi = await loadAbiRegistry("../src/testdata/multisig-full.abi.json"); | ||
| const jsonContent: string = await fs.promises.readFile("../src/testdata/multisig-full.abi.json", { |
There was a problem hiding this comment.
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.
| 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", { |
| 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", { |
There was a problem hiding this comment.
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.
| const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { | |
| const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", { |
|
|
||
| // load the abi | ||
| const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); | ||
| const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { |
There was a problem hiding this comment.
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.
| const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { | |
| const jsonContent: string = await fs.promises.readFile("../src/testData/adder.abi.json", { |
|
|
||
| // load the abi | ||
| const abi = await loadAbiRegistry("../src/testdata/adder.abi.json"); | ||
| const jsonContent: string = await fs.promises.readFile("../src/testdata/adder.abi.json", { |
There was a problem hiding this comment.
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.
No description provided.