Skip to content

Commit

Permalink
integrate hub domain in nova contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabyl committed Jun 21, 2024
1 parent d594054 commit 73d997b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
5 changes: 5 additions & 0 deletions contracts/nova/INova.sol
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions contracts/nova/INovaRegistry.sol
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
18 changes: 18 additions & 0 deletions contracts/nova/Nova.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions contracts/nova/NovaRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion contracts/nova/NovaUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/utils/StorageSlot.sol";
Expand Down

0 comments on commit 73d997b

Please sign in to comment.