difftreelog
Revert "feat: burn children when destroying a collection"
in: master
This reverts commit 4b7f4d90a16f3a5ab26bed0511dabae078429724.
12 files changed
pallets/common/src/dispatch.rsdiffbeforeafterboth--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -6,7 +6,7 @@
weights::Pays,
traits::Get,
};
-use up_data_structs::{CollectionId, CreateCollectionData, budget::Budget};
+use up_data_structs::{CollectionId, CreateCollectionData};
use crate::{pallet::Config, CommonCollectionOperations, CollectionHandle};
@@ -57,11 +57,7 @@
pub trait CollectionDispatch<T: Config> {
fn create(sender: T::AccountId, data: CreateCollectionData<T::AccountId>) -> DispatchResult;
- fn destroy(
- sender: T::CrossAccountId,
- handle: CollectionHandle<T>,
- nesting_budget: &dyn Budget,
- ) -> DispatchResult;
+ fn destroy(sender: T::CrossAccountId, handle: CollectionHandle<T>) -> DispatchResult;
fn dispatch(handle: CollectionHandle<T>) -> Self;
fn into_inner(self) -> CollectionHandle<T>;
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -1169,12 +1169,6 @@
token: TokenId,
amount: u128,
) -> DispatchResultWithPostInfo;
- fn burn_item_unchecked(
- &self,
- owner: &T::CrossAccountId,
- token: TokenId,
- amount: u128,
- ) -> DispatchResult;
fn set_collection_properties(
&self,
sender: T::CrossAccountId,
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -170,17 +170,6 @@
)
}
- fn burn_item_unchecked(
- &self,
- owner: &T::CrossAccountId,
- _token: TokenId,
- amount: u128,
- ) -> sp_runtime::DispatchResult {
- <Pallet<T>>::burn_item_unchecked(self, owner, amount)?;
-
- Ok(())
- }
-
fn transfer(
&self,
from: T::CrossAccountId,
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -160,36 +160,6 @@
owner: &T::CrossAccountId,
amount: u128,
) -> DispatchResult {
- if collection.access == AccessMode::AllowList {
- collection.check_allowlist(owner)?;
- }
-
- // =========
-
- Self::burn_item_unchecked(collection, owner, amount)?;
-
- <PalletEvm<T>>::deposit_log(
- ERC20Events::Transfer {
- from: *owner.as_eth(),
- to: H160::default(),
- value: amount.into(),
- }
- .to_log(collection_id_to_address(collection.id)),
- );
- <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
- collection.id,
- TokenId::default(),
- owner.clone(),
- amount,
- ));
- Ok(())
- }
-
- pub fn burn_item_unchecked(
- collection: &FungibleHandle<T>,
- owner: &T::CrossAccountId,
- amount: u128,
- ) -> DispatchResult {
let total_supply = <TotalSupply<T>>::get(collection.id)
.checked_sub(amount)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
@@ -216,6 +186,20 @@
}
<TotalSupply<T>>::insert(collection.id, total_supply);
+ <PalletEvm<T>>::deposit_log(
+ ERC20Events::Transfer {
+ from: *owner.as_eth(),
+ to: H160::default(),
+ value: amount.into(),
+ }
+ .to_log(collection_id_to_address(collection.id)),
+ );
+ <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
+ collection.id,
+ TokenId::default(),
+ owner.clone(),
+ amount,
+ ));
Ok(())
}
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -264,19 +264,6 @@
}
}
- fn burn_item_unchecked(
- &self,
- owner:& T::CrossAccountId,
- token: TokenId,
- amount: u128,
- ) -> sp_runtime::DispatchResult {
- if amount == 1 {
- <Pallet<T>>::burn_item_unchecked(self, owner, token)
- } else {
- Ok(())
- }
- }
-
fn transfer(
&self,
from: T::CrossAccountId,
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -27,7 +27,6 @@
use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
use pallet_common::{
Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,
- dispatch::CollectionDispatch,
eth::collection_id_to_address,
};
use pallet_structure::Pallet as PalletStructure;
@@ -80,8 +79,6 @@
NonfungibleItemsHaveNoAmount,
/// Unable to burn NFT with children
CantBurnNftWithChildren,
- /// Too many children to burn when destroying a collection
- TooManyChildrenToBurn,
}
#[pallet::config]
@@ -293,14 +290,13 @@
pub fn destroy_collection(
collection: NonfungibleHandle<T>,
sender: &T::CrossAccountId,
- nesting_budget: &dyn Budget,
) -> DispatchResult {
let id = collection.id;
// =========
- Self::burn_children_in_collection(id, nesting_budget)?;
PalletCommon::destroy_collection(collection.0, sender)?;
+
<TokenData<T>>::remove_prefix((id,), None);
<TokenChildren<T>>::remove_prefix((id,), None);
<Owned<T>>::remove_prefix((id,), None);
@@ -308,47 +304,9 @@
<TokensBurnt<T>>::remove(id);
<Allowance<T>>::remove_prefix((id,), None);
<AccountBalance<T>>::remove_prefix((id,), None);
- Ok(())
- }
-
- #[transactional]
- fn burn_children_in_collection(collection_id: CollectionId, nesting_budget: &dyn Budget) -> DispatchResult {
- for (parent_id, child) in <TokenChildren<T>>::drain_prefix((collection_id,))
- .map(|((parent_id, child), _)| (parent_id, child)) {
-
- let parent_address = T::CrossTokenAddressMapping::token_to_address(collection_id, parent_id);
- Self::burn_tree(parent_address, child.0, child.1, nesting_budget)?;
- }
-
Ok(())
}
- fn burn_tree(
- parent: T::CrossAccountId,
- collection_id: CollectionId,
- token_id: TokenId,
- nesting_budget: &dyn Budget
- ) -> DispatchResult {
- if !nesting_budget.consume() {
- return Err(<Error<T>>::TooManyChildrenToBurn.into());
- }
-
- let handle = <CollectionHandle<T>>::try_get(collection_id)?;
- let handle = T::CollectionDispatch::dispatch(handle);
- let handle = handle.as_dyn();
-
- let amount = handle.balance(parent.clone(), token_id);
-
- handle.burn_item_unchecked(&parent, token_id, amount)?;
-
- for child in <TokenChildren<T>>::drain_prefix((collection_id, token_id)).map(|(child, _)| child) {
- let parent = T::CrossTokenAddressMapping::token_to_address(collection_id, token_id);
- Self::burn_tree(parent, child.0, child.1, nesting_budget)?;
- }
-
- Ok(())
- }
-
pub fn burn(
collection: &NonfungibleHandle<T>,
sender: &T::CrossAccountId,
@@ -370,11 +328,31 @@
return Err(<Error<T>>::CantBurnNftWithChildren.into());
}
- let old_spender = <Allowance<T>>::get((collection.id, token));
+ let burnt = <TokensBurnt<T>>::get(collection.id)
+ .checked_add(1)
+ .ok_or(ArithmeticError::Overflow)?;
+
+ let balance = <AccountBalance<T>>::get((collection.id, token_data.owner.clone()))
+ .checked_sub(1)
+ .ok_or(ArithmeticError::Overflow)?;
+
+ if balance == 0 {
+ <AccountBalance<T>>::remove((collection.id, token_data.owner.clone()));
+ } else {
+ <AccountBalance<T>>::insert((collection.id, token_data.owner.clone()), balance);
+ }
+
+ if let Some(owner) = T::CrossTokenAddressMapping::address_to_token(&token_data.owner) {
+ Self::unnest(owner, (collection.id, token));
+ }
// =========
- Self::burn_item_unchecked(collection, &token_data.owner, token)?;
+ <Owned<T>>::remove((collection.id, &token_data.owner, token));
+ <TokensBurnt<T>>::insert(collection.id, burnt);
+ <TokenData<T>>::remove((collection.id, token));
+ <TokenProperties<T>>::remove((collection.id, token));
+ let old_spender = <Allowance<T>>::take((collection.id, token));
if let Some(old_spender) = old_spender {
<PalletCommon<T>>::deposit_event(CommonEvent::Approved(
@@ -400,40 +378,6 @@
token_data.owner,
1,
));
- Ok(())
- }
-
- pub fn burn_item_unchecked(
- collection: &NonfungibleHandle<T>,
- owner: &T::CrossAccountId,
- token: TokenId,
- ) -> DispatchResult {
- let burnt = <TokensBurnt<T>>::get(collection.id)
- .checked_add(1)
- .ok_or(ArithmeticError::Overflow)?;
-
- let balance = <AccountBalance<T>>::get((collection.id, owner.clone()))
- .checked_sub(1)
- .ok_or(ArithmeticError::Overflow)?;
-
- // =========
-
- if let Some(owner) = T::CrossTokenAddressMapping::address_to_token(owner) {
- Self::unnest(owner, (collection.id, token));
- }
-
- if balance == 0 {
- <AccountBalance<T>>::remove((collection.id, owner.clone()));
- } else {
- <AccountBalance<T>>::insert((collection.id, owner.clone()), balance);
- }
-
- <Owned<T>>::remove((collection.id, owner, token));
- <TokensBurnt<T>>::insert(collection.id, burnt);
- <TokenData<T>>::remove((collection.id, token));
- <TokenProperties<T>>::remove((collection.id, token));
- <Allowance<T>>::remove((collection.id, token));
-
Ok(())
}
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -179,8 +179,7 @@
ensure!(collection.total_supply() == 0, <Error<T>>::CollectionNotEmpty);
- let empty_budget = budget::Value::new(0);
- <PalletNft<T>>::destroy_collection(collection, &cross_sender, &empty_budget)
+ <PalletNft<T>>::destroy_collection(collection, &cross_sender)
.map_err(Self::map_common_err_to_proxy)?;
Self::deposit_event(Event::CollectionDestroyed { issuer: sender, collection_id });
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -205,15 +205,6 @@
)
}
- fn burn_item_unchecked(
- &self,
- owner: &T::CrossAccountId,
- token: TokenId,
- amount: u128,
- ) -> sp_runtime::DispatchResult {
- <Pallet<T>>::burn_item_unchecked(self, owner, token, amount)
- }
-
fn transfer(
&self,
from: T::CrossAccountId,
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -245,25 +245,6 @@
token: TokenId,
amount: u128,
) -> DispatchResult {
- Self::burn_item_unchecked(collection, owner, token, amount)?;
-
- // TODO: ERC20 transfer event
- <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
- collection.id,
- token,
- owner.clone(),
- amount,
- ));
-
- Ok(())
- }
-
- pub fn burn_item_unchecked(
- collection: &RefungibleHandle<T>,
- owner: &T::CrossAccountId,
- token: TokenId,
- amount: u128,
- ) -> DispatchResult {
let total_supply = <TotalSupply<T>>::get((collection.id, token))
.checked_sub(amount)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
@@ -318,6 +299,13 @@
<Balance<T>>::insert((collection.id, token, owner), balance);
}
<TotalSupply<T>>::insert((collection.id, token), total_supply);
+ // TODO: ERC20 transfer event
+ <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
+ collection.id,
+ token,
+ owner.clone(),
+ amount,
+ ));
Ok(())
}
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -332,24 +332,15 @@
/// # Arguments
///
/// * collection_id: collection to destroy.
- #[weight =
- <SelfWeightOf<T>>::destroy_collection()
- + <SelfWeightOf<T>>::burn_children_in_collection(*max_children_to_burn)
- ]
+ #[weight = <SelfWeightOf<T>>::destroy_collection()]
#[transactional]
- pub fn destroy_collection(
- origin,
- collection_id: CollectionId,
- max_children_to_burn: u32,
- ) -> DispatchResult {
+ pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let collection = <CollectionHandle<T>>::try_get(collection_id)?;
- let budget = budget::Value::new(max_children_to_burn);
-
// =========
- T::CollectionDispatch::destroy(sender, collection, &budget)?;
+ T::CollectionDispatch::destroy(sender, collection)?;
<NftTransferBasket<T>>::remove_prefix(collection_id, None);
<FungibleTransferBasket<T>>::remove_prefix(collection_id, None);
pallets/unique/src/weights.rsdiffbeforeafterboth1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_unique4//!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-unique14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/unique/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_unique.34pub trait WeightInfo {35 fn create_collection() -> Weight;36 fn destroy_collection() -> Weight;37 fn burn_children_in_collection(max: u32) -> Weight;38 fn add_to_allow_list() -> Weight;39 fn remove_from_allow_list() -> Weight;40 fn set_public_access_mode() -> Weight;41 fn set_mint_permission() -> Weight;42 fn change_collection_owner() -> Weight;43 fn add_collection_admin() -> Weight;44 fn remove_collection_admin() -> Weight;45 fn set_collection_sponsor() -> Weight;46 fn confirm_sponsorship() -> Weight;47 fn remove_collection_sponsor() -> Weight;48 fn set_transfers_enabled_flag() -> Weight;49 fn set_offchain_schema(b: u32, ) -> Weight;50 fn set_const_on_chain_schema(b: u32, ) -> Weight;51 fn set_schema_version() -> Weight;52 fn set_collection_limits() -> Weight;53}5455/// Weights for pallet_unique using the Substrate node and recommended hardware.56pub struct SubstrateWeight<T>(PhantomData<T>);57impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {58 // Storage: Common CreatedCollectionCount (r:1 w:1)59 // Storage: Common DestroyedCollectionCount (r:1 w:0)60 // Storage: System Account (r:2 w:2)61 // Storage: Common CollectionById (r:0 w:1)62 fn create_collection() -> Weight {63 (28_929_000 as Weight)64 .saturating_add(T::DbWeight::get().reads(4 as Weight))65 .saturating_add(T::DbWeight::get().writes(4 as Weight))66 }67 // Storage: Common CollectionById (r:1 w:1)68 // Storage: Common DestroyedCollectionCount (r:1 w:1)69 // Storage: Nonfungible TokensMinted (r:0 w:1)70 // Storage: Nonfungible TokensBurnt (r:0 w:1)71 // Storage: Common AdminAmount (r:0 w:1)72 fn destroy_collection() -> Weight {73 (40_303_000 as Weight)74 .saturating_add(T::DbWeight::get().reads(2 as Weight))75 .saturating_add(T::DbWeight::get().writes(5 as Weight))76 }7778 fn burn_children_in_collection(max: u32) -> Weight {79 // TODO80 (50_000_000 as Weight).saturating_mul(max as Weight)81 }8283 // Storage: Common CollectionById (r:1 w:0)84 // Storage: Common Allowlist (r:0 w:1)85 fn add_to_allow_list() -> Weight {86 (15_989_000 as Weight)87 .saturating_add(T::DbWeight::get().reads(1 as Weight))88 .saturating_add(T::DbWeight::get().writes(1 as Weight))89 }90 // Storage: Common CollectionById (r:1 w:0)91 // Storage: Common Allowlist (r:0 w:1)92 fn remove_from_allow_list() -> Weight {93 (15_582_000 as Weight)94 .saturating_add(T::DbWeight::get().reads(1 as Weight))95 .saturating_add(T::DbWeight::get().writes(1 as Weight))96 }97 // Storage: Common CollectionById (r:1 w:1)98 fn set_public_access_mode() -> Weight {99 (14_846_000 as Weight)100 .saturating_add(T::DbWeight::get().reads(1 as Weight))101 .saturating_add(T::DbWeight::get().writes(1 as Weight))102 }103 // Storage: Common CollectionById (r:1 w:1)104 fn set_mint_permission() -> Weight {105 (14_534_000 as Weight)106 .saturating_add(T::DbWeight::get().reads(1 as Weight))107 .saturating_add(T::DbWeight::get().writes(1 as Weight))108 }109 // Storage: Common CollectionById (r:1 w:1)110 fn change_collection_owner() -> Weight {111 (14_990_000 as Weight)112 .saturating_add(T::DbWeight::get().reads(1 as Weight))113 .saturating_add(T::DbWeight::get().writes(1 as Weight))114 }115 // Storage: Common CollectionById (r:1 w:0)116 // Storage: Common IsAdmin (r:1 w:1)117 // Storage: Common AdminAmount (r:1 w:1)118 fn add_collection_admin() -> Weight {119 (19_957_000 as Weight)120 .saturating_add(T::DbWeight::get().reads(3 as Weight))121 .saturating_add(T::DbWeight::get().writes(2 as Weight))122 }123 // Storage: Common CollectionById (r:1 w:0)124 // Storage: Common IsAdmin (r:1 w:1)125 // Storage: Common AdminAmount (r:1 w:1)126 fn remove_collection_admin() -> Weight {127 (21_209_000 as Weight)128 .saturating_add(T::DbWeight::get().reads(3 as Weight))129 .saturating_add(T::DbWeight::get().writes(2 as Weight))130 }131 // Storage: Common CollectionById (r:1 w:1)132 fn set_collection_sponsor() -> Weight {133 (14_963_000 as Weight)134 .saturating_add(T::DbWeight::get().reads(1 as Weight))135 .saturating_add(T::DbWeight::get().writes(1 as Weight))136 }137 // Storage: Common CollectionById (r:1 w:1)138 fn confirm_sponsorship() -> Weight {139 (14_478_000 as Weight)140 .saturating_add(T::DbWeight::get().reads(1 as Weight))141 .saturating_add(T::DbWeight::get().writes(1 as Weight))142 }143 // Storage: Common CollectionById (r:1 w:1)144 fn remove_collection_sponsor() -> Weight {145 (14_393_000 as Weight)146 .saturating_add(T::DbWeight::get().reads(1 as Weight))147 .saturating_add(T::DbWeight::get().writes(1 as Weight))148 }149 // Storage: Common CollectionById (r:1 w:1)150 fn set_transfers_enabled_flag() -> Weight {151 (7_309_000 as Weight)152 .saturating_add(T::DbWeight::get().reads(1 as Weight))153 .saturating_add(T::DbWeight::get().writes(1 as Weight))154 }155 // Storage: Common CollectionById (r:1 w:1)156 fn set_offchain_schema(_b: u32, ) -> Weight {157 (15_220_000 as Weight)158 .saturating_add(T::DbWeight::get().reads(1 as Weight))159 .saturating_add(T::DbWeight::get().writes(1 as Weight))160 }161 // Storage: Common CollectionById (r:1 w:1)162 fn set_const_on_chain_schema(_b: u32, ) -> Weight {163 (14_984_000 as Weight)164 .saturating_add(T::DbWeight::get().reads(1 as Weight))165 .saturating_add(T::DbWeight::get().writes(1 as Weight))166 }167 // Storage: Common CollectionById (r:1 w:1)168 fn set_schema_version() -> Weight {169 (14_596_000 as Weight)170 .saturating_add(T::DbWeight::get().reads(1 as Weight))171 .saturating_add(T::DbWeight::get().writes(1 as Weight))172 }173 // Storage: Common CollectionById (r:1 w:1)174 fn set_collection_limits() -> Weight {175 (15_339_000 as Weight)176 .saturating_add(T::DbWeight::get().reads(1 as Weight))177 .saturating_add(T::DbWeight::get().writes(1 as Weight))178 }179}180181// For backwards compatibility and tests182impl WeightInfo for () {183 // Storage: Common CreatedCollectionCount (r:1 w:1)184 // Storage: Common DestroyedCollectionCount (r:1 w:0)185 // Storage: System Account (r:2 w:2)186 // Storage: Common CollectionById (r:0 w:1)187 fn create_collection() -> Weight {188 (28_929_000 as Weight)189 .saturating_add(RocksDbWeight::get().reads(4 as Weight))190 .saturating_add(RocksDbWeight::get().writes(4 as Weight))191 }192 // Storage: Common CollectionById (r:1 w:1)193 // Storage: Common DestroyedCollectionCount (r:1 w:1)194 // Storage: Nonfungible TokensMinted (r:0 w:1)195 // Storage: Nonfungible TokensBurnt (r:0 w:1)196 // Storage: Common AdminAmount (r:0 w:1)197 fn destroy_collection() -> Weight {198 (40_303_000 as Weight)199 .saturating_add(RocksDbWeight::get().reads(2 as Weight))200 .saturating_add(RocksDbWeight::get().writes(5 as Weight))201 }202203 fn burn_children_in_collection(max: u32) -> Weight {204 // TODO205 (50_000_000 as Weight).saturating_mul(max as Weight)206 }207208 // Storage: Common CollectionById (r:1 w:0)209 // Storage: Common Allowlist (r:0 w:1)210 fn add_to_allow_list() -> Weight {211 (15_989_000 as Weight)212 .saturating_add(RocksDbWeight::get().reads(1 as Weight))213 .saturating_add(RocksDbWeight::get().writes(1 as Weight))214 }215 // Storage: Common CollectionById (r:1 w:0)216 // Storage: Common Allowlist (r:0 w:1)217 fn remove_from_allow_list() -> Weight {218 (15_582_000 as Weight)219 .saturating_add(RocksDbWeight::get().reads(1 as Weight))220 .saturating_add(RocksDbWeight::get().writes(1 as Weight))221 }222 // Storage: Common CollectionById (r:1 w:1)223 fn set_public_access_mode() -> Weight {224 (14_846_000 as Weight)225 .saturating_add(RocksDbWeight::get().reads(1 as Weight))226 .saturating_add(RocksDbWeight::get().writes(1 as Weight))227 }228 // Storage: Common CollectionById (r:1 w:1)229 fn set_mint_permission() -> Weight {230 (14_534_000 as Weight)231 .saturating_add(RocksDbWeight::get().reads(1 as Weight))232 .saturating_add(RocksDbWeight::get().writes(1 as Weight))233 }234 // Storage: Common CollectionById (r:1 w:1)235 fn change_collection_owner() -> Weight {236 (14_990_000 as Weight)237 .saturating_add(RocksDbWeight::get().reads(1 as Weight))238 .saturating_add(RocksDbWeight::get().writes(1 as Weight))239 }240 // Storage: Common CollectionById (r:1 w:0)241 // Storage: Common IsAdmin (r:1 w:1)242 // Storage: Common AdminAmount (r:1 w:1)243 fn add_collection_admin() -> Weight {244 (19_957_000 as Weight)245 .saturating_add(RocksDbWeight::get().reads(3 as Weight))246 .saturating_add(RocksDbWeight::get().writes(2 as Weight))247 }248 // Storage: Common CollectionById (r:1 w:0)249 // Storage: Common IsAdmin (r:1 w:1)250 // Storage: Common AdminAmount (r:1 w:1)251 fn remove_collection_admin() -> Weight {252 (21_209_000 as Weight)253 .saturating_add(RocksDbWeight::get().reads(3 as Weight))254 .saturating_add(RocksDbWeight::get().writes(2 as Weight))255 }256 // Storage: Common CollectionById (r:1 w:1)257 fn set_collection_sponsor() -> Weight {258 (14_963_000 as Weight)259 .saturating_add(RocksDbWeight::get().reads(1 as Weight))260 .saturating_add(RocksDbWeight::get().writes(1 as Weight))261 }262 // Storage: Common CollectionById (r:1 w:1)263 fn confirm_sponsorship() -> Weight {264 (14_478_000 as Weight)265 .saturating_add(RocksDbWeight::get().reads(1 as Weight))266 .saturating_add(RocksDbWeight::get().writes(1 as Weight))267 }268 // Storage: Common CollectionById (r:1 w:1)269 fn remove_collection_sponsor() -> Weight {270 (14_393_000 as Weight)271 .saturating_add(RocksDbWeight::get().reads(1 as Weight))272 .saturating_add(RocksDbWeight::get().writes(1 as Weight))273 }274 // Storage: Common CollectionById (r:1 w:1)275 fn set_transfers_enabled_flag() -> Weight {276 (7_309_000 as Weight)277 .saturating_add(RocksDbWeight::get().reads(1 as Weight))278 .saturating_add(RocksDbWeight::get().writes(1 as Weight))279 }280 // Storage: Common CollectionById (r:1 w:1)281 fn set_offchain_schema(_b: u32, ) -> Weight {282 (15_220_000 as Weight)283 .saturating_add(RocksDbWeight::get().reads(1 as Weight))284 .saturating_add(RocksDbWeight::get().writes(1 as Weight))285 }286 // Storage: Common CollectionById (r:1 w:1)287 fn set_const_on_chain_schema(_b: u32, ) -> Weight {288 (14_984_000 as Weight)289 .saturating_add(RocksDbWeight::get().reads(1 as Weight))290 .saturating_add(RocksDbWeight::get().writes(1 as Weight))291 }292 // Storage: Common CollectionById (r:1 w:1)293 fn set_schema_version() -> Weight {294 (14_596_000 as Weight)295 .saturating_add(RocksDbWeight::get().reads(1 as Weight))296 .saturating_add(RocksDbWeight::get().writes(1 as Weight))297 }298 // Storage: Common CollectionById (r:1 w:1)299 fn set_collection_limits() -> Weight {300 (15_339_000 as Weight)301 .saturating_add(RocksDbWeight::get().reads(1 as Weight))302 .saturating_add(RocksDbWeight::get().writes(1 as Weight))303 }304}1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_unique4//!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-unique14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=20022// --heap-pages=409623// --output=./pallets/unique/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_unique.34pub trait WeightInfo {35 fn create_collection() -> Weight;36 fn destroy_collection() -> Weight;37 fn add_to_allow_list() -> Weight;38 fn remove_from_allow_list() -> Weight;39 fn set_public_access_mode() -> Weight;40 fn set_mint_permission() -> Weight;41 fn change_collection_owner() -> Weight;42 fn add_collection_admin() -> Weight;43 fn remove_collection_admin() -> Weight;44 fn set_collection_sponsor() -> Weight;45 fn confirm_sponsorship() -> Weight;46 fn remove_collection_sponsor() -> Weight;47 fn set_transfers_enabled_flag() -> Weight;48 fn set_offchain_schema(b: u32, ) -> Weight;49 fn set_const_on_chain_schema(b: u32, ) -> Weight;50 fn set_schema_version() -> Weight;51 fn set_collection_limits() -> Weight;52}5354/// Weights for pallet_unique using the Substrate node and recommended hardware.55pub struct SubstrateWeight<T>(PhantomData<T>);56impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {57 // Storage: Common CreatedCollectionCount (r:1 w:1)58 // Storage: Common DestroyedCollectionCount (r:1 w:0)59 // Storage: System Account (r:2 w:2)60 // Storage: Common CollectionById (r:0 w:1)61 fn create_collection() -> Weight {62 (28_929_000 as Weight)63 .saturating_add(T::DbWeight::get().reads(4 as Weight))64 .saturating_add(T::DbWeight::get().writes(4 as Weight))65 }66 // Storage: Common CollectionById (r:1 w:1)67 // Storage: Common DestroyedCollectionCount (r:1 w:1)68 // Storage: Nonfungible TokensMinted (r:0 w:1)69 // Storage: Nonfungible TokensBurnt (r:0 w:1)70 // Storage: Common AdminAmount (r:0 w:1)71 fn destroy_collection() -> Weight {72 (40_303_000 as Weight)73 .saturating_add(T::DbWeight::get().reads(2 as Weight))74 .saturating_add(T::DbWeight::get().writes(5 as Weight))75 }76 // Storage: Common CollectionById (r:1 w:0)77 // Storage: Common Allowlist (r:0 w:1)78 fn add_to_allow_list() -> Weight {79 (15_989_000 as Weight)80 .saturating_add(T::DbWeight::get().reads(1 as Weight))81 .saturating_add(T::DbWeight::get().writes(1 as Weight))82 }83 // Storage: Common CollectionById (r:1 w:0)84 // Storage: Common Allowlist (r:0 w:1)85 fn remove_from_allow_list() -> Weight {86 (15_582_000 as Weight)87 .saturating_add(T::DbWeight::get().reads(1 as Weight))88 .saturating_add(T::DbWeight::get().writes(1 as Weight))89 }90 // Storage: Common CollectionById (r:1 w:1)91 fn set_public_access_mode() -> Weight {92 (14_846_000 as Weight)93 .saturating_add(T::DbWeight::get().reads(1 as Weight))94 .saturating_add(T::DbWeight::get().writes(1 as Weight))95 }96 // Storage: Common CollectionById (r:1 w:1)97 fn set_mint_permission() -> Weight {98 (14_534_000 as Weight)99 .saturating_add(T::DbWeight::get().reads(1 as Weight))100 .saturating_add(T::DbWeight::get().writes(1 as Weight))101 }102 // Storage: Common CollectionById (r:1 w:1)103 fn change_collection_owner() -> Weight {104 (14_990_000 as Weight)105 .saturating_add(T::DbWeight::get().reads(1 as Weight))106 .saturating_add(T::DbWeight::get().writes(1 as Weight))107 }108 // Storage: Common CollectionById (r:1 w:0)109 // Storage: Common IsAdmin (r:1 w:1)110 // Storage: Common AdminAmount (r:1 w:1)111 fn add_collection_admin() -> Weight {112 (19_957_000 as Weight)113 .saturating_add(T::DbWeight::get().reads(3 as Weight))114 .saturating_add(T::DbWeight::get().writes(2 as Weight))115 }116 // Storage: Common CollectionById (r:1 w:0)117 // Storage: Common IsAdmin (r:1 w:1)118 // Storage: Common AdminAmount (r:1 w:1)119 fn remove_collection_admin() -> Weight {120 (21_209_000 as Weight)121 .saturating_add(T::DbWeight::get().reads(3 as Weight))122 .saturating_add(T::DbWeight::get().writes(2 as Weight))123 }124 // Storage: Common CollectionById (r:1 w:1)125 fn set_collection_sponsor() -> Weight {126 (14_963_000 as Weight)127 .saturating_add(T::DbWeight::get().reads(1 as Weight))128 .saturating_add(T::DbWeight::get().writes(1 as Weight))129 }130 // Storage: Common CollectionById (r:1 w:1)131 fn confirm_sponsorship() -> Weight {132 (14_478_000 as Weight)133 .saturating_add(T::DbWeight::get().reads(1 as Weight))134 .saturating_add(T::DbWeight::get().writes(1 as Weight))135 }136 // Storage: Common CollectionById (r:1 w:1)137 fn remove_collection_sponsor() -> Weight {138 (14_393_000 as Weight)139 .saturating_add(T::DbWeight::get().reads(1 as Weight))140 .saturating_add(T::DbWeight::get().writes(1 as Weight))141 }142 // Storage: Common CollectionById (r:1 w:1)143 fn set_transfers_enabled_flag() -> Weight {144 (7_309_000 as Weight)145 .saturating_add(T::DbWeight::get().reads(1 as Weight))146 .saturating_add(T::DbWeight::get().writes(1 as Weight))147 }148 // Storage: Common CollectionById (r:1 w:1)149 fn set_offchain_schema(_b: u32, ) -> Weight {150 (15_220_000 as Weight)151 .saturating_add(T::DbWeight::get().reads(1 as Weight))152 .saturating_add(T::DbWeight::get().writes(1 as Weight))153 }154 // Storage: Common CollectionById (r:1 w:1)155 fn set_const_on_chain_schema(_b: u32, ) -> Weight {156 (14_984_000 as Weight)157 .saturating_add(T::DbWeight::get().reads(1 as Weight))158 .saturating_add(T::DbWeight::get().writes(1 as Weight))159 }160 // Storage: Common CollectionById (r:1 w:1)161 fn set_schema_version() -> Weight {162 (14_596_000 as Weight)163 .saturating_add(T::DbWeight::get().reads(1 as Weight))164 .saturating_add(T::DbWeight::get().writes(1 as Weight))165 }166 // Storage: Common CollectionById (r:1 w:1)167 fn set_collection_limits() -> Weight {168 (15_339_000 as Weight)169 .saturating_add(T::DbWeight::get().reads(1 as Weight))170 .saturating_add(T::DbWeight::get().writes(1 as Weight))171 }172}173174// For backwards compatibility and tests175impl WeightInfo for () {176 // Storage: Common CreatedCollectionCount (r:1 w:1)177 // Storage: Common DestroyedCollectionCount (r:1 w:0)178 // Storage: System Account (r:2 w:2)179 // Storage: Common CollectionById (r:0 w:1)180 fn create_collection() -> Weight {181 (28_929_000 as Weight)182 .saturating_add(RocksDbWeight::get().reads(4 as Weight))183 .saturating_add(RocksDbWeight::get().writes(4 as Weight))184 }185 // Storage: Common CollectionById (r:1 w:1)186 // Storage: Common DestroyedCollectionCount (r:1 w:1)187 // Storage: Nonfungible TokensMinted (r:0 w:1)188 // Storage: Nonfungible TokensBurnt (r:0 w:1)189 // Storage: Common AdminAmount (r:0 w:1)190 fn destroy_collection() -> Weight {191 (40_303_000 as Weight)192 .saturating_add(RocksDbWeight::get().reads(2 as Weight))193 .saturating_add(RocksDbWeight::get().writes(5 as Weight))194 }195 // Storage: Common CollectionById (r:1 w:0)196 // Storage: Common Allowlist (r:0 w:1)197 fn add_to_allow_list() -> Weight {198 (15_989_000 as Weight)199 .saturating_add(RocksDbWeight::get().reads(1 as Weight))200 .saturating_add(RocksDbWeight::get().writes(1 as Weight))201 }202 // Storage: Common CollectionById (r:1 w:0)203 // Storage: Common Allowlist (r:0 w:1)204 fn remove_from_allow_list() -> Weight {205 (15_582_000 as Weight)206 .saturating_add(RocksDbWeight::get().reads(1 as Weight))207 .saturating_add(RocksDbWeight::get().writes(1 as Weight))208 }209 // Storage: Common CollectionById (r:1 w:1)210 fn set_public_access_mode() -> Weight {211 (14_846_000 as Weight)212 .saturating_add(RocksDbWeight::get().reads(1 as Weight))213 .saturating_add(RocksDbWeight::get().writes(1 as Weight))214 }215 // Storage: Common CollectionById (r:1 w:1)216 fn set_mint_permission() -> Weight {217 (14_534_000 as Weight)218 .saturating_add(RocksDbWeight::get().reads(1 as Weight))219 .saturating_add(RocksDbWeight::get().writes(1 as Weight))220 }221 // Storage: Common CollectionById (r:1 w:1)222 fn change_collection_owner() -> Weight {223 (14_990_000 as Weight)224 .saturating_add(RocksDbWeight::get().reads(1 as Weight))225 .saturating_add(RocksDbWeight::get().writes(1 as Weight))226 }227 // Storage: Common CollectionById (r:1 w:0)228 // Storage: Common IsAdmin (r:1 w:1)229 // Storage: Common AdminAmount (r:1 w:1)230 fn add_collection_admin() -> Weight {231 (19_957_000 as Weight)232 .saturating_add(RocksDbWeight::get().reads(3 as Weight))233 .saturating_add(RocksDbWeight::get().writes(2 as Weight))234 }235 // Storage: Common CollectionById (r:1 w:0)236 // Storage: Common IsAdmin (r:1 w:1)237 // Storage: Common AdminAmount (r:1 w:1)238 fn remove_collection_admin() -> Weight {239 (21_209_000 as Weight)240 .saturating_add(RocksDbWeight::get().reads(3 as Weight))241 .saturating_add(RocksDbWeight::get().writes(2 as Weight))242 }243 // Storage: Common CollectionById (r:1 w:1)244 fn set_collection_sponsor() -> Weight {245 (14_963_000 as Weight)246 .saturating_add(RocksDbWeight::get().reads(1 as Weight))247 .saturating_add(RocksDbWeight::get().writes(1 as Weight))248 }249 // Storage: Common CollectionById (r:1 w:1)250 fn confirm_sponsorship() -> Weight {251 (14_478_000 as Weight)252 .saturating_add(RocksDbWeight::get().reads(1 as Weight))253 .saturating_add(RocksDbWeight::get().writes(1 as Weight))254 }255 // Storage: Common CollectionById (r:1 w:1)256 fn remove_collection_sponsor() -> Weight {257 (14_393_000 as Weight)258 .saturating_add(RocksDbWeight::get().reads(1 as Weight))259 .saturating_add(RocksDbWeight::get().writes(1 as Weight))260 }261 // Storage: Common CollectionById (r:1 w:1)262 fn set_transfers_enabled_flag() -> Weight {263 (7_309_000 as Weight)264 .saturating_add(RocksDbWeight::get().reads(1 as Weight))265 .saturating_add(RocksDbWeight::get().writes(1 as Weight))266 }267 // Storage: Common CollectionById (r:1 w:1)268 fn set_offchain_schema(_b: u32, ) -> Weight {269 (15_220_000 as Weight)270 .saturating_add(RocksDbWeight::get().reads(1 as Weight))271 .saturating_add(RocksDbWeight::get().writes(1 as Weight))272 }273 // Storage: Common CollectionById (r:1 w:1)274 fn set_const_on_chain_schema(_b: u32, ) -> Weight {275 (14_984_000 as Weight)276 .saturating_add(RocksDbWeight::get().reads(1 as Weight))277 .saturating_add(RocksDbWeight::get().writes(1 as Weight))278 }279 // Storage: Common CollectionById (r:1 w:1)280 fn set_schema_version() -> Weight {281 (14_596_000 as Weight)282 .saturating_add(RocksDbWeight::get().reads(1 as Weight))283 .saturating_add(RocksDbWeight::get().writes(1 as Weight))284 }285 // Storage: Common CollectionById (r:1 w:1)286 fn set_collection_limits() -> Weight {287 (15_339_000 as Weight)288 .saturating_add(RocksDbWeight::get().reads(1 as Weight))289 .saturating_add(RocksDbWeight::get().writes(1 as Weight))290 }291}runtime/common/src/dispatch.rsdiffbeforeafterboth--- a/runtime/common/src/dispatch.rs
+++ b/runtime/common/src/dispatch.rs
@@ -1,4 +1,4 @@
-use frame_support::{dispatch::{DispatchResult}, ensure};
+use frame_support::{dispatch::DispatchResult, ensure};
use pallet_evm::PrecompileResult;
use sp_core::{H160, U256};
use sp_std::{borrow::ToOwned, vec::Vec};
@@ -12,7 +12,6 @@
use pallet_refungible::{Pallet as PalletRefungible, RefungibleHandle, erc::RefungibleTokenHandle};
use up_data_structs::{
CollectionMode, CreateCollectionData, MAX_DECIMAL_POINTS, mapping::TokenAddressMapping,
- budget::Budget,
};
pub enum CollectionDispatchT<T>
@@ -47,11 +46,7 @@
Ok(())
}
- fn destroy(
- sender: T::CrossAccountId,
- collection: CollectionHandle<T>,
- nesting_budget: &dyn Budget,
- ) -> DispatchResult {
+ fn destroy(sender: T::CrossAccountId, collection: CollectionHandle<T>) -> DispatchResult {
match collection.mode {
CollectionMode::ReFungible => {
PalletRefungible::destroy_collection(RefungibleHandle::cast(collection), &sender)?
@@ -60,11 +55,7 @@
PalletFungible::destroy_collection(FungibleHandle::cast(collection), &sender)?
}
CollectionMode::NFT => {
- PalletNonfungible::destroy_collection(
- NonfungibleHandle::cast(collection),
- &sender,
- nesting_budget,
- )?
+ PalletNonfungible::destroy_collection(NonfungibleHandle::cast(collection), &sender)?
}
}
Ok(())