v0.15.0
Summary
whatsabi.providers.WithCachedCode
Added helper for caching getCode
calls with autoload
, useful for only resolving proxies when we already have the bytecode:
const address = "0x...";
const bytecode = "0x..."; // Already loaded from somewhere
const cachedCodeProvider = whatsabi.providers.WithCachedCode(provider, {
[address]: bytecode,
});
const result = whatsabi.autoload(address, {
provider: cachedCodeProvider,
abiLoader: false, // Skip ABI loaders
signatureLookup: false, // Skip looking up selector signatures
})
More docs here: https://shazow.github.io/whatsabi/modules/proxies.html
AutoloadResult.abiLoadedFrom
whatsabi.autoload
will do everything necessary to load the ABI, which by default includes checking if it's already verified in public databases like Sourcify and Etherscan.
If the result is successfully loaded from an ABILoader
, then it will be included in the AutoloadResult.abiLoadedFrom
property. This is useful to distinguish if the result is from a verified database or whether WhatsABI had to resolve to doing its own internal static analysis to find selectors.
const result = whatsabi.autoload(address, config);
const loadedFrom = result.abiLoadedFrom?.name ?? "static analysis";
console.log("ABI loaded from:", loadedFrom);
More docs here: https://shazow.github.io/whatsabi/types/AutoloadResult.html
AutoloadResult.ContractResult
If we call whatsabi.autoload
with setting { loadContractResult: true }
, then we'll use the getContract
loader APIs instead of loadABI
which returns the full contract metadata (larger result and slower API call). The result will be included in the contractResult
attribute, which also includes the full raw result in AutoloadResult.contractResult?.loaderResult
.
const result = whatsabi.autoload(address, { provider, loadContractResult: true });
console.log(result.contractResult);
More docs here: https://shazow.github.io/whatsabi/types/loaders.ContractResult.html
What's Changed
- src/loaders.ts: Add devdoc and userdoc support for SourcifyABILoader by @yohamta in #116
- src/loader.ts: Add fallback for contract name in SourcifyABILoader by @yohamta in #121
- loaders: Add AutoloadResult.abiLoadedFrom and plumb the result through MultiABILoader by @shazow in #122
- Improve devex for only resolving proxies by @shazow in #120
- loaders: Add loaderResult, remove {userdoc,devdoc} by @shazow in #127
- loaders: Enhance
ContractResult.loaderResult
type by @yohamta in #128 - autoload: AutoloadResult.ContractResult by @shazow in #131
New Contributors
Full Changelog: v0.14.1...v0.15.0