RegistrationUtils

Git Source

Title: DotNS Registration Utilities Library

Single canonical implementation of the "mint + forward-registry + store-write" triad used by every DotNS registration flow.

Exists so that every controller (public commit-reveal, PoP gateway, future privileged flows) calls the same sequence. Without this library each controller re-implements the sequence, and the implementations drift.

Scope: this library is deliberately minimal. It only performs the steps that every registration flow needs regardless of policy:

  1. Mint the ERC721 name token on the base registrar.
  2. Write the forward registry entry (node => owner + default resolver).
  3. Resolve the per-user LabelStore (deploying on demand) so the caller can pass it back. The registrar writes the labels-only store entry internally. Flow-specific concerns (pricing, reverse-record setting, chat-key persistence, reservation queue mutation) stay inside the calling controller.

Note: security-contact: admin@parity.io

Functions

registerAndStore

Performs the canonical mint + forward-registry + store-write sequence.

Callable by any authorised controller. Emits no events; each controller emits its own flow-level event after this returns, so behavioural drift between flows stays contained at the emission layer rather than at the underlying state-transition layer. Store authorisation is handled by the protocol registry (isRegisteredAddress) on every write, so no per-store allowlist bookkeeping is needed here.

The registrar writes the LabelStore entry directly inside register so this helper deliberately does not call StoreUtils.writeLabel. Doing it twice would deploy or touch the store on every flow and could conflict with the registrar's locked-entry semantics.

function registerAndStore(RegistrationContext memory context)
    internal
    returns (address labelStore);

Parameters

NameTypeDescription
contextRegistrationContextRegistration inputs. See @custom:struct RegistrationContext.

Returns

NameTypeDescription
labelStoreaddressThe resolved or newly deployed LabelStore address for context.user.

_resolveSiblings

Resolves sibling contracts via the protocol registry.

Exists so that resolution is one round-trip through a single helper and not duplicated inline at every call site. If protocol-registry key conventions change, the change lands here.

function _resolveSiblings(IDotnsProtocolRegistry protocolRegistry)
    private
    view
    returns (Siblings memory siblings);

Structs

RegistrationContext

Inputs describing a single name registration.

Passed as a struct so callers do not have to thread a growing positional argument list, and so future additions (e.g. a subname parent node) can be made additively without breaking call sites.

struct RegistrationContext {
    IDotnsProtocolRegistry protocolRegistry;
    address user;
    string label;
    bytes32 labelhash;
    bytes32 node;
}

Properties

NameTypeDescription
protocolRegistryIDotnsProtocolRegistryThe protocol-level address registry for sibling lookups.
useraddressAddress receiving the name.
labelstringHuman-readable label (without the TLD).
labelhashbytes32keccak256(bytes(label)).
nodebytes32namehash(DOT_NODE, labelhash).

Siblings

Resolved sibling contracts for a registration call.

Held as a struct internally so the helper can pass a single value to the downstream steps rather than three separate locals. Never returned to callers; kept in memory for the lifetime of one registerAndStore.

struct Siblings {
    IDotnsRegistrar registrar;
    IDotnsRegistry registry;
    IStoreFactory storeFactory;
}