File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -257,16 +257,24 @@ const loadAbiFromBlockScout = async (network, address) =>
257
257
} ,
258
258
)
259
259
260
+ const getEtherscanLikeAPIUrl = ( network ) => {
261
+ switch ( network ) {
262
+ case "mainnet" : return `https://api.etherscan.io/api` ;
263
+ case "bsc" : return `https://api.bscscan.com/api` ;
264
+ case "matic" : return `https://api.polygonscan.com/api` ;
265
+ default : return `https://api-${ network } .etherscan.io/api` ;
266
+ }
267
+ }
268
+
260
269
const loadAbiFromEtherscan = async ( network , address ) =>
261
270
await withSpinner (
262
271
`Fetching ABI from Etherscan` ,
263
272
`Failed to fetch ABI from Etherscan` ,
264
273
`Warnings while fetching ABI from Etherscan` ,
265
274
async spinner => {
275
+ const scanApiUrl = getEtherscanLikeAPIUrl ( network ) ;
266
276
let result = await fetch (
267
- `https://${
268
- network === 'mainnet' ? 'api' : `api-${ network } `
269
- } .etherscan.io/api?module=contract&action=getabi&address=${ address } `,
277
+ `${ scanApiUrl } ?module=contract&action=getabi&address=${ address } ` ,
270
278
)
271
279
let json = await result . json ( )
272
280
You can’t perform that action at this time.
0 commit comments