Skip to content

Commit

Permalink
autoload: Fix onProgress label, add abiFromBytecode override
Browse files Browse the repository at this point in the history
  • Loading branch information
shazow committed Oct 17, 2023
1 parent cb1d397 commit d8bb770
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type AutoloadResult = {
export type AutoloadConfig = {
provider: AnyProvider;

abiFromBytecode?: (bytecode: string) => Promise<ABI>;
abiLoader?: ABILoader|false;
signatureLookup?: SignatureLookup|false;

Expand Down Expand Up @@ -118,8 +119,12 @@ export async function autoload(address: string, config: AutoloadConfig): Promise
}

// Load from code
onProgress("getCode", {address});
result.abi = abiFromBytecode(program);
onProgress("abiFromBytecode", {address});
if (config.abiFromBytecode) {
result.abi = await config.abiFromBytecode(bytecode);
} else {
result.abi = abiFromBytecode(program);
}

if (!config.enableExperimentalMetadata) {
result.abi = stripUnreliableABI(result.abi);
Expand Down

0 comments on commit d8bb770

Please sign in to comment.