Skip to content

Commit 591ae79

Browse files
feat: add support fallback rpcs
1 parent 235b80e commit 591ae79

File tree

3 files changed

+115
-95
lines changed

3 files changed

+115
-95
lines changed

Diff for: indexer-compose.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ services:
2323
IPFS_GATEWAYS: ${IPFS_GATEWAYS}
2424
COINGECKO_API_KEY: ${COINGECKO_API_KEY}
2525
GRAPHILE_LICENSE: ${GRAPHILE_LICENSE}
26-
SEPOLIA_RPC_URL: ${SEPOLIA_RPC_URL}
27-
POLYGON_MUMBAI_RPC_URL: ${POLYGON_MUMBAI_RPC_URL}
28-
AVALANCHE_RPC_URL: ${AVALANCHE_RPC_URL}
29-
OPTIMISM_RPC_URL: ${OPTIMISM_RPC_URL}
26+
SEPOLIA_RPC_URLS: ${SEPOLIA_RPC_URLS}
27+
POLYGON_MUMBAI_RPC_URLS: ${POLYGON_MUMBAI_RPC_URLS}
28+
AVALANCHE_RPC_URLS: ${AVALANCHE_RPC_URLS}
29+
OPTIMISM_RPC_URLS: ${OPTIMISM_RPC_URLS}
3030
SENTRY_DSN: ${SENTRY_DSN}
3131
PGN_TESTNET_RPC_URL: ${PGN_TESTNET_RPC_URL}
32-
ARBITRUM_GOERLI_RPC_URL: ${ARBITRUM_GOERLI_RPC_URL}
33-
FANTOM_RPC_URL: ${FANTOM_RPC_URL}
34-
BASE_RPC_URL: ${BASE_RPC_URL}
35-
PGN_RPC_URL: ${PGN_RPC_URL}
36-
GOERLI_RPC_URL: ${GOERLI_RPC_URL}
37-
AVALANCHE_FUJI_RPC_URL: ${AVALANCHE_FUJI_RPC_URL}
38-
ARBITRUM_RPC_URL: ${ARBITRUM_RPC_URL}
39-
SEI_MAINNET_RPC_URL: ${SEI_MAINNET_RPC_URL}
40-
MAINNET_RPC_URL: ${MAINNET_RPC_URL}
41-
POLYGON_RPC_URL: ${POLYGON_RPC_URL}
42-
METIS_ANDROMEDA_RPC_URL: ${METIS_ANDROMEDA_RPC_URL}
43-
SCROLL_SEPOLIA_RPC_URL: ${SCROLL_SEPOLIA_RPC_URL}
32+
ARBITRUM_GOERLI_RPC_URLS: ${ARBITRUM_GOERLI_RPC_URLS}
33+
FANTOM_RPC_URLS: ${FANTOM_RPC_URLS}
34+
BASE_RPC_URLS: ${BASE_RPC_URLS}
35+
PGN_RPC_URLS: ${PGN_RPC_URLS}
36+
GOERLI_RPC_URLS: ${GOERLI_RPC_URLS}
37+
AVALANCHE_FUJI_RPC_URLS: ${AVALANCHE_FUJI_RPC_URLS}
38+
ARBITRUM_RPC_URLS: ${ARBITRUM_RPC_URLS}
39+
SEI_MAINNET_RPC_URLS: ${SEI_MAINNET_RPC_URLS}
40+
MAINNET_RPC_URLS: ${MAINNET_RPC_URLS}
41+
POLYGON_RPC_URLS: ${POLYGON_RPC_URLS}
42+
METIS_ANDROMEDA_RPC_URLS: ${METIS_ANDROMEDA_RPC_URLS}
43+
SCROLL_SEPOLIA_RPC_URLS: ${SCROLL_SEPOLIA_RPC_URLS}
4444
DATABASE_URL: "postgresql://postgres:postgres@db:5432/grants_stack_indexer"
4545

4646
index:

Diff for: src/config.ts

+71-71
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export type Subscription = {
4040
};
4141

