git.delta.rocks / unique-network / refs/commits / 3a0da55c0806

difftreelog

Merge pull request #392 from UniqueNetwork/feature/rmrk-resources-refactor

kozyrevdev2022-06-21parents: #8a30e22 #16f309e.patch.diff
in: master
Feature/rmrk resources refactor

25 files changed

modifiedCargo.lockdiffbeforeafterboth
9999
100[[package]]100[[package]]
101name = "anyhow"101name = "anyhow"
102version = "1.0.58"102version = "1.0.57"
103source = "registry+https://github.com/rust-lang/crates.io-index"103source = "registry+https://github.com/rust-lang/crates.io-index"
104checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"104checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
105105
106[[package]]106[[package]]
107name = "approx"107name = "approx"
248248
249[[package]]249[[package]]
250name = "async-std"250name = "async-std"
251version = "1.12.0"251version = "1.11.0"
252source = "registry+https://github.com/rust-lang/crates.io-index"252source = "registry+https://github.com/rust-lang/crates.io-index"
253checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d"253checksum = "52580991739c5cdb36cde8b2a516371c0a3b70dda36d916cc08b82372916808c"
254dependencies = [254dependencies = [
255 "async-attributes",255 "async-attributes",
256 "async-channel",256 "async-channel",
267 "kv-log-macro",267 "kv-log-macro",
268 "log",268 "log",
269 "memchr",269 "memchr",
270 "num_cpus",
270 "once_cell",271 "once_cell",
271 "pin-project-lite 0.2.9",272 "pin-project-lite 0.2.9",
272 "pin-utils",273 "pin-utils",
12991300
1300[[package]]1301[[package]]
1301name = "crossbeam-channel"1302name = "crossbeam-channel"
1302version = "0.5.5"1303version = "0.5.4"
1303source = "registry+https://github.com/rust-lang/crates.io-index"1304source = "registry+https://github.com/rust-lang/crates.io-index"
1304checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c"1305checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
1305dependencies = [1306dependencies = [
1306 "cfg-if 1.0.0",1307 "cfg-if 1.0.0",
1307 "crossbeam-utils",1308 "crossbeam-utils",
13201321
1321[[package]]1322[[package]]
1322name = "crossbeam-epoch"1323name = "crossbeam-epoch"
1323version = "0.9.9"1324version = "0.9.8"
1324source = "registry+https://github.com/rust-lang/crates.io-index"1325source = "registry+https://github.com/rust-lang/crates.io-index"
1325checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d"1326checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
1326dependencies = [1327dependencies = [
1327 "autocfg",1328 "autocfg",
1328 "cfg-if 1.0.0",1329 "cfg-if 1.0.0",
1329 "crossbeam-utils",1330 "crossbeam-utils",
1331 "lazy_static",
1330 "memoffset",1332 "memoffset",
1331 "once_cell",
1332 "scopeguard",1333 "scopeguard",
1333]1334]
13341335
13441345
1345[[package]]1346[[package]]
1346name = "crossbeam-utils"1347name = "crossbeam-utils"
1347version = "0.8.9"1348version = "0.8.8"
1348source = "registry+https://github.com/rust-lang/crates.io-index"1349source = "registry+https://github.com/rust-lang/crates.io-index"
1349checksum = "8ff1f980957787286a554052d03c7aee98d99cc32e09f6d45f0a814133c87978"1350checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
1350dependencies = [1351dependencies = [
1351 "cfg-if 1.0.0",1352 "cfg-if 1.0.0",
1352 "once_cell",1353 "lazy_static",
1353]1354]
13541355
1355[[package]]1356[[package]]
21572158
2158[[package]]2159[[package]]
2159name = "dyn-clone"2160name = "dyn-clone"
2160version = "1.0.6"2161version = "1.0.5"
2161source = "registry+https://github.com/rust-lang/crates.io-index"2162source = "registry+https://github.com/rust-lang/crates.io-index"
2162checksum = "140206b78fb2bc3edbcfc9b5ccbd0b30699cfe8d348b8b31b330e47df5291a5a"2163checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28"
21632164
2164[[package]]2165[[package]]
2165name = "ecdsa"2166name = "ecdsa"
36613662
3662[[package]]3663[[package]]
3663name = "indexmap"3664name = "indexmap"
3664version = "1.9.0"3665version = "1.8.2"
3665source = "registry+https://github.com/rust-lang/crates.io-index"3666source = "registry+https://github.com/rust-lang/crates.io-index"
3666checksum = "6c6392766afd7964e2531940894cffe4bd8d7d17dbc3c1c4857040fd4b33bdb3"3667checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a"
3667dependencies = [3668dependencies = [
3668 "autocfg",3669 "autocfg",
3669 "hashbrown 0.12.1",3670 "hashbrown 0.11.2",
3670 "serde",3671 "serde",
3671]3672]
36723673
49554956
4956[[package]]4957[[package]]
4957name = "mio"4958name = "mio"
4958version = "0.8.4"4959version = "0.8.3"
4959source = "registry+https://github.com/rust-lang/crates.io-index"4960source = "registry+https://github.com/rust-lang/crates.io-index"
4960checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf"4961checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799"
4961dependencies = [4962dependencies = [
4962 "libc",4963 "libc",
4963 "log",4964 "log",
52085209
5209[[package]]5210[[package]]
5210name = "num-complex"5211name = "num-complex"
5211version = "0.4.2"5212version = "0.4.1"
5212source = "registry+https://github.com/rust-lang/crates.io-index"5213source = "registry+https://github.com/rust-lang/crates.io-index"
5213checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19"5214checksum = "97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790"
5214dependencies = [5215dependencies = [
5215 "num-traits",5216 "num-traits",
5216]5217]
84358436
8436[[package]]8437[[package]]
8437name = "proc-macro2"8438name = "proc-macro2"
8438version = "1.0.40"8439version = "1.0.39"
8439source = "registry+https://github.com/rust-lang/crates.io-index"8440source = "registry+https://github.com/rust-lang/crates.io-index"
8440checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"8441checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
8441dependencies = [8442dependencies = [
8442 "unicode-ident",8443 "unicode-ident",
8443]8444]
8557 "fp-evm-mapping",8558 "fp-evm-mapping",
8558 "fp-rpc",8559 "fp-rpc",
8559 "fp-self-contained",8560 "fp-self-contained",
8561 "frame-benchmarking",
8560 "frame-executive",8562 "frame-executive",
8561 "frame-support",8563 "frame-support",
8562 "frame-system",8564 "frame-system",
8565 "frame-system-benchmarking",
8563 "frame-system-rpc-runtime-api",8566 "frame-system-rpc-runtime-api",
8564 "frame-try-runtime",8567 "frame-try-runtime",
8568 "hex-literal",
8565 "log",8569 "log",
8566 "orml-vesting",8570 "orml-vesting",
8567 "pallet-aura",8571 "pallet-aura",
86398643
8640[[package]]8644[[package]]
8641name = "quote"8645name = "quote"
8642version = "1.0.20"8646version = "1.0.18"
8643source = "registry+https://github.com/rust-lang/crates.io-index"8647source = "registry+https://github.com/rust-lang/crates.io-index"
8644checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"8648checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
8645dependencies = [8649dependencies = [
8646 "proc-macro2",8650 "proc-macro2",
8647]8651]
92649268
9265[[package]]9269[[package]]
9266name = "rustversion"9270name = "rustversion"
9267version = "1.0.7"9271version = "1.0.6"
9268source = "registry+https://github.com/rust-lang/crates.io-index"9272source = "registry+https://github.com/rust-lang/crates.io-index"
9269checksum = "a0a5f7c728f5d284929a1cccb5bc19884422bfe6ef4d6c409da2c41838983fcf"9273checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
92709274
9271[[package]]9275[[package]]
9272name = "rw-stream-sink"9276name = "rw-stream-sink"
11587source = "registry+https://github.com/rust-lang/crates.io-index"11591source = "registry+https://github.com/rust-lang/crates.io-index"
11588checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"11592checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
11589dependencies = [11593dependencies = [
11590 "strum_macros 0.24.0",11594 "strum_macros 0.24.1",
11591]11595]
1159211596
11593[[package]]11597[[package]]
1160511609
11606[[package]]11610[[package]]
11607name = "strum_macros"11611name = "strum_macros"
11608version = "0.24.0"11612version = "0.24.1"
11609source = "registry+https://github.com/rust-lang/crates.io-index"11613source = "registry+https://github.com/rust-lang/crates.io-index"
11610checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef"11614checksum = "9550962e7cf70d9980392878dfaf1dcc3ece024f4cf3bf3c46b978d0bad61d6c"
11611dependencies = [11615dependencies = [
11612 "heck 0.4.0",11616 "heck 0.4.0",
11613 "proc-macro2",11617 "proc-macro2",
1176311767
11764[[package]]11768[[package]]
11765name = "syn"11769name = "syn"
11766version = "1.0.98"11770version = "1.0.96"
11767source = "registry+https://github.com/rust-lang/crates.io-index"11771source = "registry+https://github.com/rust-lang/crates.io-index"
11768checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"11772checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
11769dependencies = [11773dependencies = [
11770 "proc-macro2",11774 "proc-macro2",
11771 "quote",11775 "quote",
1212212126
12123[[package]]12127[[package]]
12124name = "tower-service"12128name = "tower-service"
12125version = "0.3.2"12129version = "0.3.1"
12126source = "registry+https://github.com/rust-lang/crates.io-index"12130source = "registry+https://github.com/rust-lang/crates.io-index"
12127checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"12131checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"
1212812132
12129[[package]]12133[[package]]
12130name = "tracing"12134name = "tracing"
12356source = "registry+https://github.com/rust-lang/crates.io-index"12360source = "registry+https://github.com/rust-lang/crates.io-index"
12357checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"12361checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
12358dependencies = [12362dependencies = [
12359 "cfg-if 1.0.0",12363 "cfg-if 0.1.10",
12360 "digest 0.10.3",12364 "digest 0.10.3",
12361 "rand 0.8.5",12365 "rand 0.8.5",
12362 "static_assertions",12366 "static_assertions",
modifiedMakefilediffbeforeafterboth
5959
60.PHONY: _bench60.PHONY: _bench
61_bench:61_bench:
62 cargo run --release --features runtime-benchmarks,unique-runtime -- \62 cargo run --release --features runtime-benchmarks,$(RUNTIME) -- \
63 benchmark pallet --pallet pallet-$(if $(PALLET),$(PALLET),$(error Must set PALLET)) \63 benchmark pallet --pallet pallet-$(if $(PALLET),$(PALLET),$(error Must set PALLET)) \
64 --wasm-execution compiled --extrinsic '*' \64 --wasm-execution compiled --extrinsic '*' \
65 --template .maintain/frame-weight-template.hbs --steps=50 --repeat=80 --heap-pages=4096 \65 --template .maintain/frame-weight-template.hbs --steps=50 --repeat=80 --heap-pages=4096 \
101bench-rmrk-core:101bench-rmrk-core:
102 make _bench PALLET=proxy-rmrk-core102 make _bench PALLET=proxy-rmrk-core
103
104.PHONY: bench-rmrk-equip
105bench-rmrk-equip:
106 make _bench PALLET=proxy-rmrk-equip
103107
104.PHONY: bench108.PHONY: bench
105bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-scheduler bench-rmrk-core109bench: bench-evm-migration bench-unique bench-structure bench-fungible bench-refungible bench-nonfungible bench-scheduler bench-rmrk-core bench-rmrk-equip
106110
modifiednode/cli/Cargo.tomldiffbeforeafterboth
323[features]323[features]
324default = []324default = []
325runtime-benchmarks = [325runtime-benchmarks = [
326 'unique-runtime/runtime-benchmarks',326 'unique-runtime?/runtime-benchmarks',
327 'quartz-runtime?/runtime-benchmarks',
328 'opal-runtime/runtime-benchmarks',
327 'polkadot-service/runtime-benchmarks',329 'polkadot-service/runtime-benchmarks',
328]330]
329try-runtime = []331try-runtime = []
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
26use unique_runtime_common::types::*;26use unique_runtime_common::types::*;
2727
28#[cfg(feature = "unique-runtime")]28#[cfg(feature = "unique-runtime")]
29use unique_runtime as default_runtime;29pub use unique_runtime as default_runtime;
3030
31#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]31#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
32use quartz_runtime as default_runtime;32pub use quartz_runtime as default_runtime;
3333
34#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]34#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
35use opal_runtime as default_runtime;35pub use opal_runtime as default_runtime;
3636
37/// The `ChainSpec` parameterized for the unique runtime.37/// The `ChainSpec` parameterized for the unique runtime.
38#[cfg(feature = "unique-runtime")]38#[cfg(feature = "unique-runtime")]
modifiednode/cli/src/command.rsdiffbeforeafterboth
3434
35use crate::{35use crate::{
36 chain_spec::{self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification},36 chain_spec::{
37 self, RuntimeId, RuntimeIdentification, ServiceId, ServiceIdentification, default_runtime,
38 },
37 cli::{Cli, RelayChainCli, Subcommand},39 cli::{Cli, RelayChainCli, Subcommand},
38 service::{new_partial, start_node, start_dev_node},40 service::{new_partial, start_node, start_dev_node},
44#[cfg(feature = "quartz-runtime")]46#[cfg(feature = "quartz-runtime")]
45use crate::service::QuartzRuntimeExecutor;47use crate::service::QuartzRuntimeExecutor;
4648
47use crate::service::OpalRuntimeExecutor;49use crate::service::{OpalRuntimeExecutor, DefaultRuntimeExecutor};
4850
49use codec::Encode;51use codec::Encode;
50use cumulus_primitives_core::ParaId;52use cumulus_primitives_core::ParaId;
372374
373 Ok(())375 Ok(())
374 }376 }
375 #[cfg(feature = "unique-runtime")]
376 Some(Subcommand::Benchmark(cmd)) => {377 Some(Subcommand::Benchmark(cmd)) => {
377 use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};378 use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
378 let runner = cli.create_runner(cmd)?;379 let runner = cli.create_runner(cmd)?;
379 // Switch on the concrete benchmark sub-command-380 // Switch on the concrete benchmark sub-command-
380 match cmd {381 match cmd {
381 BenchmarkCmd::Pallet(cmd) => {382 BenchmarkCmd::Pallet(cmd) => {
382 if cfg!(feature = "runtime-benchmarks") {383 if cfg!(feature = "runtime-benchmarks") {
383 runner.sync_run(|config| cmd.run::<Block, UniqueRuntimeExecutor>(config))384 runner.sync_run(|config| cmd.run::<Block, DefaultRuntimeExecutor>(config))
384 } else {385 } else {
385 Err("Benchmarking wasn't enabled when building the node. \386 Err("Benchmarking wasn't enabled when building the node. \
386 You can enable it with `--features runtime-benchmarks`."387 You can enable it with `--features runtime-benchmarks`."
389 }390 }
390 BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {391 BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
391 let partials = new_partial::<392 let partials = new_partial::<
392 unique_runtime::RuntimeApi,393 default_runtime::RuntimeApi,
393 UniqueRuntimeExecutor,394 DefaultRuntimeExecutor,
394 _,395 _,
395 >(&config, crate::service::parachain_build_import_queue)?;396 >(&config, crate::service::parachain_build_import_queue)?;
396 cmd.run(partials.client)397 cmd.run(partials.client)
397 }),398 }),
398 BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {399 BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
399 let partials = new_partial::<400 let partials = new_partial::<
400 unique_runtime::RuntimeApi,401 default_runtime::RuntimeApi,
401 UniqueRuntimeExecutor,402 DefaultRuntimeExecutor,
402 _,403 _,
403 >(&config, crate::service::parachain_build_import_queue)?;404 >(&config, crate::service::parachain_build_import_queue)?;
404 let db = partials.backend.expose_db();405 let db = partials.backend.expose_db();
412 BenchmarkCmd::Overhead(_) => Err("Unsupported benchmarking command".into()),413 BenchmarkCmd::Overhead(_) => Err("Unsupported benchmarking command".into()),
413 }414 }
414 }415 }
415 #[cfg(not(feature = "unique-runtime"))]
416 Some(Subcommand::Benchmark(..)) => {
417 Err("benchmarking is only available with unique runtime enabled".into())
418 }
419 Some(Subcommand::TryRuntime(cmd)) => {416 Some(Subcommand::TryRuntime(cmd)) => {
420 if cfg!(feature = "try-runtime") {417 if cfg!(feature = "try-runtime") {
421 let runner = cli.create_runner(cmd)?;418 let runner = cli.create_runner(cmd)?;
modifiednode/cli/src/service.rsdiffbeforeafterboth
83/// Opal native executor instance.82/// Opal native executor instance.
84pub struct OpalRuntimeExecutor;83pub struct OpalRuntimeExecutor;
84
85#[cfg(feature = "unique-runtime")]
86pub type DefaultRuntimeExecutor = UniqueRuntimeExecutor;
87
88#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
89pub type DefaultRuntimeExecutor = QuartzRuntimeExecutor;
90
91#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
92pub type DefaultRuntimeExecutor = OpalRuntimeExecutor;
8593
86#[cfg(feature = "unique-runtime")]94#[cfg(feature = "unique-runtime")]
87impl NativeExecutionDispatch for UniqueRuntimeExecutor {95impl NativeExecutionDispatch for UniqueRuntimeExecutor {
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
74 RmrkPropertyInfo,74 RmrkPropertyInfo,
75 RmrkBaseInfo,75 RmrkBaseInfo,
76 RmrkPartType,76 RmrkPartType,
77 RmrkTheme,77 RmrkBoundedTheme,
78 RmrkNftChild,78 RmrkNftChild,
79 CollectionPermissions,79 CollectionPermissions,
80 SchemaVersion,80 SchemaVersion,
543 RmrkPropertyInfo,543 RmrkPropertyInfo,
544 RmrkBaseInfo<T::AccountId>,544 RmrkBaseInfo<T::AccountId>,
545 RmrkPartType,545 RmrkPartType,
546 RmrkTheme,546 RmrkBoundedTheme,
547 RmrkNftChild,547 RmrkNftChild,
548 )>,548 )>,
549 ),549 ),
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
28use up_data_structs::{28use up_data_structs::{
29 AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,29 AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,
30 mapping::TokenAddressMapping, budget::Budget, Property, PropertyPermission, PropertyKey,30 mapping::TokenAddressMapping, budget::Budget, Property, PropertyPermission, PropertyKey,
31 PropertyKeyPermission, Properties, PropertyScope, TrySetProperty, TokenChild,31 PropertyKeyPermission, Properties, PropertyScope, TrySetProperty, TokenChild, AuxPropertyValue,
32};32};
33use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};33use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
34use pallet_common::{34use pallet_common::{
124 OnEmpty = up_data_structs::TokenProperties,124 OnEmpty = up_data_structs::TokenProperties,
125 >;125 >;
126
127 #[pallet::storage]
128 #[pallet::getter(fn token_aux_property)]
129 pub type TokenAuxProperties<T: Config> = StorageNMap<
130 Key = (
131 Key<Twox64Concat, CollectionId>,
132 Key<Twox64Concat, TokenId>,
133 Key<Twox64Concat, PropertyScope>,
134 Key<Twox64Concat, PropertyKey>,
135 ),
136 Value = AuxPropertyValue,
137 QueryKind = OptionQuery,
138 >;
126139
127 /// Used to enumerate tokens owned by account140 /// Used to enumerate tokens owned by account
128 #[pallet::storage]141 #[pallet::storage]
294 Ok(())307 Ok(())
295 }308 }
309
310 pub fn try_mutate_token_aux_property<R, E>(
311 collection_id: CollectionId,
312 token_id: TokenId,
313 scope: PropertyScope,
314 key: PropertyKey,
315 f: impl FnOnce(&mut Option<AuxPropertyValue>) -> Result<R, E>,
316 ) -> Result<R, E> {
317 <TokenAuxProperties<T>>::try_mutate((collection_id, token_id, scope, key), f)
318 }
319
320 pub fn remove_token_aux_property(
321 collection_id: CollectionId,
322 token_id: TokenId,
323 scope: PropertyScope,
324 key: PropertyKey,
325 ) {
326 <TokenAuxProperties<T>>::remove((collection_id, token_id, scope, key));
327 }
328
329 pub fn iterate_token_aux_properties(
330 collection_id: CollectionId,
331 token_id: TokenId,
332 scope: PropertyScope,
333 ) -> impl Iterator<Item = (PropertyKey, AuxPropertyValue)> {
334 <TokenAuxProperties<T>>::iter_prefix((collection_id, token_id, scope))
335 }
296336
297 pub fn current_token_id(collection_id: CollectionId) -> TokenId {337 pub fn current_token_id(collection_id: CollectionId) -> TokenId {
298 TokenId(<TokensMinted<T>>::get(collection_id))338 TokenId(<TokensMinted<T>>::get(collection_id))
375 <TokensBurnt<T>>::insert(collection.id, burnt);415 <TokensBurnt<T>>::insert(collection.id, burnt);
376 <TokenData<T>>::remove((collection.id, token));416 <TokenData<T>>::remove((collection.id, token));
377 <TokenProperties<T>>::remove((collection.id, token));417 <TokenProperties<T>>::remove((collection.id, token));
418 <TokenAuxProperties<T>>::remove_prefix((collection.id, token), None);
378 let old_spender = <Allowance<T>>::take((collection.id, token));419 let old_spender = <Allowance<T>>::take((collection.id, token));
379420
380 if let Some(old_spender) = old_spender {421 if let Some(old_spender) = old_spender {
modifiedpallets/proxy-rmrk-core/src/benchmarking.rsdiffbeforeafterboth
8585
86 <Pallet<T>>::mint_nft(86 <Pallet<T>>::mint_nft(
87 RawOrigin::Signed(owner.clone()).into(),87 RawOrigin::Signed(owner.clone()).into(),
88 owner.clone(),88 None,
89 collection_id,89 collection_id,
90 royalty_recipient,90 royalty_recipient,
91 royalty_amount,91 royalty_amount,
108 }108 }
109 }109 }
110
111 fn current_nft_id(&self) -> RmrkNftId {
112 self.current_nft_id
113 }
114110
115 fn build<T: Config>(&mut self, owner: &T::AccountId) -> Result<RmrkNftId, DispatchError> {111 fn build<T: Config>(&mut self, owner: &T::AccountId) -> Result<RmrkNftId, DispatchError> {
116 create_nft::<T>(owner, self.collection_id)?;112 create_nft::<T>(owner, self.collection_id)?;
220 let b in 0..100;216 let b in 0..100;
221217
222 let caller: T::AccountId = account("caller", 0, SEED);218 let caller: T::AccountId = account("caller", 0, SEED);
223 <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
224219
225 create_max_collection::<T>(&caller)?;220 create_max_collection::<T>(&caller)?;
226 let collection_id = 0;221 let collection_id = 0;
232 let transferable = true;227 let transferable = true;
233 }: _(228 }: _(
234 RawOrigin::Signed(caller),229 RawOrigin::Signed(caller),
235 owner,230 None,
236 collection_id,231 collection_id,
237 royalty_recipient,232 royalty_recipient,
238 royalty_amount,233 royalty_amount,
381376
382 add_basic_resource {377 add_basic_resource {
383 let caller: T::AccountId = account("caller", 0, SEED);378 let caller: T::AccountId = account("caller", 0, SEED);
384 <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
385379
386 create_max_collection::<T>(&caller)?;380 create_max_collection::<T>(&caller)?;
387 let collection_id = 0;381 let collection_id = 0;
398392
399 add_composable_resource {393 add_composable_resource {
400 let caller: T::AccountId = account("caller", 0, SEED);394 let caller: T::AccountId = account("caller", 0, SEED);
401 <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
402395
403 create_max_collection::<T>(&caller)?;396 create_max_collection::<T>(&caller)?;
404 let collection_id = 0;397 let collection_id = 0;
415408
416 add_slot_resource {409 add_slot_resource {
417 let caller: T::AccountId = account("caller", 0, SEED);410 let caller: T::AccountId = account("caller", 0, SEED);
418 <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
419411
420 create_max_collection::<T>(&caller)?;412 create_max_collection::<T>(&caller)?;
421 let collection_id = 0;413 let collection_id = 0;
432424
433 remove_resource {425 remove_resource {
434 let caller: T::AccountId = account("caller", 0, SEED);426 let caller: T::AccountId = account("caller", 0, SEED);
435 <T as pallet_common::Config>::Currency::deposit_creating(&caller, T::CollectionCreationPrice::get());
436427
437 create_max_collection::<T>(&caller)?;428 create_max_collection::<T>(&caller)?;
438 let collection_id = 0;429 let collection_id = 0;
448 resource439 resource
449 )?;440 )?;
450441
451 let resource_id = 1;442 let resource_id = 0;
452 }: _(443 }: _(
453 RawOrigin::Signed(caller),444 RawOrigin::Signed(caller),
454 collection_id,445 collection_id,
460 let caller: T::AccountId = account("caller", 0, SEED);451 let caller: T::AccountId = account("caller", 0, SEED);
461 let admin: T::AccountId = account("admin", 0, SEED);452 let admin: T::AccountId = account("admin", 0, SEED);
462
463 <T as pallet_common::Config>::Currency::deposit_creating(&admin, T::CollectionCreationPrice::get());
464453
465 create_max_collection::<T>(&admin)?;454 create_max_collection::<T>(&admin)?;
466 let collection_id = 0;455 let collection_id = 0;
486 resource475 resource
487 )?;476 )?;
488477
489 let resource_id = 1;478 let resource_id = 0;
490 }: _(479 }: _(
491 RawOrigin::Signed(caller),480 RawOrigin::Signed(caller),
492 collection_id,481 collection_id,
498 let caller: T::AccountId = account("caller", 0, SEED);487 let caller: T::AccountId = account("caller", 0, SEED);
499 let admin: T::AccountId = account("admin", 0, SEED);488 let admin: T::AccountId = account("admin", 0, SEED);
500
501 <T as pallet_common::Config>::Currency::deposit_creating(&admin, T::CollectionCreationPrice::get());
502489
503 create_max_collection::<T>(&admin)?;490 create_max_collection::<T>(&admin)?;
504 let collection_id = 0;491 let collection_id = 0;
515 resource502 resource
516 )?;503 )?;
517504
518 let resource_id = 1;505 let resource_id = 0;
519506
520 let new_owner = <RmrkAccountIdOrCollectionNftTuple<T::AccountId>>::AccountId(caller.clone());507 let new_owner = <RmrkAccountIdOrCollectionNftTuple<T::AccountId>>::AccountId(caller.clone());
521508
modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
35pub mod benchmarking;35pub mod benchmarking;
36pub mod misc;36pub mod misc;
37pub mod property;37pub mod property;
38pub mod rpc;
38pub mod weights;39pub mod weights;
3940
40pub type SelfWeightOf<T> = <T as Config>::WeightInfo;41pub type SelfWeightOf<T> = <T as Config>::WeightInfo;
154 NftTypeEncodeError,155 NftTypeEncodeError,
155 RmrkPropertyKeyIsTooLong,156 RmrkPropertyKeyIsTooLong,
156 RmrkPropertyValueIsTooLong,157 RmrkPropertyValueIsTooLong,
158 RmrkPropertyIsNotFound,
157 UnableToDecodeRmrkData,159 UnableToDecodeRmrkData,
158160
159 /* RMRK compatible events */161 /* RMRK compatible events */
168 CannotSendToDescendentOrSelf,170 CannotSendToDescendentOrSelf,
169 CannotAcceptNonOwnedNft,171 CannotAcceptNonOwnedNft,
170 CannotRejectNonOwnedNft,172 CannotRejectNonOwnedNft,
173 CannotRejectNonPendingNft,
171 ResourceNotPending,174 ResourceNotPending,
175 NoAvailableResourceId,
172 }176 }
173177
174 #[pallet::call]178 #[pallet::call]
347 #[pallet::weight(<SelfWeightOf<T>>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))]351 #[pallet::weight(<SelfWeightOf<T>>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))]
348 pub fn mint_nft(352 pub fn mint_nft(
349 origin: OriginFor<T>,353 origin: OriginFor<T>,
350 owner: T::AccountId,354 owner: Option<T::AccountId>,
351 collection_id: RmrkCollectionId,355 collection_id: RmrkCollectionId,
352 recipient: Option<T::AccountId>,356 recipient: Option<T::AccountId>,
353 royalty_amount: Option<Permill>,357 royalty_amount: Option<Permill>,
357 ) -> DispatchResult {361 ) -> DispatchResult {
358 let sender = ensure_signed(origin)?;362 let sender = ensure_signed(origin)?;
359 let cross_sender = T::CrossAccountId::from_sub(sender.clone());363 let cross_sender = T::CrossAccountId::from_sub(sender.clone());
364
365 let owner = owner.unwrap_or(sender.clone());
360 let cross_owner = T::CrossAccountId::from_sub(owner.clone());366 let cross_owner = T::CrossAccountId::from_sub(owner.clone());
361367
362 let collection = Self::get_typed_nft_collection(368 let collection = Self::get_typed_nft_collection(
381 Self::rmrk_property(RoyaltyInfo, &royalty_info)?,387 Self::rmrk_property(RoyaltyInfo, &royalty_info)?,
382 Self::rmrk_property(Metadata, &metadata)?,388 Self::rmrk_property(Metadata, &metadata)?,
383 Self::rmrk_property(Equipped, &false)?,389 Self::rmrk_property(Equipped, &false)?,
384 Self::rmrk_property(ResourceCollection, &None::<CollectionId>)?,
385 Self::rmrk_property(ResourcePriorities, &<Vec<u8>>::new())?,390 Self::rmrk_property(ResourcePriorities, &<Vec<u8>>::new())?,
391 Self::rmrk_property(NextResourceId, &(0 as RmrkResourceId))?,
386 ]392 ]
387 .into_iter(),393 .into_iter(),
388 )394 )
653 collection.check_is_external()?;659 collection.check_is_external()?;
654660
655 ensure!(661 ensure!(
662 <TokenData<T>>::get((collection_id, nft_id)).is_some(),
663 <Error<T>>::NoAvailableNftId
664 );
665
666 ensure!(
656 Self::get_nft_property_decoded(667 Self::get_nft_property_decoded(
657 collection_id,668 collection_id,
658 nft_id,669 nft_id,
659 RmrkProperty::PendingNftAccept670 RmrkProperty::PendingNftAccept
660 )?,671 )?,
661 <Error<T>>::NoPermission672 <Error<T>>::CannotRejectNonPendingNft
662 );673 );
663674
664 Self::destroy_nft(675 Self::destroy_nft(
686 origin: OriginFor<T>,697 origin: OriginFor<T>,
687 rmrk_collection_id: RmrkCollectionId,698 rmrk_collection_id: RmrkCollectionId,
688 rmrk_nft_id: RmrkNftId,699 rmrk_nft_id: RmrkNftId,
689 rmrk_resource_id: RmrkResourceId,700 resource_id: RmrkResourceId,
690 ) -> DispatchResult {701 ) -> DispatchResult {
691 let sender = ensure_signed(origin)?;702 let sender = ensure_signed(origin)?;
692 let cross_sender = T::CrossAccountId::from_sub(sender);703 let cross_sender = T::CrossAccountId::from_sub(sender);
698 collection.check_is_external()?;709 collection.check_is_external()?;
699710
700 let nft_id = rmrk_nft_id.into();711 let nft_id = rmrk_nft_id.into();
701 let resource_id = rmrk_resource_id.into();
702712
703 let budget = budget::Value::new(NESTING_BUDGET);713 let budget = budget::Value::new(NESTING_BUDGET);
704714
705 let nft_owner =715 let nft_owner =
706 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)716 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)
707 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;717 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;
708718
709 let resource_collection_id: Option<CollectionId> =719 Self::try_mutate_resource_info(collection_id, nft_id, resource_id, |res| {
710 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)720 ensure!(res.pending, <Error<T>>::ResourceNotPending);
711 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;721 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);
712722
713 let resource_collection_id =723 res.pending = false;
714 resource_collection_id.ok_or(<Error<T>>::ResourceDoesntExist)?;
715724
716 let is_pending: bool = Self::get_nft_property_decoded(725 Ok(())
717 resource_collection_id,
718 resource_id,
719 PendingResourceAccept,
720 )
721 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;726 })?;
722727
723 ensure!(is_pending, <Error<T>>::ResourceNotPending);
724
725 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);
726
727 <PalletNft<T>>::set_scoped_token_property(
728 resource_collection_id,
729 rmrk_resource_id.into(),
730 PropertyScope::Rmrk,
731 Self::rmrk_property(PendingResourceAccept, &false)?,
732 )?;
733
734 Self::deposit_event(Event::<T>::ResourceAccepted {728 Self::deposit_event(Event::<T>::ResourceAccepted {
735 nft_id: rmrk_nft_id,729 nft_id: rmrk_nft_id,
736 resource_id: rmrk_resource_id,730 resource_id,
737 });731 });
738732
739 Ok(())733 Ok(())
746 origin: OriginFor<T>,740 origin: OriginFor<T>,
747 rmrk_collection_id: RmrkCollectionId,741 rmrk_collection_id: RmrkCollectionId,
748 rmrk_nft_id: RmrkNftId,742 rmrk_nft_id: RmrkNftId,
749 rmrk_resource_id: RmrkResourceId,743 resource_id: RmrkResourceId,
750 ) -> DispatchResult {744 ) -> DispatchResult {
751 let sender = ensure_signed(origin)?;745 let sender = ensure_signed(origin)?;
752 let cross_sender = T::CrossAccountId::from_sub(sender);746 let cross_sender = T::CrossAccountId::from_sub(sender);
758 collection.check_is_external()?;752 collection.check_is_external()?;
759753
760 let nft_id = rmrk_nft_id.into();754 let nft_id = rmrk_nft_id.into();
761 let resource_id = rmrk_resource_id.into();
762755
763 let budget = budget::Value::new(NESTING_BUDGET);756 let budget = budget::Value::new(NESTING_BUDGET);
764757
768761
769 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);762 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);
770763
771 let resource_collection_id: Option<CollectionId> =764 let resource_id_key = Self::rmrk_property_key(ResourceId(resource_id))?;
772 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)
773 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;
774765
775 let resource_collection_id =766 let resource_info = <PalletNft<T>>::token_aux_property((
776 resource_collection_id.ok_or(<Error<T>>::ResourceDoesntExist)?;767 collection_id,
768 nft_id,
769 PropertyScope::Rmrk,
770 resource_id_key.clone(),
771 ))
772 .ok_or(<Error<T>>::ResourceDoesntExist)?;
777773
778 let is_pending: bool = Self::get_nft_property_decoded(774 let resource_info: RmrkResourceInfo = Self::decode_property(&resource_info)?;
779 resource_collection_id,
780 resource_id,
781 PendingResourceRemoval,
782 )
783 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;
784775
785 ensure!(is_pending, <Error<T>>::ResourceNotPending);776 ensure!(
777 resource_info.pending_removal,
778 <Error<T>>::ResourceNotPending
779 );
786780
787 let resource_collection = Self::get_typed_nft_collection(781 <PalletNft<T>>::remove_token_aux_property(
788 resource_collection_id,782 collection_id,
789 misc::CollectionType::Resource,783 nft_id,
784 PropertyScope::Rmrk,
785 resource_id_key,
790 )?;786 );
791787
792 let resource_data = <TokenData<T>>::get((resource_collection_id, resource_id))
793 .ok_or(<Error<T>>::ResourceDoesntExist)?;
794
795 let resource_owner = resource_data.owner;
796
797 <PalletNft<T>>::burn(
798 &resource_collection,
799 &resource_owner,
800 rmrk_resource_id.into(),
801 )
802 .map_err(Self::map_unique_err_to_proxy)?;
803
804 Self::deposit_event(Event::<T>::ResourceRemovalAccepted {788 Self::deposit_event(Event::<T>::ResourceRemovalAccepted {
805 nft_id: rmrk_nft_id,789 nft_id: rmrk_nft_id,
806 resource_id: rmrk_resource_id,790 resource_id,
807 });791 });
808792
809 Ok(())793 Ok(())
1014 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;998 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;
1015 collection.check_is_external()?;999 collection.check_is_external()?;
10161000
1017 Self::resource_remove(sender, collection_id, nft_id.into(), resource_id.into())?;1001 Self::resource_remove(sender, collection_id, nft_id.into(), resource_id)?;
10181002
1019 Self::deposit_event(Event::ResourceRemoval {1003 Self::deposit_event(Event::ResourceRemoval {
1020 nft_id,1004 nft_id,
1043 ) -> Result<Property, DispatchError> {1027 ) -> Result<Property, DispatchError> {
1044 let key = rmrk_key.to_key::<T>()?;1028 let key = rmrk_key.to_key::<T>()?;
10451029
1030 let value = Self::encode_property(value)?;
1031
1032 let property = Property { key, value };
1033
1034 Ok(property)
1035 }
1036
1037 pub fn encode_property<E: Encode, S: Get<u32>>(
1038 value: &E,
1039 ) -> Result<BoundedBytes<S>, DispatchError> {
1046 let value = value1040 let value = value
1047 .encode()1041 .encode()
1048 .try_into()1042 .try_into()
1049 .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong)?;1043 .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong)?;
10501044
1051 let property = Property { key, value };1045 Ok(value)
1052
1053 Ok(property)
1054 }1046 }
10551047
1056 pub fn decode_property<D: Decode>(vec: PropertyValue) -> Result<D, DispatchError> {1048 pub fn decode_property<D: Decode, S: Get<u32>>(
1049 vec: &BoundedBytes<S>,
1050 ) -> Result<D, DispatchError> {
1057 vec.decode()1051 vec.decode()
1058 .map_err(|_| <Error<T>>::UnableToDecodeRmrkData.into())1052 .map_err(|_| <Error<T>>::UnableToDecodeRmrkData.into())
1059 }1053 }
1153 )1147 )
1154 }1148 }
11551149
1156 fn resource_add(1150 fn acquire_next_resource_id(
1157 sender: T::AccountId,
1158 collection_id: CollectionId,1151 collection_id: CollectionId,
1159 nft_id: TokenId,1152 nft_id: TokenId,
1160 resource: RmrkResourceTypes,
1161 ) -> Result<RmrkResourceId, DispatchError> {1153 ) -> Result<RmrkResourceId, DispatchError> {
1162 match resource {1154 let resource_id: RmrkResourceId =
1163 RmrkResourceTypes::Basic(resource) => Self::resource_add_helper(
1164 sender,1155 Self::get_nft_property_decoded(collection_id, nft_id, NextResourceId)?;
1165 collection_id,1156
1166 nft_id,
1167 [
1168 Self::rmrk_property(TokenType, &NftType::Resource)?,
1169 Self::rmrk_property(ResourceType, &misc::ResourceType::Basic)?,
1170 Self::rmrk_property(Src, &resource.src)?,
1171 Self::rmrk_property(Metadata, &resource.metadata)?,1157 let next_id = resource_id
1172 Self::rmrk_property(License, &resource.license)?,
1173 Self::rmrk_property(Thumb, &resource.thumb)?,
1174 ]
1175 .into_iter(),
1176 ),
1177 RmrkResourceTypes::Composable(resource) => Self::resource_add_helper(
1178 sender,1158 .checked_add(1)
1179 collection_id,
1180 nft_id.into(),
1181 [1159 .ok_or(<Error<T>>::NoAvailableResourceId)?;
1182 Self::rmrk_property(TokenType, &NftType::Resource)?,1160
1183 Self::rmrk_property(ResourceType, &misc::ResourceType::Composable)?,
1184 Self::rmrk_property(Parts, &resource.parts)?,
1185 Self::rmrk_property(Base, &resource.base)?,
1186 Self::rmrk_property(Src, &resource.src)?,
1187 Self::rmrk_property(Metadata, &resource.metadata)?,
1188 Self::rmrk_property(License, &resource.license)?,1161 <PalletNft<T>>::set_scoped_token_property(
1189 Self::rmrk_property(Thumb, &resource.thumb)?,
1190 ]
1191 .into_iter(),
1192 ),
1193 RmrkResourceTypes::Slot(resource) => Self::resource_add_helper(
1194 sender,1162 collection_id,
1195 collection_id,
1196 nft_id.into(),1163 nft_id,
1197 [1164 PropertyScope::Rmrk,
1198 Self::rmrk_property(TokenType, &NftType::Resource)?,
1199 Self::rmrk_property(ResourceType, &misc::ResourceType::Slot)?,1165 Self::rmrk_property(NextResourceId, &next_id)?,
1200 Self::rmrk_property(Base, &resource.base)?,1166 )?;
1201 Self::rmrk_property(Src, &resource.src)?,1167
1202 Self::rmrk_property(Metadata, &resource.metadata)?,1168 Ok(resource_id)
1203 Self::rmrk_property(Slot, &resource.slot)?,
1204 Self::rmrk_property(License, &resource.license)?,
1205 Self::rmrk_property(Thumb, &resource.thumb)?,
1206 ]
1207 .into_iter(),
1208 ),
1209 }
1210 }1169 }
12111170
1212 fn resource_add_helper(1171 fn resource_add(
1213 sender: T::AccountId,1172 sender: T::AccountId,
1214 collection_id: CollectionId,1173 collection_id: CollectionId,
1215 token_id: TokenId,1174 nft_id: TokenId,
1216 resource_properties: impl Iterator<Item = Property>,1175 resource: RmrkResourceTypes,
1217 ) -> Result<RmrkResourceId, DispatchError> {1176 ) -> Result<RmrkResourceId, DispatchError> {
1218 let collection =1177 let collection =
1219 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1178 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;
1222 let sender = T::CrossAccountId::from_sub(sender);1181 let sender = T::CrossAccountId::from_sub(sender);
1223 let budget = budget::Value::new(NESTING_BUDGET);1182 let budget = budget::Value::new(NESTING_BUDGET);
12241183
1225 let nft_owner = <PalletStructure<T>>::find_topmost_owner(collection_id, token_id, &budget)1184 let nft_owner = <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)
1226 .map_err(Self::map_unique_err_to_proxy)?;1185 .map_err(Self::map_unique_err_to_proxy)?;
12271186
1228 let pending = sender != nft_owner;1187 let pending = sender != nft_owner;
12291188
1230 let resource_collection_id: Option<CollectionId> =1189 let id = Self::acquire_next_resource_id(collection_id, nft_id)?;
1231 Self::get_nft_property_decoded(collection_id, token_id, ResourceCollection)?;
12321190
1233 let resource_collection_id = match resource_collection_id {1191 let resource_info = RmrkResourceInfo {
1234 Some(id) => id,1192 id,
1235 None => {1193 resource,
1236 let resource_collection_id = Self::init_collection(
1237 sender.clone(),
1238 CreateCollectionData {1194 pending,
1239 ..Default::default()
1240 },
1241 [Self::rmrk_property(1195 pending_removal: false,
1242 CollectionType,
1243 &misc::CollectionType::Resource,
1244 )?]
1245 .into_iter(),
1246 )?;
1247
1248 <PalletNft<T>>::set_scoped_token_property(
1249 collection_id,
1250 token_id,
1251 PropertyScope::Rmrk,
1252 Self::rmrk_property(ResourceCollection, &Some(resource_collection_id))?,
1253 )?;
1254
1255 resource_collection_id
1256 }
1257 };1196 };
12581197
1259 let resource_collection =1198 <PalletNft<T>>::try_mutate_token_aux_property(
1260 Self::get_typed_nft_collection(resource_collection_id, misc::CollectionType::Resource)?;1199 collection_id,
1200 nft_id,
1201 PropertyScope::Rmrk,
1202 Self::rmrk_property_key(ResourceId(id))?,
1203 |value| -> DispatchResult {
1204 *value = Some(Self::encode_property(&resource_info)?);
12611205
1262 // todo probably add extra connections to bases, slots, etc., when RMRK starts to use them1206 Ok(())
1207 },
1208 )?;
12631209
1264 let resource_id = Self::create_nft(1210 Ok(id)
1265 &sender,
1266 &nft_owner,
1267 &resource_collection,
1268 resource_properties.chain(
1269 [
1270 Self::rmrk_property(PendingResourceAccept, &pending)?,
1271 Self::rmrk_property(PendingResourceRemoval, &false)?,
1272 ]
1273 .into_iter(),
1274 ),
1275 )
1276 .map_err(|err| match err {
1277 DispatchError::Arithmetic(_) => <Error<T>>::NoAvailableNftId.into(),
1278 err => Self::map_unique_err_to_proxy(err),
1279 })?;
1280
1281 Ok(resource_id.0)
1282 }1211 }
12831212
1284 fn resource_remove(1213 fn resource_remove(
1285 sender: T::AccountId,1214 sender: T::AccountId,
1286 collection_id: CollectionId,1215 collection_id: CollectionId,
1287 nft_id: TokenId,1216 nft_id: TokenId,
1288 resource_id: TokenId,1217 resource_id: RmrkResourceId,
1289 ) -> DispatchResult {1218 ) -> DispatchResult {
1290 let collection =1219 let collection =
1291 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1220 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;
1292 ensure!(collection.owner == sender, Error::<T>::NoPermission);1221 ensure!(collection.owner == sender, Error::<T>::NoPermission);
12931222
1294 let resource_collection_id: Option<CollectionId> =1223 let resource_id_key = Self::rmrk_property_key(ResourceId(resource_id))?;
1295 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)?;1224 let scope = PropertyScope::Rmrk;
12961225
1297 let resource_collection_id =
1298 resource_collection_id.ok_or(Error::<T>::ResourceDoesntExist)?;
1299
1300 let resource_collection =
1301 Self::get_typed_nft_collection(resource_collection_id, misc::CollectionType::Resource)?;
1302 ensure!(1226 ensure!(
1303 <PalletNft<T>>::token_exists(&resource_collection, resource_id),1227 <PalletNft<T>>::token_aux_property((
1228 collection_id,
1229 nft_id,
1230 scope,
1231 resource_id_key.clone()
1232 ))
1233 .is_some(),
1304 Error::<T>::ResourceDoesntExist1234 <Error<T>>::ResourceDoesntExist
1305 );1235 );
13061236
1307 let budget = up_data_structs::budget::Value::new(NESTING_BUDGET);1237 let budget = up_data_structs::budget::Value::new(NESTING_BUDGET);
13101240
1311 let sender = T::CrossAccountId::from_sub(sender);1241 let sender = T::CrossAccountId::from_sub(sender);
1312 if topmost_owner == sender {1242 if topmost_owner == sender {
1313 <PalletNft<T>>::burn(&resource_collection, &sender, resource_id)1243 <PalletNft<T>>::remove_token_aux_property(
1314 .map_err(Self::map_unique_err_to_proxy)?;
1315 } else {
1316 <PalletNft<T>>::set_scoped_token_property(
1317 resource_collection_id,1244 collection_id,
1318 resource_id,1245 nft_id,
1319 PropertyScope::Rmrk,1246 PropertyScope::Rmrk,
1320 Self::rmrk_property(PendingResourceRemoval, &true)?,1247 Self::rmrk_property_key(ResourceId(resource_id))?,
1248 );
1249 } else {
1250 Self::try_mutate_resource_info(collection_id, nft_id, resource_id, |res| {
1251 res.pending_removal = true;
1252
1253 Ok(())
1321 )?;1254 })?;
1322 }1255 }
13231256
1324 Ok(())1257 Ok(())
1325 }1258 }
13261259
1260 fn try_mutate_resource_info(
1261 collection_id: CollectionId,
1262 nft_id: TokenId,
1263 resource_id: RmrkResourceId,
1264 f: impl FnOnce(&mut RmrkResourceInfo) -> DispatchResult,
1265 ) -> DispatchResult {
1266 <PalletNft<T>>::try_mutate_token_aux_property(
1267 collection_id,
1268 nft_id,
1269 PropertyScope::Rmrk,
1270 Self::rmrk_property_key(ResourceId(resource_id))?,
1271 |value| match value {
1272 Some(value) => {
1273 let mut resource_info: RmrkResourceInfo = Self::decode_property(value)?;
1274
1275 f(&mut resource_info)?;
1276
1277 *value = Self::encode_property(&resource_info)?;
1278
1279 Ok(())
1280 }
1281 None => Err(<Error<T>>::ResourceDoesntExist.into()),
1282 },
1283 )
1284 }
1285
1327 fn change_collection_owner(1286 fn change_collection_owner(
1328 collection_id: CollectionId,1287 collection_id: CollectionId,
1329 collection_type: misc::CollectionType,1288 collection_type: misc::CollectionType,
1339 collection.save()1298 collection.save()
1340 }1299 }
13411300
1342 fn check_collection_owner(1301 pub fn check_collection_owner(
1343 collection: &NonfungibleHandle<T>,1302 collection: &NonfungibleHandle<T>,
1344 account: &T::CrossAccountId,1303 account: &T::CrossAccountId,
1345 ) -> DispatchResult {1304 ) -> DispatchResult {
1397 collection_id: CollectionId,1356 collection_id: CollectionId,
1398 key: RmrkProperty,1357 key: RmrkProperty,
1399 ) -> Result<V, DispatchError> {1358 ) -> Result<V, DispatchError> {
1400 Self::decode_property(Self::get_collection_property(collection_id, key)?)1359 Self::decode_property(&Self::get_collection_property(collection_id, key)?)
1401 }1360 }
14021361
1403 pub fn get_collection_type(1362 pub fn get_collection_type(
1404 collection_id: CollectionId,1363 collection_id: CollectionId,
1405 ) -> Result<misc::CollectionType, DispatchError> {1364 ) -> Result<misc::CollectionType, DispatchError> {
1406 Self::get_collection_property_decoded(collection_id, CollectionType)1365 Self::get_collection_property_decoded(collection_id, CollectionType).map_err(|err| {
1407 .map_err(|_| <Error<T>>::CorruptedCollectionType.into())1366 if err != <Error<T>>::CollectionUnknown.into() {
1367 <Error<T>>::CorruptedCollectionType.into()
1368 } else {
1369 err
1370 }
1371 })
1408 }1372 }
14091373
1410 pub fn ensure_collection_type(1374 pub fn ensure_collection_type(
1450 ) -> Result<PropertyValue, DispatchError> {1414 ) -> Result<PropertyValue, DispatchError> {
1451 let nft_property = <PalletNft<T>>::token_properties((collection_id, nft_id))1415 let nft_property = <PalletNft<T>>::token_properties((collection_id, nft_id))
1452 .get(&Self::rmrk_property_key(key)?)1416 .get(&Self::rmrk_property_key(key)?)
1453 .ok_or(<Error<T>>::NoAvailableNftId)? // todo replace with better error?1417 .ok_or(<Error<T>>::RmrkPropertyIsNotFound)?
1454 .clone();1418 .clone();
14551419
1456 Ok(nft_property)1420 Ok(nft_property)
1461 nft_id: TokenId,1425 nft_id: TokenId,
1462 key: RmrkProperty,1426 key: RmrkProperty,
1463 ) -> Result<V, DispatchError> {1427 ) -> Result<V, DispatchError> {
1464 Self::decode_property(Self::get_nft_property(collection_id, nft_id, key)?)1428 Self::decode_property(&Self::get_nft_property(collection_id, nft_id, key)?)
1465 }1429 }
14661430
1467 pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {1431 pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {
modifiedpallets/proxy-rmrk-core/src/misc.rsdiffbeforeafterboth
61#[derive(Encode, Decode, PartialEq, Eq)]61#[derive(Encode, Decode, PartialEq, Eq)]
62pub enum CollectionType {62pub enum CollectionType {
63 Regular,63 Regular,
64 Resource,
65 Base,64 Base,
66}65}
6766
68#[derive(Encode, Decode, PartialEq, Eq)]67#[derive(Encode, Decode, PartialEq, Eq)]
69pub enum NftType {68pub enum NftType {
70 Regular,69 Regular,
71 Resource,
72 FixedPart,70 FixedPart,
73 SlotPart,71 SlotPart,
74 Theme,72 Theme,
75}73}
76
77#[derive(Encode, Decode, PartialEq, Eq)]
78pub enum ResourceType {
79 Basic,
80 Composable,
81 Slot,
82}
8374
modifiedpallets/proxy-rmrk-core/src/property.rsdiffbeforeafterboth
17use super::*;17use super::*;
18use core::convert::AsRef;18use core::convert::AsRef;
19
20const RESOURCE_ID_PREFIX: &str = "rsid-";
1921
20pub enum RmrkProperty<'r> {22pub enum RmrkProperty<'r> {
21 Metadata,23 Metadata,
25 Transferable,27 Transferable,
26 RoyaltyInfo,28 RoyaltyInfo,
27 Equipped,29 Equipped,
28 ResourceCollection,
29 ResourcePriorities,30 ResourcePriorities,
30 ResourceType,31 NextResourceId,
32 ResourceId(RmrkResourceId),
31 PendingNftAccept,33 PendingNftAccept,
32 PendingResourceAccept,
33 PendingResourceRemoval,
34 Parts,34 Parts,
35 Base,35 Base,
36 Src,36 Src,
37 Slot,
38 License,
39 Thumb,
40 EquippedNft,37 EquippedNft,
41 BaseType,38 BaseType,
42 ExternalPartId,39 ExternalPartId,
72 Self::Transferable => key!("transferable"),69 Self::Transferable => key!("transferable"),
73 Self::RoyaltyInfo => key!("royalty-info"),70 Self::RoyaltyInfo => key!("royalty-info"),
74 Self::Equipped => key!("equipped"),71 Self::Equipped => key!("equipped"),
75 Self::ResourceCollection => key!("resource-collection"),
76 Self::ResourcePriorities => key!("resource-priorities"),72 Self::ResourcePriorities => key!("resource-priorities"),
77 Self::ResourceType => key!("resource-type"),73 Self::NextResourceId => key!("next-resource-id"),
74 Self::ResourceId(id) => key!(RESOURCE_ID_PREFIX, id.to_le_bytes()),
78 Self::PendingNftAccept => key!("pending-nft-accept"),75 Self::PendingNftAccept => key!("pending-nft-accept"),
79 Self::PendingResourceAccept => key!("pending-resource-accept"),
80 Self::PendingResourceRemoval => key!("pending-resource-removal"),
81 Self::Parts => key!("parts"),76 Self::Parts => key!("parts"),
82 Self::Base => key!("base"),77 Self::Base => key!("base"),
83 Self::Src => key!("src"),78 Self::Src => key!("src"),
84 Self::Slot => key!("slot"),
85 Self::License => key!("license"),
86 Self::Thumb => key!("thumb"),
87 Self::EquippedNft => key!("equipped-nft"),79 Self::EquippedNft => key!("equipped-nft"),
88 Self::BaseType => key!("base-type"),80 Self::BaseType => key!("base-type"),
89 Self::ExternalPartId => key!("ext-part-id"),81 Self::ExternalPartId => key!("ext-part-id"),
addedpallets/proxy-rmrk-core/src/rpc.rsdiffbeforeafterboth

no changes

modifiedpallets/proxy-rmrk-core/src/weights.rsdiffbeforeafterboth
3//! Autogenerated weights for pallet_proxy_rmrk_core3//! Autogenerated weights for pallet_proxy_rmrk_core
4//!4//!
5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
6//! DATE: 2022-06-14, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2022-06-17, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`
7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10247//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
88
9// Executed Command:9// Executed Command:
19// --template19// --template
20// .maintain/frame-weight-template.hbs20// .maintain/frame-weight-template.hbs
21// --steps=5021// --steps=50
22// --repeat=20022// --repeat=80
23// --heap-pages=409623// --heap-pages=4096
24// --output=./pallets/proxy-rmrk-core/src/weights.rs24// --output=./pallets/proxy-rmrk-core/src/weights.rs
2525
64 // Storage: Common CollectionById (r:0 w:1)64 // Storage: Common CollectionById (r:0 w:1)
65 // Storage: RmrkCore UniqueCollectionId (r:0 w:1)65 // Storage: RmrkCore UniqueCollectionId (r:0 w:1)
66 fn create_collection() -> Weight {66 fn create_collection() -> Weight {
67 (41_277_000 as Weight)67 (42_359_000 as Weight)
68 .saturating_add(T::DbWeight::get().reads(5 as Weight))68 .saturating_add(T::DbWeight::get().reads(5 as Weight))
69 .saturating_add(T::DbWeight::get().writes(8 as Weight))69 .saturating_add(T::DbWeight::get().writes(8 as Weight))
70 }70 }
77 // Storage: Nonfungible TokensBurnt (r:0 w:1)77 // Storage: Nonfungible TokensBurnt (r:0 w:1)
78 // Storage: Common AdminAmount (r:0 w:1)78 // Storage: Common AdminAmount (r:0 w:1)
79 fn destroy_collection() -> Weight {79 fn destroy_collection() -> Weight {
80 (43_371_000 as Weight)80 (45_375_000 as Weight)
81 .saturating_add(T::DbWeight::get().reads(5 as Weight))81 .saturating_add(T::DbWeight::get().reads(5 as Weight))
82 .saturating_add(T::DbWeight::get().writes(6 as Weight))82 .saturating_add(T::DbWeight::get().writes(6 as Weight))
83 }83 }
84 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)84 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
85 // Storage: Common CollectionById (r:1 w:1)85 // Storage: Common CollectionById (r:1 w:1)
86 // Storage: Common CollectionProperties (r:1 w:0)86 // Storage: Common CollectionProperties (r:1 w:0)
87 fn change_collection_issuer() -> Weight {87 fn change_collection_issuer() -> Weight {
88 (21_891_000 as Weight)88 (22_753_000 as Weight)
89 .saturating_add(T::DbWeight::get().reads(3 as Weight))89 .saturating_add(T::DbWeight::get().reads(3 as Weight))
90 .saturating_add(T::DbWeight::get().writes(1 as Weight))90 .saturating_add(T::DbWeight::get().writes(1 as Weight))
91 }91 }
95 // Storage: Nonfungible TokensMinted (r:1 w:0)95 // Storage: Nonfungible TokensMinted (r:1 w:0)
96 // Storage: Nonfungible TokensBurnt (r:1 w:0)96 // Storage: Nonfungible TokensBurnt (r:1 w:0)
97 fn lock_collection() -> Weight {97 fn lock_collection() -> Weight {
98 (23_144_000 as Weight)98 (24_356_000 as Weight)
99 .saturating_add(T::DbWeight::get().reads(5 as Weight))99 .saturating_add(T::DbWeight::get().reads(5 as Weight))
100 .saturating_add(T::DbWeight::get().writes(1 as Weight))100 .saturating_add(T::DbWeight::get().writes(1 as Weight))
101 }101 }
107 // Storage: Nonfungible TokenProperties (r:1 w:1)107 // Storage: Nonfungible TokenProperties (r:1 w:1)
108 // Storage: Nonfungible TokenData (r:0 w:1)108 // Storage: Nonfungible TokenData (r:0 w:1)
109 // Storage: Nonfungible Owned (r:0 w:1)109 // Storage: Nonfungible Owned (r:0 w:1)
110 // Storage: Common CreatedCollectionCount (r:1 w:1)
111 // Storage: Common DestroyedCollectionCount (r:1 w:0)
112 // Storage: System Account (r:2 w:2)
113 // Storage: Common CollectionPropertyPermissions (r:0 w:1)110 // Storage: Nonfungible TokenAuxProperties (r:2 w:2)
114 fn mint_nft(b: u32, ) -> Weight {111 fn mint_nft(b: u32, ) -> Weight {
115 (68_329_000 as Weight)112 (44_853_000 as Weight)
116 // Standard Error: 3_000113 // Standard Error: 2_000
117 .saturating_add((21_470_000 as Weight).saturating_mul(b as Weight))114 .saturating_add((10_721_000 as Weight).saturating_mul(b as Weight))
118 .saturating_add(T::DbWeight::get().reads(12 as Weight))115 .saturating_add(T::DbWeight::get().reads(6 as Weight))
119 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))116 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
120 .saturating_add(T::DbWeight::get().writes(12 as Weight))117 .saturating_add(T::DbWeight::get().writes(5 as Weight))
121 .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))118 .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight)))
122 }119 }
123 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)120 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
124 // Storage: Common CollectionProperties (r:1 w:0)121 // Storage: Common CollectionProperties (r:1 w:0)
132 // Storage: Nonfungible TokenProperties (r:0 w:1)129 // Storage: Nonfungible TokenProperties (r:0 w:1)
133 fn burn_nft(b: u32, ) -> Weight {130 fn burn_nft(b: u32, ) -> Weight {
134 (0 as Weight)131 (0 as Weight)
135 // Standard Error: 959_000132 // Standard Error: 1_590_000
136 .saturating_add((305_872_000 as Weight).saturating_mul(b as Weight))133 .saturating_add((319_825_000 as Weight).saturating_mul(b as Weight))
137 .saturating_add(T::DbWeight::get().reads(9 as Weight))134 .saturating_add(T::DbWeight::get().reads(9 as Weight))
138 .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))135 .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
139 .saturating_add(T::DbWeight::get().writes(6 as Weight))136 .saturating_add(T::DbWeight::get().writes(6 as Weight))
149 // Storage: Nonfungible TokenChildren (r:0 w:1)146 // Storage: Nonfungible TokenChildren (r:0 w:1)
150 // Storage: Nonfungible Owned (r:0 w:2)147 // Storage: Nonfungible Owned (r:0 w:2)
151 fn send() -> Weight {148 fn send() -> Weight {
152 (71_405_000 as Weight)149 (72_576_000 as Weight)
153 .saturating_add(T::DbWeight::get().reads(12 as Weight))150 .saturating_add(T::DbWeight::get().reads(12 as Weight))
154 .saturating_add(T::DbWeight::get().writes(6 as Weight))151 .saturating_add(T::DbWeight::get().writes(6 as Weight))
155 }152 }
163 // Storage: Nonfungible TokenChildren (r:0 w:1)160 // Storage: Nonfungible TokenChildren (r:0 w:1)
164 // Storage: Nonfungible Owned (r:0 w:2)161 // Storage: Nonfungible Owned (r:0 w:2)
165 fn accept_nft() -> Weight {162 fn accept_nft() -> Weight {
166 (79_159_000 as Weight)163 (79_670_000 as Weight)
167 .saturating_add(T::DbWeight::get().reads(15 as Weight))164 .saturating_add(T::DbWeight::get().reads(15 as Weight))
168 .saturating_add(T::DbWeight::get().writes(7 as Weight))165 .saturating_add(T::DbWeight::get().writes(7 as Weight))
169 }166 }
170 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)167 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
171 // Storage: Common CollectionProperties (r:1 w:0)168 // Storage: Common CollectionProperties (r:1 w:0)
172 // Storage: Common CollectionById (r:1 w:0)169 // Storage: Common CollectionById (r:1 w:0)
173 // Storage: Nonfungible TokenProperties (r:1 w:5)
174 // Storage: Nonfungible TokenData (r:5 w:5)170 // Storage: Nonfungible TokenData (r:5 w:5)
171 // Storage: Nonfungible TokenProperties (r:1 w:5)
175 // Storage: Nonfungible TokenChildren (r:9 w:4)172 // Storage: Nonfungible TokenChildren (r:9 w:4)
176 // Storage: Nonfungible TokensBurnt (r:1 w:1)173 // Storage: Nonfungible TokensBurnt (r:1 w:1)
177 // Storage: Nonfungible AccountBalance (r:5 w:5)174 // Storage: Nonfungible AccountBalance (r:5 w:5)
178 // Storage: Nonfungible Allowance (r:5 w:0)175 // Storage: Nonfungible Allowance (r:5 w:0)
179 // Storage: Nonfungible Owned (r:0 w:5)176 // Storage: Nonfungible Owned (r:0 w:5)
180 fn reject_nft() -> Weight {177 fn reject_nft() -> Weight {
181 (238_179_000 as Weight)178 (254_989_000 as Weight)
182 .saturating_add(T::DbWeight::get().reads(29 as Weight))179 .saturating_add(T::DbWeight::get().reads(29 as Weight))
183 .saturating_add(T::DbWeight::get().writes(25 as Weight))180 .saturating_add(T::DbWeight::get().writes(25 as Weight))
184 }181 }
188 // Storage: Nonfungible TokenProperties (r:1 w:1)185 // Storage: Nonfungible TokenProperties (r:1 w:1)
189 // Storage: Nonfungible TokenData (r:5 w:0)186 // Storage: Nonfungible TokenData (r:5 w:0)
190 fn set_property() -> Weight {187 fn set_property() -> Weight {
191 (47_770_000 as Weight)188 (48_651_000 as Weight)
192 .saturating_add(T::DbWeight::get().reads(9 as Weight))189 .saturating_add(T::DbWeight::get().reads(9 as Weight))
193 .saturating_add(T::DbWeight::get().writes(1 as Weight))190 .saturating_add(T::DbWeight::get().writes(1 as Weight))
194 }191 }
198 // Storage: Nonfungible TokenProperties (r:1 w:1)195 // Storage: Nonfungible TokenProperties (r:1 w:1)
199 // Storage: Nonfungible TokenData (r:5 w:0)196 // Storage: Nonfungible TokenData (r:5 w:0)
200 fn set_priority() -> Weight {197 fn set_priority() -> Weight {
201 (46_679_000 as Weight)198 (47_579_000 as Weight)
202 .saturating_add(T::DbWeight::get().reads(9 as Weight))199 .saturating_add(T::DbWeight::get().reads(9 as Weight))
203 .saturating_add(T::DbWeight::get().writes(1 as Weight))200 .saturating_add(T::DbWeight::get().writes(1 as Weight))
204 }201 }
205 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)202 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
206 // Storage: Common CollectionProperties (r:1 w:1)203 // Storage: Common CollectionProperties (r:1 w:0)
207 // Storage: Common CollectionById (r:1 w:1)204 // Storage: Common CollectionById (r:1 w:0)
208 // Storage: Nonfungible TokenData (r:5 w:1)205 // Storage: Nonfungible TokenData (r:5 w:0)
209 // Storage: Nonfungible TokenProperties (r:2 w:2)206 // Storage: Nonfungible TokenProperties (r:1 w:1)
210 // Storage: Common CreatedCollectionCount (r:1 w:1)
211 // Storage: Common DestroyedCollectionCount (r:1 w:0)
212 // Storage: System Account (r:2 w:2)
213 // Storage: Nonfungible TokensMinted (r:1 w:1)207 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
214 // Storage: Nonfungible AccountBalance (r:1 w:1)
215 // Storage: Nonfungible Owned (r:0 w:1)
216 // Storage: Common CollectionPropertyPermissions (r:0 w:1)
217 fn add_basic_resource() -> Weight {208 fn add_basic_resource() -> Weight {
218 (100_770_000 as Weight)209 (55_013_000 as Weight)
219 .saturating_add(T::DbWeight::get().reads(16 as Weight))210 .saturating_add(T::DbWeight::get().reads(10 as Weight))
220 .saturating_add(T::DbWeight::get().writes(12 as Weight))211 .saturating_add(T::DbWeight::get().writes(2 as Weight))
221 }212 }
222 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)213 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
223 // Storage: Common CollectionProperties (r:1 w:1)214 // Storage: Common CollectionProperties (r:1 w:0)
224 // Storage: Common CollectionById (r:1 w:1)215 // Storage: Common CollectionById (r:1 w:0)
225 // Storage: Nonfungible TokenData (r:5 w:1)216 // Storage: Nonfungible TokenData (r:5 w:0)
226 // Storage: Nonfungible TokenProperties (r:2 w:2)217 // Storage: Nonfungible TokenProperties (r:1 w:1)
227 // Storage: Common CreatedCollectionCount (r:1 w:1)
228 // Storage: Common DestroyedCollectionCount (r:1 w:0)
229 // Storage: System Account (r:2 w:2)
230 // Storage: Nonfungible TokensMinted (r:1 w:1)218 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
231 // Storage: Nonfungible AccountBalance (r:1 w:1)
232 // Storage: Nonfungible Owned (r:0 w:1)
233 // Storage: Common CollectionPropertyPermissions (r:0 w:1)
234 fn add_composable_resource() -> Weight {219 fn add_composable_resource() -> Weight {
235 (101_791_000 as Weight)220 (55_184_000 as Weight)
236 .saturating_add(T::DbWeight::get().reads(16 as Weight))221 .saturating_add(T::DbWeight::get().reads(10 as Weight))
237 .saturating_add(T::DbWeight::get().writes(12 as Weight))222 .saturating_add(T::DbWeight::get().writes(2 as Weight))
238 }223 }
239 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)224 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
240 // Storage: Common CollectionProperties (r:1 w:1)225 // Storage: Common CollectionProperties (r:1 w:0)
241 // Storage: Common CollectionById (r:1 w:1)226 // Storage: Common CollectionById (r:1 w:0)
242 // Storage: Nonfungible TokenData (r:5 w:1)227 // Storage: Nonfungible TokenData (r:5 w:0)
243 // Storage: Nonfungible TokenProperties (r:2 w:2)228 // Storage: Nonfungible TokenProperties (r:1 w:1)
244 // Storage: Common CreatedCollectionCount (r:1 w:1)
245 // Storage: Common DestroyedCollectionCount (r:1 w:0)
246 // Storage: System Account (r:2 w:2)
247 // Storage: Nonfungible TokensMinted (r:1 w:1)229 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
248 // Storage: Nonfungible AccountBalance (r:1 w:1)
249 // Storage: Nonfungible Owned (r:0 w:1)
250 // Storage: Common CollectionPropertyPermissions (r:0 w:1)
251 fn add_slot_resource() -> Weight {230 fn add_slot_resource() -> Weight {
252 (101_610_000 as Weight)231 (54_792_000 as Weight)
253 .saturating_add(T::DbWeight::get().reads(16 as Weight))232 .saturating_add(T::DbWeight::get().reads(10 as Weight))
254 .saturating_add(T::DbWeight::get().writes(12 as Weight))233 .saturating_add(T::DbWeight::get().writes(2 as Weight))
255 }234 }
256 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)235 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
257 // Storage: Common CollectionProperties (r:2 w:0)236 // Storage: Common CollectionProperties (r:1 w:0)
258 // Storage: Common CollectionById (r:2 w:0)237 // Storage: Common CollectionById (r:1 w:0)
259 // Storage: Nonfungible TokenProperties (r:1 w:1)238 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
260 // Storage: Nonfungible TokenData (r:6 w:1)239 // Storage: Nonfungible TokenData (r:5 w:0)
261 // Storage: Nonfungible TokenChildren (r:1 w:0)
262 // Storage: Nonfungible TokensBurnt (r:1 w:1)
263 // Storage: Nonfungible AccountBalance (r:1 w:1)
264 // Storage: Nonfungible Allowance (r:1 w:0)
265 // Storage: Nonfungible Owned (r:0 w:1)
266 fn remove_resource() -> Weight {240 fn remove_resource() -> Weight {
267 (80_571_000 as Weight)241 (46_447_000 as Weight)
268 .saturating_add(T::DbWeight::get().reads(16 as Weight))242 .saturating_add(T::DbWeight::get().reads(9 as Weight))
269 .saturating_add(T::DbWeight::get().writes(5 as Weight))243 .saturating_add(T::DbWeight::get().writes(1 as Weight))
270 }244 }
271 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)245 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
272 // Storage: Common CollectionProperties (r:1 w:0)246 // Storage: Common CollectionProperties (r:1 w:0)
273 // Storage: Common CollectionById (r:1 w:0)247 // Storage: Common CollectionById (r:1 w:0)
274 // Storage: Nonfungible TokenData (r:5 w:0)248 // Storage: Nonfungible TokenData (r:5 w:0)
275 // Storage: Nonfungible TokenProperties (r:2 w:1)249 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
276 fn accept_resource() -> Weight {250 fn accept_resource() -> Weight {
277 (54_733_000 as Weight)251 (45_096_000 as Weight)
278 .saturating_add(T::DbWeight::get().reads(10 as Weight))252 .saturating_add(T::DbWeight::get().reads(9 as Weight))
279 .saturating_add(T::DbWeight::get().writes(1 as Weight))253 .saturating_add(T::DbWeight::get().writes(1 as Weight))
280 }254 }
281 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)255 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
282 // Storage: Common CollectionProperties (r:2 w:0)256 // Storage: Common CollectionProperties (r:1 w:0)
283 // Storage: Common CollectionById (r:2 w:0)257 // Storage: Common CollectionById (r:1 w:0)
284 // Storage: Nonfungible TokenData (r:6 w:1)258 // Storage: Nonfungible TokenData (r:5 w:0)
285 // Storage: Nonfungible TokenProperties (r:2 w:1)259 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
286 // Storage: Nonfungible TokenChildren (r:1 w:0)
287 // Storage: Nonfungible TokensBurnt (r:1 w:1)
288 // Storage: Nonfungible AccountBalance (r:1 w:1)
289 // Storage: Nonfungible Allowance (r:1 w:0)
290 // Storage: Nonfungible Owned (r:0 w:1)
291 fn accept_resource_removal() -> Weight {260 fn accept_resource_removal() -> Weight {
292 (84_138_000 as Weight)261 (45_445_000 as Weight)
293 .saturating_add(T::DbWeight::get().reads(17 as Weight))262 .saturating_add(T::DbWeight::get().reads(9 as Weight))
294 .saturating_add(T::DbWeight::get().writes(5 as Weight))263 .saturating_add(T::DbWeight::get().writes(1 as Weight))
295 }264 }
296}265}
297266
306 // Storage: Common CollectionById (r:0 w:1)275 // Storage: Common CollectionById (r:0 w:1)
307 // Storage: RmrkCore UniqueCollectionId (r:0 w:1)276 // Storage: RmrkCore UniqueCollectionId (r:0 w:1)
308 fn create_collection() -> Weight {277 fn create_collection() -> Weight {
309 (41_277_000 as Weight)278 (42_359_000 as Weight)
310 .saturating_add(RocksDbWeight::get().reads(5 as Weight))279 .saturating_add(RocksDbWeight::get().reads(5 as Weight))
311 .saturating_add(RocksDbWeight::get().writes(8 as Weight))280 .saturating_add(RocksDbWeight::get().writes(8 as Weight))
312 }281 }
319 // Storage: Nonfungible TokensBurnt (r:0 w:1)288 // Storage: Nonfungible TokensBurnt (r:0 w:1)
320 // Storage: Common AdminAmount (r:0 w:1)289 // Storage: Common AdminAmount (r:0 w:1)
321 fn destroy_collection() -> Weight {290 fn destroy_collection() -> Weight {
322 (43_371_000 as Weight)291 (45_375_000 as Weight)
323 .saturating_add(RocksDbWeight::get().reads(5 as Weight))292 .saturating_add(RocksDbWeight::get().reads(5 as Weight))
324 .saturating_add(RocksDbWeight::get().writes(6 as Weight))293 .saturating_add(RocksDbWeight::get().writes(6 as Weight))
325 }294 }
326 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)295 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
327 // Storage: Common CollectionById (r:1 w:1)296 // Storage: Common CollectionById (r:1 w:1)
328 // Storage: Common CollectionProperties (r:1 w:0)297 // Storage: Common CollectionProperties (r:1 w:0)
329 fn change_collection_issuer() -> Weight {298 fn change_collection_issuer() -> Weight {
330 (21_891_000 as Weight)299 (22_753_000 as Weight)
331 .saturating_add(RocksDbWeight::get().reads(3 as Weight))300 .saturating_add(RocksDbWeight::get().reads(3 as Weight))
332 .saturating_add(RocksDbWeight::get().writes(1 as Weight))301 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
333 }302 }
337 // Storage: Nonfungible TokensMinted (r:1 w:0)306 // Storage: Nonfungible TokensMinted (r:1 w:0)
338 // Storage: Nonfungible TokensBurnt (r:1 w:0)307 // Storage: Nonfungible TokensBurnt (r:1 w:0)
339 fn lock_collection() -> Weight {308 fn lock_collection() -> Weight {
340 (23_144_000 as Weight)309 (24_356_000 as Weight)
341 .saturating_add(RocksDbWeight::get().reads(5 as Weight))310 .saturating_add(RocksDbWeight::get().reads(5 as Weight))
342 .saturating_add(RocksDbWeight::get().writes(1 as Weight))311 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
343 }312 }
349 // Storage: Nonfungible TokenProperties (r:1 w:1)318 // Storage: Nonfungible TokenProperties (r:1 w:1)
350 // Storage: Nonfungible TokenData (r:0 w:1)319 // Storage: Nonfungible TokenData (r:0 w:1)
351 // Storage: Nonfungible Owned (r:0 w:1)320 // Storage: Nonfungible Owned (r:0 w:1)
352 // Storage: Common CreatedCollectionCount (r:1 w:1)
353 // Storage: Common DestroyedCollectionCount (r:1 w:0)
354 // Storage: System Account (r:2 w:2)
355 // Storage: Common CollectionPropertyPermissions (r:0 w:1)321 // Storage: Nonfungible TokenAuxProperties (r:2 w:2)
356 fn mint_nft(b: u32, ) -> Weight {322 fn mint_nft(b: u32, ) -> Weight {
357 (68_329_000 as Weight)323 (44_853_000 as Weight)
358 // Standard Error: 3_000324 // Standard Error: 2_000
359 .saturating_add((21_470_000 as Weight).saturating_mul(b as Weight))325 .saturating_add((10_721_000 as Weight).saturating_mul(b as Weight))
360 .saturating_add(RocksDbWeight::get().reads(12 as Weight))326 .saturating_add(RocksDbWeight::get().reads(6 as Weight))
361 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))327 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
362 .saturating_add(RocksDbWeight::get().writes(12 as Weight))328 .saturating_add(RocksDbWeight::get().writes(5 as Weight))
363 .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))329 .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(b as Weight)))
364 }330 }
365 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)331 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
366 // Storage: Common CollectionProperties (r:1 w:0)332 // Storage: Common CollectionProperties (r:1 w:0)
374 // Storage: Nonfungible TokenProperties (r:0 w:1)340 // Storage: Nonfungible TokenProperties (r:0 w:1)
375 fn burn_nft(b: u32, ) -> Weight {341 fn burn_nft(b: u32, ) -> Weight {
376 (0 as Weight)342 (0 as Weight)
377 // Standard Error: 959_000343 // Standard Error: 1_590_000
378 .saturating_add((305_872_000 as Weight).saturating_mul(b as Weight))344 .saturating_add((319_825_000 as Weight).saturating_mul(b as Weight))
379 .saturating_add(RocksDbWeight::get().reads(9 as Weight))345 .saturating_add(RocksDbWeight::get().reads(9 as Weight))
380 .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))346 .saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(b as Weight)))
381 .saturating_add(RocksDbWeight::get().writes(6 as Weight))347 .saturating_add(RocksDbWeight::get().writes(6 as Weight))
391 // Storage: Nonfungible TokenChildren (r:0 w:1)357 // Storage: Nonfungible TokenChildren (r:0 w:1)
392 // Storage: Nonfungible Owned (r:0 w:2)358 // Storage: Nonfungible Owned (r:0 w:2)
393 fn send() -> Weight {359 fn send() -> Weight {
394 (71_405_000 as Weight)360 (72_576_000 as Weight)
395 .saturating_add(RocksDbWeight::get().reads(12 as Weight))361 .saturating_add(RocksDbWeight::get().reads(12 as Weight))
396 .saturating_add(RocksDbWeight::get().writes(6 as Weight))362 .saturating_add(RocksDbWeight::get().writes(6 as Weight))
397 }363 }
405 // Storage: Nonfungible TokenChildren (r:0 w:1)371 // Storage: Nonfungible TokenChildren (r:0 w:1)
406 // Storage: Nonfungible Owned (r:0 w:2)372 // Storage: Nonfungible Owned (r:0 w:2)
407 fn accept_nft() -> Weight {373 fn accept_nft() -> Weight {
408 (79_159_000 as Weight)374 (79_670_000 as Weight)
409 .saturating_add(RocksDbWeight::get().reads(15 as Weight))375 .saturating_add(RocksDbWeight::get().reads(15 as Weight))
410 .saturating_add(RocksDbWeight::get().writes(7 as Weight))376 .saturating_add(RocksDbWeight::get().writes(7 as Weight))
411 }377 }
412 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)378 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
413 // Storage: Common CollectionProperties (r:1 w:0)379 // Storage: Common CollectionProperties (r:1 w:0)
414 // Storage: Common CollectionById (r:1 w:0)380 // Storage: Common CollectionById (r:1 w:0)
415 // Storage: Nonfungible TokenProperties (r:1 w:5)
416 // Storage: Nonfungible TokenData (r:5 w:5)381 // Storage: Nonfungible TokenData (r:5 w:5)
382 // Storage: Nonfungible TokenProperties (r:1 w:5)
417 // Storage: Nonfungible TokenChildren (r:9 w:4)383 // Storage: Nonfungible TokenChildren (r:9 w:4)
418 // Storage: Nonfungible TokensBurnt (r:1 w:1)384 // Storage: Nonfungible TokensBurnt (r:1 w:1)
419 // Storage: Nonfungible AccountBalance (r:5 w:5)385 // Storage: Nonfungible AccountBalance (r:5 w:5)
420 // Storage: Nonfungible Allowance (r:5 w:0)386 // Storage: Nonfungible Allowance (r:5 w:0)
421 // Storage: Nonfungible Owned (r:0 w:5)387 // Storage: Nonfungible Owned (r:0 w:5)
422 fn reject_nft() -> Weight {388 fn reject_nft() -> Weight {
423 (238_179_000 as Weight)389 (254_989_000 as Weight)
424 .saturating_add(RocksDbWeight::get().reads(29 as Weight))390 .saturating_add(RocksDbWeight::get().reads(29 as Weight))
425 .saturating_add(RocksDbWeight::get().writes(25 as Weight))391 .saturating_add(RocksDbWeight::get().writes(25 as Weight))
426 }392 }
430 // Storage: Nonfungible TokenProperties (r:1 w:1)396 // Storage: Nonfungible TokenProperties (r:1 w:1)
431 // Storage: Nonfungible TokenData (r:5 w:0)397 // Storage: Nonfungible TokenData (r:5 w:0)
432 fn set_property() -> Weight {398 fn set_property() -> Weight {
433 (47_770_000 as Weight)399 (48_651_000 as Weight)
434 .saturating_add(RocksDbWeight::get().reads(9 as Weight))400 .saturating_add(RocksDbWeight::get().reads(9 as Weight))
435 .saturating_add(RocksDbWeight::get().writes(1 as Weight))401 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
436 }402 }
440 // Storage: Nonfungible TokenProperties (r:1 w:1)406 // Storage: Nonfungible TokenProperties (r:1 w:1)
441 // Storage: Nonfungible TokenData (r:5 w:0)407 // Storage: Nonfungible TokenData (r:5 w:0)
442 fn set_priority() -> Weight {408 fn set_priority() -> Weight {
443 (46_679_000 as Weight)409 (47_579_000 as Weight)
444 .saturating_add(RocksDbWeight::get().reads(9 as Weight))410 .saturating_add(RocksDbWeight::get().reads(9 as Weight))
445 .saturating_add(RocksDbWeight::get().writes(1 as Weight))411 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
446 }412 }
447 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)413 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
448 // Storage: Common CollectionProperties (r:1 w:1)414 // Storage: Common CollectionProperties (r:1 w:0)
449 // Storage: Common CollectionById (r:1 w:1)415 // Storage: Common CollectionById (r:1 w:0)
450 // Storage: Nonfungible TokenData (r:5 w:1)416 // Storage: Nonfungible TokenData (r:5 w:0)
451 // Storage: Nonfungible TokenProperties (r:2 w:2)417 // Storage: Nonfungible TokenProperties (r:1 w:1)
452 // Storage: Common CreatedCollectionCount (r:1 w:1)
453 // Storage: Common DestroyedCollectionCount (r:1 w:0)
454 // Storage: System Account (r:2 w:2)
455 // Storage: Nonfungible TokensMinted (r:1 w:1)418 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
456 // Storage: Nonfungible AccountBalance (r:1 w:1)
457 // Storage: Nonfungible Owned (r:0 w:1)
458 // Storage: Common CollectionPropertyPermissions (r:0 w:1)
459 fn add_basic_resource() -> Weight {419 fn add_basic_resource() -> Weight {
460 (100_770_000 as Weight)420 (55_013_000 as Weight)
461 .saturating_add(RocksDbWeight::get().reads(16 as Weight))421 .saturating_add(RocksDbWeight::get().reads(10 as Weight))
462 .saturating_add(RocksDbWeight::get().writes(12 as Weight))422 .saturating_add(RocksDbWeight::get().writes(2 as Weight))
463 }423 }
464 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)424 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
465 // Storage: Common CollectionProperties (r:1 w:1)425 // Storage: Common CollectionProperties (r:1 w:0)
466 // Storage: Common CollectionById (r:1 w:1)426 // Storage: Common CollectionById (r:1 w:0)
467 // Storage: Nonfungible TokenData (r:5 w:1)427 // Storage: Nonfungible TokenData (r:5 w:0)
468 // Storage: Nonfungible TokenProperties (r:2 w:2)428 // Storage: Nonfungible TokenProperties (r:1 w:1)
469 // Storage: Common CreatedCollectionCount (r:1 w:1)
470 // Storage: Common DestroyedCollectionCount (r:1 w:0)
471 // Storage: System Account (r:2 w:2)
472 // Storage: Nonfungible TokensMinted (r:1 w:1)429 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
473 // Storage: Nonfungible AccountBalance (r:1 w:1)
474 // Storage: Nonfungible Owned (r:0 w:1)
475 // Storage: Common CollectionPropertyPermissions (r:0 w:1)
476 fn add_composable_resource() -> Weight {430 fn add_composable_resource() -> Weight {
477 (101_791_000 as Weight)431 (55_184_000 as Weight)
478 .saturating_add(RocksDbWeight::get().reads(16 as Weight))432 .saturating_add(RocksDbWeight::get().reads(10 as Weight))
479 .saturating_add(RocksDbWeight::get().writes(12 as Weight))433 .saturating_add(RocksDbWeight::get().writes(2 as Weight))
480 }434 }
481 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)435 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
482 // Storage: Common CollectionProperties (r:1 w:1)436 // Storage: Common CollectionProperties (r:1 w:0)
483 // Storage: Common CollectionById (r:1 w:1)437 // Storage: Common CollectionById (r:1 w:0)
484 // Storage: Nonfungible TokenData (r:5 w:1)438 // Storage: Nonfungible TokenData (r:5 w:0)
485 // Storage: Nonfungible TokenProperties (r:2 w:2)439 // Storage: Nonfungible TokenProperties (r:1 w:1)
486 // Storage: Common CreatedCollectionCount (r:1 w:1)
487 // Storage: Common DestroyedCollectionCount (r:1 w:0)
488 // Storage: System Account (r:2 w:2)
489 // Storage: Nonfungible TokensMinted (r:1 w:1)440 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
490 // Storage: Nonfungible AccountBalance (r:1 w:1)
491 // Storage: Nonfungible Owned (r:0 w:1)
492 // Storage: Common CollectionPropertyPermissions (r:0 w:1)
493 fn add_slot_resource() -> Weight {441 fn add_slot_resource() -> Weight {
494 (101_610_000 as Weight)442 (54_792_000 as Weight)
495 .saturating_add(RocksDbWeight::get().reads(16 as Weight))443 .saturating_add(RocksDbWeight::get().reads(10 as Weight))
496 .saturating_add(RocksDbWeight::get().writes(12 as Weight))444 .saturating_add(RocksDbWeight::get().writes(2 as Weight))
497 }445 }
498 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)446 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
499 // Storage: Common CollectionProperties (r:2 w:0)447 // Storage: Common CollectionProperties (r:1 w:0)
500 // Storage: Common CollectionById (r:2 w:0)448 // Storage: Common CollectionById (r:1 w:0)
501 // Storage: Nonfungible TokenProperties (r:1 w:1)449 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
502 // Storage: Nonfungible TokenData (r:6 w:1)450 // Storage: Nonfungible TokenData (r:5 w:0)
503 // Storage: Nonfungible TokenChildren (r:1 w:0)
504 // Storage: Nonfungible TokensBurnt (r:1 w:1)
505 // Storage: Nonfungible AccountBalance (r:1 w:1)
506 // Storage: Nonfungible Allowance (r:1 w:0)
507 // Storage: Nonfungible Owned (r:0 w:1)
508 fn remove_resource() -> Weight {451 fn remove_resource() -> Weight {
509 (80_571_000 as Weight)452 (46_447_000 as Weight)
510 .saturating_add(RocksDbWeight::get().reads(16 as Weight))453 .saturating_add(RocksDbWeight::get().reads(9 as Weight))
511 .saturating_add(RocksDbWeight::get().writes(5 as Weight))454 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
512 }455 }
513 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)456 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
514 // Storage: Common CollectionProperties (r:1 w:0)457 // Storage: Common CollectionProperties (r:1 w:0)
515 // Storage: Common CollectionById (r:1 w:0)458 // Storage: Common CollectionById (r:1 w:0)
516 // Storage: Nonfungible TokenData (r:5 w:0)459 // Storage: Nonfungible TokenData (r:5 w:0)
517 // Storage: Nonfungible TokenProperties (r:2 w:1)460 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
518 fn accept_resource() -> Weight {461 fn accept_resource() -> Weight {
519 (54_733_000 as Weight)462 (45_096_000 as Weight)
520 .saturating_add(RocksDbWeight::get().reads(10 as Weight))463 .saturating_add(RocksDbWeight::get().reads(9 as Weight))
521 .saturating_add(RocksDbWeight::get().writes(1 as Weight))464 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
522 }465 }
523 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)466 // Storage: RmrkCore UniqueCollectionId (r:1 w:0)
524 // Storage: Common CollectionProperties (r:2 w:0)467 // Storage: Common CollectionProperties (r:1 w:0)
525 // Storage: Common CollectionById (r:2 w:0)468 // Storage: Common CollectionById (r:1 w:0)
526 // Storage: Nonfungible TokenData (r:6 w:1)469 // Storage: Nonfungible TokenData (r:5 w:0)
527 // Storage: Nonfungible TokenProperties (r:2 w:1)470 // Storage: Nonfungible TokenAuxProperties (r:1 w:1)
528 // Storage: Nonfungible TokenChildren (r:1 w:0)
529 // Storage: Nonfungible TokensBurnt (r:1 w:1)
530 // Storage: Nonfungible AccountBalance (r:1 w:1)
531 // Storage: Nonfungible Allowance (r:1 w:0)
532 // Storage: Nonfungible Owned (r:0 w:1)
533 fn accept_resource_removal() -> Weight {471 fn accept_resource_removal() -> Weight {
534 (84_138_000 as Weight)472 (45_445_000 as Weight)
535 .saturating_add(RocksDbWeight::get().reads(17 as Weight))473 .saturating_add(RocksDbWeight::get().reads(9 as Weight))
536 .saturating_add(RocksDbWeight::get().writes(5 as Weight))474 .saturating_add(RocksDbWeight::get().writes(1 as Weight))
537 }475 }
538}476}
539477
addedpallets/proxy-rmrk-equip/src/benchmarking.rsdiffbeforeafterboth

