DotnsProtocolRegistry

Git Source

Inherits: Initializable, UUPSUpgradeable, OwnableUpgradeable, IDotnsProtocolRegistry

Title: Dotns Protocol Registry

Author: Parity

Upgradeable address registry for all DotNS protocol contracts, and the authority for the network's top-level domain.

Single source of truth for sibling-contract lookups. All siblings resolve each other via well-known bytes32 constants in DotnsConstants rather than holding direct addresses, so an upgrade or rewire only mutates this contract. The TLD node and suffix are set once at initialisation and read live by every consumer, so a network runs one TLD without recompiling its contracts.

Note: security-contact: admin@parity.io

State Variables

_addresses

Address stored for each well-known protocol key.

mapping(bytes32 key => address addr) private _addresses

_registeredRefcount

Reference count per address, incremented for every key it is registered under.

Lets isRegisteredAddress answer in O(1) and survive a contract being mapped to multiple keys without being treated as deregistered when only one key is rewired.

mapping(address addr => uint256 refcount) private _registeredRefcount

_tldNode

Namehash of the TLD node, namehash(0, keccak256(bytes(tldLabel))).

bytes32 private _tldNode

_tld

TLD suffix including the leading dot, e.g. .dot.

string private _tld

__gap

uint256[50] private __gap

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor() ;

initialize

Initialises the protocol registry and fixes the network's TLD.

Callable exactly once via Initializable, otherwise

Note: reverts: InvalidInitialization. Sets the deployer as owner. tldLabel is the bare label without a dot (e.g. dot, paseo); it must be a single DNS label, otherwise @custom:reverts InvalidTld. The TLD is fixed here because changing it after names exist would reroot every node.

function initialize(string calldata tldLabel) external initializer;

Parameters

NameTypeDescription
tldLabelstringBare TLD label, without the leading dot.

get

Returns the address stored for a given key.

Returns address(0) when the key is unset; callers must validate when non-zero is required.

function get(bytes32 key) external view override returns (address addr);

set

Sets or updates the address for a given key.

Owner-restricted, otherwise @custom:reverts OwnableUnauthorizedAccount. addr must be non-zero, otherwise @custom:reverts ZeroAddress. Idempotent when the new value matches the stored one (no event emitted in that case). Maintains a per-address refcount so the same contract can occupy multiple keys without losing its registered status until every key is rewired. Emits

Note: emits: AddressUpdated on each effective change.

function set(bytes32 key, address addr) external override onlyOwner;

isRegisteredAddress

Returns true iff addr is currently registered under at least one well-known key.

O(1) refcount-backed lookup. Canonical peer-trust check consumed by LabelStore writes and StoreFactory deploys; only addresses governance has actively registered return true. Treats address(0) as never registered regardless of refcount.

function isRegisteredAddress(address addr) external view override returns (bool registered);

tldNode

Returns the namehash of the network's TLD node.

namehash(0, keccak256(bytes(tldLabel))), fixed at initialisation. Consumers use it as the root parent when deriving a name's node.

function tldNode() external view override returns (bytes32 node);

tld

Returns the network's TLD suffix, including the leading dot (e.g. .dot).

Fixed at initialisation. Consumers append it when rendering a label as a full name.

function tld() external view override returns (string memory suffix);

version

Returns implementation version.

function version() external pure virtual returns (string memory versionString);

Returns

NameTypeDescription
versionStringstringCurrent version string.

_authorizeUpgrade

Function that should revert when msg.sender is not authorized to upgrade the contract. Called by {upgradeToAndCall}. Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.

function _authorizeUpgrade(address) internal onlyOwner {}
function _authorizeUpgrade(address newImplementation) internal override onlyOwner;