Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added scripts to set PohVerifier signer and transfer ownership #194

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)