From 73d997bf6e88306e60e0d33d17223543ad80137b Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 21 Jun 2024 18:59:20 +0300 Subject: [PATCH] integrate hub domain in nova contracts --- contracts/nova/INova.sol | 5 +++++ contracts/nova/INovaRegistry.sol | 4 ++++ contracts/nova/Nova.sol | 18 ++++++++++++++++++ contracts/nova/NovaRegistry.sol | 15 +++++++++++++++ contracts/nova/NovaUpgradeable.sol | 2 +- 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/contracts/nova/INova.sol b/contracts/nova/INova.sol index b12b5414..5eb76c0b 100644 --- a/contracts/nova/INova.sol +++ b/contracts/nova/INova.sol @@ -1,6 +1,10 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.20; +import "../hub-contracts/IHubDomainsRegistry.sol"; +import "../hub-contracts/IHubDomains.sol"; +import "../hub-contracts/PublicResolver.sol"; + interface INova { error NotAdmin(); error NotMember(); @@ -17,6 +21,7 @@ interface INova { event MarketSet(uint256); event CommitmentSet(uint256); + function registerDomain(string calldata domain, string calldata metadataUri) external; function autID() external view returns (address); function pluginRegistry() external view returns (address); function onboarding() external view returns (address); diff --git a/contracts/nova/INovaRegistry.sol b/contracts/nova/INovaRegistry.sol index 63d39164..f0d8da57 100644 --- a/contracts/nova/INovaRegistry.sol +++ b/contracts/nova/INovaRegistry.sol @@ -1,6 +1,10 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.20; +import "../hub-contracts/IHubDomainsRegistry.sol"; +import "../hub-contracts/IHubDomains.sol"; +import "../hub-contracts/PublicResolver.sol"; + interface INovaRegistry { function checkNova(address) external view returns (bool); diff --git a/contracts/nova/Nova.sol b/contracts/nova/Nova.sol index 69cae295..392cb2ee 100644 --- a/contracts/nova/Nova.sol +++ b/contracts/nova/Nova.sol @@ -6,6 +6,10 @@ import {NovaUpgradeable} from "./NovaUpgradeable.sol"; import {NovaUtils} from "./NovaUtils.sol"; import {INova} from "./INova.sol"; import {INovaRegistry} from "./INovaRegistry.sol"; +import "../hub-contracts/HubDomainsRegistry.sol"; +import "../hub-contracts/IHubDomainsRegistry.sol"; +import "../hub-contracts/IHubDomains.sol"; +import "../hub-contracts/PublicResolver.sol"; // todo: admin retro onboarding contract Nova is INova, NovaUtils, NovaUpgradeable { @@ -31,6 +35,8 @@ contract Nova is INova, NovaUtils, NovaUpgradeable { uint256 public market; string public metadataUri; + IHubDomainsRegistry public hubDomainsRegistry; + mapping(address => uint256) public roles; mapping(address => uint256) public joinedAt; mapping(address => uint256) public commitmentLevels; @@ -53,6 +59,8 @@ contract Nova is INova, NovaUtils, NovaUpgradeable { uint256 market_, uint256 commitment_, string memory metadataUri_ + address hubDomainsRegistryAddress + ) external initializer { _setMaskPosition(deployer, ADMIN_MASK_POSITION); /// @custom:sdk-legacy-interface-compatibility @@ -63,6 +71,7 @@ contract Nova is INova, NovaUtils, NovaUpgradeable { pluginRegistry = pluginRegistry_; autID = autID_; novaRegistry = novaRegistry_; + hubDomainsRegistry = IHubDomainsRegistry(hubDomainsRegistryAddress); } function setMetadataUri(string memory uri) external { @@ -176,6 +185,15 @@ contract Nova is INova, NovaUtils, NovaUpgradeable { return _checkMaskPosition(who, ADMIN_MASK_POSITION); } + // this function registers a new .hub domain through the Nova contract. + // It's called when the user submits their custom domain part and metadata URI. + // It forwards the request to the HubDomainsRegistry. + + function registerDomain(string calldata domain, string calldata metadataUri) external override { + hubDomainsRegistry.registerDomain(domain, metadataUri); + _revertForNotAdmin(msg.sender); + } + /// internal function _setMarket(uint256 market_) internal { diff --git a/contracts/nova/NovaRegistry.sol b/contracts/nova/NovaRegistry.sol index e4cb28df..5add252a 100644 --- a/contracts/nova/NovaRegistry.sol +++ b/contracts/nova/NovaRegistry.sol @@ -13,9 +13,11 @@ import {IModuleRegistry} from "../modules/registry/IModuleRegistry.sol"; import {INovaRegistry} from "./INovaRegistry.sol"; import {IAllowlist} from "../utils/IAllowlist.sol"; import {Nova} from "../nova/Nova.sol"; +import {Domain} from "../hub-contracts/HubDomainsRegistry.sol"; /// @title NovaRegistry contract NovaRegistry is INovaRegistry, ERC2771ContextUpgradeable, OwnableUpgradeable { + HubDomainsRegistry public hubDomainsRegistry; event NovaCreated(address deployer, address novaAddress, uint256 market, uint256 commitment, string metadata); event AllowlistSet(address allowlist); @@ -39,6 +41,10 @@ contract NovaRegistry is INovaRegistry, ERC2771ContextUpgradeable, OwnableUpgrad require(autIDAddr_ != address(0), "NovaRegistry: AutID address zero"); require(novaLogic != address(0), "NovaRegistry: Nova logic address zero"); require(pluginRegistry_ != address(0), "NovaRegistry: PluginRegistry address zero"); + } + function initialize(address hubDomainsRegistryAddress) external initializer { + hubDomainsRegistry = HubDomainsRegistry(hubDomainsRegistryAddress); + } __Ownable_init(msg.sender); @@ -97,6 +103,15 @@ contract NovaRegistry is INovaRegistry, ERC2771ContextUpgradeable, OwnableUpgrad _userNovaListIds[member][nova] = position; } + function resolveDomain(string calldata domain) external view override returns (address) { + return hubDomainsRegistry.resolveDomain(domain); + } + + function getDomainMetadata(string calldata domain) external view override returns (string memory) { + return hubDomainsRegistry.getDomainMetadata(domain); + } + + /// @dev upgrades nova beacon to the new logic contract function upgradeNova(address newLogic) external { _checkOwner(); diff --git a/contracts/nova/NovaUpgradeable.sol b/contracts/nova/NovaUpgradeable.sol index 2e71c626..0b844c73 100644 --- a/contracts/nova/NovaUpgradeable.sol +++ b/contracts/nova/NovaUpgradeable.sol @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/utils/StorageSlot.sol";