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

Deploy to Sepolia #258

Merged
merged 9 commits into from
Jul 18, 2023
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
8 changes: 7 additions & 1 deletion deploy/dnsregistrar/10_deploy_dnsregistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
}

func.tags = ['DNSRegistrar']
func.dependencies = ['registry', 'dnssec-oracle', 'OffchainDNSResolver', 'Root']
func.dependencies = [
'registry',
'dnssec-oracle',
'OffchainDNSResolver',
'Root',
'setupRoot',
]

export default func
21 changes: 2 additions & 19 deletions deploy/ethregistrar/00_deploy_base_registrar_implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import { keccak256 } from 'js-sha3'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments, network } = hre
const { deploy, fetchIfDifferent } = deployments
const { deployer, owner } = await getNamedAccounts()
const { deploy } = deployments
const { deployer } = await getNamedAccounts()

if (!network.tags.use_root) {
return true
}

const registry = await ethers.getContract('ENSRegistry')
const root = await ethers.getContract('Root')

const deployArgs = {
from: deployer,
Expand All @@ -24,22 +23,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const bri = await deploy('BaseRegistrarImplementation', deployArgs)
if (!bri.newlyDeployed) return

const registrar = await ethers.getContract('BaseRegistrarImplementation')

const tx1 = await registrar.transferOwnership(owner, { from: deployer })
console.log(
`Transferring ownership of registrar to owner (tx: ${tx1.hash})...`,
)
await tx1.wait()

const tx2 = await root
.connect(await ethers.getSigner(owner))
.setSubnodeOwner('0x' + keccak256('eth'), registrar.address)
console.log(
`Setting owner of eth node to registrar on root (tx: ${tx2.hash})...`,
)
await tx2.wait()
}

func.id = 'registrar'
Expand Down
40 changes: 40 additions & 0 deletions deploy/ethregistrar/00_setup_base_registrar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import namehash from 'eth-ens-namehash'
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { keccak256 } from 'js-sha3'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments, network } = hre
const { deployer, owner } = await getNamedAccounts()

if (!network.tags.use_root) {
return true
}

const root = await ethers.getContract('Root')
const registrar = await ethers.getContract('BaseRegistrarImplementation')

console.log('Running base registrar setup')

const tx1 = await registrar.transferOwnership(owner, { from: deployer })
console.log(
`Transferring ownership of registrar to owner (tx: ${tx1.hash})...`,
)
await tx1.wait()

const tx2 = await root
.connect(await ethers.getSigner(owner))
.setSubnodeOwner('0x' + keccak256('eth'), registrar.address)
console.log(
`Setting owner of eth node to registrar on root (tx: ${tx2.hash})...`,
)
await tx2.wait()
}

func.id = 'setupRegistrar'
func.tags = ['setupRegistrar']
//Runs after the root is setup
func.dependencies = ['setupRoot']

export default func
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func.dependencies = [
'registry',
'wrapper',
'LegacyPublicResolver',
'ExponentialPremiumPriceOracle',
'ReverseRegistrar',
]