no changes

modifiedpallets/proxy-rmrk-equip/src/lib.rsdiffbeforeafterboth
22use up_data_structs::*;22use up_data_structs::*;
23use pallet_common::{Pallet as PalletCommon, Error as CommonError};23use pallet_common::{Pallet as PalletCommon, Error as CommonError};
24use pallet_rmrk_core::{24use pallet_rmrk_core::{
25 Pallet as PalletCore,25 Pallet as PalletCore, Error as CoreError,
26 misc::{self, *},26 misc::{self, *},
27 property::RmrkProperty::*,27 property::RmrkProperty::*,
28};28};
29use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle};29use pallet_nonfungible::{Pallet as PalletNft, NonfungibleHandle};
30use pallet_evm::account::CrossAccountId;30use pallet_evm::account::CrossAccountId;
31use weights::WeightInfo;
3132
32pub use pallet::*;33pub use pallet::*;
34
35#[cfg(feature = "runtime-benchmarks")]
36pub mod benchmarking;
37pub mod rpc;
38pub mod weights;
39
40pub type SelfWeightOf<T> = <T as Config>::WeightInfo;
3341
34#[frame_support::pallet]42#[frame_support::pallet]
35pub mod pallet {43pub mod pallet {
38 #[pallet::config]46 #[pallet::config]
39 pub trait Config: frame_system::Config + pallet_rmrk_core::Config {47 pub trait Config: frame_system::Config + pallet_rmrk_core::Config {
40 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;48 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
49 type WeightInfo: WeightInfo;
41 }50 }
4251
43 #[pallet::storage]52 #[pallet::storage]
61 issuer: T::AccountId,70 issuer: T::AccountId,
62 base_id: RmrkBaseId,71 base_id: RmrkBaseId,
63 },72 },
73 EquippablesUpdated {
74 base_id: RmrkBaseId,
75 slot_id: RmrkSlotId,
76 },
64 }77 }
6578
66 #[pallet::error]79 #[pallet::error]
70 NoAvailablePartId,83 NoAvailablePartId,
71 BaseDoesntExist,84 BaseDoesntExist,
72 NeedsDefaultThemeFirst,85 NeedsDefaultThemeFirst,
86 PartDoesntExist,
87 NoEquippableOnFixedPart,
73 }88 }
7489
75 #[pallet::call]90 #[pallet::call]
83 /// - symbol: arbitrary client-chosen symbol98 /// - symbol: arbitrary client-chosen symbol
84 /// - parts: array of Fixed and Slot parts composing the base, confined in length by99 /// - parts: array of Fixed and Slot parts composing the base, confined in length by
85 /// RmrkPartsLimit100 /// RmrkPartsLimit
101 #[transactional]
86 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]102 #[pallet::weight(<SelfWeightOf<T>>::create_base(parts.len() as u32))]
87 #[transactional]
88 pub fn create_base(103 pub fn create_base(
89 origin: OriginFor<T>,104 origin: OriginFor<T>,
90 base_type: RmrkString,105 base_type: RmrkString,
91 symbol: RmrkString,106 symbol: RmrkBaseSymbol,
92 parts: BoundedVec<RmrkPartType, RmrkPartsLimit>,107 parts: BoundedVec<RmrkPartType, RmrkPartsLimit>,
93 ) -> DispatchResult {108 ) -> DispatchResult {
94 let sender = ensure_signed(origin)?;109 let sender = ensure_signed(origin)?;
125 let collection = <PalletCore<T>>::get_nft_collection(collection_id)?;140 let collection = <PalletCore<T>>::get_nft_collection(collection_id)?;
126141
127 for part in parts {142 for part in parts {
128 let part_id = part.id();
129 let part_token_id = Self::create_part(&cross_sender, &collection, part)?;143 Self::create_part(&cross_sender, &collection, part)?;
130
131 <InernalPartId<T>>::insert(collection_id, part_id, part_token_id);
132
133 <PalletNft<T>>::set_scoped_token_property(
134 collection_id,
135 part_token_id,
136 PropertyScope::Rmrk,
137 <PalletCore<T>>::rmrk_property(ExternalPartId, &part_id)?,
138 )?;
139 }144 }
140145
141 Self::deposit_event(Event::BaseCreated {146 Self::deposit_event(Event::BaseCreated {
159 /// - key: arbitrary BoundedString, defined by client164 /// - key: arbitrary BoundedString, defined by client
160 /// - value: arbitrary BoundedString, defined by client165 /// - value: arbitrary BoundedString, defined by client
161 /// - inherit: optional bool166 /// - inherit: optional bool
167 #[transactional]
162 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]168 #[pallet::weight(<SelfWeightOf<T>>::theme_add(theme.properties.len() as u32))]
163 #[transactional]
164 pub fn theme_add(169 pub fn theme_add(
165 origin: OriginFor<T>,170 origin: OriginFor<T>,
166 base_id: RmrkBaseId,171 base_id: RmrkBaseId,
167 theme: RmrkTheme,172 theme: RmrkBoundedTheme,
168 ) -> DispatchResult {173 ) -> DispatchResult {
169 let sender = ensure_signed(origin)?;174 let sender = ensure_signed(origin)?;
170175
173178
174 let collection_id: CollectionId = base_id.into();179 let collection_id: CollectionId = base_id.into();
175180
176 let collection = <PalletCore<T>>::get_typed_nft_collection(181 let collection = Self::get_base(collection_id)?;
177 collection_id,
178 misc::CollectionType::Base,
179 )
180 .map_err(|_| <Error<T>>::BaseDoesntExist)?;
181 collection.check_is_external()?;
182182
183 if theme.name.as_slice() == b"default" {183 if theme.name.as_slice() == b"default" {
184 <BaseHasDefaultTheme<T>>::insert(collection_id, true);184 <BaseHasDefaultTheme<T>>::insert(collection_id, true);
214 Ok(())214 Ok(())
215 }215 }
216
217 #[transactional]
218 #[pallet::weight(<SelfWeightOf<T>>::equippable())]
219 pub fn equippable(
220 origin: OriginFor<T>,
221 base_id: RmrkBaseId,
222 slot_id: RmrkSlotId,
223 equippables: RmrkEquippableList,
224 ) -> DispatchResult {
225 let sender = ensure_signed(origin)?;
226
227 let base_collection_id = base_id.into();
228 let collection = Self::get_base(base_collection_id)?;
229
230 <PalletCore<T>>::check_collection_owner(
231 &collection,
232 &T::CrossAccountId::from_sub(sender),
233 )
234 .map_err(|err| {
235 if err == <CoreError<T>>::NoPermission.into() {
236 <Error<T>>::PermissionError.into()
237 } else {
238 err
239 }
240 })?;
241
242 let part_id = Self::internal_part_id(base_collection_id, slot_id)
243 .ok_or(<Error<T>>::PartDoesntExist)?;
244
245 let nft_type = <PalletCore<T>>::get_nft_type(base_collection_id, part_id)
246 .map_err(|_| <Error<T>>::PartDoesntExist)?;
247
248 match nft_type {
249 NftType::Regular | NftType::Theme => return Err(<Error<T>>::PermissionError.into()),
250 NftType::FixedPart => return Err(<Error<T>>::NoEquippableOnFixedPart.into()),
251 NftType::SlotPart => {
252 <PalletNft<T>>::set_scoped_token_property(
253 base_collection_id,
254 part_id,
255 PropertyScope::Rmrk,
256 <PalletCore<T>>::rmrk_property(EquippableList, &equippables)?,
257 )?;
258 }
259 }
260
261 Self::deposit_event(Event::EquippablesUpdated { base_id, slot_id });
262
263 Ok(())
264 }
216 }265 }
217}266}
218267
221 sender: &T::CrossAccountId,270 sender: &T::CrossAccountId,
222 collection: &NonfungibleHandle<T>,271 collection: &NonfungibleHandle<T>,
223 part: RmrkPartType,272 part: RmrkPartType,
224 ) -> Result<TokenId, DispatchError> {273 ) -> DispatchResult {
225 let owner = sender;274 let owner = sender;
226275
276 let part_id = part.id();
227 let src = part.src();277 let src = part.src();
228 let z_index = part.z_index();278 let z_index = part.z_index();
229279
232 RmrkPartType::SlotPart(_) => NftType::SlotPart,282 RmrkPartType::SlotPart(_) => NftType::SlotPart,
233 };283 };
234284
235 let token_id = <PalletCore<T>>::create_nft(285 let token_id = match Self::internal_part_id(collection.id, part_id) {
286 Some(token_id) => token_id,
287 None => {
288 let token_id =
289 <PalletCore<T>>::create_nft(sender, owner, collection, [].into_iter())
290 .map_err(|err| match err {
291 DispatchError::Arithmetic(_) => <Error<T>>::NoAvailablePartId.into(),
292 err => err,
293 })?;
294
295 <InernalPartId<T>>::insert(collection.id, part_id, token_id);
296
297 <PalletNft<T>>::set_scoped_token_property(
298 collection.id,
299 token_id,
300 PropertyScope::Rmrk,
301 <PalletCore<T>>::rmrk_property(ExternalPartId, &part_id)?,
302 )?;
303
304 token_id
305 }
306 };
307
308 <PalletNft<T>>::set_scoped_token_properties(
236 sender,309 collection.id,
237 owner,310 token_id,
238 collection,311 PropertyScope::Rmrk,
239 [312 [
240 <PalletCore<T>>::rmrk_property(TokenType, &nft_type)?,313 <PalletCore<T>>::rmrk_property(TokenType, &nft_type)?,
241 <PalletCore<T>>::rmrk_property(Src, &src)?,314 <PalletCore<T>>::rmrk_property(Src, &src)?,
242 <PalletCore<T>>::rmrk_property(ZIndex, &z_index)?,315 <PalletCore<T>>::rmrk_property(ZIndex, &z_index)?,
243 ]316 ]
244 .into_iter(),317 .into_iter(),
245 )
246 .map_err(|err| match err {
247 DispatchError::Arithmetic(_) => <Error<T>>::NoAvailablePartId.into(),
248 err => err,
249 })?;318 )?;
250319
251 if let RmrkPartType::SlotPart(part) = part {320 if let RmrkPartType::SlotPart(part) = part {
252 <PalletNft<T>>::set_scoped_token_property(321 <PalletNft<T>>::set_scoped_token_property(
257 )?;326 )?;
258 }327 }
259328
260 Ok(token_id)329 Ok(())
261 }330 }
331
332 fn get_base(base_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {
333 let collection =
334 <PalletCore<T>>::get_typed_nft_collection(base_id, misc::CollectionType::Base)
335 .map_err(|err| {
336 if err == <CoreError<T>>::CollectionUnknown.into() {
337 <Error<T>>::BaseDoesntExist.into()
338 } else {
339 err
340 }
341 })?;
342 collection.check_is_external()?;
343
344 Ok(collection)
345 }
262}346}
263347
addedpallets/proxy-rmrk-equip/src/rpc.rsdiffbeforeafterboth

