difftreelog
fieat: add repair_item extrinsic + test
in: master
15 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1815,6 +1815,9 @@
/// The price of setting approval for all
fn set_allowance_for_all() -> Weight;
+
+ /// The price of repairing an item.
+ fn repair_item() -> Weight;
}
/// Weight info extension trait for refungible pallet.
@@ -2136,6 +2139,9 @@
/// Tells whether the given `owner` approves the `operator`.
fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool;
+
+ /// Repairs a possibly broken item.
+ fn repair_item(&self, token: TokenId) -> DispatchResultWithPostInfo;
}
/// Extension for RFT collection.
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -111,6 +111,10 @@
fn set_allowance_for_all() -> Weight {
Weight::zero()
}
+
+ fn repair_item() -> Weight {
+ Weight::zero()
+ }
}
/// Implementation of `CommonCollectionOperations` for `FungibleHandle`. It wraps FungibleHandle Pallete
@@ -441,4 +445,9 @@
fn allowance_for_all(&self, _owner: T::CrossAccountId, _operator: T::CrossAccountId) -> bool {
false
}
+
+ /// Repairs a possibly broken item.
+ fn repair_item(&self, _token: TokenId) -> DispatchResultWithPostInfo {
+ fail!(<Error<T>>::FungibleTokensAreAlwaysValid)
+ }
}
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -129,6 +129,8 @@
SettingPropertiesNotAllowed,
/// Setting allowance for all is not allowed.
SettingAllowanceForAllNotAllowed,
+ /// Only a fungible collection could be possibly broken; any fungible token is valid.
+ FungibleTokensAreAlwaysValid,
}
#[pallet::config]
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -236,4 +236,12 @@
operator: cross_sub;
};
}: {<Pallet<T>>::allowance_for_all(&collection, &owner, &operator)}
+
+ repair_item {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub;
+ };
+ let item = create_max_item(&collection, &owner, owner.clone())?;
+ }: {<Pallet<T>>::repair_item(&collection, item)?}
}
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -126,6 +126,10 @@
fn set_allowance_for_all() -> Weight {
<SelfWeightOf<T>>::set_allowance_for_all()
}
+
+ fn repair_item() -> Weight {
+ <SelfWeightOf<T>>::repair_item()
+ }
}
fn map_create_data<T: Config>(
@@ -532,4 +536,11 @@
fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {
<Pallet<T>>::allowance_for_all(self, &owner, &operator)
}
+
+ fn repair_item(&self, token: TokenId) -> DispatchResultWithPostInfo {
+ with_weight(
+ <Pallet<T>>::repair_item(self, token),
+ <CommonWeights<T>>::repair_item(),
+ )
+ }
}
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -1398,4 +1398,12 @@
) -> bool {
<CollectionAllowance<T>>::get((collection.id, owner, operator))
}
+
+ pub fn repair_item(collection: &NonfungibleHandle<T>, token: TokenId) -> DispatchResult {
+ <TokenProperties<T>>::mutate((collection.id, token), |properties| {
+ properties.recompute_consumed_space();
+ });
+
+ Ok(())
+ }
}
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -50,6 +50,7 @@
fn token_owner() -> Weight;
fn set_allowance_for_all() -> Weight;
fn allowance_for_all() -> Weight;
+ fn repair_item() -> Weight;
}
/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.
@@ -208,6 +209,12 @@
Weight::from_ref_time(6_161_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
}
+ // Storage: Nonfungible TokenProperties (r:1 w:1)
+ fn repair_item() -> Weight {
+ Weight::from_ref_time(5_701_000 as u64)
+ .saturating_add(T::DbWeight::get().reads(1 as u64))
+ .saturating_add(T::DbWeight::get().writes(1 as u64))
+ }
}
// For backwards compatibility and tests
@@ -365,4 +372,10 @@
Weight::from_ref_time(6_161_000 as u64)
.saturating_add(RocksDbWeight::get().reads(1 as u64))
}
+ // Storage: Nonfungible TokenProperties (r:1 w:1)
+ fn repair_item() -> Weight {
+ Weight::from_ref_time(5_701_000 as u64)
+ .saturating_add(RocksDbWeight::get().reads(1 as u64))
+ .saturating_add(RocksDbWeight::get().writes(1 as u64))
+ }
}
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -304,4 +304,12 @@
operator: cross_sub;
};
}: {<Pallet<T>>::allowance_for_all(&collection, &owner, &operator)}
+
+ repair_item {
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ owner: cross_from_sub;
+ };
+ let item = create_max_item(&collection, &owner, [(owner.clone(), 100)])?;
+ }: {<Pallet<T>>::repair_item(&collection, item)?}
}
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -156,6 +156,10 @@
fn set_allowance_for_all() -> Weight {
<SelfWeightOf<T>>::set_allowance_for_all()
}
+
+ fn repair_item() -> Weight {
+ <SelfWeightOf<T>>::repair_item()
+ }
}
fn map_create_data<T: Config>(
@@ -536,6 +540,13 @@
fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {
<Pallet<T>>::allowance_for_all(self, &owner, &operator)
}
+
+ fn repair_item(&self, token: TokenId) -> DispatchResultWithPostInfo {
+ with_weight(
+ <Pallet<T>>::repair_item(self, token),
+ <CommonWeights<T>>::repair_item(),
+ )
+ }
}
impl<T: Config> RefungibleExtensions<T> for RefungibleHandle<T> {
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -1461,4 +1461,12 @@
) -> bool {
<CollectionAllowance<T>>::get((collection.id, owner, operator))
}
+
+ pub fn repair_item(collection: &RefungibleHandle<T>, token: TokenId) -> DispatchResult {
+ <TokenProperties<T>>::mutate((collection.id, token), |properties| {
+ properties.recompute_consumed_space();
+ });
+
+ Ok(())
+ }
}
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-11-25, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// pallet13// --pallet14// pallet-refungible15// --wasm-execution16// compiled17// --extrinsic18// *19// --template20// .maintain/frame-weight-template.hbs21// --steps=5022// --repeat=8023// --heap-pages=409624// --output=./pallets/refungible/src/weights.rs2526#![cfg_attr(rustfmt, rustfmt_skip)]27#![allow(unused_parens)]28#![allow(unused_imports)]29#![allow(missing_docs)]30#![allow(clippy::unnecessary_cast)]3132use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};33use sp_std::marker::PhantomData;3435/// Weight functions needed for pallet_refungible.36pub trait WeightInfo {37 fn create_item() -> Weight;38 fn create_multiple_items(b: u32, ) -> Weight;39 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight;40 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight;41 fn burn_item_partial() -> Weight;42 fn burn_item_fully() -> 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_token_property_permissions(b: u32, ) -> Weight;54 fn set_token_properties(b: u32, ) -> Weight;55 fn delete_token_properties(b: u32, ) -> Weight;56 fn repartition_item() -> Weight;57 fn token_owner() -> Weight;58 fn set_allowance_for_all() -> Weight;59 fn allowance_for_all() -> Weight;60}6162/// Weights for pallet_refungible using the Substrate node and recommended hardware.63pub struct SubstrateWeight<T>(PhantomData<T>);64impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {65 // Storage: Refungible TokensMinted (r:1 w:1)66 // Storage: Refungible AccountBalance (r:1 w:1)67 // Storage: Refungible Balance (r:0 w:1)68 // Storage: Refungible TotalSupply (r:0 w:1)69 // Storage: Refungible Owned (r:0 w:1)70 fn create_item() -> Weight {71 Weight::from_ref_time(29_527_000)72 .saturating_add(T::DbWeight::get().reads(2 as u64))73 .saturating_add(T::DbWeight::get().writes(5 as u64))74 }75 // Storage: Refungible TokensMinted (r:1 w:1)76 // Storage: Refungible AccountBalance (r:1 w:1)77 // Storage: Refungible Balance (r:0 w:4)78 // Storage: Refungible TotalSupply (r:0 w:4)79 // Storage: Refungible Owned (r:0 w:4)80 fn create_multiple_items(b: u32, ) -> Weight {81 Weight::from_ref_time(28_541_000)82 // Standard Error: 4_00083 .saturating_add(Weight::from_ref_time(6_671_000).saturating_mul(b as u64))84 .saturating_add(T::DbWeight::get().reads(2 as u64))85 .saturating_add(T::DbWeight::get().writes(2 as u64))86 .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(b as u64)))87 }88 // Storage: Refungible TokensMinted (r:1 w:1)89 // Storage: Refungible AccountBalance (r:4 w:4)90 // Storage: Refungible Balance (r:0 w:4)91 // Storage: Refungible TotalSupply (r:0 w:4)92 // Storage: Refungible Owned (r:0 w:4)93 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {94 Weight::from_ref_time(24_366_000)95 // Standard Error: 5_00096 .saturating_add(Weight::from_ref_time(9_338_000).saturating_mul(b as u64))97 .saturating_add(T::DbWeight::get().reads(1 as u64))98 .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(b as u64)))99 .saturating_add(T::DbWeight::get().writes(1 as u64))100 .saturating_add(T::DbWeight::get().writes((4 as u64).saturating_mul(b as u64)))101 }102 // Storage: Refungible TokensMinted (r:1 w:1)103 // Storage: Refungible TotalSupply (r:0 w:1)104 // Storage: Refungible AccountBalance (r:4 w:4)105 // Storage: Refungible Balance (r:0 w:4)106 // Storage: Refungible Owned (r:0 w:4)107 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {108 Weight::from_ref_time(27_574_000)109 // Standard Error: 4_000110 .saturating_add(Weight::from_ref_time(7_193_000).saturating_mul(b as u64))111 .saturating_add(T::DbWeight::get().reads(1 as u64))112 .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(b as u64)))113 .saturating_add(T::DbWeight::get().writes(2 as u64))114 .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(b as u64)))115 }116 // Storage: Refungible TotalSupply (r:1 w:1)117 // Storage: Refungible Balance (r:3 w:1)118 // Storage: Refungible AccountBalance (r:1 w:1)119 // Storage: Refungible Owned (r:0 w:1)120 fn burn_item_partial() -> Weight {121 Weight::from_ref_time(42_943_000)122 .saturating_add(T::DbWeight::get().reads(5 as u64))123 .saturating_add(T::DbWeight::get().writes(4 as u64))124 }125 // Storage: Refungible TotalSupply (r:1 w:1)126 // Storage: Refungible Balance (r:1 w:1)127 // Storage: Refungible AccountBalance (r:1 w:1)128 // Storage: Refungible TokensBurnt (r:1 w:1)129 // Storage: Refungible Owned (r:0 w:1)130 // Storage: Refungible TokenProperties (r:0 w:1)131 fn burn_item_fully() -> Weight {132 Weight::from_ref_time(36_861_000)133 .saturating_add(T::DbWeight::get().reads(4 as u64))134 .saturating_add(T::DbWeight::get().writes(6 as u64))135 }136 // Storage: Refungible Balance (r:2 w:2)137 // Storage: Refungible TotalSupply (r:1 w:0)138 fn transfer_normal() -> Weight {139 Weight::from_ref_time(27_789_000)140 .saturating_add(T::DbWeight::get().reads(3 as u64))141 .saturating_add(T::DbWeight::get().writes(2 as u64))142 }143 // Storage: Refungible Balance (r:2 w:2)144 // Storage: Refungible AccountBalance (r:1 w:1)145 // Storage: Refungible TotalSupply (r:1 w:0)146 // Storage: Refungible Owned (r:0 w:1)147 fn transfer_creating() -> Weight {148 Weight::from_ref_time(32_893_000)149 .saturating_add(T::DbWeight::get().reads(4 as u64))150 .saturating_add(T::DbWeight::get().writes(4 as u64))151 }152 // Storage: Refungible Balance (r:2 w:2)153 // Storage: Refungible AccountBalance (r:1 w:1)154 // Storage: Refungible TotalSupply (r:1 w:0)155 // Storage: Refungible Owned (r:0 w:1)156 fn transfer_removing() -> Weight {157 Weight::from_ref_time(34_703_000)158 .saturating_add(T::DbWeight::get().reads(4 as u64))159 .saturating_add(T::DbWeight::get().writes(4 as u64))160 }161 // Storage: Refungible Balance (r:2 w:2)162 // Storage: Refungible AccountBalance (r:2 w:2)163 // Storage: Refungible TotalSupply (r:1 w:0)164 // Storage: Refungible Owned (r:0 w:2)165 fn transfer_creating_removing() -> Weight {166 Weight::from_ref_time(37_547_000)167 .saturating_add(T::DbWeight::get().reads(5 as u64))168 .saturating_add(T::DbWeight::get().writes(6 as u64))169 }170 // Storage: Refungible Balance (r:1 w:0)171 // Storage: Refungible Allowance (r:0 w:1)172 fn approve() -> Weight {173 Weight::from_ref_time(20_039_000)174 .saturating_add(T::DbWeight::get().reads(1 as u64))175 .saturating_add(T::DbWeight::get().writes(1 as u64))176 }177 // Storage: Refungible Allowance (r:1 w:1)178 // Storage: Refungible Balance (r:2 w:2)179 // Storage: Refungible TotalSupply (r:1 w:0)180 fn transfer_from_normal() -> Weight {181 Weight::from_ref_time(37_628_000)182 .saturating_add(T::DbWeight::get().reads(4 as u64))183 .saturating_add(T::DbWeight::get().writes(3 as u64))184 }185 // Storage: Refungible Allowance (r:1 w:1)186 // Storage: Refungible Balance (r:2 w:2)187 // Storage: Refungible AccountBalance (r:1 w:1)188 // Storage: Refungible TotalSupply (r:1 w:0)189 // Storage: Refungible Owned (r:0 w:1)190 fn transfer_from_creating() -> Weight {191 Weight::from_ref_time(42_072_000)192 .saturating_add(T::DbWeight::get().reads(5 as u64))193 .saturating_add(T::DbWeight::get().writes(5 as u64))194 }195 // Storage: Refungible Allowance (r:1 w:1)196 // Storage: Refungible Balance (r:2 w:2)197 // Storage: Refungible AccountBalance (r:1 w:1)198 // Storage: Refungible TotalSupply (r:1 w:0)199 // Storage: Refungible Owned (r:0 w:1)200 fn transfer_from_removing() -> Weight {201 Weight::from_ref_time(43_024_000)202 .saturating_add(T::DbWeight::get().reads(5 as u64))203 .saturating_add(T::DbWeight::get().writes(5 as u64))204 }205 // Storage: Refungible Allowance (r:1 w:1)206 // Storage: Refungible Balance (r:2 w:2)207 // Storage: Refungible AccountBalance (r:2 w:2)208 // Storage: Refungible TotalSupply (r:1 w:0)209 // Storage: Refungible Owned (r:0 w:2)210 fn transfer_from_creating_removing() -> Weight {211 Weight::from_ref_time(45_910_000)212 .saturating_add(T::DbWeight::get().reads(6 as u64))213 .saturating_add(T::DbWeight::get().writes(7 as u64))214 }215 // Storage: Refungible Allowance (r:1 w:1)216 // Storage: Refungible TotalSupply (r:1 w:1)217 // Storage: Refungible Balance (r:1 w:1)218 // Storage: Refungible AccountBalance (r:1 w:1)219 // Storage: Refungible TokensBurnt (r:1 w:1)220 // Storage: Refungible Owned (r:0 w:1)221 // Storage: Refungible TokenProperties (r:0 w:1)222 fn burn_from() -> Weight {223 Weight::from_ref_time(48_584_000)224 .saturating_add(T::DbWeight::get().reads(5 as u64))225 .saturating_add(T::DbWeight::get().writes(7 as u64))226 }227 // Storage: Common CollectionPropertyPermissions (r:1 w:1)228 fn set_token_property_permissions(b: u32, ) -> Weight {229 (Weight::from_ref_time(0))230 // Standard Error: 60_000231 .saturating_add(Weight::from_ref_time(15_533_000).saturating_mul(b as u64))232 .saturating_add(T::DbWeight::get().reads(1 as u64))233 .saturating_add(T::DbWeight::get().writes(1 as u64))234 }235 // Storage: Common CollectionPropertyPermissions (r:1 w:0)236 // Storage: Refungible TokenProperties (r:1 w:1)237 fn set_token_properties(b: u32, ) -> Weight {238 (Weight::from_ref_time(0))239 // Standard Error: 3_609_000240 .saturating_add(Weight::from_ref_time(590_204_000).saturating_mul(b as u64))241 .saturating_add(T::DbWeight::get().reads(2 as u64))242 .saturating_add(T::DbWeight::get().writes(1 as u64))243 }244 // Storage: Common CollectionPropertyPermissions (r:1 w:0)245 // Storage: Refungible TokenProperties (r:1 w:1)246 fn delete_token_properties(b: u32, ) -> Weight {247 (Weight::from_ref_time(0))248 // Standard Error: 3_637_000249 .saturating_add(Weight::from_ref_time(603_468_000).saturating_mul(b as u64))250 .saturating_add(T::DbWeight::get().reads(2 as u64))251 .saturating_add(T::DbWeight::get().writes(1 as u64))252 }253 // Storage: Refungible TotalSupply (r:1 w:1)254 // Storage: Refungible Balance (r:1 w:1)255 fn repartition_item() -> Weight {256 Weight::from_ref_time(22_356_000)257 .saturating_add(T::DbWeight::get().reads(2 as u64))258 .saturating_add(T::DbWeight::get().writes(2 as u64))259 }260 // Storage: Refungible Balance (r:2 w:0)261 fn token_owner() -> Weight {262 Weight::from_ref_time(9_431_000)263 .saturating_add(T::DbWeight::get().reads(2 as u64))264 }265 // Storage: Refungible WalletOperator (r:0 w:1)266 fn set_allowance_for_all() -> Weight {267 Weight::from_ref_time(16_150_000 as u64)268 .saturating_add(T::DbWeight::get().writes(1 as u64))269 }270 // Storage: Refungible WalletOperator (r:1 w:0)271 fn allowance_for_all() -> Weight {272 Weight::from_ref_time(5_901_000 as u64)273 .saturating_add(T::DbWeight::get().reads(1 as u64))274 }275}276277// For backwards compatibility and tests278impl WeightInfo for () {279 // Storage: Refungible TokensMinted (r:1 w:1)280 // Storage: Refungible AccountBalance (r:1 w:1)281 // Storage: Refungible Balance (r:0 w:1)282 // Storage: Refungible TotalSupply (r:0 w:1)283 // Storage: Refungible Owned (r:0 w:1)284 fn create_item() -> Weight {285 Weight::from_ref_time(29_527_000)286 .saturating_add(RocksDbWeight::get().reads(2 as u64))287 .saturating_add(RocksDbWeight::get().writes(5 as u64))288 }289 // Storage: Refungible TokensMinted (r:1 w:1)290 // Storage: Refungible AccountBalance (r:1 w:1)291 // Storage: Refungible Balance (r:0 w:4)292 // Storage: Refungible TotalSupply (r:0 w:4)293 // Storage: Refungible Owned (r:0 w:4)294 fn create_multiple_items(b: u32, ) -> Weight {295 Weight::from_ref_time(28_541_000)296 // Standard Error: 4_000297 .saturating_add(Weight::from_ref_time(6_671_000).saturating_mul(b as u64))298 .saturating_add(RocksDbWeight::get().reads(2 as u64))299 .saturating_add(RocksDbWeight::get().writes(2 as u64))300 .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(b as u64)))301 }302 // Storage: Refungible TokensMinted (r:1 w:1)303 // Storage: Refungible AccountBalance (r:4 w:4)304 // Storage: Refungible Balance (r:0 w:4)305 // Storage: Refungible TotalSupply (r:0 w:4)306 // Storage: Refungible Owned (r:0 w:4)307 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {308 Weight::from_ref_time(24_366_000)309 // Standard Error: 5_000310 .saturating_add(Weight::from_ref_time(9_338_000).saturating_mul(b as u64))311 .saturating_add(RocksDbWeight::get().reads(1 as u64))312 .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(b as u64)))313 .saturating_add(RocksDbWeight::get().writes(1 as u64))314 .saturating_add(RocksDbWeight::get().writes((4 as u64).saturating_mul(b as u64)))315 }316 // Storage: Refungible TokensMinted (r:1 w:1)317 // Storage: Refungible TotalSupply (r:0 w:1)318 // Storage: Refungible AccountBalance (r:4 w:4)319 // Storage: Refungible Balance (r:0 w:4)320 // Storage: Refungible Owned (r:0 w:4)321 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {322 Weight::from_ref_time(27_574_000)323 // Standard Error: 4_000324 .saturating_add(Weight::from_ref_time(7_193_000).saturating_mul(b as u64))325 .saturating_add(RocksDbWeight::get().reads(1 as u64))326 .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(b as u64)))327 .saturating_add(RocksDbWeight::get().writes(2 as u64))328 .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(b as u64)))329 }330 // Storage: Refungible TotalSupply (r:1 w:1)331 // Storage: Refungible Balance (r:3 w:1)332 // Storage: Refungible AccountBalance (r:1 w:1)333 // Storage: Refungible Owned (r:0 w:1)334 fn burn_item_partial() -> Weight {335 Weight::from_ref_time(42_943_000)336 .saturating_add(RocksDbWeight::get().reads(5 as u64))337 .saturating_add(RocksDbWeight::get().writes(4 as u64))338 }339 // Storage: Refungible TotalSupply (r:1 w:1)340 // Storage: Refungible Balance (r:1 w:1)341 // Storage: Refungible AccountBalance (r:1 w:1)342 // Storage: Refungible TokensBurnt (r:1 w:1)343 // Storage: Refungible Owned (r:0 w:1)344 // Storage: Refungible TokenProperties (r:0 w:1)345 fn burn_item_fully() -> Weight {346 Weight::from_ref_time(36_861_000)347 .saturating_add(RocksDbWeight::get().reads(4 as u64))348 .saturating_add(RocksDbWeight::get().writes(6 as u64))349 }350 // Storage: Refungible Balance (r:2 w:2)351 // Storage: Refungible TotalSupply (r:1 w:0)352 fn transfer_normal() -> Weight {353 Weight::from_ref_time(27_789_000)354 .saturating_add(RocksDbWeight::get().reads(3 as u64))355 .saturating_add(RocksDbWeight::get().writes(2 as u64))356 }357 // Storage: Refungible Balance (r:2 w:2)358 // Storage: Refungible AccountBalance (r:1 w:1)359 // Storage: Refungible TotalSupply (r:1 w:0)360 // Storage: Refungible Owned (r:0 w:1)361 fn transfer_creating() -> Weight {362 Weight::from_ref_time(32_893_000)363 .saturating_add(RocksDbWeight::get().reads(4 as u64))364 .saturating_add(RocksDbWeight::get().writes(4 as u64))365 }366 // Storage: Refungible Balance (r:2 w:2)367 // Storage: Refungible AccountBalance (r:1 w:1)368 // Storage: Refungible TotalSupply (r:1 w:0)369 // Storage: Refungible Owned (r:0 w:1)370 fn transfer_removing() -> Weight {371 Weight::from_ref_time(34_703_000)372 .saturating_add(RocksDbWeight::get().reads(4 as u64))373 .saturating_add(RocksDbWeight::get().writes(4 as u64))374 }375 // Storage: Refungible Balance (r:2 w:2)376 // Storage: Refungible AccountBalance (r:2 w:2)377 // Storage: Refungible TotalSupply (r:1 w:0)378 // Storage: Refungible Owned (r:0 w:2)379 fn transfer_creating_removing() -> Weight {380 Weight::from_ref_time(37_547_000)381 .saturating_add(RocksDbWeight::get().reads(5 as u64))382 .saturating_add(RocksDbWeight::get().writes(6 as u64))383 }384 // Storage: Refungible Balance (r:1 w:0)385 // Storage: Refungible Allowance (r:0 w:1)386 fn approve() -> Weight {387 Weight::from_ref_time(20_039_000)388 .saturating_add(RocksDbWeight::get().reads(1 as u64))389 .saturating_add(RocksDbWeight::get().writes(1 as u64))390 }391 // Storage: Refungible Allowance (r:1 w:1)392 // Storage: Refungible Balance (r:2 w:2)393 // Storage: Refungible TotalSupply (r:1 w:0)394 fn transfer_from_normal() -> Weight {395 Weight::from_ref_time(37_628_000)396 .saturating_add(RocksDbWeight::get().reads(4 as u64))397 .saturating_add(RocksDbWeight::get().writes(3 as u64))398 }399 // Storage: Refungible Allowance (r:1 w:1)400 // Storage: Refungible Balance (r:2 w:2)401 // Storage: Refungible AccountBalance (r:1 w:1)402 // Storage: Refungible TotalSupply (r:1 w:0)403 // Storage: Refungible Owned (r:0 w:1)404 fn transfer_from_creating() -> Weight {405 Weight::from_ref_time(42_072_000)406 .saturating_add(RocksDbWeight::get().reads(5 as u64))407 .saturating_add(RocksDbWeight::get().writes(5 as u64))408 }409 // Storage: Refungible Allowance (r:1 w:1)410 // Storage: Refungible Balance (r:2 w:2)411 // Storage: Refungible AccountBalance (r:1 w:1)412 // Storage: Refungible TotalSupply (r:1 w:0)413 // Storage: Refungible Owned (r:0 w:1)414 fn transfer_from_removing() -> Weight {415 Weight::from_ref_time(43_024_000)416 .saturating_add(RocksDbWeight::get().reads(5 as u64))417 .saturating_add(RocksDbWeight::get().writes(5 as u64))418 }419 // Storage: Refungible Allowance (r:1 w:1)420 // Storage: Refungible Balance (r:2 w:2)421 // Storage: Refungible AccountBalance (r:2 w:2)422 // Storage: Refungible TotalSupply (r:1 w:0)423 // Storage: Refungible Owned (r:0 w:2)424 fn transfer_from_creating_removing() -> Weight {425 Weight::from_ref_time(45_910_000)426 .saturating_add(RocksDbWeight::get().reads(6 as u64))427 .saturating_add(RocksDbWeight::get().writes(7 as u64))428 }429 // Storage: Refungible Allowance (r:1 w:1)430 // Storage: Refungible TotalSupply (r:1 w:1)431 // Storage: Refungible Balance (r:1 w:1)432 // Storage: Refungible AccountBalance (r:1 w:1)433 // Storage: Refungible TokensBurnt (r:1 w:1)434 // Storage: Refungible Owned (r:0 w:1)435 // Storage: Refungible TokenProperties (r:0 w:1)436 fn burn_from() -> Weight {437 Weight::from_ref_time(48_584_000)438 .saturating_add(RocksDbWeight::get().reads(5 as u64))439 .saturating_add(RocksDbWeight::get().writes(7 as u64))440 }441 // Storage: Common CollectionPropertyPermissions (r:1 w:1)442 fn set_token_property_permissions(b: u32, ) -> Weight {443 (Weight::from_ref_time(0))444 // Standard Error: 60_000445 .saturating_add(Weight::from_ref_time(15_533_000).saturating_mul(b as u64))446 .saturating_add(RocksDbWeight::get().reads(1 as u64))447 .saturating_add(RocksDbWeight::get().writes(1 as u64))448 }449 // Storage: Common CollectionPropertyPermissions (r:1 w:0)450 // Storage: Refungible TokenProperties (r:1 w:1)451 fn set_token_properties(b: u32, ) -> Weight {452 (Weight::from_ref_time(0))453 // Standard Error: 3_609_000454 .saturating_add(Weight::from_ref_time(590_204_000).saturating_mul(b as u64))455 .saturating_add(RocksDbWeight::get().reads(2 as u64))456 .saturating_add(RocksDbWeight::get().writes(1 as u64))457 }458 // Storage: Common CollectionPropertyPermissions (r:1 w:0)459 // Storage: Refungible TokenProperties (r:1 w:1)460 fn delete_token_properties(b: u32, ) -> Weight {461 (Weight::from_ref_time(0))462 // Standard Error: 3_637_000463 .saturating_add(Weight::from_ref_time(603_468_000).saturating_mul(b as u64))464 .saturating_add(RocksDbWeight::get().reads(2 as u64))465 .saturating_add(RocksDbWeight::get().writes(1 as u64))466 }467 // Storage: Refungible TotalSupply (r:1 w:1)468 // Storage: Refungible Balance (r:1 w:1)469 fn repartition_item() -> Weight {470 Weight::from_ref_time(22_356_000)471 .saturating_add(RocksDbWeight::get().reads(2 as u64))472 .saturating_add(RocksDbWeight::get().writes(2 as u64))473 }474 // Storage: Refungible Balance (r:2 w:0)475 fn token_owner() -> Weight {476 Weight::from_ref_time(9_431_000)477 .saturating_add(RocksDbWeight::get().reads(2 as u64))478 }479 // Storage: Refungible WalletOperator (r:0 w:1)480 fn set_allowance_for_all() -> Weight {481 Weight::from_ref_time(16_150_000 as u64)482 .saturating_add(RocksDbWeight::get().writes(1 as u64))483 }484 // Storage: Refungible WalletOperator (r:1 w:0)485 fn allowance_for_all() -> Weight {486 Weight::from_ref_time(5_901_000 as u64)487 .saturating_add(RocksDbWeight::get().reads(1 as u64))488 }489}1// 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-11-25, STEPS: `50`, REPEAT: 80, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 102489// Executed Command:10// target/release/unique-collator11// benchmark12// pallet13// --pallet14// pallet-refungible15// --wasm-execution16// compiled17// --extrinsic18// *19// --template20// .maintain/frame-weight-template.hbs21// --steps=5022// --repeat=8023// --heap-pages=409624// --output=./pallets/refungible/src/weights.rs2526#![cfg_attr(rustfmt, rustfmt_skip)]27#![allow(unused_parens)]28#![allow(unused_imports)]29#![allow(missing_docs)]30#![allow(clippy::unnecessary_cast)]3132use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};33use sp_std::marker::PhantomData;3435/// Weight functions needed for pallet_refungible.36pub trait WeightInfo {37 fn create_item() -> Weight;38 fn create_multiple_items(b: u32, ) -> Weight;39 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight;40 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight;41 fn burn_item_partial() -> Weight;42 fn burn_item_fully() -> 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_token_property_permissions(b: u32, ) -> Weight;54 fn set_token_properties(b: u32, ) -> Weight;55 fn delete_token_properties(b: u32, ) -> Weight;56 fn repartition_item() -> Weight;57 fn token_owner() -> Weight;58 fn set_allowance_for_all() -> Weight;59 fn allowance_for_all() -> Weight;60 fn repair_item() -> Weight;61}6263/// Weights for pallet_refungible using the Substrate node and recommended hardware.64pub struct SubstrateWeight<T>(PhantomData<T>);65impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {66 // Storage: Refungible TokensMinted (r:1 w:1)67 // Storage: Refungible AccountBalance (r:1 w:1)68 // Storage: Refungible Balance (r:0 w:1)69 // Storage: Refungible TotalSupply (r:0 w:1)70 // Storage: Refungible Owned (r:0 w:1)71 fn create_item() -> Weight {72 Weight::from_ref_time(29_527_000)73 .saturating_add(T::DbWeight::get().reads(2 as u64))74 .saturating_add(T::DbWeight::get().writes(5 as u64))75 }76 // Storage: Refungible TokensMinted (r:1 w:1)77 // Storage: Refungible AccountBalance (r:1 w:1)78 // Storage: Refungible Balance (r:0 w:4)79 // Storage: Refungible TotalSupply (r:0 w:4)80 // Storage: Refungible Owned (r:0 w:4)81 fn create_multiple_items(b: u32, ) -> Weight {82 Weight::from_ref_time(28_541_000)83 // Standard Error: 4_00084 .saturating_add(Weight::from_ref_time(6_671_000).saturating_mul(b as u64))85 .saturating_add(T::DbWeight::get().reads(2 as u64))86 .saturating_add(T::DbWeight::get().writes(2 as u64))87 .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(b as u64)))88 }89 // Storage: Refungible TokensMinted (r:1 w:1)90 // Storage: Refungible AccountBalance (r:4 w:4)91 // Storage: Refungible Balance (r:0 w:4)92 // Storage: Refungible TotalSupply (r:0 w:4)93 // Storage: Refungible Owned (r:0 w:4)94 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {95 Weight::from_ref_time(24_366_000)96 // Standard Error: 5_00097 .saturating_add(Weight::from_ref_time(9_338_000).saturating_mul(b as u64))98 .saturating_add(T::DbWeight::get().reads(1 as u64))99 .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(b as u64)))100 .saturating_add(T::DbWeight::get().writes(1 as u64))101 .saturating_add(T::DbWeight::get().writes((4 as u64).saturating_mul(b as u64)))102 }103 // Storage: Refungible TokensMinted (r:1 w:1)104 // Storage: Refungible TotalSupply (r:0 w:1)105 // Storage: Refungible AccountBalance (r:4 w:4)106 // Storage: Refungible Balance (r:0 w:4)107 // Storage: Refungible Owned (r:0 w:4)108 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {109 Weight::from_ref_time(27_574_000)110 // Standard Error: 4_000111 .saturating_add(Weight::from_ref_time(7_193_000).saturating_mul(b as u64))112 .saturating_add(T::DbWeight::get().reads(1 as u64))113 .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(b as u64)))114 .saturating_add(T::DbWeight::get().writes(2 as u64))115 .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(b as u64)))116 }117 // Storage: Refungible TotalSupply (r:1 w:1)118 // Storage: Refungible Balance (r:3 w:1)119 // Storage: Refungible AccountBalance (r:1 w:1)120 // Storage: Refungible Owned (r:0 w:1)121 fn burn_item_partial() -> Weight {122 Weight::from_ref_time(42_943_000)123 .saturating_add(T::DbWeight::get().reads(5 as u64))124 .saturating_add(T::DbWeight::get().writes(4 as u64))125 }126 // Storage: Refungible TotalSupply (r:1 w:1)127 // Storage: Refungible Balance (r:1 w:1)128 // Storage: Refungible AccountBalance (r:1 w:1)129 // Storage: Refungible TokensBurnt (r:1 w:1)130 // Storage: Refungible Owned (r:0 w:1)131 // Storage: Refungible TokenProperties (r:0 w:1)132 fn burn_item_fully() -> Weight {133 Weight::from_ref_time(36_861_000)134 .saturating_add(T::DbWeight::get().reads(4 as u64))135 .saturating_add(T::DbWeight::get().writes(6 as u64))136 }137 // Storage: Refungible Balance (r:2 w:2)138 // Storage: Refungible TotalSupply (r:1 w:0)139 fn transfer_normal() -> Weight {140 Weight::from_ref_time(27_789_000)141 .saturating_add(T::DbWeight::get().reads(3 as u64))142 .saturating_add(T::DbWeight::get().writes(2 as u64))143 }144 // Storage: Refungible Balance (r:2 w:2)145 // Storage: Refungible AccountBalance (r:1 w:1)146 // Storage: Refungible TotalSupply (r:1 w:0)147 // Storage: Refungible Owned (r:0 w:1)148 fn transfer_creating() -> Weight {149 Weight::from_ref_time(32_893_000)150 .saturating_add(T::DbWeight::get().reads(4 as u64))151 .saturating_add(T::DbWeight::get().writes(4 as u64))152 }153 // Storage: Refungible Balance (r:2 w:2)154 // Storage: Refungible AccountBalance (r:1 w:1)155 // Storage: Refungible TotalSupply (r:1 w:0)156 // Storage: Refungible Owned (r:0 w:1)157 fn transfer_removing() -> Weight {158 Weight::from_ref_time(34_703_000)159 .saturating_add(T::DbWeight::get().reads(4 as u64))160 .saturating_add(T::DbWeight::get().writes(4 as u64))161 }162 // Storage: Refungible Balance (r:2 w:2)163 // Storage: Refungible AccountBalance (r:2 w:2)164 // Storage: Refungible TotalSupply (r:1 w:0)165 // Storage: Refungible Owned (r:0 w:2)166 fn transfer_creating_removing() -> Weight {167 Weight::from_ref_time(37_547_000)168 .saturating_add(T::DbWeight::get().reads(5 as u64))169 .saturating_add(T::DbWeight::get().writes(6 as u64))170 }171 // Storage: Refungible Balance (r:1 w:0)172 // Storage: Refungible Allowance (r:0 w:1)173 fn approve() -> Weight {174 Weight::from_ref_time(20_039_000)175 .saturating_add(T::DbWeight::get().reads(1 as u64))176 .saturating_add(T::DbWeight::get().writes(1 as u64))177 }178 // Storage: Refungible Allowance (r:1 w:1)179 // Storage: Refungible Balance (r:2 w:2)180 // Storage: Refungible TotalSupply (r:1 w:0)181 fn transfer_from_normal() -> Weight {182 Weight::from_ref_time(37_628_000)183 .saturating_add(T::DbWeight::get().reads(4 as u64))184 .saturating_add(T::DbWeight::get().writes(3 as u64))185 }186 // Storage: Refungible Allowance (r:1 w:1)187 // Storage: Refungible Balance (r:2 w:2)188 // Storage: Refungible AccountBalance (r:1 w:1)189 // Storage: Refungible TotalSupply (r:1 w:0)190 // Storage: Refungible Owned (r:0 w:1)191 fn transfer_from_creating() -> Weight {192 Weight::from_ref_time(42_072_000)193 .saturating_add(T::DbWeight::get().reads(5 as u64))194 .saturating_add(T::DbWeight::get().writes(5 as u64))195 }196 // Storage: Refungible Allowance (r:1 w:1)197 // Storage: Refungible Balance (r:2 w:2)198 // Storage: Refungible AccountBalance (r:1 w:1)199 // Storage: Refungible TotalSupply (r:1 w:0)200 // Storage: Refungible Owned (r:0 w:1)201 fn transfer_from_removing() -> Weight {202 Weight::from_ref_time(43_024_000)203 .saturating_add(T::DbWeight::get().reads(5 as u64))204 .saturating_add(T::DbWeight::get().writes(5 as u64))205 }206 // Storage: Refungible Allowance (r:1 w:1)207 // Storage: Refungible Balance (r:2 w:2)208 // Storage: Refungible AccountBalance (r:2 w:2)209 // Storage: Refungible TotalSupply (r:1 w:0)210 // Storage: Refungible Owned (r:0 w:2)211 fn transfer_from_creating_removing() -> Weight {212 Weight::from_ref_time(45_910_000)213 .saturating_add(T::DbWeight::get().reads(6 as u64))214 .saturating_add(T::DbWeight::get().writes(7 as u64))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 Owned (r:0 w:1)222 // Storage: Refungible TokenProperties (r:0 w:1)223 fn burn_from() -> Weight {224 Weight::from_ref_time(48_584_000)225 .saturating_add(T::DbWeight::get().reads(5 as u64))226 .saturating_add(T::DbWeight::get().writes(7 as u64))227 }228 // Storage: Common CollectionPropertyPermissions (r:1 w:1)229 fn set_token_property_permissions(b: u32, ) -> Weight {230 (Weight::from_ref_time(0))231 // Standard Error: 60_000232 .saturating_add(Weight::from_ref_time(15_533_000).saturating_mul(b as u64))233 .saturating_add(T::DbWeight::get().reads(1 as u64))234 .saturating_add(T::DbWeight::get().writes(1 as u64))235 }236 // Storage: Common CollectionPropertyPermissions (r:1 w:0)237 // Storage: Refungible TokenProperties (r:1 w:1)238 fn set_token_properties(b: u32, ) -> Weight {239 (Weight::from_ref_time(0))240 // Standard Error: 3_609_000241 .saturating_add(Weight::from_ref_time(590_204_000).saturating_mul(b as u64))242 .saturating_add(T::DbWeight::get().reads(2 as u64))243 .saturating_add(T::DbWeight::get().writes(1 as u64))244 }245 // Storage: Common CollectionPropertyPermissions (r:1 w:0)246 // Storage: Refungible TokenProperties (r:1 w:1)247 fn delete_token_properties(b: u32, ) -> Weight {248 (Weight::from_ref_time(0))249 // Standard Error: 3_637_000250 .saturating_add(Weight::from_ref_time(603_468_000).saturating_mul(b as u64))251 .saturating_add(T::DbWeight::get().reads(2 as u64))252 .saturating_add(T::DbWeight::get().writes(1 as u64))253 }254 // Storage: Refungible TotalSupply (r:1 w:1)255 // Storage: Refungible Balance (r:1 w:1)256 fn repartition_item() -> Weight {257 Weight::from_ref_time(22_356_000)258 .saturating_add(T::DbWeight::get().reads(2 as u64))259 .saturating_add(T::DbWeight::get().writes(2 as u64))260 }261 // Storage: Refungible Balance (r:2 w:0)262 fn token_owner() -> Weight {263 Weight::from_ref_time(9_431_000)264 .saturating_add(T::DbWeight::get().reads(2 as u64))265 }266 // Storage: Refungible WalletOperator (r:0 w:1)267 fn set_allowance_for_all() -> Weight {268 Weight::from_ref_time(16_150_000 as u64)269 .saturating_add(T::DbWeight::get().writes(1 as u64))270 }271 // Storage: Refungible WalletOperator (r:1 w:0)272 fn allowance_for_all() -> Weight {273 Weight::from_ref_time(5_901_000 as u64)274 .saturating_add(T::DbWeight::get().reads(1 as u64))275 }276 // Storage: Refungible TokenProperties (r:1 w:1)277 fn repair_item() -> Weight {278 Weight::from_ref_time(5_489_000 as u64)279 .saturating_add(T::DbWeight::get().reads(1 as u64))280 .saturating_add(T::DbWeight::get().writes(1 as u64))281 }282}283284// For backwards compatibility and tests285impl WeightInfo for () {286 // Storage: Refungible TokensMinted (r:1 w:1)287 // Storage: Refungible AccountBalance (r:1 w:1)288 // Storage: Refungible Balance (r:0 w:1)289 // Storage: Refungible TotalSupply (r:0 w:1)290 // Storage: Refungible Owned (r:0 w:1)291 fn create_item() -> Weight {292 Weight::from_ref_time(29_527_000)293 .saturating_add(RocksDbWeight::get().reads(2 as u64))294 .saturating_add(RocksDbWeight::get().writes(5 as u64))295 }296 // Storage: Refungible TokensMinted (r:1 w:1)297 // Storage: Refungible AccountBalance (r:1 w:1)298 // Storage: Refungible Balance (r:0 w:4)299 // Storage: Refungible TotalSupply (r:0 w:4)300 // Storage: Refungible Owned (r:0 w:4)301 fn create_multiple_items(b: u32, ) -> Weight {302 Weight::from_ref_time(28_541_000)303 // Standard Error: 4_000304 .saturating_add(Weight::from_ref_time(6_671_000).saturating_mul(b as u64))305 .saturating_add(RocksDbWeight::get().reads(2 as u64))306 .saturating_add(RocksDbWeight::get().writes(2 as u64))307 .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(b as u64)))308 }309 // Storage: Refungible TokensMinted (r:1 w:1)310 // Storage: Refungible AccountBalance (r:4 w:4)311 // Storage: Refungible Balance (r:0 w:4)312 // Storage: Refungible TotalSupply (r:0 w:4)313 // Storage: Refungible Owned (r:0 w:4)314 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {315 Weight::from_ref_time(24_366_000)316 // Standard Error: 5_000317 .saturating_add(Weight::from_ref_time(9_338_000).saturating_mul(b as u64))318 .saturating_add(RocksDbWeight::get().reads(1 as u64))319 .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(b as u64)))320 .saturating_add(RocksDbWeight::get().writes(1 as u64))321 .saturating_add(RocksDbWeight::get().writes((4 as u64).saturating_mul(b as u64)))322 }323 // Storage: Refungible TokensMinted (r:1 w:1)324 // Storage: Refungible TotalSupply (r:0 w:1)325 // Storage: Refungible AccountBalance (r:4 w:4)326 // Storage: Refungible Balance (r:0 w:4)327 // Storage: Refungible Owned (r:0 w:4)328 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {329 Weight::from_ref_time(27_574_000)330 // Standard Error: 4_000331 .saturating_add(Weight::from_ref_time(7_193_000).saturating_mul(b as u64))332 .saturating_add(RocksDbWeight::get().reads(1 as u64))333 .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(b as u64)))334 .saturating_add(RocksDbWeight::get().writes(2 as u64))335 .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(b as u64)))336 }337 // Storage: Refungible TotalSupply (r:1 w:1)338 // Storage: Refungible Balance (r:3 w:1)339 // Storage: Refungible AccountBalance (r:1 w:1)340 // Storage: Refungible Owned (r:0 w:1)341 fn burn_item_partial() -> Weight {342 Weight::from_ref_time(42_943_000)343 .saturating_add(RocksDbWeight::get().reads(5 as u64))344 .saturating_add(RocksDbWeight::get().writes(4 as u64))345 }346 // Storage: Refungible TotalSupply (r:1 w:1)347 // Storage: Refungible Balance (r:1 w:1)348 // Storage: Refungible AccountBalance (r:1 w:1)349 // Storage: Refungible TokensBurnt (r:1 w:1)350 // Storage: Refungible Owned (r:0 w:1)351 // Storage: Refungible TokenProperties (r:0 w:1)352 fn burn_item_fully() -> Weight {353 Weight::from_ref_time(36_861_000)354 .saturating_add(RocksDbWeight::get().reads(4 as u64))355 .saturating_add(RocksDbWeight::get().writes(6 as u64))356 }357 // Storage: Refungible Balance (r:2 w:2)358 // Storage: Refungible TotalSupply (r:1 w:0)359 fn transfer_normal() -> Weight {360 Weight::from_ref_time(27_789_000)361 .saturating_add(RocksDbWeight::get().reads(3 as u64))362 .saturating_add(RocksDbWeight::get().writes(2 as u64))363 }364 // Storage: Refungible Balance (r:2 w:2)365 // Storage: Refungible AccountBalance (r:1 w:1)366 // Storage: Refungible TotalSupply (r:1 w:0)367 // Storage: Refungible Owned (r:0 w:1)368 fn transfer_creating() -> Weight {369 Weight::from_ref_time(32_893_000)370 .saturating_add(RocksDbWeight::get().reads(4 as u64))371 .saturating_add(RocksDbWeight::get().writes(4 as u64))372 }373 // Storage: Refungible Balance (r:2 w:2)374 // Storage: Refungible AccountBalance (r:1 w:1)375 // Storage: Refungible TotalSupply (r:1 w:0)376 // Storage: Refungible Owned (r:0 w:1)377 fn transfer_removing() -> Weight {378 Weight::from_ref_time(34_703_000)379 .saturating_add(RocksDbWeight::get().reads(4 as u64))380 .saturating_add(RocksDbWeight::get().writes(4 as u64))381 }382 // Storage: Refungible Balance (r:2 w:2)383 // Storage: Refungible AccountBalance (r:2 w:2)384 // Storage: Refungible TotalSupply (r:1 w:0)385 // Storage: Refungible Owned (r:0 w:2)386 fn transfer_creating_removing() -> Weight {387 Weight::from_ref_time(37_547_000)388 .saturating_add(RocksDbWeight::get().reads(5 as u64))389 .saturating_add(RocksDbWeight::get().writes(6 as u64))390 }391 // Storage: Refungible Balance (r:1 w:0)392 // Storage: Refungible Allowance (r:0 w:1)393 fn approve() -> Weight {394 Weight::from_ref_time(20_039_000)395 .saturating_add(RocksDbWeight::get().reads(1 as u64))396 .saturating_add(RocksDbWeight::get().writes(1 as u64))397 }398 // Storage: Refungible Allowance (r:1 w:1)399 // Storage: Refungible Balance (r:2 w:2)400 // Storage: Refungible TotalSupply (r:1 w:0)401 fn transfer_from_normal() -> Weight {402 Weight::from_ref_time(37_628_000)403 .saturating_add(RocksDbWeight::get().reads(4 as u64))404 .saturating_add(RocksDbWeight::get().writes(3 as u64))405 }406 // Storage: Refungible Allowance (r:1 w:1)407 // Storage: Refungible Balance (r:2 w:2)408 // Storage: Refungible AccountBalance (r:1 w:1)409 // Storage: Refungible TotalSupply (r:1 w:0)410 // Storage: Refungible Owned (r:0 w:1)411 fn transfer_from_creating() -> Weight {412 Weight::from_ref_time(42_072_000)413 .saturating_add(RocksDbWeight::get().reads(5 as u64))414 .saturating_add(RocksDbWeight::get().writes(5 as u64))415 }416 // Storage: Refungible Allowance (r:1 w:1)417 // Storage: Refungible Balance (r:2 w:2)418 // Storage: Refungible AccountBalance (r:1 w:1)419 // Storage: Refungible TotalSupply (r:1 w:0)420 // Storage: Refungible Owned (r:0 w:1)421 fn transfer_from_removing() -> Weight {422 Weight::from_ref_time(43_024_000)423 .saturating_add(RocksDbWeight::get().reads(5 as u64))424 .saturating_add(RocksDbWeight::get().writes(5 as u64))425 }426 // Storage: Refungible Allowance (r:1 w:1)427 // Storage: Refungible Balance (r:2 w:2)428 // Storage: Refungible AccountBalance (r:2 w:2)429 // Storage: Refungible TotalSupply (r:1 w:0)430 // Storage: Refungible Owned (r:0 w:2)431 fn transfer_from_creating_removing() -> Weight {432 Weight::from_ref_time(45_910_000)433 .saturating_add(RocksDbWeight::get().reads(6 as u64))434 .saturating_add(RocksDbWeight::get().writes(7 as u64))435 }436 // Storage: Refungible Allowance (r:1 w:1)437 // Storage: Refungible TotalSupply (r:1 w:1)438 // Storage: Refungible Balance (r:1 w:1)439 // Storage: Refungible AccountBalance (r:1 w:1)440 // Storage: Refungible TokensBurnt (r:1 w:1)441 // Storage: Refungible Owned (r:0 w:1)442 // Storage: Refungible TokenProperties (r:0 w:1)443 fn burn_from() -> Weight {444 Weight::from_ref_time(48_584_000)445 .saturating_add(RocksDbWeight::get().reads(5 as u64))446 .saturating_add(RocksDbWeight::get().writes(7 as u64))447 }448 // Storage: Common CollectionPropertyPermissions (r:1 w:1)449 fn set_token_property_permissions(b: u32, ) -> Weight {450 (Weight::from_ref_time(0))451 // Standard Error: 60_000452 .saturating_add(Weight::from_ref_time(15_533_000).saturating_mul(b as u64))453 .saturating_add(RocksDbWeight::get().reads(1 as u64))454 .saturating_add(RocksDbWeight::get().writes(1 as u64))455 }456 // Storage: Common CollectionPropertyPermissions (r:1 w:0)457 // Storage: Refungible TokenProperties (r:1 w:1)458 fn set_token_properties(b: u32, ) -> Weight {459 (Weight::from_ref_time(0))460 // Standard Error: 3_609_000461 .saturating_add(Weight::from_ref_time(590_204_000).saturating_mul(b as u64))462 .saturating_add(RocksDbWeight::get().reads(2 as u64))463 .saturating_add(RocksDbWeight::get().writes(1 as u64))464 }465 // Storage: Common CollectionPropertyPermissions (r:1 w:0)466 // Storage: Refungible TokenProperties (r:1 w:1)467 fn delete_token_properties(b: u32, ) -> Weight {468 (Weight::from_ref_time(0))469 // Standard Error: 3_637_000470 .saturating_add(Weight::from_ref_time(603_468_000).saturating_mul(b as u64))471 .saturating_add(RocksDbWeight::get().reads(2 as u64))472 .saturating_add(RocksDbWeight::get().writes(1 as u64))473 }474 // Storage: Refungible TotalSupply (r:1 w:1)475 // Storage: Refungible Balance (r:1 w:1)476 fn repartition_item() -> Weight {477 Weight::from_ref_time(22_356_000)478 .saturating_add(RocksDbWeight::get().reads(2 as u64))479 .saturating_add(RocksDbWeight::get().writes(2 as u64))480 }481 // Storage: Refungible Balance (r:2 w:0)482 fn token_owner() -> Weight {483 Weight::from_ref_time(9_431_000)484 .saturating_add(RocksDbWeight::get().reads(2 as u64))485 }486 // Storage: Refungible WalletOperator (r:0 w:1)487 fn set_allowance_for_all() -> Weight {488 Weight::from_ref_time(16_150_000 as u64)489 .saturating_add(RocksDbWeight::get().writes(1 as u64))490 }491 // Storage: Refungible WalletOperator (r:1 w:0)492 fn allowance_for_all() -> Weight {493 Weight::from_ref_time(5_901_000 as u64)494 .saturating_add(RocksDbWeight::get().reads(1 as u64))495 }496 // Storage: Refungible TokenProperties (r:1 w:1)497 fn repair_item() -> Weight {498 Weight::from_ref_time(5_489_000 as u64)499 .saturating_add(RocksDbWeight::get().reads(1 as u64))500 .saturating_add(RocksDbWeight::get().writes(1 as u64))501 }502}pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -982,6 +982,23 @@
d.set_allowance_for_all(sender, operator, approve)
})
}
+
+ /// Repairs a broken item
+ ///
+ /// # Arguments
+ ///
+ /// * `collection_id`: ID of the collection the item belongs to.
+ /// * `item_id`: ID of the item.
+ #[weight = T::CommonWeightInfo::repair_item()]
+ pub fn repair_item(
+ _origin,
+ collection_id: CollectionId,
+ item_id: TokenId,
+ ) -> DispatchResultWithPostInfo {
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.repair_item(item_id)
+ })
+ }
}
}
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -1218,6 +1218,10 @@
Ok(())
}
+
+ pub fn values(&self) -> impl Iterator<Item = &Value> {
+ self.0.values()
+ }
}
impl<Value> IntoIterator for PropertiesMap<Value> {
@@ -1290,6 +1294,12 @@
pub fn get(&self, key: &PropertyKey) -> Option<&PropertyValue> {
self.map.get(key)
}
+
+ /// Recomputes the consumed space for the current properties state.
+ /// Needed to repair a token due to a bug fixed in the [PR #733](https://github.com/UniqueNetwork/unique-chain/pull/773).
+ pub fn recompute_consumed_space(&mut self) {
+ self.consumed_space = self.map.values().map(|value| value.len() as u32).sum();
+ }
}
impl IntoIterator for Properties {
runtime/common/weights.rsdiffbeforeafterboth--- a/runtime/common/weights.rs
+++ b/runtime/common/weights.rs
@@ -124,6 +124,10 @@
fn set_allowance_for_all() -> Weight {
max_weight_of!(set_allowance_for_all())
}
+
+ fn repair_item() -> Weight {
+ max_weight_of!(repair_item())
+ }
}
#[cfg(feature = "refungible")]
tests/src/nesting/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/tokenProperties.test.ts
+++ b/tests/src/nesting/tokenProperties.test.ts
@@ -28,7 +28,7 @@
before(async () => {
await usingPlaygrounds(async (helper, privateKey) => {
const donor = await privateKey({filename: __filename});
- [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);
+ [alice, bob, charlie] = await helper.arrange.createAccounts([200n, 100n, 100n], donor);
});
permissions = [
@@ -401,6 +401,39 @@
consumedSpace = await token.getTokenPropertiesConsumedSpace();
expect(consumedSpace).to.be.equal(originalSpace);
}));
+
+ [
+ {mode: 'nft' as const, pieces: undefined, requiredPallets: []},
+ {mode: 'rft' as const, pieces: 100n, requiredPallets: [Pallets.ReFungible]},
+ ].map(testCase =>
+ itSub.ifWithPallets(`repair_item preserves valid consumed space (${testCase.mode})`, testCase.requiredPallets, async({helper}) => {
+ const propKey = 'tok-prop';
+
+ const collection = await helper[testCase.mode].mintCollection(alice, {
+ tokenPropertyPermissions: [
+ {
+ key: propKey,
+ permission: {mutable: true, tokenOwner: true},
+ },
+ ],
+ });
+ const token = await (
+ testCase.pieces
+ ? collection.mintToken(alice, testCase.pieces)
+ : collection.mintToken(alice)
+ );
+
+ const propDataSize = 4096;
+ const propData = 'a'.repeat(propDataSize);
+
+ await token.setProperties(alice, [{key: propKey, value: propData}]);
+ const originalSpace = await token.getTokenPropertiesConsumedSpace();
+ expect(originalSpace).to.be.equal(propDataSize);
+
+ await helper.executeExtrinsic(alice, 'api.tx.unique.repairItem', [token.collectionId, token.tokenId], true);
+ const recomputedSpace = await token.getTokenPropertiesConsumedSpace();
+ expect(recomputedSpace).to.be.equal(originalSpace);
+ }));
});
describe('Negative Integration Test: Token Properties', () => {