-
Notifications
You must be signed in to change notification settings - Fork 3
/
prepare.ts
40 lines (36 loc) · 1.13 KB
/
prepare.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { writeFileSync } from "node:fs";
type RouteScanResponse = {
items: {
workspace: string;
chainId: string;
}[];
};
async function getRoutescan() {
const result = await fetch("https://cdn-canary.routescan.io/api/evm/all/explorers");
const data = (await result.json()) as RouteScanResponse;
const formatted = data.items.map((d) => ({
api: `https://api.routescan.io/v2/network/${d.workspace}/evm/${d.chainId}/etherscan`,
explorer: `${d.chainId}.routescan.io`,
chainId: Number(d.chainId),
}));
writeFileSync("src/explorers/routescan.json", JSON.stringify(formatted, null, 2));
}
type EtherscanResponse = {
result: {
blockexplorer: string;
chainid: string;
apiurl: string;
}[];
};
async function getEtherscan() {
const result = await fetch("https://api.etherscan.io/v2/chainlist");
const data = (await result.json()) as EtherscanResponse;
const formatted = data.result.map((d) => ({
api: d.apiurl,
explorer: d.blockexplorer,
chainId: Number(d.chainid),
}));
writeFileSync("src/explorers/etherscan.json", JSON.stringify(formatted, null, 2));
}
getRoutescan();
getEtherscan();