Skip to content

Commit ded01b5

Browse files
Cleanup APIs (#89)
* add pinax apis, remove non-working apis * fix scroll-sepolia endpoint * handle rate limiting better * add apechain-testnet api * update lens api * add jitter to retries * bump version * replace mainnet rpc * add routescan api
1 parent e556e15 commit ded01b5

32 files changed

+75
-47
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.6.44",
2+
"version": "0.6.45",
33
"private": true,
44
"type": "module",
55
"scripts": {
@@ -28,4 +28,4 @@
2828
"prettier": "3.4.2",
2929
"wrangler": "^3.107.2"
3030
}
31-
}
31+
}

registry/eip155/abstract-testnet.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
{
1616
"url": "https://api.routescan.io/v2/network/testnet/evm/11124/etherscan/api",
1717
"kind": "etherscan"
18-
}
18+
},
19+
{ "url": "https://abstract-testnet.abi.pinax.network/api", "kind": "etherscan" }
1920
],
2021
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
2122
"networkType": "testnet",

registry/eip155/abstract.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"graphNode": { "protocol": "ethereum" },
88
"rpcUrls": ["https://api.mainnet.abs.xyz"],
99
"explorerUrls": ["https://abscan.org"],
10-
"apiUrls": [{ "url": "https://api.abscan.org/api", "kind": "etherscan" }],
10+
"apiUrls": [
11+
{ "url": "https://abstract.abi.pinax.network/api", "kind": "etherscan" }
12+
],
1113
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
1214
"networkType": "mainnet",
1315
"relations": [{ "kind": "l2Of", "network": "mainnet" }],

