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.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use core::marker::PhantomData;1819use sp_std::collections::btree_map::BTreeMap;20use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};21use up_data_structs::{22 CollectionId, TokenId, CreateItemExData, CreateRefungibleExData, budget::Budget, Property,23 PropertyKey, PropertyValue, PropertyKeyPermission, CreateItemData,24};25use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};26use sp_runtime::DispatchError;27use sp_std::{vec::Vec, vec};2829use crate::{30 AccountBalance, Allowance, Balance, Config, Error, Owned, Pallet, RefungibleHandle,31 SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,32};3334macro_rules! max_weight_of {35 ($($method:ident ($($args:tt)*)),*) => {36 037 $(38 .max(<SelfWeightOf<T>>::$method($($args)*))39 )*40 };41}4243pub struct CommonWeights<T: Config>(PhantomData<T>);44impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {45 fn create_item() -> Weight {46 <SelfWeightOf<T>>::create_item()47 }4849 fn create_multiple_items(data: &[CreateItemData]) -> Weight {50 <SelfWeightOf<T>>::create_multiple_items(data.len() as u32)51 }5253 fn create_multiple_items_ex(call: &CreateItemExData<T::CrossAccountId>) -> Weight {54 match call {55 CreateItemExData::RefungibleMultipleOwners(i) => {56 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)57 }58 CreateItemExData::RefungibleMultipleItems(i) => {59 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)60 }61 _ => 0,62 }63 }6465 fn burn_item() -> Weight {66 max_weight_of!(burn_item_partial(), burn_item_fully())67 }6869 fn set_collection_properties(_amount: u32) -> Weight {70 // Error71 072 }7374 fn delete_collection_properties(_amount: u32) -> Weight {75 // Error76 077 }7879 fn set_token_properties(amount: u32) -> Weight {80 <SelfWeightOf<T>>::set_token_properties(amount)81 }8283 fn delete_token_properties(amount: u32) -> Weight {84 <SelfWeightOf<T>>::delete_token_properties(amount)85 }8687 fn set_property_permissions(amount: u32) -> Weight {88 <SelfWeightOf<T>>::set_property_permissions(amount)89 }9091 fn transfer() -> Weight {92 max_weight_of!(93 transfer_normal(),94 transfer_creating(),95 transfer_removing(),96 transfer_creating_removing()97 )98 }99100 fn approve() -> Weight {101 <SelfWeightOf<T>>::approve()102 }103104 fn transfer_from() -> Weight {105 max_weight_of!(106 transfer_from_normal(),107 transfer_from_creating(),108 transfer_from_removing(),109 transfer_from_creating_removing()110 )111 }112113 fn burn_from() -> Weight {114 <SelfWeightOf<T>>::burn_from()115 }116}117118fn map_create_data<T: Config>(119 data: up_data_structs::CreateItemData,120 to: &T::CrossAccountId,121) -> Result<CreateRefungibleExData<T::CrossAccountId>, DispatchError> {122 match data {123 up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateRefungibleExData {124 const_data: data.const_data,125 users: {126 let mut out = BTreeMap::new();127 out.insert(to.clone(), data.pieces);128 out.try_into().expect("limit > 0")129 },130 }),131 _ => fail!(<Error<T>>::NotRefungibleDataUsedToMintFungibleCollectionToken),132 }133}134135impl<T: Config> CommonCollectionOperations<T> for RefungibleHandle<T> {136 fn create_item(137 &self,138 sender: T::CrossAccountId,139 to: T::CrossAccountId,140 data: up_data_structs::CreateItemData,141 nesting_budget: &dyn Budget,142 ) -> DispatchResultWithPostInfo {143 with_weight(144 <Pallet<T>>::create_item(145 self,146 &sender,147 map_create_data::<T>(data, &to)?,148 nesting_budget,149 ),150 <CommonWeights<T>>::create_item(),151 )152 }153154 fn create_multiple_items(155 &self,156 sender: T::CrossAccountId,157 to: T::CrossAccountId,158 data: Vec<up_data_structs::CreateItemData>,159 nesting_budget: &dyn Budget,160 ) -> DispatchResultWithPostInfo {161 let weight = <CommonWeights<T>>::create_multiple_items(&data);162 let data = data163 .into_iter()164 .map(|d| map_create_data::<T>(d, &to))165 .collect::<Result<Vec<_>, DispatchError>>()?;166167 with_weight(168 <Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),169 weight,170 )171 }172173 fn create_multiple_items_ex(174 &self,175 sender: <T>::CrossAccountId,176 data: CreateItemExData<T::CrossAccountId>,177 nesting_budget: &dyn Budget,178 ) -> DispatchResultWithPostInfo {179 let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);180 let data = match data {181 CreateItemExData::RefungibleMultipleOwners(r) => vec![r],182 CreateItemExData::RefungibleMultipleItems(r)183 if r.iter().all(|i| i.users.len() == 1) =>184 {185 r.into_inner()186 }187 _ => fail!(<Error<T>>::NotRefungibleDataUsedToMintFungibleCollectionToken),188 };189190 with_weight(191 <Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),192 weight,193 )194 }195196 fn burn_item(197 &self,198 sender: T::CrossAccountId,199 token: TokenId,200 amount: u128,201 ) -> DispatchResultWithPostInfo {202 with_weight(203 <Pallet<T>>::burn(self, &sender, token, amount),204 <CommonWeights<T>>::burn_item(),205 )206 }207208 fn burn_item_unchecked(209 &self,210 owner: &T::CrossAccountId,211 token: TokenId,212 amount: u128,213 ) -> sp_runtime::DispatchResult {214 <Pallet<T>>::burn_item_unchecked(self, owner, token, amount)215 }216217 fn transfer(218 &self,219 from: T::CrossAccountId,220 to: T::CrossAccountId,221 token: TokenId,222 amount: u128,223 nesting_budget: &dyn Budget,224 ) -> DispatchResultWithPostInfo {225 with_weight(226 <Pallet<T>>::transfer(self, &from, &to, token, amount, nesting_budget),227 <CommonWeights<T>>::transfer(),228 )229 }230231 fn approve(232 &self,233 sender: T::CrossAccountId,234 spender: T::CrossAccountId,235 token: TokenId,236 amount: u128,237 ) -> DispatchResultWithPostInfo {238 with_weight(239 <Pallet<T>>::set_allowance(self, &sender, &spender, token, amount),240 <CommonWeights<T>>::approve(),241 )242 }243244 fn transfer_from(245 &self,246 sender: T::CrossAccountId,247 from: T::CrossAccountId,248 to: T::CrossAccountId,249 token: TokenId,250 amount: u128,251 nesting_budget: &dyn Budget,252 ) -> DispatchResultWithPostInfo {253 with_weight(254 <Pallet<T>>::transfer_from(self, &sender, &from, &to, token, amount, nesting_budget),255 <CommonWeights<T>>::transfer_from(),256 )257 }258259 fn burn_from(260 &self,261 sender: T::CrossAccountId,262 from: T::CrossAccountId,263 token: TokenId,264 amount: u128,265 nesting_budget: &dyn Budget,266 ) -> DispatchResultWithPostInfo {267 with_weight(268 <Pallet<T>>::burn_from(self, &sender, &from, token, amount, nesting_budget),269 <CommonWeights<T>>::burn_from(),270 )271 }272273 fn set_collection_properties(274 &self,275 _sender: T::CrossAccountId,276 _property: Vec<Property>,277 ) -> DispatchResultWithPostInfo {278 fail!(<Error<T>>::SettingPropertiesNotAllowed)279 }280281 fn delete_collection_properties(282 &self,283 _sender: &T::CrossAccountId,284 _property_keys: Vec<PropertyKey>,285 ) -> DispatchResultWithPostInfo {286 fail!(<Error<T>>::SettingPropertiesNotAllowed)287 }288289 fn set_token_properties(290 &self,291 _sender: T::CrossAccountId,292 _token_id: TokenId,293 _property: Vec<Property>,294 ) -> DispatchResultWithPostInfo {295 fail!(<Error<T>>::SettingPropertiesNotAllowed)296 }297298 fn set_property_permissions(299 &self,300 _sender: &T::CrossAccountId,301 _property_permissions: Vec<PropertyKeyPermission>,302 ) -> DispatchResultWithPostInfo {303 fail!(<Error<T>>::SettingPropertiesNotAllowed)304 }305306 fn delete_token_properties(307 &self,308 _sender: T::CrossAccountId,309 _token_id: TokenId,310 _property_keys: Vec<PropertyKey>,311 ) -> DispatchResultWithPostInfo {312 fail!(<Error<T>>::SettingPropertiesNotAllowed)313 }314315 fn check_nesting(316 &self,317 _sender: <T>::CrossAccountId,318 _from: (CollectionId, TokenId),319 _under: TokenId,320 _budget: &dyn Budget,321 ) -> sp_runtime::DispatchResult {322 fail!(<Error<T>>::RefungibleDisallowsNesting)323 }324325 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {326 <Owned<T>>::iter_prefix((self.id, account))327 .map(|(id, _)| id)328 .collect()329 }330331 fn collection_tokens(&self) -> Vec<TokenId> {332 <TokenData<T>>::iter_prefix((self.id,))333 .map(|(id, _)| id)334 .collect()335 }336337 fn token_exists(&self, token: TokenId) -> bool {338 <Pallet<T>>::token_exists(self, token)339 }340341 fn last_token_id(&self) -> TokenId {342 TokenId(<TokensMinted<T>>::get(self.id))343 }344345 fn token_owner(&self, _token: TokenId) -> Option<T::CrossAccountId> {346 None347 }348349 fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {350 None351 }352353 fn token_properties(354 &self,355 _token_id: TokenId,356 _keys: Option<Vec<PropertyKey>>,357 ) -> Vec<Property> {358 Vec::new()359 }360361 fn total_supply(&self) -> u32 {362 <Pallet<T>>::total_supply(self)363 }364365 fn account_balance(&self, account: T::CrossAccountId) -> u32 {366 <AccountBalance<T>>::get((self.id, account))367 }368369 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {370 <Balance<T>>::get((self.id, token, account))371 }372373 fn allowance(374 &self,375 sender: T::CrossAccountId,376 spender: T::CrossAccountId,377 token: TokenId,378 ) -> u128 {379 <Allowance<T>>::get((self.id, token, sender, spender))380 }381}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.rsdiffbeforeafterboth--- a/pallets/unique/src/weights.rs
+++ b/pallets/unique/src/weights.rs
@@ -34,7 +34,6 @@
pub trait WeightInfo {
fn create_collection() -> Weight;
fn destroy_collection() -> Weight;
- fn burn_children_in_collection(max: u32) -> Weight;
fn add_to_allow_list() -> Weight;
fn remove_from_allow_list() -> Weight;
fn set_public_access_mode() -> Weight;
@@ -74,12 +73,6 @@
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
}
-
- fn burn_children_in_collection(max: u32) -> Weight {
- // TODO
- (50_000_000 as Weight).saturating_mul(max as Weight)
- }
-
// Storage: Common CollectionById (r:1 w:0)
// Storage: Common Allowlist (r:0 w:1)
fn add_to_allow_list() -> Weight {
@@ -199,12 +192,6 @@
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(5 as Weight))
}
-
- fn burn_children_in_collection(max: u32) -> Weight {
- // TODO
- (50_000_000 as Weight).saturating_mul(max as Weight)
- }
-
// Storage: Common CollectionById (r:1 w:0)
// Storage: Common Allowlist (r:0 w:1)
fn add_to_allow_list() -> Weight {
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(())