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
6 changes: 5 additions & 1 deletion contracts/deploy/l1/00_RootRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export default execute(
const registryDatastore =
get<(typeof artifacts.RegistryDatastore)["abi"]>("RegistryDatastore");

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

const registryMetadata = get<
(typeof artifacts.SimpleRegistryMetadata)["abi"]
>("SimpleRegistryMetadata");
Expand All @@ -15,6 +18,7 @@ export default execute(
artifact: artifacts.PermissionedRegistry,
args: [
registryDatastore.address,
hcaFactory.address,
registryMetadata.address,
deployer,
ROLES.ALL,
Expand All @@ -23,6 +27,6 @@ export default execute(
},
{
tags: ["RootRegistry", "l1"],
dependencies: ["RegistryDatastore", "RegistryMetadata"],
dependencies: ["RegistryDatastore", "HCAFactory", "RegistryMetadata"],
},
);
5 changes: 5 additions & 0 deletions contracts/deploy/l1/01_ReverseRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export default execute(
const registryDatastore =
get<(typeof artifacts.RegistryDatastore)["abi"]>("RegistryDatastore");

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

const registryMetadata = get<
(typeof artifacts.SimpleRegistryMetadata)["abi"]
>("SimpleRegistryMetadata");
Expand All @@ -24,6 +27,7 @@ export default execute(
artifact: artifacts.PermissionedRegistry,
args: [
registryDatastore.address,
hcaFactory.address,
registryMetadata.address,
deployer,
ROLES.ALL,
Expand All @@ -50,6 +54,7 @@ export default execute(
"DefaultReverseResolver",
"RootRegistry",
"RegistryDatastore",
"HCAFactory",
"SimpleRegistryMetadata",
],
},
Expand Down
9 changes: 7 additions & 2 deletions contracts/deploy/l1/02_ETHRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { artifacts, execute } from "@rocketh";
import { MAX_EXPIRY, ROLES } from "../constants.js";

// TODO: ownership
// TODO: ownership
export default execute(
async ({ deploy, execute: write, get, namedAccounts: { deployer } }) => {
const rootRegistry =
Expand All @@ -10,6 +10,9 @@ export default execute(
const registryDatastore =
get<(typeof artifacts.RegistryDatastore)["abi"]>("RegistryDatastore");

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

const registryMetadata = get<
(typeof artifacts.SimpleRegistryMetadata)["abi"]
>("SimpleRegistryMetadata");
Expand All @@ -22,6 +25,7 @@ export default execute(
artifact: artifacts.PermissionedRegistry,
args: [
registryDatastore.address,
hcaFactory.address,
registryMetadata.address,
deployer,
ROLES.ALL,
Expand All @@ -33,7 +37,7 @@ export default execute(
functionName: "register",
args: [
"eth",
deployer,
deployer,
ethRegistry.address,
ethTLDResolver.address,
0n,
Expand All @@ -46,6 +50,7 @@ export default execute(
dependencies: [
"RootRegistry",
"RegistryDatastore",
"HCAFactory",
"RegistryMetadata",
"ETHTLDResolver",
],
Expand Down
6 changes: 5 additions & 1 deletion contracts/deploy/l2/01_ETHRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export default execute(
const registryDatastore =
get<(typeof artifacts.RegistryDatastore)["abi"]>("RegistryDatastore");

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

const registryMetadata = get<
(typeof artifacts.SimpleRegistryMetadata)["abi"]
>("SimpleRegistryMetadata");
Expand All @@ -15,6 +18,7 @@ export default execute(
artifact: artifacts.PermissionedRegistry,
args: [
registryDatastore.address,
hcaFactory.address,
registryMetadata.address,
deployer,
ROLES.ALL,
Expand All @@ -23,6 +27,6 @@ export default execute(
},
{
tags: ["ETHRegistry", "l2"],
dependencies: ["RegistryDatastore", "RegistryMetadata"],
dependencies: ["RegistryDatastore", "HCAFactory", "RegistryMetadata"],
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { artifacts, execute } from "@rocketh";

export default execute(
async ({ deploy, namedAccounts: { deployer } }) => {
await deploy("SimpleRegistryMetadata", {
// TODO: deploy the actual HCAFactory
await deploy("HCAFactory", {
account: deployer,
artifact: artifacts.SimpleRegistryMetadata,
artifact: artifacts.MockHCAFactoryBasic,
args: [],
});
},
{ tags: ["RegistryMetadata", "shared"] },
{
tags: ["HCAFactory", "shared"],
},
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { artifacts, execute } from "@rocketh";

export default execute(
async ({ deploy, namedAccounts: { deployer } }) => {
async ({ deploy, get, namedAccounts: { deployer } }) => {
const hcaFactory =
get<(typeof artifacts.MockHCAFactoryBasic)["abi"]>("HCAFactory");
await deploy("DedicatedResolverFactory", {
account: deployer,
artifact: artifacts.VerifiableFactory,
Expand All @@ -10,9 +12,11 @@ export default execute(
await deploy("DedicatedResolverImpl", {
account: deployer,
artifact: artifacts.DedicatedResolver,
args: [hcaFactory.address],
});
},
{
tags: ["DedicatedResolver", "shared"],
dependencies: ["HCAFactory"],
},
);
15 changes: 15 additions & 0 deletions contracts/deploy/shared/01_RegistryMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { artifacts, execute } from "@rocketh";

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

await deploy("SimpleRegistryMetadata", {
account: deployer,
artifact: artifacts.SimpleRegistryMetadata,
args: [hcaFactory.address],
});
},
{ tags: ["RegistryMetadata", "HCAFactory", "shared"] },
);
3 changes: 3 additions & 0 deletions contracts/script/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export async function setupCrossChainEnvironment({
universalResolver: l1Contracts("UniversalResolverV2"),
// shared
registryDatastore: l1Contracts("RegistryDatastore"),
hcaFactory: l1Contracts("MockHCAFactoryBasic", "HCAFactory"),
simpleRegistryMetadata: l1Contracts("SimpleRegistryMetadata"),
dedicatedResolverFactory: l1Contracts(
"VerifiableFactory",
Expand Down Expand Up @@ -328,6 +329,7 @@ export async function setupCrossChainEnvironment({
mockDAI: l2Contracts("src/mocks/MockERC20.sol/MockERC20", "MockDAI"),
// shared
registryDatastore: l2Contracts("RegistryDatastore"),
hcaFactory: l2Contracts("MockHCAFactoryBasic", "HCAFactory"),
simpleRegistryMetadata: l2Contracts("SimpleRegistryMetadata"),
dedicatedResolverFactory: l2Contracts(
"VerifiableFactory",
Expand Down Expand Up @@ -425,6 +427,7 @@ export async function setupCrossChainEnvironment({
bytecode: artifacts.PermissionedRegistry.bytecode,
args: [
this.contracts.registryDatastore.address,
this.contracts.hcaFactory.address,
this.contracts.simpleRegistryMetadata.address,
account.address,
roles,
Expand Down
4 changes: 3 additions & 1 deletion contracts/src/L1/registry/MigratedWrappedNameRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

import {MigrationData} from "../../common/bridge/types/TransferData.sol";
import {UnauthorizedCaller} from "../../common/CommonErrors.sol";
import {IHCAFactoryBasic} from "../../common/hca/interfaces/IHCAFactoryBasic.sol";
import {IPermissionedRegistry} from "../../common/registry/interfaces/IPermissionedRegistry.sol";
import {IRegistry} from "../../common/registry/interfaces/IRegistry.sol";
import {IRegistryDatastore} from "../../common/registry/interfaces/IRegistryDatastore.sol";
Expand Down Expand Up @@ -77,8 +78,9 @@ contract MigratedWrappedNameRegistry is
VerifiableFactory factory_,
IPermissionedRegistry ethRegistry_,
IRegistryDatastore datastore_,
IHCAFactoryBasic hcaFactory_,
IRegistryMetadata metadataProvider_
) PermissionedRegistry(datastore_, metadataProvider_, _msgSender(), 0) {
) PermissionedRegistry(datastore_, hcaFactory_, metadataProvider_, _msgSender(), 0) {
NAME_WRAPPER = nameWrapper_;
ENS_REGISTRY = ensRegistry_;
FACTORY = factory_;
Expand Down
4 changes: 3 additions & 1 deletion contracts/src/L2/registrar/ETHRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import {EnhancedAccessControl} from "../../common/access-control/EnhancedAccessControl.sol";
import {EACBaseRolesLib} from "../../common/access-control/libraries/EACBaseRolesLib.sol";
import {HCAEquivalence} from "../../common/hca/HCAEquivalence.sol";
import {IHCAFactoryBasic} from "../../common/hca/interfaces/IHCAFactoryBasic.sol";
import {IPermissionedRegistry} from "../../common/registry/interfaces/IPermissionedRegistry.sol";
import {IRegistry} from "../../common/registry/interfaces/IRegistry.sol";
import {IRegistryDatastore} from "../../common/registry/interfaces/IRegistryDatastore.sol";
Expand Down Expand Up @@ -61,7 +63,7 @@ contract ETHRegistrar is IETHRegistrar, EnhancedAccessControl {
uint64 maxCommitmentAge_,
uint64 minRegisterDuration_,
IRentPriceOracle rentPriceOracle_
) {
) HCAEquivalence(IHCAFactoryBasic(address(0))) {
if (maxCommitmentAge_ <= minCommitmentAge_) {
revert MaxCommitmentAgeTooLow();
}
Expand Down
4 changes: 3 additions & 1 deletion contracts/src/L2/registry/UserRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity >=0.8.13;
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

import {IHCAFactoryBasic} from "../../common/hca/interfaces/IHCAFactoryBasic.sol";
import {IRegistryDatastore} from "../../common/registry/interfaces/IRegistryDatastore.sol";
import {IRegistryMetadata} from "../../common/registry/interfaces/IRegistryMetadata.sol";
import {PermissionedRegistry} from "../../common/registry/PermissionedRegistry.sol";
Expand All @@ -27,8 +28,9 @@ contract UserRegistry is Initializable, PermissionedRegistry, UUPSUpgradeable {

constructor(
IRegistryDatastore datastore_,
IHCAFactoryBasic hcaFactory_,
IRegistryMetadata metadataProvider_
) PermissionedRegistry(datastore_, metadataProvider_, _msgSender(), 0) {
) PermissionedRegistry(datastore_, hcaFactory_, metadataProvider_, _msgSender(), 0) {
// This disables initialization for the implementation contract
_disableInitializers();
}
Expand Down
5 changes: 3 additions & 2 deletions contracts/src/common/access-control/EnhancedAccessControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

pragma solidity ^0.8.20;

import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

import {HCAContext} from "../hca/HCAContext.sol";

import {IEnhancedAccessControl} from "./interfaces/IEnhancedAccessControl.sol";
import {EACBaseRolesLib} from "./libraries/EACBaseRolesLib.sol";

Expand All @@ -22,7 +23,7 @@ import {EACBaseRolesLib} from "./libraries/EACBaseRolesLib.sol";
/// - A role bitmap is a uint256, where the lower 128 bits represent the regular roles (0-31), and the upper 128 bits represent the admin roles (32-63) for those roles.
/// - Each role is represented by a nybble (4 bits), in little-endian order.
/// - If a given role left-most nybble bit is located at index N then the corresponding admin role nybble starts at bit position N << 128.
abstract contract EnhancedAccessControl is Context, ERC165, IEnhancedAccessControl {
abstract contract EnhancedAccessControl is HCAContext, ERC165, IEnhancedAccessControl {
////////////////////////////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////////////////////////////
Expand Down
7 changes: 6 additions & 1 deletion contracts/src/common/bridge/EjectionController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {ERC165, IERC165} from "@openzeppelin/contracts/utils/introspection/ERC16

import {EnhancedAccessControl} from "../access-control/EnhancedAccessControl.sol";
import {UnauthorizedCaller} from "../CommonErrors.sol";
import {HCAEquivalence} from "../hca/HCAEquivalence.sol";
import {IHCAFactoryBasic} from "../hca/interfaces/IHCAFactoryBasic.sol";
import {IPermissionedRegistry} from "../registry/interfaces/IPermissionedRegistry.sol";
import {LibLabel} from "../utils/LibLabel.sol";

Expand Down Expand Up @@ -55,7 +57,10 @@ abstract contract EjectionController is IERC1155Receiver, ERC165, EnhancedAccess
// Initialization
////////////////////////////////////////////////////////////////////////

constructor(IPermissionedRegistry registry_, IBridge bridge_) {
constructor(
IPermissionedRegistry registry_,
IBridge bridge_
) HCAEquivalence(IHCAFactoryBasic(address(0))) {
REGISTRY = registry_;
BRIDGE = bridge_;

Expand Down
5 changes: 3 additions & 2 deletions contracts/src/common/erc1155/ERC1155Singleton.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import {
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {ERC1155Utils} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Utils.sol";
import {Arrays} from "@openzeppelin/contracts/utils/Arrays.sol";
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

import {HCAContext} from "../hca/HCAContext.sol";

import {IERC1155Singleton} from "./interfaces/IERC1155Singleton.sol";

abstract contract ERC1155Singleton is
Context,
HCAContext,
ERC165,
IERC1155Singleton,
IERC1155Errors,
Expand Down
14 changes: 14 additions & 0 deletions contracts/src/common/hca/HCAContext.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import {Context} from "@openzeppelin/contracts/utils/Context.sol";

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

/// @dev Replaces msg.sender
abstract contract HCAContext is Context, HCAEquivalence {
/// @notice Returns either the account owner of an HCA or the original sender
function _msgSender() internal view virtual override returns (address) {
return _msgSenderWithHcaEquivalence();
}
}
14 changes: 14 additions & 0 deletions contracts/src/common/hca/HCAContextUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";

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

/// @dev Replaces msg.sender
abstract contract HCAContextUpgradeable is ContextUpgradeable, HCAEquivalence {
/// @notice Returns either the account owner of an HCA or the original sender
function _msgSender() internal view virtual override(ContextUpgradeable) returns (address) {
return _msgSenderWithHcaEquivalence();
}
}
22 changes: 22 additions & 0 deletions contracts/src/common/hca/HCAEquivalence.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

import {IHCAFactoryBasic} from "./interfaces/IHCAFactoryBasic.sol";

/// @dev Replaces msg.sender
abstract contract HCAEquivalence {
/// @notice The HCA factory contract
IHCAFactoryBasic public immutable HCA_FACTORY;

constructor(IHCAFactoryBasic hcaFactory) {
HCA_FACTORY = hcaFactory;
}

/// @notice Returns either the account owner of an HCA or the original sender
function _msgSenderWithHcaEquivalence() internal view returns (address) {
if (address(HCA_FACTORY) == address(0)) return msg.sender;
address accountOwner = HCA_FACTORY.getAccountOwner(msg.sender);
if (accountOwner == address(0)) return msg.sender;
return accountOwner;
}
}
10 changes: 10 additions & 0 deletions contracts/src/common/hca/interfaces/IHCAFactoryBasic.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

/// @dev Basic interface for the HCA factory.
interface IHCAFactoryBasic {
/// @notice Returns the account owner of the given HCA
/// @param hca The HCA to get the account owner of
/// @return The account owner of the given HCA
function getAccountOwner(address hca) external view returns (address);
}
4 changes: 2 additions & 2 deletions contracts/src/common/registry/BaseRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ abstract contract BaseRegistry is IRegistry, ERC1155Singleton {

modifier onlyTokenOwner(uint256 tokenId) {
address owner = ownerOf(tokenId);
if (owner != msg.sender) {
revert AccessDenied(tokenId, owner, msg.sender);
if (owner != _msgSender()) {
revert AccessDenied(tokenId, owner, _msgSender());
}
_;
}
Expand Down
Loading
Loading