Skip to content

Commit da572f9

Browse files
committed
Fix v2 url path
1 parent 571386e commit da572f9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

packages/ethereum-viewer/src/explorer/fetchFiles.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)