Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ NEXT_PUBLIC_SUBGRAPH_ID=FE63YgkzcpVocxdCEyEYbvjYqEf2kb1A6daMYRxmejYC
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=
NEXT_PUBLIC_METRICS_SERVER_URL=https://livepeer-leaderboard-serverless.vercel.app
NEXT_PUBLIC_AI_METRICS_SERVER_URL=https://leaderboard-api.livepeer.cloud

# Optional dev overrides (e.g. Graph Studio sandbox; leave empty in prod)
NEXT_PUBLIC_SUBGRAPH_ENDPOINT=
15 changes: 11 additions & 4 deletions lib/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ const SUBGRAPH_KEY = process.env.NEXT_PUBLIC_SUBGRAPH_API_KEY;
const SUBGRAPH_ID =
process.env.NEXT_PUBLIC_SUBGRAPH_ID ||
"FE63YgkzcpVocxdCEyEYbvjYqEf2kb1A6daMYRxmejYC";
const SUBGRAPH_URL_OVERRIDE = process.env.NEXT_PUBLIC_SUBGRAPH_ENDPOINT;

// Check for required environment variables.
if (!INFURA_KEY || !NETWORK) {
throw new Error(
`NEXT_PUBLIC_INFURA_KEY and NETWORK must be defined environment variables`
);
}
if (!SUBGRAPH_KEY) {
if (!SUBGRAPH_KEY && !SUBGRAPH_URL_OVERRIDE) {
throw new Error(
`NEXT_PUBLIC_SUBGRAPH_API_KEY must be defined environment variables`
`NEXT_PUBLIC_SUBGRAPH_API_KEY (or NEXT_PUBLIC_SUBGRAPH_ENDPOINT override) must be defined environment variables`
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message uses plural "environment variables" when referring to a requirement that only one of the two variables needs to be defined. Consider changing to "must be defined as an environment variable" for grammatical correctness.

Copilot uses AI. Check for mistakes.
);
Comment on lines +26 to 29
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation logic allows either SUBGRAPH_KEY or SUBGRAPH_URL_OVERRIDE to be set, but when SUBGRAPH_URL_OVERRIDE is not provided, the code will still attempt to use SUBGRAPH_KEY in the URL template strings. This means if only SUBGRAPH_URL_OVERRIDE is set (without SUBGRAPH_KEY), the validation passes but undefined will be interpolated into the fallback URLs. Consider validating that SUBGRAPH_KEY is defined when SUBGRAPH_URL_OVERRIDE is not set.

Copilot uses AI. Check for mistakes.
}

Expand Down Expand Up @@ -153,7 +154,9 @@ export const CHAIN_INFO = {
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
rpcUrl: INFURA_NETWORK_URLS[chain.mainnet.id],
},
subgraph: `https://gateway.thegraph.com/api/${SUBGRAPH_KEY}/subgraphs/id/${SUBGRAPH_ID}`,
subgraph:
SUBGRAPH_URL_OVERRIDE ||
`https://gateway.thegraph.com/api/${SUBGRAPH_KEY}/subgraphs/id/${SUBGRAPH_ID}`,
contracts: MAINNET_CONTRACTS,
},
// TODO this needs to be updated
Expand All @@ -169,6 +172,7 @@ export const CHAIN_INFO = {
rpcUrl: INFURA_NETWORK_URLS[chain.goerli.id],
},
subgraph:
SUBGRAPH_URL_OVERRIDE ||
"https://api.thegraph.com/subgraphs/name/livepeer/arbitrum-goerli",
contracts: ARBITRUM_GOERLI_CONTRACTS,
},
Expand All @@ -185,7 +189,9 @@ export const CHAIN_INFO = {
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
rpcUrl: "https://arb1.arbitrum.io/rpc",
},
subgraph: `https://gateway.thegraph.com/api/${SUBGRAPH_KEY}/subgraphs/id/${SUBGRAPH_ID}`,
subgraph:
SUBGRAPH_URL_OVERRIDE ||
`https://gateway.thegraph.com/api/${SUBGRAPH_KEY}/subgraphs/id/${SUBGRAPH_ID}`,
contracts: ARBITRUM_ONE_CONTRACTS,
},
[chain.arbitrumGoerli.id]: {
Expand All @@ -206,6 +212,7 @@ export const CHAIN_INFO = {
rpcUrl: "https://goerli-rollup.arbitrum.io/rpc",
},
subgraph:
SUBGRAPH_URL_OVERRIDE ||
"https://api.thegraph.com/subgraphs/name/livepeer/arbitrum-goerli",
contracts: ARBITRUM_GOERLI_CONTRACTS,
},
Expand Down