Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix usage of chains
  • Loading branch information
alexandre-abrioux committed Apr 17, 2025
commit da33c4aed04511e06a918a2f959fc8d60f5acfd9
18 changes: 9 additions & 9 deletions packages/payment-detection/src/thegraph/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,29 @@ export const defaultGetTheGraphClientUrl = (
network: CurrencyTypes.ChainName,
options?: TheGraphClientOptions,
) => {
const filteredNetwork = network.replace('aurora', 'near');
const theGraphExplorerSubgraphId = THE_GRAPH_EXPLORER_SUBGRAPH_ID[network];
const chain = network.replace('aurora', 'near') as CurrencyTypes.ChainName;
const theGraphExplorerSubgraphId = THE_GRAPH_EXPLORER_SUBGRAPH_ID[chain];
const { theGraphExplorerApiKey } = options || {};

// build URLs
const theGraphStudioUrl = THE_GRAPH_STUDIO_URL.replace('$NETWORK', filteredNetwork);
const theGraphStudioUrl = THE_GRAPH_STUDIO_URL.replace('$NETWORK', chain);
const theGraphExplorerUrl = THE_GRAPH_EXPLORER_URL.replace(
'$API_KEY',
theGraphExplorerApiKey || '',
).replace('$SUBGRAPH_ID', theGraphExplorerSubgraphId || '');
const theGraphAlchemyUrl = THE_GRAPH_ALCHEMY_URL.replace('$NETWORK', filteredNetwork);
const theGraphAlchemyUrl = THE_GRAPH_ALCHEMY_URL.replace('$NETWORK', chain);

const shouldUseTheGraphExplorer = !!theGraphExplorerApiKey && !!theGraphExplorerSubgraphId;
const shouldUseAlchemy = THE_GRAPH_ALCHEMY_CHAINS.includes(network);
const shouldUseAlchemy = THE_GRAPH_ALCHEMY_CHAINS.includes(chain);

switch (true) {
case network === 'private':
case chain === 'private':
return;
case network === 'mantle':
case chain === 'mantle':
return THE_GRAPH_URL_MANTLE;
case network === 'mantle-testnet':
case chain === 'mantle-testnet':
return THE_GRAPH_URL_MANTLE_TESTNET;
case network === 'core':
case chain === 'core':
return THE_GRAPH_URL_CORE;
default:
return shouldUseTheGraphExplorer
Expand Down