DotnsContentResolver
Inherits: Initializable, UUPSUpgradeable, OwnableUpgradeable, ERC165Upgradeable, IDotnsContentResolver
Title: Dotns Content Resolver
Implements IDotnsContentResolver interface with content hash, text records, and
operator approvals.
Writes are gated on the registry's authorisation for the node (owner or registrar-level approval) or on a resolver-local operator the owner has approved, rather than on a privileged writer address. Content records are user-managed metadata, so write authority follows the node owner across transfers and honours the same delegates the registry recognises.
Note: security-contact: admin@parity.io
State Variables
contenthashes
Stores all content hash mappings
mapping(bytes32 node => bytes contentHash) private contenthashes
textRecords
Stores all text records
mapping(bytes32 node => mapping(string key => string value)) private textRecords
operators
Store all approval mapping
mapping(address owner => mapping(address operator => bool approved)) private operators
protocolRegistry
Protocol-level address registry for all DotNS contracts.
IDotnsProtocolRegistry public protocolRegistry
__gap
Reserved storage space to allow for layout changes in the future.
uint256[50] private __gap
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor() ;
initialize
Initialises the content 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. |
setContenthash
Sets the content hash for a node.
The caller must own the node in the DotNS registry or be an approved operator, otherwise @custom:reverts NotAuthorised. Content hashes are opaque bytes (e.g. an IPFS CID); the resolver stores them as-is and never interprets the payload. Emits
Note: emits: ContentHashUpdated on every successful write.
function setContenthash(bytes32 node, bytes calldata hash) external override;
Parameters
| Name | Type | Description |
|---|---|---|
node | bytes32 | The node whose content hash is being set. |
hash | bytes | Opaque content hash bytes. |
contenthash
Returns the content hash associated with a node.
function contenthash(bytes32 node) external view override returns (bytes memory hash);
Parameters
| Name | Type | Description |
|---|---|---|
node | bytes32 | The node to query. |
Returns
| Name | Type | Description |
|---|---|---|
hash | bytes | The stored content hash bytes, or empty if unset. |
setText
Sets a text record for a node.
The caller must own the node in the DotNS registry or be an approved operator,
otherwise @custom:reverts NotAuthorised. Text records are arbitrary key/value strings
(e.g. avatar, url, description). Emits @custom:emits TextUpdated on every
successful write.
function setText(bytes32 node, string calldata key, string calldata value) external override;
Parameters
| Name | Type | Description |
|---|---|---|
node | bytes32 | The node whose text record is being set. |
key | string | Text record key (e.g., "ipfs", "avatar"). |
value | string | Text record value. |
text
Returns a text record for a node.
function text(
bytes32 node,
string calldata key
)
external
view
override
returns (string memory value);
Parameters
| Name | Type | Description |
|---|---|---|
node | bytes32 | The node to query. |
key | string | Text record key. |
Returns
| Name | Type | Description |
|---|---|---|
value | string | Stored text value, or empty string if unset. |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage all of
msg.sender's nodes.
Emits @custom:emits ApprovalForAll whenever the approval flag is written, including idempotent writes that do not change the stored value.
function setApprovalForAll(address operator, bool approved) external override;
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | Address to authorise or revoke. |
approved | bool | True to approve, false to revoke. |
isApprovedForAll
Query if an address is an approved operator for another address.
function isApprovedForAll(
address owner,
address operator
)
external
view
override
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | The owner of the nodes. |
operator | address | The address acting on behalf of the owner. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if operator is approved, false otherwise. |
_requireNodeOwnerOrOperator
Ensures the caller may write records for node.
Authority is granted to the node owner, to a resolver-local operator the owner has approved for all of their records, or to any address the registry deems authorised for the node. Delegating through the registry means a single registrar-level approval (ERC-721 owner / approved / operator-for-all) also confers record-write authority, while the resolver-local operator mapping remains a narrower record-only delegation that grants no power over ownership or transfers. The cheap owner and local-operator checks run before the cross-contract registry call.
function _requireNodeOwnerOrOperator(bytes32 node) internal view;
Parameters
| Name | Type | Description |
|---|---|---|
node | bytes32 | Node identifier. |
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. |
supportsInterface
function supportsInterface(bytes4 interfaceId) public view override returns (bool);
_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;