0x0::attributes

Module of the AttributesDomain

Used to register string attributes on NFTs.

Interoperability functions are delegated to the display_ext module.

Structs

attributes::AttributesDomain has store

Fields:

Name Type Description
map vec_map::VecMap<ascii::String, ascii::String>

Map of attributes

Domain for storing NFT string attributes

Changes are replicated to ComposableUrl domain as URL parameters.

attributes::Witness has drop

Witness used to authenticate witness protected endpoints

Methods

public fun borrow_attributes(
    domain: &attributes::AttributesDomain,
): &vec_map::VecMap<ascii::String, ascii::String>

Borrows underlying attribute map of AttributesDomain

public fun borrow_attributes_mut(
    domain: &mut attributes::AttributesDomain,
): &mut vec_map::VecMap<ascii::String, ascii::String>

Mutably borrows underlying attribute map of AttributesDomain

Endpoint is unprotected as it relies on safetly obtaining a mutable reference to AttributesDomain.

public fun as_url_parameters(
    domain: &attributes::AttributesDomain,
): vector<u8>

Serializes attributes as URL parameters

public fun has_domain<C>(nft: &nft::Nft<C>): bool

Returns whether AttributesDomain is registered on Nft

public fun borrow_domain<C>(nft: &nft::Nft<C>): 
    &attributes::AttributesDomain

Borrows UrlDomain from Nft

Panics

Panics if UrlDomain is not registered on the Nft

public fun borrow_domain_mut<C>(
    _witness: witness::Witness<C>,
    nft: &mut nft::Nft<C>,
): &mut attributes::AttributesDomain

Mutably borrows UrlDomain from Nft

Panics

Panics if UrlDomain is not registered on the Nft

public fun add_domain<C, W>(
    witness: &W,
    nft: &mut nft::Nft<C>,
    map: vec_map::VecMap<ascii::String, ascii::String>,
)

Adds AttributesDomain to Nft

Panics

Panics if AttributesDomain domain already exists

public fun add_domain_delegated<C>(
    witness: witness::Witness<C>,
    nft: &mut nft::Nft<C>,
    map: vec_map::VecMap<ascii::String, ascii::String>,
)

Adds AttributesDomain to Nft

Panics

Panics if AttributesDomain domain already exists

public fun add_empty_domain<C, W>(
    witness: &W,
    nft: &mut nft::Nft<C>,
)

Adds AttributesDomain to Nft

Panics

Panics if AttributesDomain domain already exists

public fun add_empty_domain_delegated<C>(
    witness: witness::Witness<C>,
    nft: &mut nft::Nft<C>,
)

Adds AttributesDomain to Nft

Panics

Panics if AttributesDomain domain already exists

public fun add_domain_from_vec<C, W>(
    witness: &W,
    nft: &mut nft::Nft<C>,
    keys: vector<ascii::String>,
    values: vector<ascii::String>,
)

Adds AttributesDomain to Nft from vector of keys and values

Panics

Panics if AttributesDomain domain already exists or keys and values vectors have different lengths

public fun add_domain_from_vec_delegated<C>(
    witness: witness::Witness<C>,
    nft: &mut nft::Nft<C>,
    keys: vector<ascii::String>,
    values: vector<ascii::String>,
)

Adds AttributesDomain to Nft from vector of keys and values

Panics

Panics if AttributesDomain domain already exists or keys and values vectors have different lengths

public fun assert_attributes<C>(nft: &nft::Nft<C>)

Asserts that AttributesDomain is registered on Nft

Panics

Panics if AttributesDomain is not registered