difftreelog
fix rename sys property to aux property
in: master
7 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1300,9 +1300,9 @@
[[package]]
name = "crossbeam-channel"
-version = "0.5.4"
+version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
+checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
@@ -1321,15 +1321,15 @@
[[package]]
name = "crossbeam-epoch"
-version = "0.9.8"
+version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
+checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d"
dependencies = [
"autocfg",
"cfg-if 1.0.0",
"crossbeam-utils",
- "lazy_static",
"memoffset",
+ "once_cell",
"scopeguard",
]
@@ -1345,12 +1345,12 @@
[[package]]
name = "crossbeam-utils"
-version = "0.8.8"
+version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
+checksum = "8ff1f980957787286a554052d03c7aee98d99cc32e09f6d45f0a814133c87978"
dependencies = [
"cfg-if 1.0.0",
- "lazy_static",
+ "once_cell",
]
[[package]]
@@ -3662,12 +3662,12 @@
[[package]]
name = "indexmap"
-version = "1.8.2"
+version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
+checksum = "6c6392766afd7964e2531940894cffe4bd8d7d17dbc3c1c4857040fd4b33bdb3"
dependencies = [
"autocfg",
- "hashbrown 0.11.2",
+ "hashbrown 0.12.1",
"serde",
]
@@ -11591,7 +11591,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
dependencies = [
- "strum_macros 0.24.1",
+ "strum_macros 0.24.0",
]
[[package]]
@@ -11609,9 +11609,9 @@
[[package]]
name = "strum_macros"
-version = "0.24.1"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9550962e7cf70d9980392878dfaf1dcc3ece024f4cf3bf3c46b978d0bad61d6c"
+checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef"
dependencies = [
"heck 0.4.0",
"proc-macro2",
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -28,7 +28,7 @@
use up_data_structs::{
AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,
mapping::TokenAddressMapping, budget::Budget, Property, PropertyPermission, PropertyKey,
- PropertyKeyPermission, Properties, PropertyScope, TrySetProperty, TokenChild, SysPropertyValue,
+ PropertyKeyPermission, Properties, PropertyScope, TrySetProperty, TokenChild, AuxPropertyValue,
};
use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
use pallet_common::{
@@ -125,15 +125,15 @@
>;
#[pallet::storage]
- #[pallet::getter(fn token_sys_property)]
- pub type TokenSysProperties<T: Config> = StorageNMap<
+ #[pallet::getter(fn token_aux_property)]
+ pub type TokenAuxProperties<T: Config> = StorageNMap<
Key = (
Key<Twox64Concat, CollectionId>,
Key<Twox64Concat, TokenId>,
Key<Twox64Concat, PropertyScope>,
Key<Twox64Concat, PropertyKey>,
),
- Value = SysPropertyValue,
+ Value = AuxPropertyValue,
QueryKind = OptionQuery,
>;
@@ -307,31 +307,31 @@
Ok(())
}
- pub fn try_mutate_token_sys_property<R, E>(
+ pub fn try_mutate_token_aux_property<R, E>(
collection_id: CollectionId,
token_id: TokenId,
scope: PropertyScope,
key: PropertyKey,
- f: impl FnOnce(&mut Option<SysPropertyValue>) -> Result<R, E>,
+ f: impl FnOnce(&mut Option<AuxPropertyValue>) -> Result<R, E>,
) -> Result<R, E> {
- <TokenSysProperties<T>>::try_mutate((collection_id, token_id, scope, key), f)
+ <TokenAuxProperties<T>>::try_mutate((collection_id, token_id, scope, key), f)
}
- pub fn remove_token_sys_property(
+ pub fn remove_token_aux_property(
collection_id: CollectionId,
token_id: TokenId,
scope: PropertyScope,
key: PropertyKey,
) {
- <TokenSysProperties<T>>::remove((collection_id, token_id, scope, key));
+ <TokenAuxProperties<T>>::remove((collection_id, token_id, scope, key));
}
- pub fn iterate_token_sys_properties(
+ pub fn iterate_token_aux_properties(
collection_id: CollectionId,
token_id: TokenId,
scope: PropertyScope,
- ) -> impl Iterator<Item = (PropertyKey, SysPropertyValue)> {
- <TokenSysProperties<T>>::iter_prefix((collection_id, token_id, scope))
+ ) -> impl Iterator<Item = (PropertyKey, AuxPropertyValue)> {
+ <TokenAuxProperties<T>>::iter_prefix((collection_id, token_id, scope))
}
pub fn current_token_id(collection_id: CollectionId) -> TokenId {
@@ -415,7 +415,7 @@
<TokensBurnt<T>>::insert(collection.id, burnt);
<TokenData<T>>::remove((collection.id, token));
<TokenProperties<T>>::remove((collection.id, token));
- <TokenSysProperties<T>>::remove_prefix((collection.id, token), None);
+ <TokenAuxProperties<T>>::remove_prefix((collection.id, token), None);
let old_spender = <Allowance<T>>::take((collection.id, token));
if let Some(old_spender) = old_spender {
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -762,7 +762,7 @@
let resource_id_key = Self::rmrk_property_key(ResourceId(resource_id))?;
- let resource_info = <PalletNft<T>>::token_sys_property((
+ let resource_info = <PalletNft<T>>::token_aux_property((
collection_id,
nft_id,
PropertyScope::Rmrk,
@@ -777,7 +777,7 @@
<Error<T>>::ResourceNotPending
);
- <PalletNft<T>>::remove_token_sys_property(
+ <PalletNft<T>>::remove_token_aux_property(
collection_id,
nft_id,
PropertyScope::Rmrk,
@@ -1194,7 +1194,7 @@
pending_removal: false,
};
- <PalletNft<T>>::try_mutate_token_sys_property(
+ <PalletNft<T>>::try_mutate_token_aux_property(
collection_id,
nft_id,
PropertyScope::Rmrk,
@@ -1223,7 +1223,7 @@
let scope = PropertyScope::Rmrk;
ensure!(
- <PalletNft<T>>::token_sys_property((
+ <PalletNft<T>>::token_aux_property((
collection_id,
nft_id,
scope,
@@ -1239,7 +1239,7 @@
let sender = T::CrossAccountId::from_sub(sender);
if topmost_owner == sender {
- <PalletNft<T>>::remove_token_sys_property(
+ <PalletNft<T>>::remove_token_aux_property(
collection_id,
nft_id,
PropertyScope::Rmrk,
@@ -1262,7 +1262,7 @@
resource_id: RmrkResourceId,
f: impl FnOnce(&mut RmrkResourceInfo) -> DispatchResult,
) -> DispatchResult {
- <PalletNft<T>>::try_mutate_token_sys_property(
+ <PalletNft<T>>::try_mutate_token_aux_property(
collection_id,
nft_id,
PropertyScope::Rmrk,
pallets/proxy-rmrk-core/src/weights.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/weights.rs
+++ b/pallets/proxy-rmrk-core/src/weights.rs
@@ -3,7 +3,7 @@
//! Autogenerated weights for pallet_proxy_rmrk_core
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2022-06-16, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2022-06-17, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
// Executed Command:
@@ -64,7 +64,7 @@
// Storage: Common CollectionById (r:0 w:1)
// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
fn create_collection() -> Weight {
- (42_239_000 as Weight)
+ (42_359_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(8 as Weight))
}
@@ -77,7 +77,7 @@
// Storage: Nonfungible TokensBurnt (r:0 w:1)
// Storage: Common AdminAmount (r:0 w:1)
fn destroy_collection() -> Weight {
- (44_684_000 as Weight)
+ (45_375_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
@@ -85,7 +85,7 @@
// Storage: Common CollectionById (r:1 w:1)
// Storage: Common CollectionProperties (r:1 w:0)
fn change_collection_issuer() -> Weight {
- (22_513_000 as Weight)
+ (22_753_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -95,7 +95,7 @@
// Storage: Nonfungible TokensMinted (r:1 w:0)
// Storage: Nonfungible TokensBurnt (r:1 w:0)
fn lock_collection() -> Weight {
- (23_735_000 as Weight)
+ (24_356_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -107,11 +107,11 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Nonfungible TokenSysProperties (r:2 w:2)
+ // Storage: Nonfungible TokenAuxProperties (r:2 w:2)
fn mint_nft(b: u32, ) -> Weight {
- (45_152_000 as Weight)
+ (44_853_000 as Weight)
// Standard Error: 2_000
- .saturating_add((11_084_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add((10_721_000 as Weight).saturating_mul(b as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
@@ -129,8 +129,8 @@
// Storage: Nonfungible TokenProperties (r:0 w:1)
fn burn_nft(b: u32, ) -> Weight {
(0 as Weight)
- // Standard Error: 1_581_000
- .saturating_add((321_866_000 as Weight).saturating_mul(b as Weight))
+ // Standard Error: 1_590_000
+ .saturating_add((319_825_000 as Weight).saturating_mul(b as Weight))
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
@@ -146,7 +146,7 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn send() -> Weight {
- (72_246_000 as Weight)
+ (72_576_000 as Weight)
.saturating_add(T::DbWeight::get().reads(12 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
@@ -160,7 +160,7 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn accept_nft() -> Weight {
- (81_203_000 as Weight)
+ (79_670_000 as Weight)
.saturating_add(T::DbWeight::get().reads(15 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
@@ -175,7 +175,7 @@
// Storage: Nonfungible Allowance (r:5 w:0)
// Storage: Nonfungible Owned (r:0 w:5)
fn reject_nft() -> Weight {
- (253_117_000 as Weight)
+ (254_989_000 as Weight)
.saturating_add(T::DbWeight::get().reads(29 as Weight))
.saturating_add(T::DbWeight::get().writes(25 as Weight))
}
@@ -185,7 +185,7 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_property() -> Weight {
- (49_653_000 as Weight)
+ (48_651_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -195,7 +195,7 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_priority() -> Weight {
- (47_890_000 as Weight)
+ (47_579_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -204,9 +204,9 @@
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
// Storage: Nonfungible TokenProperties (r:1 w:1)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn add_basic_resource() -> Weight {
- (54_703_000 as Weight)
+ (55_013_000 as Weight)
.saturating_add(T::DbWeight::get().reads(10 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
@@ -215,9 +215,9 @@
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
// Storage: Nonfungible TokenProperties (r:1 w:1)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn add_composable_resource() -> Weight {
- (55_114_000 as Weight)
+ (55_184_000 as Weight)
.saturating_add(T::DbWeight::get().reads(10 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
@@ -226,19 +226,19 @@
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
// Storage: Nonfungible TokenProperties (r:1 w:1)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn add_slot_resource() -> Weight {
- (55_615_000 as Weight)
+ (54_792_000 as Weight)
.saturating_add(T::DbWeight::get().reads(10 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn remove_resource() -> Weight {
- (47_139_000 as Weight)
+ (46_447_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -246,9 +246,9 @@
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn accept_resource() -> Weight {
- (45_535_000 as Weight)
+ (45_096_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -256,9 +256,9 @@
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn accept_resource_removal() -> Weight {
- (46_327_000 as Weight)
+ (45_445_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -275,7 +275,7 @@
// Storage: Common CollectionById (r:0 w:1)
// Storage: RmrkCore UniqueCollectionId (r:0 w:1)
fn create_collection() -> Weight {
- (42_239_000 as Weight)
+ (42_359_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(8 as Weight))
}
@@ -288,7 +288,7 @@
// Storage: Nonfungible TokensBurnt (r:0 w:1)
// Storage: Common AdminAmount (r:0 w:1)
fn destroy_collection() -> Weight {
- (44_684_000 as Weight)
+ (45_375_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
@@ -296,7 +296,7 @@
// Storage: Common CollectionById (r:1 w:1)
// Storage: Common CollectionProperties (r:1 w:0)
fn change_collection_issuer() -> Weight {
- (22_513_000 as Weight)
+ (22_753_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -306,7 +306,7 @@
// Storage: Nonfungible TokensMinted (r:1 w:0)
// Storage: Nonfungible TokensBurnt (r:1 w:0)
fn lock_collection() -> Weight {
- (23_735_000 as Weight)
+ (24_356_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -318,11 +318,11 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:1)
- // Storage: Nonfungible TokenSysProperties (r:2 w:2)
+ // Storage: Nonfungible TokenAuxProperties (r:2 w:2)
fn mint_nft(b: u32, ) -> Weight {
- (45_152_000 as Weight)
+ (44_853_000 as Weight)
// Standard Error: 2_000
- .saturating_add((11_084_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add((10_721_000 as Weight).saturating_mul(b as Weight))
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
@@ -340,8 +340,8 @@
// Storage: Nonfungible TokenProperties (r:0 w:1)
fn burn_nft(b: u32, ) -> Weight {
(0 as Weight)
- // Standard Error: 1_581_000
- .saturating_add((321_866_000 as Weight).saturating_mul(b as Weight))
+ // Standard Error: 1_590_000
+ .saturating_add((319_825_000 as Weight).saturating_mul(b as Weight))
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
@@ -357,7 +357,7 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn send() -> Weight {
- (72_246_000 as Weight)
+ (72_576_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(12 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
@@ -371,7 +371,7 @@
// Storage: Nonfungible TokenChildren (r:0 w:1)
// Storage: Nonfungible Owned (r:0 w:2)
fn accept_nft() -> Weight {
- (81_203_000 as Weight)
+ (79_670_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(15 as Weight))
.saturating_add(RocksDbWeight::get().writes(7 as Weight))
}
@@ -386,7 +386,7 @@
// Storage: Nonfungible Allowance (r:5 w:0)
// Storage: Nonfungible Owned (r:0 w:5)
fn reject_nft() -> Weight {
- (253_117_000 as Weight)
+ (254_989_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(29 as Weight))
.saturating_add(RocksDbWeight::get().writes(25 as Weight))
}
@@ -396,7 +396,7 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_property() -> Weight {
- (49_653_000 as Weight)
+ (48_651_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -406,7 +406,7 @@
// Storage: Nonfungible TokenProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn set_priority() -> Weight {
- (47_890_000 as Weight)
+ (47_579_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -415,9 +415,9 @@
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
// Storage: Nonfungible TokenProperties (r:1 w:1)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn add_basic_resource() -> Weight {
- (54_703_000 as Weight)
+ (55_013_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(10 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
@@ -426,9 +426,9 @@
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
// Storage: Nonfungible TokenProperties (r:1 w:1)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn add_composable_resource() -> Weight {
- (55_114_000 as Weight)
+ (55_184_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(10 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
@@ -437,19 +437,19 @@
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
// Storage: Nonfungible TokenProperties (r:1 w:1)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn add_slot_resource() -> Weight {
- (55_615_000 as Weight)
+ (54_792_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(10 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
// Storage: RmrkCore UniqueCollectionId (r:1 w:0)
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
// Storage: Nonfungible TokenData (r:5 w:0)
fn remove_resource() -> Weight {
- (47_139_000 as Weight)
+ (46_447_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -457,9 +457,9 @@
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn accept_resource() -> Weight {
- (45_535_000 as Weight)
+ (45_096_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -467,9 +467,9 @@
// Storage: Common CollectionProperties (r:1 w:0)
// Storage: Common CollectionById (r:1 w:0)
// Storage: Nonfungible TokenData (r:5 w:0)
- // Storage: Nonfungible TokenSysProperties (r:1 w:1)
+ // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
fn accept_resource_removal() -> Weight {
- (46_327_000 as Weight)
+ (45_445_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
primitives/data-structs/src/lib.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use core::{20 convert::{TryFrom, TryInto},21 fmt,22};23use frame_support::{24 storage::{bounded_btree_map::BoundedBTreeMap, bounded_btree_set::BoundedBTreeSet},25 traits::Get,26 parameter_types,27};2829#[cfg(feature = "serde")]30use serde::{Serialize, Deserialize};3132use sp_core::U256;33use sp_runtime::{ArithmeticError, sp_std::prelude::Vec, Permill};34use codec::{Decode, Encode, EncodeLike, MaxEncodedLen};35use frame_support::{BoundedVec, traits::ConstU32};36use derivative::Derivative;37use scale_info::TypeInfo;3839// RMRK40use rmrk_traits::{41 CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme, ThemeProperty,42 ResourceTypes, BasicResource, ComposableResource, SlotResource,43};44pub use rmrk_traits::{45 primitives::{46 CollectionId as RmrkCollectionId, NftId as RmrkNftId, BaseId as RmrkBaseId,47 PartId as RmrkPartId, ResourceId as RmrkResourceId,48 },49 NftChild as RmrkNftChild, AccountIdOrCollectionNftTuple as RmrkAccountIdOrCollectionNftTuple,50 FixedPart as RmrkFixedPart, SlotPart as RmrkSlotPart, EquippableList as RmrkEquippableList,51};5253mod bounded;54pub mod budget;55pub mod mapping;56mod migration;5758pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;59pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;60pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;6162pub const MAX_TOKEN_OWNERSHIP: u32 = if cfg!(not(feature = "limit-testing")) {63 100_00064} else {65 1066};67pub const COLLECTION_NUMBER_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {68 100_00069} else {70 1071};72pub const CUSTOM_DATA_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {73 204874} else {75 1076};77pub const COLLECTION_ADMINS_LIMIT: u32 = 5;78pub const COLLECTION_TOKEN_LIMIT: u32 = u32::MAX;79pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {80 1_000_00081} else {82 1083};8485// Timeouts for item types in passed blocks86pub const NFT_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;87pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;88pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;8990pub const SPONSOR_APPROVE_TIMEOUT: u32 = 5;9192// Schema limits93pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 8192;94pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;95pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;9697pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;9899pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;100pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;101pub const MAX_TOKEN_PREFIX_LENGTH: u32 = 16;102103pub const MAX_PROPERTY_KEY_LENGTH: u32 = 256;104pub const MAX_PROPERTY_VALUE_LENGTH: u32 = 32768;105pub const MAX_PROPERTIES_PER_ITEM: u32 = 64;106107pub const MAX_SYSTEM_PROPERTY_VALUE_LENGTH: u32 = 2048;108109pub const MAX_COLLECTION_PROPERTIES_SIZE: u32 = 40960;110pub const MAX_TOKEN_PROPERTIES_SIZE: u32 = 32768;111112/// How much items can be created per single113/// create_many call114pub const MAX_ITEMS_PER_BATCH: u32 = 200;115116pub type CustomDataLimit = ConstU32<CUSTOM_DATA_LIMIT>;117118#[derive(119 Encode,120 Decode,121 PartialEq,122 Eq,123 PartialOrd,124 Ord,125 Clone,126 Copy,127 Debug,128 Default,129 TypeInfo,130 MaxEncodedLen,131)]132#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]133pub struct CollectionId(pub u32);134impl EncodeLike<u32> for CollectionId {}135impl EncodeLike<CollectionId> for u32 {}136137#[derive(138 Encode,139 Decode,140 PartialEq,141 Eq,142 PartialOrd,143 Ord,144 Clone,145 Copy,146 Debug,147 Default,148 TypeInfo,149 MaxEncodedLen,150)]151#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]152pub struct TokenId(pub u32);153impl EncodeLike<u32> for TokenId {}154impl EncodeLike<TokenId> for u32 {}155156impl TokenId {157 pub fn try_next(self) -> Result<TokenId, ArithmeticError> {158 self.0159 .checked_add(1)160 .ok_or(ArithmeticError::Overflow)161 .map(Self)162 }163}164165impl From<TokenId> for U256 {166 fn from(t: TokenId) -> Self {167 t.0.into()168 }169}170171impl TryFrom<U256> for TokenId {172 type Error = &'static str;173174 fn try_from(value: U256) -> Result<Self, Self::Error> {175 Ok(TokenId(value.try_into().map_err(|_| "too large token id")?))176 }177}178179#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]180#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]181pub struct TokenData<CrossAccountId> {182 pub properties: Vec<Property>,183 pub owner: Option<CrossAccountId>,184}185186pub struct OverflowError;187impl From<OverflowError> for &'static str {188 fn from(_: OverflowError) -> Self {189 "overflow occured"190 }191}192193pub type DecimalPoints = u8;194195#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]196#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]197pub enum CollectionMode {198 NFT,199 // decimal points200 Fungible(DecimalPoints),201 ReFungible,202}203204impl CollectionMode {205 pub fn id(&self) -> u8 {206 match self {207 CollectionMode::NFT => 1,208 CollectionMode::Fungible(_) => 2,209 CollectionMode::ReFungible => 3,210 }211 }212}213214pub trait SponsoringResolve<AccountId, Call> {215 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;216}217218#[derive(Encode, Decode, Eq, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]219#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]220pub enum AccessMode {221 Normal,222 AllowList,223}224impl Default for AccessMode {225 fn default() -> Self {226 Self::Normal227 }228}229230#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]231#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]232pub enum SchemaVersion {233 ImageURL,234 Unique,235}236impl Default for SchemaVersion {237 fn default() -> Self {238 Self::ImageURL239 }240}241242#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, TypeInfo)]243#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]244pub struct Ownership<AccountId> {245 pub owner: AccountId,246 pub fraction: u128,247}248249#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]250#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]251pub enum SponsorshipState<AccountId> {252 /// The fees are applied to the transaction sender253 Disabled,254 Unconfirmed(AccountId),255 /// Transactions are sponsored by specified account256 Confirmed(AccountId),257}258259impl<AccountId> SponsorshipState<AccountId> {260 pub fn sponsor(&self) -> Option<&AccountId> {261 match self {262 Self::Confirmed(sponsor) => Some(sponsor),263 _ => None,264 }265 }266267 pub fn pending_sponsor(&self) -> Option<&AccountId> {268 match self {269 Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),270 _ => None,271 }272 }273274 pub fn confirmed(&self) -> bool {275 matches!(self, Self::Confirmed(_))276 }277}278279impl<T> Default for SponsorshipState<T> {280 fn default() -> Self {281 Self::Disabled282 }283}284285/// Used in storage286#[struct_versioning::versioned(version = 2, upper)]287#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]288pub struct Collection<AccountId> {289 pub owner: AccountId,290 pub mode: CollectionMode,291 #[version(..2)]292 pub access: AccessMode,293 pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,294 pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,295 pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,296297 #[version(..2)]298 pub mint_mode: bool,299300 #[version(..2)]301 pub offchain_schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,302303 #[version(..2)]304 pub schema_version: SchemaVersion,305 pub sponsorship: SponsorshipState<AccountId>,306307 pub limits: CollectionLimits,308309 #[version(2.., upper(Default::default()))]310 pub permissions: CollectionPermissions,311312 /// Marks that this collection is not "unique", and managed from external.313 #[version(2.., upper(false))]314 pub external_collection: bool,315316 #[version(..2)]317 pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,318319 #[version(..2)]320 pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,321322 #[version(..2)]323 pub meta_update_permission: MetaUpdatePermission,324}325326/// Used in RPC calls327#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]328#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]329pub struct RpcCollection<AccountId> {330 pub owner: AccountId,331 pub mode: CollectionMode,332 pub name: Vec<u16>,333 pub description: Vec<u16>,334 pub token_prefix: Vec<u8>,335 pub sponsorship: SponsorshipState<AccountId>,336 pub limits: CollectionLimits,337 pub permissions: CollectionPermissions,338 pub token_property_permissions: Vec<PropertyKeyPermission>,339 pub properties: Vec<Property>,340 pub read_only: bool,341}342343#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Derivative, MaxEncodedLen)]344#[derivative(Debug, Default(bound = ""))]345pub struct CreateCollectionData<AccountId> {346 #[derivative(Default(value = "CollectionMode::NFT"))]347 pub mode: CollectionMode,348 pub access: Option<AccessMode>,349 pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,350 pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,351 pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,352 pub pending_sponsor: Option<AccountId>,353 pub limits: Option<CollectionLimits>,354 pub permissions: Option<CollectionPermissions>,355 pub token_property_permissions: CollectionPropertiesPermissionsVec,356 pub properties: CollectionPropertiesVec,357}358359pub type CollectionPropertiesPermissionsVec =360 BoundedVec<PropertyKeyPermission, ConstU32<MAX_PROPERTIES_PER_ITEM>>;361362pub type CollectionPropertiesVec = BoundedVec<Property, ConstU32<MAX_PROPERTIES_PER_ITEM>>;363364/// All fields are wrapped in `Option`s, where None means chain default365// When adding/removing fields from this struct - don't forget to also update clamp_limits366#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]367#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]368pub struct CollectionLimits {369 pub account_token_ownership_limit: Option<u32>,370 pub sponsored_data_size: Option<u32>,371372 /// FIXME should we delete this or repurpose it?373 /// None - setVariableMetadata is not sponsored374 /// Some(v) - setVariableMetadata is sponsored375 /// if there is v block between txs376 pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,377 pub token_limit: Option<u32>,378379 // Timeouts for item types in passed blocks380 pub sponsor_transfer_timeout: Option<u32>,381 pub sponsor_approve_timeout: Option<u32>,382 pub owner_can_transfer: Option<bool>,383 pub owner_can_destroy: Option<bool>,384 pub transfers_enabled: Option<bool>,385}386387impl CollectionLimits {388 pub fn account_token_ownership_limit(&self) -> u32 {389 self.account_token_ownership_limit390 .unwrap_or(ACCOUNT_TOKEN_OWNERSHIP_LIMIT)391 .min(MAX_TOKEN_OWNERSHIP)392 }393 pub fn sponsored_data_size(&self) -> u32 {394 self.sponsored_data_size395 .unwrap_or(CUSTOM_DATA_LIMIT)396 .min(CUSTOM_DATA_LIMIT)397 }398 pub fn token_limit(&self) -> u32 {399 self.token_limit400 .unwrap_or(COLLECTION_TOKEN_LIMIT)401 .min(COLLECTION_TOKEN_LIMIT)402 }403 pub fn sponsor_transfer_timeout(&self, default: u32) -> u32 {404 self.sponsor_transfer_timeout405 .unwrap_or(default)406 .min(MAX_SPONSOR_TIMEOUT)407 }408 pub fn sponsor_approve_timeout(&self) -> u32 {409 self.sponsor_approve_timeout410 .unwrap_or(SPONSOR_APPROVE_TIMEOUT)411 .min(MAX_SPONSOR_TIMEOUT)412 }413 pub fn owner_can_transfer(&self) -> bool {414 self.owner_can_transfer.unwrap_or(false)415 }416 pub fn owner_can_transfer_instaled(&self) -> bool {417 self.owner_can_transfer.is_some()418 }419 pub fn owner_can_destroy(&self) -> bool {420 self.owner_can_destroy.unwrap_or(true)421 }422 pub fn transfers_enabled(&self) -> bool {423 self.transfers_enabled.unwrap_or(true)424 }425 pub fn sponsored_data_rate_limit(&self) -> Option<u32> {426 match self427 .sponsored_data_rate_limit428 .unwrap_or(SponsoringRateLimit::SponsoringDisabled)429 {430 SponsoringRateLimit::SponsoringDisabled => None,431 SponsoringRateLimit::Blocks(v) => Some(v.min(MAX_SPONSOR_TIMEOUT)),432 }433 }434}435436// When adding/removing fields from this struct - don't forget to also update clamp_limits437#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]438#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]439pub struct CollectionPermissions {440 pub access: Option<AccessMode>,441 pub mint_mode: Option<bool>,442 pub nesting: Option<NestingPermissions>,443}444445impl CollectionPermissions {446 pub fn access(&self) -> AccessMode {447 self.access.unwrap_or(AccessMode::Normal)448 }449 pub fn mint_mode(&self) -> bool {450 self.mint_mode.unwrap_or(false)451 }452 pub fn nesting(&self) -> &NestingPermissions {453 static DEFAULT: NestingPermissions = NestingPermissions {454 token_owner: false,455 collection_admin: false,456 restricted: None,457458 permissive: false,459 };460 self.nesting.as_ref().unwrap_or(&DEFAULT)461 }462}463464type OwnerRestrictedSetInner = BoundedBTreeSet<CollectionId, ConstU32<16>>;465466#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen, Derivative)]467#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]468#[derivative(Debug)]469pub struct OwnerRestrictedSet(470 #[cfg_attr(feature = "serde1", serde(with = "bounded::set_serde"))]471 #[derivative(Debug(format_with = "bounded::set_debug"))]472 pub OwnerRestrictedSetInner,473);474impl OwnerRestrictedSet {475 pub fn new() -> Self {476 Self(Default::default())477 }478}479impl core::ops::Deref for OwnerRestrictedSet {480 type Target = OwnerRestrictedSetInner;481 fn deref(&self) -> &Self::Target {482 &self.0483 }484}485impl core::ops::DerefMut for OwnerRestrictedSet {486 fn deref_mut(&mut self) -> &mut Self::Target {487 &mut self.0488 }489}490491#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen, Derivative)]492#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]493#[derivative(Debug)]494pub struct NestingPermissions {495 /// Owner of token can nest tokens under it496 pub token_owner: bool,497 /// Admin of token collection can nest tokens under token498 pub collection_admin: bool,499 /// If set - only tokens from specified collections can be nested500 pub restricted: Option<OwnerRestrictedSet>,501502 /// Anyone can nest tokens, mutually exclusive with `token_owner`, `admin`503 pub permissive: bool,504}505506#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]507#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]508pub enum SponsoringRateLimit {509 SponsoringDisabled,510 Blocks(u32),511}512513#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]514#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]515#[derivative(Debug)]516pub struct CreateNftData {517 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]518 #[derivative(Debug(format_with = "bounded::vec_debug"))]519 pub properties: CollectionPropertiesVec,520}521522#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, TypeInfo)]523#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]524pub struct CreateFungibleData {525 pub value: u128,526}527528#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]529#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]530#[derivative(Debug)]531pub struct CreateReFungibleData {532 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]533 #[derivative(Debug(format_with = "bounded::vec_debug"))]534 pub const_data: BoundedVec<u8, CustomDataLimit>,535 pub pieces: u128,536}537538#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]539#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]540pub enum MetaUpdatePermission {541 ItemOwner,542 Admin,543 None,544}545546#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]547#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]548pub enum CreateItemData {549 NFT(CreateNftData),550 Fungible(CreateFungibleData),551 ReFungible(CreateReFungibleData),552}553554#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]555#[derivative(Debug)]556pub struct CreateNftExData<CrossAccountId> {557 #[derivative(Debug(format_with = "bounded::vec_debug"))]558 pub properties: CollectionPropertiesVec,559 pub owner: CrossAccountId,560}561562#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]563#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]564pub struct CreateRefungibleExData<CrossAccountId> {565 #[derivative(Debug(format_with = "bounded::vec_debug"))]566 pub const_data: BoundedVec<u8, CustomDataLimit>,567 #[derivative(Debug(format_with = "bounded::map_debug"))]568 pub users: BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,569}570571#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]572#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]573pub enum CreateItemExData<CrossAccountId> {574 NFT(575 #[derivative(Debug(format_with = "bounded::vec_debug"))]576 BoundedVec<CreateNftExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,577 ),578 Fungible(579 #[derivative(Debug(format_with = "bounded::map_debug"))]580 BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,581 ),582 /// Many tokens, each may have only one owner583 RefungibleMultipleItems(584 #[derivative(Debug(format_with = "bounded::vec_debug"))]585 BoundedVec<CreateRefungibleExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,586 ),587 /// Single token, which may have many owners588 RefungibleMultipleOwners(CreateRefungibleExData<CrossAccountId>),589}590591impl CreateItemData {592 pub fn data_size(&self) -> usize {593 match self {594 CreateItemData::ReFungible(data) => data.const_data.len(),595 _ => 0,596 }597 }598}599600impl From<CreateNftData> for CreateItemData {601 fn from(item: CreateNftData) -> Self {602 CreateItemData::NFT(item)603 }604}605606impl From<CreateReFungibleData> for CreateItemData {607 fn from(item: CreateReFungibleData) -> Self {608 CreateItemData::ReFungible(item)609 }610}611612impl From<CreateFungibleData> for CreateItemData {613 fn from(item: CreateFungibleData) -> Self {614 CreateItemData::Fungible(item)615 }616}617618#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]619#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]620// todo possibly rename to be used generally as an address pair621pub struct TokenChild {622 pub token: TokenId,623 pub collection: CollectionId,624}625626#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]627#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]628pub struct CollectionStats {629 pub created: u32,630 pub destroyed: u32,631 pub alive: u32,632}633634#[derive(Encode, Decode, Clone, Debug)]635#[cfg_attr(feature = "std", derive(PartialEq))]636pub struct PhantomType<T>(core::marker::PhantomData<T>);637638impl<T: TypeInfo + 'static> TypeInfo for PhantomType<T> {639 type Identity = PhantomType<T>;640641 fn type_info() -> scale_info::Type {642 use scale_info::{643 Type, Path,644 build::{FieldsBuilder, UnnamedFields},645 type_params,646 };647 Type::builder()648 .path(Path::new("up_data_structs", "PhantomType"))649 .type_params(type_params!(T))650 .composite(<FieldsBuilder<UnnamedFields>>::default().field(|b| b.ty::<[T; 0]>()))651 }652}653impl<T> MaxEncodedLen for PhantomType<T> {654 fn max_encoded_len() -> usize {655 0656 }657}658659pub type BoundedBytes<S> = BoundedVec<u8, S>;660661pub type SysPropertyValue = BoundedBytes<ConstU32<MAX_SYSTEM_PROPERTY_VALUE_LENGTH>>;662663pub type PropertyKey = BoundedBytes<ConstU32<MAX_PROPERTY_KEY_LENGTH>>;664pub type PropertyValue = BoundedBytes<ConstU32<MAX_PROPERTY_VALUE_LENGTH>>;665666#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]667#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]668pub struct PropertyPermission {669 pub mutable: bool,670 pub collection_admin: bool,671 pub token_owner: bool,672}673674impl PropertyPermission {675 pub fn none() -> Self {676 Self {677 mutable: true,678 collection_admin: false,679 token_owner: false,680 }681 }682}683684#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, MaxEncodedLen)]685#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]686pub struct Property {687 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]688 pub key: PropertyKey,689690 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]691 pub value: PropertyValue,692}693694impl Into<(PropertyKey, PropertyValue)> for Property {695 fn into(self) -> (PropertyKey, PropertyValue) {696 (self.key, self.value)697 }698}699700#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]701#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]702pub struct PropertyKeyPermission {703 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]704 pub key: PropertyKey,705706 pub permission: PropertyPermission,707}708709impl Into<(PropertyKey, PropertyPermission)> for PropertyKeyPermission {710 fn into(self) -> (PropertyKey, PropertyPermission) {711 (self.key, self.permission)712 }713}714715#[derive(Debug)]716pub enum PropertiesError {717 NoSpaceForProperty,718 PropertyLimitReached,719 InvalidCharacterInPropertyKey,720 PropertyKeyIsTooLong,721 EmptyPropertyKey,722}723724#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq, Clone, Copy)]725pub enum PropertyScope {726 None,727 Rmrk,728}729730impl PropertyScope {731 pub fn apply(self, key: PropertyKey) -> Result<PropertyKey, PropertiesError> {732 let scope_str: &[u8] = match self {733 Self::None => return Ok(key),734 Self::Rmrk => b"rmrk",735 };736737 [scope_str, b":", key.as_slice()]738 .concat()739 .try_into()740 .map_err(|_| PropertiesError::PropertyKeyIsTooLong)741 }742}743744pub trait TrySetProperty: Sized {745 type Value;746747 fn try_scoped_set(748 &mut self,749 scope: PropertyScope,750 key: PropertyKey,751 value: Self::Value,752 ) -> Result<(), PropertiesError>;753754 fn try_scoped_set_from_iter<I, KV>(755 &mut self,756 scope: PropertyScope,757 iter: I,758 ) -> Result<(), PropertiesError>759 where760 I: Iterator<Item = KV>,761 KV: Into<(PropertyKey, Self::Value)>,762 {763 for kv in iter {764 let (key, value) = kv.into();765 self.try_scoped_set(scope, key, value)?;766 }767768 Ok(())769 }770771 fn try_set(&mut self, key: PropertyKey, value: Self::Value) -> Result<(), PropertiesError> {772 self.try_scoped_set(PropertyScope::None, key, value)773 }774775 fn try_set_from_iter<I, KV>(&mut self, iter: I) -> Result<(), PropertiesError>776 where777 I: Iterator<Item = KV>,778 KV: Into<(PropertyKey, Self::Value)>,779 {780 self.try_scoped_set_from_iter(PropertyScope::None, iter)781 }782}783784#[derive(Encode, Decode, TypeInfo, Derivative, Clone, PartialEq, MaxEncodedLen)]785#[derivative(Default(bound = ""))]786pub struct PropertiesMap<Value>(787 BoundedBTreeMap<PropertyKey, Value, ConstU32<MAX_PROPERTIES_PER_ITEM>>,788);789790impl<Value> PropertiesMap<Value> {791 pub fn new() -> Self {792 Self(BoundedBTreeMap::new())793 }794795 pub fn remove(&mut self, key: &PropertyKey) -> Result<Option<Value>, PropertiesError> {796 Self::check_property_key(key)?;797798 Ok(self.0.remove(key))799 }800801 pub fn get(&self, key: &PropertyKey) -> Option<&Value> {802 self.0.get(key)803 }804805 pub fn contains_key(&self, key: &PropertyKey) -> bool {806 self.0.contains_key(key)807 }808809 fn check_property_key(key: &PropertyKey) -> Result<(), PropertiesError> {810 if key.is_empty() {811 return Err(PropertiesError::EmptyPropertyKey);812 }813814 for byte in key.as_slice().iter() {815 let byte = *byte;816817 if !byte.is_ascii_alphanumeric() && byte != b'_' && byte != b'-' && byte != b'.' {818 return Err(PropertiesError::InvalidCharacterInPropertyKey);819 }820 }821822 Ok(())823 }824}825826impl<Value> IntoIterator for PropertiesMap<Value> {827 type Item = (PropertyKey, Value);828 type IntoIter = <829 BoundedBTreeMap<830 PropertyKey,831 Value,832 ConstU32<MAX_PROPERTIES_PER_ITEM>833 > as IntoIterator834 >::IntoIter;835836 fn into_iter(self) -> Self::IntoIter {837 self.0.into_iter()838 }839}840841impl<Value> TrySetProperty for PropertiesMap<Value> {842 type Value = Value;843844 fn try_scoped_set(845 &mut self,846 scope: PropertyScope,847 key: PropertyKey,848 value: Self::Value,849 ) -> Result<(), PropertiesError> {850 Self::check_property_key(&key)?;851852 let key = scope.apply(key)?;853 self.0854 .try_insert(key, value)855 .map_err(|_| PropertiesError::PropertyLimitReached)?;856857 Ok(())858 }859}860861pub type PropertiesPermissionMap = PropertiesMap<PropertyPermission>;862863#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, MaxEncodedLen)]864pub struct Properties {865 map: PropertiesMap<PropertyValue>,866 consumed_space: u32,867 space_limit: u32,868}869870impl Properties {871 pub fn new(space_limit: u32) -> Self {872 Self {873 map: PropertiesMap::new(),874 consumed_space: 0,875 space_limit,876 }877 }878879 pub fn remove(&mut self, key: &PropertyKey) -> Result<Option<PropertyValue>, PropertiesError> {880 let value = self.map.remove(key)?;881882 if let Some(ref value) = value {883 let value_len = value.len() as u32;884 self.consumed_space -= value_len;885 }886887 Ok(value)888 }889890 pub fn get(&self, key: &PropertyKey) -> Option<&PropertyValue> {891 self.map.get(key)892 }893}894895impl IntoIterator for Properties {896 type Item = (PropertyKey, PropertyValue);897 type IntoIter = <PropertiesMap<PropertyValue> as IntoIterator>::IntoIter;898899 fn into_iter(self) -> Self::IntoIter {900 self.map.into_iter()901 }902}903904impl TrySetProperty for Properties {905 type Value = PropertyValue;906907 fn try_scoped_set(908 &mut self,909 scope: PropertyScope,910 key: PropertyKey,911 value: Self::Value,912 ) -> Result<(), PropertiesError> {913 let value_len = value.len();914915 if self.consumed_space as usize + value_len > self.space_limit as usize916 && !cfg!(feature = "runtime-benchmarks")917 {918 return Err(PropertiesError::NoSpaceForProperty);919 }920921 self.map.try_scoped_set(scope, key, value)?;922923 self.consumed_space += value_len as u32;924925 Ok(())926 }927}928929pub struct CollectionProperties;930931impl Get<Properties> for CollectionProperties {932 fn get() -> Properties {933 Properties::new(MAX_COLLECTION_PROPERTIES_SIZE)934 }935}936937pub struct TokenProperties;938939impl Get<Properties> for TokenProperties {940 fn get() -> Properties {941 Properties::new(MAX_TOKEN_PROPERTIES_SIZE)942 }943}944945// RMRK946// todo document?947parameter_types! {948 #[derive(PartialEq, TypeInfo)]949 pub const RmrkStringLimit: u32 = 128;950 #[derive(PartialEq)]951 pub const RmrkCollectionSymbolLimit: u32 = MAX_TOKEN_PREFIX_LENGTH;952 #[derive(PartialEq)]953 pub const RmrkResourceSymbolLimit: u32 = 10;954 #[derive(PartialEq)]955 pub const RmrkBaseSymbolLimit: u32 = MAX_TOKEN_PREFIX_LENGTH;956 #[derive(PartialEq)]957 pub const RmrkKeyLimit: u32 = 32;958 #[derive(PartialEq)]959 pub const RmrkValueLimit: u32 = 256;960 #[derive(PartialEq)]961 pub const RmrkMaxCollectionsEquippablePerPart: u32 = 100;962 #[derive(PartialEq)]963 pub const MaxPropertiesPerTheme: u32 = 5;964 #[derive(PartialEq)]965 pub const RmrkPartsLimit: u32 = 25;966 #[derive(PartialEq)]967 pub const RmrkMaxPriorities: u32 = 25;968 #[derive(PartialEq)]969 pub const MaxResourcesOnMint: u32 = 100;970}971972impl From<RmrkCollectionId> for CollectionId {973 fn from(id: RmrkCollectionId) -> Self {974 Self(id)975 }976}977978impl From<RmrkNftId> for TokenId {979 fn from(id: RmrkNftId) -> Self {980 Self(id)981 }982}983984pub type RmrkCollectionInfo<AccountId> =985 CollectionInfo<RmrkString, RmrkCollectionSymbol, AccountId>;986pub type RmrkInstanceInfo<AccountId> = NftInfo<AccountId, Permill, RmrkString>;987pub type RmrkResourceInfo = ResourceInfo<RmrkString, RmrkBoundedParts>;988pub type RmrkPropertyInfo = PropertyInfo<RmrkKeyString, RmrkValueString>;989pub type RmrkBaseInfo<AccountId> = BaseInfo<AccountId, RmrkString>;990pub type RmrkPartType =991 PartType<RmrkString, BoundedVec<RmrkCollectionId, RmrkMaxCollectionsEquippablePerPart>>;992pub type RmrkThemeProperty = ThemeProperty<RmrkString>;993pub type RmrkTheme = Theme<RmrkString, Vec<RmrkThemeProperty>>;994pub type RmrkBoundedTheme = Theme<RmrkString, BoundedVec<RmrkThemeProperty, MaxPropertiesPerTheme>>;995pub type RmrkResourceTypes = ResourceTypes<RmrkString, RmrkBoundedParts>;996997pub type RmrkBasicResource = BasicResource<RmrkString>;998pub type RmrkComposableResource = ComposableResource<RmrkString, RmrkBoundedParts>;999pub type RmrkSlotResource = SlotResource<RmrkString>;10001001pub type RmrkString = BoundedVec<u8, RmrkStringLimit>;1002pub type RmrkCollectionSymbol = BoundedVec<u8, RmrkCollectionSymbolLimit>;1003pub type RmrkBaseSymbol = BoundedVec<u8, RmrkBaseSymbolLimit>;1004pub type RmrkKeyString = BoundedVec<u8, RmrkKeyLimit>;1005pub type RmrkValueString = BoundedVec<u8, RmrkValueLimit>;1006pub type RmrkBoundedResource = BoundedVec<u8, RmrkResourceSymbolLimit>;1007pub type RmrkBoundedParts = BoundedVec<RmrkPartId, RmrkPartsLimit>; // todo make sure it is needed10081009pub type RmrkRpcString = Vec<u8>;1010pub type RmrkThemeName = RmrkRpcString;1011pub type RmrkPropertyKey = RmrkRpcString;1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use core::{20 convert::{TryFrom, TryInto},21 fmt,22};23use frame_support::{24 storage::{bounded_btree_map::BoundedBTreeMap, bounded_btree_set::BoundedBTreeSet},25 traits::Get,26 parameter_types,27};2829#[cfg(feature = "serde")]30use serde::{Serialize, Deserialize};3132use sp_core::U256;33use sp_runtime::{ArithmeticError, sp_std::prelude::Vec, Permill};34use codec::{Decode, Encode, EncodeLike, MaxEncodedLen};35use frame_support::{BoundedVec, traits::ConstU32};36use derivative::Derivative;37use scale_info::TypeInfo;3839// RMRK40use rmrk_traits::{41 CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme, ThemeProperty,42 ResourceTypes, BasicResource, ComposableResource, SlotResource,43};44pub use rmrk_traits::{45 primitives::{46 CollectionId as RmrkCollectionId, NftId as RmrkNftId, BaseId as RmrkBaseId,47 PartId as RmrkPartId, ResourceId as RmrkResourceId,48 },49 NftChild as RmrkNftChild, AccountIdOrCollectionNftTuple as RmrkAccountIdOrCollectionNftTuple,50 FixedPart as RmrkFixedPart, SlotPart as RmrkSlotPart, EquippableList as RmrkEquippableList,51};5253mod bounded;54pub mod budget;55pub mod mapping;56mod migration;5758pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;59pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;60pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;6162pub const MAX_TOKEN_OWNERSHIP: u32 = if cfg!(not(feature = "limit-testing")) {63 100_00064} else {65 1066};67pub const COLLECTION_NUMBER_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {68 100_00069} else {70 1071};72pub const CUSTOM_DATA_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {73 204874} else {75 1076};77pub const COLLECTION_ADMINS_LIMIT: u32 = 5;78pub const COLLECTION_TOKEN_LIMIT: u32 = u32::MAX;79pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {80 1_000_00081} else {82 1083};8485// Timeouts for item types in passed blocks86pub const NFT_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;87pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;88pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;8990pub const SPONSOR_APPROVE_TIMEOUT: u32 = 5;9192// Schema limits93pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 8192;94pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;95pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;9697pub const COLLECTION_FIELD_LIMIT: u32 = CONST_ON_CHAIN_SCHEMA_LIMIT;9899pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;100pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;101pub const MAX_TOKEN_PREFIX_LENGTH: u32 = 16;102103pub const MAX_PROPERTY_KEY_LENGTH: u32 = 256;104pub const MAX_PROPERTY_VALUE_LENGTH: u32 = 32768;105pub const MAX_PROPERTIES_PER_ITEM: u32 = 64;106107pub const MAX_AUX_PROPERTY_VALUE_LENGTH: u32 = 2048;108109pub const MAX_COLLECTION_PROPERTIES_SIZE: u32 = 40960;110pub const MAX_TOKEN_PROPERTIES_SIZE: u32 = 32768;111112/// How much items can be created per single113/// create_many call114pub const MAX_ITEMS_PER_BATCH: u32 = 200;115116pub type CustomDataLimit = ConstU32<CUSTOM_DATA_LIMIT>;117118#[derive(119 Encode,120 Decode,121 PartialEq,122 Eq,123 PartialOrd,124 Ord,125 Clone,126 Copy,127 Debug,128 Default,129 TypeInfo,130 MaxEncodedLen,131)]132#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]133pub struct CollectionId(pub u32);134impl EncodeLike<u32> for CollectionId {}135impl EncodeLike<CollectionId> for u32 {}136137#[derive(138 Encode,139 Decode,140 PartialEq,141 Eq,142 PartialOrd,143 Ord,144 Clone,145 Copy,146 Debug,147 Default,148 TypeInfo,149 MaxEncodedLen,150)]151#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]152pub struct TokenId(pub u32);153impl EncodeLike<u32> for TokenId {}154impl EncodeLike<TokenId> for u32 {}155156impl TokenId {157 pub fn try_next(self) -> Result<TokenId, ArithmeticError> {158 self.0159 .checked_add(1)160 .ok_or(ArithmeticError::Overflow)161 .map(Self)162 }163}164165impl From<TokenId> for U256 {166 fn from(t: TokenId) -> Self {167 t.0.into()168 }169}170171impl TryFrom<U256> for TokenId {172 type Error = &'static str;173174 fn try_from(value: U256) -> Result<Self, Self::Error> {175 Ok(TokenId(value.try_into().map_err(|_| "too large token id")?))176 }177}178179#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]180#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]181pub struct TokenData<CrossAccountId> {182 pub properties: Vec<Property>,183 pub owner: Option<CrossAccountId>,184}185186pub struct OverflowError;187impl From<OverflowError> for &'static str {188 fn from(_: OverflowError) -> Self {189 "overflow occured"190 }191}192193pub type DecimalPoints = u8;194195#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]196#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]197pub enum CollectionMode {198 NFT,199 // decimal points200 Fungible(DecimalPoints),201 ReFungible,202}203204impl CollectionMode {205 pub fn id(&self) -> u8 {206 match self {207 CollectionMode::NFT => 1,208 CollectionMode::Fungible(_) => 2,209 CollectionMode::ReFungible => 3,210 }211 }212}213214pub trait SponsoringResolve<AccountId, Call> {215 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>;216}217218#[derive(Encode, Decode, Eq, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]219#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]220pub enum AccessMode {221 Normal,222 AllowList,223}224impl Default for AccessMode {225 fn default() -> Self {226 Self::Normal227 }228}229230#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]231#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]232pub enum SchemaVersion {233 ImageURL,234 Unique,235}236impl Default for SchemaVersion {237 fn default() -> Self {238 Self::ImageURL239 }240}241242#[derive(Encode, Decode, Default, Debug, Clone, PartialEq, TypeInfo)]243#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]244pub struct Ownership<AccountId> {245 pub owner: AccountId,246 pub fraction: u128,247}248249#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]250#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]251pub enum SponsorshipState<AccountId> {252 /// The fees are applied to the transaction sender253 Disabled,254 Unconfirmed(AccountId),255 /// Transactions are sponsored by specified account256 Confirmed(AccountId),257}258259impl<AccountId> SponsorshipState<AccountId> {260 pub fn sponsor(&self) -> Option<&AccountId> {261 match self {262 Self::Confirmed(sponsor) => Some(sponsor),263 _ => None,264 }265 }266267 pub fn pending_sponsor(&self) -> Option<&AccountId> {268 match self {269 Self::Unconfirmed(sponsor) | Self::Confirmed(sponsor) => Some(sponsor),270 _ => None,271 }272 }273274 pub fn confirmed(&self) -> bool {275 matches!(self, Self::Confirmed(_))276 }277}278279impl<T> Default for SponsorshipState<T> {280 fn default() -> Self {281 Self::Disabled282 }283}284285/// Used in storage286#[struct_versioning::versioned(version = 2, upper)]287#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)]288pub struct Collection<AccountId> {289 pub owner: AccountId,290 pub mode: CollectionMode,291 #[version(..2)]292 pub access: AccessMode,293 pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,294 pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,295 pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,296297 #[version(..2)]298 pub mint_mode: bool,299300 #[version(..2)]301 pub offchain_schema: BoundedVec<u8, ConstU32<OFFCHAIN_SCHEMA_LIMIT>>,302303 #[version(..2)]304 pub schema_version: SchemaVersion,305 pub sponsorship: SponsorshipState<AccountId>,306307 pub limits: CollectionLimits,308309 #[version(2.., upper(Default::default()))]310 pub permissions: CollectionPermissions,311312 /// Marks that this collection is not "unique", and managed from external.313 #[version(2.., upper(false))]314 pub external_collection: bool,315316 #[version(..2)]317 pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,318319 #[version(..2)]320 pub const_on_chain_schema: BoundedVec<u8, ConstU32<CONST_ON_CHAIN_SCHEMA_LIMIT>>,321322 #[version(..2)]323 pub meta_update_permission: MetaUpdatePermission,324}325326/// Used in RPC calls327#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]328#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]329pub struct RpcCollection<AccountId> {330 pub owner: AccountId,331 pub mode: CollectionMode,332 pub name: Vec<u16>,333 pub description: Vec<u16>,334 pub token_prefix: Vec<u8>,335 pub sponsorship: SponsorshipState<AccountId>,336 pub limits: CollectionLimits,337 pub permissions: CollectionPermissions,338 pub token_property_permissions: Vec<PropertyKeyPermission>,339 pub properties: Vec<Property>,340 pub read_only: bool,341}342343#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Derivative, MaxEncodedLen)]344#[derivative(Debug, Default(bound = ""))]345pub struct CreateCollectionData<AccountId> {346 #[derivative(Default(value = "CollectionMode::NFT"))]347 pub mode: CollectionMode,348 pub access: Option<AccessMode>,349 pub name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,350 pub description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,351 pub token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,352 pub pending_sponsor: Option<AccountId>,353 pub limits: Option<CollectionLimits>,354 pub permissions: Option<CollectionPermissions>,355 pub token_property_permissions: CollectionPropertiesPermissionsVec,356 pub properties: CollectionPropertiesVec,357}358359pub type CollectionPropertiesPermissionsVec =360 BoundedVec<PropertyKeyPermission, ConstU32<MAX_PROPERTIES_PER_ITEM>>;361362pub type CollectionPropertiesVec = BoundedVec<Property, ConstU32<MAX_PROPERTIES_PER_ITEM>>;363364/// All fields are wrapped in `Option`s, where None means chain default365// When adding/removing fields from this struct - don't forget to also update clamp_limits366#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]367#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]368pub struct CollectionLimits {369 pub account_token_ownership_limit: Option<u32>,370 pub sponsored_data_size: Option<u32>,371372 /// FIXME should we delete this or repurpose it?373 /// None - setVariableMetadata is not sponsored374 /// Some(v) - setVariableMetadata is sponsored375 /// if there is v block between txs376 pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,377 pub token_limit: Option<u32>,378379 // Timeouts for item types in passed blocks380 pub sponsor_transfer_timeout: Option<u32>,381 pub sponsor_approve_timeout: Option<u32>,382 pub owner_can_transfer: Option<bool>,383 pub owner_can_destroy: Option<bool>,384 pub transfers_enabled: Option<bool>,385}386387impl CollectionLimits {388 pub fn account_token_ownership_limit(&self) -> u32 {389 self.account_token_ownership_limit390 .unwrap_or(ACCOUNT_TOKEN_OWNERSHIP_LIMIT)391 .min(MAX_TOKEN_OWNERSHIP)392 }393 pub fn sponsored_data_size(&self) -> u32 {394 self.sponsored_data_size395 .unwrap_or(CUSTOM_DATA_LIMIT)396 .min(CUSTOM_DATA_LIMIT)397 }398 pub fn token_limit(&self) -> u32 {399 self.token_limit400 .unwrap_or(COLLECTION_TOKEN_LIMIT)401 .min(COLLECTION_TOKEN_LIMIT)402 }403 pub fn sponsor_transfer_timeout(&self, default: u32) -> u32 {404 self.sponsor_transfer_timeout405 .unwrap_or(default)406 .min(MAX_SPONSOR_TIMEOUT)407 }408 pub fn sponsor_approve_timeout(&self) -> u32 {409 self.sponsor_approve_timeout410 .unwrap_or(SPONSOR_APPROVE_TIMEOUT)411 .min(MAX_SPONSOR_TIMEOUT)412 }413 pub fn owner_can_transfer(&self) -> bool {414 self.owner_can_transfer.unwrap_or(false)415 }416 pub fn owner_can_transfer_instaled(&self) -> bool {417 self.owner_can_transfer.is_some()418 }419 pub fn owner_can_destroy(&self) -> bool {420 self.owner_can_destroy.unwrap_or(true)421 }422 pub fn transfers_enabled(&self) -> bool {423 self.transfers_enabled.unwrap_or(true)424 }425 pub fn sponsored_data_rate_limit(&self) -> Option<u32> {426 match self427 .sponsored_data_rate_limit428 .unwrap_or(SponsoringRateLimit::SponsoringDisabled)429 {430 SponsoringRateLimit::SponsoringDisabled => None,431 SponsoringRateLimit::Blocks(v) => Some(v.min(MAX_SPONSOR_TIMEOUT)),432 }433 }434}435436// When adding/removing fields from this struct - don't forget to also update clamp_limits437#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]438#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]439pub struct CollectionPermissions {440 pub access: Option<AccessMode>,441 pub mint_mode: Option<bool>,442 pub nesting: Option<NestingPermissions>,443}444445impl CollectionPermissions {446 pub fn access(&self) -> AccessMode {447 self.access.unwrap_or(AccessMode::Normal)448 }449 pub fn mint_mode(&self) -> bool {450 self.mint_mode.unwrap_or(false)451 }452 pub fn nesting(&self) -> &NestingPermissions {453 static DEFAULT: NestingPermissions = NestingPermissions {454 token_owner: false,455 collection_admin: false,456 restricted: None,457458 permissive: false,459 };460 self.nesting.as_ref().unwrap_or(&DEFAULT)461 }462}463464type OwnerRestrictedSetInner = BoundedBTreeSet<CollectionId, ConstU32<16>>;465466#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen, Derivative)]467#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]468#[derivative(Debug)]469pub struct OwnerRestrictedSet(470 #[cfg_attr(feature = "serde1", serde(with = "bounded::set_serde"))]471 #[derivative(Debug(format_with = "bounded::set_debug"))]472 pub OwnerRestrictedSetInner,473);474impl OwnerRestrictedSet {475 pub fn new() -> Self {476 Self(Default::default())477 }478}479impl core::ops::Deref for OwnerRestrictedSet {480 type Target = OwnerRestrictedSetInner;481 fn deref(&self) -> &Self::Target {482 &self.0483 }484}485impl core::ops::DerefMut for OwnerRestrictedSet {486 fn deref_mut(&mut self) -> &mut Self::Target {487 &mut self.0488 }489}490491#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen, Derivative)]492#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]493#[derivative(Debug)]494pub struct NestingPermissions {495 /// Owner of token can nest tokens under it496 pub token_owner: bool,497 /// Admin of token collection can nest tokens under token498 pub collection_admin: bool,499 /// If set - only tokens from specified collections can be nested500 pub restricted: Option<OwnerRestrictedSet>,501502 /// Anyone can nest tokens, mutually exclusive with `token_owner`, `admin`503 pub permissive: bool,504}505506#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]507#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]508pub enum SponsoringRateLimit {509 SponsoringDisabled,510 Blocks(u32),511}512513#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]514#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]515#[derivative(Debug)]516pub struct CreateNftData {517 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]518 #[derivative(Debug(format_with = "bounded::vec_debug"))]519 pub properties: CollectionPropertiesVec,520}521522#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, TypeInfo)]523#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]524pub struct CreateFungibleData {525 pub value: u128,526}527528#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]529#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]530#[derivative(Debug)]531pub struct CreateReFungibleData {532 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]533 #[derivative(Debug(format_with = "bounded::vec_debug"))]534 pub const_data: BoundedVec<u8, CustomDataLimit>,535 pub pieces: u128,536}537538#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo, MaxEncodedLen)]539#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]540pub enum MetaUpdatePermission {541 ItemOwner,542 Admin,543 None,544}545546#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]547#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]548pub enum CreateItemData {549 NFT(CreateNftData),550 Fungible(CreateFungibleData),551 ReFungible(CreateReFungibleData),552}553554#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]555#[derivative(Debug)]556pub struct CreateNftExData<CrossAccountId> {557 #[derivative(Debug(format_with = "bounded::vec_debug"))]558 pub properties: CollectionPropertiesVec,559 pub owner: CrossAccountId,560}561562#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]563#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]564pub struct CreateRefungibleExData<CrossAccountId> {565 #[derivative(Debug(format_with = "bounded::vec_debug"))]566 pub const_data: BoundedVec<u8, CustomDataLimit>,567 #[derivative(Debug(format_with = "bounded::map_debug"))]568 pub users: BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,569}570571#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]572#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]573pub enum CreateItemExData<CrossAccountId> {574 NFT(575 #[derivative(Debug(format_with = "bounded::vec_debug"))]576 BoundedVec<CreateNftExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,577 ),578 Fungible(579 #[derivative(Debug(format_with = "bounded::map_debug"))]580 BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,581 ),582 /// Many tokens, each may have only one owner583 RefungibleMultipleItems(584 #[derivative(Debug(format_with = "bounded::vec_debug"))]585 BoundedVec<CreateRefungibleExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,586 ),587 /// Single token, which may have many owners588 RefungibleMultipleOwners(CreateRefungibleExData<CrossAccountId>),589}590591impl CreateItemData {592 pub fn data_size(&self) -> usize {593 match self {594 CreateItemData::ReFungible(data) => data.const_data.len(),595 _ => 0,596 }597 }598}599600impl From<CreateNftData> for CreateItemData {601 fn from(item: CreateNftData) -> Self {602 CreateItemData::NFT(item)603 }604}605606impl From<CreateReFungibleData> for CreateItemData {607 fn from(item: CreateReFungibleData) -> Self {608 CreateItemData::ReFungible(item)609 }610}611612impl From<CreateFungibleData> for CreateItemData {613 fn from(item: CreateFungibleData) -> Self {614 CreateItemData::Fungible(item)615 }616}617618#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]619#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]620// todo possibly rename to be used generally as an address pair621pub struct TokenChild {622 pub token: TokenId,623 pub collection: CollectionId,624}625626#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]627#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]628pub struct CollectionStats {629 pub created: u32,630 pub destroyed: u32,631 pub alive: u32,632}633634#[derive(Encode, Decode, Clone, Debug)]635#[cfg_attr(feature = "std", derive(PartialEq))]636pub struct PhantomType<T>(core::marker::PhantomData<T>);637638impl<T: TypeInfo + 'static> TypeInfo for PhantomType<T> {639 type Identity = PhantomType<T>;640641 fn type_info() -> scale_info::Type {642 use scale_info::{643 Type, Path,644 build::{FieldsBuilder, UnnamedFields},645 type_params,646 };647 Type::builder()648 .path(Path::new("up_data_structs", "PhantomType"))649 .type_params(type_params!(T))650 .composite(<FieldsBuilder<UnnamedFields>>::default().field(|b| b.ty::<[T; 0]>()))651 }652}653impl<T> MaxEncodedLen for PhantomType<T> {654 fn max_encoded_len() -> usize {655 0656 }657}658659pub type BoundedBytes<S> = BoundedVec<u8, S>;660661pub type AuxPropertyValue = BoundedBytes<ConstU32<MAX_AUX_PROPERTY_VALUE_LENGTH>>;662663pub type PropertyKey = BoundedBytes<ConstU32<MAX_PROPERTY_KEY_LENGTH>>;664pub type PropertyValue = BoundedBytes<ConstU32<MAX_PROPERTY_VALUE_LENGTH>>;665666#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]667#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]668pub struct PropertyPermission {669 pub mutable: bool,670 pub collection_admin: bool,671 pub token_owner: bool,672}673674impl PropertyPermission {675 pub fn none() -> Self {676 Self {677 mutable: true,678 collection_admin: false,679 token_owner: false,680 }681 }682}683684#[derive(Encode, Decode, Debug, TypeInfo, Clone, PartialEq, MaxEncodedLen)]685#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]686pub struct Property {687 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]688 pub key: PropertyKey,689690 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]691 pub value: PropertyValue,692}693694impl Into<(PropertyKey, PropertyValue)> for Property {695 fn into(self) -> (PropertyKey, PropertyValue) {696 (self.key, self.value)697 }698}699700#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]701#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]702pub struct PropertyKeyPermission {703 #[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]704 pub key: PropertyKey,705706 pub permission: PropertyPermission,707}708709impl Into<(PropertyKey, PropertyPermission)> for PropertyKeyPermission {710 fn into(self) -> (PropertyKey, PropertyPermission) {711 (self.key, self.permission)712 }713}714715#[derive(Debug)]716pub enum PropertiesError {717 NoSpaceForProperty,718 PropertyLimitReached,719 InvalidCharacterInPropertyKey,720 PropertyKeyIsTooLong,721 EmptyPropertyKey,722}723724#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq, Clone, Copy)]725pub enum PropertyScope {726 None,727 Rmrk,728}729730impl PropertyScope {731 pub fn apply(self, key: PropertyKey) -> Result<PropertyKey, PropertiesError> {732 let scope_str: &[u8] = match self {733 Self::None => return Ok(key),734 Self::Rmrk => b"rmrk",735 };736737 [scope_str, b":", key.as_slice()]738 .concat()739 .try_into()740 .map_err(|_| PropertiesError::PropertyKeyIsTooLong)741 }742}743744pub trait TrySetProperty: Sized {745 type Value;746747 fn try_scoped_set(748 &mut self,749 scope: PropertyScope,750 key: PropertyKey,751 value: Self::Value,752 ) -> Result<(), PropertiesError>;753754 fn try_scoped_set_from_iter<I, KV>(755 &mut self,756 scope: PropertyScope,757 iter: I,758 ) -> Result<(), PropertiesError>759 where760 I: Iterator<Item = KV>,761 KV: Into<(PropertyKey, Self::Value)>,762 {763 for kv in iter {764 let (key, value) = kv.into();765 self.try_scoped_set(scope, key, value)?;766 }767768 Ok(())769 }770771 fn try_set(&mut self, key: PropertyKey, value: Self::Value) -> Result<(), PropertiesError> {772 self.try_scoped_set(PropertyScope::None, key, value)773 }774775 fn try_set_from_iter<I, KV>(&mut self, iter: I) -> Result<(), PropertiesError>776 where777 I: Iterator<Item = KV>,778 KV: Into<(PropertyKey, Self::Value)>,779 {780 self.try_scoped_set_from_iter(PropertyScope::None, iter)781 }782}783784#[derive(Encode, Decode, TypeInfo, Derivative, Clone, PartialEq, MaxEncodedLen)]785#[derivative(Default(bound = ""))]786pub struct PropertiesMap<Value>(787 BoundedBTreeMap<PropertyKey, Value, ConstU32<MAX_PROPERTIES_PER_ITEM>>,788);789790impl<Value> PropertiesMap<Value> {791 pub fn new() -> Self {792 Self(BoundedBTreeMap::new())793 }794795 pub fn remove(&mut self, key: &PropertyKey) -> Result<Option<Value>, PropertiesError> {796 Self::check_property_key(key)?;797798 Ok(self.0.remove(key))799 }800801 pub fn get(&self, key: &PropertyKey) -> Option<&Value> {802 self.0.get(key)803 }804805 pub fn contains_key(&self, key: &PropertyKey) -> bool {806 self.0.contains_key(key)807 }808809 fn check_property_key(key: &PropertyKey) -> Result<(), PropertiesError> {810 if key.is_empty() {811 return Err(PropertiesError::EmptyPropertyKey);812 }813814 for byte in key.as_slice().iter() {815 let byte = *byte;816817 if !byte.is_ascii_alphanumeric() && byte != b'_' && byte != b'-' && byte != b'.' {818 return Err(PropertiesError::InvalidCharacterInPropertyKey);819 }820 }821822 Ok(())823 }824}825826impl<Value> IntoIterator for PropertiesMap<Value> {827 type Item = (PropertyKey, Value);828 type IntoIter = <829 BoundedBTreeMap<830 PropertyKey,831 Value,832 ConstU32<MAX_PROPERTIES_PER_ITEM>833 > as IntoIterator834 >::IntoIter;835836 fn into_iter(self) -> Self::IntoIter {837 self.0.into_iter()838 }839}840841impl<Value> TrySetProperty for PropertiesMap<Value> {842 type Value = Value;843844 fn try_scoped_set(845 &mut self,846 scope: PropertyScope,847 key: PropertyKey,848 value: Self::Value,849 ) -> Result<(), PropertiesError> {850 Self::check_property_key(&key)?;851852 let key = scope.apply(key)?;853 self.0854 .try_insert(key, value)855 .map_err(|_| PropertiesError::PropertyLimitReached)?;856857 Ok(())858 }859}860861pub type PropertiesPermissionMap = PropertiesMap<PropertyPermission>;862863#[derive(Encode, Decode, TypeInfo, Clone, PartialEq, MaxEncodedLen)]864pub struct Properties {865 map: PropertiesMap<PropertyValue>,866 consumed_space: u32,867 space_limit: u32,868}869870impl Properties {871 pub fn new(space_limit: u32) -> Self {872 Self {873 map: PropertiesMap::new(),874 consumed_space: 0,875 space_limit,876 }877 }878879 pub fn remove(&mut self, key: &PropertyKey) -> Result<Option<PropertyValue>, PropertiesError> {880 let value = self.map.remove(key)?;881882 if let Some(ref value) = value {883 let value_len = value.len() as u32;884 self.consumed_space -= value_len;885 }886887 Ok(value)888 }889890 pub fn get(&self, key: &PropertyKey) -> Option<&PropertyValue> {891 self.map.get(key)892 }893}894895impl IntoIterator for Properties {896 type Item = (PropertyKey, PropertyValue);897 type IntoIter = <PropertiesMap<PropertyValue> as IntoIterator>::IntoIter;898899 fn into_iter(self) -> Self::IntoIter {900 self.map.into_iter()901 }902}903904impl TrySetProperty for Properties {905 type Value = PropertyValue;906907 fn try_scoped_set(908 &mut self,909 scope: PropertyScope,910 key: PropertyKey,911 value: Self::Value,912 ) -> Result<(), PropertiesError> {913 let value_len = value.len();914915 if self.consumed_space as usize + value_len > self.space_limit as usize916 && !cfg!(feature = "runtime-benchmarks")917 {918 return Err(PropertiesError::NoSpaceForProperty);919 }920921 self.map.try_scoped_set(scope, key, value)?;922923 self.consumed_space += value_len as u32;924925 Ok(())926 }927}928929pub struct CollectionProperties;930931impl Get<Properties> for CollectionProperties {932 fn get() -> Properties {933 Properties::new(MAX_COLLECTION_PROPERTIES_SIZE)934 }935}936937pub struct TokenProperties;938939impl Get<Properties> for TokenProperties {940 fn get() -> Properties {941 Properties::new(MAX_TOKEN_PROPERTIES_SIZE)942 }943}944945// RMRK946// todo document?947parameter_types! {948 #[derive(PartialEq, TypeInfo)]949 pub const RmrkStringLimit: u32 = 128;950 #[derive(PartialEq)]951 pub const RmrkCollectionSymbolLimit: u32 = MAX_TOKEN_PREFIX_LENGTH;952 #[derive(PartialEq)]953 pub const RmrkResourceSymbolLimit: u32 = 10;954 #[derive(PartialEq)]955 pub const RmrkBaseSymbolLimit: u32 = MAX_TOKEN_PREFIX_LENGTH;956 #[derive(PartialEq)]957 pub const RmrkKeyLimit: u32 = 32;958 #[derive(PartialEq)]959 pub const RmrkValueLimit: u32 = 256;960 #[derive(PartialEq)]961 pub const RmrkMaxCollectionsEquippablePerPart: u32 = 100;962 #[derive(PartialEq)]963 pub const MaxPropertiesPerTheme: u32 = 5;964 #[derive(PartialEq)]965 pub const RmrkPartsLimit: u32 = 25;966 #[derive(PartialEq)]967 pub const RmrkMaxPriorities: u32 = 25;968 #[derive(PartialEq)]969 pub const MaxResourcesOnMint: u32 = 100;970}971972impl From<RmrkCollectionId> for CollectionId {973 fn from(id: RmrkCollectionId) -> Self {974 Self(id)975 }976}977978impl From<RmrkNftId> for TokenId {979 fn from(id: RmrkNftId) -> Self {980 Self(id)981 }982}983984pub type RmrkCollectionInfo<AccountId> =985 CollectionInfo<RmrkString, RmrkCollectionSymbol, AccountId>;986pub type RmrkInstanceInfo<AccountId> = NftInfo<AccountId, Permill, RmrkString>;987pub type RmrkResourceInfo = ResourceInfo<RmrkString, RmrkBoundedParts>;988pub type RmrkPropertyInfo = PropertyInfo<RmrkKeyString, RmrkValueString>;989pub type RmrkBaseInfo<AccountId> = BaseInfo<AccountId, RmrkString>;990pub type RmrkPartType =991 PartType<RmrkString, BoundedVec<RmrkCollectionId, RmrkMaxCollectionsEquippablePerPart>>;992pub type RmrkThemeProperty = ThemeProperty<RmrkString>;993pub type RmrkTheme = Theme<RmrkString, Vec<RmrkThemeProperty>>;994pub type RmrkBoundedTheme = Theme<RmrkString, BoundedVec<RmrkThemeProperty, MaxPropertiesPerTheme>>;995pub type RmrkResourceTypes = ResourceTypes<RmrkString, RmrkBoundedParts>;996997pub type RmrkBasicResource = BasicResource<RmrkString>;998pub type RmrkComposableResource = ComposableResource<RmrkString, RmrkBoundedParts>;999pub type RmrkSlotResource = SlotResource<RmrkString>;10001001pub type RmrkString = BoundedVec<u8, RmrkStringLimit>;1002pub type RmrkCollectionSymbol = BoundedVec<u8, RmrkCollectionSymbolLimit>;1003pub type RmrkBaseSymbol = BoundedVec<u8, RmrkBaseSymbolLimit>;1004pub type RmrkKeyString = BoundedVec<u8, RmrkKeyLimit>;1005pub type RmrkValueString = BoundedVec<u8, RmrkValueLimit>;1006pub type RmrkBoundedResource = BoundedVec<u8, RmrkResourceSymbolLimit>;1007pub type RmrkBoundedParts = BoundedVec<RmrkPartId, RmrkPartsLimit>; // todo make sure it is needed10081009pub type RmrkRpcString = Vec<u8>;1010pub type RmrkThemeName = RmrkRpcString;1011pub type RmrkPropertyKey = RmrkRpcString;runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -1513,7 +1513,7 @@
let nft_id = TokenId(nft_id);
if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Regular).is_err() { return Ok(Vec::new()); }
- let resources = <pallet_nonfungible::Pallet<Runtime>>::iterate_token_sys_properties(
+ let resources = <pallet_nonfungible::Pallet<Runtime>>::iterate_token_aux_properties(
collection_id, nft_id, PropertyScope::Rmrk
).filter_map(|(_, value)| {
let resource_info: RmrkResourceInfo = RmrkCore::decode_property(&value).ok()?;
runtime/quartz/src/lib.rsdiffbeforeafterboth--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -1513,7 +1513,7 @@
let nft_id = TokenId(nft_id);
if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Regular).is_err() { return Ok(Vec::new()); }
- let resources = <pallet_nonfungible::Pallet<Runtime>>::iterate_token_sys_properties(
+ let resources = <pallet_nonfungible::Pallet<Runtime>>::iterate_token_aux_properties(
collection_id, nft_id, PropertyScope::Rmrk
).filter_map(|(_, value)| {
let resource_info: RmrkResourceInfo = RmrkCore::decode_property(&value).ok()?;