Skip to content

Commit

Permalink
[ZNS ZChain] String Resolver (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Whytecrowe authored Sep 11, 2024
2 parents 449e121 + 898ac60 commit 1b7cf47
Show file tree
Hide file tree
Showing 17 changed files with 2,052 additions and 1,383 deletions.
280 changes: 140 additions & 140 deletions contracts/registrar/IZNSSubRegistrar.sol
Original file line number Diff line number Diff line change
@@ -1,140 +1,140 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import { IDistributionConfig } from "../types/IDistributionConfig.sol";
import { PaymentConfig } from "../treasury/IZNSTreasury.sol";
import { IZNSPricer } from "../types/IZNSPricer.sol";

/**
* @title IZNSSubRegistrar.sol - Interface for the ZNSSubRegistrar contract responsible for registering subdomains.
*/
interface IZNSSubRegistrar is IDistributionConfig {
/**
* @notice Reverted when someone other than parent owner is trying to buy
a subdomain under the parent that is locked\
* or when the parent provided does not exist.
*/
error ParentLockedOrDoesntExist(bytes32 parentHash);

/**
* @notice Reverted when the buyer of subdomain is not approved by the parent in it's mintlist.
*/
error SenderNotApprovedForPurchase(bytes32 parentHash, address sender);

/**
* @notice Emitted when a new `DistributionConfig.pricerContract` is set for a domain.
*/
event PricerContractSet(
bytes32 indexed domainHash,
address indexed pricerContract
);

/**
* @notice Emitted when a new `DistributionConfig.paymentType` is set for a domain.
*/
event PaymentTypeSet(bytes32 indexed domainHash, PaymentType paymentType);

/**
* @notice Emitted when a new `DistributionConfig.accessType` is set for a domain.
*/
event AccessTypeSet(bytes32 indexed domainHash, AccessType accessType);

/**
* @notice Emitted when a new full `DistributionConfig` is set for a domain at once.
*/
event DistributionConfigSet(
bytes32 indexed domainHash,
IZNSPricer pricerContract,
PaymentType paymentType,
AccessType accessType
);

/**
* @notice Emitted when a `mintlist` is updated for a domain.
*/
event MintlistUpdated(
bytes32 indexed domainHash,
uint256 indexed ownerIndex,
address[] candidates,
bool[] allowed
);

/*
* @notice Emitted when a `mintlist` is removed for a domain by the owner or through
* `ZNSRootRegistrar.revokeDomain()`.
*/
event MintlistCleared(bytes32 indexed domainHash);

/**
* @notice Emitted when the ZNSRootRegistrar address is set in state.
*/
event RootRegistrarSet(address registrar);

function distrConfigs(
bytes32 domainHash
)
external view returns (
IZNSPricer pricerContract,
PaymentType paymentType,
AccessType accessType
);

function isMintlistedForDomain(
bytes32 domainHash,
address candidate
) external view returns (bool);

function initialize(
address _accessController,
address _registry,
address _rootRegistrar
) external;

function registerSubdomain(
bytes32 parentHash,
string calldata label,
address domainAddress,
string calldata tokenURI,
DistributionConfig calldata configForSubdomains,
PaymentConfig calldata paymentConfig
) external returns (bytes32);

function hashWithParent(
bytes32 parentHash,
string calldata label
) external pure returns (bytes32);

function setDistributionConfigForDomain(
bytes32 parentHash,
DistributionConfig calldata config
) external;

function setPricerContractForDomain(
bytes32 domainHash,
IZNSPricer pricerContract
) external;

function setPaymentTypeForDomain(
bytes32 domainHash,
PaymentType paymentType
) external;

function setAccessTypeForDomain(
bytes32 domainHash,
AccessType accessType
) external;

function updateMintlistForDomain(
bytes32 domainHash,
address[] calldata candidates,
bool[] calldata allowed
) external;

function clearMintlistForDomain(bytes32 domainHash) external;

function clearMintlistAndLock(bytes32 domainHash) external;

function setRegistry(address registry_) external;

function setRootRegistrar(address registrar_) external;
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import { IDistributionConfig } from "../types/IDistributionConfig.sol";
import { PaymentConfig } from "../treasury/IZNSTreasury.sol";
import { IZNSPricer } from "../types/IZNSPricer.sol";


/**
* @title IZNSSubRegistrar.sol - Interface for the ZNSSubRegistrar contract responsible for registering subdomains.
*/
interface IZNSSubRegistrar is IDistributionConfig {
/**
* @notice Reverted when someone other than parent owner is trying to buy
* a subdomain under the parent that is locked
* or when the parent provided does not exist.
*/
error ParentLockedOrDoesntExist(bytes32 parentHash);

/**
* @notice Reverted when the buyer of subdomain is not approved by the parent in it's mintlist.
*/
error SenderNotApprovedForPurchase(bytes32 parentHash, address sender);

/**
* @notice Emitted when a new `DistributionConfig.pricerContract` is set for a domain.
*/
event PricerContractSet(
bytes32 indexed domainHash,
address indexed pricerContract
);

/**
* @notice Emitted when a new `DistributionConfig.paymentType` is set for a domain.
*/
event PaymentTypeSet(bytes32 indexed domainHash, PaymentType paymentType);

/**
* @notice Emitted when a new `DistributionConfig.accessType` is set for a domain.
*/
event AccessTypeSet(bytes32 indexed domainHash, AccessType accessType);

/**
* @notice Emitted when a new full `DistributionConfig` is set for a domain at once.
*/
event DistributionConfigSet(
bytes32 indexed domainHash,
IZNSPricer pricerContract,
PaymentType paymentType,
AccessType accessType
);

/**
* @notice Emitted when a `mintlist` is updated for a domain.
*/
event MintlistUpdated(
bytes32 indexed domainHash,
uint256 indexed ownerIndex,
address[] candidates,
bool[] allowed
);

/*
* @notice Emitted when a `mintlist` is removed for a domain by the owner or through
* `ZNSRootRegistrar.revokeDomain()`.
*/
event MintlistCleared(bytes32 indexed domainHash);

/**
* @notice Emitted when the ZNSRootRegistrar address is set in state.
*/
event RootRegistrarSet(address registrar);

function distrConfigs(
bytes32 domainHash
) external view returns (
IZNSPricer pricerContract,
PaymentType paymentType,
AccessType accessType
);

function isMintlistedForDomain(
bytes32 domainHash,
address candidate
) external view returns (bool);

function initialize(
address _accessController,
address _registry,
address _rootRegistrar
) external;

function registerSubdomain(
bytes32 parentHash,
string calldata label,
address domainAddress,
string calldata tokenURI,
DistributionConfig calldata configForSubdomains,
PaymentConfig calldata paymentConfig
) external returns (bytes32);

function hashWithParent(
bytes32 parentHash,
string calldata label
) external pure returns (bytes32);

function setDistributionConfigForDomain(
bytes32 parentHash,
DistributionConfig calldata config
) external;

function setPricerContractForDomain(
bytes32 domainHash,
IZNSPricer pricerContract
) external;

function setPaymentTypeForDomain(
bytes32 domainHash,
PaymentType paymentType
) external;

function setAccessTypeForDomain(
bytes32 domainHash,
AccessType accessType
) external;

function updateMintlistForDomain(
bytes32 domainHash,
address[] calldata candidates,
bool[] calldata allowed
) external;

function clearMintlistForDomain(bytes32 domainHash) external;

function clearMintlistAndLock(bytes32 domainHash) external;

function setRegistry(address registry_) external;

function setRootRegistrar(address registrar_) external;
}
26 changes: 26 additions & 0 deletions contracts/resolver/IZNSStringResolver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;


interface IZNSStringResolver {
/**
* @param domainHash The identifying hash of a domain's name
* @param newString - content of string type set by the owner/operator to which a domain will resolve to
*/
event StringSet(bytes32 indexed domainHash, string indexed newString);

function supportsInterface(bytes4 interfaceId) external view returns (bool);

function resolveDomainString(bytes32 domainHash) external view returns (string memory);

function setString(
bytes32 domainHash,
string calldata newString
) external;

function getInterfaceId() external pure returns (bytes4);

function setRegistry(address _registry) external;

function initialize(address _accessController, address _registry) external;
}
Loading

0 comments on commit 1b7cf47

Please sign in to comment.