StoreUtils

Git Source

Title: DotNS Store Utilities Library

Canonical helpers for protocol writes into per-user LabelStore instances.

One auth rule, one write path. Every DotNS consumer (controller, registrar, registry, PoP controller) funnels label writes through writeLabel so authorisation and deploy-on-first-use semantics are identical across flows.

Note: security-contact: admin@parity.io

Functions

ensureLabelStore

Returns the LabelStore for user, deploying one via the factory if absent.

Deploy-on-demand: a user's store is created on their first protocol write so unused accounts never pay the deployment cost. The deploy path is gated by the factory, so callers that are not the factory owner and not a store writer

Note: reverts: NotAuthorised when a deployment is required.

function ensureLabelStore(IStoreFactory factory, address user)
    internal
    returns (address store);

Parameters

NameTypeDescription
factoryIStoreFactoryThe store factory.
useraddressThe user whose label store is being resolved.

Returns

NameTypeDescription
storeaddressThe resolved or newly deployed store address.

writeNewLabel

Writes label for a name being registered, rejecting a conflicting entry.

Same as @custom:function writeLabel except that an existing entry is only tolerated when it already holds label. A registration is the first time the protocol names a node in this user's store, so an entry saying something else was put there by someone else and must not be silently honoured: storeLabel is single-write with no delete, so accepting it would leave the name permanently mislabelled and untransferable. Matching entries stay a no-op, which keeps re-registration by a previous holder working.

function writeNewLabel(
    IStoreFactory factory,
    address user,
    bytes32 labelhash,
    string memory label
)
    internal
    returns (address store);

Parameters

NameTypeDescription
factoryIStoreFactoryThe store factory.
useraddressThe label store owner.
labelhashbytes32The labelhash key.
labelstringThe label string (typically the full name, e.g. "alice.dot").

Returns

NameTypeDescription
storeaddressThe resolved or newly deployed store address.

writeLabel

Writes label under labelhash for user, deploying their LabelStore if needed.

Idempotent on locked entries: once a label is locked the call is a no-op rather than a revert, so retried protocol flows (e.g. an ERC721 transfer back to a prior owner) pass through without failing on the existing lock. Inherits the factory's writer authorisation: callers that are not the factory owner and not a store writer @custom:reverts NotAuthorised when the user has no store yet.

function writeLabel(
    IStoreFactory factory,
    address user,
    bytes32 labelhash,
    string memory label
)
    internal
    returns (address store);

Parameters

NameTypeDescription
factoryIStoreFactoryThe store factory.
useraddressThe label store owner.
labelhashbytes32The labelhash key.
labelstringThe label string (typically the full name, e.g. "alice.dot").

Returns

NameTypeDescription
storeaddressThe resolved or newly deployed store address.

Errors

LabelEntryConflict

Thrown when a name being registered already has a different label entry.

error LabelEntryConflict(address store, bytes32 labelhash, string existing);

Parameters

NameTypeDescription
storeaddressThe label store holding the conflicting entry.
labelhashbytes32The key that is already occupied.
existingstringThe label already stored under labelhash.