Skip to content

Commit

Permalink
chore: the graph migration for api endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
chefjackson committed May 31, 2024
1 parent 67bcaaa commit 37a91dd
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions apis/farms/src/bindings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ declare global {
const OPBNB_NODE: string
const OPBNB_TESTNET_NODE: string
const NODE_REAL_SUBGRAPH_API_KEY: string
const THE_GRAPH_API_KEY: string
}
11 changes: 7 additions & 4 deletions apis/farms/src/lpApr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ const blockClientWithChain = (chainId: FarmSupportedChainId) => {
}

const infoClientWithChain = (chainId: FarmSupportedChainId) => {
// @ts-ignore
return new GraphQLClient(getV2Subgraphs({ noderealApiKey: NODE_REAL_SUBGRAPH_API_KEY })[chainId], {
fetch,
})
return new GraphQLClient(
// @ts-ignore
getV2Subgraphs({ noderealApiKey: NODE_REAL_SUBGRAPH_API_KEY, theGraphApiKey: THE_GRAPH_API_KEY })[chainId],
{
fetch,
},
)
}

const stableSwapClient = new GraphQLClient(STABLESWAP_SUBGRAPH_ENDPOINT, {
Expand Down
1 change: 1 addition & 0 deletions apis/farms/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const requireCheck = [
OPBNB_NODE,
OPBNB_TESTNET_NODE,
NODE_REAL_SUBGRAPH_API_KEY,
THE_GRAPH_API_KEY,
]

const base = {
Expand Down
1 change: 1 addition & 0 deletions apis/farms/src/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type SupportChainId = (typeof V3_SUBGRAPH_CLIENTS_CHAIN_IDS)[number]

const V3_SUBGRAPHS = getV3Subgraphs({
noderealApiKey: NODE_REAL_SUBGRAPH_API_KEY,
theGraphApiKey: THE_GRAPH_API_KEY,
})

export const V3_SUBGRAPH_CLIENTS = V3_SUBGRAPH_CLIENTS_CHAIN_IDS.reduce((acc, chainId) => {
Expand Down
1 change: 1 addition & 0 deletions apis/farms/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ crons = ["0 0 * * *", "*/1 * * * *"]
# - LINEA_NODE
# - BASE_NODE
# - NODE_REAL_SUBGRAPH_API_KEY
# - THE_GRAPH_API_KEY
# Run `echo <VALUE> | wrangler secret put <NAME>` for each of these
1 change: 1 addition & 0 deletions apis/routing/src/bindings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare global {
const BSC_NODE: string
const BSC_TESTNET_NODE: string
const NODE_REAL_SUBGRAPH_API_KEY: string
const THE_GRAPH_API_KEY: string

const SUBGRAPH_POOLS: R2Bucket
}
3 changes: 2 additions & 1 deletion apis/routing/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GraphQLClient } from 'graphql-request'

import { SupportedChainId } from './constants'

const requireCheck = [ETH_NODE, GOERLI_NODE, BSC_NODE, BSC_TESTNET_NODE, NODE_REAL_SUBGRAPH_API_KEY]
const requireCheck = [ETH_NODE, GOERLI_NODE, BSC_NODE, BSC_TESTNET_NODE, NODE_REAL_SUBGRAPH_API_KEY, THE_GRAPH_API_KEY]
requireCheck.forEach((node) => {
if (!node) {
throw new Error('Missing env var')
Expand All @@ -15,6 +15,7 @@ requireCheck.forEach((node) => {

const V3_SUBGRAPHS = getV3Subgraphs({
noderealApiKey: NODE_REAL_SUBGRAPH_API_KEY,
theGraphApiKey: THE_GRAPH_API_KEY,
})

const mainnetClient = createPublicClient({
Expand Down
1 change: 1 addition & 0 deletions apis/routing/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ crons = ["*/30 * * * *"]
# - BSC_NODE
# - BSC_TESTNET_NODE
# - NODE_REAL_SUBGRAPH_API_KEY
# - THE_GRAPH_API_KEY
# Run `echo <VALUE> | wrangler secret put <NAME>` for each of these

0 comments on commit 37a91dd

Please sign in to comment.