Expand Down
18 changes: 4 additions & 14 deletions deploy/ethregistrar/03_deploy_eth_registrar_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const artifact = await deployments.getArtifact('IETHRegistrarController')
const interfaceId = computeInterfaceId(new Interface(artifact.abi))
const provider = new ethers.providers.StaticJsonRpcProvider(
ethers.provider.connection.url,
{
...ethers.provider.network,
ensAddress: (await ethers.getContract('ENSRegistry')).address,
},
)
const resolver = await provider.getResolver('eth')
if (resolver === null) {
registrar.setResolver(ethOwnedResolver.address)

const resolver = await registry.resolver(ethers.utils.namehash('eth'))
if (resolver === ethers.constants.AddressZero) {
console.log(
`No resolver set for .eth; not setting interface ${interfaceId} for ETH Registrar Controller`,
)
return
}
const resolverContract = await ethers.getContractAt(
'PublicResolver',
resolver.address,
)
const resolverContract = await ethers.getContractAt('OwnedResolver', resolver)
const tx3 = await resolverContract.setInterface(
ethers.utils.namehash('eth'),
interfaceId,
Expand Down
12 changes: 5 additions & 7 deletions deploy/ethregistrar/04_deploy_bulk_renewal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
ensAddress: registry.address,
},
)
const resolver = await provider.getResolver('eth')
if (resolver === null) {

const resolver = await registry.resolver(ethers.utils.namehash('eth'))
if (resolver === ethers.constants.AddressZero) {
console.log(
'No resolver set for .eth; not setting interface for BulkRenewal',
`No resolver set for .eth; not setting interface ${interfaceId} for BulkRenewal`,
)
return
}
const resolverContract = await ethers.getContractAt(
'PublicResolver',
resolver.address,
)
const resolverContract = await ethers.getContractAt('OwnedResolver', resolver)
const tx = await resolverContract.setInterface(
ethers.utils.namehash('eth'),
interfaceId,
Expand Down
6 changes: 4 additions & 2 deletions deploy/registry/00_deploy_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer, owner } = await getNamedAccounts()

if (network.tags.legacy) {
console.log(deployer)
console.log(owner)
const contract = await deploy('LegacyENSRegistry', {
from: deployer,
from: owner,
args: [],
log: true,
contract: await deployments.getArtifact('ENSRegistry'),
Expand All @@ -22,7 +24,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const legacyRegistry = await ethers.getContract('LegacyENSRegistry')

const rootTx = await legacyRegistry
.connect(await ethers.getSigner(deployer))
.connect(await ethers.getSigner(owner))
.setOwner(ZERO_HASH, owner)
console.log(`Setting owner of root node to owner (tx: ${rootTx.hash})`)
await rootTx.wait()
Expand Down
23 changes: 19 additions & 4 deletions deploy/resolvers/00_deploy_eth_owned_resolver.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { ethers } from 'hardhat'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments } = hre
const { deploy } = deployments
const { deployer } = await getNamedAccounts()
const { deployer, owner } = await getNamedAccounts()

const deployArgs = {
from: deployer,
args: [],
log: true,
}
const ethOwnedResolver = await deploy('OwnedResolver', deployArgs)

if (!ethOwnedResolver.newlyDeployed) return

const registry = await ethers.getContract('ENSRegistry', owner)
const registrar = await ethers.getContract(
'BaseRegistrarImplementation',
owner,
)

const tx = await registrar.setResolver(ethOwnedResolver.address)
await tx.wait()

const resolver = await registry.resolver(ethers.utils.namehash('eth'))
console.log(`set resolver for .eth to ${resolver}`)
if (!ethOwnedResolver.newlyDeployed) return
}

func.id = 'owned-resolver'
func.tags = ['resolvers', 'OwnedResolver']
func.dependencies = []
func.id = 'eth-owned-resolver'
func.tags = ['resolvers', 'OwnedResolver', 'EthOwnedResolver']
func.dependencies = ['Registry']

export default func
39 changes: 0 additions & 39 deletions deploy/root/00_deploy_root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

const ZERO_HASH =
'0x0000000000000000000000000000000000000000000000000000000000000000'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments, network } = hre
const { deploy } = deployments
Expand All @@ -22,42 +19,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
log: true,
})

const root = await ethers.getContract('Root')

const tx1 = await registry.setOwner(ZERO_HASH, root.address)
console.log(
`Setting owner of root node to root contract (tx: ${tx1.hash})...`,
)
await tx1.wait()

const rootOwner = await root.owner()

