SldRegistrationManager
Git Source (opens in a new tab)
Author: Sam Ward
Inherits: OwnableUpgradeable, ISldRegistrationManager, PaymentManager, HasUsdOracle, HasLabelValidator
Author: hodl.esf.eth
Registration manager for second level domains
State Variables
sldRegistrationHistory
mapping(bytes32 => SldRegistrationDetail) public sldRegistrationHistory;
pricesAtRegistration
mapping(bytes32 => uint80[10]) public pricesAtRegistration;
addressDiscounts
mapping(bytes32 => mapping(address => SldDiscountSettings)) public addressDiscounts;
globalStrategy
IGlobalRegistrationRules public globalStrategy;
sld
IHandshakeSld public sld;
tld
IHandshakeTld public tld;
commitIntent
ICommitIntent public commitIntent;
Functions
constructor
constructor();
init
Initialize the contract
This function is called during contract deployment and sets up the contract's dependencies. It should only be called once.
function init(
IHandshakeTld _tld,
IHandshakeSld _sld,
ICommitIntent _commitIntent,
IPriceOracle _oracle,
ILabelValidator _validator,
IGlobalRegistrationRules _globalRules,
address _payoutWallet,
address _owner
) public initializer;
Parameters
Name | Type | Description |
---|---|---|
_tld | IHandshakeTld | Address of the top level domain contract |
_sld | IHandshakeSld | Address of the second level domain contract |
_commitIntent | ICommitIntent | Address of the commit intent contract |
_oracle | IPriceOracle | Address of the price oracle contract |
_validator | ILabelValidator | Address of the label validator contract |
_globalRules | IGlobalRegistrationRules | Address of the global registration rules contract |
_payoutWallet | address | Address of the wallet for royalties |
_owner | address | Address of the contract owner |
registerSld
Register an eligible Sld. Require to send in the appropriate amount of ethereum
Checks commitIntent, labelValidator, globalStrategy to ensure domain can be registered
function registerSld(
string calldata _label,
bytes32 _secret,
uint256 _registrationLength,
bytes32 _parentNamehash,
address _recipient
) external payable;
Parameters
Name | Type | Description |
---|---|---|
_label | string | selected SLD label. Requires to pass LabelValidator validation |
_secret | bytes32 | This is the secret generated from the commitIntent contract |
_registrationLength | uint256 | Number of days for registration length |
_parentNamehash | bytes32 | bytes32 representation of the top level domain |
_recipient | address | Address that the sld should be sent to. address(0) will send to msg.sender |
setAddressDiscounts
function setAddressDiscounts(
bytes32 _parentNamehash,
address[] calldata _addresses,
SldDiscountSettings[] calldata _discounts
) public;
renewSld
Renew an eligible Sld. Require to send in the appropriate amount of ethereum. Anyone can renew a domain, it doesn't have to be the owner of the SLD.
We check the historic values of what the domain was sold for originally.
function renewSld(string calldata _label, bytes32 _parentNamehash, uint80 _registrationLength) external payable;
Parameters
Name | Type | Description |
---|---|---|
_label | string | selected SLD label. |
_parentNamehash | bytes32 | bytes32 representation of the top level domain |
_registrationLength | uint80 | Number of days for registration length |
canRegister
function canRegister(bytes32 _namehash) private view returns (bool);
updateLabelValidator
Update the label validator contract. This just contains a function that checks the label is acceptable
This should implement the ILabelValidator interface. Can only be run from the contract owner wallet
function updateLabelValidator(ILabelValidator _validator) public onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_validator | ILabelValidator | Address of the label validator. This can be updated in the future if required. |
updatePaymentAddress
Update the handshake payment address that primary funds are sent to
This function can only be run by the contract owner
function updatePaymentAddress(address _addr) public onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_addr | address | Wallet address to set the commission payment for primary sales to |
updatePaymentPercent
Update the handshake payment percent that primary funds are sent to
This function can only be run by the contract owner
function updatePaymentPercent(uint256 _percent) public onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_percent | uint256 | % of primary sales to send to the handshake wallet |
updateGlobalRegistrationStrategy
Update the global registration strategy. As people can implement their own rules per TLD then this is to make sure that base rules cannot be updated by the TLD owners. $1 minimum etc.
This should implement the IGlobalRegistrationRules interface. Can only be run from the contract owner wallet
function updateGlobalRegistrationStrategy(IGlobalRegistrationRules _strategy) public onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_strategy | IGlobalRegistrationRules | Address of the global strategy. This should implement the IGlobalRegistrationRules interface. |
updatePriceOracle
Update the chainlink price oracle.
Probably should never need updating.
function updatePriceOracle(IPriceOracle _oracle) public onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
_oracle | IPriceOracle | Address of the internal price oracle (this proxies to chainlink in current instance) |
getTenYearGuarenteedPricing
When a domain is registered the 10 year pricing is saved to prevent an owner updating their TLD price strategy and then gouging the price for a popular domain.
function getTenYearGuarenteedPricing(bytes32 _sldNamehash) external view returns (uint80[10] memory _history);
Parameters
Name | Type | Description |
---|---|---|
_sldNamehash | bytes32 | bytes32 representation of the SLD |
Returns
Name | Type | Description |
---|---|---|
_history | uint80[10] | An array containing the 10 year prices that were locked in when the domain was first registered |
addRegistrationDetails
function addRegistrationDetails(
bytes32 _namehash,
ISldRegistrationStrategy _strategy,
bytes32 _parentNamehash,
string calldata _label
) private;
getRenewalPrice
When a domain is registered the 10 year pricing is saved. This function will return back the cheapest option for the renewer based on historic prices and the current strategy.
function getRenewalPrice(address _addr, bytes32 _parentNamehash, string calldata _label, uint256 _registrationLength)
public
view
returns (uint256 _price);
Parameters
Name | Type | Description |
---|---|---|
_addr | address | |
_parentNamehash | bytes32 | bytes32 representation of the top level domain |
_label | string | Label of the SLD |
_registrationLength | uint256 | Registration length in days |
Returns
Name | Type | Description |
---|---|---|
_price | uint256 | Returns the price in dollars (18 decimal precision) |
safeCallRegistrationStrategyInAssembly
Calls the specified registration strategy contract and calculates the price used to prevent "gas griefing" attacks as the TLD owner can update the registration strategy
function safeCallRegistrationStrategyInAssembly(address _strategy, bytes memory _data, uint256 _registrationDays)
private
view
returns (uint256 _price);
Parameters
Name | Type | Description |
---|---|---|
_strategy | address | The address of the registration strategy contract |
_data | bytes | The data to pass to the registration strategy contract |
_registrationDays | uint256 | The number of days for which the domain will be registered |
Returns
Name | Type | Description |
---|---|---|
_price | uint256 | The calculated price |
getRegistrationBasePrice
function getRegistrationBasePrice(
address _strategy,
address _addr,
bytes32 _parentNamehash,
string calldata _label,
uint256 _registrationLength,
bool _isRenewal
) public view returns (uint256);
getRegistrationPrice
function getRegistrationPrice(
address _strategy,
address _addr,
bytes32 _parentNamehash,
string calldata _label,
uint256 _registrationLength
) public view returns (uint256);
getCurrentDiscount
function getCurrentDiscount(bytes32 _parentNamehash, address _addr, bool _isRegistration)
private
view
returns (uint256);
getRenewalPricePerDay
Gets the full registration cost and then divides it by the number of days to get the price per day.
function getRenewalPricePerDay(
address _addr,
bytes32 _parentNamehash,
string calldata _label,
uint256 _registrationLength
) public view returns (uint256 _price);
Parameters
Name | Type | Description |
---|---|---|
_addr | address | Address of the owner of the domain. |
_parentNamehash | bytes32 | Namehash of the parent domain. |
_label | string | Label of the domain. |
_registrationLength | uint256 | Length of the registration. |
Returns
Name | Type | Description |
---|---|---|
_price | uint256 | The renewal price per day for the domain. |
getWeiValueOfDollar
function getWeiValueOfDollar() public view returns (uint256);
Events
DiscountSet
event DiscountSet(bytes32 indexed _tokenNamehash, address indexed _claimant, SldDiscountSettings _discount);