forked from idmanagement/ens-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out setup scripts to allow registrar to be deployed at nonce 2
- Loading branch information
Showing
5 changed files
with
137 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ['ethregistrar', 'BaseRegistrarImplementation'] | ||
//Runs after the root is setup | ||
func.dependencies = ['setupRoot'] | ||
|
||
export default func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters