This module extends the functionality of the UnprotectedSafe with
an additional feature of restricting deposits into it.
Structs
safe::Safe has store, key
safe::Safe has store, key
Fields:
| Name | Type | Description |
|---|---|---|
id
|
object::UID
|
|
inner
|
unprotected_safe::UnprotectedSafe
|
|
enable_any_deposit
|
bool
|
Enables depositing any collection, bypassing enabled deposits |
collections_with_enabled_deposits
|
vec_set::VecSet<type_name::TypeName>
|
Collections which can be deposited into the |
safe::OwnerCap has store, key
safe::OwnerCap has store, key
Fields:
| Name | Type | Description |
|---|---|---|
id
|
object::UID
|
|
safe
|
object::ID
|
|
inner
|
unprotected_safe::OwnerCap
|
Whoever owns this object can perform some admin actions against the
Safe shared object with the corresponding id.
safe::TransferCap has store, key
safe::TransferCap has store, key
Fields:
| Name | Type | Description |
|---|---|---|
id
|
object::UID
|
|
safe
|
object::ID
|
|
inner
|
unprotected_safe::TransferCap
|
Enables the owner to transfer given NFT out of the Safe.
Methods
public fun new(ctx: &mut tx_context::TxContext):
(safe::Safe, safe::OwnerCap)
public fun new(ctx: &mut tx_context::TxContext):
(safe::Safe, safe::OwnerCap)Creates a new safe.
Enables all deposits by default.
public entry fun create_for_sender(
ctx: &mut tx_context::TxContext,
)
public entry fun create_for_sender(
ctx: &mut tx_context::TxContext,
)Instantiates a new shared object Safe and transfer
OwnerCap to the tx sender.
Enables all deposits by default.
public fun create_safe(ctx: &mut tx_context::TxContext):
safe::OwnerCap
public fun create_safe(ctx: &mut tx_context::TxContext):
safe::OwnerCapCreates a new Safe shared object and returns the
authority capability that grants authority over this safe.
Enables all deposits by default.
public fun create_transfer_cap(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
): safe::TransferCap
public fun create_transfer_cap(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
): safe::TransferCapCreates a TransferCap which must be claimed atomically.
Otherwise, there's a risk of a race condition as multiple non-exclusive transfer caps can be created.
public entry fun create_transfer_cap_for_sender(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun create_transfer_cap_for_sender(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public fun create_exclusive_transfer_cap(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
): safe::TransferCap
public fun create_exclusive_transfer_cap(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
): safe::TransferCapCreates an irrevocable and exclusive transfer cap.
Useful for trading contracts which cannot claim an NFT atomically.
public entry fun create_exclusive_transfer_cap_for_sender(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun create_exclusive_transfer_cap_for_sender(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun restrict_deposits(
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
)
public entry fun restrict_deposits(
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
)Only owner or allowlisted collections can deposit.
public entry fun enable_any_deposit(
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
)
public entry fun enable_any_deposit(
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
)No restriction on deposits.
public entry fun disable_deposits_of_collection<C>(
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
)
public entry fun disable_deposits_of_collection<C>(
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
)The owner can restrict deposits into the Safe from given
collection.
However, if the flag Safe::enable_any_deposit is set to
true, then it takes precedence.
public entry fun enable_deposits_of_collection<C>(
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
)
public entry fun enable_deposits_of_collection<C>(
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
)The owner can enable deposits into the Safe from given
collection.
However, if the flag Safe::enable_any_deposit is set to
true, then it takes precedence anyway.
public entry fun deposit_nft<T>(
nft: nft::Nft<T>,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun deposit_nft<T>(
nft: nft::Nft<T>,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)Transfer an NFT into the Safe.
Requires that enable_any_deposit flag is set to true, or that the
Safe owner enabled NFTs of given collection to be inserted.
public entry fun deposit_generic_nft<T: store + key>(
nft: T,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun deposit_generic_nft<T: store + key>(
nft: T,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)Transfer an NFT into the Safe.
The type T here can refer to any object, not just the NFT protocol's exported NFT type.
public entry fun deposit_nft_privileged<T>(
nft: nft::Nft<T>,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun deposit_nft_privileged<T>(
nft: nft::Nft<T>,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)Transfer an NFT from owner to the Safe.
public entry fun deposit_generic_nft_privileged<T: store + key>(
nft: T,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun deposit_generic_nft_privileged<T: store + key>(
nft: T,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public fun transfer_nft_to_recipient<T, Auth: drop>(
transfer_cap: safe::TransferCap,
recipient: address,
authority: Auth,
allowlist: &transfer_allowlist::Allowlist,
safe: &mut safe::Safe,
)
public fun transfer_nft_to_recipient<T, Auth: drop>(
transfer_cap: safe::TransferCap,
recipient: address,
authority: Auth,
allowlist: &transfer_allowlist::Allowlist,
safe: &mut safe::Safe,
)Use a transfer cap to get an NFT out of the Safe.
If the NFT is not exclusively listed, it can happen that the transfer cap is no longer valid. The NFT could've been traded or the trading cap revoked.
public fun transfer_generic_nft_to_recipient<T: store + key>(
transfer_cap: safe::TransferCap,
recipient: address,
safe: &mut safe::Safe,
)
public fun transfer_generic_nft_to_recipient<T: store + key>(
transfer_cap: safe::TransferCap,
recipient: address,
safe: &mut safe::Safe,
)
public fun transfer_nft_to_safe<T, Auth: drop>(
transfer_cap: safe::TransferCap,
recipient: address,
authority: Auth,
allowlist: &transfer_allowlist::Allowlist,
source: &mut safe::Safe,
target: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public fun transfer_nft_to_safe<T, Auth: drop>(
transfer_cap: safe::TransferCap,
recipient: address,
authority: Auth,
allowlist: &transfer_allowlist::Allowlist,
source: &mut safe::Safe,
target: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)Use a transfer cap to get an NFT out of source Safe and
deposit it to the target Safe. The recipient address should match the
owner of the target Safe.
If the NFT is not exclusively listed, it can happen that the transfer cap is no longer valid. The NFT could've been traded or the trading cap revoked.
public fun transfer_generic_nft_to_safe<T: store + key>(
transfer_cap: safe::TransferCap,
source: &mut safe::Safe,
target: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public fun transfer_generic_nft_to_safe<T: store + key>(
transfer_cap: safe::TransferCap,
source: &mut safe::Safe,
target: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun burn_transfer_cap(
transfer_cap: safe::TransferCap,
safe: &mut safe::Safe,
)
public entry fun burn_transfer_cap(
transfer_cap: safe::TransferCap,
safe: &mut safe::Safe,
)Destroys given transfer cap. This is mainly useful for exclusively listed NFTs.
public entry fun delist_nft(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)
public entry fun delist_nft(
nft: object::ID,
owner_cap: &safe::OwnerCap,
safe: &mut safe::Safe,
ctx: &mut tx_context::TxContext,
)Changes the transfer ref version, thereby invalidating all existing
TransferCap objects.
Can happen only if the NFT is not listed exclusively.
public fun inner(safe: &safe::Safe):
&unprotected_safe::UnprotectedSafe
public fun inner(safe: &safe::Safe):
&unprotected_safe::UnprotectedSafe
public fun borrow_nft<C>(
nft: object::ID,
safe: &safe::Safe,
): &nft::Nft<C>
public fun borrow_nft<C>(
nft: object::ID,
safe: &safe::Safe,
): &nft::Nft<C>
public fun borrow_generic_nft<C: store + key>(
nft: object::ID,
safe: &safe::Safe,
): &C
public fun borrow_generic_nft<C: store + key>(
nft: object::ID,
safe: &safe::Safe,
): &C
public fun has_generic_nft<T: store + key>(
nft: object::ID,
safe: &safe::Safe,
): bool
public fun has_generic_nft<T: store + key>(
nft: object::ID,
safe: &safe::Safe,
): bool
public fun owner_cap_safe(cap: &safe::OwnerCap): object::ID
public fun owner_cap_safe(cap: &safe::OwnerCap): object::ID
public fun transfer_cap_safe(cap: &safe::TransferCap):
object::ID
public fun transfer_cap_safe(cap: &safe::TransferCap):
object::ID
public fun transfer_cap_nft(cap: &safe::TransferCap): object::ID
public fun transfer_cap_nft(cap: &safe::TransferCap): object::ID
public fun transfer_cap_version(cap: &safe::TransferCap):
object::ID
public fun transfer_cap_version(cap: &safe::TransferCap):
object::ID
public fun transfer_cap_is_exclusive(cap: &safe::TransferCap):
bool
public fun transfer_cap_is_exclusive(cap: &safe::TransferCap):
bool
public fun transfer_cap_is_nft_generic(
cap: &safe::TransferCap,
): bool
public fun transfer_cap_is_nft_generic(
cap: &safe::TransferCap,
): bool
public fun transfer_cap_object_type(cap: &safe::TransferCap):
type_name::TypeName
public fun transfer_cap_object_type(cap: &safe::TransferCap):
type_name::TypeName
public fun are_all_deposits_enabled(safe: &safe::Safe): bool
public fun are_all_deposits_enabled(safe: &safe::Safe): bool
public fun assert_owner_cap(
cap: &safe::OwnerCap,
safe: &safe::Safe,
)
public fun assert_owner_cap(
cap: &safe::OwnerCap,
safe: &safe::Safe,
)
public fun assert_transfer_cap_of_safe(
cap: &safe::TransferCap,
safe: &safe::Safe,
)
public fun assert_transfer_cap_of_safe(
cap: &safe::TransferCap,
safe: &safe::Safe,
)
public fun assert_nft_of_transfer_cap(
nft: &object::ID,
cap: &safe::TransferCap,
)
public fun assert_nft_of_transfer_cap(
nft: &object::ID,
cap: &safe::TransferCap,
)
public fun assert_has_nft(nft: &object::ID, safe: &safe::Safe)
public fun assert_has_nft(nft: &object::ID, safe: &safe::Safe)
public fun assert_not_exclusively_listed(
cap: &safe::TransferCap,
)
public fun assert_not_exclusively_listed(
cap: &safe::TransferCap,
)
public fun assert_transfer_cap_exclusive(
cap: &safe::TransferCap,
)
public fun assert_transfer_cap_exclusive(
cap: &safe::TransferCap,
)
public fun assert_transfer_cap_of_native_nft(
cap: &safe::TransferCap,
)
public fun assert_transfer_cap_of_native_nft(
cap: &safe::TransferCap,
)
public fun assert_nft_type<C>(cap: &safe::TransferCap)
public fun assert_nft_type<C>(cap: &safe::TransferCap)Checks that the transfer cap is issued for an NFT of type Nft<C>
public fun assert_generic_nft_type<C>(
cap: &safe::TransferCap,
)
public fun assert_generic_nft_type<C>(
cap: &safe::TransferCap,
)Checks that the transfer cap is issued for an NFT of type C
public fun assert_can_deposit<T>(safe: &safe::Safe)
public fun assert_can_deposit<T>(safe: &safe::Safe)