ZNSSubRegistrar.sol - The contract for registering and revoking subdomains of zNS.
This contract has the entry point for registering subdomains, but calls
the ZNSRootRegistrar back to finalize registration. Common logic for domains
of any level is in the ZNSRootRegistrar.coreRegister()
.
contract IZNSRootRegistrar rootRegistrar
State var for the ZNSRootRegistrar contract that finalizes registration of subdomains.
mapping(bytes32 => struct IDistributionConfig.DistributionConfig) distrConfigs
Mapping of domainHash to distribution config set by the domain owner/operator. These configs are used to determine how subdomains are distributed for every parent.
Note that the rules outlined in the DistributionConfig are only applied to direct children!
struct Mintlist {
mapping(uint256 => mapping(address => bool)) list;
uint256 ownerIndex;
}
mapping(bytes32 => struct ZNSSubRegistrar.Mintlist) mintlist
Mapping of domainHash to mintlist set by the domain owner/operator. These configs are used to determine who can register subdomains for every parent in the case where parent's DistributionConfig.AccessType is set to AccessType.MINTLIST.
modifier onlyOwnerOperatorOrRegistrar(bytes32 domainHash)
constructor() public
function initialize(address _accessController, address _registry, address _rootRegistrar) external
function registerSubdomain(bytes32 parentHash, string label, address domainAddress, string tokenURI, struct IDistributionConfig.DistributionConfig distrConfig, struct PaymentConfig paymentConfig) external returns (bytes32)
Entry point to register a subdomain under a parent domain specified.
Reads the DistributionConfig
for the parent domain to determine how to distribute,
checks if the sender is allowed to register, check if subdomain is available,
acquires the price and other data needed to finalize the registration
and calls the ZNSRootRegistrar.coreRegister()
to finalize.
Name | Type | Description |
---|---|---|
parentHash | bytes32 | The hash of the parent domain to register the subdomain under |
label | string | The label of the subdomain to register (e.g. in 0://zero.child the label would be "child"). |
domainAddress | address | (optional) The address to which the subdomain will be resolved to |
tokenURI | string | (required) The tokenURI for the subdomain to be registered |
distrConfig | struct IDistributionConfig.DistributionConfig | (optional) The distribution config to be set for the subdomain to set rules for children |
paymentConfig | struct PaymentConfig | (optional) Payment config for the domain to set on ZNSTreasury in the same tx > paymentConfig has to be fully filled or all zeros. It is optional as a whole, but all the parameters inside are required. |
function hashWithParent(bytes32 parentHash, string label) public pure returns (bytes32)
Helper function to hash a child label with a parent domain hash.
function setDistributionConfigForDomain(bytes32 domainHash, struct IDistributionConfig.DistributionConfig config) public
Setter for distrConfigs[domainHash]
.
Only domain owner/operator or ZNSRootRegistrar can call this function.
This config can be changed by the domain owner/operator at any time or be set
after registration if the config was not provided during the registration.
Fires DistributionConfigSet
event.
Name | Type | Description |
---|---|---|
domainHash | bytes32 | The domain hash to set the distribution config for |
config | struct IDistributionConfig.DistributionConfig | The new distribution config to set (for config fields see IDistributionConfig.sol ) |
function setPricerContractForDomain(bytes32 domainHash, contract IZNSPricer pricerContract) public
One of the individual setters for distrConfigs[domainHash]
. Sets pricerContract
field of the struct.
Made to be able to set the pricer contract for a domain without setting the whole config.
Only domain owner/operator can call this function.
Fires PricerContractSet
event.
Name | Type | Description |
---|---|---|
domainHash | bytes32 | The domain hash to set the pricer contract for |
pricerContract | contract IZNSPricer | The new pricer contract to set |
function setPaymentTypeForDomain(bytes32 domainHash, enum IDistributionConfig.PaymentType paymentType) public
One of the individual setters for distrConfigs[domainHash]
. Sets paymentType
field of the struct.
Made to be able to set the payment type for a domain without setting the whole config.
Only domain owner/operator can call this function.
Fires PaymentTypeSet
event.
Name | Type | Description |
---|---|---|
domainHash | bytes32 | The domain hash to set the payment type for |
paymentType | enum IDistributionConfig.PaymentType | The new payment type to set |
function setAccessTypeForDomain(bytes32 domainHash, enum IDistributionConfig.AccessType accessType) public
One of the individual setters for distrConfigs[domainHash]
. Sets accessType
field of the struct.
Made to be able to set the access type for a domain without setting the whole config.
Only domain owner/operator or ZNSRootRegistrar can call this function.
Fires AccessTypeSet
event.
Name | Type | Description |
---|---|---|
domainHash | bytes32 | The domain hash to set the access type for |
accessType | enum IDistributionConfig.AccessType | The new access type to set |
function updateMintlistForDomain(bytes32 domainHash, address[] candidates, bool[] allowed) external
Setter for mintlist[domainHash][candidate]
. Only domain owner/operator can call this function.
Adds or removes candidates from the mintlist for a domain. Should only be used when the domain's owner
wants to limit subdomain registration to a specific set of addresses.
Can be used to add/remove multiple candidates at once. Can only be called by the domain owner/operator.
Fires MintlistUpdated
event.
Name | Type | Description |
---|---|---|
domainHash | bytes32 | The domain hash to set the mintlist for |
candidates | address[] | The array of candidates to add/remove |
allowed | bool[] | The array of booleans indicating whether to add or remove the candidate |
function isMintlistedForDomain(bytes32 domainHash, address candidate) external view returns (bool)
function clearMintlistForDomain(bytes32 domainHash) public
function clearMintlistAndLock(bytes32 domainHash) external
function setRegistry(address registry_) public
Sets the registry address in state.
This function is required for all contracts inheriting ARegistryWired
.
function setRootRegistrar(address registrar_) public
Setter for rootRegistrar
. Only admin can call this function.
Fires RootRegistrarSet
event.
Name | Type | Description |
---|---|---|
registrar_ | address | The new address of the ZNSRootRegistrar contract |
function _authorizeUpgrade(address newImplementation) internal view
To use UUPS proxy we override this function and revert if msg.sender
isn't authorized
Name | Type | Description |
---|---|---|
newImplementation | address | The implementation contract to upgrade to |