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 22dd257
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 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,11 +119,16 @@ export async function autoload(address: string, config: AutoloadConfig): Promise
}

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

if (!config.enableExperimentalMetadata) {
result.abi = stripUnreliableABI(result.abi);
onProgress("abiFromBytecode", {address});
if (config.abiFromBytecode) {
result.abi = await config.abiFromBytecode(bytecode);
} else {
result.abi = abiFromBytecode(program);

// We only strip if our default abiFromBytecode function is used.
if (!config.enableExperimentalMetadata) {
result.abi = stripUnreliableABI(result.abi);
}
}

let signatureLookup = config.signatureLookup;
Expand Down

0 comments on commit 22dd257

Please sign in to comment.