difftreelog
Add properties extrinsics
in: master
10 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -736,7 +736,24 @@
) -> DispatchResult {
collection.check_is_owner_or_admin(sender)?;
- CollectionProperties::<T>::get(collection.id).try_change_property(property)?;
+ CollectionProperties::<T>::try_mutate(
+ collection.id,
+ |properties| properties.try_change_property(property.clone())
+ )?;
+
+ <Pallet<T>>::deposit_event(Event::CollectionPropertySet(collection.id, property));
+
+ Ok(())
+ }
+
+ pub fn change_collection_properties(
+ collection: &CollectionHandle<T>,
+ sender: &T::CrossAccountId,
+ properties: Vec<Property>,
+ ) -> DispatchResult {
+ for property in properties {
+ Self::change_collection_property(collection, sender, property)?;
+ }
Ok(())
}
@@ -909,7 +926,8 @@
fn create_multiple_items(amount: u32) -> Weight;
fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;
fn burn_item() -> Weight;
- fn set_property() -> Weight;
+ fn change_collection_properties(amount: u32) -> Weight;
+ fn change_token_properties(amount: u32) -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
fn transfer_from() -> Weight;
@@ -945,17 +963,17 @@
amount: u128,
) -> DispatchResultWithPostInfo;
- fn change_collection_property(
+ fn change_collection_properties(
&self,
sender: T::CrossAccountId,
- property: Property,
+ properties: Vec<Property>,
) -> DispatchResultWithPostInfo;
- fn change_token_property(
+ fn change_token_properties(
&self,
sender: T::CrossAccountId,
token_id: TokenId,
- property: Property,
+ property: Vec<Property>,
) -> DispatchResultWithPostInfo;
fn transfer(
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -50,8 +50,12 @@
<SelfWeightOf<T>>::burn_item()
}
- fn set_property() -> Weight {
- <SelfWeightOf<T>>::set_property()
+ fn change_collection_properties(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::change_collection_properties(amount)
+ }
+
+ fn change_token_properties(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::change_token_properties(amount)
}
fn transfer() -> Weight {
@@ -229,19 +233,19 @@
)
}
- fn change_collection_property(
+ fn change_collection_properties(
&self,
_sender: T::CrossAccountId,
- _property: Property,
+ _property: Vec<Property>,
) -> DispatchResultWithPostInfo {
fail!(<Error<T>>::PropertiesNotAllowed)
}
- fn change_token_property(
+ fn change_token_properties(
&self,
_sender: T::CrossAccountId,
_token_id: TokenId,
- _property: Property,
+ _property: Vec<Property>,
) -> DispatchResultWithPostInfo {
fail!(<Error<T>>::PropertiesNotAllowed)
}
pallets/fungible/src/weights.rsdiffbeforeafterboth--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -35,7 +35,8 @@
fn create_item() -> Weight;
fn create_multiple_items_ex(b: u32, ) -> Weight;
fn burn_item() -> Weight;
- fn set_property() -> Weight;
+ fn change_collection_properties(amount: u32) -> Weight;
+ fn change_token_properties(amount: u32) -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
fn transfer_from() -> Weight;
@@ -71,11 +72,16 @@
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
- fn set_property() -> Weight {
+ fn change_collection_properties(amount: u32) -> Weight {
// Error
0
}
+ fn change_token_properties(amount: u32) -> Weight {
+ // Error
+ 0
+ }
+
// Storage: Fungible Balance (r:2 w:2)
fn transfer() -> Weight {
(17_713_000 as Weight)
@@ -134,7 +140,12 @@
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
- fn set_property() -> Weight {
+ fn change_collection_properties(amount: u32) -> Weight {
+ // Error
+ 0
+ }
+
+ fn change_token_properties(amount: u32) -> Weight {
// Error
0
}
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -50,8 +50,12 @@
<SelfWeightOf<T>>::burn_item()
}
- fn set_property() -> Weight {
- <SelfWeightOf<T>>::set_property()
+ fn change_collection_properties(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::change_collection_properties(amount)
+ }
+
+ fn change_token_properties(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::change_token_properties(amount)
}
fn transfer() -> Weight {
@@ -145,6 +149,33 @@
)
}
+ fn change_collection_properties(
+ &self,
+ sender: T::CrossAccountId,
+ properties: Vec<Property>,
+ ) -> DispatchResultWithPostInfo {
+ let weight = <CommonWeights<T>>::change_collection_properties(properties.len() as u32);
+
+ with_weight(
+ <Pallet<T>>::change_collection_properties(self, &sender, properties),
+ weight
+ )
+ }
+
+ fn change_token_properties(
+ &self,
+ sender: T::CrossAccountId,
+ token_id: TokenId,
+ properties: Vec<Property>,
+ ) -> DispatchResultWithPostInfo {
+ let weight = <CommonWeights<T>>::change_token_properties(properties.len() as u32);
+
+ with_weight(
+ <Pallet<T>>::change_token_properties(self, &sender, token_id, properties),
+ weight
+ )
+ }
+
fn burn_item(
&self,
sender: T::CrossAccountId,
@@ -239,32 +270,6 @@
} else {
Ok(().into())
}
- }
-
- fn change_collection_property(
- &self,
- sender: T::CrossAccountId,
- property: Property,
- ) -> DispatchResultWithPostInfo {
- // let token_id = None;
- with_weight(
- // <Pallet<T>>::change_property(self, &sender, token_id, property),
- Ok(()),
- <CommonWeights<T>>::set_property(),
- )
- }
-
- fn change_token_property(
- &self,
- sender: T::CrossAccountId,
- token_id: TokenId,
- property: Property,
- ) -> DispatchResultWithPostInfo {
- with_weight(
- // <Pallet<T>>::change_property(self, &sender, Some(token_id), property),
- Ok(()),
- <CommonWeights<T>>::set_property(),
- )
}
fn set_variable_metadata(
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -265,12 +265,11 @@
.map(|p| p.clone())
.unwrap_or(PropertyPermission::None);
- let check_token_owner = || -> DispatchResult {
- let token_data = <TokenData<T>>::get((collection.id, token_id))
- .ok_or(<CommonError<T>>::TokenNotFound)?;
+ let token_data = <TokenData<T>>::get((collection.id, token_id))
+ .ok_or(<CommonError<T>>::TokenNotFound)?;
+ let check_token_owner = || -> DispatchResult {
ensure!(&token_data.owner == sender, <CommonError<T>>::NoPermission);
-
Ok(())
};
@@ -304,6 +303,27 @@
Ok(())
}
+ pub fn change_token_properties(
+ collection: &NonfungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ token_id: TokenId,
+ properties: Vec<Property>,
+ ) -> DispatchResult {
+ for property in properties {
+ Self::change_token_property(collection, sender, token_id, property)?;
+ }
+
+ Ok(())
+ }
+
+ pub fn change_collection_properties(
+ collection: &NonfungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ properties: Vec<Property>,
+ ) -> DispatchResult {
+ <PalletCommon<T>>::change_collection_properties(collection, sender, properties)
+ }
+
pub fn transfer(
collection: &NonfungibleHandle<T>,
from: &T::CrossAccountId,
pallets/nonfungible/src/weights.rsdiffbeforeafterboth1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_nonfungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-03-01, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// --pallet13// pallet-nonfungible14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/nonfungible/src/weights.rs2425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]28#![allow(clippy::unnecessary_cast)]2930use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};31use sp_std::marker::PhantomData;3233/// Weight functions needed for pallet_nonfungible.34pub trait WeightInfo {35 fn create_item() -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;37 fn create_multiple_items_ex(b: u32, ) -> Weight;38 fn burn_item() -> Weight;39 fn set_property() -> Weight;40 fn transfer() -> Weight;41 fn approve() -> Weight;42 fn transfer_from() -> Weight;43 fn burn_from() -> Weight;44 fn set_variable_metadata(b: u32, ) -> Weight;45}4647/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.48pub struct SubstrateWeight<T>(PhantomData<T>);49impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {50 // Storage: Nonfungible TokensMinted (r:1 w:1)51 // Storage: Nonfungible AccountBalance (r:1 w:1)52 // Storage: Nonfungible TokenData (r:0 w:1)53 // Storage: Nonfungible Owned (r:0 w:1)54 fn create_item() -> Weight {55 (18_450_000 as Weight)56 .saturating_add(T::DbWeight::get().reads(2 as Weight))57 .saturating_add(T::DbWeight::get().writes(4 as Weight))58 }59 // Storage: Nonfungible TokensMinted (r:1 w:1)60 // Storage: Nonfungible AccountBalance (r:1 w:1)61 // Storage: Nonfungible TokenData (r:0 w:4)62 // Storage: Nonfungible Owned (r:0 w:4)63 fn create_multiple_items(b: u32, ) -> Weight {64 (10_228_000 as Weight)65 // Standard Error: 1_00066 .saturating_add((4_392_000 as Weight).saturating_mul(b as Weight))67 .saturating_add(T::DbWeight::get().reads(2 as Weight))68 .saturating_add(T::DbWeight::get().writes(2 as Weight))69 .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))70 }71 // Storage: Nonfungible TokensMinted (r:1 w:1)72 // Storage: Nonfungible AccountBalance (r:4 w:4)73 // Storage: Nonfungible TokenData (r:0 w:4)74 // Storage: Nonfungible Owned (r:0 w:4)75 fn create_multiple_items_ex(b: u32, ) -> Weight {76 (6_543_000 as Weight)77 // Standard Error: 2_00078 .saturating_add((7_175_000 as Weight).saturating_mul(b as Weight))79 .saturating_add(T::DbWeight::get().reads(1 as Weight))80 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))81 .saturating_add(T::DbWeight::get().writes(1 as Weight))82 .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))83 }84 // Storage: Nonfungible TokenData (r:1 w:1)85 // Storage: Nonfungible TokensBurnt (r:1 w:1)86 // Storage: Nonfungible AccountBalance (r:1 w:1)87 // Storage: Nonfungible Allowance (r:1 w:0)88 // Storage: Nonfungible Owned (r:0 w:1)89 fn burn_item() -> Weight {90 (24_554_000 as Weight)91 .saturating_add(T::DbWeight::get().reads(4 as Weight))92 .saturating_add(T::DbWeight::get().writes(4 as Weight))93 }9495 fn set_property() -> Weight {96 // TODO calculate appropriate weight97 50_000_000 as Weight98 }99100 // Storage: Nonfungible TokenData (r:1 w:1)101 // Storage: Nonfungible AccountBalance (r:2 w:2)102 // Storage: Nonfungible Allowance (r:1 w:0)103 // Storage: Nonfungible Owned (r:0 w:2)104 fn transfer() -> Weight {105 (28_339_000 as Weight)106 .saturating_add(T::DbWeight::get().reads(4 as Weight))107 .saturating_add(T::DbWeight::get().writes(5 as Weight))108 }109 // Storage: Nonfungible TokenData (r:1 w:0)110 // Storage: Nonfungible Allowance (r:1 w:1)111 fn approve() -> Weight {112 (17_616_000 as Weight)113 .saturating_add(T::DbWeight::get().reads(2 as Weight))114 .saturating_add(T::DbWeight::get().writes(1 as Weight))115 }116 // Storage: Nonfungible Allowance (r:1 w:1)117 // Storage: Nonfungible TokenData (r:1 w:1)118 // Storage: Nonfungible AccountBalance (r:2 w:2)119 // Storage: Nonfungible Owned (r:0 w:2)120 fn transfer_from() -> Weight {121 (32_196_000 as Weight)122 .saturating_add(T::DbWeight::get().reads(4 as Weight))123 .saturating_add(T::DbWeight::get().writes(6 as Weight))124 }125 // Storage: Nonfungible Allowance (r:1 w:1)126 // Storage: Nonfungible TokenData (r:1 w:1)127 // Storage: Nonfungible TokensBurnt (r:1 w:1)128 // Storage: Nonfungible AccountBalance (r:1 w:1)129 // Storage: Nonfungible Owned (r:0 w:1)130 fn burn_from() -> Weight {131 (27_580_000 as Weight)132 .saturating_add(T::DbWeight::get().reads(4 as Weight))133 .saturating_add(T::DbWeight::get().writes(5 as Weight))134 }135 // Storage: Nonfungible TokenData (r:1 w:1)136 fn set_variable_metadata(_b: u32, ) -> Weight {137 (7_700_000 as Weight)138 .saturating_add(T::DbWeight::get().reads(1 as Weight))139 .saturating_add(T::DbWeight::get().writes(1 as Weight))140 }141}142143// For backwards compatibility and tests144impl WeightInfo for () {145 // Storage: Nonfungible TokensMinted (r:1 w:1)146 // Storage: Nonfungible AccountBalance (r:1 w:1)147 // Storage: Nonfungible TokenData (r:0 w:1)148 // Storage: Nonfungible Owned (r:0 w:1)149 fn create_item() -> Weight {150 (18_450_000 as Weight)151 .saturating_add(RocksDbWeight::get().reads(2 as Weight))152 .saturating_add(RocksDbWeight::get().writes(4 as Weight))153 }154 // Storage: Nonfungible TokensMinted (r:1 w:1)155 // Storage: Nonfungible AccountBalance (r:1 w:1)156 // Storage: Nonfungible TokenData (r:0 w:4)157 // Storage: Nonfungible Owned (r:0 w:4)158 fn create_multiple_items(b: u32, ) -> Weight {159 (10_228_000 as Weight)160 // Standard Error: 1_000161 .saturating_add((4_392_000 as Weight).saturating_mul(b as Weight))162 .saturating_add(RocksDbWeight::get().reads(2 as Weight))163 .saturating_add(RocksDbWeight::get().writes(2 as Weight))164 .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))165 }166 // Storage: Nonfungible TokensMinted (r:1 w:1)167 // Storage: Nonfungible AccountBalance (r:4 w:4)168 // Storage: Nonfungible TokenData (r:0 w:4)169 // Storage: Nonfungible Owned (r:0 w:4)170 fn create_multiple_items_ex(b: u32, ) -> Weight {171 (6_543_000 as Weight)172 // Standard Error: 2_000173 .saturating_add((7_175_000 as Weight).saturating_mul(b as Weight))174 .saturating_add(RocksDbWeight::get().reads(1 as Weight))175 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))176 .saturating_add(RocksDbWeight::get().writes(1 as Weight))177 .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))178 }179 // Storage: Nonfungible TokenData (r:1 w:1)180 // Storage: Nonfungible TokensBurnt (r:1 w:1)181 // Storage: Nonfungible AccountBalance (r:1 w:1)182 // Storage: Nonfungible Allowance (r:1 w:0)183 // Storage: Nonfungible Owned (r:0 w:1)184 fn burn_item() -> Weight {185 (24_554_000 as Weight)186 .saturating_add(RocksDbWeight::get().reads(4 as Weight))187 .saturating_add(RocksDbWeight::get().writes(4 as Weight))188 }189190 fn set_property() -> Weight {191 // TODO calculate appropriate weight192 50_000_000 as Weight193 }194195 // Storage: Nonfungible TokenData (r:1 w:1)196 // Storage: Nonfungible AccountBalance (r:2 w:2)197 // Storage: Nonfungible Allowance (r:1 w:0)198 // Storage: Nonfungible Owned (r:0 w:2)199 fn transfer() -> Weight {200 (28_339_000 as Weight)201 .saturating_add(RocksDbWeight::get().reads(4 as Weight))202 .saturating_add(RocksDbWeight::get().writes(5 as Weight))203 }204 // Storage: Nonfungible TokenData (r:1 w:0)205 // Storage: Nonfungible Allowance (r:1 w:1)206 fn approve() -> Weight {207 (17_616_000 as Weight)208 .saturating_add(RocksDbWeight::get().reads(2 as Weight))209 .saturating_add(RocksDbWeight::get().writes(1 as Weight))210 }211 // Storage: Nonfungible Allowance (r:1 w:1)212 // Storage: Nonfungible TokenData (r:1 w:1)213 // Storage: Nonfungible AccountBalance (r:2 w:2)214 // Storage: Nonfungible Owned (r:0 w:2)215 fn transfer_from() -> Weight {216 (32_196_000 as Weight)217 .saturating_add(RocksDbWeight::get().reads(4 as Weight))218 .saturating_add(RocksDbWeight::get().writes(6 as Weight))219 }220 // Storage: Nonfungible Allowance (r:1 w:1)221 // Storage: Nonfungible TokenData (r:1 w:1)222 // Storage: Nonfungible TokensBurnt (r:1 w:1)223 // Storage: Nonfungible AccountBalance (r:1 w:1)224 // Storage: Nonfungible Owned (r:0 w:1)225 fn burn_from() -> Weight {226 (27_580_000 as Weight)227 .saturating_add(RocksDbWeight::get().reads(4 as Weight))228 .saturating_add(RocksDbWeight::get().writes(5 as Weight))229 }230 // Storage: Nonfungible TokenData (r:1 w:1)231 fn set_variable_metadata(_b: u32, ) -> Weight {232 (7_700_000 as Weight)233 .saturating_add(RocksDbWeight::get().reads(1 as Weight))234 .saturating_add(RocksDbWeight::get().writes(1 as Weight))235 }236}1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_nonfungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2022-03-01, STEPS: `50`, REPEAT: 200, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// --pallet13// pallet-nonfungible14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/nonfungible/src/weights.rs2425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]28#![allow(clippy::unnecessary_cast)]2930use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};31use sp_std::marker::PhantomData;3233/// Weight functions needed for pallet_nonfungible.34pub trait WeightInfo {35 fn create_item() -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;37 fn create_multiple_items_ex(b: u32, ) -> Weight;38 fn burn_item() -> Weight;39 fn change_collection_properties(amount: u32) -> Weight;40 fn change_token_properties(amount: u32) -> Weight;41 fn transfer() -> Weight;42 fn approve() -> Weight;43 fn transfer_from() -> Weight;44 fn burn_from() -> Weight;45 fn set_variable_metadata(b: u32, ) -> Weight;46}4748/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.49pub struct SubstrateWeight<T>(PhantomData<T>);50impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {51 // Storage: Nonfungible TokensMinted (r:1 w:1)52 // Storage: Nonfungible AccountBalance (r:1 w:1)53 // Storage: Nonfungible TokenData (r:0 w:1)54 // Storage: Nonfungible Owned (r:0 w:1)55 fn create_item() -> Weight {56 (18_450_000 as Weight)57 .saturating_add(T::DbWeight::get().reads(2 as Weight))58 .saturating_add(T::DbWeight::get().writes(4 as Weight))59 }60 // Storage: Nonfungible TokensMinted (r:1 w:1)61 // Storage: Nonfungible AccountBalance (r:1 w:1)62 // Storage: Nonfungible TokenData (r:0 w:4)63 // Storage: Nonfungible Owned (r:0 w:4)64 fn create_multiple_items(b: u32, ) -> Weight {65 (10_228_000 as Weight)66 // Standard Error: 1_00067 .saturating_add((4_392_000 as Weight).saturating_mul(b as Weight))68 .saturating_add(T::DbWeight::get().reads(2 as Weight))69 .saturating_add(T::DbWeight::get().writes(2 as Weight))70 .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))71 }72 // Storage: Nonfungible TokensMinted (r:1 w:1)73 // Storage: Nonfungible AccountBalance (r:4 w:4)74 // Storage: Nonfungible TokenData (r:0 w:4)75 // Storage: Nonfungible Owned (r:0 w:4)76 fn create_multiple_items_ex(b: u32, ) -> Weight {77 (6_543_000 as Weight)78 // Standard Error: 2_00079 .saturating_add((7_175_000 as Weight).saturating_mul(b as Weight))80 .saturating_add(T::DbWeight::get().reads(1 as Weight))81 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))82 .saturating_add(T::DbWeight::get().writes(1 as Weight))83 .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))84 }85 // Storage: Nonfungible TokenData (r:1 w:1)86 // Storage: Nonfungible TokensBurnt (r:1 w:1)87 // Storage: Nonfungible AccountBalance (r:1 w:1)88 // Storage: Nonfungible Allowance (r:1 w:0)89 // Storage: Nonfungible Owned (r:0 w:1)90 fn burn_item() -> Weight {91 (24_554_000 as Weight)92 .saturating_add(T::DbWeight::get().reads(4 as Weight))93 .saturating_add(T::DbWeight::get().writes(4 as Weight))94 }9596 fn change_collection_properties(amount: u32) -> Weight {97 // TODO calculate appropriate weight98 (50_000_000 as Weight).saturating_mul(amount as Weight)99 }100101 fn change_token_properties(amount: u32) -> Weight {102 // TODO calculate appropriate weight103 (50_000_000 as Weight).saturating_mul(amount as Weight)104 }105106 // Storage: Nonfungible TokenData (r:1 w:1)107 // Storage: Nonfungible AccountBalance (r:2 w:2)108 // Storage: Nonfungible Allowance (r:1 w:0)109 // Storage: Nonfungible Owned (r:0 w:2)110 fn transfer() -> Weight {111 (28_339_000 as Weight)112 .saturating_add(T::DbWeight::get().reads(4 as Weight))113 .saturating_add(T::DbWeight::get().writes(5 as Weight))114 }115 // Storage: Nonfungible TokenData (r:1 w:0)116 // Storage: Nonfungible Allowance (r:1 w:1)117 fn approve() -> Weight {118 (17_616_000 as Weight)119 .saturating_add(T::DbWeight::get().reads(2 as Weight))120 .saturating_add(T::DbWeight::get().writes(1 as Weight))121 }122 // Storage: Nonfungible Allowance (r:1 w:1)123 // Storage: Nonfungible TokenData (r:1 w:1)124 // Storage: Nonfungible AccountBalance (r:2 w:2)125 // Storage: Nonfungible Owned (r:0 w:2)126 fn transfer_from() -> Weight {127 (32_196_000 as Weight)128 .saturating_add(T::DbWeight::get().reads(4 as Weight))129 .saturating_add(T::DbWeight::get().writes(6 as Weight))130 }131 // Storage: Nonfungible Allowance (r:1 w:1)132 // Storage: Nonfungible TokenData (r:1 w:1)133 // Storage: Nonfungible TokensBurnt (r:1 w:1)134 // Storage: Nonfungible AccountBalance (r:1 w:1)135 // Storage: Nonfungible Owned (r:0 w:1)136 fn burn_from() -> Weight {137 (27_580_000 as Weight)138 .saturating_add(T::DbWeight::get().reads(4 as Weight))139 .saturating_add(T::DbWeight::get().writes(5 as Weight))140 }141 // Storage: Nonfungible TokenData (r:1 w:1)142 fn set_variable_metadata(_b: u32, ) -> Weight {143 (7_700_000 as Weight)144 .saturating_add(T::DbWeight::get().reads(1 as Weight))145 .saturating_add(T::DbWeight::get().writes(1 as Weight))146 }147}148149// For backwards compatibility and tests150impl WeightInfo for () {151 // Storage: Nonfungible TokensMinted (r:1 w:1)152 // Storage: Nonfungible AccountBalance (r:1 w:1)153 // Storage: Nonfungible TokenData (r:0 w:1)154 // Storage: Nonfungible Owned (r:0 w:1)155 fn create_item() -> Weight {156 (18_450_000 as Weight)157 .saturating_add(RocksDbWeight::get().reads(2 as Weight))158 .saturating_add(RocksDbWeight::get().writes(4 as Weight))159 }160 // Storage: Nonfungible TokensMinted (r:1 w:1)161 // Storage: Nonfungible AccountBalance (r:1 w:1)162 // Storage: Nonfungible TokenData (r:0 w:4)163 // Storage: Nonfungible Owned (r:0 w:4)164 fn create_multiple_items(b: u32, ) -> Weight {165 (10_228_000 as Weight)166 // Standard Error: 1_000167 .saturating_add((4_392_000 as Weight).saturating_mul(b as Weight))168 .saturating_add(RocksDbWeight::get().reads(2 as Weight))169 .saturating_add(RocksDbWeight::get().writes(2 as Weight))170 .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))171 }172 // Storage: Nonfungible TokensMinted (r:1 w:1)173 // Storage: Nonfungible AccountBalance (r:4 w:4)174 // Storage: Nonfungible TokenData (r:0 w:4)175 // Storage: Nonfungible Owned (r:0 w:4)176 fn create_multiple_items_ex(b: u32, ) -> Weight {177 (6_543_000 as Weight)178 // Standard Error: 2_000179 .saturating_add((7_175_000 as Weight).saturating_mul(b as Weight))180 .saturating_add(RocksDbWeight::get().reads(1 as Weight))181 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))182 .saturating_add(RocksDbWeight::get().writes(1 as Weight))183 .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))184 }185 // Storage: Nonfungible TokenData (r:1 w:1)186 // Storage: Nonfungible TokensBurnt (r:1 w:1)187 // Storage: Nonfungible AccountBalance (r:1 w:1)188 // Storage: Nonfungible Allowance (r:1 w:0)189 // Storage: Nonfungible Owned (r:0 w:1)190 fn burn_item() -> Weight {191 (24_554_000 as Weight)192 .saturating_add(RocksDbWeight::get().reads(4 as Weight))193 .saturating_add(RocksDbWeight::get().writes(4 as Weight))194 }195196 fn change_collection_properties(amount: u32) -> Weight {197 // TODO calculate appropriate weight198 (50_000_000 as Weight).saturating_mul(amount as Weight)199 }200201 fn change_token_properties(amount: u32) -> Weight {202 // TODO calculate appropriate weight203 (50_000_000 as Weight).saturating_mul(amount as Weight)204 }205206 // Storage: Nonfungible TokenData (r:1 w:1)207 // Storage: Nonfungible AccountBalance (r:2 w:2)208 // Storage: Nonfungible Allowance (r:1 w:0)209 // Storage: Nonfungible Owned (r:0 w:2)210 fn transfer() -> Weight {211 (28_339_000 as Weight)212 .saturating_add(RocksDbWeight::get().reads(4 as Weight))213 .saturating_add(RocksDbWeight::get().writes(5 as Weight))214 }215 // Storage: Nonfungible TokenData (r:1 w:0)216 // Storage: Nonfungible Allowance (r:1 w:1)217 fn approve() -> Weight {218 (17_616_000 as Weight)219 .saturating_add(RocksDbWeight::get().reads(2 as Weight))220 .saturating_add(RocksDbWeight::get().writes(1 as Weight))221 }222 // Storage: Nonfungible Allowance (r:1 w:1)223 // Storage: Nonfungible TokenData (r:1 w:1)224 // Storage: Nonfungible AccountBalance (r:2 w:2)225 // Storage: Nonfungible Owned (r:0 w:2)226 fn transfer_from() -> Weight {227 (32_196_000 as Weight)228 .saturating_add(RocksDbWeight::get().reads(4 as Weight))229 .saturating_add(RocksDbWeight::get().writes(6 as Weight))230 }231 // Storage: Nonfungible Allowance (r:1 w:1)232 // Storage: Nonfungible TokenData (r:1 w:1)233 // Storage: Nonfungible TokensBurnt (r:1 w:1)234 // Storage: Nonfungible AccountBalance (r:1 w:1)235 // Storage: Nonfungible Owned (r:0 w:1)236 fn burn_from() -> Weight {237 (27_580_000 as Weight)238 .saturating_add(RocksDbWeight::get().reads(4 as Weight))239 .saturating_add(RocksDbWeight::get().writes(5 as Weight))240 }241 // Storage: Nonfungible TokenData (r:1 w:1)242 fn set_variable_metadata(_b: u32, ) -> Weight {243 (7_700_000 as Weight)244 .saturating_add(RocksDbWeight::get().reads(1 as Weight))245 .saturating_add(RocksDbWeight::get().writes(1 as Weight))246 }247}pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -66,8 +66,12 @@
max_weight_of!(burn_item_partial(), burn_item_fully())
}
- fn set_property() -> Weight {
- <SelfWeightOf<T>>::set_property()
+ fn change_collection_properties(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::change_collection_properties(amount)
+ }
+
+ fn change_token_properties(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::change_token_properties(amount)
}
fn transfer() -> Weight {
@@ -248,19 +252,19 @@
)
}
- fn change_collection_property(
+ fn change_collection_properties(
&self,
_sender: T::CrossAccountId,
- _property: Property,
+ _property: Vec<Property>,
) -> DispatchResultWithPostInfo {
fail!(<Error<T>>::PropertiesNotAllowed)
}
- fn change_token_property(
+ fn change_token_properties(
&self,
_sender: T::CrossAccountId,
_token_id: TokenId,
- _property: Property,
+ _property: Vec<Property>,
) -> DispatchResultWithPostInfo {
fail!(<Error<T>>::PropertiesNotAllowed)
}
pallets/refungible/src/weights.rsdiffbeforeafterboth--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -38,7 +38,8 @@
fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight;
fn burn_item_partial() -> Weight;
fn burn_item_fully() -> Weight;
- fn set_property() -> Weight;
+ fn change_collection_properties(amount: u32) -> Weight;
+ fn change_token_properties(amount: u32) -> Weight;
fn transfer_normal() -> Weight;
fn transfer_creating() -> Weight;
fn transfer_removing() -> Weight;
@@ -131,11 +132,16 @@
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
- fn set_property() -> Weight {
+ fn change_collection_properties(amount: u32) -> Weight {
// Error
0
}
+ fn change_token_properties(amount: u32) -> Weight {
+ // Error
+ 0
+ }
+
// Storage: Refungible Balance (r:2 w:2)
fn transfer_normal() -> Weight {
(19_766_000 as Weight)
@@ -305,7 +311,12 @@
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
- fn set_property() -> Weight {
+ fn change_collection_properties(amount: u32) -> Weight {
+ // Error
+ 0
+ }
+
+ fn change_token_properties(amount: u32) -> Weight {
// Error
0
}
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -694,6 +694,35 @@
dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))
}
+ #[weight = T::CommonWeightInfo::change_collection_properties(properties.len() as u32)]
+ #[transactional]
+ pub fn change_collection_properties(
+ origin,
+ collection_id: CollectionId,
+ properties: Vec<Property>
+ ) -> DispatchResultWithPostInfo {
+ ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);
+
+ let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
+
+ dispatch_call::<T, _>(collection_id, |d| d.change_collection_properties(sender, properties))
+ }
+
+ #[weight = T::CommonWeightInfo::change_token_properties(properties.len() as u32)]
+ #[transactional]
+ pub fn change_token_properties(
+ origin,
+ collection_id: CollectionId,
+ token_id: TokenId,
+ properties: Vec<Property>
+ ) -> DispatchResultWithPostInfo {
+ ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);
+
+ let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
+
+ dispatch_call::<T, _>(collection_id, |d| d.change_token_properties(sender, token_id, properties))
+ }
+
#[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]
#[transactional]
pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {
runtime/common/src/weights.rsdiffbeforeafterboth--- a/runtime/common/src/weights.rs
+++ b/runtime/common/src/weights.rs
@@ -54,8 +54,12 @@
dispatch_weight::<T>() + max_weight_of!(burn_item())
}
- fn set_property() -> Weight {
- dispatch_weight::<T>() + max_weight_of!(set_property())
+ fn change_collection_properties(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(change_collection_properties(amount))
+ }
+
+ fn change_token_properties(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(change_token_properties(amount))
}
fn transfer() -> Weight {