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, gateway path, 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 resolved against the protocol registry on every write (@custom:function StoreAuth.isStoreWriter), 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.writeNewLabel. 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.

registerName

Mints the name token for node to user and points the forward registry at them: the first two steps of the triad.

For a controller that already holds the registrar and registry addresses, so it runs the same steps as @custom:function registerAndStore without resolving them again. A non-empty label makes the registrar write the owner's LabelStore entry; an empty one leaves the store write to the caller.

function registerName(
    IDotnsRegistrar registrar,
    IDotnsRegistry registry,
    bytes32 node,
    address user,
    string memory label
)
    internal;

Parameters

NameTypeDescription
registrarIDotnsRegistrarThe base registrar.
registryIDotnsRegistryThe forward registry.
nodebytes32namehash(tldNode, labelhash).
useraddressAddress receiving the name.
labelstringLabel for the registrar's store write, or empty to skip it.

_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(tldNode, 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;
}