IDotnsContentResolver

Git Source

Title: dotNS Content Resolver

Defines storage and retrieval for content hash, text records, and operator approvals for dotNS nodes. @dev Content hash and text records point to off-chain content such as IPFS CIDs or future schemes; interpretation is handled off-chain. Operator approvals allow third parties to manage records on behalf of the owner.

Note: security-contact: admin@parity.io

Functions

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. An empty hash deletes the record: its storage is zeroed and the storage deposit released to the signer of the transaction. Emits @custom:emits ContentHashUpdated on every successful write.

function setContenthash(bytes32 node, bytes calldata hash) external;

Parameters

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

contenthash

Returns the content hash associated with 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 contenthash(bytes32 node) external view 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). An empty value deletes the record: its storage is zeroed and the storage deposit released to the signer of the transaction. That also works for a key a clear has already hidden, which still holds storage until it is deleted. Emits @custom:emits TextUpdated and @custom:emits TextChanged on every successful write, a delete included.

function setText(bytes32 node, string calldata key, string calldata value) external;

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.

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 text(bytes32 node, string calldata key) external view 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;

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 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.

Events

ContentHashUpdated

Emitted when a node's content hash is updated.

event ContentHashUpdated(bytes32 indexed node, bytes hash);

Parameters

NameTypeDescription
nodebytes32The node whose content hash was updated.
hashbytesThe new content hash bytes.

TextUpdated

Emitted when a node's text record is updated.

An indexed string is logged only as its keccak256 hash, so this event lets a consumer filter by key but never recover the key. @custom:emits TextChanged is emitted alongside it with the key readable.

event TextUpdated(bytes32 indexed node, string indexed key, string value);

Parameters

NameTypeDescription
nodebytes32The node whose text record was updated.
keystringThe text record key, logged as its hash.
valuestringThe new text record value.

TextChanged

Emitted with every @custom:emits TextUpdated, carrying the key readably.

The key appears twice: indexed, as a hash to filter on, and in the data, where an indexer can read it and so list the keys a node has set. The shape matches the ENS public resolver's TextChanged, so tooling built for it reads this event unchanged.

event TextChanged(bytes32 indexed node, string indexed indexedKey, string key, string value);

Parameters

NameTypeDescription
nodebytes32The node whose text record was updated.
indexedKeystringThe text record key, logged as its hash.
keystringThe text record key, readable.
valuestringThe new text record value.

ApprovalForAll

Emitted when an operator is approved or revoked.

event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

Parameters

NameTypeDescription
owneraddressThe owner of the nodes.
operatoraddressThe operator address.
approvedboolTrue if approved, false if revoked.

Errors

NotAuthorised

Thrown when the caller is not authorised to modify a node.

error NotAuthorised(bytes32 node, address caller);

Parameters

NameTypeDescription
nodebytes32The node being modified.
calleraddressThe address attempting the modification.