@@ -44,52 +44,9 @@ sepolia.rpcUrls.default.http[0] = 'https://sepolia.gateway.tenderly.co';
4444// @ts -ignore
4545sepolia . rpcUrls . public . http [ 0 ] = 'https://sepolia.gateway.tenderly.co' ;
4646
47- const arbiscanApiKey = loadApiKey ( 'ARBISCAN_API_KEY' ) ;
48- const arbiscanNovaApiKey = loadApiKey ( 'ARBISCAN_NOVA_API_KEY' ) ;
49- const etherscanApiKey = loadApiKey ( 'ETHERSCAN_API_KEY' ) ;
50- const basescanApikey = loadApiKey ( 'BASESCAN_API_KEY' ) ;
51-
52- const blockExplorerApiUrls : Record < ParentChainId , { url : string ; apiKey : string } > = {
53- // mainnet L1
54- [ mainnet . id ] : {
55- url : 'https://api.etherscan.io/api' ,
56- apiKey : etherscanApiKey ,
57- } ,
58- // mainnet L2
59- [ arbitrumOne . id ] : {
60- url : 'https://api.arbiscan.io/api' ,
61- apiKey : arbiscanApiKey ,
62- } ,
63- [ arbitrumNova . id ] : {
64- url : 'https://api-nova.arbiscan.io/api' ,
65- apiKey : arbiscanNovaApiKey ,
66- } ,
67- [ base . id ] : {
68- url : 'https://api.basescan.org/api' ,
69- apiKey : basescanApikey ,
70- } ,
71- // testnet L1
72- [ sepolia . id ] : {
73- url : 'https://api-sepolia.etherscan.io/api' ,
74- apiKey : etherscanApiKey ,
75- } ,
76- // testnet L2
77- [ arbitrumSepolia . id ] : {
78- url : 'https://api-sepolia.arbiscan.io/api' ,
79- apiKey : arbiscanApiKey ,
80- } ,
81- [ baseSepolia . id ] : {
82- url : 'https://api-sepolia.basescan.org/api' ,
83- apiKey : basescanApikey ,
84- } ,
85- // local nitro-testnode / fine to omit these as we skip abi fetch
86- [ nitroTestnodeL1 . id ] : { url : '' , apiKey : '' } ,
87- [ nitroTestnodeL2 . id ] : { url : '' , apiKey : '' } ,
88- } ;
47+ const apiKey = loadApiKey ( 'ETHERSCAN_API_KEY' ) ;
8948
9049export async function fetchAbi ( chainId : ParentChainId , address : `0x${string } `) {
91- const { url, apiKey } = blockExplorerApiUrls [ chainId ] ;
92-
9350 const client = createPublicClient ( {
9451 chain : chains . find ( ( chain ) => chain . id === chainId ) ,
9552 transport : http ( ) ,
@@ -104,7 +61,7 @@ export async function fetchAbi(chainId: ParentChainId, address: `0x${string}`) {
10461
10562 const responseJson = await (
10663 await fetch (
107- `${ url } ? module=contract&action=getabi&format=raw&address=${ address } &apikey=${ apiKey } ` ,
64+ `https://api.etherscan.io/v2/api?chainid= ${ chainId } & module=contract&action=getabi&format=raw&address=${ address } &apikey=${ apiKey } ` ,
10865 )
10966 ) . json ( ) ;
11067
@@ -226,7 +183,10 @@ export async function assertContractAbisMatch(contract: ContractConfig) {
226183 ) ;
227184 } )
228185 // fetch abis for all chains and hash them
229- . map ( async ( [ chainId , address ] ) => {
186+ . map ( async ( [ chainId , address ] , index ) => {
187+ // sleep to avoid rate limiting
188+ await sleep ( index * 500 ) ;
189+
230190 const abi = await fetchAbi ( Number ( chainId ) as ParentChainId , address ) ;
231191 const abiHash = hashMessage ( JSON . stringify ( abi ) ) ;
232192
@@ -287,7 +247,7 @@ export default async function () {
287247 plugins : [
288248 etherscan ( {
289249 chainId : arbitrumSepolia . id ,
290- apiKey : arbiscanApiKey ,
250+ apiKey,
291251 // todo: fix viem type issue
292252 contracts : [ contract ] ,
293253 cacheDuration : 0 ,
0 commit comments