IDotnsNameWhitelist

Git Source

Title: IDotnsNameWhitelist

Interface for the pre-launch name whitelist. A name is Open until governance either reserves it or a claim is accepted for it. Several beneficiaries may claim the same Open name, each with a reason, and governance accepts one as the winner.

Callers never supply a hash. Every entry point takes the bare label and derives the node from the label and the TLD in the protocol registry, so a caller cannot supply a mismatched hash. Claims are keyed by the beneficiary user, not the submitter, so a relayer or a cross-chain sovereign account can submit a claim on a user's behalf and the name still binds to that user. All state is on-chain and queryable through views; no event indexing is required. Grants, revocations, acceptances, rejections and reservations are substrate Root only: those gates check callerIsRoot and read no msg.sender, and no signed account can make them. The request window and the caps are also open to the maintainer account, within the rules each setter enforces. The controllers hold only the consume hook.

Note: security-contact: admin@parity.io

Functions

requestName

Claims label for user.

Permissionless within the window; the submitter may differ from user. Requires the name Open, the window open, user non-zero, a canonical label of at least three bytes, user without an existing claim, and fewer than maxClaimants claims on the name.

Notes:

  • reverts: WindowClosed, @custom:reverts NameNotOpen, @custom:reverts ZeroUser,

  • reverts: InvalidLabel, @custom:reverts ReasonTooLong,

  • reverts: AlreadyClaimed, or @custom:reverts TooManyClaimants.

  • emits: NameRequested.

function requestName(string calldata label, string calldata reason, address user) external;

Parameters

NameTypeDescription
labelstringBare label to claim.
reasonstringFree-text justification, at most maxReasonBytes bytes.
useraddressBeneficiary the name binds to if this claim wins.

withdrawClaim

Withdraws the caller's pending claim on label.

The caller is the beneficiary, whoever filed the claim, so a claim filed in their name never blocks their own request. Deletes the claim and frees its slot.

Notes:

  • reverts: NotRequested when the caller holds no pending claim on the name.

  • emits: ClaimWithdrawn.

function withdrawClaim(string calldata label) external;

Parameters

NameTypeDescription
labelstringBare label the claim is on.

accept

Accepts user's claim as the winner of label.

Restricted to a substrate Root dispatch. Requires user's claim Requested. Sets the name Claimed with user the winner and clears every claim on the name.

Notes:

  • reverts: NotRequested. @custom:emits NameAccepted for the winner and

  • emits: ClaimsCleared for the round.

function accept(string calldata label, address user) external;

Parameters

NameTypeDescription
labelstringBare label to resolve.
useraddressBeneficiary whose claim wins.

reject

Rejects user's pending claim on label without resolving the name.

Restricted to a substrate Root dispatch. Requires the claim Requested.

Note: reverts: NotRequested. @custom:emits NameRejected.

function reject(string calldata label, address user) external;

Parameters

NameTypeDescription
labelstringBare label.
useraddressBeneficiary whose claim is rejected.

grantName

Grants label to user directly, without a prior claim.

Restricted to a substrate Root dispatch. Requires the name Open, which an expired grant is, user non-zero and a canonical label of at least three bytes. Sets the name Claimed with user the winner, starts the grant period, and clears any pending claims. @custom:reverts NameNotOpen, @custom:reverts ZeroUser or

Notes:

  • reverts: InvalidLabel. @custom:emits NameAccepted, and

  • emits: ClaimsCleared when the name held claims.

function grantName(string calldata label, address user) external;

Parameters

NameTypeDescription
labelstringBare label to grant.
useraddressBeneficiary the name binds to.

grantNames

Grants several labels to one user directly.

Restricted to a substrate Root dispatch. Applies @custom:function grantName to each, at most maxGrantBatch labels per call.

Note: reverts: TooManyLabels when labels exceeds the batch cap.

function grantNames(string[] calldata labels, address user) external;

