Built on top of the registrar contract containing logics for name validation, prevent frontrunning. This is the entry point for registering a new name. The contract also maintains funds collected from name purchases, only address holds the SuiNS Admin NFT can withdraw the funds.
public entry fun make_commitment_and_commit(controller: &mut BaseController, commitment: vector<u8>, ctx: &mut TxContext)
Parameters:
- controller: address of
BaseControllershare object - commitment: commitment bytes
Register for a name requires 2 steps, this is the first step to make commitment to buy a domain. Refer to this sample commitment.cjs to see how to generate commitment. This function is open to everyone.
public entry fun register(controller: &mut BaseController, registrar: &mut BaseRegistrar, registry: &mut Registry, config: &Configuration, label: vector<u8>, owner: address, duration: u64, secret: vector<u8>, payment: &mut Coin<SUI>, ctx: &mut TxContext)
Parameters:
- controller: address of
BaseControllershare object - registrar: address of
BaseRegistrarshare object - registry: address of
Registryshare object - config: address of
Configurationshare object - label: label of domain, e.g.
suins - owner: owner of the domain
- duration: register duration in epoch
- secret: the secret string used to make commitment in the first transaction
- payment: coin object used to pay for the domain registration
Final step to register for a domain, this will add a new record into Registry, mints a new RegistrationNFT NFT representing for the owner of the domain and sends it to owner (anyone holds this NFT can claim for domain ownership).
This function is open to everyone.
Error codes:
- 311: invalid label ~ Name should have between 3 to 63 characters and contain only: lowercase (a-z), numbers (0-9), hyphen (-). A name may not start or end with a hyphen.
- 305: insufficient balance.
- 302: commitment does not exist (make commitment required before calling register).
- 308: domain is not available.
- 206: invalid duration.
Emits the following event:
struct NameRegisteredEvent has copy, drop {
node: String,
label: String,
owner: address,
cost: u64,
expiry: u64,
nft_id: ID,
resolver: address,
}
public entry fun register(controller: &mut BaseController, registrar: &mut BaseRegistrar, registry: &mut Registry, config: &Configuration, label: vector<u8>, owner: address, duration: u64, secret: vector<u8>, resolver: address, payment: &mut Coin<SUI>, ctx: &mut TxContext)
Refers to register function. This function allows registering with custom resolver (does not use default).
public entry fun renew(controller: &mut BaseController, registrar: &mut BaseRegistrar, label: vector<u8>, duration: u64, payment: &mut Coin<SUI>, ctx: &mut TxContext)
Parameters:
- controller: address of
BaseControllershare object - registrar: address of
BaseRegistrarshare object - label: label of domain, e.g.
suins - duration: renew duration in epoch
Renews for a domain. This function is open to everyone even not the owner of the name can call this method but only domain's expiry will be updated; ownership stays as-is. Note: after renewing, the NFT representing for the domain will not be updated (image with expiry date). To be able to update content of the NFT to match with the new expiry date, we will have to limit this fuction to only address holding the NFT.
Error codes:
- 305: insufficient balance.
- 207: domain does not exist.
- 205: domain expired - this method can be called anytime before expired time + grace period (
90epoches).
Emits the following event:
struct NameRenewedEvent has copy, drop {
label: String,
expiry: u64,
}
public entry fun withdraw(_: &AdminCap, controller: &mut BaseController, ctx: &mut TxContext)
Parameters:
- admin_cap: address of
AdminCapowned object - controller: address of
BaseControllershare object
Withdraw registering funds and transfer to caller.
Only callable by the address holds AdminCap NFT.
Error codes:
- 310: no funds to withdraw.
public entry fun set_default_resolver(_: &AdminCap, controller: &mut BaseController, resolver: address)
Parameters:
- admin_cap: address of
AdminCapowned object - controller: address of
BaseControllershare object - resolver: address of new default resolver
Sets default resolver for all registrations.
Only callable by the address holds AdminCap NFT.
Emits the following event:
struct DefaultResolverChangedEvent has copy, drop {
resolver: address,
}