Skip to content

Commit

Permalink
feat: add support fallback rpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavaparoksham committed Sep 9, 2024
1 parent b6eb77b commit d824010
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 95 deletions.
32 changes: 16 additions & 16 deletions indexer-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ services:
IPFS_GATEWAY: ${IPFS_GATEWAY}
COINGECKO_API_KEY: ${COINGECKO_API_KEY}
GRAPHILE_LICENSE: ${GRAPHILE_LICENSE}
SEPOLIA_RPC_URL: ${SEPOLIA_RPC_URL}
POLYGON_MUMBAI_RPC_URL: ${POLYGON_MUMBAI_RPC_URL}
AVALANCHE_RPC_URL: ${AVALANCHE_RPC_URL}
OPTIMISM_RPC_URL: ${OPTIMISM_RPC_URL}
SEPOLIA_RPC_URLS: ${SEPOLIA_RPC_URLS}
POLYGON_MUMBAI_RPC_URLS: ${POLYGON_MUMBAI_RPC_URLS}
AVALANCHE_RPC_URLS: ${AVALANCHE_RPC_URLS}
OPTIMISM_RPC_URLS: ${OPTIMISM_RPC_URLS}
SENTRY_DSN: ${SENTRY_DSN}
PGN_TESTNET_RPC_URL: ${PGN_TESTNET_RPC_URL}
ARBITRUM_GOERLI_RPC_URL: ${ARBITRUM_GOERLI_RPC_URL}
FANTOM_RPC_URL: ${FANTOM_RPC_URL}
BASE_RPC_URL: ${BASE_RPC_URL}
PGN_RPC_URL: ${PGN_RPC_URL}
GOERLI_RPC_URL: ${GOERLI_RPC_URL}
AVALANCHE_FUJI_RPC_URL: ${AVALANCHE_FUJI_RPC_URL}
ARBITRUM_RPC_URL: ${ARBITRUM_RPC_URL}
SEI_MAINNET_RPC_URL: ${SEI_MAINNET_RPC_URL}
MAINNET_RPC_URL: ${MAINNET_RPC_URL}
POLYGON_RPC_URL: ${POLYGON_RPC_URL}
METIS_ANDROMEDA_RPC_URL: ${METIS_ANDROMEDA_RPC_URL}
SCROLL_SEPOLIA_RPC_URL: ${SCROLL_SEPOLIA_RPC_URL}
ARBITRUM_GOERLI_RPC_URLS: ${ARBITRUM_GOERLI_RPC_URLS}
FANTOM_RPC_URLS: ${FANTOM_RPC_URLS}
BASE_RPC_URLS: ${BASE_RPC_URLS}
PGN_RPC_URLS: ${PGN_RPC_URLS}
GOERLI_RPC_URLS: ${GOERLI_RPC_URLS}
AVALANCHE_FUJI_RPC_URLS: ${AVALANCHE_FUJI_RPC_URLS}
ARBITRUM_RPC_URLS: ${ARBITRUM_RPC_URLS}
SEI_MAINNET_RPC_URLS: ${SEI_MAINNET_RPC_URLS}
MAINNET_RPC_URLS: ${MAINNET_RPC_URLS}
POLYGON_RPC_URLS: ${POLYGON_RPC_URLS}
METIS_ANDROMEDA_RPC_URLS: ${METIS_ANDROMEDA_RPC_URLS}
SCROLL_SEPOLIA_RPC_URLS: ${SCROLL_SEPOLIA_RPC_URLS}
DATABASE_URL: "postgresql://postgres:postgres@db:5432/grants_stack_indexer"

index:
Expand Down
142 changes: 71 additions & 71 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type Subscription = {
};

