Skip to content

Commit

Permalink
Deploy and update final subgraph URLs (#7)
Browse files Browse the repository at this point in the history
* Deploy and update final subgraph URLs
* refactor: upgrade to Map for TypeScript happiness
  • Loading branch information
0xMillz authored Dec 6, 2024
1 parent ad054d5 commit 4f95b86
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 50 deletions.
10 changes: 5 additions & 5 deletions apps/subgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ You can now query the subgraph in the Goldsky GraphQL playground to test your ch

The subgraph is currently deployed to the following networks:

- [Ethereum](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-ethereum/latest/gn)
- [Base](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-base/latest/gn)
- [Optimism](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-optimism/latest/gn)
- TODO: [Zora](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-zora/latest/gn)
- TODO?: [Ethereum Sepolia](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-ethereum-sepolia/latest/gn)
- [Ethereum](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-ethereum-mainnet/latest/gn)
- [Base](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-base-mainnet/latest/gn)
- [Optimism](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-optimism-mainnet/latest/gn)
- [Zora](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-zora-mainnet/latest/gn)
- [Ethereum Sepolia](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-ethereum-sepolia/latest/gn)
- TODO?: [Optimism Sepolia](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-optimism-sepolia/latest/gn)
- TODO?: [Zora Sepolia](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-zora-sepolia/latest/gn)
- TODO?: [Base Sepolia](https://api.goldsky.com/api/public/<project name>/subgraphs/nouns-builder-base-sepolia/latest/gn)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"network": "ethereum-sepolia",
"network": "sepolia",
"manager": {
"address": "0x0ca90a96ac58f19b1f69f67103245c9263bc4bfc",
"startBlock": 5074430
Expand Down
2 changes: 1 addition & 1 deletion apps/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"clean": "rm -rf ./generated ./build subgraph.yaml",
"build:subgraph": "graph build",
"codegen": "graph codegen",
"prepare:ethereum-sepolia": "mustache config/ethereum-sepolia.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:ethereum-sepolia": "mustache config/sepolia.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:ethereum": "mustache config/ethereum.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:base": "mustache config/base.json subgraph.yaml.mustache > subgraph.yaml",
"prepare:base-sepolia": "mustache config/base-sepolia.json subgraph.yaml.mustache > subgraph.yaml",
Expand Down
3 changes: 1 addition & 2 deletions apps/web/src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export const L2_MIGRATION_DEPLOYER = {
[CHAIN_ID.ETHEREUM]: '0x0000000000000000000000000000000000000000' as AddressType,
[CHAIN_ID.OPTIMISM]: '0x7D8Ea0D056f5B8443cdD8495D4e90FFCf0a8A354' as AddressType,
[CHAIN_ID.SEPOLIA]: '0x0000000000000000000000000000000000000000' as AddressType,
[CHAIN_ID.OPTIMISM_SEPOLIA]:
'0xF3a4ca161a88e26115d1C1DBcB8C4874E1786F42' as AddressType,
[CHAIN_ID.OPTIMISM_SEPOLIA]: '0xF3a4ca161a88e26115d1C1DBcB8C4874E1786F42' as AddressType,
[CHAIN_ID.BASE]: '0x8ef7b563Ff9F4A1f2d294845000cDf782d9afd7c' as AddressType,
[CHAIN_ID.BASE_SEPOLIA]: '0x1e57Cad7C22042BD765011d0F2eb36606Fe12C3F' as AddressType,
[CHAIN_ID.ZORA]: '0x7D8Ea0D056f5B8443cdD8495D4e90FFCf0a8A354' as AddressType,
Expand Down
31 changes: 9 additions & 22 deletions apps/web/src/constants/subgraph.ts
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']
]);
36 changes: 18 additions & 18 deletions apps/web/src/data/subgraph/client.ts
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)
}
}
2 changes: 1 addition & 1 deletion apps/web/src/typings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface Duration {
minutes?: number
}

export const enum CHAIN_ID {
export enum CHAIN_ID {
ETHEREUM = 1,
SEPOLIA = 11155111,
OPTIMISM = 10,
Expand Down

0 comments on commit 4f95b86

Please sign in to comment.