DotnsResolver
Inherits: Initializable, UUPSUpgradeable, OwnableUpgradeable, ERC165Upgradeable, IDotnsResolver
Title: dotNS Resolver
Stores forward-resolution address records for dotNS nodes
Writes are gated on node ownership in the forward registry, not on a privileged writer address. Address records describe where a name points and only the current node owner has the authority to set that target. Each record is stamped with the node's record version from the registry (@custom:function IDotnsRegistry.recordVersion), and a read returns the zero address unless the node still resolves and the stamp is current. That is how a cleared name, or a name beneath a cleared one, stops resolving without its records being visited.
Note: security-contact: admin@parity.io
State Variables
protocolRegistry
Protocol-level address registry for all dotNS contracts.
IDotnsProtocolRegistry public protocolRegistry
__gap
Reserved storage space. It sits before addresses, so it must never shrink: add new
state after the last variable instead.
uint256[50] private __gap
addresses
Node => resolved address.
mapping(bytes32 node => address owner) private addresses
addressVersions
Node => registry record version its address was written under.
Zero matches the record version every node starts at, so an address stamped zero reads as set until its node is first cleared.
mapping(bytes32 node => uint64 version) private addressVersions
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor() ;
initialize
Initialises the resolver.
Runs once through the UUPS proxy; a repeat call reverts with
Note:
reverts: InvalidInitialization. Emits @custom:emits OwnershipTransferred when
msg.sender is recorded as the initial owner and @custom:emits Initialized once
setup completes.
function initialize(
address initialOwner,
IDotnsProtocolRegistry registry
)
external
initializer;
Parameters
| Name | Type | Description |
|---|---|---|
initialOwner | address | Address that owns the contract once initialised. |
registry | IDotnsProtocolRegistry | Protocol-level address registry used to resolve sibling contracts. |
setAddress
Sets the resolved address for a node.
The caller must be the current owner of node in the forward registry, otherwise
Note:
reverts: NotAuthorised. A zero value deletes the record: its storage is zeroed
and the storage deposit released to the signer of the transaction, which is how an
owner reclaims it before giving the name up. Emits @custom:emits AddressSet on every
successful write.
function setAddress(bytes32 node, address value) external override;
Parameters
| Name | Type | Description |
|---|---|---|
node | bytes32 | The node identifier. |
value | address | The address to associate with the node, or zero to delete the record. |
addressOf
Returns the resolved address for a node.
A record reads as unset once the node is cleared (@custom:function IDotnsRegistry.clearRecords) or stops resolving because a name above it was cleared, even though the bytes written before stay in storage.
function addressOf(bytes32 node) external view override returns (address value);
Parameters
| Name | Type | Description |
|---|---|---|
node | bytes32 | The node identifier. |
Returns
| Name | Type | Description |
|---|---|---|
value | address | The resolved address, or zero if unset. |
supportsInterface
function supportsInterface(bytes4 interfaceId) public view override returns (bool);
_onlyNodeOwner
Internal ownership check for a registry node.
function _onlyNodeOwner(bytes32 node) internal view returns (IDotnsRegistry registry);
Parameters
| Name | Type | Description |
|---|---|---|
node | bytes32 | Node identifier. |
Returns
| Name | Type | Description |
|---|---|---|
registry | IDotnsRegistry | The forward registry, returned so the caller reads it once. |
_registry
Returns the forward registry.
Resolved lazily through protocolRegistry so a registry upgrade or rewire is picked
up automatically without a resolver upgrade.
function _registry() internal view returns (IDotnsRegistry registry);
Returns
| Name | Type | Description |
|---|---|---|
registry | IDotnsRegistry | The forward registry. |
version
Returns the release this network declares it runs, read live from the protocol registry so every dotNS contract reports one synchronised value.
Mirror of IDotnsProtocolRegistry.protocolVersion, kept under the historical
version() selector for ABI compatibility. It reports the network's declaration,
not this contract's build; per-contract identity is the codehash declared on the
registry.
function version() external view virtual returns (string memory versionString);
Returns
| Name | Type | Description |
|---|---|---|
versionString | string | Declared release as bare semver, empty when never declared. |
_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;