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.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -91,7 +91,7 @@
use up_data_structs::{
AccessMode, CollectionId, CustomDataLimit, MAX_REFUNGIBLE_PIECES, TokenId,
CreateCollectionData, CreateRefungibleExData, mapping::TokenAddressMapping, budget::Budget,
- Property, PropertyScope, TrySetProperty, PropertyKey, PropertyPermission
+ Property, PropertyScope, TrySetProperty, PropertyKey, PropertyPermission, PropertyKeyPermission
};
use pallet_evm::account::CrossAccountId;
use pallet_common::{Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, CommonCollectionOperations as _};
@@ -1064,4 +1064,28 @@
fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<u128> {
<TotalSupply<T>>::try_get((collection_id, token_id)).ok()
}
+
+ pub fn set_collection_properties(
+ collection: &RefungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ properties: Vec<Property>,
+ ) -> DispatchResult {
+ <PalletCommon<T>>::set_collection_properties(collection, sender, properties)
+ }
+
+ pub fn delete_collection_properties(
+ collection: &RefungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ property_keys: Vec<PropertyKey>,
+ ) -> DispatchResult {
+ <PalletCommon<T>>::delete_collection_properties(collection, sender, property_keys)
+ }
+
+ pub fn set_token_property_permissions(
+ collection: &RefungibleHandle<T>,
+ sender: &T::CrossAccountId,
+ property_permissions: Vec<PropertyKeyPermission>,
+ ) -> DispatchResult {
+ <PalletCommon<T>>::set_token_property_permissions(collection, sender, property_permissions)
+ }
}
tests/src/refungible.test.tsdiffbeforeafterboth--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -212,17 +212,20 @@
});
});
- it.only('Set properties for exist collection', async () => {
+ it('Set properties for exist collection', async () => {
await usingApi(async api => {
const collectionId = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'ReFungible'},
});
- const properties = [{key: 'key1', value: 'val1'}];
- // await expect(executeTransaction(
- // api,
- // alice,
- // api.tx.unique.setCollectionProperties(collectionId, properties),
- // )).to.not.be.rejected;
+ const properties = [
+ {key: 'key1', value: 'val1'},
+ {key: 'key2', value: 'val2'},
+ ];
+ await expect(executeTransaction(
+ api,
+ alice,
+ api.tx.unique.setCollectionProperties(collectionId, properties),
+ )).to.not.be.rejected;
const propertyPermissions = [
{key: 'key1', permission: {collectionAdmin: true, mutable: false, tokenOwner: true}},