no changes

addedpallets/proxy-rmrk-equip/src/weights.rsdiffbeforeafterboth

no changes

modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
39// RMRK39// RMRK
40use rmrk_traits::{40use rmrk_traits::{
41 CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme, ThemeProperty,41 CollectionInfo, NftInfo, ResourceInfo, PropertyInfo, BaseInfo, PartType, Theme, ThemeProperty,
42 ResourceTypes, BasicResource, ComposableResource, SlotResource,42 ResourceTypes, BasicResource, ComposableResource, SlotResource, EquippableList,
43};43};
44pub use rmrk_traits::{44pub use rmrk_traits::{
45 primitives::{45 primitives::{
46 CollectionId as RmrkCollectionId, NftId as RmrkNftId, BaseId as RmrkBaseId,46 CollectionId as RmrkCollectionId, NftId as RmrkNftId, BaseId as RmrkBaseId,
47 PartId as RmrkPartId, ResourceId as RmrkResourceId,47 SlotId as RmrkSlotId, PartId as RmrkPartId, ResourceId as RmrkResourceId,
48 },48 },
49 NftChild as RmrkNftChild, AccountIdOrCollectionNftTuple as RmrkAccountIdOrCollectionNftTuple,49 NftChild as RmrkNftChild, AccountIdOrCollectionNftTuple as RmrkAccountIdOrCollectionNftTuple,
50 FixedPart as RmrkFixedPart, SlotPart as RmrkSlotPart, EquippableList as RmrkEquippableList,50 FixedPart as RmrkFixedPart, SlotPart as RmrkSlotPart,
51};51};
5252
53mod bounded;53mod bounded;
104pub const MAX_PROPERTY_VALUE_LENGTH: u32 = 32768;104pub const MAX_PROPERTY_VALUE_LENGTH: u32 = 32768;
105pub const MAX_PROPERTIES_PER_ITEM: u32 = 64;105pub const MAX_PROPERTIES_PER_ITEM: u32 = 64;
106
107pub const MAX_AUX_PROPERTY_VALUE_LENGTH: u32 = 2048;
106108
107pub const MAX_COLLECTION_PROPERTIES_SIZE: u32 = 40960;109pub const MAX_COLLECTION_PROPERTIES_SIZE: u32 = 40960;
108pub const MAX_TOKEN_PROPERTIES_SIZE: u32 = 32768;110pub const MAX_TOKEN_PROPERTIES_SIZE: u32 = 32768;
654 }656 }
655}657}
658
659pub type BoundedBytes<S> = BoundedVec<u8, S>;
660
661pub type AuxPropertyValue = BoundedBytes<ConstU32<MAX_AUX_PROPERTY_VALUE_LENGTH>>;
656662
657pub type PropertyKey = BoundedVec<u8, ConstU32<MAX_PROPERTY_KEY_LENGTH>>;663pub type PropertyKey = BoundedBytes<ConstU32<MAX_PROPERTY_KEY_LENGTH>>;
658pub type PropertyValue = BoundedVec<u8, ConstU32<MAX_PROPERTY_VALUE_LENGTH>>;664pub type PropertyValue = BoundedBytes<ConstU32<MAX_PROPERTY_VALUE_LENGTH>>;
659665
660#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]666#[derive(Encode, Decode, TypeInfo, Debug, MaxEncodedLen, PartialEq, Clone)]
661#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]667#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
715 EmptyPropertyKey,721 EmptyPropertyKey,
716}722}
717723
718#[derive(Clone, Copy)]724#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq, Clone, Copy)]
719pub enum PropertyScope {725pub enum PropertyScope {
720 None,726 None,
721 Rmrk,727 Rmrk,
944 #[derive(PartialEq)]950 #[derive(PartialEq)]
945 pub const RmrkCollectionSymbolLimit: u32 = MAX_TOKEN_PREFIX_LENGTH;951 pub const RmrkCollectionSymbolLimit: u32 = MAX_TOKEN_PREFIX_LENGTH;
946 #[derive(PartialEq)]952 #[derive(PartialEq)]
947 pub const RmrkResourceSymbolLimit: u32 = MAX_TOKEN_PREFIX_LENGTH;953 pub const RmrkResourceSymbolLimit: u32 = 10;
954 #[derive(PartialEq)]
955 pub const RmrkBaseSymbolLimit: u32 = MAX_TOKEN_PREFIX_LENGTH;
948 #[derive(PartialEq)]956 #[derive(PartialEq)]
949 pub const RmrkKeyLimit: u32 = 32;957 pub const RmrkKeyLimit: u32 = 32;
950 #[derive(PartialEq)]958 #[derive(PartialEq)]
951 pub const RmrkValueLimit: u32 = 256;959 pub const RmrkValueLimit: u32 = 256;
952 #[derive(PartialEq)]960 #[derive(PartialEq)]
953 pub const RmrkMaxCollectionsEquippablePerPart: u32 = 100;961 pub const RmrkMaxCollectionsEquippablePerPart: u32 = 100;
954 #[derive(PartialEq)]962 #[derive(PartialEq)]
963 pub const MaxPropertiesPerTheme: u32 = 5;
964 #[derive(PartialEq)]
955 pub const RmrkPartsLimit: u32 = 25;965 pub const RmrkPartsLimit: u32 = 25;
956 #[derive(PartialEq)]966 #[derive(PartialEq)]
957 pub const RmrkMaxPriorities: u32 = 25;967 pub const RmrkMaxPriorities: u32 = 25;
977pub type RmrkResourceInfo = ResourceInfo<RmrkString, RmrkBoundedParts>;987pub type RmrkResourceInfo = ResourceInfo<RmrkString, RmrkBoundedParts>;
978pub type RmrkPropertyInfo = PropertyInfo<RmrkKeyString, RmrkValueString>;988pub type RmrkPropertyInfo = PropertyInfo<RmrkKeyString, RmrkValueString>;
979pub type RmrkBaseInfo<AccountId> = BaseInfo<AccountId, RmrkString>;989pub type RmrkBaseInfo<AccountId> = BaseInfo<AccountId, RmrkString>;
980pub type RmrkPartType =990pub type BoundedEquippableCollectionIds =
981 PartType<RmrkString, BoundedVec<RmrkCollectionId, RmrkMaxCollectionsEquippablePerPart>>;991 BoundedVec<RmrkCollectionId, RmrkMaxCollectionsEquippablePerPart>;
992pub type RmrkPartType = PartType<RmrkString, BoundedEquippableCollectionIds>;
993pub type RmrkEquippableList = EquippableList<BoundedEquippableCollectionIds>;
982pub type RmrkThemeProperty = ThemeProperty<RmrkString>;994pub type RmrkThemeProperty = ThemeProperty<RmrkString>;
983pub type RmrkTheme = Theme<RmrkString, Vec<RmrkThemeProperty>>;995pub type RmrkTheme = Theme<RmrkString, Vec<RmrkThemeProperty>>;
996pub type RmrkBoundedTheme = Theme<RmrkString, BoundedVec<RmrkThemeProperty, MaxPropertiesPerTheme>>;
984pub type RmrkResourceTypes = ResourceTypes<RmrkString, RmrkBoundedParts>;997pub type RmrkResourceTypes = ResourceTypes<RmrkString, RmrkBoundedParts>;
985998
986pub type RmrkBasicResource = BasicResource<RmrkString>;999pub type RmrkBasicResource = BasicResource<RmrkString>;
9891002
990pub type RmrkString = BoundedVec<u8, RmrkStringLimit>;1003pub type RmrkString = BoundedVec<u8, RmrkStringLimit>;
991pub type RmrkCollectionSymbol = BoundedVec<u8, RmrkCollectionSymbolLimit>;1004pub type RmrkCollectionSymbol = BoundedVec<u8, RmrkCollectionSymbolLimit>;
1005pub type RmrkBaseSymbol = BoundedVec<u8, RmrkBaseSymbolLimit>;
992pub type RmrkKeyString = BoundedVec<u8, RmrkKeyLimit>;1006pub type RmrkKeyString = BoundedVec<u8, RmrkKeyLimit>;
993pub type RmrkValueString = BoundedVec<u8, RmrkValueLimit>;1007pub type RmrkValueString = BoundedVec<u8, RmrkValueLimit>;
994pub type RmrkBoundedResource = BoundedVec<u8, RmrkResourceSymbolLimit>;1008pub type RmrkBoundedResource = BoundedVec<u8, RmrkResourceSymbolLimit>;
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
455 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);455 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);
456 list_benchmark!(list, extra, pallet_unique_scheduler, Scheduler);456 list_benchmark!(list, extra, pallet_unique_scheduler, Scheduler);
457
458 #[cfg(not(feature = "unique-runtime"))]
459 list_benchmark!(list, extra, pallet_proxy_rmrk_core, RmrkCore);
460
461 #[cfg(not(feature = "unique-runtime"))]
462 list_benchmark!(list, extra, pallet_proxy_rmrk_equip, RmrkEquip);
463
457 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);464 // list_benchmark!(list, extra, pallet_evm_coder_substrate, EvmCoderSubstrate);
458465
499 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);506 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);
500 add_benchmark!(params, batches, pallet_unique_scheduler, Scheduler);507 add_benchmark!(params, batches, pallet_unique_scheduler, Scheduler);
508
509 #[cfg(not(feature = "unique-runtime"))]
510 add_benchmark!(params, batches, pallet_proxy_rmrk_core, RmrkCore);
511
512 #[cfg(not(feature = "unique-runtime"))]
513 add_benchmark!(params, batches, pallet_proxy_rmrk_equip, RmrkEquip);
514
501 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);515 // add_benchmark!(params, batches, pallet_evm_coder_substrate, EvmCoderSubstrate);
502516
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
34 'pallet-refungible/runtime-benchmarks',34 'pallet-refungible/runtime-benchmarks',
35 'pallet-nonfungible/runtime-benchmarks',35 'pallet-nonfungible/runtime-benchmarks',
36 'pallet-proxy-rmrk-core/runtime-benchmarks',36 'pallet-proxy-rmrk-core/runtime-benchmarks',
37 'pallet-proxy-rmrk-equip/runtime-benchmarks',
37 'pallet-unique/runtime-benchmarks',38 'pallet-unique/runtime-benchmarks',
38 'pallet-inflation/runtime-benchmarks',39 'pallet-inflation/runtime-benchmarks',
39 'pallet-unique-scheduler/runtime-benchmarks',40 'pallet-unique-scheduler/runtime-benchmarks',
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
74 CollectionStats, RpcCollection,74 CollectionStats, RpcCollection,
75 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},75 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},
76 TokenChild, RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo,76 TokenChild, RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo,
77 RmrkBaseInfo, RmrkPartType, RmrkTheme, RmrkThemeName, RmrkThemeProperty, RmrkCollectionId,77 RmrkBaseInfo, RmrkPartType, RmrkTheme, RmrkThemeName, RmrkCollectionId, RmrkNftId,
78 RmrkNftId, RmrkAccountIdOrCollectionNftTuple, RmrkNftChild, RmrkPropertyKey, RmrkResourceTypes,78 RmrkNftChild, RmrkPropertyKey, RmrkResourceId, RmrkBaseId,
79 RmrkBasicResource, RmrkComposableResource, RmrkSlotResource, RmrkResourceId, RmrkBaseId,
80 RmrkFixedPart, RmrkSlotPart, RmrkString,
81};79};
8280
83// use pallet_contracts::weights::WeightInfo;81// use pallet_contracts::weights::WeightInfo;
924}922}
925923
926impl pallet_proxy_rmrk_equip::Config for Runtime {924impl pallet_proxy_rmrk_equip::Config for Runtime {
925 type WeightInfo = pallet_proxy_rmrk_equip::weights::SubstrateWeight<Self>;
927 type Event = Event;926 type Event = Event;
928}927}
929928
1330 RmrkTheme1329 RmrkTheme
1331 > for Runtime {1330 > for Runtime {
1332 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {1331 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {
1333 Ok(RmrkCore::last_collection_idx())1332 pallet_proxy_rmrk_core::rpc::last_collection_idx::<Runtime>()
1334 }1333 }
13351334
1336 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {1335 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
1337 use pallet_proxy_rmrk_core::{RmrkProperty, misc::CollectionType};1336 pallet_proxy_rmrk_core::rpc::collection_by_id::<Runtime>(collection_id)
1338 use pallet_common::CommonCollectionOperations;
1339
1340 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(collection_id, CollectionType::Regular) {
1341 Ok(c) => c,
1342 Err(_) => return Ok(None),
1343 };
1344
1345 let nfts_count = collection.total_supply();
1346
1347 Ok(Some(RmrkCollectionInfo {
1348 issuer: collection.owner.clone(),
1349 metadata: RmrkCore::get_collection_property_decoded(collection_id, RmrkProperty::Metadata)?,
1350 max: collection.limits.token_limit,
1351 symbol: RmrkCore::rebind(&collection.token_prefix)?,
1352 nfts_count
1353 }))
1354 }1337 }
13551338
1356 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {1339 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {
1357 use up_data_structs::mapping::TokenAddressMapping;
1358 use pallet_proxy_rmrk_core::{RmrkProperty, misc::CollectionType};1340 pallet_proxy_rmrk_core::rpc::nft_by_id::<Runtime>(collection_id, nft_by_id)
1359 use pallet_common::CommonCollectionOperations;
1360
1361 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(collection_id, CollectionType::Regular) {
1362 Ok(c) => c,
1363 Err(_) => return Ok(None),
1364 };
1365
1366 let nft_id = TokenId(nft_by_id);
1367 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(None); }
1368
1369 let owner = match collection.token_owner(nft_id) {
1370 Some(owner) => match <Runtime as pallet_common::Config>::CrossTokenAddressMapping::address_to_token(&owner) {
1371 Some((col, tok)) => {
1372 let rmrk_collection = RmrkCore::rmrk_collection_id(col)?;
1373
1374 RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(rmrk_collection, tok.0)
1375 }
1376 None => RmrkAccountIdOrCollectionNftTuple::AccountId(owner.as_sub().clone())
1377 },
1378 None => return Ok(None)
1379 };
1380
1381 Ok(Some(RmrkInstanceInfo {
1382 owner: owner,
1383 royalty: RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::RoyaltyInfo)?,
1384 metadata: RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::Metadata)?,
1385 equipped: RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::Equipped)?,
1386 pending: RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::PendingNftAccept)?,
1387 }))
1388 }1341 }
13891342
1390 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {1343 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
1391 use pallet_proxy_rmrk_core::{RmrkProperty, misc::CollectionType};1344 pallet_proxy_rmrk_core::rpc::account_tokens::<Runtime>(account_id, collection_id)
1392 use pallet_common::CommonCollectionOperations;
1393
1394 let cross_account_id = CrossAccountId::from_sub(account_id);
1395
1396 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(collection_id, CollectionType::Regular) {
1397 Ok(c) => c,
1398 Err(_) => return Ok(Vec::new()),
1399 };
1400
1401 let tokens = collection.account_tokens(cross_account_id)
1402 .into_iter()
1403 .filter(|token| {
1404 let is_pending = RmrkCore::get_nft_property_decoded(
1405 collection_id,
1406 *token,
1407 RmrkProperty::PendingNftAccept
1408 ).unwrap_or(true);
1409
1410 !is_pending
1411 })
1412 .map(|token| token.0)
1413 .collect();
1414
1415 Ok(tokens)
1416 }1345 }
14171346
1418 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {1347 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
1419 use pallet_proxy_rmrk_core::RmrkProperty;1348 pallet_proxy_rmrk_core::rpc::nft_children::<Runtime>(collection_id, nft_id)
1420
1421 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1422 Ok(id) => id,
1423 Err(_) => return Ok(Vec::new())
1424 };
1425 let nft_id = TokenId(nft_id);
1426 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(Vec::new()); }
1427
1428 Ok(
1429 pallet_nonfungible::TokenChildren::<Runtime>::iter_prefix((collection_id, nft_id))
1430 .filter_map(|((child_collection, child_token), _)| {
1431 let is_pending = RmrkCore::get_nft_property_decoded(
1432 child_collection,
1433 child_token,
1434 RmrkProperty::PendingNftAccept
1435 ).ok()?;
1436
1437 if is_pending {
1438 return None;
1439 }
1440
1441 let rmrk_child_collection = RmrkCore::rmrk_collection_id(
1442 child_collection
1443 ).ok()?;
1444
1445 Some(RmrkNftChild {
1446 collection_id: rmrk_child_collection,
1447 nft_id: child_token.0,
1448 })
1449 }).collect()
1450 )
1451 }1349 }
14521350
1453 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {1351 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
1454 use pallet_proxy_rmrk_core::misc::CollectionType;1352 pallet_proxy_rmrk_core::rpc::collection_properties::<Runtime>(collection_id, filter_keys)
1455
1456 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1457 Ok(id) => id,
1458 Err(_) => return Ok(Vec::new())
1459 };
1460 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() {
1461 return Ok(Vec::new());
1462 }
1463
1464 let properties = RmrkCore::filter_user_properties(
1465 collection_id,
1466 /* token_id = */ None,
1467 filter_keys,
1468 |key, value| RmrkPropertyInfo {
1469 key,
1470 value
1471 }
1472 )?;
1473
1474 Ok(properties)
1475 }1353 }
14761354
1477 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {1355 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
1478 use pallet_proxy_rmrk_core::misc::NftType;1356 pallet_proxy_rmrk_core::rpc::nft_properties::<Runtime>(collection_id, nft_id, filter_keys)
1479
1480 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1481 Ok(id) => id,
1482 Err(_) => return Ok(Vec::new())
1483 };
1484 let token_id = TokenId(nft_id);
1485
1486 if RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Regular).is_err() {
1487 return Ok(Vec::new());
1488 }
1489
1490 let properties = RmrkCore::filter_user_properties(
1491 collection_id,
1492 Some(token_id),
1493 filter_keys,
1494 |key, value| RmrkPropertyInfo {
1495 key,
1496 value
1497 }
1498 )?;
1499
1500 Ok(properties)
1501 }1357 }
15021358
1503 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {1359 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
1504 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, ResourceType}};1360 pallet_proxy_rmrk_core::rpc::nft_resources::<Runtime>(collection_id, nft_id)
1505 use pallet_common::CommonCollectionOperations;
1506
1507 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1508 Ok(id) => id,
1509 Err(_) => return Ok(Vec::new())
1510 };
1511 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() { return Ok(Vec::new()); }
1512
1513 let nft_id = TokenId(nft_id);
1514 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Regular).is_err() { return Ok(Vec::new()); }
1515
1516 let res_collection_id: Option<CollectionId> = RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::ResourceCollection)?;
1517
1518 let res_collection_id = match res_collection_id {
1519 Some(id) => id,
1520 None => return Ok(Vec::new())
1521 };
1522
1523 let resource_collection = RmrkCore::get_typed_nft_collection(res_collection_id, CollectionType::Resource)?;
1524
1525 let resources = resource_collection
1526 .collection_tokens()
1527 .iter()
1528 .filter_map(|res_id| Some(RmrkResourceInfo {
1529 id: res_id.0,
1530 pending: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::PendingResourceAccept).ok()?,
1531 pending_removal: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::PendingResourceRemoval).ok()?,
1532 resource: match RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::ResourceType).ok()? {
1533 ResourceType::Basic => RmrkResourceTypes::Basic(RmrkBasicResource {
1534 src: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Src).ok()?,
1535 metadata: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Metadata).ok()?,
1536 license: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::License).ok()?,
1537 thumb: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Thumb).ok()?,
1538 }),
1539 ResourceType::Composable => RmrkResourceTypes::Composable(RmrkComposableResource {
1540 parts: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Parts).ok()?,
1541 base: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Base).ok()?,
1542 src: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Src).ok()?,
1543 metadata: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Metadata).ok()?,
1544 license: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::License).ok()?,
1545 thumb: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Thumb).ok()?,
1546 }),
1547 ResourceType::Slot => RmrkResourceTypes::Slot(RmrkSlotResource {
1548 base: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Base).ok()?,
1549 src: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Src).ok()?,
1550 metadata: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Metadata).ok()?,
1551 slot: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Slot).ok()?,
1552 license: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::License).ok()?,
1553 thumb: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Thumb).ok()?,
1554 }),
1555 },
1556 }))
1557 .collect();
1558
1559 Ok(resources)
1560 }1361 }
15611362
1562 fn nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {1363 fn nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {
1563 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType}};1364 pallet_proxy_rmrk_core::rpc::nft_resource_priority::<Runtime>(collection_id, nft_id, resource_id)
1564
1565 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1566 Ok(id) => id,
1567 Err(_) => return Ok(None)
1568 };
1569 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() { return Ok(None); }
1570
1571 let nft_id = TokenId(nft_id);
1572 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Regular).is_err() { return Ok(None); }
1573
1574 let priorities: Vec<_> = RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::ResourcePriorities)?;
1575 Ok(
1576 priorities.into_iter()
1577 .enumerate()
1578 .find(|(_, id)| *id == resource_id)
1579 .map(|(priority, _): (usize, RmrkResourceId)| priority as u32)
1580 )
1581 }1365 }
15821366
1583 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {1367 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
1584 use pallet_proxy_rmrk_core::{1368 pallet_proxy_rmrk_equip::rpc::base::<Runtime>(base_id)
1585 RmrkProperty, misc::{CollectionType},
1586 };
1587
1588 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(base_id, CollectionType::Base) {
1589 Ok(c) => c,
1590 Err(_) => return Ok(None),
1591 };
1592
1593 Ok(Some(RmrkBaseInfo {
1594 issuer: collection.owner.clone(),
1595 base_type: RmrkCore::get_collection_property_decoded(collection_id, RmrkProperty::BaseType)?,
1596 symbol: RmrkCore::rebind(&collection.token_prefix)?,
1597 }))
1598 }1369 }
15991370
1600 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {1371 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
1601 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType}};1372 pallet_proxy_rmrk_equip::rpc::base_parts::<Runtime>(base_id)
1602 use pallet_common::CommonCollectionOperations;
1603
1604 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(base_id, CollectionType::Base) {
1605 Ok(c) => c,
1606 Err(_) => return Ok(Vec::new()),
1607 };
1608
1609 let parts = collection.collection_tokens()
1610 .into_iter()
1611 .filter_map(|token_id| {
1612 let nft_type = RmrkCore::get_nft_type(collection_id, token_id).ok()?;
1613
1614 match nft_type {
1615 NftType::FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {
1616 id: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?,
1617 src: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::Src).ok()?,
1618 z: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::ZIndex).ok()?,
1619 })),
1620 NftType::SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {
1621 id: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?,
1622 src: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::Src).ok()?,
1623 z: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::ZIndex).ok()?,
1624 equippable: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::EquippableList).ok()?,
1625 })),
1626 _ => None
1627 }
1628 })
1629 .collect();
1630
1631 Ok(parts)
1632 }1373 }
16331374
1634 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {1375 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
1635 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{NftType, CollectionType}};1376 pallet_proxy_rmrk_equip::rpc::theme_names::<Runtime>(base_id)
1636 use pallet_common::CommonCollectionOperations;
1637
1638 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(base_id, CollectionType::Base) {
1639 Ok(c) => c,
1640 Err(_) => return Ok(Vec::new()),
1641 };
1642
1643 let theme_names = collection.collection_tokens()
1644 .iter()
1645 .filter_map(|token_id| {
1646 let nft_type = RmrkCore::get_nft_type(collection_id, *token_id).ok()?;
1647
1648 match nft_type {
1649 NftType::Theme => RmrkCore::get_nft_property_decoded(collection_id, *token_id, RmrkProperty::ThemeName).ok(),
1650 _ => None
1651 }
1652 })
1653 .collect();
1654
1655 Ok(theme_names)
1656 }1377 }
16571378
1658 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {1379 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
1659 use pallet_proxy_rmrk_core::{1380 pallet_proxy_rmrk_equip::rpc::theme::<Runtime>(base_id, theme_name, filter_keys)
1660 RmrkProperty,
1661 misc::{CollectionType, NftType}
1662 };
1663 use pallet_common::CommonCollectionOperations;
1664
1665 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(base_id, CollectionType::Base) {
1666 Ok(c) => c,
1667 Err(_) => return Ok(None),
1668 };
1669
1670 let theme_info = collection.collection_tokens()
1671 .into_iter()
1672 .find_map(|token_id| {
1673 RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Theme).ok()?;
1674
1675 let name: RmrkString = RmrkCore::get_nft_property_decoded(
1676 collection_id, token_id, RmrkProperty::ThemeName
1677 ).ok()?;
1678
1679 if name == theme_name {
1680 Some((name, token_id))
1681 } else {
1682 None
1683 }
1684 });
1685
1686 let (name, theme_id) = match theme_info {
1687 Some((name, theme_id)) => (name, theme_id),
1688 None => return Ok(None)
1689 };
1690
1691 let properties = RmrkCore::filter_user_properties(
1692 collection_id,
1693 Some(theme_id),
1694 filter_keys,
1695 |key, value| RmrkThemeProperty {
1696 key,
1697 value
1698 }
1699 )?;
1700
1701 let inherit = RmrkCore::get_nft_property_decoded(
1702 collection_id,
1703 theme_id,
1704 RmrkProperty::ThemeInherit
1705 )?;
1706
1707 let theme = RmrkTheme {
1708 name,
1709 properties,
1710 inherit,
1711 };
1712
1713 Ok(Some(theme))
1714 }1381 }
1715 }1382 }
1716}1383}
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
74 CollectionStats, RpcCollection,74 CollectionStats, RpcCollection,
75 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},75 mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping},
76 TokenChild, RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo,76 TokenChild, RmrkCollectionInfo, RmrkInstanceInfo, RmrkResourceInfo, RmrkPropertyInfo,
77 RmrkBaseInfo, RmrkPartType, RmrkTheme, RmrkThemeName, RmrkThemeProperty, RmrkCollectionId,77 RmrkBaseInfo, RmrkPartType, RmrkTheme, RmrkThemeName, RmrkCollectionId, RmrkNftId,
78 RmrkNftId, RmrkAccountIdOrCollectionNftTuple, RmrkNftChild, RmrkPropertyKey, RmrkResourceTypes,78 RmrkNftChild, RmrkPropertyKey, RmrkResourceId, RmrkBaseId,
79 RmrkBasicResource, RmrkComposableResource, RmrkSlotResource, RmrkResourceId, RmrkBaseId,
80 RmrkFixedPart, RmrkSlotPart, RmrkString,
81};79};
8280
83// use pallet_contracts::weights::WeightInfo;81// use pallet_contracts::weights::WeightInfo;
923}921}
924922
925impl pallet_proxy_rmrk_equip::Config for Runtime {923impl pallet_proxy_rmrk_equip::Config for Runtime {
924 type WeightInfo = pallet_proxy_rmrk_equip::weights::SubstrateWeight<Self>;
926 type Event = Event;925 type Event = Event;
927}926}
928927
1330 RmrkTheme1329 RmrkTheme
1331 > for Runtime {1330 > for Runtime {
1332 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {1331 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {
1333 Ok(RmrkCore::last_collection_idx())1332 pallet_proxy_rmrk_core::rpc::last_collection_idx::<Runtime>()
1334 }1333 }
13351334
1336 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {1335 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {
1337 use pallet_proxy_rmrk_core::{RmrkProperty, misc::CollectionType};1336 pallet_proxy_rmrk_core::rpc::collection_by_id::<Runtime>(collection_id)
1338 use pallet_common::CommonCollectionOperations;
1339
1340 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(collection_id, CollectionType::Regular) {
1341 Ok(c) => c,
1342 Err(_) => return Ok(None),
1343 };
1344
1345 let nfts_count = collection.total_supply();
1346
1347 Ok(Some(RmrkCollectionInfo {
1348 issuer: collection.owner.clone(),
1349 metadata: RmrkCore::get_collection_property_decoded(collection_id, RmrkProperty::Metadata)?,
1350 max: collection.limits.token_limit,
1351 symbol: RmrkCore::rebind(&collection.token_prefix)?,
1352 nfts_count
1353 }))
1354 }1337 }
13551338
1356 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {1339 fn nft_by_id(collection_id: RmrkCollectionId, nft_by_id: RmrkNftId) -> Result<Option<RmrkInstanceInfo<AccountId>>, DispatchError> {
1357 use up_data_structs::mapping::TokenAddressMapping;
1358 use pallet_proxy_rmrk_core::{RmrkProperty, misc::CollectionType};1340 pallet_proxy_rmrk_core::rpc::nft_by_id::<Runtime>(collection_id, nft_by_id)
1359 use pallet_common::CommonCollectionOperations;
1360
1361 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(collection_id, CollectionType::Regular) {
1362 Ok(c) => c,
1363 Err(_) => return Ok(None),
1364 };
1365
1366 let nft_id = TokenId(nft_by_id);
1367 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(None); }
1368
1369 let owner = match collection.token_owner(nft_id) {
1370 Some(owner) => match <Runtime as pallet_common::Config>::CrossTokenAddressMapping::address_to_token(&owner) {
1371 Some((col, tok)) => {
1372 let rmrk_collection = RmrkCore::rmrk_collection_id(col)?;
1373
1374 RmrkAccountIdOrCollectionNftTuple::CollectionAndNftTuple(rmrk_collection, tok.0)
1375 }
1376 None => RmrkAccountIdOrCollectionNftTuple::AccountId(owner.as_sub().clone())
1377 },
1378 None => return Ok(None)
1379 };
1380
1381 Ok(Some(RmrkInstanceInfo {
1382 owner: owner,
1383 royalty: RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::RoyaltyInfo)?,
1384 metadata: RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::Metadata)?,
1385 equipped: RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::Equipped)?,
1386 pending: RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::PendingNftAccept)?,
1387 }))
1388 }1341 }
13891342
1390 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {1343 fn account_tokens(account_id: AccountId, collection_id: RmrkCollectionId) -> Result<Vec<RmrkNftId>, DispatchError> {
1391 use pallet_proxy_rmrk_core::{RmrkProperty, misc::CollectionType};1344 pallet_proxy_rmrk_core::rpc::account_tokens::<Runtime>(account_id, collection_id)
1392 use pallet_common::CommonCollectionOperations;
1393
1394 let cross_account_id = CrossAccountId::from_sub(account_id);
1395
1396 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(collection_id, CollectionType::Regular) {
1397 Ok(c) => c,
1398 Err(_) => return Ok(Vec::new()),
1399 };
1400
1401 let tokens = collection.account_tokens(cross_account_id)
1402 .into_iter()
1403 .filter(|token| {
1404 let is_pending = RmrkCore::get_nft_property_decoded(
1405 collection_id,
1406 *token,
1407 RmrkProperty::PendingNftAccept
1408 ).unwrap_or(true);
1409
1410 !is_pending
1411 })
1412 .map(|token| token.0)
1413 .collect();
1414
1415 Ok(tokens)
1416 }1345 }
14171346
1418 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {1347 fn nft_children(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkNftChild>, DispatchError> {
1419 use pallet_proxy_rmrk_core::RmrkProperty;1348 pallet_proxy_rmrk_core::rpc::nft_children::<Runtime>(collection_id, nft_id)
1420
1421 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1422 Ok(id) => id,
1423 Err(_) => return Ok(Vec::new())
1424 };
1425 let nft_id = TokenId(nft_id);
1426 if !RmrkCore::nft_exists(collection_id, nft_id) { return Ok(Vec::new()); }
1427
1428 Ok(
1429 pallet_nonfungible::TokenChildren::<Runtime>::iter_prefix((collection_id, nft_id))
1430 .filter_map(|((child_collection, child_token), _)| {
1431 let is_pending = RmrkCore::get_nft_property_decoded(
1432 child_collection,
1433 child_token,
1434 RmrkProperty::PendingNftAccept
1435 ).ok()?;
1436
1437 if is_pending {
1438 return None;
1439 }
1440
1441 let rmrk_child_collection = RmrkCore::rmrk_collection_id(
1442 child_collection
1443 ).ok()?;
1444
1445 Some(RmrkNftChild {
1446 collection_id: rmrk_child_collection,
1447 nft_id: child_token.0,
1448 })
1449 }).collect()
1450 )
1451 }1349 }
14521350
1453 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {1351 fn collection_properties(collection_id: RmrkCollectionId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
1454 use pallet_proxy_rmrk_core::misc::CollectionType;1352 pallet_proxy_rmrk_core::rpc::collection_properties::<Runtime>(collection_id, filter_keys)
1455
1456 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1457 Ok(id) => id,
1458 Err(_) => return Ok(Vec::new())
1459 };
1460 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() {
1461 return Ok(Vec::new());
1462 }
1463
1464 let properties = RmrkCore::filter_user_properties(
1465 collection_id,
1466 /* token_id = */ None,
1467 filter_keys,
1468 |key, value| RmrkPropertyInfo {
1469 key,
1470 value
1471 }
1472 )?;
1473
1474 Ok(properties)
1475 }1353 }
14761354
1477 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {1355 fn nft_properties(collection_id: RmrkCollectionId, nft_id: RmrkNftId, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Vec<RmrkPropertyInfo>, DispatchError> {
1478 use pallet_proxy_rmrk_core::misc::NftType;1356 pallet_proxy_rmrk_core::rpc::nft_properties::<Runtime>(collection_id, nft_id, filter_keys)
1479
1480 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1481 Ok(id) => id,
1482 Err(_) => return Ok(Vec::new())
1483 };
1484 let token_id = TokenId(nft_id);
1485
1486 if RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Regular).is_err() {
1487 return Ok(Vec::new());
1488 }
1489
1490 let properties = RmrkCore::filter_user_properties(
1491 collection_id,
1492 Some(token_id),
1493 filter_keys,
1494 |key, value| RmrkPropertyInfo {
1495 key,
1496 value
1497 }
1498 )?;
1499
1500 Ok(properties)
1501 }1357 }
15021358
1503 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {1359 fn nft_resources(collection_id: RmrkCollectionId, nft_id: RmrkNftId) -> Result<Vec<RmrkResourceInfo>, DispatchError> {
1504 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType, ResourceType}};1360 pallet_proxy_rmrk_core::rpc::nft_resources::<Runtime>(collection_id, nft_id)
1505 use pallet_common::CommonCollectionOperations;
1506
1507 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1508 Ok(id) => id,
1509 Err(_) => return Ok(Vec::new())
1510 };
1511 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() { return Ok(Vec::new()); }
1512
1513 let nft_id = TokenId(nft_id);
1514 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Regular).is_err() { return Ok(Vec::new()); }
1515
1516 let res_collection_id: Option<CollectionId> = RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::ResourceCollection)?;
1517
1518 let res_collection_id = match res_collection_id {
1519 Some(id) => id,
1520 None => return Ok(Vec::new())
1521 };
1522
1523 let resource_collection = RmrkCore::get_typed_nft_collection(res_collection_id, CollectionType::Resource)?;
1524
1525 let resources = resource_collection
1526 .collection_tokens()
1527 .iter()
1528 .filter_map(|res_id| Some(RmrkResourceInfo {
1529 id: res_id.0,
1530 pending: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::PendingResourceAccept).ok()?,
1531 pending_removal: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::PendingResourceRemoval).ok()?,
1532 resource: match RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::ResourceType).ok()? {
1533 ResourceType::Basic => RmrkResourceTypes::Basic(RmrkBasicResource {
1534 src: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Src).ok()?,
1535 metadata: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Metadata).ok()?,
1536 license: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::License).ok()?,
1537 thumb: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Thumb).ok()?,
1538 }),
1539 ResourceType::Composable => RmrkResourceTypes::Composable(RmrkComposableResource {
1540 parts: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Parts).ok()?,
1541 base: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Base).ok()?,
1542 src: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Src).ok()?,
1543 metadata: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Metadata).ok()?,
1544 license: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::License).ok()?,
1545 thumb: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Thumb).ok()?,
1546 }),
1547 ResourceType::Slot => RmrkResourceTypes::Slot(RmrkSlotResource {
1548 base: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Base).ok()?,
1549 src: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Src).ok()?,
1550 metadata: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Metadata).ok()?,
1551 slot: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Slot).ok()?,
1552 license: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::License).ok()?,
1553 thumb: RmrkCore::get_nft_property_decoded(res_collection_id, *res_id, RmrkProperty::Thumb).ok()?,
1554 }),
1555 },
1556 }))
1557 .collect();
1558
1559 Ok(resources)
1560 }1361 }
15611362
1562 fn nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {1363 fn nft_resource_priority(collection_id: RmrkCollectionId, nft_id: RmrkNftId, resource_id: RmrkResourceId) -> Result<Option<u32>, DispatchError> {
1563 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType}};1364 pallet_proxy_rmrk_core::rpc::nft_resource_priority::<Runtime>(collection_id, nft_id, resource_id)
1564
1565 let collection_id = match RmrkCore::unique_collection_id(collection_id) {
1566 Ok(id) => id,
1567 Err(_) => return Ok(None)
1568 };
1569 if RmrkCore::ensure_collection_type(collection_id, CollectionType::Regular).is_err() { return Ok(None); }
1570
1571 let nft_id = TokenId(nft_id);
1572 if RmrkCore::ensure_nft_type(collection_id, nft_id, NftType::Regular).is_err() { return Ok(None); }
1573
1574 let priorities: Vec<_> = RmrkCore::get_nft_property_decoded(collection_id, nft_id, RmrkProperty::ResourcePriorities)?;
1575 Ok(
1576 priorities.into_iter()
1577 .enumerate()
1578 .find(|(_, id)| *id == resource_id)
1579 .map(|(priority, _): (usize, RmrkResourceId)| priority as u32)
1580 )
1581 }1365 }
15821366
1583 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {1367 fn base(base_id: RmrkBaseId) -> Result<Option<RmrkBaseInfo<AccountId>>, DispatchError> {
1584 use pallet_proxy_rmrk_core::{1368 pallet_proxy_rmrk_equip::rpc::base::<Runtime>(base_id)
1585 RmrkProperty, misc::{CollectionType},
1586 };
1587
1588 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(base_id, CollectionType::Base) {
1589 Ok(c) => c,
1590 Err(_) => return Ok(None),
1591 };
1592
1593 Ok(Some(RmrkBaseInfo {
1594 issuer: collection.owner.clone(),
1595 base_type: RmrkCore::get_collection_property_decoded(collection_id, RmrkProperty::BaseType)?,
1596 symbol: RmrkCore::rebind(&collection.token_prefix)?,
1597 }))
1598 }1369 }
15991370
1600 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {1371 fn base_parts(base_id: RmrkBaseId) -> Result<Vec<RmrkPartType>, DispatchError> {
1601 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{CollectionType, NftType}};1372 pallet_proxy_rmrk_equip::rpc::base_parts::<Runtime>(base_id)
1602 use pallet_common::CommonCollectionOperations;
1603
1604 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(base_id, CollectionType::Base) {
1605 Ok(c) => c,
1606 Err(_) => return Ok(Vec::new()),
1607 };
1608
1609 let parts = collection.collection_tokens()
1610 .into_iter()
1611 .filter_map(|token_id| {
1612 let nft_type = RmrkCore::get_nft_type(collection_id, token_id).ok()?;
1613
1614 match nft_type {
1615 NftType::FixedPart => Some(RmrkPartType::FixedPart(RmrkFixedPart {
1616 id: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?,
1617 src: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::Src).ok()?,
1618 z: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::ZIndex).ok()?,
1619 })),
1620 NftType::SlotPart => Some(RmrkPartType::SlotPart(RmrkSlotPart {
1621 id: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::ExternalPartId).ok()?,
1622 src: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::Src).ok()?,
1623 z: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::ZIndex).ok()?,
1624 equippable: RmrkCore::get_nft_property_decoded(collection_id, token_id, RmrkProperty::EquippableList).ok()?,
1625 })),
1626 _ => None
1627 }
1628 })
1629 .collect();
1630
1631 Ok(parts)
1632 }1373 }
16331374
1634 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {1375 fn theme_names(base_id: RmrkBaseId) -> Result<Vec<RmrkThemeName>, DispatchError> {
1635 use pallet_proxy_rmrk_core::{RmrkProperty, misc::{NftType, CollectionType}};1376 pallet_proxy_rmrk_equip::rpc::theme_names::<Runtime>(base_id)
1636 use pallet_common::CommonCollectionOperations;
1637
1638 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(base_id, CollectionType::Base) {
1639 Ok(c) => c,
1640 Err(_) => return Ok(Vec::new()),
1641 };
1642
1643 let theme_names = collection.collection_tokens()
1644 .iter()
1645 .filter_map(|token_id| {
1646 let nft_type = RmrkCore::get_nft_type(collection_id, *token_id).ok()?;
1647
1648 match nft_type {
1649 NftType::Theme => RmrkCore::get_nft_property_decoded(collection_id, *token_id, RmrkProperty::ThemeName).ok(),
1650 _ => None
1651 }
1652 })
1653 .collect();
1654
1655 Ok(theme_names)
1656 }1377 }
16571378
1658 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {1379 fn theme(base_id: RmrkBaseId, theme_name: RmrkThemeName, filter_keys: Option<Vec<RmrkPropertyKey>>) -> Result<Option<RmrkTheme>, DispatchError> {
1659 use pallet_proxy_rmrk_core::{1380 pallet_proxy_rmrk_equip::rpc::theme::<Runtime>(base_id, theme_name, filter_keys)
1660 RmrkProperty,
1661 misc::{CollectionType, NftType}
1662 };
1663 use pallet_common::CommonCollectionOperations;
1664
1665 let (collection, collection_id) = match RmrkCore::get_typed_nft_collection_mapped(base_id, CollectionType::Base) {
1666 Ok(c) => c,
1667 Err(_) => return Ok(None),
1668 };
1669
1670 let theme_info = collection.collection_tokens()
1671 .into_iter()
1672 .find_map(|token_id| {
1673 RmrkCore::ensure_nft_type(collection_id, token_id, NftType::Theme).ok()?;
1674
1675 let name: RmrkString = RmrkCore::get_nft_property_decoded(
1676 collection_id, token_id, RmrkProperty::ThemeName
1677 ).ok()?;
1678
1679 if name == theme_name {
1680 Some((name, token_id))
1681 } else {
1682 None
1683 }
1684 });
1685
1686 let (name, theme_id) = match theme_info {
1687 Some((name, theme_id)) => (name, theme_id),
1688 None => return Ok(None)
1689 };
1690
1691 let properties = RmrkCore::filter_user_properties(
1692 collection_id,
1693 Some(theme_id),
1694 filter_keys,
1695 |key, value| RmrkThemeProperty {
1696 key,
1697 value
1698 }
1699 )?;
1700
1701 let inherit = RmrkCore::get_nft_property_decoded(
1702 collection_id,
1703 theme_id,
1704 RmrkProperty::ThemeInherit
1705 )?;
1706
1707 let theme = RmrkTheme {
1708 name,
1709 properties,
1710 inherit,
1711 };
1712
1713 Ok(Some(theme))
1714 }1381 }
1715 }1382 }
1716}1383}
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
16targets = ['x86_64-unknown-linux-gnu']16targets = ['x86_64-unknown-linux-gnu']
1717
18[features]18[features]
19default = ['std']19default = ['std', 'unique-runtime']
20runtime-benchmarks = [20runtime-benchmarks = [
21 'hex-literal',21 'hex-literal',
22 'frame-benchmarking',22 'frame-benchmarking',
119 "orml-vesting/std",119 "orml-vesting/std",
120]120]
121limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']121limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
122unique-runtime = []
122123
123################################################################################124################################################################################
124# Substrate Dependencies125# Substrate Dependencies
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth

no syntactic changes