switch (rootOwner) {
case deployer:
const tx2 = await root
.connect(await ethers.getSigner(deployer))
.transferOwnership(owner)
console.log(
`Transferring root ownership to final owner (tx: ${tx2.hash})...`,
)
await tx2.wait()
case owner:
if (!(await root.controllers(owner))) {
const tx2 = await root
.connect(await ethers.getSigner(owner))
.setController(owner, true)
console.log(
`Setting final owner as controller on root contract (tx: ${tx2.hash})...`,
)
await tx2.wait()
}
break
default:
console.log(
`WARNING: Root is owned by ${rootOwner}; cannot transfer to owner account`,
)
}

return true
}

Expand Down
62 changes: 62 additions & 0 deletions deploy/root/00_setup_root.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { ethers } from 'hardhat'
import { DeployFunction } from 'hardhat-deploy/types'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

const ZERO_HASH =
'0x0000000000000000000000000000000000000000000000000000000000000000'

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, deployments, network } = hre
const { deployer, owner } = await getNamedAccounts()

if (!network.tags.use_root) {
return true
}

console.log('Running root setup')

const registry = await ethers.getContract('ENSRegistry')
const root = await ethers.getContract('Root')

const tx1 = await registry.setOwner(ZERO_HASH, root.address)
console.log(
`Setting owner of root node to root contract (tx: ${tx1.hash})...`,
)
await tx1.wait()

const rootOwner = await root.owner()

switch (rootOwner) {
case deployer:
const tx2 = await root
.connect(await ethers.getSigner(deployer))
.transferOwnership(owner)
console.log(
`Transferring root ownership to final owner (tx: ${tx2.hash})...`,
)
await tx2.wait()
case owner:
if (!(await root.controllers(owner))) {
const tx2 = await root
.connect(await ethers.getSigner(owner))
.setController(owner, true)
console.log(
`Setting final owner as controller on root contract (tx: ${tx2.hash})...`,
)
await tx2.wait()
}
break
default:
console.log(
`WARNING: Root is owned by ${rootOwner}; cannot transfer to owner account`,
)
}

return true
}

func.id = 'setupRoot'
func.tags = ['setupRoot']
func.dependencies = ['Root']

export default func
3 changes: 2 additions & 1 deletion deploy/wrapper/00_deploy_static_metadata_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

func.id = 'metadata'
func.tags = ['wrapper', 'StaticMetadataService']
func.dependencies = []
// technically not a dep, but we want to make sure it's deployed first for the consistent address
func.dependencies = ['BaseRegistrarImplementation']

export default func
21 changes: 9 additions & 12 deletions deploy/wrapper/01_deploy_name_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const deployArgs = {
from: deployer,
args: [registry.address, registrar.address, metadata.address],
args: [
registry.address,
'0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85',
metadata.address,
],
log: true,
}

Expand All @@ -52,21 +56,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const artifact = await deployments.getArtifact('INameWrapper')
const interfaceId = computeInterfaceId(new Interface(artifact.abi))
const providerWithEns = new ethers.providers.StaticJsonRpcProvider(
ethers.provider.connection.url,
{ ...ethers.provider.network, ensAddress: registry.address },
)
const resolver = await providerWithEns.getResolver('eth')
if (resolver === null) {
const resolver = await registry.resolver(ethers.utils.namehash('eth'))
if (resolver === ethers.constants.AddressZero) {
console.log(
`No resolver set for .eth; not setting interface ${interfaceId} for NameWrapper`,
)
return
}
const resolverContract = await ethers.getContractAt(
'PublicResolver',
resolver.address,
)
const resolverContract = await ethers.getContractAt('OwnedResolver', resolver)
const tx3 = await resolverContract.setInterface(
ethers.utils.namehash('eth'),
interfaceId,
Expand All @@ -81,10 +78,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
func.id = 'name-wrapper'
func.tags = ['wrapper', 'NameWrapper']
func.dependencies = [
'BaseRegistrarImplementation',
'StaticMetadataService',
'registry',
'ReverseRegistrar',
'OwnedResolver',
]

export default func
1 change: 1 addition & 0 deletions deployments/sepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155111
Loading