4242
export type Chain = {
43-
rpc: string;
43+
rpcs: string[];
4444
name: string;
4545
id: ChainId;
4646
pricesFromTimestamp: number;
@@ -49,15 +49,15 @@ export type Chain = {
4949
maxGetLogsRange?: number;
5050
};
5151

52-
const rpcUrl = z.string().url();
52+
const rpcUrl = z.array(z.string().url());
5353

5454
const CHAINS: Chain[] = [
5555
{
5656
id: 1,
5757
name: "mainnet",
58-
rpc: rpcUrl
59-
.default("https://mainnet.infura.io/v3/")
60-
.parse(process.env.MAINNET_RPC_URL),
58+
rpcs: rpcUrl
59+
.default(["https://mainnet.infura.io/v3/"])
60+
.parse(process.env.MAINNET_RPC_URLS),
6161
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
6262
tokens: [
6363
{
@@ -152,9 +152,9 @@ const CHAINS: Chain[] = [
152152
{
153153
id: 10,
154154
name: "optimism",
155-
rpc: rpcUrl
156-
.default("https://optimism-rpc.publicnode.com")
157-
.parse(process.env.OPTIMISM_RPC_URL),
155+
rpcs: rpcUrl
156+
.default(["https://optimism-rpc.publicnode.com"])
157+
.parse(process.env.OPTIMISM_RPC_URLS),
158158
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
159159
tokens: [
160160
{
@@ -268,9 +268,9 @@ const CHAINS: Chain[] = [
268268
{
269269
id: 11155111,
270270
name: "sepolia",
271-
rpc: rpcUrl
272-
.default("https://ethereum-sepolia.publicnode.com")
273-
.parse(process.env.SEPOLIA_RPC_URL),
271+
rpcs: rpcUrl
272+
.default(["https://ethereum-sepolia.publicnode.com"])
273+
.parse(process.env.SEPOLIA_RPC_URLS),
274274
pricesFromTimestamp: Date.UTC(2023, 11, 1, 0, 0, 0),
275275
tokens: [
276276
{
@@ -372,9 +372,9 @@ const CHAINS: Chain[] = [
372372
{
373373
id: 250,
374374
name: "fantom",
375-
rpc: rpcUrl
376-
.default("https://rpcapi.fantom.network")
377-
.parse(process.env.FANTOM_RPC_URL),
375+
rpcs: rpcUrl
376+
.default(["https://rpcapi.fantom.network"])
377+
.parse(process.env.FANTOM_RPC_URLS),
378378
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
379379
tokens: [
380380
{
@@ -471,9 +471,9 @@ const CHAINS: Chain[] = [
471471
{
472472
id: 58008,
473473
name: "pgn-testnet",
474-
rpc: rpcUrl
475-
.default("https://sepolia.publicgoods.network")
476-
.parse(process.env.PGN_TESTNET_RPC_URL),
474+
rpcs: rpcUrl
475+
.default(["https://sepolia.publicgoods.network"])
476+
.parse(process.env.PGN_TESTNET_RPC_URLS),
477477
pricesFromTimestamp: Date.UTC(2023, 5, 2, 0, 0, 0),
478478
tokens: [
479479
{
@@ -524,9 +524,9 @@ const CHAINS: Chain[] = [
524524
{
525525
id: 424,
526526
name: "pgn-mainnet",
527-
rpc: rpcUrl
528-
.default("https://rpc.publicgoods.network")
529-
.parse(process.env.PGN_RPC_URL),
527+
rpcs: rpcUrl
528+
.default(["https://rpc.publicgoods.network"])
529+
.parse(process.env.PGN_RPC_URLS),
530530
pricesFromTimestamp: Date.UTC(2023, 5, 2, 0, 0, 0),
531531
tokens: [
532532
{
@@ -602,9 +602,9 @@ const CHAINS: Chain[] = [
602602
{
603603
id: 42161,
604604
name: "arbitrum",
605-
rpc: rpcUrl
606-
.default("https://arb-mainnet.g.alchemy.com/v2/")
607-
.parse(process.env.ARBITRUM_RPC_URL),
605+
rpcs: rpcUrl
606+
.default(["https://arb-mainnet.g.alchemy.com/v2/"])
607+
.parse(process.env.ARBITRUM_RPC_URLS),
608608
pricesFromTimestamp: Date.UTC(2023, 7, 1, 0, 0, 0),
609609
tokens: [
610610
{
@@ -715,9 +715,9 @@ const CHAINS: Chain[] = [
715715
{
716716
id: 80001,
717717
name: "polygon-mumbai",
718-
rpc: rpcUrl
719-
.default("https://rpc-mumbai.maticvigil.com/")
720-
.parse(process.env.POLYGON_MUMBAI_RPC_URL),
718+
rpcs: rpcUrl
719+
.default(["https://rpc-mumbai.maticvigil.com/"])
720+
.parse(process.env.POLYGON_MUMBAI_RPC_URLS),
721721
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
722722
tokens: [
723723
{
@@ -795,9 +795,9 @@ const CHAINS: Chain[] = [
795795
{
796796
id: 137,
797797
name: "polygon",
798-
rpc: rpcUrl
799-
.default("https://polygon-rpc.com")
800-
.parse(process.env.POLYGON_RPC_URL),
798+
rpcs: rpcUrl
799+
.default(["https://polygon-rpc.com"])
800+
.parse(process.env.POLYGON_RPC_URLS),
801801
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
802802
tokens: [
803803
{
@@ -893,9 +893,9 @@ const CHAINS: Chain[] = [
893893
{
894894
id: 8453,
895895
name: "base",
896-
rpc: rpcUrl
897-
.default("https://mainnet.base.org/")
898-
.parse(process.env.BASE_RPC_URL),
896+
rpcs: rpcUrl
897+
.default(["https://mainnet.base.org/"])
898+
.parse(process.env.BASE_RPC_URLS),
899899
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
900900
tokens: [
901901
{
@@ -973,9 +973,9 @@ const CHAINS: Chain[] = [
973973
{
974974
id: 324,
975975
name: "zksync-era-mainnet",
976-
rpc: rpcUrl
977-
.default("https://mainnet.era.zksync.io")
978-
.parse(process.env.ZKSYNC_RPC_URL),
976+
rpcs: rpcUrl
977+
.default(["https://mainnet.era.zksync.io"])
978+
.parse(process.env.ZKSYNC_RPC_URLS),
979979
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
980980
tokens: [
981981
{
@@ -1088,9 +1088,9 @@ const CHAINS: Chain[] = [
10881088
{
10891089
id: 300,
10901090
name: "zksync-era-testnet",
1091-
rpc: rpcUrl
1092-
.default("https://sepolia.era.zksync.dev")
1093-
.parse(process.env.ZKSYNC_TESTNET_RPC_URL),
1091+
rpcs: rpcUrl
1092+
.default(["https://sepolia.era.zksync.dev"])
1093+
.parse(process.env.ZKSYNC_TESTNET_RPC_URLS),
10941094
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
10951095
tokens: [
10961096
{
@@ -1128,9 +1128,9 @@ const CHAINS: Chain[] = [
11281128
{
11291129
id: 43114,
11301130
name: "avalanche",
1131-
rpc: rpcUrl
1132-
.default("https://rpc.ankr.com/avalanche")
1133-
.parse(process.env.AVALANCHE_RPC_URL),
1131+
rpcs: rpcUrl
1132+
.default(["https://rpc.ankr.com/avalanche"])
1133+
.parse(process.env.AVALANCHE_RPC_URLS),
11341134
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
11351135
tokens: [
11361136
{
@@ -1208,9 +1208,9 @@ const CHAINS: Chain[] = [
12081208
{
12091209
id: 43113,
12101210
name: "avalanche-fuji",
1211-
rpc: rpcUrl
1212-
.default("https://avalanche-fuji-c-chain.publicnode.com")
1213-
.parse(process.env.AVALANCHE_FUJI_RPC_URL),
1211+
rpcs: rpcUrl
1212+
.default(["https://avalanche-fuji-c-chain.publicnode.com"])
1213+
.parse(process.env.AVALANCHE_FUJI_RPC_URLS),
12141214
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
12151215
tokens: [
12161216
{
@@ -1278,9 +1278,9 @@ const CHAINS: Chain[] = [
12781278
{
12791279
id: 534351,
12801280
name: "scroll-sepolia",
1281-
rpc: rpcUrl
1282-
.default("https://sepolia-rpc.scroll.io")
1283-
.parse(process.env.SCROLL_SEPOLIA_RPC_URL),
1281+
rpcs: rpcUrl
1282+
.default(["https://sepolia-rpc.scroll.io"])
1283+
.parse(process.env.SCROLL_SEPOLIA_RPC_URLS),
12841284
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
12851285
maxGetLogsRange: 2000,
12861286
tokens: [
@@ -1349,9 +1349,9 @@ const CHAINS: Chain[] = [
13491349
{
13501350
id: 534352,
13511351
name: "scroll",
1352-
rpc: rpcUrl
1353-
.default("https://rpc.scroll.io")
1354-
.parse(process.env.SCROLL_RPC_URL),
1352+
rpcs: rpcUrl
1353+
.default(["https://rpc.scroll.io"])
1354+
.parse(process.env.SCROLL_RPC_URLS),
13551355
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
13561356
maxGetLogsRange: 9000,
13571357
tokens: [
@@ -1435,9 +1435,9 @@ const CHAINS: Chain[] = [
14351435
{
14361436
id: 713715,
14371437
name: "sei-devnet",
1438-
rpc: rpcUrl
1439-
.default("https://evm-rpc-arctic-1.sei-apis.com")
1440-
.parse(process.env.SEI_DEVNET_RPC_URL),
1438+
rpcs: rpcUrl
1439+
.default(["https://evm-rpc-arctic-1.sei-apis.com"])
1440+
.parse(process.env.SEI_DEVNET_RPC_URLS),
14411441
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
14421442
tokens: [
14431443
{
@@ -1485,9 +1485,9 @@ const CHAINS: Chain[] = [
14851485
{
14861486
id: 1329,
14871487
name: "sei-mainnet",
1488-
rpc: rpcUrl
1489-
.default("https://evm-rpc.sei-apis.com")
1490-
.parse(process.env.SEI_MAINNET_RPC_URL),
1488+
rpcs: rpcUrl
1489+
.default(["https://evm-rpc.sei-apis.com"])
1490+
.parse(process.env.SEI_MAINNET_RPC_URLS),
14911491
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
14921492
maxGetLogsRange: 10000,
14931493
tokens: [
@@ -1536,9 +1536,9 @@ const CHAINS: Chain[] = [
15361536
{
15371537
id: 42,
15381538
name: "lukso-mainnet",
1539-
rpc: rpcUrl
1540-
.default("https://42.rpc.thirdweb.com")
1541-
.parse(process.env.LUKSO_MAINNET_RPC_URL),
1539+
rpcs: rpcUrl
1540+
.default(["https://42.rpc.thirdweb.com"])
1541+
.parse(process.env.LUKSO_MAINNET_RPC_URLS),
15421542
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
15431543
tokens: [
15441544
{
@@ -1586,9 +1586,9 @@ const CHAINS: Chain[] = [
15861586
{
15871587
id: 4201,
15881588
name: "lukso-testnet",
1589-
rpc: rpcUrl
1590-
.default("https://4201.rpc.thirdweb.com")
1591-
.parse(process.env.LUKSO_TESTNET_RPC_URL),
1589+
rpcs: rpcUrl
1590+
.default(["https://4201.rpc.thirdweb.com"])
1591+
.parse(process.env.LUKSO_TESTNET_RPC_URLS),
15921592
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
15931593
tokens: [
15941594
{
@@ -1627,9 +1627,9 @@ const CHAINS: Chain[] = [
16271627
{
16281628
id: 42220,
16291629
name: "celo-mainnet",
1630-
rpc: rpcUrl
1631-
.default("https://forno.celo.org")
1632-
.parse(process.env.CELO_MAINNET_RPC_URL),
1630+
rpcs: rpcUrl
1631+
.default(["https://forno.celo.org"])
1632+
.parse(process.env.CELO_MAINNET_RPC_URLS),
16331633
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
16341634
tokens: [
16351635
{
@@ -1686,9 +1686,9 @@ const CHAINS: Chain[] = [
16861686
{
16871687
id: 44787,
16881688
name: "celo-testnet",
1689-
rpc: rpcUrl
1690-
.default("https://alfajores-forno.celo-testnet.org")
1691-
.parse(process.env.CELO_TESTNET_RPC_URL),
1689+
rpcs: rpcUrl
1690+
.default(["https://alfajores-forno.celo-testnet.org"])
1691+
.parse(process.env.CELO_TESTNET_RPC_URLS),
16921692
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
16931693
tokens: [
16941694
{
@@ -1727,9 +1727,9 @@ const CHAINS: Chain[] = [
17271727
{
17281728
id: 1088,
17291729
name: "metisAndromeda",
1730-
rpc: rpcUrl
1731-
.default("https://andromeda.metis.io/?owner=1088")
1732-
.parse(process.env.METIS_ANDROMEDA_RPC_URL),
1730+
rpcs: rpcUrl
1731+
.default(["https://andromeda.metis.io/?owner=1088"])
1732+
.parse(process.env.METIS_ANDROMEDA_RPC_URLS),
17331733
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
17341734
tokens: [
17351735
{

0 commit comments

Comments
 (0)