ILabelStore

Git Source

Inherits: IDotnsStore

Title: ILabelStore

Interface for the per-user DotNS label store.

The LabelStore is the protocol-managed half of the per-user storage pair: write-only by addresses registered in the protocol registry, read-only by everyone else, and permanently locked per labelhash on first write. It holds registration records only; every other per-name category (reverse, content, forward address, chat key, lite link) lives on a dedicated resolver, not here.

Note: security-contact: admin@parity.io

Functions

initialize

Initialises the store, binding it permanently to user_ and protocolRegistry_.

Callable exactly once via Initializable; both parameters are immutable post-call. user_ must be non-zero, otherwise @custom:reverts InvalidUser. protocolRegistry_ must be non-zero, otherwise @custom:reverts InvalidProtocolRegistry. @param user_ The user this store is bound to forever.

function initialize(address user_, address protocolRegistry_) external;

Parameters

NameTypeDescription
user_address
protocolRegistry_addressThe protocol registry used to authorise writers.

storeLabel

Records a label under labelhash and locks the slot permanently.

Gated to addresses currently registered in the protocol registry, otherwise

Notes:

  • reverts: NotAuthorised. labelhash must be non-zero, otherwise

  • reverts: InvalidLabel. The slot must not already hold an entry, otherwise

  • reverts: LabelAlreadyExists; the write is permanent so any second call reverts. Emits @custom:emits LabelStored on the single successful write.

function storeLabel(bytes32 labelhash, string calldata label) external;

Parameters

NameTypeDescription
labelhashbytes32The labelhash key.
labelstringThe label string to store.

protocolRegistry

Returns the protocol registry this store queries for write authorisation.

function protocolRegistry() external view returns (address protocolRegistry_);

Returns

NameTypeDescription
protocolRegistry_addressThe registry address.

hasLabel

Returns true iff a label has been stored under labelhash.

function hasLabel(bytes32 labelhash) external view returns (bool exists);

Parameters

NameTypeDescription
labelhashbytes32The labelhash to check.

Returns

NameTypeDescription
existsboolTrue iff the slot holds a label.

isLocked

Returns true iff the slot for labelhash is permanently locked.

Always equal to hasLabel in the current design; exposed explicitly so future implementations behind the beacon can distinguish "stored" from "locked" if needed.

function isLocked(bytes32 labelhash) external view returns (bool locked);

Parameters

NameTypeDescription
labelhashbytes32The labelhash to check.

Returns

NameTypeDescription
lockedboolTrue iff the slot is locked.

getLabel

Returns the stored label for labelhash, or the empty string if none.

function getLabel(bytes32 labelhash) external view returns (string memory label);

Parameters

NameTypeDescription
labelhashbytes32The labelhash to look up.

Returns

NameTypeDescription
labelstringThe stored label string.

getLabelCount

Returns the total number of labels ever stored.

function getLabelCount() external view returns (uint256 count);

Returns

NameTypeDescription
countuint256Current length of the insertion-order list.

getLabelAt

Returns the human-readable label at the given insertion-order index.

Primary read for "give me my names"; does not require the caller to know any labelhash. For the underlying labelhash key see @custom:function getLabelhashAt.

function getLabelAt(uint256 index) external view returns (string memory label);

Parameters

NameTypeDescription
indexuint256Zero-based index into the insertion-order list.

Returns

NameTypeDescription
labelstringThe stored label string at index.

getLabelhashAt

Returns the labelhash at the given insertion-order index.

function getLabelhashAt(uint256 index) external view returns (bytes32 labelhash);

Parameters

NameTypeDescription
indexuint256Zero-based index into the insertion-order list.

Returns

NameTypeDescription
labelhashbytes32The labelhash at index.

getLabels

Paginated read returning just the stored labels, in insertion order.

Primary bulk read for "give me all my names". Callers never need to touch labelhashes. Length is min(limit, getLabelCount() - offset); offset >= getLabelCount() returns an empty array (not a revert).

function getLabels(uint256 offset, uint256 limit) external view returns (string[] memory labels);

Parameters

NameTypeDescription
offsetuint256Start index.
limituint256Maximum entries to return.

Returns

NameTypeDescription
labelsstring[]Slice of label strings.

getLabelhashes

Paginated read over the labelhash keys, in insertion order.

Advanced read for callers that need the raw labelhash keys. Symmetric with

Note: function: getLabels; same indices map to the same entries.

function getLabelhashes(
    uint256 offset,
    uint256 limit
)
    external
    view
    returns (bytes32[] memory labelhashes);

Parameters

NameTypeDescription
offsetuint256Start index.
limituint256Maximum entries to return.

Returns

NameTypeDescription
labelhashesbytes32[]Slice of labelhash keys.

Events

LabelStored

Emitted when a label is stored for the first (and only) time under a given labelhash. @param owner The user this store is bound to.

event LabelStored(address indexed owner, bytes32 indexed labelhash, string label);

Parameters

NameTypeDescription
owneraddress
labelhashbytes32The labelhash key.
labelstringThe stored label string (typically the full name, e.g. "alice.dot").

Errors

NotAuthorised

Thrown when a caller that is not currently protocol-registered attempts a write.

error NotAuthorised(address caller);

Parameters

NameTypeDescription
calleraddressThe msg.sender that failed the isRegisteredAddress check.

InvalidUser

Thrown when initialize is called with a zero user address.

error InvalidUser(address user);

Parameters

NameTypeDescription
useraddressThe invalid user argument.

InvalidProtocolRegistry

Thrown when initialize is called with a zero protocol registry address.

error InvalidProtocolRegistry(address protocolRegistry);

Parameters

NameTypeDescription
protocolRegistryaddressThe invalid registry argument.

InvalidLabel

Thrown when storeLabel is called with a zero labelhash.

error InvalidLabel(bytes32 labelhash);

Parameters

NameTypeDescription
labelhashbytes32The invalid labelhash argument.

LabelAlreadyExists

Thrown when storeLabel is called for a labelhash already present in the index.

Labels are write-once and permanently locked on first store, so any second write for the same labelhash fails with this error regardless of caller or session.

error LabelAlreadyExists(bytes32 labelhash);

Parameters

NameTypeDescription
labelhashbytes32The conflicting labelhash.