Minor Changes
-
9d6eaa4Thanks @jwahdatehagh! - Correctness, robustness, and API hardening across the SDK.Fixes
- Sourcify v2: request the valid
runtimeBytecodefield instead ofdeployedBytecode(which the live API rejects with HTTP 400) and surfaceruntimeBytecode.onchainBytecodeasdeployedBytecode. Field selectors are validated against the known v2 field list (buildSourcifyFields,SOURCIFY_V2_FIELDS). - Repository source: chain-aware lookups —
contracts/{chainId}/{address}.jsonfirst with a flat-layout fallback; documents with a mismatchedchainIdare discarded; malformed JSON shapes (arrays, non-stringincludes) return null instead of crashingget(). merge/mergeNatspecDocsskip__proto__,constructor, andprototypekeys (prototype-pollution hardening).- ENS names are lowercased before the
.ethcheck and hashing, soVitalik.eth/VITALIK.ETHresolve correctly. - Diamond facets: NatSpec methods and derived actions are filtered to mounted selectors so unmounted facet functions can't inject actions.
- Multi-target proxy
metadataLayeris now first-target-wins, consistent with the NatSpec merge. - On-chain
name()/symbol()fill uses the bytes32-aware, sanitizing token decoder (fixes MKR/SAI-style tokens; hostile values are capped/stripped). - Calldata matching treats a missing
call.valueas0for locked value constraints. - Event/error key validation flags truncated and uppercase hex keys; the action signature grammar accepts
$identifiers, aligned betweenactions.tsandvalidate.ts. - Mixed-case addresses are EIP-55 checksum-validated and rejected with
InvalidAddressErroron mismatch.
Robustness
- JSON-RPC calls carry a 10s abort timeout.
includesresolution only followshttps:URLs; the schema base is configurable (schemaBaseUrl, defaulthttps://evmnow.github.io/contract-metadata/v1).resolveUricaps response bodies at ~1 MB and recognizes thedata:application/json;charset=utf-8,variant.- Sourcify responses are shape-validated (non-object bodies, non-record natspec, non-array ABIs).
New options & API
ContractClientConfig:schemaBaseUrl,cache(per-client memoization + in-flight dedup of repository/Sourcify fetches, default on),ensResolver(custom ENS Universal Resolver address).- New error classes:
InvalidAddressError,ChainIdMismatchError,ContractClientConfigError. - New exports:
filterSourcifyBySelectors,buildSourcifyFields,SOURCIFY_V2_FIELDS,decodeSymbol,sanitizeSymbol,normalizeEnsName,UNIVERSAL_RESOLVER,AbiItem. - New subpath exports:
./actions,./natspec,./interfaces/detect,./interfaces/erc20,./interfaces/erc721,./package.json. ContractResult.abi,ProxyResolution.compositeAbi,TargetInfo.abi, andSourcifyResult.abiare now typed asAbiItem[]instead ofunknown[].- Token info resolver fetches
decimals()andsymbol()concurrently.
- Sourcify v2: request the valid