Skip to content

Commit

Permalink
feat(abi): add the option to use a literal abi string (#423)
Browse files Browse the repository at this point in the history
* feat(abi): add the option to use a literal abi string
* fix(abi): add trim when checking for abi
  • Loading branch information
mjlescano authored Sep 10, 2023
1 parent 3a5decd commit 3287cd1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/builder/src/steps/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,19 @@ export default {

// override abi?
if (config.abi) {
const implContract = getContractDefinitionFromPath(ctx, config.abi);
if (config.abi.trimStart().startsWith('[')) {
// Allow to pass in a literal abi string
abi = JSON.parse(config.abi);
} else {
// Load the abi from another contract
const implContract = getContractDefinitionFromPath(ctx, config.abi);

if (!implContract) {
throw new Error(`previously deployed contract with name ${config.abi} for abi not found`);
}
if (!implContract) {
throw new Error(`previously deployed contract with name ${config.abi} for abi not found`);
}

abi = implContract.abi;
abi = implContract.abi;
}
} else if (config.abiOf) {
abi = getMergedAbiFromContractPaths(ctx, config.abiOf);
}
Expand Down

0 comments on commit 3287cd1

Please sign in to comment.