Utility functions
Structs
Methods
public fun bps(): u16
public fun bps(): u16
public fun assert_same_module_as_witness<T, Witness>()
public fun assert_same_module_as_witness<T, Witness>()
First generic T
is any type, second generic is Witness
.
Witness
is a type always in form "struct Witness has drop {}"
In this method, we check that T
is exported by the same module.
That is both package ID, package name and module name must match.
Additionally, with accordance to the convention above, the second
generic Witness
must be named Witness
as a type.
Example
It's useful to assert that a one-time-witness is exported by the same
contract as Witness
.
That's because one-time-witness is often used as a convention for
initiating e.g. a collection name.
However, it cannot be instantiated outside of the init
function.
Therefore, the collection contract can export Witness
which serves as
an auth token at a later stage.
public fun get_package_module_type<T>():
(string::String, string::String, string::String)
public fun get_package_module_type<T>():
(string::String, string::String, string::String)
public fun from_vec_to_map<K: copy + drop, V: drop>(
keys: vector<K>,
values: vector<V>,
): vec_map::VecMap<K, V>
public fun from_vec_to_map<K: copy + drop, V: drop>(
keys: vector<K>,
values: vector<V>,
): vec_map::VecMap<K, V>
public fun assert_not_nft_protocol_type<T>()
public fun assert_not_nft_protocol_type<T>()
T mustn't be exported by nft-protocol to avoid unexpected bugs
public fun is_nft_protocol_nft_type<T>(): bool
public fun is_nft_protocol_nft_type<T>(): bool
Returns true if T is of type nft_protocol::nft::Nft
public fun nft_protocol_package_id(): string::String
public fun nft_protocol_package_id(): string::String