Skip to content
Open
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
41 changes: 41 additions & 0 deletions contracts/deploy/01_PublicResolverSet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { artifacts, execute } from "@rocketh";
import type { Address } from "viem";

export default execute(
async ({ deploy, execute: write, get, namedAccounts: { deployer } }) => {
const hcaFactory =
get<(typeof artifacts.MockHCAFactoryBasic)["abi"]>("HCAFactory");

const publicResolverSet = await deploy("PublicResolverSet", {
account: deployer,
artifact: artifacts.PermissionedAddressSet,
args: [hcaFactory.address, deployer], // TODO: ownership
});

const publicResolverV1 =
get<(typeof artifacts.PublicResolver)["abi"]>("PublicResolver");

// TODO: update these addresses
const wrapperAwarePublicResolvers: Address[] = [
// devnet
publicResolverV1.address,
// mainnet
// "0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63", // PublicResolverV3: https://etherscan.io/address/0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63
// "0xF29100983E058B709F3D539b0c765937B804AC15", // PublicResolverV4: https://etherscan.io/address/0xF29100983E058B709F3D539b0c765937B804AC15
];
for (const addr of wrapperAwarePublicResolvers) {
await write(publicResolverSet, {
account: deployer,
functionName: "approve",
args: [addr, true],
});
}

console.log("Wrapper-aware PublicResolvers:");
console.table(wrapperAwarePublicResolvers);
},
{
tags: ["PublicResolverSet", "v2"],
dependencies: ["HCAFactory", "PublicResolver"],
},
);
24 changes: 24 additions & 0 deletions contracts/deploy/01_PublicResolverV2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { artifacts, execute } from "@rocketh";

export default execute(
async ({ deploy, get, namedAccounts: { deployer } }) => {
const nameWrapper =
get<(typeof artifacts.NameWrapper)["abi"]>("NameWrapper");

const hcaFactory =
get<(typeof artifacts.MockHCAFactoryBasic)["abi"]>("HCAFactory");

const rootRegistry =
get<(typeof artifacts.PermissionedRegistry)["abi"]>("RootRegistry");

await deploy("PublicResolverV2", {
account: deployer,
artifact: artifacts.PublicResolverV2,
args: [hcaFactory.address, nameWrapper.address, rootRegistry.address],
});
},
{
tags: ["PublicResolverV2", "v2"],
dependencies: ["NameWrapper", "HCAFactory", "RootRegistry"],
},
);
10 changes: 10 additions & 0 deletions contracts/deploy/03_WrapperRegistryImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export default execute(
const ensV1Resolver =
get<(typeof artifacts.ENSV1Resolver)["abi"]>("ENSV1Resolver");

const publicResolverSet =
get<(typeof artifacts.IAddressSet)["abi"]>("PublicResolverSet");

const publicResolverV2 =
get<(typeof artifacts.PublicResolverV2)["abi"]>("PublicResolverV2");

await deploy("WrapperRegistryImpl", {
account: deployer,
artifact: artifacts.WrapperRegistry,
Expand All @@ -27,6 +33,8 @@ export default execute(
ensV1Resolver.address,
hcaFactory.address,
registryMetadata.address,
publicResolverSet.address,
publicResolverV2.address,
],
});
},
Expand All @@ -38,6 +46,8 @@ export default execute(
"SimpleRegistryMetadata",
"VerifiableFactory",
"ENSV1Resolver",
"PublicResolverSet",
"PublicResolverV2",
],
},
);
10 changes: 10 additions & 0 deletions contracts/deploy/04_LockedMigrationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export default execute(
"WrapperRegistryImpl",
);

const publicResolverSet =
get<(typeof artifacts.IAddressSet)["abi"]>("PublicResolverSet");

const publicResolverV2 =
get<(typeof artifacts.PublicResolverV2)["abi"]>("PublicResolverV2");

