DotnsCostModelRegistry

Git Source

Inherits: Ownable, IDotnsCostModelRegistry

Title: DotNS Cost Model Registry

Keeps every registered cost model addressable by version and tracks the current one.

Holds only pointers, so it stays a plain owner-gated contract. PopRules resolves it once through DotnsConstants.COST_MODEL and prices the current version for fresh reads and a specific version for in-flight registrations.

Note: security-contact: admin@parity.io

State Variables

modelOf

mapping(uint256 version => IDotnsPricing model) public override modelOf

currentVersion

Returns the version currently serving fresh pricing.

uint256 public override currentVersion

Functions

constructor

Sets the owner permitted to register models.

constructor(address owner_) Ownable(owner_);

Parameters

NameTypeDescription
owner_addressAddress that governs the model set.

register

Registers a model and makes it current.

Owner-only. Keys the model by its own version, so a version can be registered once; a repeat triggers @custom:reverts AlreadyRegistered. Moves the current pointer to the new version and emits @custom:emits CostModelRegistered.

function register(IDotnsPricing model) external override onlyOwner;

Parameters

NameTypeDescription
modelIDotnsPricingThe cost model to register.

setCurrentVersion

Points the current version at an already-registered model.

Owner-only. Reverts to a previously registered version without redeploying it, so governance can roll fresh pricing back to an earlier curve. @custom:reverts UnknownVersion when no model is registered for version. Emits @custom:emits CurrentModelSet.

function setCurrentVersion(uint256 version) external override onlyOwner;

Parameters

NameTypeDescription
versionuint256The already-registered version to make current.

current

Returns the current model.

function current() external view override returns (IDotnsPricing model);

Returns

NameTypeDescription
modelIDotnsPricingThe model serving the current version.

priceForBaseLength

Prices a base length at the current version.

function priceForBaseLength(uint256 baseLength)
    external
    view
    override
    returns (uint256 weiPrice);

Parameters

NameTypeDescription
baseLengthuint256Digit-stripped length of the label being priced.

Returns

NameTypeDescription
weiPriceuint256Registration cost in wei at the current version.

priceForBaseLengthAtVersion

Prices a base length at a specific version.

@custom:reverts UnknownVersion when no model is registered for version.

function priceForBaseLengthAtVersion(
    uint256 version,
    uint256 baseLength
)
    external
    view
    override
    returns (uint256 weiPrice);

Parameters

NameTypeDescription
versionuint256The version to price against.
baseLengthuint256Digit-stripped length of the label being priced.

Returns

NameTypeDescription
weiPriceuint256Registration cost in wei at that version.