Module of NftBagDomain which is shared across all composable domains
to store the actual NFT objects.
NftBagDomain allows easy checking on which NFTs are composed across
different composability schemes.
Structs
nft_bag::NftBagDomain has store
nft_bag::NftBagDomain has store
Fields:
| Name | Type | Description |
|---|---|---|
id
|
object::UID
|
|
authorities
|
vector<type_name::TypeName>
|
Authorities which are allowed to withdraw NFTs |
nfts
|
vec_map::VecMap<object::ID, u64>
|
NFTs that are currently composed and the index of the authority permitted to decompose it Avoids storage costs of holding |
NftBagDomain object
Methods
public fun new(ctx: &mut tx_context::TxContext):
nft_bag::NftBagDomain
public fun new(ctx: &mut tx_context::TxContext):
nft_bag::NftBagDomainCreates new NftBagDomain
public fun has(
container: &nft_bag::NftBagDomain,
nft_id: object::ID,
): bool
public fun has(
container: &nft_bag::NftBagDomain,
nft_id: object::ID,
): boolReturns whether NFT with given ID is composed within provided
NftBagDomain
public fun borrow<C>(
container: &nft_bag::NftBagDomain,
nft_id: object::ID,
): &nft::Nft<C>
public fun borrow<C>(
container: &nft_bag::NftBagDomain,
nft_id: object::ID,
): &nft::Nft<C>Borrows Nft from NftBagDomain
Panics
Panics if Nft was not composed within the NftBagDomain.
public fun borrow_mut<C>(
container: &mut nft_bag::NftBagDomain,
nft_id: object::ID,
): &mut nft::Nft<C>
public fun borrow_mut<C>(
container: &mut nft_bag::NftBagDomain,
nft_id: object::ID,
): &mut nft::Nft<C>Mutably borrows Nft from NftBagDomain
Panics
Panics if Nft was not composed within the NftBagDomain.
public fun has_domain<C>(nft: &nft::Nft<C>): bool
public fun has_domain<C>(nft: &nft::Nft<C>): boolReturns whether NftBagDomain is registered on Nft
public fun add_domain<C, W: drop>(
witness: &W,
nft: &mut nft::Nft<C>,
ctx: &mut tx_context::TxContext,
)
public fun add_domain<C, W: drop>(
witness: &W,
nft: &mut nft::Nft<C>,
ctx: &mut tx_context::TxContext,
)Register NftBagDomain on Nft
Panics
Panics if NftBagDomain is already registered on the Nft.
public fun borrow_domain<C>(nft: &nft::Nft<C>):
&nft_bag::NftBagDomain
public fun borrow_domain<C>(nft: &nft::Nft<C>):
&nft_bag::NftBagDomainBorrows NftBagDomain from Nft
Panics
Panics if NftBagDomain is not registered on the Nft.
public fun borrow_domain_mut<C>(
nft: &mut nft::Nft<C>,
): &mut nft_bag::NftBagDomain
public fun borrow_domain_mut<C>(
nft: &mut nft::Nft<C>,
): &mut nft_bag::NftBagDomainMutably borrows NftBagDomain from Nft
NftBagDomain is a safe to expose a mutable reference to.
Panics
Panics if NftBagDomain is not registered on the Nft.
public fun borrow_nft<C>(
nft: &nft::Nft<C>,
nft_id: object::ID,
): &nft::Nft<C>
public fun borrow_nft<C>(
nft: &nft::Nft<C>,
nft_id: object::ID,
): &nft::Nft<C>Borrows composed NFT with given ID from Nft
Panics
Panics if NftBagDomain is not registered or NFT is not composed.
public fun borrow_nft_mut<C>(
nft: &mut nft::Nft<C>,
nft_id: object::ID,
): &nft::Nft<C>
public fun borrow_nft_mut<C>(
nft: &mut nft::Nft<C>,
nft_id: object::ID,
): &nft::Nft<C>Mutably borrows composed NFT with given ID from Nft
Panics
Panics if NftBagDomain is not registered or NFT is not composed.
public fun compose<C, Auth: drop>(
_authority: Auth,
domain: &mut nft_bag::NftBagDomain,
child_nft: nft::Nft<C>,
)
public fun compose<C, Auth: drop>(
_authority: Auth,
domain: &mut nft_bag::NftBagDomain,
child_nft: nft::Nft<C>,
)Composes child NFT into NftBagDomain
public fun compose_nft<C, Auth: drop>(
authority: Auth,
parent_nft: &mut nft::Nft<C>,
child_nft: nft::Nft<C>,
)
public fun compose_nft<C, Auth: drop>(
authority: Auth,
parent_nft: &mut nft::Nft<C>,
child_nft: nft::Nft<C>,
)Composes child NFT into parent NFT
Panics
Panics if NftBagDomain is not registered on the parent Nft
public fun decompose<C, Auth: drop>(
_authority: Auth,
domain: &mut nft_bag::NftBagDomain,
child_nft_id: object::ID,
): nft::Nft<C>
public fun decompose<C, Auth: drop>(
_authority: Auth,
domain: &mut nft_bag::NftBagDomain,
child_nft_id: object::ID,
): nft::Nft<C>Decomposes child NFT from NftBagDomain
Panics
Panics if child Nft does not exist.
public fun decompose_nft<C, Auth: drop>(
authority: Auth,
parent_nft: &mut nft::Nft<C>,
child_nft_id: object::ID,
): nft::Nft<C>
public fun decompose_nft<C, Auth: drop>(
authority: Auth,
parent_nft: &mut nft::Nft<C>,
child_nft_id: object::ID,
): nft::Nft<C>Decomposes child NFT from parent NFT
Panics
Panics if NftBagDomain is not registered on the parent Nft
public fun count<Auth>(domain: &nft_bag::NftBagDomain):
u64
public fun count<Auth>(domain: &nft_bag::NftBagDomain):
u64Counts how many NFTs are registered under the given authority
public fun assert_container<C>(nft: &nft::Nft<C>)
public fun assert_container<C>(nft: &nft::Nft<C>)Asserts that NftBagDomain is registered on Nft
Panics
Panics if NftBagDomain is not registered
public fun assert_composed(
container: &nft_bag::NftBagDomain,
nft_id: object::ID,
)
public fun assert_composed(
container: &nft_bag::NftBagDomain,
nft_id: object::ID,
)Assert that NFT with given ID is composed within the NftBagDomain
Panics
Panics if NFT is not composed.