Releases: shazow/whatsabi
v0.18.0
Summary
- Minor breaking change: Backwards-compatible signature change of
loaders.ContractResult
, making more fields optional: evmVersion, compilerVersion, runs. This makes it so that we can express a simple loadABIresult as agetContract` result with missing fields. - Added EtherscanV2 and AnyABI loaders (not used by default yet).
What's Changed
- Adding AnyABI loader by @k-thornton in #156
- Adding EtherscanV2 by @k-thornton in #158
- The error status is inside err.cause by @k-thornton in #160
- (includes 3 above PRs) loaders: add AnyABI, Etherscan v2; change ContractResult by @shazow in #163
- tests: Improve loader tests, add no-result checks by @shazow in #161
Full Changelog: v0.17.0...v0.18.0
v0.17.0
Summary
- Switched from ethers.js to Ox as our utility library (mainly for things like encoding/decoding ABIs).
- Reduced the bundle size from 15.34kb ➡ 13.87kb (before new features below).
- Big thanks to @jxom for the hands-on support.
- Added Blockscout ABI loader.
- Big thanks to @yohamta for doing this work!
// Make a MultiABILoader that includes BlockscoutABILoader
const abiLoader = new whatsabi.loaders.MultiABILoader([
new whatsabi.loaders.SourcifyABILoader(),
new whatsabi.loaders.EtherscanABILoader({
apiKey: "...", // Replace the value with your Etherscan API key
}),
new whatsabi.loaders.BlockscoutABILoader({
apiKey: "...", // Replace the value with your Blockscout API key
}),
]);
{
// Can use it separately
const result = await loader.getContract("0x7a250d5630b4cf539739df2c5dacb4c659f2488d");
}
{
// Or let autoload use it for us
const result = whatsabi.autoload(address, { provider, abiLoader });
}
What's Changed
- autoload: Add
abiFillEmptyNames
helper by @yohamta in #150 - ethers.js -> ox by @shazow in #153
- chore: prepare = false by @jxom in #154
- loaders: Add Blockscout ABI support by @yohamta in #152
Full Changelog: v0.16.0...v0.17.0
v0.16.0
Summary
- Improved whatsabi's disassembly so that it's more precise about where the runnable code section is. This helps reduce false positives, and improves finding proxy slots pulled in from the data section using
CODECOPY
. - Added
AutoloadResult.isFactory
when aCREATE
orCREATE2
opcode is detected. This means that some of the results could be attributed to bytecode that is deployed by the factory, rather than the factory itself. That said, false positives like this should be further mitigated by the previous improvement! - Deduplicated experimental event results.
What's Changed
- autoload: Add AutoloadResult.isFactory by @shazow in #144
- disasm: Detect code boundary and look for slots in aux data by @shazow in #129
- src/disasm.ts: Use Set for eventCandidates to avoid dupes by @shazow in #147
Full Changelog: v0.15.4...v0.16.0
v0.15.4
v0.15.3
v0.15.2
v0.15.1
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
v0.14.1
Minor fix: Added exported whatsabi.errors
types: https://shazow.github.io/whatsabi/modules/whatsabi.errors.html
Full Changelog: v0.14.0...v0.14.1
v0.14.0
Summary
- New and improved docs! https://shazow.github.io/whatsabi/
- Typed errors! Errors thrown by WhatsABI code will be wrapped in
WhatsABIError
and more fine-grained errors, to help with better error handling. - Improved viem support! Now handling any kind of viem client or transport (before we only worked with publicClient objects).
- Added source code loading of verified contracts to our loaders! Supporting both Etherscan and Sourcify.
What's Changed
- Add svvy.sh to readme by @roninjin10 in #97
- Add typed errors by @shazow in #100
- providers: Fix viem non-public clients, wrap autoload ENS error by @shazow in #107
- Add generated docs by @shazow in #108
- loaders: Add getSources() to ContractResult by @shazow in #112
New Contributors
- @roninjin10 made their first contribution in #97
Full Changelog: v0.13.2...v0.14.0