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 writeNewLabel so authorisation, deploy-on-first-use and conflict handling 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.

An existing entry is tolerated only when it already holds label. 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, and a transfer back to one, 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.

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.