Skip to content

Commit d824010

Browse files
feat: add support fallback rpcs
1 parent b6eb77b commit d824010

File tree

3 files changed

+115
-95
lines changed

3 files changed

+115
-95
lines changed

indexer-compose.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ services:
2323
IPFS_GATEWAY: ${IPFS_GATEWAY}
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:

src/config.ts

+71-71
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type Subscription = {
3838
};
3939

4040
export type Chain = {
41-
rpc: string;
41+
rpcs: string[];
4242
name: string;
4343
id: ChainId;
4444
pricesFromTimestamp: number;
@@ -47,15 +47,15 @@ export type Chain = {
4747
maxGetLogsRange?: number;
4848
};
4949

50-
const rpcUrl = z.string().url();
50+
const rpcUrl = z.array(z.string().url());
5151

5252
const CHAINS: Chain[] = [
5353
{
5454
id: 1,
5555
name: "mainnet",
56-
rpc: rpcUrl
57-
.default("https://mainnet.infura.io/v3/")
58-
.parse(process.env.MAINNET_RPC_URL),
56+
rpcs: rpcUrl
57+
.default(["https://mainnet.infura.io/v3/"])
58+
.parse(process.env.MAINNET_RPC_URLS),
5959
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
6060
tokens: [
6161
{
@@ -150,9 +150,9 @@ const CHAINS: Chain[] = [
150150
{
151151
id: 10,
152152
name: "optimism",
153-
rpc: rpcUrl
154-
.default("https://optimism-rpc.publicnode.com")
155-
.parse(process.env.OPTIMISM_RPC_URL),
153+
rpcs: rpcUrl
154+
.default(["https://optimism-rpc.publicnode.com"])
155+
.parse(process.env.OPTIMISM_RPC_URLS),
156156
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
157157
tokens: [
158158
{
@@ -266,9 +266,9 @@ const CHAINS: Chain[] = [
266266
{
267267
id: 11155111,
268268
name: "sepolia",
269-
rpc: rpcUrl
270-
.default("https://ethereum-sepolia.publicnode.com")
271-
.parse(process.env.SEPOLIA_RPC_URL),
269+
rpcs: rpcUrl
270+
.default(["https://ethereum-sepolia.publicnode.com"])
271+
.parse(process.env.SEPOLIA_RPC_URLS),
272272
pricesFromTimestamp: Date.UTC(2023, 11, 1, 0, 0, 0),
273273
tokens: [
274274
{
@@ -370,9 +370,9 @@ const CHAINS: Chain[] = [
370370
{
371371
id: 250,
372372
name: "fantom",
373-
rpc: rpcUrl
374-
.default("https://rpcapi.fantom.network")
375-
.parse(process.env.FANTOM_RPC_URL),
373+
rpcs: rpcUrl
374+
.default(["https://rpcapi.fantom.network"])
375+
.parse(process.env.FANTOM_RPC_URLS),
376376
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
377377
tokens: [
378378
{
@@ -469,9 +469,9 @@ const CHAINS: Chain[] = [
469469
{
470470
id: 58008,
471471
name: "pgn-testnet",
472-
rpc: rpcUrl
473-
.default("https://sepolia.publicgoods.network")
474-
.parse(process.env.PGN_TESTNET_RPC_URL),
472+
rpcs: rpcUrl
473+
.default(["https://sepolia.publicgoods.network"])
474+
.parse(process.env.PGN_TESTNET_RPC_URLS),
475475
pricesFromTimestamp: Date.UTC(2023, 5, 2, 0, 0, 0),
476476
tokens: [
477477
{
@@ -522,9 +522,9 @@ const CHAINS: Chain[] = [
522522
{
523523
id: 424,
524524
name: "pgn-mainnet",
525-
rpc: rpcUrl
526-
.default("https://rpc.publicgoods.network")
527-
.parse(process.env.PGN_RPC_URL),
525+
rpcs: rpcUrl
526+
.default(["https://rpc.publicgoods.network"])
527+
.parse(process.env.PGN_RPC_URLS),
528528
pricesFromTimestamp: Date.UTC(2023, 5, 2, 0, 0, 0),
529529
tokens: [
530530
{
@@ -600,9 +600,9 @@ const CHAINS: Chain[] = [
600600
{
601601
id: 42161,
602602
name: "arbitrum",
603-
rpc: rpcUrl
604-
.default("https://arb-mainnet.g.alchemy.com/v2/")
605-
.parse(process.env.ARBITRUM_RPC_URL),
603+
rpcs: rpcUrl
604+
.default(["https://arb-mainnet.g.alchemy.com/v2/"])
605+
.parse(process.env.ARBITRUM_RPC_URLS),
606606
pricesFromTimestamp: Date.UTC(2023, 7, 1, 0, 0, 0),
607607
tokens: [
608608
{
@@ -713,9 +713,9 @@ const CHAINS: Chain[] = [
713713
{
714714
id: 80001,
715715
name: "polygon-mumbai",
716-
rpc: rpcUrl
717-
.default("https://rpc-mumbai.maticvigil.com/")
718-
.parse(process.env.POLYGON_MUMBAI_RPC_URL),
716+
rpcs: rpcUrl
717+
.default(["https://rpc-mumbai.maticvigil.com/"])
718+
.parse(process.env.POLYGON_MUMBAI_RPC_URLS),
719719
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
720720
tokens: [
721721
{
@@ -793,9 +793,9 @@ const CHAINS: Chain[] = [
793793
{
794794
id: 137,
795795
name: "polygon",
796-
rpc: rpcUrl
797-
.default("https://polygon-rpc.com")
798-
.parse(process.env.POLYGON_RPC_URL),
796+
rpcs: rpcUrl
797+
.default(["https://polygon-rpc.com"])
798+
.parse(process.env.POLYGON_RPC_URLS),
799799
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
800800
tokens: [
801801
{
@@ -891,9 +891,9 @@ const CHAINS: Chain[] = [
891891
{
892892
id: 8453,
893893
name: "base",
894-
rpc: rpcUrl
895-
.default("https://mainnet.base.org/")
896-
.parse(process.env.BASE_RPC_URL),
894+
rpcs: rpcUrl
895+
.default(["https://mainnet.base.org/"])
896+
.parse(process.env.BASE_RPC_URLS),
897897
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
898898
tokens: [
899899
{
@@ -971,9 +971,9 @@ const CHAINS: Chain[] = [
971971
{
972972
id: 324,
973973
name: "zksync-era-mainnet",
974-
rpc: rpcUrl
975-
.default("https://mainnet.era.zksync.io")
976-
.parse(process.env.ZKSYNC_RPC_URL),
974+
rpcs: rpcUrl
975+
.default(["https://mainnet.era.zksync.io"])
976+
.parse(process.env.ZKSYNC_RPC_URLS),
977977
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
978978
tokens: [
979979
{
@@ -1086,9 +1086,9 @@ const CHAINS: Chain[] = [
10861086
{
10871087
id: 300,
10881088
name: "zksync-era-testnet",
1089-
rpc: rpcUrl
1090-
.default("https://sepolia.era.zksync.dev")
1091-
.parse(process.env.ZKSYNC_TESTNET_RPC_URL),
1089+
rpcs: rpcUrl
1090+
.default(["https://sepolia.era.zksync.dev"])
1091+
.parse(process.env.ZKSYNC_TESTNET_RPC_URLS),
10921092
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
10931093
tokens: [
10941094
{
@@ -1126,9 +1126,9 @@ const CHAINS: Chain[] = [
11261126
{
11271127
id: 43114,
11281128
name: "avalanche",
1129-
rpc: rpcUrl
1130-
.default("https://rpc.ankr.com/avalanche")
1131-
.parse(process.env.AVALANCHE_RPC_URL),
1129+
rpcs: rpcUrl
1130+
.default(["https://rpc.ankr.com/avalanche"])
1131+
.parse(process.env.AVALANCHE_RPC_URLS),
11321132
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
11331133
tokens: [
11341134
{
@@ -1206,9 +1206,9 @@ const CHAINS: Chain[] = [
12061206
{
12071207
id: 43113,
12081208
name: "avalanche-fuji",
1209-
rpc: rpcUrl
1210-
.default("https://avalanche-fuji-c-chain.publicnode.com")
1211-
.parse(process.env.AVALANCHE_FUJI_RPC_URL),
1209+
rpcs: rpcUrl
1210+
.default(["https://avalanche-fuji-c-chain.publicnode.com"])
1211+
.parse(process.env.AVALANCHE_FUJI_RPC_URLS),
12121212
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
12131213
tokens: [
12141214
{
@@ -1276,9 +1276,9 @@ const CHAINS: Chain[] = [
12761276
{
12771277
id: 534351,
12781278
name: "scroll-sepolia",
1279-
rpc: rpcUrl
1280-
.default("https://sepolia-rpc.scroll.io")
1281-
.parse(process.env.SCROLL_SEPOLIA_RPC_URL),
1279+
rpcs: rpcUrl
1280+
.default(["https://sepolia-rpc.scroll.io"])
1281+
.parse(process.env.SCROLL_SEPOLIA_RPC_URLS),
12821282
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
12831283
maxGetLogsRange: 2000,
12841284
tokens: [
@@ -1347,9 +1347,9 @@ const CHAINS: Chain[] = [
13471347
{
13481348
id: 534352,
13491349
name: "scroll",
1350-
rpc: rpcUrl
1351-
.default("https://rpc.scroll.io")
1352-
.parse(process.env.SCROLL_RPC_URL),
1350+
rpcs: rpcUrl
1351+
.default(["https://rpc.scroll.io"])
1352+
.parse(process.env.SCROLL_RPC_URLS),
13531353
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
13541354
maxGetLogsRange: 9000,
13551355
tokens: [
@@ -1433,9 +1433,9 @@ const CHAINS: Chain[] = [
14331433
{
14341434
id: 713715,
14351435
name: "sei-devnet",
1436-
rpc: rpcUrl
1437-
.default("https://evm-rpc-arctic-1.sei-apis.com")
1438-
.parse(process.env.SEI_DEVNET_RPC_URL),
1436+
rpcs: rpcUrl
1437+
.default(["https://evm-rpc-arctic-1.sei-apis.com"])
1438+
.parse(process.env.SEI_DEVNET_RPC_URLS),
14391439
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
14401440
tokens: [
14411441
{
@@ -1483,9 +1483,9 @@ const CHAINS: Chain[] = [
14831483
{
14841484
id: 1329,
14851485
name: "sei-mainnet",
1486-
rpc: rpcUrl
1487-
.default("https://evm-rpc.sei-apis.com")
1488-
.parse(process.env.SEI_MAINNET_RPC_URL),
1486+
rpcs: rpcUrl
1487+
.default(["https://evm-rpc.sei-apis.com"])
1488+
.parse(process.env.SEI_MAINNET_RPC_URLS),
14891489
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
14901490
maxGetLogsRange: 10000,
14911491
tokens: [
@@ -1534,9 +1534,9 @@ const CHAINS: Chain[] = [
15341534
{
15351535
id: 42,
15361536
name: "lukso-mainnet",
1537-
rpc: rpcUrl
1538-
.default("https://42.rpc.thirdweb.com")
1539-
.parse(process.env.LUKSO_MAINNET_RPC_URL),
1537+
rpcs: rpcUrl
1538+
.default(["https://42.rpc.thirdweb.com"])
1539+
.parse(process.env.LUKSO_MAINNET_RPC_URLS),
15401540
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
15411541
tokens: [
15421542
{
@@ -1584,9 +1584,9 @@ const CHAINS: Chain[] = [
15841584
{
15851585
id: 4201,
15861586
name: "lukso-testnet",
1587-
rpc: rpcUrl
1588-
.default("https://4201.rpc.thirdweb.com")
1589-
.parse(process.env.LUKSO_TESTNET_RPC_URL),
1587+
rpcs: rpcUrl
1588+
.default(["https://4201.rpc.thirdweb.com"])
1589+
.parse(process.env.LUKSO_TESTNET_RPC_URLS),
15901590
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
15911591
tokens: [
15921592
{
@@ -1625,9 +1625,9 @@ const CHAINS: Chain[] = [
16251625
{
16261626
id: 42220,
16271627
name: "celo-mainnet",
1628-
rpc: rpcUrl
1629-
.default("https://forno.celo.org")
1630-
.parse(process.env.CELO_MAINNET_RPC_URL),
1628+
rpcs: rpcUrl
1629+
.default(["https://forno.celo.org"])
1630+
.parse(process.env.CELO_MAINNET_RPC_URLS),
16311631
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
16321632
tokens: [
16331633
{
@@ -1684,9 +1684,9 @@ const CHAINS: Chain[] = [
16841684
{
16851685
id: 44787,
16861686
name: "celo-testnet",
1687-
rpc: rpcUrl
1688-
.default("https://alfajores-forno.celo-testnet.org")
1689-
.parse(process.env.CELO_TESTNET_RPC_URL),
1687+
rpcs: rpcUrl
1688+
.default(["https://alfajores-forno.celo-testnet.org"])
1689+
.parse(process.env.CELO_TESTNET_RPC_URLS),
16901690
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
16911691
tokens: [
16921692
{
@@ -1725,9 +1725,9 @@ const CHAINS: Chain[] = [
17251725
{
17261726
id: 1088,
17271727
name: "metisAndromeda",
1728-
rpc: rpcUrl
1729-
.default("https://andromeda.metis.io/?owner=1088")
1730-
.parse(process.env.METIS_ANDROMEDA_RPC_URL),
1728+
rpcs: rpcUrl
1729+
.default(["https://andromeda.metis.io/?owner=1088"])
1730+
.parse(process.env.METIS_ANDROMEDA_RPC_URLS),
17311731
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
17321732
tokens: [
17331733
{

0 commit comments

Comments
 (0)