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 protocol-registered

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.

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 protocol-registered @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.