registry/eip155/apechain-curtis.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"explorerUrls": ["https://curtis.apescan.io"],
1010
"rpcUrls": ["https://curtis.rpc.caldera.xyz/http"],
1111
"apiUrls": [
12-
{ "url": "https://api-curtis.apescan.io/api", "kind": "etherscan" }
12+
{ "url": "https://apechain-testnet.abi.pinax.network/api", "kind": "etherscan" }
1313
],
1414
"networkType": "testnet",
1515
"relations": [

registry/eip155/apechain.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"graphNode": { "protocol": "ethereum" },
88
"explorerUrls": ["https://apescan.io"],
99
"rpcUrls": ["https://rpc.apechain.com"],
10-
"apiUrls": [{ "url": "https://api.apescan.io/api", "kind": "etherscan" }],
10+
"apiUrls": [
11+
{ "url": "https://apechain.abi.pinax.network/api", "kind": "etherscan" }
12+
],
1113
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
1214
"networkType": "mainnet",
1315
"issuanceRewards": false,

registry/eip155/arbitrum-nova.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
{
1616
"url": "https://arbitrum-nova.abi.pinax.network/api",
1717
"kind": "etherscan"
18-
},
19-
{ "url": "https://nova-explorer.arbitrum.io/api", "kind": "blockscout" }
18+
}
2019
],
2120
"services": {
2221
"subgraphs": ["https://api.studio.thegraph.com/deploy"],

registry/eip155/arbitrum-sepolia.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
{
2121
"url": "https://arbitrum-sepolia.abi.pinax.network/api",
2222
"kind": "etherscan"
23-
},
24-
{ "url": "https://sepolia-explorer.arbitrum.io/api", "kind": "blockscout" }
23+
}
2524
],
2625
"services": {
2726
"subgraphs": ["https://api.studio.thegraph.com/deploy"],

registry/eip155/avalanche.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"https://avalanche-c-chain-rpc.publicnode.com"
1414
],
1515
"apiUrls": [
16+
{ "url": "https://avalanche.abi.pinax.network/api", "kind": "etherscan" },
1617
{ "url": "https://api.snowtrace.io/api", "kind": "etherscan" },
1718
{
1819
"url": "https://api.routescan.io/v2/network/mainnet/evm/43114/etherscan/api",

registry/eip155/berachain.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"graphNode": { "protocol": "ethereum" },
88
"rpcUrls": ["https://rpc.berachain.com"],
99
"explorerUrls": ["https://berascan.com"],
10-
"apiUrls": [{ "url": "https://api.berascan.com/api", "kind": "etherscan" }],
10+
"apiUrls": [
11+
{ "url": "https://berachain.abi.pinax.network/api", "kind": "etherscan" },
12+
{ "url": "https://api.routescan.io/v2/network/mainnet/evm/80094/etherscan/api", "kind": "etherscan" }
13+
],
1114
"services": {
1215
"subgraphs": ["https://api.studio.thegraph.com/deploy"],
1316
"firehose": ["bera.firehose.pinax.network:443"],

registry/eip155/bnb-op.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"https://opbnb-mainnet-rpc.bnbchain.org",
1212
"https://opbnb.rpc.pinax.network/v1/{PINAX_API_KEY}"
1313
],
14-
"apiUrls": [],
14+
"apiUrls": [
15+
{ "url": "https://bnb-op.abi.pinax.network/api", "kind": "etherscan" }
16+
],
1517
"services": {
1618
"firehose": ["opbnb.firehose.pinax.network:443"],
1719
"substreams": ["opbnb.substreams.pinax.network:443"]

registry/eip155/cronos.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"https://cronos.rpc.pinax.network/v1/{PINAX_API_KEY}"
1212
],
1313
"apiUrls": [
14-
{ "url": "https://cronos.org/explorer/api", "kind": "blockscout" }
14+
{ "url": "https://cronos.org/explorer/api", "kind": "blockscout" },
15+
{ "url": "https://cronos.abi.pinax.network/api", "kind": "etherscan" }
1516
],
1617
"services": {},
1718
"networkType": "mainnet",

registry/eip155/fraxtal.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"explorerUrls": ["https://fraxscan.com"],
99
"rpcUrls": ["https://rpc.frax.com"],
1010
"apiUrls": [
11-
{ "url": "https://fraxtal.abi.pinax.network/api", "kind": "etherscan" }
11+
{ "url": "https://fraxtal.abi.pinax.network/api", "kind": "etherscan" },
12+
{ "url": "https://api.routescan.io/v2/network/mainnet/evm/252/etherscan/api", "kind": "etherscan" }
1213
],
1314
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
1415
"networkType": "mainnet",

registry/eip155/fuji.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"https://fuji.rpc.pinax.network/v1/{PINAX_API_KEY}/ext/bc/C/rpc"
1313
],
1414
"apiUrls": [
15+
{ "url": "https://fuji.abi.pinax.network/api", "kind": "etherscan" },
1516
{ "url": "https://api-testnet.snowtrace.io/api", "kind": "etherscan" },
1617
{
1718
"url": "https://api.routescan.io/v2/network/testnet/evm/43113/etherscan/api",

registry/eip155/harmony.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"explorerUrls": ["https://explorer.harmony.one/?shard=0"],
99
"rpcUrls": ["https://api.harmony.one/?shard=0"],
1010
"apiUrls": [
11-
{ "url": "https://explorer.harmony.one/api?shard=0", "kind": "etherscan" }
11+
{ "url": "https://explorer.harmony.one/api", "kind": "etherscan" }
1212
],
1313
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
1414
"networkType": "mainnet",

registry/eip155/holesky.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"https://holesky.rpc.pinax.network/v1/{PINAX_API_KEY}"
1919
],
2020
"apiUrls": [
21-
{ "url": "https://eth-holesky.blockscout.com/api", "kind": "blockscout" }
21+
{ "url": "https://eth-holesky.blockscout.com/api", "kind": "blockscout" },
22+
{ "url": "https://holesky.abi.pinax.network/api", "kind": "etherscan" }
2223
],
2324
"services": {
2425
"subgraphs": ["https://api.studio.thegraph.com/deploy"],

registry/eip155/kaia-testnet.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"graphNode": { "protocol": "ethereum" },
99
"explorerUrls": ["https://kairos.kaiascan.io"],
1010
"rpcUrls": ["https://public-en-kairos.node.kaia.io"],
11-
"apiUrls": [],
11+
"apiUrls": [
12+
{ "url": "https://kaia-testnet.abi.pinax.network/api", "kind": "etherscan" }
13+
],
1214
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
1315
"networkType": "testnet",
1416
"relations": [{ "kind": "testnetOf", "network": "kaia" }],

registry/eip155/kaia.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"graphNode": { "protocol": "ethereum" },
88
"explorerUrls": ["https://kaiascan.io"],
99
"rpcUrls": ["https://public-en.node.kaia.io"],
10-
"apiUrls": [],
10+
"apiUrls": [
11+
{ "url": "https://kaia.abi.pinax.network/api", "kind": "etherscan" }
12+
],
1113
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
1214
"networkType": "mainnet",
1315
"issuanceRewards": false,

registry/eip155/lens-testnet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"rpcUrls": ["https://rpc.testnet.lens.dev"],
1010
"apiUrls": [
1111
{
12-
"url": "https://block-explorer-api.staging.lens.dev/api",
12+
"url": "https://block-explorer-api.lens.dev/api",
1313
"kind": "etherscan"
1414
}
1515
],

registry/eip155/mainnet.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"explorerUrls": ["https://etherscan.io"],
99
"rpcUrls": [
1010
"https://rpc.ankr.com/eth",
11-
"https://cloudflare-eth.com",
11+
"https://ethereum-rpc.publicnode.com",
12+
"https://mainnet.gateway.tenderly.co",
1213
"https://eth.rpc.pinax.network/v1/{PINAX_API_KEY}",
1314
"https://mainnet.infura.io/v3/{INFURA_API_KEY}"
1415
],

registry/eip155/moonriver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"https://moonriver.public.blastapi.io"
1313
],
1414
"apiUrls": [
15-
{ "url": "https://api-moonriver.moonscan.io/api", "kind": "etherscan" }
15+
{ "url": "https://moonriver.abi.pinax.network/api", "kind": "etherscan" }
1616
],
1717
"services": {
1818
"subgraphs": ["https://api.studio.thegraph.com/deploy"],

registry/eip155/polygon-zkevm-cardona.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
"https://cardona.rpc.pinax.network/v1/{PINAX_API_KEY}"
1717
],
1818
"apiUrls": [
19-
{
20-
"url": "https://api-cardona-zkevm.polygonscan.com/api",
21-
"kind": "blockscout"
22-
},
2319
{
2420
"url": "https://polygon-zkevm-cardona.abi.pinax.network/api",
2521
"kind": "etherscan"

registry/eip155/scroll-sepolia.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"https://scrsepolia.rpc.pinax.network/v1/{PINAX_API_KEY}"
1313
],
1414
"apiUrls": [
15-
{ "url": "https://api-sepolia.scrollscan.com/api", "kind": "etherscan" },
16-
{ "url": "https://scroll-sepolia.blockscout.com/api", "kind": "blockscout" }
15+
{ "url": "https://scroll-sepolia.blockscout.com/api", "kind": "blockscout" },
16+
{ "url": "https://scroll-sepolia.abi.pinax.network/api", "kind": "etherscan" }
1717
],
1818
"services": {
1919
"subgraphs": ["https://api.studio.thegraph.com/deploy"],

registry/eip155/scroll.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"https://rpc.ankr.com/scroll"
1313
],
1414
"apiUrls": [
15-
{ "url": "https://api.scrollscan.com/api", "kind": "etherscan" },
16-
{ "url": "https://scroll.blockscout.com/api", "kind": "blockscout" }
15+
{ "url": "https://scroll.blockscout.com/api", "kind": "blockscout" },
16+
{ "url": "https://scroll.abi.pinax.network/api", "kind": "etherscan" }
1717
],
1818
"services": {
1919
"subgraphs": ["https://api.studio.thegraph.com/deploy"],

registry/eip155/sonic.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
{
1212
"url": "https://api.routescan.io/v2/network/mainnet/evm/146/etherscan/api",
1313
"kind": "etherscan"
14-
}
14+
},
15+
{ "url": "https://sonic.abi.pinax.network/api", "kind": "etherscan" }
1516
],
1617
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
1718
"networkType": "mainnet",

registry/eip155/unichain-testnet.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
{
2525
"url": "https://api.routescan.io/v2/network/testnet/evm/1301/etherscan/api",
2626
"kind": "etherscan"
27-
}
27+
},
28+
{ "url": "https://unichain-testnet.abi.pinax.network/api", "kind": "etherscan" }
2829
],
2930
"services": {
3031
"subgraphs": ["https://api.studio.thegraph.com/deploy"],

registry/eip155/unichain.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"relations": [{ "kind": "l2Of", "network": "mainnet" }],
1111
"explorerUrls": ["https://unichain.blockscout.com", "https://uniscan.xyz"],
1212
"apiUrls": [
13-
{ "url": "https://unichain.blockscout.com/api", "kind": "blockscout" }
13+
{ "url": "https://unichain.blockscout.com/api", "kind": "blockscout" },
14+
{ "url": "https://unichain.abi.pinax.network/api", "kind": "etherscan" }
1415
],
1516
"rpcUrls": ["https://mainnet.unichain.org"],
1617
"issuanceRewards": false,

registry/eip155/xai.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"https://xai.rpc.pinax.network/v1/{PINAX_API_KEY}"
1212
],
1313
"apiUrls": [
14-
{ "url": "https://explorer.xai-chain.net/api", "kind": "blockscout" }
14+
{ "url": "https://explorer.xai-chain.net/api", "kind": "blockscout" },
15+
{ "url": "https://xai.abi.pinax.network/api", "kind": "etherscan" }
1516
],
1617
"services": {
1718
"firehose": ["xai.firehose.pinax.network:443"],

registry/eip155/zksync-era-sepolia.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"url": "https://block-explorer-api.sepolia.zksync.dev/api",
1414
"kind": "etherscan"
1515
},
16-
{ "url": "https://zksync-sepolia.blockscout.com/api", "kind": "blockscout" }
16+
{ "url": "https://zksync-sepolia.blockscout.com/api", "kind": "blockscout" },
17+
{ "url": "https://zksync-era-sepolia.abi.pinax.network/api", "kind": "etherscan" }
1718
],
1819
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
1920
"networkType": "testnet",

