difftreelog
Add extrinsic: delete collection property
in: master
10 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -292,6 +292,8 @@
CollectionPropertySet(CollectionId, Property),
+ CollectionPropertyDeleted(CollectionId, PropertyKey),
+
TokenPropertySet(CollectionId, TokenId, Property),
TokenPropertyDeleted(CollectionId, TokenId, PropertyKey),
@@ -761,6 +763,34 @@
Ok(())
}
+ pub fn delete_collection_property(
+ collection: &CollectionHandle<T>,
+ sender: &T::CrossAccountId,
+ property_key: PropertyKey,
+ ) -> DispatchResult {
+ collection.check_is_owner_or_admin(sender)?;
+
+ CollectionProperties::<T>::mutate(collection.id, |properties| {
+ properties.remove_property(&property_key);
+ });
+
+ Self::deposit_event(Event::CollectionPropertyDeleted(collection.id, property_key));
+
+ Ok(())
+ }
+
+ pub fn delete_collection_properties(
+ collection: &CollectionHandle<T>,
+ sender: &T::CrossAccountId,
+ property_keys: Vec<PropertyKey>,
+ ) -> DispatchResult {
+ for key in property_keys {
+ Self::delete_collection_property(collection, sender, key)?;
+ }
+
+ Ok(())
+ }
+
pub fn set_property_permission(
collection: &CollectionHandle<T>,
sender: &T::CrossAccountId,
@@ -956,6 +986,7 @@
fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;
fn burn_item() -> Weight;
fn set_collection_properties(amount: u32) -> Weight;
+ fn delete_collection_properties(amount: u32) -> Weight;
fn set_token_properties(amount: u32) -> Weight;
fn delete_token_properties(amount: u32) -> Weight;
fn set_property_permissions(amount: u32) -> Weight;
@@ -998,6 +1029,11 @@
sender: T::CrossAccountId,
properties: Vec<Property>,
) -> DispatchResultWithPostInfo;
+ fn delete_collection_properties(
+ &self,
+ sender: &T::CrossAccountId,
+ property_keys: Vec<PropertyKey>,
+ ) -> DispatchResultWithPostInfo;
fn set_token_properties(
&self,
sender: T::CrossAccountId,
pallets/fungible/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 frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, BoundedVec};20use up_data_structs::{TokenId, CollectionId, CreateItemExData, budget::Budget};21use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};22use sp_runtime::ArithmeticError;23use sp_std::{vec::Vec, vec};24use up_data_structs::{CustomDataLimit, Property, PropertyKey, PropertyKeyPermission};2526use crate::{27 Allowance, Balance, Config, Error, FungibleHandle, Pallet, SelfWeightOf, weights::WeightInfo,28};2930pub struct CommonWeights<T: Config>(PhantomData<T>);31impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {32 fn create_item() -> Weight {33 <SelfWeightOf<T>>::create_item()34 }3536 fn create_multiple_items(_amount: u32) -> Weight {37 Self::create_item()38 }3940 fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {41 match data {42 CreateItemExData::Fungible(f) => {43 <SelfWeightOf<T>>::create_multiple_items_ex(f.len() as u32)44 }45 _ => 0,46 }47 }4849 fn burn_item() -> Weight {50 <SelfWeightOf<T>>::burn_item()51 }5253 fn set_collection_properties(amount: u32) -> Weight {54 <SelfWeightOf<T>>::set_collection_properties(amount)55 }5657 fn set_token_properties(amount: u32) -> Weight {58 <SelfWeightOf<T>>::set_token_properties(amount)59 }6061 fn delete_token_properties(amount: u32) -> Weight {62 <SelfWeightOf<T>>::delete_token_properties(amount)63 }6465 fn set_property_permissions(amount: u32) -> Weight {66 <SelfWeightOf<T>>::set_property_permissions(amount)67 }6869 fn transfer() -> Weight {70 <SelfWeightOf<T>>::transfer()71 }7273 fn approve() -> Weight {74 <SelfWeightOf<T>>::approve()75 }7677 fn transfer_from() -> Weight {78 <SelfWeightOf<T>>::transfer_from()79 }8081 fn burn_from() -> Weight {82 <SelfWeightOf<T>>::burn_from()83 }8485 fn set_variable_metadata(_bytes: u32) -> Weight {86 // Error87 088 }89}9091impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {92 fn create_item(93 &self,94 sender: T::CrossAccountId,95 to: T::CrossAccountId,96 data: up_data_structs::CreateItemData,97 nesting_budget: &dyn Budget,98 ) -> DispatchResultWithPostInfo {99 match data {100 up_data_structs::CreateItemData::Fungible(data) => with_weight(101 <Pallet<T>>::create_item(self, &sender, (to, data.value), nesting_budget),102 <CommonWeights<T>>::create_item(),103 ),104 _ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),105 }106 }107108 fn create_multiple_items(109 &self,110 sender: T::CrossAccountId,111 to: T::CrossAccountId,112 data: Vec<up_data_structs::CreateItemData>,113 nesting_budget: &dyn Budget,114 ) -> DispatchResultWithPostInfo {115 let mut sum: u128 = 0;116 for data in data {117 match data {118 up_data_structs::CreateItemData::Fungible(data) => {119 sum = sum120 .checked_add(data.value)121 .ok_or(ArithmeticError::Overflow)?;122 }123 _ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),124 }125 }126127 with_weight(128 <Pallet<T>>::create_item(self, &sender, (to, sum), nesting_budget),129 <CommonWeights<T>>::create_item(),130 )131 }132133 fn create_multiple_items_ex(134 &self,135 sender: <T>::CrossAccountId,136 data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,137 nesting_budget: &dyn Budget,138 ) -> DispatchResultWithPostInfo {139 let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);140 let data = match data {141 up_data_structs::CreateItemExData::Fungible(f) => f,142 _ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),143 };144145 with_weight(146 <Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),147 weight,148 )149 }150151 fn burn_item(152 &self,153 sender: T::CrossAccountId,154 token: TokenId,155 amount: u128,156 ) -> DispatchResultWithPostInfo {157 ensure!(158 token == TokenId::default(),159 <Error<T>>::FungibleItemsHaveNoId160 );161162 with_weight(163 <Pallet<T>>::burn(self, &sender, amount),164 <CommonWeights<T>>::burn_item(),165 )166 }167168 fn transfer(169 &self,170 from: T::CrossAccountId,171 to: T::CrossAccountId,172 token: TokenId,173 amount: u128,174 nesting_budget: &dyn Budget,175 ) -> DispatchResultWithPostInfo {176 ensure!(177 token == TokenId::default(),178 <Error<T>>::FungibleItemsHaveNoId179 );180181 with_weight(182 <Pallet<T>>::transfer(self, &from, &to, amount, nesting_budget),183 <CommonWeights<T>>::transfer(),184 )185 }186187 fn approve(188 &self,189 sender: T::CrossAccountId,190 spender: T::CrossAccountId,191 token: TokenId,192 amount: u128,193 ) -> DispatchResultWithPostInfo {194 ensure!(195 token == TokenId::default(),196 <Error<T>>::FungibleItemsHaveNoId197 );198199 with_weight(200 <Pallet<T>>::set_allowance(self, &sender, &spender, amount),201 <CommonWeights<T>>::approve(),202 )203 }204205 fn transfer_from(206 &self,207 sender: T::CrossAccountId,208 from: T::CrossAccountId,209 to: T::CrossAccountId,210 token: TokenId,211 amount: u128,212 nesting_budget: &dyn Budget,213 ) -> DispatchResultWithPostInfo {214 ensure!(215 token == TokenId::default(),216 <Error<T>>::FungibleItemsHaveNoId217 );218219 with_weight(220 <Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, nesting_budget),221 <CommonWeights<T>>::transfer_from(),222 )223 }224225 fn burn_from(226 &self,227 sender: T::CrossAccountId,228 from: T::CrossAccountId,229 token: TokenId,230 amount: u128,231 nesting_budget: &dyn Budget,232 ) -> DispatchResultWithPostInfo {233 ensure!(234 token == TokenId::default(),235 <Error<T>>::FungibleItemsHaveNoId236 );237238 with_weight(239 <Pallet<T>>::burn_from(self, &sender, &from, amount, nesting_budget),240 <CommonWeights<T>>::burn_from(),241 )242 }243244 fn set_collection_properties(245 &self,246 _sender: T::CrossAccountId,247 _property: Vec<Property>,248 ) -> DispatchResultWithPostInfo {249 fail!(<Error<T>>::PropertiesNotAllowed)250 }251252 fn set_token_properties(253 &self,254 _sender: T::CrossAccountId,255 _token_id: TokenId,256 _property: Vec<Property>,257 ) -> DispatchResultWithPostInfo {258 fail!(<Error<T>>::PropertiesNotAllowed)259 }260261 fn set_property_permissions(262 &self,263 _sender: &T::CrossAccountId,264 _property_permissions: Vec<PropertyKeyPermission>,265 ) -> DispatchResultWithPostInfo {266 fail!(<Error<T>>::PropertiesNotAllowed)267 }268269 fn delete_token_properties(270 &self,271 _sender: T::CrossAccountId,272 _token_id: TokenId,273 _property_keys: Vec<PropertyKey>,274 ) -> DispatchResultWithPostInfo {275 fail!(<Error<T>>::PropertiesNotAllowed)276 }277278 fn set_variable_metadata(279 &self,280 _sender: T::CrossAccountId,281 _token: TokenId,282 _data: BoundedVec<u8, CustomDataLimit>,283 ) -> DispatchResultWithPostInfo {284 fail!(<Error<T>>::FungibleItemsDontHaveData)285 }286287 fn check_nesting(288 &self,289 _sender: <T>::CrossAccountId,290 _from: (CollectionId, TokenId),291 _under: TokenId,292 _budget: &dyn Budget,293 ) -> sp_runtime::DispatchResult {294 fail!(<Error<T>>::FungibleDisallowsNesting)295 }296297 fn collection_tokens(&self) -> Vec<TokenId> {298 vec![TokenId::default()]299 }300301 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {302 if <Balance<T>>::get((self.id, account)) != 0 {303 vec![TokenId::default()]304 } else {305 vec![]306 }307 }308309 fn token_exists(&self, token: TokenId) -> bool {310 token == TokenId::default()311 }312313 fn last_token_id(&self) -> TokenId {314 TokenId::default()315 }316317 fn token_owner(&self, _token: TokenId) -> Option<T::CrossAccountId> {318 None319 }320 fn const_metadata(&self, _token: TokenId) -> Vec<u8> {321 Vec::new()322 }323 fn variable_metadata(&self, _token: TokenId) -> Vec<u8> {324 Vec::new()325 }326327 fn total_supply(&self) -> u32 {328 1329 }330331 fn account_balance(&self, account: T::CrossAccountId) -> u32 {332 if <Balance<T>>::get((self.id, account)) != 0 {333 1334 } else {335 0336 }337 }338339 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {340 if token != TokenId::default() {341 return 0;342 }343 <Balance<T>>::get((self.id, account))344 }345346 fn allowance(347 &self,348 sender: T::CrossAccountId,349 spender: T::CrossAccountId,350 token: TokenId,351 ) -> u128 {352 if token != TokenId::default() {353 return 0;354 }355 <Allowance<T>>::get((self.id, sender, spender))356 }357}1// 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 frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, BoundedVec};20use up_data_structs::{TokenId, CollectionId, CreateItemExData, budget::Budget};21use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};22use sp_runtime::ArithmeticError;23use sp_std::{vec::Vec, vec};24use up_data_structs::{CustomDataLimit, Property, PropertyKey, PropertyKeyPermission};2526use crate::{27 Allowance, Balance, Config, Error, FungibleHandle, Pallet, SelfWeightOf, weights::WeightInfo,28};2930pub struct CommonWeights<T: Config>(PhantomData<T>);31impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {32 fn create_item() -> Weight {33 <SelfWeightOf<T>>::create_item()34 }3536 fn create_multiple_items(_amount: u32) -> Weight {37 Self::create_item()38 }3940 fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {41 match data {42 CreateItemExData::Fungible(f) => {43 <SelfWeightOf<T>>::create_multiple_items_ex(f.len() as u32)44 }45 _ => 0,46 }47 }4849 fn burn_item() -> Weight {50 <SelfWeightOf<T>>::burn_item()51 }5253 fn set_collection_properties(amount: u32) -> Weight {54 <SelfWeightOf<T>>::set_collection_properties(amount)55 }5657 fn delete_collection_properties(amount: u32) -> Weight {58 <SelfWeightOf<T>>::delete_collection_properties(amount)59 }6061 fn set_token_properties(amount: u32) -> Weight {62 <SelfWeightOf<T>>::set_token_properties(amount)63 }6465 fn delete_token_properties(amount: u32) -> Weight {66 <SelfWeightOf<T>>::delete_token_properties(amount)67 }6869 fn set_property_permissions(amount: u32) -> Weight {70 <SelfWeightOf<T>>::set_property_permissions(amount)71 }7273 fn transfer() -> Weight {74 <SelfWeightOf<T>>::transfer()75 }7677 fn approve() -> Weight {78 <SelfWeightOf<T>>::approve()79 }8081 fn transfer_from() -> Weight {82 <SelfWeightOf<T>>::transfer_from()83 }8485 fn burn_from() -> Weight {86 <SelfWeightOf<T>>::burn_from()87 }8889 fn set_variable_metadata(_bytes: u32) -> Weight {90 // Error91 092 }93}9495impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {96 fn create_item(97 &self,98 sender: T::CrossAccountId,99 to: T::CrossAccountId,100 data: up_data_structs::CreateItemData,101 nesting_budget: &dyn Budget,102 ) -> DispatchResultWithPostInfo {103 match data {104 up_data_structs::CreateItemData::Fungible(data) => with_weight(105 <Pallet<T>>::create_item(self, &sender, (to, data.value), nesting_budget),106 <CommonWeights<T>>::create_item(),107 ),108 _ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),109 }110 }111112 fn create_multiple_items(113 &self,114 sender: T::CrossAccountId,115 to: T::CrossAccountId,116 data: Vec<up_data_structs::CreateItemData>,117 nesting_budget: &dyn Budget,118 ) -> DispatchResultWithPostInfo {119 let mut sum: u128 = 0;120 for data in data {121 match data {122 up_data_structs::CreateItemData::Fungible(data) => {123 sum = sum124 .checked_add(data.value)125 .ok_or(ArithmeticError::Overflow)?;126 }127 _ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),128 }129 }130131 with_weight(132 <Pallet<T>>::create_item(self, &sender, (to, sum), nesting_budget),133 <CommonWeights<T>>::create_item(),134 )135 }136137 fn create_multiple_items_ex(138 &self,139 sender: <T>::CrossAccountId,140 data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,141 nesting_budget: &dyn Budget,142 ) -> DispatchResultWithPostInfo {143 let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);144 let data = match data {145 up_data_structs::CreateItemExData::Fungible(f) => f,146 _ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),147 };148149 with_weight(150 <Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),151 weight,152 )153 }154155 fn burn_item(156 &self,157 sender: T::CrossAccountId,158 token: TokenId,159 amount: u128,160 ) -> DispatchResultWithPostInfo {161 ensure!(162 token == TokenId::default(),163 <Error<T>>::FungibleItemsHaveNoId164 );165166 with_weight(167 <Pallet<T>>::burn(self, &sender, amount),168 <CommonWeights<T>>::burn_item(),169 )170 }171172 fn transfer(173 &self,174 from: T::CrossAccountId,175 to: T::CrossAccountId,176 token: TokenId,177 amount: u128,178 nesting_budget: &dyn Budget,179 ) -> DispatchResultWithPostInfo {180 ensure!(181 token == TokenId::default(),182 <Error<T>>::FungibleItemsHaveNoId183 );184185 with_weight(186 <Pallet<T>>::transfer(self, &from, &to, amount, nesting_budget),187 <CommonWeights<T>>::transfer(),188 )189 }190191 fn approve(192 &self,193 sender: T::CrossAccountId,194 spender: T::CrossAccountId,195 token: TokenId,196 amount: u128,197 ) -> DispatchResultWithPostInfo {198 ensure!(199 token == TokenId::default(),200 <Error<T>>::FungibleItemsHaveNoId201 );202203 with_weight(204 <Pallet<T>>::set_allowance(self, &sender, &spender, amount),205 <CommonWeights<T>>::approve(),206 )207 }208209 fn transfer_from(210 &self,211 sender: T::CrossAccountId,212 from: T::CrossAccountId,213 to: T::CrossAccountId,214 token: TokenId,215 amount: u128,216 nesting_budget: &dyn Budget,217 ) -> DispatchResultWithPostInfo {218 ensure!(219 token == TokenId::default(),220 <Error<T>>::FungibleItemsHaveNoId221 );222223 with_weight(224 <Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, nesting_budget),225 <CommonWeights<T>>::transfer_from(),226 )227 }228229 fn burn_from(230 &self,231 sender: T::CrossAccountId,232 from: T::CrossAccountId,233 token: TokenId,234 amount: u128,235 nesting_budget: &dyn Budget,236 ) -> DispatchResultWithPostInfo {237 ensure!(238 token == TokenId::default(),239 <Error<T>>::FungibleItemsHaveNoId240 );241242 with_weight(243 <Pallet<T>>::burn_from(self, &sender, &from, amount, nesting_budget),244 <CommonWeights<T>>::burn_from(),245 )246 }247248 fn set_collection_properties(249 &self,250 _sender: T::CrossAccountId,251 _property: Vec<Property>,252 ) -> DispatchResultWithPostInfo {253 fail!(<Error<T>>::PropertiesNotAllowed)254 }255256 fn delete_collection_properties(257 &self,258 _sender: &T::CrossAccountId,259 _property_keys: Vec<PropertyKey>,260 ) -> DispatchResultWithPostInfo {261 fail!(<Error<T>>::PropertiesNotAllowed)262 }263264 fn set_token_properties(265 &self,266 _sender: T::CrossAccountId,267 _token_id: TokenId,268 _property: Vec<Property>,269 ) -> DispatchResultWithPostInfo {270 fail!(<Error<T>>::PropertiesNotAllowed)271 }272273 fn set_property_permissions(274 &self,275 _sender: &T::CrossAccountId,276 _property_permissions: Vec<PropertyKeyPermission>,277 ) -> DispatchResultWithPostInfo {278 fail!(<Error<T>>::PropertiesNotAllowed)279 }280281 fn delete_token_properties(282 &self,283 _sender: T::CrossAccountId,284 _token_id: TokenId,285 _property_keys: Vec<PropertyKey>,286 ) -> DispatchResultWithPostInfo {287 fail!(<Error<T>>::PropertiesNotAllowed)288 }289290 fn set_variable_metadata(291 &self,292 _sender: T::CrossAccountId,293 _token: TokenId,294 _data: BoundedVec<u8, CustomDataLimit>,295 ) -> DispatchResultWithPostInfo {296 fail!(<Error<T>>::FungibleItemsDontHaveData)297 }298299 fn check_nesting(300 &self,301 _sender: <T>::CrossAccountId,302 _from: (CollectionId, TokenId),303 _under: TokenId,304 _budget: &dyn Budget,305 ) -> sp_runtime::DispatchResult {306 fail!(<Error<T>>::FungibleDisallowsNesting)307 }308309 fn collection_tokens(&self) -> Vec<TokenId> {310 vec![TokenId::default()]311 }312313 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {314 if <Balance<T>>::get((self.id, account)) != 0 {315 vec![TokenId::default()]316 } else {317 vec![]318 }319 }320321 fn token_exists(&self, token: TokenId) -> bool {322 token == TokenId::default()323 }324325 fn last_token_id(&self) -> TokenId {326 TokenId::default()327 }328329 fn token_owner(&self, _token: TokenId) -> Option<T::CrossAccountId> {330 None331 }332 fn const_metadata(&self, _token: TokenId) -> Vec<u8> {333 Vec::new()334 }335 fn variable_metadata(&self, _token: TokenId) -> Vec<u8> {336 Vec::new()337 }338339 fn total_supply(&self) -> u32 {340 1341 }342343 fn account_balance(&self, account: T::CrossAccountId) -> u32 {344 if <Balance<T>>::get((self.id, account)) != 0 {345 1346 } else {347 0348 }349 }350351 fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {352 if token != TokenId::default() {353 return 0;354 }355 <Balance<T>>::get((self.id, account))356 }357358 fn allowance(359 &self,360 sender: T::CrossAccountId,361 spender: T::CrossAccountId,362 token: TokenId,363 ) -> u128 {364 if token != TokenId::default() {365 return 0;366 }367 <Allowance<T>>::get((self.id, sender, spender))368 }369}pallets/fungible/src/weights.rsdiffbeforeafterboth--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -36,6 +36,7 @@
fn create_multiple_items_ex(b: u32, ) -> Weight;
fn burn_item() -> Weight;
fn set_collection_properties(amount: u32) -> Weight;
+ fn delete_collection_properties(amount: u32) -> Weight;
fn set_token_properties(amount: u32) -> Weight;
fn delete_token_properties(amount: u32) -> Weight;
fn set_property_permissions(amount: u32) -> Weight;
@@ -79,6 +80,11 @@
0
}
+ fn delete_collection_properties(_amount: u32) -> Weight {
+ // Error
+ 0
+ }
+
fn set_token_properties(_amount: u32) -> Weight {
// Error
0
@@ -157,6 +163,11 @@
0
}
+ fn delete_collection_properties(_amount: u32) -> Weight {
+ // Error
+ 0
+ }
+
fn set_token_properties(_amount: u32) -> Weight {
// Error
0
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -55,6 +55,10 @@
<SelfWeightOf<T>>::set_collection_properties(amount)
}
+ fn delete_collection_properties(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::delete_collection_properties(amount)
+ }
+
fn set_token_properties(amount: u32) -> Weight {
<SelfWeightOf<T>>::set_token_properties(amount)
}
@@ -171,6 +175,19 @@
)
}
+ fn delete_collection_properties(
+ &self,
+ sender: &T::CrossAccountId,
+ property_keys: Vec<PropertyKey>,
+ ) -> DispatchResultWithPostInfo {
+ let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);
+
+ with_weight(
+ <Pallet<T>>::delete_collection_properties(self, &sender, property_keys),
+ weight
+ )
+ }
+
fn set_token_properties(
&self,
sender: T::CrossAccountId,
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -366,6 +366,14 @@
<PalletCommon<T>>::set_collection_properties(collection, sender, properties)
}
+ pub fn delete_collection_properties(
+ collection: &CollectionHandle<T>,
+ sender: &T::CrossAccountId,
+ property_keys: Vec<PropertyKey>,
+ ) -> DispatchResult {
+ <PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)
+ }
+
pub fn set_property_permissions(
collection: &CollectionHandle<T>,
sender: &T::CrossAccountId,
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -37,6 +37,7 @@
fn create_multiple_items_ex(b: u32, ) -> Weight;
fn burn_item() -> Weight;
fn set_collection_properties(amount: u32) -> Weight;
+ fn delete_collection_properties(amount: u32) -> Weight;
fn set_token_properties(amount: u32) -> Weight;
fn delete_token_properties(amount: u32) -> Weight;
fn set_property_permissions(amount: u32) -> Weight;
@@ -100,6 +101,11 @@
(50_000_000 as Weight).saturating_mul(amount as Weight)
}
+ fn delete_collection_properties(amount: u32) -> Weight {
+ // TODO calculate appropriate weight
+ (50_000_000 as Weight).saturating_mul(amount as Weight)
+ }
+
fn set_token_properties(amount: u32) -> Weight {
// TODO calculate appropriate weight
(50_000_000 as Weight).saturating_mul(amount as Weight)
@@ -210,6 +216,11 @@
(50_000_000 as Weight).saturating_mul(amount as Weight)
}
+ fn delete_collection_properties(amount: u32) -> Weight {
+ // TODO calculate appropriate weight
+ (50_000_000 as Weight).saturating_mul(amount as Weight)
+ }
+
fn set_token_properties(amount: u32) -> Weight {
// TODO calculate appropriate weight
(50_000_000 as Weight).saturating_mul(amount as Weight)
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -70,6 +70,10 @@
<SelfWeightOf<T>>::set_collection_properties(amount)
}
+ fn delete_collection_properties(amount: u32) -> Weight {
+ <SelfWeightOf<T>>::delete_collection_properties(amount)
+ }
+
fn set_token_properties(amount: u32) -> Weight {
<SelfWeightOf<T>>::set_token_properties(amount)
}
@@ -268,6 +272,14 @@
fail!(<Error<T>>::PropertiesNotAllowed)
}
+ fn delete_collection_properties(
+ &self,
+ _sender: &T::CrossAccountId,
+ _property_keys: Vec<PropertyKey>,
+ ) -> DispatchResultWithPostInfo {
+ fail!(<Error<T>>::PropertiesNotAllowed)
+ }
+
fn set_token_properties(
&self,
_sender: T::CrossAccountId,
pallets/refungible/src/weights.rsdiffbeforeafterboth--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -39,6 +39,7 @@
fn burn_item_partial() -> Weight;
fn burn_item_fully() -> Weight;
fn set_collection_properties(amount: u32) -> Weight;
+ fn delete_collection_properties(amount: u32) -> Weight;
fn set_token_properties(amount: u32) -> Weight;
fn delete_token_properties(amount: u32) -> Weight;
fn set_property_permissions(amount: u32) -> Weight;
@@ -139,6 +140,11 @@
0
}
+ fn delete_collection_properties(_amount: u32) -> Weight {
+ // Error
+ 0
+ }
+
fn set_token_properties(_amount: u32) -> Weight {
// Error
0
@@ -328,6 +334,11 @@
0
}
+ fn delete_collection_properties(_amount: u32) -> Weight {
+ // Error
+ 0
+ }
+
fn set_token_properties(_amount: u32) -> Weight {
// Error
0
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -708,6 +708,20 @@
dispatch_call::<T, _>(collection_id, |d| d.set_collection_properties(sender, properties))
}
+ #[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]
+ #[transactional]
+ pub fn delete_collection_properties(
+ origin,
+ collection_id: CollectionId,
+ property_keys: Vec<PropertyKey>,
+ ) -> DispatchResultWithPostInfo {
+ ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);
+
+ let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
+
+ dispatch_call::<T, _>(collection_id, |d| d.delete_collection_properties(&sender, property_keys))
+ }
+
#[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]
#[transactional]
pub fn set_token_properties(
@@ -723,19 +737,19 @@
dispatch_call::<T, _>(collection_id, |d| d.set_token_properties(sender, token_id, properties))
}
- #[weight = T::CommonWeightInfo::delete_token_properties(properties.len() as u32)]
+ #[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]
#[transactional]
pub fn delete_token_properties(
origin,
collection_id: CollectionId,
token_id: TokenId,
- properties: Vec<PropertyKey>
+ property_keys: Vec<PropertyKey>
) -> DispatchResultWithPostInfo {
- ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);
+ ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- dispatch_call::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, properties))
+ dispatch_call::<T, _>(collection_id, |d| d.delete_token_properties(sender, token_id, property_keys))
}
#[weight = T::CommonWeightInfo::set_property_permissions(property_permissions.len() as u32)]
runtime/common/src/weights.rsdiffbeforeafterboth--- a/runtime/common/src/weights.rs
+++ b/runtime/common/src/weights.rs
@@ -58,6 +58,10 @@
dispatch_weight::<T>() + max_weight_of!(set_collection_properties(amount))
}
+ fn delete_collection_properties(amount: u32) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(delete_collection_properties(amount))
+ }
+
fn set_token_properties(amount: u32) -> Weight {
dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
}