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.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -36,7 +36,8 @@
fn create_multiple_items(b: u32, ) -> 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;
@@ -92,11 +93,16 @@
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
- fn set_property() -> Weight {
+ fn change_collection_properties(amount: u32) -> Weight {
// TODO calculate appropriate weight
- 50_000_000 as Weight
+ (50_000_000 as Weight).saturating_mul(amount as Weight)
}
+ fn change_token_properties(amount: u32) -> Weight {
+ // TODO calculate appropriate weight
+ (50_000_000 as Weight).saturating_mul(amount as Weight)
+ }
+
// Storage: Nonfungible TokenData (r:1 w:1)
// Storage: Nonfungible AccountBalance (r:2 w:2)
// Storage: Nonfungible Allowance (r:1 w:0)
@@ -187,9 +193,14 @@
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
}
- fn set_property() -> Weight {
+ fn change_collection_properties(amount: u32) -> Weight {
+ // TODO calculate appropriate weight
+ (50_000_000 as Weight).saturating_mul(amount as Weight)
+ }
+
+ fn change_token_properties(amount: u32) -> Weight {
// TODO calculate appropriate weight
- 50_000_000 as Weight
+ (50_000_000 as Weight).saturating_mul(amount as Weight)
}
// Storage: Nonfungible TokenData (r:1 w:1)
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.rsdiffbeforeafterboth1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_refungible4//!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-refungible14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/refungible/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_refungible.34pub trait WeightInfo {35 fn create_item() -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;37 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight;38 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight;39 fn burn_item_partial() -> Weight;40 fn burn_item_fully() -> Weight;41 fn change_collection_properties(amount: u32) -> Weight;42 fn change_token_properties(amount: u32) -> Weight;43 fn transfer_normal() -> Weight;44 fn transfer_creating() -> Weight;45 fn transfer_removing() -> Weight;46 fn transfer_creating_removing() -> Weight;47 fn approve() -> Weight;48 fn transfer_from_normal() -> Weight;49 fn transfer_from_creating() -> Weight;50 fn transfer_from_removing() -> Weight;51 fn transfer_from_creating_removing() -> Weight;52 fn burn_from() -> Weight;53 fn set_variable_metadata(b: u32, ) -> Weight;54}5556/// Weights for pallet_refungible using the Substrate node and recommended hardware.57pub struct SubstrateWeight<T>(PhantomData<T>);58impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {59 // Storage: Refungible TokensMinted (r:1 w:1)60 // Storage: Refungible AccountBalance (r:1 w:1)61 // Storage: Refungible Balance (r:0 w:1)62 // Storage: Refungible TotalSupply (r:0 w:1)63 // Storage: Refungible TokenData (r:0 w:1)64 // Storage: Refungible Owned (r:0 w:1)65 fn create_item() -> Weight {66 (21_255_000 as Weight)67 .saturating_add(T::DbWeight::get().reads(2 as Weight))68 .saturating_add(T::DbWeight::get().writes(6 as Weight))69 }70 // Storage: Refungible TokensMinted (r:1 w:1)71 // Storage: Refungible AccountBalance (r:1 w:1)72 // Storage: Refungible Balance (r:0 w:4)73 // Storage: Refungible TotalSupply (r:0 w:4)74 // Storage: Refungible TokenData (r:0 w:4)75 // Storage: Refungible Owned (r:0 w:4)76 fn create_multiple_items(b: u32, ) -> Weight {77 (18_052_000 as Weight)78 // Standard Error: 1_00079 .saturating_add((5_549_000 as Weight).saturating_mul(b as Weight))80 .saturating_add(T::DbWeight::get().reads(2 as Weight))81 .saturating_add(T::DbWeight::get().writes(2 as Weight))82 .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))83 }84 // Storage: Refungible TokensMinted (r:1 w:1)85 // Storage: Refungible AccountBalance (r:4 w:4)86 // Storage: Refungible Balance (r:0 w:4)87 // Storage: Refungible TotalSupply (r:0 w:4)88 // Storage: Refungible TokenData (r:0 w:4)89 // Storage: Refungible Owned (r:0 w:4)90 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {91 (15_766_000 as Weight)92 // Standard Error: 2_00093 .saturating_add((8_187_000 as Weight).saturating_mul(b as Weight))94 .saturating_add(T::DbWeight::get().reads(1 as Weight))95 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))96 .saturating_add(T::DbWeight::get().writes(1 as Weight))97 .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(b as Weight)))98 }99 // Storage: Refungible TokensMinted (r:1 w:1)100 // Storage: Refungible TotalSupply (r:0 w:1)101 // Storage: Refungible TokenData (r:0 w:1)102 // Storage: Refungible AccountBalance (r:4 w:4)103 // Storage: Refungible Balance (r:0 w:4)104 // Storage: Refungible Owned (r:0 w:4)105 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {106 (5_675_000 as Weight)107 // Standard Error: 2_000108 .saturating_add((6_315_000 as Weight).saturating_mul(b as Weight))109 .saturating_add(T::DbWeight::get().reads(1 as Weight))110 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))111 .saturating_add(T::DbWeight::get().writes(3 as Weight))112 .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))113 }114 // Storage: Refungible TotalSupply (r:1 w:1)115 // Storage: Refungible Balance (r:1 w:1)116 // Storage: Refungible AccountBalance (r:1 w:1)117 // Storage: Refungible Owned (r:0 w:1)118 fn burn_item_partial() -> Weight {119 (23_518_000 as Weight)120 .saturating_add(T::DbWeight::get().reads(3 as Weight))121 .saturating_add(T::DbWeight::get().writes(4 as Weight))122 }123 // Storage: Refungible TotalSupply (r:1 w:1)124 // Storage: Refungible Balance (r:1 w:1)125 // Storage: Refungible AccountBalance (r:1 w:1)126 // Storage: Refungible TokensBurnt (r:1 w:1)127 // Storage: Refungible TokenData (r:0 w:1)128 // Storage: Refungible Owned (r:0 w:1)129 fn burn_item_fully() -> Weight {130 (32_489_000 as Weight)131 .saturating_add(T::DbWeight::get().reads(4 as Weight))132 .saturating_add(T::DbWeight::get().writes(6 as Weight))133 }134135 fn change_collection_properties(amount: u32) -> Weight {136 // Error137 0138 }139140 fn change_token_properties(amount: u32) -> Weight {141 // Error142 0143 }144145 // Storage: Refungible Balance (r:2 w:2)146 fn transfer_normal() -> Weight {147 (19_766_000 as Weight)148 .saturating_add(T::DbWeight::get().reads(2 as Weight))149 .saturating_add(T::DbWeight::get().writes(2 as Weight))150 }151 // Storage: Refungible Balance (r:2 w:2)152 // Storage: Refungible AccountBalance (r:1 w:1)153 // Storage: Refungible Owned (r:0 w:1)154 fn transfer_creating() -> Weight {155 (23_360_000 as Weight)156 .saturating_add(T::DbWeight::get().reads(3 as Weight))157 .saturating_add(T::DbWeight::get().writes(4 as Weight))158 }159 // Storage: Refungible Balance (r:2 w:2)160 // Storage: Refungible AccountBalance (r:1 w:1)161 // Storage: Refungible Owned (r:0 w:1)162 fn transfer_removing() -> Weight {163 (25_344_000 as Weight)164 .saturating_add(T::DbWeight::get().reads(3 as Weight))165 .saturating_add(T::DbWeight::get().writes(4 as Weight))166 }167 // Storage: Refungible Balance (r:2 w:2)168 // Storage: Refungible AccountBalance (r:2 w:2)169 // Storage: Refungible Owned (r:0 w:2)170 fn transfer_creating_removing() -> Weight {171 (28_553_000 as Weight)172 .saturating_add(T::DbWeight::get().reads(4 as Weight))173 .saturating_add(T::DbWeight::get().writes(6 as Weight))174 }175 // Storage: Refungible Balance (r:1 w:0)176 // Storage: Refungible Allowance (r:0 w:1)177 fn approve() -> Weight {178 (15_356_000 as Weight)179 .saturating_add(T::DbWeight::get().reads(1 as Weight))180 .saturating_add(T::DbWeight::get().writes(1 as Weight))181 }182 // Storage: Refungible Allowance (r:1 w:1)183 // Storage: Refungible Balance (r:2 w:2)184 fn transfer_from_normal() -> Weight {185 (28_832_000 as Weight)186 .saturating_add(T::DbWeight::get().reads(3 as Weight))187 .saturating_add(T::DbWeight::get().writes(3 as Weight))188 }189 // Storage: Refungible Allowance (r:1 w:1)190 // Storage: Refungible Balance (r:2 w:2)191 // Storage: Refungible AccountBalance (r:1 w:1)192 // Storage: Refungible Owned (r:0 w:1)193 fn transfer_from_creating() -> Weight {194 (32_132_000 as Weight)195 .saturating_add(T::DbWeight::get().reads(4 as Weight))196 .saturating_add(T::DbWeight::get().writes(5 as Weight))197 }198 // Storage: Refungible Allowance (r:1 w:1)199 // Storage: Refungible Balance (r:2 w:2)200 // Storage: Refungible AccountBalance (r:1 w:1)201 // Storage: Refungible Owned (r:0 w:1)202 fn transfer_from_removing() -> Weight {203 (33_237_000 as Weight)204 .saturating_add(T::DbWeight::get().reads(4 as Weight))205 .saturating_add(T::DbWeight::get().writes(5 as Weight))206 }207 // Storage: Refungible Allowance (r:1 w:1)208 // Storage: Refungible Balance (r:2 w:2)209 // Storage: Refungible AccountBalance (r:2 w:2)210 // Storage: Refungible Owned (r:0 w:2)211 fn transfer_from_creating_removing() -> Weight {212 (36_399_000 as Weight)213 .saturating_add(T::DbWeight::get().reads(5 as Weight))214 .saturating_add(T::DbWeight::get().writes(7 as Weight))215 }216 // Storage: Refungible Allowance (r:1 w:1)217 // Storage: Refungible TotalSupply (r:1 w:1)218 // Storage: Refungible Balance (r:1 w:1)219 // Storage: Refungible AccountBalance (r:1 w:1)220 // Storage: Refungible TokensBurnt (r:1 w:1)221 // Storage: Refungible TokenData (r:0 w:1)222 // Storage: Refungible Owned (r:0 w:1)223 fn burn_from() -> Weight {224 (42_043_000 as Weight)225 .saturating_add(T::DbWeight::get().reads(5 as Weight))226 .saturating_add(T::DbWeight::get().writes(7 as Weight))227 }228 // Storage: Refungible TokenData (r:1 w:1)229 fn set_variable_metadata(_b: u32, ) -> Weight {230 (7_364_000 as Weight)231 .saturating_add(T::DbWeight::get().reads(1 as Weight))232 .saturating_add(T::DbWeight::get().writes(1 as Weight))233 }234}235236// For backwards compatibility and tests237impl WeightInfo for () {238 // Storage: Refungible TokensMinted (r:1 w:1)239 // Storage: Refungible AccountBalance (r:1 w:1)240 // Storage: Refungible Balance (r:0 w:1)241 // Storage: Refungible TotalSupply (r:0 w:1)242 // Storage: Refungible TokenData (r:0 w:1)243 // Storage: Refungible Owned (r:0 w:1)244 fn create_item() -> Weight {245 (21_255_000 as Weight)246 .saturating_add(RocksDbWeight::get().reads(2 as Weight))247 .saturating_add(RocksDbWeight::get().writes(6 as Weight))248 }249 // Storage: Refungible TokensMinted (r:1 w:1)250 // Storage: Refungible AccountBalance (r:1 w:1)251 // Storage: Refungible Balance (r:0 w:4)252 // Storage: Refungible TotalSupply (r:0 w:4)253 // Storage: Refungible TokenData (r:0 w:4)254 // Storage: Refungible Owned (r:0 w:4)255 fn create_multiple_items(b: u32, ) -> Weight {256 (18_052_000 as Weight)257 // Standard Error: 1_000258 .saturating_add((5_549_000 as Weight).saturating_mul(b as Weight))259 .saturating_add(RocksDbWeight::get().reads(2 as Weight))260 .saturating_add(RocksDbWeight::get().writes(2 as Weight))261 .saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))262 }263 // Storage: Refungible TokensMinted (r:1 w:1)264 // Storage: Refungible AccountBalance (r:4 w:4)265 // Storage: Refungible Balance (r:0 w:4)266 // Storage: Refungible TotalSupply (r:0 w:4)267 // Storage: Refungible TokenData (r:0 w:4)268 // Storage: Refungible Owned (r:0 w:4)269 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {270 (15_766_000 as Weight)271 // Standard Error: 2_000272 .saturating_add((8_187_000 as Weight).saturating_mul(b as Weight))273 .saturating_add(RocksDbWeight::get().reads(1 as Weight))274 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))275 .saturating_add(RocksDbWeight::get().writes(1 as Weight))276 .saturating_add(RocksDbWeight::get().writes((5 as Weight).saturating_mul(b as Weight)))277 }278 // Storage: Refungible TokensMinted (r:1 w:1)279 // Storage: Refungible TotalSupply (r:0 w:1)280 // Storage: Refungible TokenData (r:0 w:1)281 // Storage: Refungible AccountBalance (r:4 w:4)282 // Storage: Refungible Balance (r:0 w:4)283 // Storage: Refungible Owned (r:0 w:4)284 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {285 (5_675_000 as Weight)286 // Standard Error: 2_000287 .saturating_add((6_315_000 as Weight).saturating_mul(b as Weight))288 .saturating_add(RocksDbWeight::get().reads(1 as Weight))289 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))290 .saturating_add(RocksDbWeight::get().writes(3 as Weight))291 .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))292 }293 // Storage: Refungible TotalSupply (r:1 w:1)294 // Storage: Refungible Balance (r:1 w:1)295 // Storage: Refungible AccountBalance (r:1 w:1)296 // Storage: Refungible Owned (r:0 w:1)297 fn burn_item_partial() -> Weight {298 (23_518_000 as Weight)299 .saturating_add(RocksDbWeight::get().reads(3 as Weight))300 .saturating_add(RocksDbWeight::get().writes(4 as Weight))301 }302 // Storage: Refungible TotalSupply (r:1 w:1)303 // Storage: Refungible Balance (r:1 w:1)304 // Storage: Refungible AccountBalance (r:1 w:1)305 // Storage: Refungible TokensBurnt (r:1 w:1)306 // Storage: Refungible TokenData (r:0 w:1)307 // Storage: Refungible Owned (r:0 w:1)308 fn burn_item_fully() -> Weight {309 (32_489_000 as Weight)310 .saturating_add(RocksDbWeight::get().reads(4 as Weight))311 .saturating_add(RocksDbWeight::get().writes(6 as Weight))312 }313314 fn change_collection_properties(amount: u32) -> Weight {315 // Error316 0317 }318319 fn change_token_properties(amount: u32) -> Weight {320 // Error321 0322 }323324 // Storage: Refungible Balance (r:2 w:2)325 fn transfer_normal() -> Weight {326 (19_766_000 as Weight)327 .saturating_add(RocksDbWeight::get().reads(2 as Weight))328 .saturating_add(RocksDbWeight::get().writes(2 as Weight))329 }330 // Storage: Refungible Balance (r:2 w:2)331 // Storage: Refungible AccountBalance (r:1 w:1)332 // Storage: Refungible Owned (r:0 w:1)333 fn transfer_creating() -> Weight {334 (23_360_000 as Weight)335 .saturating_add(RocksDbWeight::get().reads(3 as Weight))336 .saturating_add(RocksDbWeight::get().writes(4 as Weight))337 }338 // Storage: Refungible Balance (r:2 w:2)339 // Storage: Refungible AccountBalance (r:1 w:1)340 // Storage: Refungible Owned (r:0 w:1)341 fn transfer_removing() -> Weight {342 (25_344_000 as Weight)343 .saturating_add(RocksDbWeight::get().reads(3 as Weight))344 .saturating_add(RocksDbWeight::get().writes(4 as Weight))345 }346 // Storage: Refungible Balance (r:2 w:2)347 // Storage: Refungible AccountBalance (r:2 w:2)348 // Storage: Refungible Owned (r:0 w:2)349 fn transfer_creating_removing() -> Weight {350 (28_553_000 as Weight)351 .saturating_add(RocksDbWeight::get().reads(4 as Weight))352 .saturating_add(RocksDbWeight::get().writes(6 as Weight))353 }354 // Storage: Refungible Balance (r:1 w:0)355 // Storage: Refungible Allowance (r:0 w:1)356 fn approve() -> Weight {357 (15_356_000 as Weight)358 .saturating_add(RocksDbWeight::get().reads(1 as Weight))359 .saturating_add(RocksDbWeight::get().writes(1 as Weight))360 }361 // Storage: Refungible Allowance (r:1 w:1)362 // Storage: Refungible Balance (r:2 w:2)363 fn transfer_from_normal() -> Weight {364 (28_832_000 as Weight)365 .saturating_add(RocksDbWeight::get().reads(3 as Weight))366 .saturating_add(RocksDbWeight::get().writes(3 as Weight))367 }368 // Storage: Refungible Allowance (r:1 w:1)369 // Storage: Refungible Balance (r:2 w:2)370 // Storage: Refungible AccountBalance (r:1 w:1)371 // Storage: Refungible Owned (r:0 w:1)372 fn transfer_from_creating() -> Weight {373 (32_132_000 as Weight)374 .saturating_add(RocksDbWeight::get().reads(4 as Weight))375 .saturating_add(RocksDbWeight::get().writes(5 as Weight))376 }377 // Storage: Refungible Allowance (r:1 w:1)378 // Storage: Refungible Balance (r:2 w:2)379 // Storage: Refungible AccountBalance (r:1 w:1)380 // Storage: Refungible Owned (r:0 w:1)381 fn transfer_from_removing() -> Weight {382 (33_237_000 as Weight)383 .saturating_add(RocksDbWeight::get().reads(4 as Weight))384 .saturating_add(RocksDbWeight::get().writes(5 as Weight))385 }386 // Storage: Refungible Allowance (r:1 w:1)387 // Storage: Refungible Balance (r:2 w:2)388 // Storage: Refungible AccountBalance (r:2 w:2)389 // Storage: Refungible Owned (r:0 w:2)390 fn transfer_from_creating_removing() -> Weight {391 (36_399_000 as Weight)392 .saturating_add(RocksDbWeight::get().reads(5 as Weight))393 .saturating_add(RocksDbWeight::get().writes(7 as Weight))394 }395 // Storage: Refungible Allowance (r:1 w:1)396 // Storage: Refungible TotalSupply (r:1 w:1)397 // Storage: Refungible Balance (r:1 w:1)398 // Storage: Refungible AccountBalance (r:1 w:1)399 // Storage: Refungible TokensBurnt (r:1 w:1)400 // Storage: Refungible TokenData (r:0 w:1)401 // Storage: Refungible Owned (r:0 w:1)402 fn burn_from() -> Weight {403 (42_043_000 as Weight)404 .saturating_add(RocksDbWeight::get().reads(5 as Weight))405 .saturating_add(RocksDbWeight::get().writes(7 as Weight))406 }407 // Storage: Refungible TokenData (r:1 w:1)408 fn set_variable_metadata(_b: u32, ) -> Weight {409 (7_364_000 as Weight)410 .saturating_add(RocksDbWeight::get().reads(1 as Weight))411 .saturating_add(RocksDbWeight::get().writes(1 as Weight))412 }413}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 {