Skip to content

Commit

Permalink
feat: added support for linea mainnet deployment on the frontend and …
Browse files Browse the repository at this point in the history
…subgraph
  • Loading branch information
Julink-eth committed Jul 13, 2024
1 parent ce89636 commit 53b004f
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 13 deletions.
20 changes: 16 additions & 4 deletions packages/linea-ens-app/src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -17,7 +18,7 @@ export const localhostWithEns = makeLocalhostChainWithEns<typeof localhost>(
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 = <const TChain extends Chain>(
Expand Down Expand Up @@ -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: {
Expand Down
83 changes: 83 additions & 0 deletions packages/linea-ens-app/src/constants/lineaMainnet.ts
Original file line number Diff line number Diff line change
@@ -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,
},
}
21 changes: 20 additions & 1 deletion packages/linea-ens-app/src/constants/resolverAddressData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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'
? {
Expand Down
5 changes: 4 additions & 1 deletion packages/linea-ens-app/src/utils/query/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -75,6 +76,7 @@ const localStorageWithInvertMiddleware = (): Storage | undefined => {

const chains = [
...(isLocalProvider ? ([localhostWithEns] as const) : ([] as const)),
lineaMainnetWithEns,
lineaSepoliaWithEns,
] as const

Expand All @@ -100,6 +102,7 @@ const wagmiConfig_ = createConfig({
[localhost.id]: HttpTransport
})),

[lineaMainnet.id]: initialiseTransports('linea-mainnet', [infuraUrl]),
[lineaSepolia.id]: initialiseTransports('linea-sepolia', [infuraUrl]),
},
})
Expand Down
2 changes: 1 addition & 1 deletion packages/linea-ens-contracts/scripts/ownerRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
12 changes: 7 additions & 5 deletions packages/linea-ens-contracts/scripts/setPohVerifierSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
}
Expand Down
1 change: 1 addition & 0 deletions packages/linea-ens-resolver/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const config: HardhatUserConfig = {
etherscan: {
apiKey: {
sepolia: process.env.ETHERSCAN_API_KEY ?? "",
mainnet: process.env.ETHERSCAN_API_KEY ?? "",
},
},
};
Expand Down
30 changes: 30 additions & 0 deletions packages/linea-ens-subgraph/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
2 changes: 1 addition & 1 deletion packages/poh-signer-api/.env.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53b004f

Please sign in to comment.