,
32 | /// Transaction pool instance.
33 | pub pool: Arc,
34 | /// Whether to deny unsafe calls
35 | pub deny_unsafe: DenyUnsafe,
36 | }
37 |
38 | /// Instantiate all full RPC extensions.
39 | pub fn create_full(
40 | deps: FullDeps,
41 | ) -> Result, Box>
42 | where
43 | C: ProvideRuntimeApi,
44 | C: HeaderBackend + HeaderMetadata + 'static,
45 | C: Send + Sync + 'static,
46 | C::Api: substrate_frame_rpc_system::AccountNonceApi,
47 | C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi,
48 | C::Api: BlockBuilder,
49 | C::Api: pallet_rmrk_rpc_runtime_api::RmrkApi<
50 | Block,
51 | AccountId,
52 | CollectionInfo<
53 | BoundedVec,
54 | BoundedVec,
55 | AccountId,
56 | >,
57 | NftInfo, CollectionId, NftId>,
58 | ResourceInfo, BoundedVec>,
59 | PropertyInfo, BoundedVec>,
60 | BaseInfo>,
61 | PartType<
62 | BoundedVec,
63 | BoundedVec,
64 | >,
65 | Theme<
66 | BoundedVec,
67 | BoundedVec>, MaxPropertiesPerTheme>,
68 | >,
69 | >,
70 | P: TransactionPool + 'static,
71 | {
72 | use pallet_rmrk_rpc::{Rmrk, RmrkApiServer};
73 | use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
74 | use substrate_frame_rpc_system::{System, SystemApiServer};
75 |
76 | let mut module = RpcModule::new(());
77 | let FullDeps { client, pool, deny_unsafe } = deps;
78 |
79 | module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
80 | module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
81 | module.merge(Rmrk::new(client.clone()).into_rpc())?;
82 |
83 | Ok(module)
84 | }
85 |
--------------------------------------------------------------------------------
/pallets/rmrk-core/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pallet-rmrk-core"
3 | version = "0.0.1"
4 | description = "RMRK Core"
5 | authors = ["RMRK Team"]
6 | homepage = ""
7 | edition = "2021"
8 | license = "Apache-2.0"
9 | repository = "https://github.com/rmrk-team/rmrk-substrate"
10 |
11 | [package.metadata.docs.rs]
12 | targets = ["x86_64-unknown-linux-gnu"]
13 |
14 | [dependencies]
15 | serde = { version = "1.0.111", default-features = false, features = ["derive"] }
16 | sp-runtime = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
17 | sp-std = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
18 | codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
19 | "derive",
20 | ] }
21 | scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
22 | frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
23 | frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
24 | frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.36" }
25 |
26 | pallet-uniques = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
27 | pallet-balances = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
28 |
29 |
30 | # Local Dependencies
31 | rmrk-traits = { default-features = false, version = "0.0.1", path = "../../traits" }
32 |
33 | [dev-dependencies]
34 | sp-core = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
35 | sp-io = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
36 | sp-runtime = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
37 | sp-std = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
38 |
39 | [features]
40 | default = ["std"]
41 | std = [
42 | "pallet-uniques/std",
43 | "pallet-balances/std",
44 | "serde/std",
45 | "codec/std",
46 | "scale-info/std",
47 | "frame-support/std",
48 | "frame-system/std",
49 | "frame-benchmarking/std",
50 | ]
51 |
52 | runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
53 | try-runtime = ["frame-support/try-runtime"]
54 |
--------------------------------------------------------------------------------
/pallets/rmrk-core/README.md:
--------------------------------------------------------------------------------
1 | # RMRK Core Pallet
2 |
3 | Documentation [https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-core](https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-core)
4 |
5 | License: Apache-2.0
6 |
--------------------------------------------------------------------------------
/pallets/rmrk-core/src/types.rs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2021-2022 RMRK
2 | // This file is part of rmrk-core.
3 | // License: Apache 2.0 modified by RMRK, see LICENSE.md
4 |
5 | use frame_support::pallet_prelude::*;
6 | use sp_runtime::Permill;
7 |
8 | use scale_info::TypeInfo;
9 | #[cfg(feature = "std")]
10 | use serde::{Deserialize, Serialize};
11 |
12 | #[derive(Encode, Decode, Eq, Copy, PartialEq, Clone, RuntimeDebug, TypeInfo)]
13 | #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
14 | pub struct ClassInfo {
15 | /// Arbitrary data about a class, e.g. IPFS hash
16 | pub issuer: AccountId,
17 | pub metadata: BoundedString,
18 | pub max: u32,
19 | pub symbol: BoundedString,
20 | }
21 |
22 | #[derive(Encode, Decode, Eq, Copy, PartialEq, Clone, RuntimeDebug, TypeInfo)]
23 | pub struct InstanceInfo {
24 | /// The user account which receives the royalty
25 | pub recipient: AccountId,
26 | /// Royalty in per mille (1/1000)
27 | pub royalty: Permill,
28 | /// Arbitrary data about an instance, e.g. IPFS hash
29 | pub metadata: BoundedString,
30 | }
31 |
--------------------------------------------------------------------------------
/pallets/rmrk-equip/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pallet-rmrk-equip"
3 | version = "0.0.1"
4 | description = "RMRK Equip"
5 | authors = ["RMRK Team"]
6 | homepage = ""
7 | edition = "2021"
8 | license = "Apache 2.0"
9 | repository = "https://github.com/rmrk-team/rmrk-substrate"
10 |
11 | [package.metadata.docs.rs]
12 | targets = ["x86_64-unknown-linux-gnu"]
13 |
14 | [dependencies]
15 | serde = { version = "1.0.111", default-features = false, features = ["derive"] }
16 | sp-runtime = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
17 | sp-std = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
18 | codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
19 | "derive",
20 | ] }
21 | scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
22 | frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
23 | frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
24 | frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.36" }
25 |
26 | pallet-uniques = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
27 | pallet-balances = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
28 |
29 | # Local Dependencies
30 | pallet-rmrk-core = { default-features = false, version = "0.0.1", path = "../rmrk-core" }
31 | rmrk-traits = { default-features = false, version = "0.0.1", path = "../../traits" }
32 |
33 |
34 | [dev-dependencies]
35 | sp-core = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
36 | sp-io = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
37 | sp-runtime = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
38 | sp-std = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
39 |
40 | [features]
41 | default = ["std"]
42 | std = [
43 | "pallet-uniques/std",
44 | "serde/std",
45 | "codec/std",
46 | "scale-info/std",
47 | "frame-support/std",
48 | "frame-system/std",
49 | "frame-benchmarking/std",
50 | "pallet-rmrk-core/std",
51 | "pallet-balances/std",
52 | ]
53 |
54 | runtime-benchmarks = [
55 | "frame-benchmarking/runtime-benchmarks",
56 | "pallet-rmrk-core/runtime-benchmarks"
57 | ]
58 | try-runtime = ["frame-support/try-runtime"]
59 |
--------------------------------------------------------------------------------
/pallets/rmrk-equip/README.md:
--------------------------------------------------------------------------------
1 | # Equip Pallet
2 |
3 | Documentation [https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-equip](https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-equip)
4 |
5 | License: Apache-2.0
--------------------------------------------------------------------------------
/pallets/rmrk-equip/src/weights.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_rmrk_equip`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-12-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `Sergejs-MacBook-Air.local`, CPU: ``
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/rmrk-substrate
11 | // benchmark
12 | // pallet
13 | // --chain
14 | // dev
15 | // --execution=wasm
16 | // --wasm-execution=compiled
17 | // --pallet
18 | // pallet_rmrk_equip
19 | // --extrinsic=*
20 | // --steps
21 | // 50
22 | // --repeat
23 | // 20
24 | // --output
25 | // pallets/rmrk-equip/src/weights.rs
26 |
27 | #![cfg_attr(rustfmt, rustfmt_skip)]
28 | #![allow(unused_parens)]
29 | #![allow(unused_imports)]
30 |
31 | use frame_support::{traits::Get, weights::{Weight}};
32 | use sp_std::marker::PhantomData;
33 |
34 | /// Weight functions needed for `pallet_rmrk_equip`.
35 | pub trait WeightInfo {
36 | fn change_base_issuer() -> Weight;
37 | fn equip() -> Weight;
38 | fn unequip() -> Weight;
39 | fn equippable() -> Weight;
40 | fn equippable_add() -> Weight;
41 | fn equippable_remove() -> Weight;
42 | fn theme_add() -> Weight;
43 | fn create_base() -> Weight;
44 | }
45 |
46 | /// Weight functions for `pallet_rmrk_equip`.
47 | pub struct SubstrateWeight(PhantomData);
48 | impl WeightInfo for SubstrateWeight {
49 | // Storage: RmrkEquip Bases (r:1 w:1)
50 | fn change_base_issuer() -> Weight {
51 | Weight::from_ref_time(16_000_000 as u64)
52 | .saturating_add(T::DbWeight::get().reads(1 as u64))
53 | .saturating_add(T::DbWeight::get().writes(1 as u64))
54 | }
55 | // Storage: RmrkCore Nfts (r:2 w:1)
56 | // Storage: RmrkCore Lock (r:2 w:0)
57 | // Storage: RmrkEquip Equippings (r:1 w:1)
58 | // Storage: Uniques Asset (r:2 w:0)
59 | // Storage: RmrkCore EquippableBases (r:1 w:0)
60 | // Storage: RmrkCore EquippableSlots (r:1 w:0)
61 | // Storage: RmrkEquip Parts (r:1 w:0)
62 | fn equip() -> Weight {
63 | Weight::from_ref_time(47_000_000 as u64)
64 | .saturating_add(T::DbWeight::get().reads(10 as u64))
65 | .saturating_add(T::DbWeight::get().writes(2 as u64))
66 | }
67 | // Storage: RmrkCore Lock (r:2 w:0)
68 | // Storage: RmrkEquip Equippings (r:1 w:1)
69 | // Storage: RmrkCore Nfts (r:1 w:1)
70 | // Storage: Uniques Asset (r:2 w:0)
71 | fn unequip() -> Weight {
72 | Weight::from_ref_time(35_000_000 as u64)
73 | .saturating_add(T::DbWeight::get().reads(6 as u64))
74 | .saturating_add(T::DbWeight::get().writes(2 as u64))
75 | }
76 | // Storage: RmrkEquip Bases (r:1 w:0)
77 | // Storage: RmrkEquip Parts (r:1 w:1)
78 | fn equippable() -> Weight {
79 | Weight::from_ref_time(16_000_000 as u64)
80 | .saturating_add(T::DbWeight::get().reads(2 as u64))
81 | .saturating_add(T::DbWeight::get().writes(1 as u64))
82 | }
83 | // Storage: RmrkEquip Bases (r:1 w:0)
84 | // Storage: RmrkEquip Parts (r:1 w:1)
85 | fn equippable_add() -> Weight {
86 | Weight::from_ref_time(16_000_000 as u64)
87 | .saturating_add(T::DbWeight::get().reads(2 as u64))
88 | .saturating_add(T::DbWeight::get().writes(1 as u64))
89 | }
90 | // Storage: RmrkEquip Bases (r:1 w:0)
91 | // Storage: RmrkEquip Parts (r:1 w:1)
92 | fn equippable_remove() -> Weight {
93 | Weight::from_ref_time(17_000_000 as u64)
94 | .saturating_add(T::DbWeight::get().reads(2 as u64))
95 | .saturating_add(T::DbWeight::get().writes(1 as u64))
96 | }
97 | // Storage: RmrkEquip Bases (r:1 w:0)
98 | // Storage: RmrkEquip Themes (r:1 w:2)
99 | fn theme_add() -> Weight {
100 | Weight::from_ref_time(16_000_000 as u64)
101 | .saturating_add(T::DbWeight::get().reads(2 as u64))
102 | .saturating_add(T::DbWeight::get().writes(2 as u64))
103 | }
104 | // Storage: RmrkEquip NextBaseId (r:1 w:1)
105 | // Storage: RmrkEquip Bases (r:0 w:1)
106 | fn create_base() -> Weight {
107 | Weight::from_ref_time(13_000_000 as u64)
108 | .saturating_add(T::DbWeight::get().reads(1 as u64))
109 | .saturating_add(T::DbWeight::get().writes(2 as u64))
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/pallets/rmrk-market/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pallet-rmrk-market"
3 | version = "0.0.1"
4 | description = "RMRK Market"
5 | authors = ["RMRK Team"]
6 | homepage = ""
7 | edition = "2021"
8 | license = "Apache-2.0"
9 | repository = "https://github.com/rmrk-team/rmrk-substrate"
10 |
11 | [package.metadata.docs.rs]
12 | targets = ["x86_64-unknown-linux-gnu"]
13 |
14 | [dependencies]
15 | serde = { version = "1.0.111", default-features = false, features = ["derive"] }
16 | sp-runtime = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
17 | sp-std = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
18 | codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
19 | "derive",
20 | ] }
21 | scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
22 | frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
23 | frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
24 | frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.36" }
25 |
26 | pallet-uniques = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
27 | pallet-balances = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
28 |
29 |
30 | # Local Dependencies
31 | pallet-rmrk-core = { default-features = false, version = "0.0.1", path = "../rmrk-core" }
32 | rmrk-traits = { default-features = false, version = "0.0.1", path = "../../traits" }
33 |
34 | [dev-dependencies]
35 | sp-core = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
36 | sp-io = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
37 | sp-runtime = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
38 | sp-std = { default-features = false, version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
39 |
40 | [features]
41 | default = ["std"]
42 | std = [
43 | "pallet-uniques/std",
44 | "pallet-balances/std",
45 | "serde/std",
46 | "codec/std",
47 | "scale-info/std",
48 | "frame-support/std",
49 | "frame-system/std",
50 | "frame-benchmarking/std",
51 | ]
52 |
53 | runtime-benchmarks = [
54 | "frame-benchmarking/runtime-benchmarks",
55 | "pallet-rmrk-core/runtime-benchmarks",
56 | ]
57 | try-runtime = ["frame-support/try-runtime"]
58 |
--------------------------------------------------------------------------------
/pallets/rmrk-market/README.md:
--------------------------------------------------------------------------------
1 | # Market Pallet
2 |
3 | Documentations [https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-market](https://rmrk-team.github.io/rmrk-substrate/#/pallets/rmrk-market)
4 |
5 | License: Apache-2.0
--------------------------------------------------------------------------------
/pallets/rmrk-market/src/types.rs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2021-2022 RMRK
2 | // This file is part of rmrk-market.
3 | // License: Apache 2.0 modified by RMRK, see LICENSE.md
4 |
5 | use frame_support::pallet_prelude::*;
6 |
7 | #[cfg(feature = "std")]
8 | use serde::{Deserialize, Serialize};
9 |
10 | use scale_info::TypeInfo;
11 |
12 | #[derive(Encode, Decode, Eq, Copy, PartialEq, Clone, RuntimeDebug, TypeInfo, MaxEncodedLen)]
13 | #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
14 | pub struct ListInfo {
15 | /// Owner who listed the NFT at the time
16 | pub(super) listed_by: AccountId,
17 | /// Listed amount
18 | pub(super) amount: Balance,
19 | /// After this block the listing can't be bought
20 | pub(super) expires: Option,
21 | }
22 |
23 | #[derive(Encode, Decode, Eq, Copy, PartialEq, Clone, RuntimeDebug, TypeInfo, MaxEncodedLen)]
24 | #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
25 | pub struct Offer {
26 | /// User who made the offer
27 | pub(super) maker: AccountId,
28 | /// Offered amount
29 | pub(super) amount: Balance,
30 | /// After this block the offer can't be accepted
31 | pub(super) expires: Option,
32 | }
33 |
--------------------------------------------------------------------------------
/pallets/rmrk-market/src/weights.rs:
--------------------------------------------------------------------------------
1 |
2 | //! Autogenerated weights for `pallet_rmrk_market`
3 | //!
4 | //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
5 | //! DATE: 2022-11-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
6 | //! HOSTNAME: `Sergejs-MacBook-Air.local`, CPU: ``
7 | //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
8 |
9 | // Executed Command:
10 | // ./target/release/rmrk-substrate
11 | // benchmark
12 | // pallet
13 | // --chain
14 | // dev
15 | // --execution=wasm
16 | // --wasm-execution=compiled
17 | // --pallet
18 | // pallet_rmrk_market
19 | // --extrinsic
20 | // *
21 | // --steps
22 | // 50
23 | // --repeat
24 | // 20
25 | // --output
26 | // pallets/rmrk-market/src/weights.rs
27 |
28 | #![cfg_attr(rustfmt, rustfmt_skip)]
29 | #![allow(unused_parens)]
30 | #![allow(unused_imports)]
31 |
32 | use frame_support::{traits::Get, weights::{Weight}};
33 | use sp_std::marker::PhantomData;
34 |
35 | /// Weight functions needed for pallet_rmrk_market.
36 | pub trait WeightInfo {
37 | fn buy() -> Weight;
38 | fn list() -> Weight;
39 | fn unlist() -> Weight;
40 | fn make_offer() -> Weight;
41 | fn withdraw_offer() -> Weight;
42 | fn accept_offer() -> Weight;
43 | }
44 |
45 | /// Weight functions for `pallet_rmrk_core`.
46 | pub struct SubstrateWeight(PhantomData);
47 | impl WeightInfo for SubstrateWeight {
48 | // Storage: Uniques Asset (r:1 w:1)
49 | // Storage: RmrkMarket ListedNfts (r:1 w:1)
50 | // Storage: RmrkCore Lock (r:1 w:1)
51 | // Storage: System Account (r:1 w:1)
52 | // Storage: RmrkCore Nfts (r:1 w:1)
53 | // Storage: Uniques Class (r:1 w:0)
54 | // Storage: Uniques Account (r:0 w:2)
55 | // Storage: Uniques ItemPriceOf (r:0 w:1)
56 | fn buy() -> Weight {
57 | Weight::from_ref_time(63_000_000 as u64)
58 | .saturating_add(T::DbWeight::get().reads(6 as u64))
59 | .saturating_add(T::DbWeight::get().writes(8 as u64))
60 | }
61 | // Storage: Uniques Asset (r:1 w:0)
62 | // Storage: RmrkCore Nfts (r:1 w:0)
63 | // Storage: Uniques Class (r:1 w:0)
64 | // Storage: RmrkCore Lock (r:1 w:1)
65 | // Storage: RmrkMarket ListedNfts (r:0 w:1)
66 | fn list() -> Weight {
67 | Weight::from_ref_time(26_000_000 as u64)
68 | .saturating_add(T::DbWeight::get().reads(4 as u64))
69 | .saturating_add(T::DbWeight::get().writes(2 as u64))
70 | }
71 | // Storage: RmrkMarket ListedNfts (r:1 w:1)
72 | // Storage: Uniques Asset (r:1 w:0)
73 | // Storage: RmrkCore Lock (r:1 w:1)
74 | fn unlist() -> Weight {
75 | Weight::from_ref_time(23_000_000 as u64)
76 | .saturating_add(T::DbWeight::get().reads(3 as u64))
77 | .saturating_add(T::DbWeight::get().writes(2 as u64))
78 | }
79 | // Storage: Uniques Asset (r:1 w:0)
80 | // Storage: RmrkMarket Offers (r:1 w:1)
81 | fn make_offer() -> Weight {
82 | Weight::from_ref_time(28_000_000 as u64)
83 | .saturating_add(T::DbWeight::get().reads(2 as u64))
84 | .saturating_add(T::DbWeight::get().writes(1 as u64))
85 | }
86 | // Storage: RmrkMarket Offers (r:1 w:1)
87 | // Storage: Uniques Asset (r:1 w:0)
88 | fn withdraw_offer() -> Weight {
89 | Weight::from_ref_time(28_000_000 as u64)
90 | .saturating_add(T::DbWeight::get().reads(2 as u64))
91 | .saturating_add(T::DbWeight::get().writes(1 as u64))
92 | }
93 | // Storage: Uniques Asset (r:1 w:1)
94 | // Storage: RmrkMarket Offers (r:1 w:1)
95 | // Storage: System Account (r:1 w:1)
96 | // Storage: RmrkCore Lock (r:1 w:1)
97 | // Storage: RmrkCore Nfts (r:1 w:1)
98 | // Storage: Uniques Class (r:1 w:0)
99 | // Storage: Uniques Account (r:0 w:2)
100 | // Storage: Uniques ItemPriceOf (r:0 w:1)
101 | fn accept_offer() -> Weight {
102 | Weight::from_ref_time(74_000_000 as u64)
103 | .saturating_add(T::DbWeight::get().reads(6 as u64))
104 | .saturating_add(T::DbWeight::get().writes(8 as u64))
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/pallets/template/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pallet-template"
3 | version = "0.0.1"
4 | description = "FRAME pallet template for defining custom runtime logic."
5 | authors = ["Substrate DevHub "]
6 | homepage = "https://substrate.io/"
7 | edition = "2021"
8 | license = "Unlicense"
9 | publish = false
10 | repository = "https://github.com/rmrk-team/rmrk-substrate"
11 |
12 | [package.metadata.docs.rs]
13 | targets = ["x86_64-unknown-linux-gnu"]
14 |
15 | [dependencies]
16 | codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
17 | "derive",
18 | ] }
19 | scale-info = { version = "2.0.1", default-features = false, features = ["derive"] }
20 | frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
21 | frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
22 | frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", optional = true, branch = "polkadot-v0.9.36" }
23 |
24 | [dev-dependencies]
25 | sp-core = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
26 | sp-io = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
27 | sp-runtime = { default-features = false, version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
28 |
29 | [features]
30 | default = ["std"]
31 | std = [
32 | "codec/std",
33 | "scale-info/std",
34 | "frame-support/std",
35 | "frame-system/std",
36 | "frame-benchmarking/std",
37 | ]
38 |
39 | runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
40 | try-runtime = ["frame-support/try-runtime"]
41 |
--------------------------------------------------------------------------------
/pallets/template/README.md:
--------------------------------------------------------------------------------
1 | License: Unlicense
2 |
--------------------------------------------------------------------------------
/pallets/template/src/benchmarking.rs:
--------------------------------------------------------------------------------
1 | //! Benchmarking setup for pallet-template
2 |
3 | use super::*;
4 |
5 | #[allow(unused)]
6 | use crate::Pallet as Template;
7 | use frame_benchmarking::{benchmarks, whitelisted_caller};
8 | use frame_system::RawOrigin;
9 |
10 | benchmarks! {
11 | do_something {
12 | let s in 0 .. 100;
13 | let caller: T::AccountId = whitelisted_caller();
14 | }: _(RawOrigin::Signed(caller), s)
15 | verify {
16 | assert_eq!(Something::::get(), Some(s));
17 | }
18 |
19 | impl_benchmark_test_suite!(Template, crate::mock::new_test_ext(), crate::mock::Test);
20 | }
21 |
--------------------------------------------------------------------------------
/pallets/template/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![cfg_attr(not(feature = "std"), no_std)]
2 |
3 | /// Edit this file to define custom logic or remove it if it is not needed.
4 | /// Learn more about FRAME and the core library of Substrate FRAME pallets:
5 | ///
6 | pub use pallet::*;
7 |
8 | #[cfg(test)]
9 | mod mock;
10 |
11 | #[cfg(test)]
12 | mod tests;
13 |
14 | #[cfg(feature = "runtime-benchmarks")]
15 | mod benchmarking;
16 |
17 | #[frame_support::pallet]
18 | pub mod pallet {
19 | use frame_support::{dispatch::DispatchResult, pallet_prelude::*};
20 | use frame_system::pallet_prelude::*;
21 |
22 | /// Configure the pallet by specifying the parameters and types on which it depends.
23 | #[pallet::config]
24 | pub trait Config: frame_system::Config {
25 | /// Because this pallet emits events, it depends on the runtime's definition of an event.
26 | type RuntimeEvent: From> + IsType<::RuntimeEvent>;
27 | }
28 |
29 | #[pallet::pallet]
30 | #[pallet::generate_store(pub(super) trait Store)]
31 | pub struct Pallet(_);
32 |
33 | // The pallet's runtime storage items.
34 | // https://docs.substrate.io/v3/runtime/storage
35 | #[pallet::storage]
36 | #[pallet::getter(fn something)]
37 | // Learn more about declaring storage items:
38 | // https://docs.substrate.io/v3/runtime/storage#declaring-storage-items
39 | pub type Something = StorageValue<_, u32>;
40 |
41 | // Pallets use events to inform users when important changes are made.
42 | // https://docs.substrate.io/v3/runtime/events-and-errors
43 | #[pallet::event]
44 | #[pallet::generate_deposit(pub(super) fn deposit_event)]
45 | pub enum Event {
46 | /// Event documentation should end with an array that provides descriptive names for event
47 | /// parameters. [something, who]
48 | SomethingStored(u32, T::AccountId),
49 | }
50 |
51 | // Errors inform users that something went wrong.
52 | #[pallet::error]
53 | pub enum Error {
54 | /// Error names should be descriptive.
55 | NoneValue,
56 | /// Errors should have helpful documentation associated with them.
57 | StorageOverflow,
58 | }
59 |
60 | // Dispatchable functions allows users to interact with the pallet and invoke state changes.
61 | // These functions materialize as "extrinsics", which are often compared to transactions.
62 | // Dispatchable functions must be annotated with a weight and must return a DispatchResult.
63 | #[pallet::call]
64 | impl Pallet {
65 | /// An example dispatchable that takes a singles value as a parameter, writes the value to
66 | /// storage and emits an event. This function must be dispatched by a signed extrinsic.
67 | #[pallet::call_index(0)]
68 | #[pallet::weight(10_000 + T::DbWeight::get().writes(1).ref_time())]
69 | pub fn do_something(origin: OriginFor, something: u32) -> DispatchResult {
70 | // Check that the extrinsic was signed and get the signer.
71 | // This function will return an error if the extrinsic is not signed.
72 | // https://docs.substrate.io/v3/runtime/origins
73 | let who = ensure_signed(origin)?;
74 |
75 | // Update storage.
76 | >::put(something);
77 |
78 | // Emit an event.
79 | Self::deposit_event(Event::SomethingStored(something, who));
80 | // Return a successful DispatchResultWithPostInfo
81 | Ok(())
82 | }
83 |
84 | /// An example dispatchable that may throw a custom error.
85 | #[pallet::call_index(1)]
86 | #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1).ref_time())]
87 | pub fn cause_error(origin: OriginFor) -> DispatchResult {
88 | let _who = ensure_signed(origin)?;
89 |
90 | // Read a value from storage.
91 | match >::get() {
92 | // Return an error if the value has not been set.
93 | None => Err(Error::::NoneValue.into()),
94 | Some(old) => {
95 | // Increment the value read from storage; will error in the event of overflow.
96 | let new = old.checked_add(1).ok_or(Error::::StorageOverflow)?;
97 | // Update the value in storage with the incremented result.
98 | >::put(new);
99 | Ok(())
100 | },
101 | }
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/pallets/template/src/mock.rs:
--------------------------------------------------------------------------------
1 | use crate as pallet_template;
2 | use frame_support::{parameter_types, traits::ConstU32};
3 | use frame_system as system;
4 | use sp_core::H256;
5 | use sp_runtime::{
6 | testing::Header,
7 | traits::{BlakeTwo256, IdentityLookup},
8 | };
9 |
10 | type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic;
11 | type Block = frame_system::mocking::MockBlock;
12 |
13 | // Configure a mock runtime to test the pallet.
14 | frame_support::construct_runtime!(
15 | pub enum Test where
16 | Block = Block,
17 | NodeBlock = Block,
18 | UncheckedExtrinsic = UncheckedExtrinsic,
19 | {
20 | System: frame_system::{Pallet, Call, Config, Storage, Event},
21 | TemplateModule: pallet_template::{Pallet, Call, Storage, Event},
22 | }
23 | );
24 |
25 | parameter_types! {
26 | pub const BlockHashCount: u64 = 250;
27 | pub const SS58Prefix: u8 = 42;
28 | }
29 |
30 | impl system::Config for Test {
31 | type BaseCallFilter = frame_support::traits::Everything;
32 | type BlockWeights = ();
33 | type BlockLength = ();
34 | type DbWeight = ();
35 | type RuntimeOrigin = RuntimeOrigin;
36 | type RuntimeCall = RuntimeCall;
37 | type Index = u64;
38 | type BlockNumber = u64;
39 | type Hash = H256;
40 | type Hashing = BlakeTwo256;
41 | type AccountId = u64;
42 | type Lookup = IdentityLookup;
43 | type Header = Header;
44 | type RuntimeEvent = RuntimeEvent;
45 | type BlockHashCount = BlockHashCount;
46 | type Version = ();
47 | type PalletInfo = PalletInfo;
48 | type AccountData = ();
49 | type OnNewAccount = ();
50 | type OnKilledAccount = ();
51 | type SystemWeightInfo = ();
52 | type SS58Prefix = SS58Prefix;
53 | type OnSetCode = ();
54 | type MaxConsumers = ConstU32<2>;
55 | }
56 |
57 | impl pallet_template::Config for Test {
58 | type RuntimeEvent = RuntimeEvent;
59 | }
60 |
61 | // Build genesis storage according to the mock runtime.
62 | pub fn new_test_ext() -> sp_io::TestExternalities {
63 | system::GenesisConfig::default().build_storage::().unwrap().into()
64 | }
65 |
--------------------------------------------------------------------------------
/pallets/template/src/tests.rs:
--------------------------------------------------------------------------------
1 | use crate::{mock::*, Error};
2 | use frame_support::{assert_noop, assert_ok};
3 |
4 | #[test]
5 | fn it_works_for_default_value() {
6 | new_test_ext().execute_with(|| {
7 | // Dispatch a signed extrinsic.
8 | assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42));
9 | // Read pallet storage and assert an expected result.
10 | assert_eq!(TemplateModule::something(), Some(42));
11 | });
12 | }
13 |
14 | #[test]
15 | fn correct_error_for_none_value() {
16 | new_test_ext().execute_with(|| {
17 | // Ensure the expected error is thrown when no value is present.
18 | assert_noop!(
19 | TemplateModule::cause_error(RuntimeOrigin::signed(1)),
20 | Error::::NoneValue
21 | );
22 | });
23 | }
24 |
--------------------------------------------------------------------------------
/rpc-runtime-api/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "pallet-rmrk-rpc-runtime-api"
3 | version = "0.0.1"
4 | license = ""
5 | edition = "2021"
6 |
7 | [dependencies]
8 | serde = { version = "1.0.132", default-features = false, features = ["derive"] }
9 | codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
10 | scale-info = { version = "2.0", default-features = false }
11 | sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
12 | sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
13 | sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
14 | sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
15 |
16 | rmrk-traits = { version = "0.0.1", path = "../traits", default-features = false }
17 |
18 | [features]
19 | default = ["std"]
20 | std = [
21 | "codec/std",
22 | "scale-info/std",
23 | "serde/std",
24 | "sp-core/std",
25 | "sp-std/std",
26 | "sp-api/std",
27 | "sp-runtime/std",
28 | "rmrk-traits/std",
29 | ]
30 |
--------------------------------------------------------------------------------
/rpc-runtime-api/src/lib.rs:
--------------------------------------------------------------------------------
1 | #![cfg_attr(not(feature = "std"), no_std)]
2 |
3 | use rmrk_traits::{
4 | primitives::{BaseId, CollectionId, NftId, ResourceId},
5 | NftChild,
6 | };
7 | use sp_api::{Decode, Encode};
8 | use sp_runtime::DispatchError;
9 | use sp_std::vec::Vec;
10 |
11 | pub type Result = core::result::Result;
12 |
13 | pub type RpcString = Vec;
14 |
15 | pub type PropertyKey = RpcString;
16 |
17 | pub type ThemeName = RpcString;
18 |
19 | sp_api::decl_runtime_apis! {
20 | pub trait RmrkApi<
21 | AccountId,
22 | CollectionInfo,
23 | NftInfo,
24 | ResourceInfo,
25 | PropertyInfo,
26 | BaseInfo,
27 | PartType,
28 | Theme
29 | >
30 | where
31 | AccountId: Encode,
32 | CollectionInfo: Decode,
33 | NftInfo: Decode,
34 | ResourceInfo: Decode,
35 | PropertyInfo: Decode,
36 | BaseInfo: Decode,
37 | PartType: Decode,
38 | Theme: Decode,
39 | {
40 | /// Get collection by id
41 | fn collection_by_id(id: CollectionId) -> Result