DotnsContentResolver

Git Source

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(IDotnsProtocolRegistry registry) external initializer;

Parameters

NameTypeDescription
registryIDotnsProtocolRegistryProtocol-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

NameTypeDescription
nodebytes32The node whose content hash is being set.
hashbytesOpaque content hash bytes.

contenthash

Returns the content hash associated with a node.

function contenthash(bytes32 node) external view override returns (bytes memory hash);

Parameters

NameTypeDescription
nodebytes32The node to query.

Returns

NameTypeDescription
hashbytesThe 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

NameTypeDescription
nodebytes32The node whose text record is being set.
keystringText record key (e.g., "ipfs", "avatar").
valuestringText 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

NameTypeDescription
nodebytes32The node to query.
keystringText record key.

Returns

NameTypeDescription
valuestringStored 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

NameTypeDescription
operatoraddressAddress to authorise or revoke.
approvedboolTrue 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

NameTypeDescription
owneraddressThe owner of the nodes.
operatoraddressThe address acting on behalf of the owner.

Returns

NameTypeDescription
<none>boolTrue 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

NameTypeDescription
nodebytes32Node identifier.

version

Returns implementation version.

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

Returns

NameTypeDescription
versionStringstringCurrent version string.

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;