difftreelog
CORE-410 Set collection properties for exist collection
in: master
3 files changed
pallets/refungible/src/common.rsdiffbeforeafterboth298298299 fn set_collection_properties(299 fn set_collection_properties(300 &self,300 &self,301 _sender: T::CrossAccountId,301 sender: T::CrossAccountId,302 _property: Vec<Property>,302 properties: Vec<Property>,303 ) -> DispatchResultWithPostInfo {303 ) -> DispatchResultWithPostInfo {304 let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);305304 fail!(<Error<T>>::SettingPropertiesNotAllowed)306 with_weight(307 <Pallet<T>>::set_collection_properties(self, &sender, properties),308 weight,309 )305 }310 }306311307 fn delete_collection_properties(312 fn delete_collection_properties(308 &self,313 &self,309 _sender: &T::CrossAccountId,314 sender: &T::CrossAccountId,310 _property_keys: Vec<PropertyKey>,315 property_keys: Vec<PropertyKey>,311 ) -> DispatchResultWithPostInfo {316 ) -> DispatchResultWithPostInfo {317 let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);318312 fail!(<Error<T>>::SettingPropertiesNotAllowed)319 with_weight(320 <Pallet<T>>::delete_collection_properties(self, sender, property_keys),321 weight,322 )313 }323 }314324315 fn set_token_properties(325 fn set_token_properties(316 &self,326 &self,317 _sender: T::CrossAccountId,327 sender: T::CrossAccountId,318 _token_id: TokenId,328 token_id: TokenId,319 _property: Vec<Property>,329 properties: Vec<Property>,320 _nesting_budget: &dyn Budget,330 _nesting_budget: &dyn Budget,321 ) -> DispatchResultWithPostInfo {331 ) -> DispatchResultWithPostInfo {332 let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);333322 fail!(<Error<T>>::SettingPropertiesNotAllowed)334 with_weight(335 <Pallet<T>>::set_token_properties(self, &sender, token_id, properties, false),336 weight,337 )323 }338 }324339325 fn set_token_property_permissions(340 fn set_token_property_permissions(326 &self,341 &self,327 _sender: &T::CrossAccountId,342 sender: &T::CrossAccountId,328 _property_permissions: Vec<PropertyKeyPermission>,343 property_permissions: Vec<PropertyKeyPermission>,329 ) -> DispatchResultWithPostInfo {344 ) -> DispatchResultWithPostInfo {345 let weight =346 <CommonWeights<T>>::set_token_property_permissions(property_permissions.len() as u32);347330 fail!(<Error<T>>::SettingPropertiesNotAllowed)348 with_weight(349 <Pallet<T>>::set_token_property_permissions(self, sender, property_permissions),350 weight,351 )331 }352 }332353333 fn delete_token_properties(354 fn delete_token_properties(334 &self,355 &self,335 _sender: T::CrossAccountId,356 sender: T::CrossAccountId,336 _token_id: TokenId,357 token_id: TokenId,337 _property_keys: Vec<PropertyKey>,358 property_keys: Vec<PropertyKey>,338 _nesting_budget: &dyn Budget,359 _nesting_budget: &dyn Budget,339 ) -> DispatchResultWithPostInfo {360 ) -> DispatchResultWithPostInfo {361 let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);362340 fail!(<Error<T>>::SettingPropertiesNotAllowed)363 with_weight(364 <Pallet<T>>::delete_token_properties(self, &sender, token_id, property_keys),365 weight,366 )341 }367 }342368pallets/refungible/src/lib.rsdiffbeforeafterboth91use up_data_structs::{91use up_data_structs::{92 AccessMode, CollectionId, CustomDataLimit, MAX_REFUNGIBLE_PIECES, TokenId,92 AccessMode, CollectionId, CustomDataLimit, MAX_REFUNGIBLE_PIECES, TokenId,93 CreateCollectionData, CreateRefungibleExData, mapping::TokenAddressMapping, budget::Budget,93 CreateCollectionData, CreateRefungibleExData, mapping::TokenAddressMapping, budget::Budget,94 Property, PropertyScope, TrySetProperty, PropertyKey, PropertyPermission94 Property, PropertyScope, TrySetProperty, PropertyKey, PropertyPermission, PropertyKeyPermission95};95};96use pallet_evm::account::CrossAccountId;96use pallet_evm::account::CrossAccountId;97use pallet_common::{Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, CommonCollectionOperations as _};97use pallet_common::{Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, CommonCollectionOperations as _};1065 <TotalSupply<T>>::try_get((collection_id, token_id)).ok()1065 <TotalSupply<T>>::try_get((collection_id, token_id)).ok()1066 }1066 }1067 1068 pub fn set_collection_properties(1069 collection: &RefungibleHandle<T>,1070 sender: &T::CrossAccountId,1071 properties: Vec<Property>,1072 ) -> DispatchResult {1073 <PalletCommon<T>>::set_collection_properties(collection, sender, properties)1074 }10751076 pub fn delete_collection_properties(1077 collection: &RefungibleHandle<T>,1078 sender: &T::CrossAccountId,1079 property_keys: Vec<PropertyKey>,1080 ) -> DispatchResult {1081 <PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)1082 }10831084 pub fn set_token_property_permissions(1085 collection: &RefungibleHandle<T>,1086 sender: &T::CrossAccountId,1087 property_permissions: Vec<PropertyKeyPermission>,1088 ) -> DispatchResult {1089 <PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)1090 }1067}1091}10681092tests/src/refungible.test.tsdiffbeforeafterboth212 });212 });213 });213 });214214215 it.only('Set properties for exist collection', async () => {215 it('Set properties for exist collection', async () => {216 await usingApi(async api => {216 await usingApi(async api => {217 const collectionId = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'ReFungible'},217 const collectionId = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'ReFungible'},218 });218 });219219220 const properties = [{key: 'key1', value: 'val1'}];220 const properties = [221 // await expect(executeTransaction(221 {key: 'key1', value: 'val1'},222 // api, 222 {key: 'key2', value: 'val2'},223 // alice, 223 ];224 // api.tx.unique.setCollectionProperties(collectionId, properties), 224 await expect(executeTransaction(225 // )).to.not.be.rejected;225 api, 226 alice, 227 api.tx.unique.setCollectionProperties(collectionId, properties), 228 )).to.not.be.rejected;226229227 const propertyPermissions = [230 const propertyPermissions = [228 {key: 'key1', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},231 {key: 'key1', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},