Parameters

NameTypeDescription
labelsstring[]Bare labels to grant.
useraddressBeneficiary each name binds to.

revokeName

Resets label to Open, clearing any winner and claims.

Restricted to a substrate Root dispatch. Resolves a Claimed or claim-holding name, an expired grant included, so governance can tidy a lapsed entry from the active set; a Reserved name is released through @custom:function setReserved, not here.

Notes:

  • reverts: NothingToRevoke when the name is not Claimed and holds no claims.

  • emits: NameRevoked, and @custom:emits ClaimsCleared when the name held claims.

function revokeName(string calldata label) external;

Parameters

NameTypeDescription
labelstringBare label to reset.

setReserved

Reserves or releases label.

Restricted to a substrate Root dispatch. Reserving requires the name Open and clears any pending claims; releasing requires it Reserved. @custom:reverts NameNotOpen or @custom:reverts NotReserved. @custom:emits NameReserved or @custom:emits NameUnreserved. @param label Bare label.

function setReserved(string calldata label, bool reserved) external;

Parameters

NameTypeDescription
labelstring
reservedboolTrue to reserve, false to release.

consume

Removes the win on label as registrant registers it.

Restricted to the registrar controllers resolved through the protocol registry. Resets the name to Open. @custom:reverts NotController for any other caller and

Notes:

  • reverts: NotWinner when label is not won by registrant or the grant has expired.

  • emits: NameConsumed.

function consume(string calldata label, address registrant) external;

Parameters

NameTypeDescription
labelstringBare label being registered.
registrantaddressAddress registering the name.

setWindow

Sets the request window relative to the current time.

Root or the maintainer account, otherwise @custom:reverts NotRootOrMaintainer. Opens at block.timestamp + startsIn for duration; @custom:reverts BadWindow when duration is zero. Root sets any window. The maintainer only lengthens a window that is open or scheduled: it passes startsIn zero, the window keeps its opening and duration counts from it. With no window open or scheduled, a non-zero startsIn, or a window that would close earlier, the call @custom:reverts MaintainerNotAllowed; a window longer than WHITELIST_MAINTAINER_MAX_WINDOW from its opening @custom:reverts MaintainerWindowOutOfBounds. @custom:emits WindowSet.

function setWindow(uint64 startsIn, uint64 duration) external;

Parameters

NameTypeDescription
startsInuint64Seconds from now until requests start being accepted.
durationuint64Seconds the window stays open.

setMaxClaimants

Sets the live-claim cap per name.

Root or the maintainer account, otherwise @custom:reverts NotRootOrMaintainer. While a window is open or scheduled, the maintainer can only raise it, otherwise

Notes:

  • reverts: MaintainerNotAllowed. The cap is bounded by DotnsConstants.WHITELIST_MAX_CLAIMANTS_LIMIT, which bounds the claims governance reviews per name. The cap only stops new requests: a name that collected more claims under a higher cap keeps them. Resolving a name ends its round of claims in one write, so no cap bounds the cost of a grant.

  • reverts: MaxClaimantsOutOfRange when newMax is zero or above the ceiling.

  • emits: MaxClaimantsSet.

function setMaxClaimants(uint16 newMax) external;

Parameters

NameTypeDescription
newMaxuint16New per-name claim cap.

setMaxReasonBytes

Sets the reason byte cap.

Root or the maintainer account, otherwise @custom:reverts NotRootOrMaintainer. While a window is open or scheduled, the maintainer can only raise it, otherwise

Notes:

  • reverts: MaintainerNotAllowed. Bounded by DotnsConstants.WHITELIST_MAX_REASON_LIMIT; @custom:reverts MaxReasonBytesOutOfRange when newMax is zero or above the ceiling.

  • emits: MaxReasonBytesSet.

function setMaxReasonBytes(uint256 newMax) external;

Parameters

NameTypeDescription
newMaxuint256New reason byte cap.