registry/eip155/zksync-era.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"url": "https://block-explorer-api.mainnet.zksync.io/api",
1717
"kind": "etherscan"
1818
},
19-
{ "url": "https://zksync.blockscout.com/api", "kind": "blockscout" }
19+
{ "url": "https://zksync.blockscout.com/api", "kind": "blockscout" },
20+
{ "url": "https://zksync-era.abi.pinax.network/api", "kind": "etherscan" }
2021
],
2122
"services": { "subgraphs": ["https://api.studio.thegraph.com/deploy"] },
2223
"networkType": "mainnet",

src/check_etherscan.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,19 @@ async function main() {
3737

3838
let networks = loadNetworks("registry");
3939
console.log("Loaded from registry: ", networks.length);
40+
const overlappedChains = networks
41+
.filter((network) =>
42+
etherscanChains.some(
43+
(ethChain) => network.caip2Id === `eip155:${ethChain.chainid}`,
44+
),
45+
)
46+
.sort((a, b) => a.id.localeCompare(b.id));
47+
console.log("Overlap: ", overlappedChains.length);
4048

4149
console.log(
4250
"id chainid registry proxy url",
4351
);
44-
for (const ethChain of etherscanChains) {
45-
const network = networks.find(
46-
(n) => n.caip2Id === `eip155:${ethChain.chainid}`,
47-
);
48-
if (!network) continue;
52+
for (const network of overlappedChains) {
4953
const ourApi = network.apiUrls?.find((c) =>
5054
c.url.includes("abi.pinax.network"),
5155
)?.url;
@@ -56,7 +60,7 @@ async function main() {
5660
.catch(() => false);
5761

5862
console.log(
59-
`${network.id.padEnd(22)} ${ethChain.chainid.toString().padEnd(15)} ${(inRegistry ? "✅" : "❌").padEnd(7)} ${inProxy ? "✅" : "❌"} ${url}`,
63+
`${network.id.padEnd(22)} ${network.caip2Id.replace(/^eip155:/, "").padEnd(15)} ${(inRegistry ? "✅" : "❌").padEnd(7)} ${inProxy ? "✅" : "❌"} ${url}`,
6064
);
6165
await sleep(7000); // limited to 10 requests in 1 minute
6266
}

src/utils/retry.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,22 @@ export async function withRetry<T>(
3939
caption: string = "operation",
4040
maxAttempts: number = DEFAULT_MAX_RETRY_ATTEMPTS,
4141
delayMs: number = DEFAULT_RETRY_SLEEP_MS,
42+
jitter: number = 0,
4243
): Promise<T> {
4344
let lastError: any;
4445

4546
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
4647
try {
48+
console.log(`Trying ${caption} ... (attempt ${attempt}/${maxAttempts})`);
4749
return await operation();
4850
} catch (error) {
4951
lastError = error;
5052
if (attempt < maxAttempts) {
51-
await new Promise((resolve) => setTimeout(resolve, delayMs));
52-
console.log(
53-
`Retrying ${caption} ... (attempt ${attempt + 1}/${maxAttempts})`,
54-
);
53+
const jitterOffset = jitter * (Math.random() * 2 - 1); // Value between -jitter and +jitter
54+
const actualDelay = Math.floor(delayMs * (1 + jitterOffset));
55+
56+
console.log(`${caption} failed, retrying in ${actualDelay}ms...`);
57+
await new Promise((resolve) => setTimeout(resolve, actualDelay));
5558
}
5659
}
5760
}

src/validate_urls.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ async function testAPI({
8181
console.log(` ${networkId} - ${url} is valid`);
8282
},
8383
url,
84-
3,
84+
5, // max attempts
8585
30_000, // for rate-limiting
86+
0.2, // jitter
8687
);
8788
} catch (e) {
8889
let errorMessage = "unknown error";
@@ -235,7 +236,7 @@ async function validateApis(networks: Network[]) {
235236
const urls = networks.flatMap((n) =>
236237
(n.apiUrls ?? []).map(({ url, kind }) => ({ url, kind, networkId: n.id })),
237238
);
238-
const results = await processQueue(urls, testAPI, 10);
239+
const results = await processQueue(urls, testAPI, 20);
239240

240241
console.log(
241242
`API validation complete: ${results.filter(Boolean).length}/${urls.length} endpoints accessible\n`,

0 commit comments

Comments
 (0)