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

Merge mainnet back into dev #267

Merged
merged 14 commits into from
Aug 11, 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
15 changes: 15 additions & 0 deletions contracts/utils/DummyRevertResolver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.17 <0.9.0;

contract DummyRevertResolver {
function resolve(
bytes calldata,
bytes calldata
) external pure returns (bytes memory) {
revert("Not Supported");
}

function supportsInterface(bytes4) external pure returns (bool) {
return true;
}
}
15 changes: 9 additions & 6 deletions contracts/utils/UniversalResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ error OffchainLookup(
bytes extraData
);

error ResolverNotFound();

error ResolverWildcardNotSupported();

struct MulticallData {
bytes name;
bytes[] data;
Expand Down Expand Up @@ -150,7 +154,7 @@ contract UniversalResolver is ERC165, Ownable {
(Resolver resolver, , uint256 finalOffset) = findResolver(name);
resolverAddress = address(resolver);
if (resolverAddress == address(0)) {
return (results, address(0));
revert ResolverNotFound();
}

bool isWildcard = finalOffset != 0;
Expand Down Expand Up @@ -434,7 +438,7 @@ contract UniversalResolver is ERC165, Ownable {
return (true, returnData, extraData, false);
}
} else {
returnData = revertData;
returnData = bytes.concat(errorId, revertData);
return (false, returnData, extraData, false);
}
}
Expand Down Expand Up @@ -522,10 +526,9 @@ contract UniversalResolver is ERC165, Ownable {
bool isCallback = multicallData.name.length == 0;
bool hasExtendedResolver = _hasExtendedResolver(multicallData.resolver);

require(
!multicallData.isWildcard || hasExtendedResolver,
"UniversalResolver: Wildcard on non-extended resolvers is not supported"
);
if (multicallData.isWildcard && !hasExtendedResolver) {
revert ResolverWildcardNotSupported();
}

for (uint256 i = 0; i < length; i++) {
bytes memory item = multicallData.data[i];
Expand Down
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
Loading