setMaxGrantBatch

Sets the cap on labels per grantNames call.

Root or the maintainer account, otherwise @custom:reverts NotRootOrMaintainer. The cap limits Root's own grant batches, so the maintainer can only raise it, otherwise

Note: reverts: MaintainerNotAllowed. Bounded by DotnsConstants.WHITELIST_MAX_GRANT_BATCH_LIMIT. @custom:reverts MaxGrantBatchOutOfRange when newMax is zero or above the ceiling. @custom:emits MaxGrantBatchSet.

function setMaxGrantBatch(uint16 newMax) external;

Parameters

NameTypeDescription
newMaxuint16New batch cap.

setGrantDuration

Sets the period a grant binds its name.

Root or the maintainer account, otherwise @custom:reverts NotRootOrMaintainer. The period applies to grants made after the call, and a live grant keeps the expiry it was given. A shorter period would still cut the grants a pending referendum makes, so the maintainer can only raise it, otherwise @custom:reverts MaintainerNotAllowed. Bounded by DotnsConstants.WHITELIST_MIN_GRANT_DURATION and DotnsConstants.WHITELIST_MAX_GRANT_DURATION.

Notes:

  • reverts: GrantDurationOutOfRange when newDuration is out of range.

  • emits: GrantDurationSet.

function setGrantDuration(uint64 newDuration) external;

Parameters

NameTypeDescription
newDurationuint64New grant period, in seconds.

maxClaimants

Returns the live-claim cap per name.

function maxClaimants() external view returns (uint16 cap);

Returns

NameTypeDescription
capuint16Current per-name claim cap.

maxReasonBytes

Returns the reason byte cap.

function maxReasonBytes() external view returns (uint256 cap);

Returns

NameTypeDescription
capuint256Current reason byte cap.

maxGrantBatch

Returns the cap on labels per grantNames call.

function maxGrantBatch() external view returns (uint16 cap);

Returns

NameTypeDescription
capuint16Current batch cap.

grantDuration

Returns the period a grant binds its name.

function grantDuration() external view returns (uint64 duration);

Returns

NameTypeDescription
durationuint64Current grant period, in seconds.

statusOf

Returns the status of label.

An expired grant reads Open.

function statusOf(string calldata label) external view returns (NameStatus status);

Parameters

NameTypeDescription
labelstringBare label to look up.

Returns

NameTypeDescription
statusNameStatusName status; see NameStatus.

isReserved

Returns whether label is reserved.

function isReserved(string calldata label) external view returns (bool reserved);

Parameters

NameTypeDescription
labelstringBare label to look up.

Returns

NameTypeDescription
reservedboolTrue when the name is Reserved.

granteeOf

Returns the winner of label, or the zero address when not Claimed.

Zero once the grant expires.

function granteeOf(string calldata label) external view returns (address winner);

Parameters

NameTypeDescription
labelstringBare label to look up.

Returns

NameTypeDescription
winneraddressWinning beneficiary.

granteeOfNode

Returns the winner of the name at node, or the zero address when not Claimed.

The check the controllers use to keep every other path off a granted name. They already hold the node, so this skips the TLD lookup @custom:function granteeOf makes, which keeps the gateway's proof smaller. Zero once the grant expires.

function granteeOfNode(bytes32 node) external view returns (address winner);

Parameters

NameTypeDescription
nodebytes32Namehash of the label under the active TLD.

Returns

NameTypeDescription
winneraddressWinning beneficiary.

grantExpiresAt

Returns when the grant on label expires, or zero when the name is not Claimed.

The grant binds the name while block.timestamp is below this value. Reads type(uint64).max on a whitelist upgraded without initializeGrantExpiry, where grants do not expire yet.

function grantExpiresAt(string calldata label) external view returns (uint64 expiresAt);

Parameters

NameTypeDescription
labelstringBare label to look up.

Returns

NameTypeDescription
expiresAtuint64Timestamp the grant expires at.

isGrantedTo

Returns whether account won label.

The pair check the controllers use to admit a registrant. False for the zero address and once the grant expires.

function isGrantedTo(
    string calldata label,
    address account
)
    external
    view
    returns (bool granted);

Parameters

NameTypeDescription
labelstringBare label to look up.
accountaddressAddress to test against the winner.

Returns

NameTypeDescription
grantedboolTrue when account is the winner.

claimOf

Returns user's claim on label.

function claimOf(string calldata label, address user) external view returns (Claim memory claim);

Parameters

NameTypeDescription
labelstringBare label to look up.
useraddressBeneficiary to look up.

Returns

NameTypeDescription
claimClaimThe stored claim; a zeroed struct with None status when absent.

claimantCount

Returns the number of live claims on label.

function claimantCount(string calldata label) external view returns (uint256 count);

Parameters

NameTypeDescription
labelstringBare label to look up.

Returns

NameTypeDescription
countuint256Live claim count.

claims

Returns a page of claims on label for review.

Reads the canonical offset and limit window.

function claims(
    string calldata label,
    uint256 offset,
    uint256 limit
)
    external
    view
    returns (Claim[] memory page);

Parameters

NameTypeDescription
labelstringBare label to look up.
offsetuint256Index of the first claim.
limituint256Maximum number of claims to return.

Returns

NameTypeDescription
pageClaim[]Claims in the window.

nameCount

Returns the number of names with reserved, claimed or claim-holding state.

function nameCount() external view returns (uint256 count);

Returns

NameTypeDescription
countuint256Active name count.

names

Returns a page of active names for review.

Reads the canonical offset and limit window. Iteration order is not stable. An expired grant stays in the set until a write on the name clears it, and reads Open with no winner.

function names(uint256 offset, uint256 limit) external view returns (NameView[] memory page);

Parameters

NameTypeDescription
offsetuint256Index of the first name.
limituint256Maximum number of names to return.

Returns

NameTypeDescription
pageNameView[]Names in the window.

window

Returns the request window.

function window() external view returns (uint64 openAt, uint64 closeAt);

Returns

NameTypeDescription
openAtuint64Timestamp requests start being accepted.
closeAtuint64Timestamp requests stop being accepted.

isWindowOpen

Returns whether requests are currently accepted.

function isWindowOpen() external view returns (bool open);

Returns

NameTypeDescription
openboolTrue when the current time is within the window.

Events

NameRequested

Emitted when a beneficiary claims a name.

event NameRequested(
    bytes32 indexed node,
    address indexed user,
    address indexed submitter,
    string label,
    string reason
);

Parameters

NameTypeDescription
nodebytes32
useraddress
submitteraddressAddress that filed the claim, which may differ from the beneficiary.
labelstring
reasonstring

ClaimWithdrawn

Emitted when a beneficiary withdraws their pending claim.

event ClaimWithdrawn(bytes32 indexed node, address indexed user, string label);

ClaimsCleared

Emitted when resolving a name clears the live claims of its round.

Replaces a rejection event per claim, so resolution costs the same however many claims a name holds. Every claim of round that was still pending ends without winning, except the accepted one, which @custom:emits NameAccepted names.

event ClaimsCleared(bytes32 indexed node, string label, uint256 round, uint256 cleared);

Parameters

NameTypeDescription
nodebytes32
labelstring
rounduint256Round of claims that ended.
cleareduint256Live claims the round held, the accepted one included.

NameAccepted

Emitted when a claim wins a name, including a direct governance grant.

event NameAccepted(bytes32 indexed node, address indexed user, string label);

NameRejected

Emitted when governance rejects a single claim.

event NameRejected(bytes32 indexed node, address indexed user, string label);

NameRevoked

Emitted when a name is reset to Open by governance.

event NameRevoked(bytes32 indexed node, address indexed winner, string label);

NameConsumed

Emitted when a winner registers the name and its entry is consumed.

event NameConsumed(bytes32 indexed node, address indexed user, string label);

NameReserved

Emitted when governance withholds a name from claiming.

event NameReserved(bytes32 indexed node, string label);

NameUnreserved

Emitted when governance releases a reserved name back to Open.

event NameUnreserved(bytes32 indexed node, string label);

WindowSet

Emitted when the request window is set.

event WindowSet(uint64 openAt, uint64 closeAt);

Parameters

NameTypeDescription
openAtuint64Timestamp requests start being accepted.
closeAtuint64Timestamp requests stop being accepted.

MaxClaimantsSet

Emitted when the live-claim cap is set.

event MaxClaimantsSet(uint16 maxClaimants);

Parameters

NameTypeDescription
maxClaimantsuint16New per-name claim cap.

MaxReasonBytesSet

Emitted when the reason byte cap is set.

event MaxReasonBytesSet(uint256 maxReasonBytes);

Parameters

NameTypeDescription
maxReasonBytesuint256New reason byte cap.

MaxGrantBatchSet

Emitted when the grant-batch cap is set.

event MaxGrantBatchSet(uint16 maxGrantBatch);

Parameters

NameTypeDescription
maxGrantBatchuint16New grantNames batch cap.

GrantDurationSet

Emitted when the grant period is set.

event GrantDurationSet(uint64 grantDuration);

Parameters

NameTypeDescription
grantDurationuint64New grant period, in seconds.

Errors

ZeroUser

Thrown when a claim names the zero-address beneficiary.

error ZeroUser();

InvalidLabel

Thrown when a label is not a canonical single DNS label, or when a claimed or granted label is shorter than DotnsConstants.MIN_LABEL_LENGTH.

error InvalidLabel();

ReasonTooLong

Thrown when a reason exceeds maxReasonBytes.

error ReasonTooLong();

NameNotOpen

Thrown when a name is not Open and the action requires it.

error NameNotOpen(bytes32 node);

Parameters

NameTypeDescription
nodebytes32Namehash of the label under the active TLD.

AlreadyClaimed

Thrown when user already holds a claim on the name.

error AlreadyClaimed(bytes32 node, address user);

Parameters

NameTypeDescription
nodebytes32Namehash of the label under the active TLD.
useraddressBeneficiary already holding a claim.

TooManyClaimants

Thrown when a name already holds maxClaimants claims.

error TooManyClaimants(bytes32 node);

Parameters

NameTypeDescription
nodebytes32Namehash of the label under the active TLD.

MaxClaimantsOutOfRange

Thrown when the claim cap is set to zero or above DotnsConstants.WHITELIST_MAX_CLAIMANTS_LIMIT.

error MaxClaimantsOutOfRange();

MaxReasonBytesOutOfRange

Thrown when the reason cap is set to zero or above DotnsConstants.WHITELIST_MAX_REASON_LIMIT.

error MaxReasonBytesOutOfRange();

MaxGrantBatchOutOfRange

Thrown when the grant-batch cap is set to zero or above DotnsConstants.WHITELIST_MAX_GRANT_BATCH_LIMIT.

error MaxGrantBatchOutOfRange();

GrantDurationOutOfRange

Thrown when the grant period is set below DotnsConstants.WHITELIST_MIN_GRANT_DURATION or above DotnsConstants.WHITELIST_MAX_GRANT_DURATION.

error GrantDurationOutOfRange();

NotRequested

Thrown when a claim is not in the Requested status.

error NotRequested(bytes32 node, address user);

Parameters

NameTypeDescription
nodebytes32Namehash of the label under the active TLD.
useraddressBeneficiary whose claim was expected to be pending.

NotReserved

Thrown when releasing a name that is not reserved.

error NotReserved(bytes32 node);

Parameters

NameTypeDescription
nodebytes32Namehash of the label under the active TLD.

NothingToRevoke

Thrown when revoking a name that is not Claimed and holds no claims.

error NothingToRevoke(bytes32 node);

Parameters

NameTypeDescription
nodebytes32Namehash of the label under the active TLD.

NotGovernance

Thrown when a governance-gated call is not a substrate Root dispatch.

Grant, revoke, accept, reject and reserve are Root-only: no signed account, owner included, can make them.

error NotGovernance();

NotController

Thrown when consume is called by any address other than a registrar controller.

error NotController(address caller);

Parameters

NameTypeDescription
calleraddressRejected caller.

NotWinner

Thrown when consume is called for a name not won by the registrant.

error NotWinner(address registrant, bytes32 node);

Parameters

NameTypeDescription
registrantaddressAddress attempting to register the name.
nodebytes32Namehash of the label under the active TLD.

BadWindow

Thrown when the request window is set with a zero duration.

error BadWindow();

MaintainerWindowOutOfBounds

Thrown when the maintainer lengthens a window beyond WHITELIST_MAINTAINER_MAX_WINDOW from its opening.

error MaintainerWindowOutOfBounds();

WindowClosed

Thrown when a claim is made outside the open window.

error WindowClosed();

TooManyLabels

Thrown when grantNames is passed more than maxGrantBatch labels.

error TooManyLabels();

Structs

Claim

A claim by one beneficiary on one name.

user, status and requestedAt co-locate in one storage slot; submitter takes the next, and the dynamic reason is stored separately.

struct Claim {
    address user;
    ClaimStatus status;
    uint64 requestedAt;
    address submitter;
    string reason;
}

Properties

NameTypeDescription
useraddressBeneficiary the name would bind to if this claim wins.
statusClaimStatusClaim status; see ClaimStatus.
requestedAtuint64Timestamp the claim was made.
submitteraddressAddress that filed the claim, which may differ from the beneficiary.
reasonstringFree-text justification for the claim.

NameView

A name and its resolved state, for review.

struct NameView {
    bytes32 node;
    string label;
    NameStatus status;
    address winner;
}

Properties

NameTypeDescription
nodebytes32Namehash of the label under the active TLD.
labelstringBare label.
statusNameStatusName status; see NameStatus.
winneraddressWinning beneficiary when Claimed, otherwise the zero address.

NameRecord

Stored resolved state of a name.

status, winner and expiresAt are ordered first so the 1-byte enum, the 20-byte address and the 8-byte timestamp share one storage slot; the dynamic label is stored separately. The stored status stays Claimed after a grant expires, until a write on the name clears it. That clearing emits no event: indexers derive expiry from the grant's NameAccepted timestamp and the GrantDurationSet value in force then, or read grantExpiresAt.

struct NameRecord {
    NameStatus status;
    address winner;
    uint64 expiresAt;
    string label;
}

Properties

NameTypeDescription
statusNameStatusName status; see NameStatus.
winneraddressWinning beneficiary when Claimed, otherwise the zero address.
expiresAtuint64Timestamp the grant expires at, fixed when the name became Claimed; zero otherwise, and for a grant recorded before grant expiry was initialised.
labelstringBare label, kept so reserved and claimed names are reviewable.

Enums

NameStatus

Status of a name.

Open is the zero-value default: claimable, not reserved, not won. Reserved is withheld by governance. Claimed has a single winner until the grant expires grantDuration after it was made; every view and gate reads an expired grant as Open.

enum NameStatus {
    Open,
    Reserved,
    Claimed
}

ClaimStatus

Status of a single claim on a name.

None is the zero-value default of an absent claim. Rejected is sticky for the round of claims it was made in: it is kept only when the beneficiary filed the claim themselves, so they cannot re-request until the name is resolved; a claim filed on their behalf is deleted on rejection and does not bind them.

enum ClaimStatus {
    None,
    Requested,
    Rejected
}