0x0::composable_svg

Module of ComposableSvgDomain

ComposableSvgDomain does not itself compose NFTs but serves as a display standard provider for NFTs which register SvgDomain and are composed within NftBagDomain.

Structs

composable_svg::ComposableSvgDomain has store

Fields:

Name Type Description
nfts vector<object::ID>

NFTs which are being composed

attributes vec_map::VecMap<ascii::String, ascii::String>

Attributes of root svg tag

svg vector<u8>

Composed SVG data

Domain for providing composed SVG data

composable_svg::Witness has drop

Witness used to authenticate witness protected endpoints

Methods

public fun new(): composable_svg::ComposableSvgDomain

Creates new ComposableSvgDomain with no predefined NFTs

public fun borrow_attributes(
    domain: &composable_svg::ComposableSvgDomain,
): &vec_map::VecMap<ascii::String, ascii::String>

Borrows root tag attributes from ComposableSvgDomain

public fun borrow_nfts(
    domain: &composable_svg::ComposableSvgDomain,
): &vector<object::ID>

Borrows registered NFTs from ComposableSvgDomain

public fun register<C>(
    _witness: witness::Witness<C>,
    parent_nft: &mut nft::Nft<C>,
    child_nft_id: object::ID,
)

Registers NFT whose SVG data should be composed within the final composed SVG

ComposableSvgDomain will not be automatically updated so composable_svg::regenerate must be called.

Panics

  • ComposableSvgDomain doesn't exist
  • NftBagDomain doesn't exist
  • NFT was of a different collection type
  • NFT wasn't composed

public fun deregister<C>(
    _witness: witness::Witness<C>,
    parent_nft: &mut nft::Nft<C>,
    child_nft_id: object::ID,
)

Deregisters NFT whose SVG data is being composed within ComposableSvgDomain

ComposableSvgDomain will not be automatically updated so composable_svg::regenerate must be called.

Panics

  • ComposableSvgDomain doesn't exist
  • NFT wasn't composed

public entry fun regenerate<C>(
    nft: &mut nft::Nft<C>,
)

Regenerates composed SVG data

NFTs which were removed from NftBagDomain or whose SvgDomain was unregistered will be skipped.

Panics

  • ComposableSvgDomain is not registered
  • NftBagDomain is not registered

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

Returns whether SvgDomain is registered on Nft

public fun borrow_domain<C>(nft: &nft::Nft<C>): 
    &composable_svg::ComposableSvgDomain

Borrows SVG data from Nft

Panics

Panics if SvgDomain is not registered on the Nft

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

Adds SvgDomain to Nft

ComposableSvgDomain will not be automatically updated so composable_svg::register and composable_svg::regenerate must be called.

Panics

Panics if SvgDomain domain already exists

public fun assert_composable_svg<C>(
    nft: &nft::Nft<C>,
)

Asserts that ComposableSvgDomain is registered on Nft

Panics

Panics if ComposableSvgDomain is not registered