The NameRecord is a struct that represents a single record in the registry.
Can be replaced by any other data structure due to the way NameRecords are
stored and managed. SuiNS has no direct and permanent dependency on this
module.
- Struct
NameRecord - Function
new - Function
set_data - Function
set_target_address - Function
set_expiration_timestamp_ms - Function
has_expired - Function
has_expired_past_grace_period - Function
data - Function
target_address - Function
nft_id - Function
expiration_timestamp_ms
use 0x0::constants;
use 0x1::option;
use 0x1::string;
use 0x2::clock;
use 0x2::object;
use 0x2::vec_map;
A single record in the registry.
struct NameRecord has copy, drop, store
Fields
-
nft_id: object::ID -
The ID of the
RegistrationNFTassigned to this record.The owner of the corrisponding
RegistrationNFThas the rights to be able to change and adjust thetarget_addressof this domain.It is possible that the ID changes if the record expires and is purchased by someone else.
-
expiration_timestamp_ms: u64 - Timestamp in milliseconds when the record expires.
-
target_address: option::Option<address> - The target address that this domain points to
-
data: vec_map::VecMap<string::String, string::String> - Additional data which may be stored in a record
Create a new NameRecord.
public fun new(nft_id: object::ID, expiration_timestamp_ms: u64): name_record::NameRecord
Set data as a vec_map directly overriding the data set in the registration self. This simplifies the editing flow and gives the user and clients a fine-grained control over custom data.
Here's a meta example of how a PTB would look like:
let record = moveCall('data', [domain_name]);
moveCall('vec_map::insert', [record.data, key, value]);
moveCall('vec_map::remove', [record.data, other_key]);
moveCall('set_data', [domain_name, record.data]);
public fun set_data(self: &mut name_record::NameRecord, data: vec_map::VecMap<string::String, string::String>)
Set the target_address field of the NameRecord.
public fun set_target_address(self: &mut name_record::NameRecord, new_address: option::Option<address>)
public fun set_expiration_timestamp_ms(self: &mut name_record::NameRecord, expiration_timestamp_ms: u64)
Check if the record has expired.
public fun has_expired(self: &name_record::NameRecord, clock: &clock::Clock): bool
Check if the record has expired, taking into account the grace period.
public fun has_expired_past_grace_period(self: &name_record::NameRecord, clock: &clock::Clock): bool
Read the data field from the NameRecord.
public fun data(self: &name_record::NameRecord): &vec_map::VecMap<string::String, string::String>
Read the target_address field from the NameRecord.
public fun target_address(self: &name_record::NameRecord): option::Option<address>
Read the nft_id field from the NameRecord.
public fun nft_id(self: &name_record::NameRecord): object::ID
Read the expiration_timestamp_ms field from the NameRecord.
public fun expiration_timestamp_ms(self: &name_record::NameRecord): u64