File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed
packages/ethereum-viewer/src/explorer Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ describe(fetchFiles.name, () => {
3636 await fetchFiles ( "optimistic.etherscan" , "0x0" , { fetch : f } ) ;
3737
3838 const expectedPrefix =
39- "https://api-optimistic.etherscan.io/api?& module=contract&action=getsourcecode&address=0x0&apikey=" ;
39+ "https://api-optimistic.etherscan.io/api?module=contract&action=getsourcecode&address=0x0&apikey=" ;
4040
4141 assert (
4242 url ?. startsWith ( expectedPrefix ) ,
Original file line number Diff line number Diff line change @@ -42,12 +42,22 @@ export async function fetchFiles(
4242 } : FetchFilesOptions = { }
4343) : Promise < FetchFilesResult > {
4444 const apiUrl = explorerApiUrls [ apiName ] ;
45- const url =
46- apiUrl +
47- "&module=contract" +
48- "&action=getsourcecode" +
49- `&address=${ contractAddress } ` +
50- `&apikey=${ explorerApiKeys [ apiName ] } ` ;
45+ let url ;
46+ if ( apiUrl . includes ( "chainid=" ) ) {
47+ url =
48+ apiUrl +
49+ "&module=contract" +
50+ "&action=getsourcecode" +
51+ `&address=${ contractAddress } ` +
52+ `&apikey=${ explorerApiKeys [ apiName ] } ` ;
53+ } else {
54+ url =
55+ apiUrl +
56+ "?module=contract" +
57+ "&action=getsourcecode" +
58+ `&address=${ contractAddress } ` +
59+ `&apikey=${ explorerApiKeys [ apiName ] } ` ;
60+ }
5161
5262 const response = ( await fetch ( url ) ) as types . ContractSourceResponse ;
5363
You can’t perform that action at this time.
0 commit comments