export type Chain = {
rpc: string;
rpcs: string[];
name: string;
id: ChainId;
pricesFromTimestamp: number;
Expand All @@ -47,15 +47,15 @@ export type Chain = {
maxGetLogsRange?: number;
};

const rpcUrl = z.string().url();
const rpcUrl = z.array(z.string().url());

const CHAINS: Chain[] = [
{
id: 1,
name: "mainnet",
rpc: rpcUrl
.default("https://mainnet.infura.io/v3/")
.parse(process.env.MAINNET_RPC_URL),
rpcs: rpcUrl
.default(["https://mainnet.infura.io/v3/"])
.parse(process.env.MAINNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -150,9 +150,9 @@ const CHAINS: Chain[] = [
{
id: 10,
name: "optimism",
rpc: rpcUrl
.default("https://optimism-rpc.publicnode.com")
.parse(process.env.OPTIMISM_RPC_URL),
rpcs: rpcUrl
.default(["https://optimism-rpc.publicnode.com"])
.parse(process.env.OPTIMISM_RPC_URLS),
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -266,9 +266,9 @@ const CHAINS: Chain[] = [
{
id: 11155111,
name: "sepolia",
rpc: rpcUrl
.default("https://ethereum-sepolia.publicnode.com")
.parse(process.env.SEPOLIA_RPC_URL),
rpcs: rpcUrl
.default(["https://ethereum-sepolia.publicnode.com"])
.parse(process.env.SEPOLIA_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 11, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -370,9 +370,9 @@ const CHAINS: Chain[] = [
{
id: 250,
name: "fantom",
rpc: rpcUrl
.default("https://rpcapi.fantom.network")
.parse(process.env.FANTOM_RPC_URL),
rpcs: rpcUrl
.default(["https://rpcapi.fantom.network"])
.parse(process.env.FANTOM_RPC_URLS),
pricesFromTimestamp: Date.UTC(2022, 11, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -469,9 +469,9 @@ const CHAINS: Chain[] = [
{
id: 58008,
name: "pgn-testnet",
rpc: rpcUrl
.default("https://sepolia.publicgoods.network")
.parse(process.env.PGN_TESTNET_RPC_URL),
rpcs: rpcUrl
.default(["https://sepolia.publicgoods.network"])
.parse(process.env.PGN_TESTNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 5, 2, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -522,9 +522,9 @@ const CHAINS: Chain[] = [
{
id: 424,
name: "pgn-mainnet",
rpc: rpcUrl
.default("https://rpc.publicgoods.network")
.parse(process.env.PGN_RPC_URL),
rpcs: rpcUrl
.default(["https://rpc.publicgoods.network"])
.parse(process.env.PGN_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 5, 2, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -600,9 +600,9 @@ const CHAINS: Chain[] = [
{
id: 42161,
name: "arbitrum",
rpc: rpcUrl
.default("https://arb-mainnet.g.alchemy.com/v2/")
.parse(process.env.ARBITRUM_RPC_URL),
rpcs: rpcUrl
.default(["https://arb-mainnet.g.alchemy.com/v2/"])
.parse(process.env.ARBITRUM_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 7, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -713,9 +713,9 @@ const CHAINS: Chain[] = [
{
id: 80001,
name: "polygon-mumbai",
rpc: rpcUrl
.default("https://rpc-mumbai.maticvigil.com/")
.parse(process.env.POLYGON_MUMBAI_RPC_URL),
rpcs: rpcUrl
.default(["https://rpc-mumbai.maticvigil.com/"])
.parse(process.env.POLYGON_MUMBAI_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -793,9 +793,9 @@ const CHAINS: Chain[] = [
{
id: 137,
name: "polygon",
rpc: rpcUrl
.default("https://polygon-rpc.com")
.parse(process.env.POLYGON_RPC_URL),
rpcs: rpcUrl
.default(["https://polygon-rpc.com"])
.parse(process.env.POLYGON_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -891,9 +891,9 @@ const CHAINS: Chain[] = [
{
id: 8453,
name: "base",
rpc: rpcUrl
.default("https://mainnet.base.org/")
.parse(process.env.BASE_RPC_URL),
rpcs: rpcUrl
.default(["https://mainnet.base.org/"])
.parse(process.env.BASE_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -971,9 +971,9 @@ const CHAINS: Chain[] = [
{
id: 324,
name: "zksync-era-mainnet",
rpc: rpcUrl
.default("https://mainnet.era.zksync.io")
.parse(process.env.ZKSYNC_RPC_URL),
rpcs: rpcUrl
.default(["https://mainnet.era.zksync.io"])
.parse(process.env.ZKSYNC_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1086,9 +1086,9 @@ const CHAINS: Chain[] = [
{
id: 300,
name: "zksync-era-testnet",
rpc: rpcUrl
.default("https://sepolia.era.zksync.dev")
.parse(process.env.ZKSYNC_TESTNET_RPC_URL),
rpcs: rpcUrl
.default(["https://sepolia.era.zksync.dev"])
.parse(process.env.ZKSYNC_TESTNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 12, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1126,9 +1126,9 @@ const CHAINS: Chain[] = [
{
id: 43114,
name: "avalanche",
rpc: rpcUrl
.default("https://rpc.ankr.com/avalanche")
.parse(process.env.AVALANCHE_RPC_URL),
rpcs: rpcUrl
.default(["https://rpc.ankr.com/avalanche"])
.parse(process.env.AVALANCHE_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1206,9 +1206,9 @@ const CHAINS: Chain[] = [
{
id: 43113,
name: "avalanche-fuji",
rpc: rpcUrl
.default("https://avalanche-fuji-c-chain.publicnode.com")
.parse(process.env.AVALANCHE_FUJI_RPC_URL),
rpcs: rpcUrl
.default(["https://avalanche-fuji-c-chain.publicnode.com"])
.parse(process.env.AVALANCHE_FUJI_RPC_URLS),
pricesFromTimestamp: Date.UTC(2023, 8, 19, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1276,9 +1276,9 @@ const CHAINS: Chain[] = [
{
id: 534351,
name: "scroll-sepolia",
rpc: rpcUrl
.default("https://sepolia-rpc.scroll.io")
.parse(process.env.SCROLL_SEPOLIA_RPC_URL),
rpcs: rpcUrl
.default(["https://sepolia-rpc.scroll.io"])
.parse(process.env.SCROLL_SEPOLIA_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
maxGetLogsRange: 2000,
tokens: [
Expand Down Expand Up @@ -1347,9 +1347,9 @@ const CHAINS: Chain[] = [
{
id: 534352,
name: "scroll",
rpc: rpcUrl
.default("https://rpc.scroll.io")
.parse(process.env.SCROLL_RPC_URL),
rpcs: rpcUrl
.default(["https://rpc.scroll.io"])
.parse(process.env.SCROLL_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
maxGetLogsRange: 9000,
tokens: [
Expand Down Expand Up @@ -1433,9 +1433,9 @@ const CHAINS: Chain[] = [
{
id: 713715,
name: "sei-devnet",
rpc: rpcUrl
.default("https://evm-rpc-arctic-1.sei-apis.com")
.parse(process.env.SEI_DEVNET_RPC_URL),
rpcs: rpcUrl
.default(["https://evm-rpc-arctic-1.sei-apis.com"])
.parse(process.env.SEI_DEVNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1483,9 +1483,9 @@ const CHAINS: Chain[] = [
{
id: 1329,
name: "sei-mainnet",
rpc: rpcUrl
.default("https://evm-rpc.sei-apis.com")
.parse(process.env.SEI_MAINNET_RPC_URL),
rpcs: rpcUrl
.default(["https://evm-rpc.sei-apis.com"])
.parse(process.env.SEI_MAINNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
maxGetLogsRange: 10000,
tokens: [
Expand Down Expand Up @@ -1534,9 +1534,9 @@ const CHAINS: Chain[] = [
{
id: 42,
name: "lukso-mainnet",
rpc: rpcUrl
.default("https://42.rpc.thirdweb.com")
.parse(process.env.LUKSO_MAINNET_RPC_URL),
rpcs: rpcUrl
.default(["https://42.rpc.thirdweb.com"])
.parse(process.env.LUKSO_MAINNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1584,9 +1584,9 @@ const CHAINS: Chain[] = [
{
id: 4201,
name: "lukso-testnet",
rpc: rpcUrl
.default("https://4201.rpc.thirdweb.com")
.parse(process.env.LUKSO_TESTNET_RPC_URL),
rpcs: rpcUrl
.default(["https://4201.rpc.thirdweb.com"])
.parse(process.env.LUKSO_TESTNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1625,9 +1625,9 @@ const CHAINS: Chain[] = [
{
id: 42220,
name: "celo-mainnet",
rpc: rpcUrl
.default("https://forno.celo.org")
.parse(process.env.CELO_MAINNET_RPC_URL),
rpcs: rpcUrl
.default(["https://forno.celo.org"])
.parse(process.env.CELO_MAINNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1684,9 +1684,9 @@ const CHAINS: Chain[] = [
{
id: 44787,
name: "celo-testnet",
rpc: rpcUrl
.default("https://alfajores-forno.celo-testnet.org")
.parse(process.env.CELO_TESTNET_RPC_URL),
rpcs: rpcUrl
.default(["https://alfajores-forno.celo-testnet.org"])
.parse(process.env.CELO_TESTNET_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
tokens: [
{
Expand Down Expand Up @@ -1725,9 +1725,9 @@ const CHAINS: Chain[] = [
{
id: 1088,
name: "metisAndromeda",
rpc: rpcUrl
.default("https://andromeda.metis.io/?owner=1088")
.parse(process.env.METIS_ANDROMEDA_RPC_URL),
rpcs: rpcUrl
.default(["https://andromeda.metis.io/?owner=1088"])
.parse(process.env.METIS_ANDROMEDA_RPC_URLS),
pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0),
tokens: [
{
Expand Down
Loading

0 comments on commit d824010

Please sign in to comment.