const migrationController = await deploy("LockedMigrationController", {
account: deployer,
artifact: artifacts.LockedMigrationController,
Expand All @@ -24,6 +30,8 @@ export default execute(
ethRegistry.address,
verifiableFactory.address,
wrapperRegistryImpl.address,
publicResolverSet.address,
publicResolverV2.address,
],
});

Expand All @@ -41,6 +49,8 @@ export default execute(
"ETHRegistry",
"VerifiableFactory",
"WrapperRegistryImpl",
"PublicResolverSet",
"PublicResolverV2",
],
},
);
10 changes: 10 additions & 0 deletions contracts/script/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ export async function setupDevnet({
address: rocketh.get("LockedMigrationController").address,
client,
}),
PublicResolverSet: getContract({
abi: artifacts.PermissionedAddressSet.abi,
address: rocketh.get("PublicResolverSet").address,
client,
}),
// resolvers
UniversalResolver: getContract({
abi: artifacts.UniversalResolverV2.abi,
Expand Down Expand Up @@ -383,6 +388,11 @@ export async function setupDevnet({
address: rocketh.get("ENSV2Resolver").address,
client,
}),
PublicResolver: getContract({
abi: artifacts.PublicResolverV2.abi,
address: rocketh.get("PublicResolverV2").address,
client,
}),
};

const erc20 = {
Expand Down
17 changes: 15 additions & 2 deletions contracts/src/migration/LockedMigrationController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {VerifiableFactory} from "@ensdomains/verifiable-factory/VerifiableFactor

import {IPermissionedRegistry} from "../registry/interfaces/IPermissionedRegistry.sol";
import {IRegistry} from "../registry/interfaces/IRegistry.sol";
import {IAddressSet} from "../utils/interfaces/IAddressSet.sol";

import {LockedWrapperReceiver} from "./LockedWrapperReceiver.sol";

Expand All @@ -32,12 +33,24 @@ contract LockedMigrationController is LockedWrapperReceiver {
/// @param ethRegistry The ENSv2 .eth `PermissionedRegistry` where migrated names are registered.
/// @param verifiableFactory The shared factory for verifiable deployments.
/// @param wrapperRegistryImpl The `WrapperRegistry` implementation contract.
/// @param publicResolverSet The list of `PublicResolver` contracts that require replacement.
/// @param publicResolver The replacement `PublicResolver`.
constructor(
INameWrapper nameWrapper,
IPermissionedRegistry ethRegistry,
VerifiableFactory verifiableFactory,
address wrapperRegistryImpl
) LockedWrapperReceiver(nameWrapper, verifiableFactory, wrapperRegistryImpl) {
address wrapperRegistryImpl,
IAddressSet publicResolverSet,
address publicResolver
)
LockedWrapperReceiver(
nameWrapper,
verifiableFactory,
wrapperRegistryImpl,
publicResolverSet,
publicResolver
)
{
ETH_REGISTRY = ethRegistry;
}

Expand Down
23 changes: 20 additions & 3 deletions contracts/src/migration/LockedWrapperReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {InvalidOwner} from "../CommonErrors.sol";
import {IRegistry} from "../registry/interfaces/IRegistry.sol";
import {IWrapperRegistry} from "../registry/interfaces/IWrapperRegistry.sol";
import {RegistryRolesLib} from "../registry/libraries/RegistryRolesLib.sol";
import {IAddressSet} from "../utils/interfaces/IAddressSet.sol";

import {AbstractWrapperReceiver} from "./AbstractWrapperReceiver.sol";
import {LibMigration} from "./libraries/LibMigration.sol";
Expand Down Expand Up @@ -50,6 +51,12 @@ abstract contract LockedWrapperReceiver is AbstractWrapperReceiver {
/// @notice The `WrapperRegistry` implementation contract.
address public immutable WRAPPER_REGISTRY_IMPL;

/// @notice The list of `PublicResolver` contracts that require replacement.
IAddressSet public immutable PUBLIC_RESOLVER_SET;

/// @notice The replacement `PublicResolver`.
address public immutable PUBLIC_RESOLVER;

////////////////////////////////////////////////////////////////////////
// Initialization
////////////////////////////////////////////////////////////////////////
Expand All @@ -58,13 +65,19 @@ abstract contract LockedWrapperReceiver is AbstractWrapperReceiver {
/// @param nameWrapper The ENSv1 `NameWrapper` contract.
/// @param verifiableFactory The shared factory for verifiable deployments.
/// @param wrapperRegistryImpl The `WrapperRegistry` implementation contract.
/// @param publicResolverSet The approved list of `PublicResolver` contracts.
/// @param publicResolver The replacement `PublicResolver`.
constructor(
INameWrapper nameWrapper,
VerifiableFactory verifiableFactory,
address wrapperRegistryImpl
address wrapperRegistryImpl,
IAddressSet publicResolverSet,
address publicResolver
) AbstractWrapperReceiver(nameWrapper) {
VERIFIABLE_FACTORY = verifiableFactory;
WRAPPER_REGISTRY_IMPL = wrapperRegistryImpl;
PUBLIC_RESOLVER_SET = publicResolverSet;
PUBLIC_RESOLVER = publicResolver;
}

////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -113,10 +126,14 @@ abstract contract LockedWrapperReceiver is AbstractWrapperReceiver {
revert LibMigration.FrozenTokenApproval(uint256(node));
}

address resolver = md.resolver;
if ((fuses & CANNOT_SET_RESOLVER) == 0) {
NAME_WRAPPER.setResolver(node, address(0)); // clear ENSv1 resolver
} else {
md.resolver = _REGISTRY_V1.resolver(node); // replace with ENSv1 resolver
resolver = _REGISTRY_V1.resolver(node); // replace with ENSv1 resolver
if (PUBLIC_RESOLVER_SET.includes(resolver)) {
resolver = PUBLIC_RESOLVER; // replace with new PublicResolver
Comment thread
adraffy marked this conversation as resolved.
}
}

// create subregistry
Expand Down Expand Up @@ -145,7 +162,7 @@ abstract contract LockedWrapperReceiver is AbstractWrapperReceiver {
md.label,
md.owner,
subregistry,
md.resolver,
resolver,
_tokenRoleBitmapFromFuses(fuses),
expiry
);
Expand Down
15 changes: 13 additions & 2 deletions contracts/src/registry/WrapperRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {AbstractWrapperReceiver} from "../migration/AbstractWrapperReceiver.sol"
import {LibMigration} from "../migration/libraries/LibMigration.sol";
import {LockedWrapperReceiver} from "../migration/LockedWrapperReceiver.sol";
import {IWrapperRegistry} from "../registry/interfaces/IWrapperRegistry.sol";
import {IAddressSet} from "../utils/interfaces/IAddressSet.sol";

import {IRegistry} from "./interfaces/IRegistry.sol";
import {IRegistryMetadata} from "./interfaces/IRegistryMetadata.sol";
Expand Down Expand Up @@ -52,15 +53,25 @@ contract WrapperRegistry is
/// @param ensV1Resolver The ENSv1 resolver.
/// @param hcaFactory The HCA factory.
/// @param metadataProvider The metadata provider.
/// @param publicResolverSet The approved list of `PublicResolver` contracts.
/// @param publicResolver The replacement `PublicResolver`.
constructor(
INameWrapper nameWrapper,
VerifiableFactory verifiableFactory,
address ensV1Resolver,
IHCAFactoryBasic hcaFactory,
IRegistryMetadata metadataProvider
IRegistryMetadata metadataProvider,
IAddressSet publicResolverSet,
address publicResolver
)
PermissionedRegistry(hcaFactory, metadataProvider, address(0), 0) // no roles are granted
LockedWrapperReceiver(nameWrapper, verifiableFactory, address(this))
LockedWrapperReceiver(
nameWrapper,
verifiableFactory,
address(this),
publicResolverSet,
publicResolver
)
{
V1_RESOLVER = ensV1Resolver;
_disableInitializers();
Expand Down
Loading
Loading