Skip to content

Commit

Permalink
Merge pull request #194 from Consensys/chore/post-deployment-scripts
Browse files Browse the repository at this point in the history
feat: added scripts to set PohVerifier signer and transfer ownership
  • Loading branch information
Julink-eth authored Jul 11, 2024
2 parents 8bd09cd + 60c352d commit d32f630
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/linea-ens-contracts/.env.org
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ RESOLVER_ADDRESS=
BATCH_GATEWAY_URLS=
BASE_DOMAIN="linea-test"
POH_ADDRESS_KEY=

WEB3_SIGNER_URL="http://localhost:9000"
WEB3_SIGNER_PUBLIC_KEY=0xd755fd6692d5065f387b263dd969118d01c34bcf04146e52653d52dc9fe96cdf2cc30f537db2557149ba50662957162fb2b2247e0e9941db43d41c336f350736
WEB3_SIGNER_PUBLIC_KEY=0xd755fd6692d5065f387b263dd969118d01c34bcf04146e52653d52dc9fe96cdf2cc30f537db2557149ba50662957162fb2b2247e0e9941db43d41c336f350736

SAFE_LINEA_SEPOLIA=0x30B45d3fB50B33996f4Db6F0e4Fe82fa6CF8d753
SAFE_LINEA_MAINNET=0xf5cc7604a5ef3565b4d2050d65729a06b68aa0bd

POH_SIGNER_LINEA_SEPOLIA=0xC5276dd25195825f73e8729C63E65c969865D7C1
POH_SIGNER_LINEA_MAINNET=0xdeFc3a33e18Dd479c5936F31497bc8650Dcfa070
4 changes: 2 additions & 2 deletions packages/linea-ens-contracts/scripts/ownerRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ async function main(hre: HardhatRuntimeEnvironment) {
resolverAbi = loadAbi('../deployments/LineaSepolia/PublicResolver.json')
rpcUrl = `https://linea-sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`
break
case 'mainnet':
case 'lineaMainnet':
registrarControllerAbi = loadAbi(
'../deployments/mainnet/ETHRegistrarController.json',
)
resolverAbi = loadAbi('../deployments/mainnet/PublicResolver.json')
resolverAbi = loadAbi('../deployments/lineaMainnet/PublicResolver.json')
rpcUrl = `https://linea-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`
break
default:
Expand Down
47 changes: 47 additions & 0 deletions packages/linea-ens-contracts/scripts/setPohVerifierSigner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ethers } from 'hardhat'
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'

async function main(hre: HardhatRuntimeEnvironment) {
const network = hre.network.name
const { deployer, owner } = await hre.getNamedAccounts()
const signer = await ethers.getSigner(owner)

let pohVerifier: Contract
let pohSignerAddr: string

switch (network) {
case 'lineaSepolia':
if (!process.env.POH_SIGNER_LINEA_SEPOLIA) {
throw 'Env POH_SIGNER_LINEA_SEPOLIA can not be undefined'
}
pohSignerAddr = process.env.POH_SIGNER_LINEA_SEPOLIA
pohVerifier = new ethers.Contract(
pohVerifierLineaSepolia.address,
pohVerifierLineaSepolia.abi,
signer,
)
break
case 'lineaMainnet':
if (!process.env.POH_SIGNER_LINEA_MAINNET) {
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'
default:
throw 'Network not supported'
}

const tx = await pohVerifier.setSigner(pohSignerAddr)
await tx.wait(1)

console.log(`PohVerifier signer set to ${pohSignerAddr}`)
}

main(require('hardhat') as HardhatRuntimeEnvironment).catch(console.error)
63 changes: 63 additions & 0 deletions packages/linea-ens-contracts/scripts/transferOwnershipToSafe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { ethers } from 'hardhat'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import 'dotenv/config'
import { Contract } from 'ethers'

const contractsToTransfer = [
'SimplePublicSuffixList',
'BaseRegistrarImplementation',
'ETHRegistrarController',
'ReverseRegistrar',
'Root',
'UniversalResolver',
'NameWrapper',
'PohRegistrationManager',
'PohVerifier',
]

async function main(hre: HardhatRuntimeEnvironment) {
const network = hre.network.name
const { deployer, owner } = await hre.getNamedAccounts()
const signer = await ethers.getSigner(owner)

const deployments = await hre.deployments.all()

let lineaSafeAddr: string

switch (network) {
case 'lineaSepolia':
if (!process.env.LINEA_SEPOLIA_SAFE) {
throw 'Env LINEA_SEPOLIA_SAFE can not be undefined'
}
lineaSafeAddr = process.env.LINEA_SEPOLIA_SAFE
break
case 'lineaMainnet':
if (!process.env.LINEA_MAINNET_SAFE) {
throw 'Env LINEA_MAINNET_SAFE can not be undefined'
}
lineaSafeAddr = process.env.LINEA_MAINNET_SAFE
break
default:
throw 'Network not supported'
}

for (const contractToTransfer of contractsToTransfer) {
const currentContract = deployments[contractToTransfer]
console.log(contractToTransfer)
const contract = new Contract(
currentContract.address,
currentContract.abi,
signer,
)
const tx = await contract.transferOwnership(lineaSafeAddr)
await tx.wait(1)

console.log(
`${contractToTransfer} ownership transferred to ${lineaSafeAddr}`,
)
}

console.log("All contracts's ownership have been transferred")
}

main(require('hardhat') as HardhatRuntimeEnvironment).catch(console.error)

0 comments on commit d32f630

Please sign in to comment.