-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy and update final subgraph URLs (#7)
* Deploy and update final subgraph URLs * refactor: upgrade to Map for TypeScript happiness
- Loading branch information
Showing
7 changed files
with
36 additions
and
50 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
2 changes: 1 addition & 1 deletion
2
apps/subgraph/config/ethereum-sepolia.json → apps/subgraph/config/sepolia.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,10 @@ | ||
import { CHAIN_ID } from 'src/typings' | ||
import {CHAIN_ID} from 'src/typings' | ||
|
||
// TODO: update all when all are deployed to the new BuilderDAO Goldsky account | ||
export const PUBLIC_SUBGRAPH_URL = { | ||
[CHAIN_ID.ETHEREUM]: | ||
'https://api.goldsky.com/api/public/project_clkk1ucdyf6ak38svcatie9tf/subgraphs/nouns-builder-ethereum-mainnet/stable/gn', | ||
[CHAIN_ID.OPTIMISM]: | ||
'https://api.goldsky.com/api/public/project_cm33ek8kjx6pz010i2c3w8z25/subgraphs/nouns-builder-optimism-mainnet/latest/gn', | ||
[CHAIN_ID.SEPOLIA]: | ||
'https://api.goldsky.com/api/public/project_cm33ek8kjx6pz010i2c3w8z25/subgraphs/nouns-builder-ethereum-sepolia/latest/gn', | ||
[CHAIN_ID.OPTIMISM_SEPOLIA]: | ||
'https://api.goldsky.com/api/public/project_clkk1ucdyf6ak38svcatie9tf/subgraphs/nouns-builder-optimism-sepolia/stable/gn', | ||
[CHAIN_ID.BASE]: | ||
'https://api.goldsky.com/api/public/project_cm33ek8kjx6pz010i2c3w8z25/subgraphs/nouns-builder-base-mainnet/latest/gn', | ||
[CHAIN_ID.BASE_SEPOLIA]: | ||
'https://api.goldsky.com/api/public/project_clkk1ucdyf6ak38svcatie9tf/subgraphs/nouns-builder-base-sepolia/stable/gn', | ||
[CHAIN_ID.ZORA]: | ||
'https://api.goldsky.com/api/public/project_clkk1ucdyf6ak38svcatie9tf/subgraphs/nouns-builder-zora-mainnet/stable/gn', | ||
[CHAIN_ID.ZORA_SEPOLIA]: | ||
'https://api.goldsky.com/api/public/project_clkk1ucdyf6ak38svcatie9tf/subgraphs/nouns-builder-zora-sepolia/stable/gn', | ||
[CHAIN_ID.FOUNDRY]: | ||
'https://api.thegraph.com/subgraphs/name/neokry/nouns-builder-mainnet', | ||
} | ||
export const PUBLIC_SUBGRAPH_URL: Map<CHAIN_ID, string> = new Map([ | ||
[CHAIN_ID.ETHEREUM, 'https://api.goldsky.com/api/public/project_cm33ek8kjx6pz010i2c3w8z25/subgraphs/nouns-builder-ethereum-mainnet/latest/gn'], | ||
[CHAIN_ID.OPTIMISM, 'https://api.goldsky.com/api/public/project_cm33ek8kjx6pz010i2c3w8z25/subgraphs/nouns-builder-optimism-mainnet/latest/gn'], | ||
[CHAIN_ID.SEPOLIA, 'https://api.goldsky.com/api/public/project_cm33ek8kjx6pz010i2c3w8z25/subgraphs/nouns-builder-ethereum-sepolia/latest/gn'], | ||
[CHAIN_ID.BASE, 'https://api.goldsky.com/api/public/project_cm33ek8kjx6pz010i2c3w8z25/subgraphs/nouns-builder-base-mainnet/latest/gn'], | ||
[CHAIN_ID.ZORA, 'https://api.goldsky.com/api/public/project_cm33ek8kjx6pz010i2c3w8z25/subgraphs/nouns-builder-zora-mainnet/latest/gn'], | ||
[CHAIN_ID.FOUNDRY, 'https://api.thegraph.com/subgraphs/name/neokry/nouns-builder-mainnet'] | ||
]); |
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,29 +1,29 @@ | ||
import { GraphQLClient } from 'graphql-request' | ||
import {GraphQLClient} from 'graphql-request' | ||
|
||
import { PUBLIC_SUBGRAPH_URL } from 'src/constants/subgraph' | ||
import { CHAIN_ID } from 'src/typings' | ||
import {CHAIN_ID} from 'src/typings' | ||
|
||
import { getSdk } from './sdk.generated' | ||
import {getSdk} from './sdk.generated' | ||
import {PUBLIC_SUBGRAPH_URL} from "src/constants/subgraph"; | ||
|
||
const globalForClient = global as unknown as { | ||
subgraphClient: Map<CHAIN_ID, GraphQLClient> | ||
subgraphClient: Map<CHAIN_ID, GraphQLClient> | ||
} | ||
|
||
export class SDK { | ||
static connect(chainId: CHAIN_ID) { | ||
if (!globalForClient.subgraphClient) globalForClient.subgraphClient = new Map() | ||
static connect(chainId: CHAIN_ID) { | ||
if (!globalForClient.subgraphClient) globalForClient.subgraphClient = new Map() | ||
|
||
const client = globalForClient.subgraphClient.has(chainId) | ||
? globalForClient.subgraphClient.get(chainId)! | ||
: new GraphQLClient(PUBLIC_SUBGRAPH_URL[chainId], { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
const client = globalForClient.subgraphClient.has(chainId) | ||
? globalForClient.subgraphClient.get(chainId)! | ||
: new GraphQLClient(PUBLIC_SUBGRAPH_URL.get(chainId) as string, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}) | ||
|
||
if (process.env.NODE_ENV !== 'production') | ||
globalForClient.subgraphClient.set(chainId, client) | ||
if (process.env.NODE_ENV !== 'production') | ||
globalForClient.subgraphClient.set(chainId, client) | ||
|
||
return getSdk(client) | ||
} | ||
return getSdk(client) | ||
} | ||
} |
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