0x0::composable_nft

Structs

composable_nft::Witness has drop

Witness used to authenticate witness protected endpoints

composable_nft::Key<T> has drop, store

Internal struct for indexing NFTs in NftBagDomain

composable_nft::Node has store

Fields:

Name Type Description
limit u64
order u64

Defines the properties of a child NFT in the context of type-limited composability

composable_nft::Type<T> has store

NFT type domain

Used to mark the NFT as a certain type

composable_nft::Blueprint<T> has store

Fields:

Name Type Description
id object::UID
nodes vec_map::VecMap<type_name::TypeName, composable_nft::Node>

Domain held in the Collection object, blueprinting all the composability between types. It contains a ObjectTable with all the nodes of the composability flattened.

Methods

public fun new_type<T>(): composable_nft::Type<T>

Creates a new Type

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

Registers Type as a domain on the Nft

Panics

Panics if NFT is already marked as the type

public fun new_blueprint<Parent>(
    ctx: &mut tx_context::TxContext,
): composable_nft::Blueprint<Parent>

public fun add_relationship<Parent, Child>(
    blueprint: &mut composable_nft::Blueprint<Parent>,
    limit: u64,
    order: u64,
)

Adds parent child relationship to Blueprint

Panics

Panics if parent child relationship already exists

public fun has_child<Parent>(
    blueprint: &composable_nft::Blueprint<Parent>,
    child_type: &type_name::TypeName,
): bool

Returns whether a parent child relationship exists in the blueprint

public fun borrow_child<Parent>(
    blueprint: &composable_nft::Blueprint<Parent>,
    child_type: &type_name::TypeName,
): &composable_nft::Node

Borrow child node from composability blueprint

Panics

Panics if parent child relationship was not defined on composability blueprint.

public fun add_blueprint_domain<C, W, Parent>(
    witness: &W,
    collection: &mut collection::Collection<C>,
    domain: composable_nft::Blueprint<Parent>,
)

Registers Blueprint on the given Collection

Panics

Panics if Blueprint is already registered on the Collection.

public entry fun compose<C, Parent: store, Child: store>(
    parent_nft: &mut nft::Nft<C>,
    child_nft: nft::Nft<C>,
    collection: &collection::Collection<C>,
)

Compose child NFT into parent NFT

Panics

  • Blueprint<Parent> is not registered as a domain on the parent NFT
  • Parent child relationship is not defined on the composability blueprint
  • Parent or child NFT do not have corresponding Type<Parent> and Type<Child> domains registered
  • Limit of children is exceeded

public fun decompose<C, Parent, Child>(
    parent_nft: &mut nft::Nft<C>,
    child_nft_id: object::ID,
): nft::Nft<C>

Decomposes NFT with given ID from parent NFT

Panics

Panics if there is no NFT with given ID composed

public fun decompose_and_transfer<C, Parent, Child>(
    parent_nft: &mut nft::Nft<C>,
    child_nft_id: object::ID,
    ctx: &mut tx_context::TxContext,
)

Decomposes NFT with given ID from parent NFT and transfers to transaction sender

Panics

Panics if there is no NFT with given ID composed

public fun assert_composable<Parent>(
    blueprint: &composable_nft::Blueprint<Parent>,
    child_type: &type_name::TypeName,
)

Assert that parent and child types are composable

Panics

Panics if parent and child types are not composable.