From 53b004fac54624a6f546074a72121b0c473c9076 Mon Sep 17 00:00:00 2001 From: Julink Date: Sat, 13 Jul 2024 15:10:34 +0200 Subject: [PATCH] feat: added support for linea mainnet deployment on the frontend and subgraph --- .../linea-ens-app/src/constants/chains.ts | 20 ++++- .../src/constants/lineaMainnet.ts | 83 +++++++++++++++++++ .../src/constants/resolverAddressData.ts | 21 ++++- .../linea-ens-app/src/utils/query/wagmi.ts | 5 +- .../scripts/ownerRegister.ts | 2 +- .../scripts/setPohVerifierSigner.ts | 12 +-- packages/linea-ens-resolver/hardhat.config.ts | 1 + packages/linea-ens-subgraph/networks.json | 30 +++++++ packages/poh-signer-api/.env.mainnet | 2 +- 9 files changed, 163 insertions(+), 13 deletions(-) create mode 100644 packages/linea-ens-app/src/constants/lineaMainnet.ts diff --git a/packages/linea-ens-app/src/constants/chains.ts b/packages/linea-ens-app/src/constants/chains.ts index 21d459667..c0e0aef84 100644 --- a/packages/linea-ens-app/src/constants/chains.ts +++ b/packages/linea-ens-app/src/constants/chains.ts @@ -7,6 +7,7 @@ import { addEnsContracts } from '@ensdomains/ensjs' import type { Register } from '@app/local-contracts' import { makeLocalhostChainWithEns } from '@app/utils/chains/makeLocalhostChainWithEns' +import { lineaMainnet, lineaMainnetEnsAddresses } from './lineaMainnet' import { lineaSepolia, lineaSepoliaEnsAddresses } from './lineaSepolia' export const deploymentAddresses = JSON.parse( @@ -17,7 +18,7 @@ export const localhostWithEns = makeLocalhostChainWithEns( localhost, deploymentAddresses, ) -// TODO: Replace by linea mainnet after deployment is done +// This has to stay for the test files to be able to compile export const mainnetWithEns = addEnsContracts(mainnet) const addCustomEnsContracts = ( @@ -82,17 +83,28 @@ export const lineaSepoliaWithEns = addCustomEnsContracts( 'https://linea-poh-api-verifier.sepolia.linea.build', ) -export const chainsWithEns = [lineaSepoliaWithEns, localhostWithEns] as const +export const lineaMainnetWithEns = addCustomEnsContracts( + lineaMainnet, + lineaMainnetEnsAddresses, + 'https://api.studio.thegraph.com/query/69290/ens-linea-mainnet/version/latest', + 'linea', + 'https://linea-poh-signer-api.linea.build', +) + +export const chainsWithEns = [lineaMainnetWithEns, lineaSepoliaWithEns, localhostWithEns] as const export const getSupportedChainById = (chainId: number | undefined) => { return chainId ? chainsWithEns.find((c) => c.id === chainId) : undefined } export const getBaseDomain = (chain?: Chain) => { - return chain?.custom?.baseDomain ? chain.custom.baseDomain : 'linea-sepolia' + return chain?.custom?.baseDomain ? chain.custom.baseDomain : 'linea' } -export type SupportedChain = typeof localhostWithEns | typeof lineaSepoliaWithEns +export type SupportedChain = + | typeof localhostWithEns + | typeof lineaSepoliaWithEns + | typeof lineaMainnetWithEns type EnsAddresses = { ensRegistry: { diff --git a/packages/linea-ens-app/src/constants/lineaMainnet.ts b/packages/linea-ens-app/src/constants/lineaMainnet.ts new file mode 100644 index 000000000..63aba7ae2 --- /dev/null +++ b/packages/linea-ens-app/src/constants/lineaMainnet.ts @@ -0,0 +1,83 @@ +import { Address, defineChain } from 'viem' + +export const lineaMainnet = defineChain({ + id: 59_144, + name: 'Linea Mainnet', + network: 'linea-mainnet', + nativeCurrency: { name: 'Linea Ether', symbol: 'ETH', decimals: 18 }, + rpcUrls: { + infura: { + http: ['https://linea-mainnet.infura.io/v3'], + webSocket: ['wss://linea-mainnet.infura.io/ws/v3'], + }, + default: { + http: ['https://rpc.linea.build'], + webSocket: ['wss://rpc.linea.build'], + }, + public: { + http: ['https://rpc.linea.build'], + webSocket: ['wss://rpc.linea.build'], + }, + }, + blockExplorers: { + default: { + name: 'Etherscan', + url: 'https://lineascan.build', + }, + etherscan: { + name: 'Etherscan', + url: 'https://lineascan.build', + }, + blockscout: { + name: 'Blockscout', + url: 'https://explorer.linea.build', + }, + }, + contracts: { + ensRegistry: { + address: '0x50130b669B28C339991d8676FA73CF122a121267', + }, + ensUniversalResolver: { + address: '0x3aA974fb3f8C1E02796048BDCdeD79e9D53a6965', + blockCreated: 6_683_000, + }, + multicall3: { + address: '0xcA11bde05977b3631167028862bE2a173976CA11', + blockCreated: 42, + }, + }, + testnet: false, +}) + +export const lineaMainnetEnsAddresses = { + ensBaseRegistrarImplementation: { + address: '0x6e84390dCc5195414eC91A8c56A5c91021B95704' as Address, + }, + ensBulkRenewal: { + address: '0x236Eaa636f518d1c2252F408FdeaCe2FFfAC79Dc' as Address, + }, + ensDnsRegistrar: { + address: '0x103bd37229246c58243b7741DB8b3a22dC578511' as Address, + }, + ensDnssecImpl: { + address: '0xBE4C2Cb297Eab1614c43e4Aa9cDCDE71b2678204' as Address, + }, + ensEthRegistrarController: { + address: '0xDb75Db974B1F2bD3b5916d503036208064D18295' as Address, + }, + ensNameWrapper: { + address: '0xA53cca02F98D590819141Aa85C891e2Af713C223' as Address, + }, + ensPublicResolver: { + address: '0x86c5AED9F27837074612288610fB98ccC1733126' as Address, + }, + ensRegistry: { + address: '0x50130b669B28C339991d8676FA73CF122a121267' as Address, + }, + ensReverseRegistrar: { + address: '0x08D3fF6E65f680844fd2465393ff6f0d742b67D5' as Address, + }, + ensUniversalResolver: { + address: '0x3aA974fb3f8C1E02796048BDCdeD79e9D53a6965' as Address, + }, +} diff --git a/packages/linea-ens-app/src/constants/resolverAddressData.ts b/packages/linea-ens-app/src/constants/resolverAddressData.ts index 6d3602f89..3e5715edb 100644 --- a/packages/linea-ens-app/src/constants/resolverAddressData.ts +++ b/packages/linea-ens-app/src/constants/resolverAddressData.ts @@ -2,6 +2,7 @@ import { Address } from 'viem' import { deploymentAddresses } from './chains' +import { lineaMainnetEnsAddresses } from './lineaMainnet' import { lineaSepoliaEnsAddresses } from './lineaSepolia' import { RESOLVER_INTERFACE_IDS, ResolverInterfaceId } from './resolverInterfaceIds' @@ -389,7 +390,25 @@ export const KNOWN_RESOLVER_DATA: KnownResolverData = { RESOLVER_INTERFACE_IDS.VersionableResolver, ], }, - // TODO add for linea mainnet when deployed + ], + '59144': [ + { + address: lineaMainnetEnsAddresses.ensPublicResolver.address, + deployer: 'Consensys', + tag: 'latest', + isNameWrapperAware: true, + supportedInterfaces: [ + RESOLVER_INTERFACE_IDS.AddressResolver, + RESOLVER_INTERFACE_IDS.MultiCoinAddressResolver, + RESOLVER_INTERFACE_IDS.NameResolver, + RESOLVER_INTERFACE_IDS.AbiResolver, + RESOLVER_INTERFACE_IDS.TextResolver, + RESOLVER_INTERFACE_IDS.ContentHashResolver, + RESOLVER_INTERFACE_IDS.DnsRecordResolver, + RESOLVER_INTERFACE_IDS.InterfaceResolver, + RESOLVER_INTERFACE_IDS.VersionableResolver, + ], + }, ], ...(process.env.NEXT_PUBLIC_ETH_NODE === 'anvil' ? { diff --git a/packages/linea-ens-app/src/utils/query/wagmi.ts b/packages/linea-ens-app/src/utils/query/wagmi.ts index f0711c0c3..60fe81304 100644 --- a/packages/linea-ens-app/src/utils/query/wagmi.ts +++ b/packages/linea-ens-app/src/utils/query/wagmi.ts @@ -2,7 +2,8 @@ import { FallbackTransport, HttpTransport } from 'viem' import { createConfig, createStorage, fallback, http } from 'wagmi' import { localhost } from 'wagmi/chains' -import { lineaSepoliaWithEns, localhostWithEns } from '@app/constants/chains' +import { lineaMainnetWithEns, lineaSepoliaWithEns, localhostWithEns } from '@app/constants/chains' +import { lineaMainnet } from '@app/constants/lineaMainnet' import { lineaSepolia } from '@app/constants/lineaSepolia' import { WC_PROJECT_ID } from '../constants' @@ -75,6 +76,7 @@ const localStorageWithInvertMiddleware = (): Storage | undefined => { const chains = [ ...(isLocalProvider ? ([localhostWithEns] as const) : ([] as const)), + lineaMainnetWithEns, lineaSepoliaWithEns, ] as const @@ -100,6 +102,7 @@ const wagmiConfig_ = createConfig({ [localhost.id]: HttpTransport })), + [lineaMainnet.id]: initialiseTransports('linea-mainnet', [infuraUrl]), [lineaSepolia.id]: initialiseTransports('linea-sepolia', [infuraUrl]), }, }) diff --git a/packages/linea-ens-contracts/scripts/ownerRegister.ts b/packages/linea-ens-contracts/scripts/ownerRegister.ts index 8d85d020d..40f4c26f0 100644 --- a/packages/linea-ens-contracts/scripts/ownerRegister.ts +++ b/packages/linea-ens-contracts/scripts/ownerRegister.ts @@ -80,7 +80,7 @@ async function main(hre: HardhatRuntimeEnvironment) { break case 'lineaMainnet': registrarControllerAbi = loadAbi( - '../deployments/mainnet/ETHRegistrarController.json', + '../deployments/lineaMainnet/ETHRegistrarController.json', ) resolverAbi = loadAbi('../deployments/lineaMainnet/PublicResolver.json') rpcUrl = `https://linea-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}` diff --git a/packages/linea-ens-contracts/scripts/setPohVerifierSigner.ts b/packages/linea-ens-contracts/scripts/setPohVerifierSigner.ts index a1a0cf16b..c344d87d7 100644 --- a/packages/linea-ens-contracts/scripts/setPohVerifierSigner.ts +++ b/packages/linea-ens-contracts/scripts/setPohVerifierSigner.ts @@ -3,8 +3,7 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types' import 'dotenv/config' import pohVerifierLineaSepolia from '../deployments/lineaSepolia/PohVerifier.json' import { Contract } from 'ethers' -// TODO: Uncomment when deployed on linea mainnet -// import pohVerifierLineaMainnet from '../deployments/lineaMainnet/PohVerifier.json' +import pohVerifierLineaMainnet from '../deployments/lineaMainnet/PohVerifier.json' async function main(hre: HardhatRuntimeEnvironment) { const network = hre.network.name @@ -31,9 +30,12 @@ async function main(hre: HardhatRuntimeEnvironment) { throw 'Env POH_SIGNER_LINEA_MAINNET can not be undefined' } pohSignerAddr = process.env.POH_SIGNER_LINEA_MAINNET - // TODO: Uncomment when deployed on mainnet - // pohVerifier = new ethers.Contract(pohVerifierLineaMainnet.address,pohVerifierLineaMainnet.abi,owner) - throw 'Network not supported' + pohVerifier = new ethers.Contract( + pohVerifierLineaMainnet.address, + pohVerifierLineaMainnet.abi, + signer, + ) + break default: throw 'Network not supported' } diff --git a/packages/linea-ens-resolver/hardhat.config.ts b/packages/linea-ens-resolver/hardhat.config.ts index c49c0d3ba..61f4378b4 100644 --- a/packages/linea-ens-resolver/hardhat.config.ts +++ b/packages/linea-ens-resolver/hardhat.config.ts @@ -45,6 +45,7 @@ const config: HardhatUserConfig = { etherscan: { apiKey: { sepolia: process.env.ETHERSCAN_API_KEY ?? "", + mainnet: process.env.ETHERSCAN_API_KEY ?? "", }, }, }; diff --git a/packages/linea-ens-subgraph/networks.json b/packages/linea-ens-subgraph/networks.json index dc253c9b1..4b257267e 100644 --- a/packages/linea-ens-subgraph/networks.json +++ b/packages/linea-ens-subgraph/networks.json @@ -145,5 +145,35 @@ "address": "0xF127De9E039a789806fEd4C6b1C0f3aFfeA9425e", "startBlock": 2395202 } + }, + "linea": { + "ENSRegistry": { + "address": "0x50130b669B28C339991d8676FA73CF122a121267", + "startBlock": 6682888 + }, + "ENSRegistryOld": { + "address": "0x50130b669B28C339991d8676FA73CF122a121267", + "startBlock": 6682888 + }, + "Resolver": { + "address": "0x86c5AED9F27837074612288610fB98ccC1733126", + "startBlock": 6682994 + }, + "BaseRegistrar": { + "address": "0x6e84390dCc5195414eC91A8c56A5c91021B95704", + "startBlock": 6682892 + }, + "EthRegistrarControllerOld": { + "address": "0xb92aDAd547D0585FbF05f52aC6454A96938d6A92", + "startBlock": 6682966 + }, + "EthRegistrarController": { + "address": "0xDb75Db974B1F2bD3b5916d503036208064D18295", + "startBlock": 6682978 + }, + "NameWrapper": { + "address": "0xA53cca02F98D590819141Aa85C891e2Af713C223", + "startBlock": 6682956 + } } } \ No newline at end of file diff --git a/packages/poh-signer-api/.env.mainnet b/packages/poh-signer-api/.env.mainnet index 333dad29d..e7ba1220d 100644 --- a/packages/poh-signer-api/.env.mainnet +++ b/packages/poh-signer-api/.env.mainnet @@ -3,7 +3,7 @@ NODE_ENV=production PORT=3000 # Signer -VERIFIER_CONTRACT_ADDRESS=0xa904d832aBEBb150acde3Aa520cAC39B0970AF1b +VERIFIER_CONTRACT_ADDRESS=0xBf14cFAFD7B83f6de881ae6dc10796ddD7220831 # Poh API POH_API_URL=https://linea-xp-poh-api.linea.build