From ee3cd025a927fec7baf44faee6aa1b36b5b4d324 Mon Sep 17 00:00:00 2001 From: neokry Date: Mon, 24 Jul 2023 15:11:44 +0800 Subject: [PATCH] Add optimism deployment --- apps/subgraph/networks.json | 6 ++++++ apps/web/src/constants/addresses.ts | 2 ++ apps/web/src/constants/defaultChains.ts | 15 +++++++++++++-- apps/web/src/constants/etherscan.ts | 1 + apps/web/src/constants/rpc.ts | 1 + apps/web/src/constants/subgraph.ts | 2 ++ apps/web/src/data/contract/chains.ts | 4 ++-- apps/web/src/services/abiService.ts | 1 + apps/web/src/typings/index.tsx | 1 + 9 files changed, 29 insertions(+), 4 deletions(-) diff --git a/apps/subgraph/networks.json b/apps/subgraph/networks.json index 629a4d8d..9b1df593 100644 --- a/apps/subgraph/networks.json +++ b/apps/subgraph/networks.json @@ -5,6 +5,12 @@ "startBlock": 15799000 } }, + "optimism": { + "Manager": { + "address": "0x3ac0E64Fe2931f8e082C6Bb29283540DE9b5371C", + "startBlock": 107290000 + } + }, "goerli": { "Manager": { "address": "0x0E9F3382Cf2508E3bc83248B5b4707FbA86D7Ee0", diff --git a/apps/web/src/constants/addresses.ts b/apps/web/src/constants/addresses.ts index 74b29017..d3ef7e8c 100644 --- a/apps/web/src/constants/addresses.ts +++ b/apps/web/src/constants/addresses.ts @@ -2,6 +2,7 @@ import { AddressType, CHAIN_ID } from 'src/typings' export const PUBLIC_MANAGER_ADDRESS = { [CHAIN_ID.ETHEREUM]: '0xd310a3041dfcf14def5ccbc508668974b5da7174' as AddressType, + [CHAIN_ID.OPTIMISM]: '0x3ac0E64Fe2931f8e082C6Bb29283540DE9b5371C' as AddressType, [CHAIN_ID.GOERLI]: '0x0E9F3382Cf2508E3bc83248B5b4707FbA86D7Ee0' as AddressType, [CHAIN_ID.OPTIMISM_GOERLI]: '0x5f9c1e7E31875beAa6ba6B0AB573a4AbEcC95d67' as AddressType, [CHAIN_ID.BASE_GOERLI]: '0x550c326d688fD51ae65AC6A2d48749E631023A03' as AddressType, @@ -21,6 +22,7 @@ export const PUBLIC_NOUNS_ADDRESS = { export const PUBLIC_ZORA_NFT_CREATOR = { [CHAIN_ID.ETHEREUM]: '0xF74B146ce44CC162b601deC3BE331784DB111DC1' as AddressType, + [CHAIN_ID.OPTIMISM]: '0x7d1a46c6e614A0091c39E102F2798C27c1fA8892' as AddressType, [CHAIN_ID.GOERLI]: '0xb9583D05Ba9ba8f7F14CCEe3Da10D2bc0A72f519' as AddressType, [CHAIN_ID.OPTIMISM_GOERLI]: '0x3C1ebcF36Ca9DD9371c9aA99c274e4988906c6E3' as AddressType, [CHAIN_ID.BASE_GOERLI]: '0x87cfd516c5ea86e50b950678CA970a8a28de27ac' as AddressType, diff --git a/apps/web/src/constants/defaultChains.ts b/apps/web/src/constants/defaultChains.ts index c7bdc79b..610cfd29 100644 --- a/apps/web/src/constants/defaultChains.ts +++ b/apps/web/src/constants/defaultChains.ts @@ -1,4 +1,4 @@ -import { baseGoerli, goerli, mainnet, optimismGoerli } from 'wagmi/chains' +import { baseGoerli, goerli, mainnet, optimism, optimismGoerli } from 'wagmi/chains' import { CHAIN_ID, Chain } from 'src/typings' @@ -34,7 +34,18 @@ export const zoraGoerli = { } as const const MAINNET_CHAINS: Chain[] = [ - { ...mainnet, id: CHAIN_ID.ETHEREUM, slug: 'ethereum', icon: '/chains/ethereum.svg' }, + { + ...mainnet, + id: CHAIN_ID.ETHEREUM, + slug: 'ethereum', + icon: '/chains/ethereum.svg', + }, + { + ...optimism, + id: CHAIN_ID.OPTIMISM, + slug: 'optimism', + icon: '/chains/optimism.svg', + }, ] const TESTNET_CHAINS: Chain[] = [ diff --git a/apps/web/src/constants/etherscan.ts b/apps/web/src/constants/etherscan.ts index fc53993c..06ee22f1 100644 --- a/apps/web/src/constants/etherscan.ts +++ b/apps/web/src/constants/etherscan.ts @@ -2,6 +2,7 @@ import { CHAIN_ID } from 'src/typings' export const ETHERSCAN_BASE_URL = { [CHAIN_ID.ETHEREUM]: 'https://etherscan.io', + [CHAIN_ID.OPTIMISM]: 'https://optimistic.etherscan.io', [CHAIN_ID.GOERLI]: 'https://goerli.etherscan.io', [CHAIN_ID.OPTIMISM_GOERLI]: 'https://goerli-optimism.etherscan.io/', [CHAIN_ID.BASE_GOERLI]: 'https://goerli.basescan.org/', diff --git a/apps/web/src/constants/rpc.ts b/apps/web/src/constants/rpc.ts index 3fac235d..c6cf3f06 100644 --- a/apps/web/src/constants/rpc.ts +++ b/apps/web/src/constants/rpc.ts @@ -4,6 +4,7 @@ import { CHAIN_ID } from 'src/typings' export const RPC_URL = { [CHAIN_ID.ETHEREUM]: `https://eth-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID}`, + [CHAIN_ID.OPTIMISM]: `https://opt-mainnet.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID}`, [CHAIN_ID.GOERLI]: `https://eth-goerli.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID}`, [CHAIN_ID.OPTIMISM_GOERLI]: `https://opt-goerli.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID}`, [CHAIN_ID.BASE_GOERLI]: 'https://goerli.base.org', diff --git a/apps/web/src/constants/subgraph.ts b/apps/web/src/constants/subgraph.ts index 83b03aca..56e5835c 100644 --- a/apps/web/src/constants/subgraph.ts +++ b/apps/web/src/constants/subgraph.ts @@ -3,6 +3,8 @@ import { CHAIN_ID } from 'src/typings' export const PUBLIC_SUBGRAPH_URL = { [CHAIN_ID.ETHEREUM]: 'https://api.thegraph.com/subgraphs/name/neokry/nouns-builder-mainnet', + [CHAIN_ID.OPTIMISM]: + 'https://api.thegraph.com/subgraphs/name/neokry/noun-builder-optimism-mainnet', [CHAIN_ID.GOERLI]: 'https://api.thegraph.com/subgraphs/name/neokry/nouns-builder-goerli', [CHAIN_ID.OPTIMISM_GOERLI]: diff --git a/apps/web/src/data/contract/chains.ts b/apps/web/src/data/contract/chains.ts index 89f4da81..77369053 100644 --- a/apps/web/src/data/contract/chains.ts +++ b/apps/web/src/data/contract/chains.ts @@ -1,5 +1,5 @@ import { configureChains } from 'wagmi' -import { baseGoerli, goerli, mainnet, optimismGoerli } from 'wagmi/chains' +import { baseGoerli, goerli, mainnet, optimism, optimismGoerli } from 'wagmi/chains' import { alchemyProvider } from 'wagmi/providers/alchemy' import { jsonRpcProvider } from 'wagmi/providers/jsonRpc' @@ -7,7 +7,7 @@ import { PUBLIC_IS_TESTNET, zoraGoerli } from 'src/constants/defaultChains' import { RPC_URL } from 'src/constants/rpc' import { CHAIN_ID } from 'src/typings' -const MAINNET_CHAINS = [mainnet] +const MAINNET_CHAINS = [mainnet, optimism] // Mainnet is required here due to hooks like useEnsData that only pull data from mainnet const TESTNET_CHAINS = [mainnet, goerli, optimismGoerli, baseGoerli, zoraGoerli] diff --git a/apps/web/src/services/abiService.ts b/apps/web/src/services/abiService.ts index ff283cf6..274fefec 100644 --- a/apps/web/src/services/abiService.ts +++ b/apps/web/src/services/abiService.ts @@ -21,6 +21,7 @@ export type ContractABIResult = { const CHAIN_API_LOOKUP: Record = { [CHAIN_ID.ETHEREUM]: 'api.etherscan.io', + [CHAIN_ID.OPTIMISM]: 'api-optimistic.etherscan.io', [CHAIN_ID.GOERLI]: 'api-goerli.etherscan.io', [CHAIN_ID.OPTIMISM_GOERLI]: 'api-goerli-optimistic.etherscan.io', [CHAIN_ID.BASE_GOERLI]: 'api-goerli.basescan.org', diff --git a/apps/web/src/typings/index.tsx b/apps/web/src/typings/index.tsx index 82136665..49d256e5 100644 --- a/apps/web/src/typings/index.tsx +++ b/apps/web/src/typings/index.tsx @@ -10,6 +10,7 @@ export interface Duration { export const enum CHAIN_ID { ETHEREUM = 1, GOERLI = 5, + OPTIMISM = 10, OPTIMISM_GOERLI = 420, BASE_GOERLI = 84531, ZORA_GOERLI = 999,