Skip to content

Latest commit

 

History

History
203 lines (120 loc) · 7.29 KB

File metadata and controls

203 lines (120 loc) · 7.29 KB

Module 0x0::name_record

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

A single record in the registry.

struct NameRecord has copy, drop, store
Fields
nft_id: object::ID
The ID of the RegistrationNFT assigned to this record.

The owner of the corrisponding RegistrationNFT has the rights to be able to change and adjust the target_address of 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

Function new

Create a new NameRecord.

public fun new(nft_id: object::ID, expiration_timestamp_ms: u64): name_record::NameRecord

Function set_data

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]);

Function set_target_address

Set the target_address field of the NameRecord.

public fun set_target_address(self: &mut name_record::NameRecord, new_address: option::Option<address>)

Function set_expiration_timestamp_ms

public fun set_expiration_timestamp_ms(self: &mut name_record::NameRecord, expiration_timestamp_ms: u64)

Function has_expired

Check if the record has expired.

Function has_expired_past_grace_period

Check if the record has expired, taking into account the grace period.

Function data

Read the data field from the NameRecord.

Function target_address

Read the target_address field from the NameRecord.

Function nft_id

Read the nft_id field from the NameRecord.

Function expiration_timestamp_ms

Read the expiration_timestamp_ms field from the NameRecord.