Conversation
| ) { | ||
| const chainId = referenceChain.id; | ||
|
|
||
| await assertContractAbisMatch({ name, address }); |
There was a problem hiding this comment.
What about returning the abi from assertContractAbisMatch if they match and remove every else in this function ?
There was a problem hiding this comment.
I agree there's a bit of duplicated work here (fetching ABI for the same contract multiple times), but I wanted to keep assertContractAbisMatch to do just that and nothing else. I'm not too worried about optimizing for number of calls since this is run extremely rarely.
| const primaryImplementation = await getImplementation({ client, address }); | ||
| const primaryAbi: Abi = await fetchAbi(chainId, primaryImplementation); | ||
|
|
||
| const secondaryImplementation = await getImplementation({ |
There was a problem hiding this comment.
If the rollup contract is the only one having a secondary implementation, might be worth to handle it with a special condition and save all the unnecessary calls for other contracts.
There was a problem hiding this comment.
Addressed in 6e7b166. I added a check for name !== 'Rollup' in case we ever add other core contracts.
Summary
Refactors the ABI generation logic out of
wagmi.config.tsinto a dedicatedwagmi.generate.tsfile with a custom wagmi plugin, replacing the patched@wagmi/clietherscan plugin.Motivation
Previously,
wagmi.config.tscontained all ABI fetching, proxy resolution, and contract validation logic inline, and relied on a patch to@wagmi/clito work around etherscan rate limiting and proxy resolution. This made the file large and hard to follow, as different contract types (factories, precompiles, core contracts) were handled through a mix of conditionals in a single code path.What changed
@wagmi/clipatch (patches/@wagmi+cli+1.5.2.patch) -- ABI fetching is now handled directly rather than through the patched etherscan plugin.wagmi.generate.ts-- a custom wagmi plugin with agenerate()function that auto-detects the contract type and delegates to the appropriate handler:generateAbiForFactoryContract-- ForRollupCreatorandTokenBridgeCreator. These are proxies deployed on every parent chain. Resolves each chain's implementation address, fetches the implementation ABI, and asserts all ABIs match across chains.generateAbiForPrecompileContract-- ForArbOwner,ArbGasInfo, etc. These have a fixed address on every Arbitrum chain and are not proxies. Simply fetches the ABI from the reference chain.generateAbiForCoreContract-- ForRollupandSequencerInbox. These are proxies from example deployments. Resolves primary (and optionally secondary) implementation addresses and merges their ABIs. The Rollup contract's dual-proxy pattern (RollupAdminLogic + RollupUserLogic) is handled here.fetchAbiis now a pure block explorer fetch -- proxy-to-implementation resolution is handled explicitly by each code path rather than being buried insidefetchAbi.wagmi.config.ts-- now only defines the contract list and loops through it, delegating all generation logic to the plugin.as constto address exports.