LabelStore
Inherits: Initializable, ILabelStore
Title: LabelStore
Permanent per-user DotNS label store.
One instance per user, deployed as a BeaconProxy by StoreFactory during registration.
Bound to its user forever: _owner and _protocolRegistry are set once at initialize
and never mutate. Writes are gated to the registrar, an authorised controller or the
registry, rather than to anything the protocol registry happens to hold
(@custom:function StoreAuth.isStoreWriter); every labelhash is single-write and
permanently locked on first use.
Labels-only by invariant: this store holds registration records only. Every other per-name category (reverse, content, forward address, chat key, lite link) lives on a dedicated resolver, never here.
Storage collision: the BeaconProxy stores the beacon address at EIP-1967 slot
keccak256("eip1967.proxy.beacon") - 1, which is non-sequential and cannot collide
with this contract's sequential storage slots.
Note: security-contact: admin@parity.io
State Variables
_owner
Permanent user this store belongs to. Set in initialize.
address private _owner
_protocolRegistry
Canonical DotNS protocol registry. Set in initialize.
address private _protocolRegistry
_labels
labelhash => stored label string.
mapping(bytes32 labelhash => string label) private _labels
_labelList
Insertion-order list of all stored labelhashes. Append-only.
bytes32[] private _labelList
_labelIndex
labelhash => 1-indexed position in _labelList (zero means "not present").
Doubles as the permanent-lock sentinel: a non-zero index proves the label was written and
the contract has no deletion path, so the index is also the locked flag.
mapping(bytes32 labelhash => uint256 indexPlusOne) private _labelIndex
__gap
Reserved storage space to allow for layout changes in future beacon upgrades.
uint256[50] private __gap
Functions
onlyAuthorisedProtocol
Restricts writes to the protocol components named in @custom:function StoreAuth.isStoreWriter.
modifier onlyAuthorisedProtocol() ;
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor() ;
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 override initializer;
Parameters
| Name | Type | Description |
|---|---|---|
user_ | address | |
protocolRegistry_ | address | The protocol registry used to authorise writers. |
storeLabel
Records a label under labelhash and locks the slot permanently.
Gated to the components named in @custom:function StoreAuth.isStoreWriter, otherwise
Note:
reverts: NotAuthorised. labelhash must be non-zero, otherwise
function storeLabel(
bytes32 labelhash,
string calldata label
)
external
override
onlyAuthorisedProtocol;
Parameters
| Name | Type | Description |
|---|---|---|
labelhash | bytes32 | The labelhash key. |
label | string | The label string to store. |
owner
Returns the permanent user this store is bound to.
Set once at initialize and never mutated; used as the binding-mismatch oracle
and immutable thereafter.
function owner() external view override returns (address owner_);
Returns
| Name | Type | Description |
|---|---|---|
owner_ | address | The bound user address. |
protocolRegistry
Returns the protocol registry this store queries for write authorisation.
function protocolRegistry() external view override returns (address protocolRegistry_);
Returns
| Name | Type | Description |
|---|---|---|
protocolRegistry_ | address | The registry address. |
hasLabel
Returns true iff a label has been stored under labelhash.
function hasLabel(bytes32 labelhash) external view override returns (bool exists);
Parameters
| Name | Type | Description |
|---|---|---|
labelhash | bytes32 | The labelhash to check. |
Returns
| Name | Type | Description |
|---|---|---|
exists | bool | True 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 override returns (bool locked);
Parameters
| Name | Type | Description |
|---|---|---|
labelhash | bytes32 | The labelhash to check. |
Returns
| Name | Type | Description |
|---|---|---|
locked | bool | True iff the slot is locked. |
getLabel
Returns the stored label for labelhash, or the empty string if none.
function getLabel(bytes32 labelhash) external view override returns (string memory label);
Parameters
| Name | Type | Description |
|---|---|---|
labelhash | bytes32 | The labelhash to look up. |
Returns
| Name | Type | Description |
|---|---|---|
label | string | The stored label string. |
getLabelCount
Returns the total number of labels ever stored.
function getLabelCount() external view override returns (uint256 count);
Returns
| Name | Type | Description |
|---|---|---|
count | uint256 | Current 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 override returns (string memory label);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | Zero-based index into the insertion-order list. |
Returns
| Name | Type | Description |
|---|---|---|
label | string | The stored label string at index. |
getLabelhashAt
Returns the labelhash at the given insertion-order index.
function getLabelhashAt(uint256 index) external view override returns (bytes32 labelhash);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | Zero-based index into the insertion-order list. |
Returns
| Name | Type | Description |
|---|---|---|
labelhash | bytes32 | The 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
override
returns (string[] memory labels);
Parameters
| Name | Type | Description |
|---|---|---|
offset | uint256 | Start index. |
limit | uint256 | Maximum entries to return. |
Returns
| Name | Type | Description |
|---|---|---|
labels | string[] | 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
override
returns (bytes32[] memory labelhashes);
Parameters
| Name | Type | Description |
|---|---|---|
offset | uint256 | Start index. |
limit | uint256 | Maximum entries to return. |
Returns
| Name | Type | Description |
|---|---|---|
labelhashes | bytes32[] | Slice of labelhash keys. |
version
Returns implementation version.
function version() external pure virtual returns (string memory versionString);
Returns
| Name | Type | Description |
|---|---|---|
versionString | string | Current version string. |
_onlyAuthorisedProtocol
Internal authorisation check deferred from the onlyAuthorisedProtocol modifier.
function _onlyAuthorisedProtocol() internal view;