-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use runtime env instead of build env for thegraph token
- Loading branch information
1 parent
f7e7568
commit abed135
Showing
9 changed files
with
101 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,67 @@ | ||
import getConfig from 'next/config' | ||
|
||
import { ApolloClient, InMemoryCache } from '@apollo/client' | ||
|
||
const { publicRuntimeConfig } = getConfig() | ||
const API_KEY = publicRuntimeConfig.THEGRAPH_API_KEY as string | ||
|
||
export const GnosisClient = new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/FPPoFB7S2dcCNrRyjM5QbaMwKqRZPdbTg8ysBrwXd4SP`, | ||
cache: new InMemoryCache(), | ||
}) | ||
|
||
export const EthereumClient = new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/EVjGN4mMd9h9JfGR7yLC6T2xrJf9syhjQNboFb7GzxVW`, | ||
cache: new InMemoryCache(), | ||
}) | ||
|
||
export const RMM2Client = new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/CxvZgcPjmtvFeSoSW9N563K7ZcHCwLVv8kXMbmuBKhv1`, | ||
cache: new InMemoryCache(), | ||
}) | ||
|
||
export const RMM3Client = new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/2xrWGGZ5r8Z7wdNdHxhbRVKcAD2dDgv3F2NcjrZmxifJ`, | ||
cache: new InMemoryCache(), | ||
}) | ||
|
||
export const RMM3WrapperClient = new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/2dMMk7DbQYPX6Gi5siJm6EZ2gDQBF8nJcgKtpiPnPBsK`, | ||
cache: new InMemoryCache(), | ||
}) | ||
|
||
export const LevinSwapClient = new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/2zkYvVc8xsmytcEjE9pr523qFcbvqRGxhuGGtraozs66`, | ||
cache: new InMemoryCache(), | ||
}) | ||
|
||
export const YamStatisticsClient = new ApolloClient({ | ||
uri: 'https://api.thegraph.com/subgraphs/name/jycssu-com/yam-history-gnosis', | ||
// uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/4eJa4rKCR5f8fq48BKbYBPvf7DWHppGZRvfiVUSFXBGR`, | ||
cache: new InMemoryCache(), | ||
}) | ||
function lazyInit<T>(fn: (API_KEY: string) => T) { | ||
let result: T | undefined | ||
return () => { | ||
if (!result) { | ||
result = fn(process.env.THEGRAPH_API_KEY ?? '') | ||
} | ||
return result | ||
} | ||
} | ||
|
||
export const GnosisClient = lazyInit( | ||
(API_KEY: string) => | ||
new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/FPPoFB7S2dcCNrRyjM5QbaMwKqRZPdbTg8ysBrwXd4SP`, | ||
cache: new InMemoryCache(), | ||
}), | ||
) | ||
|
||
export const EthereumClient = lazyInit( | ||
(API_KEY: string) => | ||
new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/EVjGN4mMd9h9JfGR7yLC6T2xrJf9syhjQNboFb7GzxVW`, | ||
cache: new InMemoryCache(), | ||
}), | ||
) | ||
|
||
export const RMM2Client = lazyInit( | ||
(API_KEY: string) => | ||
new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/CxvZgcPjmtvFeSoSW9N563K7ZcHCwLVv8kXMbmuBKhv1`, | ||
cache: new InMemoryCache(), | ||
}), | ||
) | ||
|
||
export const RMM3Client = lazyInit( | ||
(API_KEY: string) => | ||
new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/2xrWGGZ5r8Z7wdNdHxhbRVKcAD2dDgv3F2NcjrZmxifJ`, | ||
cache: new InMemoryCache(), | ||
}), | ||
) | ||
|
||
export const RMM3WrapperClient = lazyInit( | ||
(API_KEY: string) => | ||
new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/2dMMk7DbQYPX6Gi5siJm6EZ2gDQBF8nJcgKtpiPnPBsK`, | ||
cache: new InMemoryCache(), | ||
}), | ||
) | ||
|
||
export const LevinSwapClient = lazyInit( | ||
(API_KEY: string) => | ||
new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/2zkYvVc8xsmytcEjE9pr523qFcbvqRGxhuGGtraozs66`, | ||
cache: new InMemoryCache(), | ||
}), | ||
) | ||
|
||
export const YamStatisticsClient = lazyInit( | ||
(API_KEY: string) => | ||
new ApolloClient({ | ||
uri: `https://gateway-arbitrum.network.thegraph.com/api/${API_KEY}/subgraphs/id/4eJa4rKCR5f8fq48BKbYBPvf7DWHppGZRvfiVUSFXBGR`, | ||
cache: new InMemoryCache(), | ||
}), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters