PopClassification
Title: PopClassification
The pure dotNS naming rules: a label's base length, its trailing digits, and the PoP tier its base length places it in.
Shared by @custom:contract PopRules, which exposes them through
Every contract that uses these rules compiles them in, so a change to them takes effect in each contract only when that contract is upgraded. Upgrade PopRules and
Notes:
-
function: IPopRules.classifyName and @custom:function IPopRules.isBaseName, and by callers that apply the same rules inside their own call. Calling the library in place of PopRules saves a proxied external call for logic that reads no state. Inputs are the label bytes only; validating the label's shape is the caller's job.
-
contract: DotnsPopController together whenever these rules change.
-
security-contact: admin@parity.io
Functions
baseNameEnd
Index one past name's base name: a device name without its suffix, or the whole
of any other label.
Only a device name has a suffix to remove. The gateway allocates those two digits to
tell apart people who chose the same stem, so removing them recovers what the
candidate actually picked. No such allocation stands behind the digits in an
ordinary label, where they are part of the name: web3 is a four-character word,
not web with a counter.
function baseNameEnd(string calldata name) internal pure returns (uint256 end);
Parameters
| Name | Type | Description |
|---|---|---|
name | string | Domain label. |
Returns
| Name | Type | Description |
|---|---|---|
end | uint256 | Length of the base name. |
countTrailingDigits
Counts trailing digits in a string.
function countTrailingDigits(string calldata label) internal pure returns (uint256 digitCount);
Parameters
| Name | Type | Description |
|---|---|---|
label | string | String to analyse. |
Returns
| Name | Type | Description |
|---|---|---|
digitCount | uint256 | Number of trailing digits. |
classify
Places a label in its PoP tier by base length.
Base lengths <= 5 are governance-reserved, 6-8 require personhood (devicehood for a device name), and 9 or more are open to any caller.
function classify(string calldata name)
internal
pure
returns (IPopRules.PopStatus requirement, string memory message, uint256 baseLength);
Parameters
| Name | Type | Description |
|---|---|---|
name | string | Domain label, already validated as a DNS label or a device name. |
Returns
| Name | Type | Description |
|---|---|---|
requirement | IPopRules.PopStatus | Tier the label requires. |
message | string | Human-readable reason for the tier. |
baseLength | uint256 | Length of the label's base name. |