git.delta.rocks / unique-network / refs/commits / 7dcd3b7313a5

difftreelog

fmt

Trubnikov Sergey2022-07-15parent: #263bc69.patch.diff
in: master

3 files changed

modifiedpallets/common/src/dispatch.rsdiffbeforeafterboth
--- a/pallets/common/src/dispatch.rs
+++ b/pallets/common/src/dispatch.rs
@@ -23,7 +23,7 @@
 }
 
 /// Helper function to implement substrate calls for common collection methods.
-/// 
+///
 /// * `collection` - The collection on which to call the method.
 /// * `call` - The function in which to call the corresponding method from [CommonCollectionOperations].
 pub fn dispatch_tx<
@@ -72,7 +72,7 @@
 /// Interface for working with different collections through the dispatcher.
 pub trait CollectionDispatch<T: Config> {
 	/// Create a collection. The collection will be created according to the value of [data.mode](CreateCollectionData::mode).
-	/// 
+	///
 	/// * `sender` - The user who will become the owner of the collection.
 	/// * `data` - Description of the created collection.
 	fn create(
@@ -81,13 +81,13 @@
 	) -> DispatchResult;
 
 	/// Delete the collection.
-	/// 
+	///
 	/// * `sender` - The owner of the collection.
 	/// * `handle` - Collection handle.
 	fn destroy(sender: T::CrossAccountId, handle: CollectionHandle<T>) -> DispatchResult;
 
 	/// Get a specialized collection from the handle.
-	/// 
+	///
 	/// * `handle` - Collection handle.
 	fn dispatch(handle: CollectionHandle<T>) -> Self;
 
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -61,7 +61,7 @@
 	T::AccountId: From<[u8; 32]>,
 {
 	/// Set collection property.
-	/// 
+	///
 	/// @param key Property key.
 	/// @param value Propery value.
 	fn set_collection_property(
@@ -72,16 +72,16 @@
 	) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let key = <Vec<u8>>::from(key)
-		.try_into()
-		.map_err(|_| "key too large")?;
+			.try_into()
+			.map_err(|_| "key too large")?;
 		let value = value.try_into().map_err(|_| "value too large")?;
-		
+
 		<Pallet<T>>::set_collection_property(self, &caller, Property { key, value })
-		.map_err(dispatch_to_evm::<T>)
+			.map_err(dispatch_to_evm::<T>)
 	}
-	
+
 	/// Delete collection property.
-	/// 
+	///
 	/// @param key Property key.
 	fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -93,9 +93,9 @@
 	}
 
 	/// Get collection property.
-	/// 
+	///
 	/// @dev Throws error if key not found.
-	/// 
+	///
 	/// @param key Property key.
 	/// @return bytes The property corresponding to the key.
 	fn collection_property(&self, key: string) -> Result<bytes> {
@@ -110,9 +110,9 @@
 	}
 
 	/// Set the sponsor of the collection.
-	/// 
+	///
 	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
-	/// 
+	///
 	/// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
 	fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<void> {
 		check_is_owner_or_admin(caller, self)?;
@@ -124,7 +124,7 @@
 	}
 
 	/// Collection sponsorship confirmation.
-	/// 
+	///
 	/// @dev After setting the sponsor for the collection, it must be confirmed with this function.
 	fn confirm_collection_sponsorship(&mut self, caller: caller) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -236,18 +236,13 @@
 
 	/// Remove collection admin by substrate address.
 	/// @param admin Substrate administrator address.
-	fn remove_collection_admin_substrate(
-		&self,
-		caller: caller,
-		admin: uint256,
-	) -> Result<void> {
+	fn remove_collection_admin_substrate(&self, caller: caller, admin: uint256) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let mut admin_arr: [u8; 32] = Default::default();
 		admin.to_big_endian(&mut admin_arr);
 		let account_id = T::AccountId::from(admin_arr);
 		let admin = T::CrossAccountId::from_sub(account_id);
-		<Pallet<T>>::toggle_admin(self, &caller, &admin, false)
-			.map_err(dispatch_to_evm::<T>)?;
+		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
 
@@ -261,7 +256,7 @@
 	}
 
 	/// Remove collection admin.
-	/// 
+	///
 	/// @param new_admin Address of the removed administrator.
 	fn remove_collection_admin(&self, caller: caller, admin: address) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -271,7 +266,7 @@
 	}
 
 	/// Toggle accessibility of collection nesting.
-	/// 
+	///
 	/// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
 	#[solidity(rename_selector = "setCollectionNesting")]
 	fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<void> {
@@ -294,7 +289,7 @@
 	}
 
 	/// Toggle accessibility of collection nesting.
-	/// 
+	///
 	/// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
 	/// @param collections Addresses of collections that will be available for nesting.
 	#[solidity(rename_selector = "setCollectionNesting")]
@@ -367,7 +362,7 @@
 	}
 
 	/// Add the user to the allowed list.
-	/// 
+	///
 	/// @param user Address of a trusted user.
 	fn add_to_collection_allow_list(&self, caller: caller, user: address) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -375,9 +370,9 @@
 		<Pallet<T>>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;
 		Ok(())
 	}
-	
+
 	/// Remove the user from the allowed list.
-	/// 
+	///
 	/// @param user Address of a removed user.
 	fn remove_from_collection_allow_list(&self, caller: caller, user: address) -> Result<void> {
 		let caller = T::CrossAccountId::from_eth(caller);
@@ -387,7 +382,7 @@
 	}
 
 	/// Switch permission for minting.
-	/// 
+	///
 	/// @param mode Enable if "true".
 	fn set_collection_mint_mode(&mut self, caller: caller, mode: bool) -> Result<void> {
 		check_is_owner_or_admin(caller, self)?;
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
17//! # Common pallet17//! # Common pallet
18//!18//!
19//! The Common pallet provides functionality for handling collections.19//! The Common pallet provides functionality for handling collections.
20//! 20//!
21//! ## Overview21//! ## Overview
22//! 22//!
23//! The Common pallet provides functions for:23//! The Common pallet provides functions for:
24//! 24//!
25//! - Setting and approving collection soponsor.25//! - Setting and approving collection soponsor.
26//! - Get\set\delete allow list.26//! - Get\set\delete allow list.
27//! - Get\set\delete collection properties.27//! - Get\set\delete collection properties.
32//! - Provides an interface for common collection operations for different collection types.32//! - Provides an interface for common collection operations for different collection types.
33//! - Provides dispatching for implementations of common collection operations, see [dispatch] module.33//! - Provides dispatching for implementations of common collection operations, see [dispatch] module.
34//! - Provides functionality of collection into evm, see [erc] and [eth] module.34//! - Provides functionality of collection into evm, see [erc] and [eth] module.
35//! 35//!
36//! ### Terminology36//! ### Terminology
37//! **Collection sponsor** - For the collection, you can set a sponsor, at whose expense it will 37//! **Collection sponsor** - For the collection, you can set a sponsor, at whose expense it will
38//! be possible to mint tokens.38//! be possible to mint tokens.
39//! 39//!
40//! **Allow list** - List of users who have the right to minting tokens.40//! **Allow list** - List of users who have the right to minting tokens.
41//! 41//!
42//! **Collection properties** - Collection properties are simply key-value stores where various 42//! **Collection properties** - Collection properties are simply key-value stores where various
43//! metadata can be placed.43//! metadata can be placed.
44//! 44//!
45//! **Collection property permissions** - For each property in the collection can be set permission 45//! **Collection property permissions** - For each property in the collection can be set permission
46//! to change, see [PropertyPermission].46//! to change, see [PropertyPermission].
47//! 47//!
48//! **Permissions on token properties** - Similar to _permissions on collection properties_, 48//! **Permissions on token properties** - Similar to _permissions on collection properties_,
49//! only restrictions apply to token properties.49//! only restrictions apply to token properties.
50//! 50//!
51//! **Collection administrator** - For a collection, you can set administrators who have the right 51//! **Collection administrator** - For a collection, you can set administrators who have the right
52//! to most actions on the collection.52//! to most actions on the collection.
53
5453
131/// Weight info.130/// Weight info.
132pub type SelfWeightOf<T> = <T as Config>::WeightInfo;131pub type SelfWeightOf<T> = <T as Config>::WeightInfo;
133132
134/// Collection handle contains information about collection data and id. 133/// Collection handle contains information about collection data and id.
135/// Also provides functionality to count consumed gas.134/// Also provides functionality to count consumed gas.
136#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]135#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]
137pub struct CollectionHandle<T: Config> {136pub struct CollectionHandle<T: Config> {
208 }207 }
209208
210 /// Set collection sponsor.209 /// Set collection sponsor.
211 /// 210 ///
212 /// Unique collections allows sponsoring for certain actions. 211 /// Unique collections allows sponsoring for certain actions.
213 /// This method allows you to set the sponsor of the collection. 212 /// This method allows you to set the sponsor of the collection.
214 /// In order for sponsorship to become active, it must be confirmed through [Self::confirm_sponsorship].213 /// In order for sponsorship to become active, it must be confirmed through [Self::confirm_sponsorship].
215 pub fn set_sponsor(&mut self, sponsor: T::AccountId) -> DispatchResult {214 pub fn set_sponsor(&mut self, sponsor: T::AccountId) -> DispatchResult {
216 self.collection.sponsorship = SponsorshipState::Unconfirmed(sponsor);215 self.collection.sponsorship = SponsorshipState::Unconfirmed(sponsor);
217 Ok(())216 Ok(())
218 }217 }
219218
220 /// Confirm sponsorship219 /// Confirm sponsorship
221 /// 220 ///
222 /// In order for the sponsorship to become active, the user set as the sponsor must confirm their participation.221 /// In order for the sponsorship to become active, the user set as the sponsor must confirm their participation.
223 /// Before confirming sponsorship, the user must be specified as the sponsor of the collection via [Self::set_sponsor].222 /// Before confirming sponsorship, the user must be specified as the sponsor of the collection via [Self::set_sponsor].
224 pub fn confirm_sponsorship(&mut self, sender: &T::AccountId) -> Result<bool, DispatchError> {223 pub fn confirm_sponsorship(&mut self, sender: &T::AccountId) -> Result<bool, DispatchError> {
379 /// [CollectionMode] converted into _u8_.378 /// [CollectionMode] converted into _u8_.
380 u8,379 u8,
381 /// Collection owner.380 /// Collection owner.
382 T::AccountId381 T::AccountId,
383 ),382 ),
384383
385 /// New collection was destroyed384 /// New collection was destroyed
386 CollectionDestroyed(385 CollectionDestroyed(
387 /// Globally unique identifier of collection.386 /// Globally unique identifier of collection.
388 CollectionId387 CollectionId,
389 ),388 ),
390389
391 /// New item was created.390 /// New item was created.
397 /// Owner of newly created item396 /// Owner of newly created item
398 T::CrossAccountId,397 T::CrossAccountId,
399 /// Always 1 for NFT398 /// Always 1 for NFT
400 u128399 u128,
401 ),400 ),
402401
403 /// Collection item was burned.402 /// Collection item was burned.
409 /// Which user has destroyed its tokens.408 /// Which user has destroyed its tokens.
410 T::CrossAccountId,409 T::CrossAccountId,
411 /// Amount of token pieces destroed. Always 1 for NFT.410 /// Amount of token pieces destroed. Always 1 for NFT.
412 u128),411 u128,
412 ),
413413
414 /// Item was transferred414 /// Item was transferred
444 /// Id of collection to which property has been set.444 /// Id of collection to which property has been set.
445 CollectionId,445 CollectionId,
446 /// The property that was set.446 /// The property that was set.
447 PropertyKey447 PropertyKey,
448 ),448 ),
449 449
450 /// The property has been deleted.450 /// The property has been deleted.
451 CollectionPropertyDeleted(451 CollectionPropertyDeleted(
452 /// Id of collection to which property has been deleted.452 /// Id of collection to which property has been deleted.
453 CollectionId,453 CollectionId,
454 /// The property that was deleted.454 /// The property that was deleted.
455 PropertyKey455 PropertyKey,
456 ),456 ),
457 457
458 /// The token property has been set.458 /// The token property has been set.
462 /// The token for which the property was set.462 /// The token for which the property was set.
463 TokenId,463 TokenId,
464 /// The property that was set.464 /// The property that was set.
465 PropertyKey465 PropertyKey,
466 ),466 ),
467 467
468
473 /// The token for which the property was deleted.472 /// The token for which the property was deleted.
474 TokenId,473 TokenId,
475 /// The property that was deleted.474 /// The property that was deleted.
476 PropertyKey475 PropertyKey,
477 ),476 ),
478 477
479 /// The colletion property permission has been set.478 /// The colletion property permission has been set.
480 PropertyPermissionSet(479 PropertyPermissionSet(
481 /// Id of collection to which property permission has been set.480 /// Id of collection to which property permission has been set.
482 CollectionId,481 CollectionId,
483 /// The property permission that was set.482 /// The property permission that was set.
484 PropertyKey483 PropertyKey,
485 ),484 ),
486 }485 }
487486
735734
736impl<T: Config> Pallet<T> {735impl<T: Config> Pallet<T> {
737 /// Enshure that receiver address is correct.736 /// Enshure that receiver address is correct.
738 /// 737 ///
739 /// Ethereum receiver 0x0000000000000000000000000000000000000000 is reserved, and shouldn't own tokens.738 /// Ethereum receiver 0x0000000000000000000000000000000000000000 is reserved, and shouldn't own tokens.
740 pub fn ensure_correct_receiver(receiver: &T::CrossAccountId) -> DispatchResult {739 pub fn ensure_correct_receiver(receiver: &T::CrossAccountId) -> DispatchResult {
741 ensure!(740 ensure!(
886885
887impl<T: Config> Pallet<T> {886impl<T: Config> Pallet<T> {
888 /// Create new collection.887 /// Create new collection.
889 /// 888 ///
890 /// * `owner` - The owner of the collection.889 /// * `owner` - The owner of the collection.
891 /// * `data` - Description of the created collection.890 /// * `data` - Description of the created collection.
892 /// * `is_external` - Marks that collection managet by not "Unique network".891 /// * `is_external` - Marks that collection managet by not "Unique network".
991 }990 }
992991
993 /// Destroy collection.992 /// Destroy collection.
994 /// 993 ///
995 /// * `collection` - Collection handler.994 /// * `collection` - Collection handler.
996 /// * `sender` - The owner or administrator of the collection.995 /// * `sender` - The owner or administrator of the collection.
997 pub fn destroy_collection(996 pub fn destroy_collection(
1023 }1022 }
10241023
1025 /// Set collection property.1024 /// Set collection property.
1026 /// 1025 ///
1027 /// * `collection` - Collection handler.1026 /// * `collection` - Collection handler.
1028 /// * `sender` - The owner or administrator of the collection.1027 /// * `sender` - The owner or administrator of the collection.
1029 /// * `property` - The property to set.1028 /// * `property` - The property to set.
1046 }1045 }
10471046
1048 /// Set scouped collection property.1047 /// Set scouped collection property.
1049 /// 1048 ///
1050 /// * `collection_id` - ID of the collection for which the property is being set.1049 /// * `collection_id` - ID of the collection for which the property is being set.
1051 /// * `scope` - Property scope.1050 /// * `scope` - Property scope.
1052 /// * `property` - The property to set.1051 /// * `property` - The property to set.
1064 }1063 }
1065 1064
1066 /// Set scouped collection properties.1065 /// Set scouped collection properties.
1067 /// 1066 ///
1068 /// * `collection_id` - ID of the collection for which the properties is being set.1067 /// * `collection_id` - ID of the collection for which the properties is being set.
1069 /// * `scope` - Property scope.1068 /// * `scope` - Property scope.
1070 /// * `properties` - The properties to set.1069 /// * `properties` - The properties to set.
1082 }1081 }
10831082
1084 /// Set collection properties.1083 /// Set collection properties.
1085 /// 1084 ///
1086 /// * `collection` - Collection handler.1085 /// * `collection` - Collection handler.
1087 /// * `sender` - The owner or administrator of the collection.1086 /// * `sender` - The owner or administrator of the collection.
1088 /// * `properties` - The properties to set.1087 /// * `properties` - The properties to set.
1100 }1099 }
1101 1100
1102 /// Delete collection property.1101 /// Delete collection property.
1103 /// 1102 ///
1104 /// * `collection` - Collection handler.1103 /// * `collection` - Collection handler.
1105 /// * `sender` - The owner or administrator of the collection.1104 /// * `sender` - The owner or administrator of the collection.
1106 /// * `property` - The property to delete.1105 /// * `property` - The property to delete.
1125 }1124 }
1126 1125
1127 /// Delete collection properties.1126 /// Delete collection properties.
1128 /// 1127 ///
1129 /// * `collection` - Collection handler.1128 /// * `collection` - Collection handler.
1130 /// * `sender` - The owner or administrator of the collection.1129 /// * `sender` - The owner or administrator of the collection.
1131 /// * `properties` - The properties to delete.1130 /// * `properties` - The properties to delete.
1143 }1142 }
1144 1143
1145 /// Set collection propetry permission without any checks.1144 /// Set collection propetry permission without any checks.
1146 /// 1145 ///
1147 /// Used for migrations.1146 /// Used for migrations.
1148 /// 1147 ///
1149 /// * `collection` - Collection handler.1148 /// * `collection` - Collection handler.
1150 /// * `property_permissions` - Property permissions.1149 /// * `property_permissions` - Property permissions.
1151 pub fn set_property_permission_unchecked(1150 pub fn set_property_permission_unchecked(
1160 }1159 }
11611160
1162 /// Set collection property permission.1161 /// Set collection property permission.
1163 /// 1162 ///
1164 /// * `collection` - Collection handler.1163 /// * `collection` - Collection handler.
1165 /// * `sender` - The owner or administrator of the collection.1164 /// * `sender` - The owner or administrator of the collection.
1166 /// * `property_permission` - Property permission.1165 /// * `property_permission` - Property permission.
1195 }1194 }
11961195
1197 /// Set token property permission.1196 /// Set token property permission.
1198 /// 1197 ///
1199 /// * `collection` - Collection handler.1198 /// * `collection` - Collection handler.
1200 /// * `sender` - The owner or administrator of the collection.1199 /// * `sender` - The owner or administrator of the collection.
1201 /// * `property_permissions` - Property permissions.1200 /// * `property_permissions` - Property permissions.
1430 fn burn_item() -> Weight;1429 fn burn_item() -> Weight;
14311430
1432 /// Property setting weight.1431 /// Property setting weight.
1433 /// 1432 ///
1434 /// * `amount`- The number of properties to set.1433 /// * `amount`- The number of properties to set.
1435 fn set_collection_properties(amount: u32) -> Weight;1434 fn set_collection_properties(amount: u32) -> Weight;
14361435
1437 /// Collection property deletion weight.1436 /// Collection property deletion weight.
1438 /// 1437 ///
1439 /// * `amount`- The number of properties to set.1438 /// * `amount`- The number of properties to set.
1440 fn delete_collection_properties(amount: u32) -> Weight;1439 fn delete_collection_properties(amount: u32) -> Weight;
14411440
1445 fn set_token_properties(amount: u32) -> Weight;1444 fn set_token_properties(amount: u32) -> Weight;
14461445
1447 /// Token property deletion weight.1446 /// Token property deletion weight.
1448 /// 1447 ///
1449 /// * `amount`- The number of properties to delete.1448 /// * `amount`- The number of properties to delete.
1450 fn delete_token_properties(amount: u32) -> Weight;1449 fn delete_token_properties(amount: u32) -> Weight;
1451 1450
1452
1453 /// Token property permissions set weight.1451 /// Token property permissions set weight.
1454 /// 1452 ///
1455 /// * `amount`- The number of property permissions to set.1453 /// * `amount`- The number of property permissions to set.
1456 fn set_token_property_permissions(amount: u32) -> Weight;1454 fn set_token_property_permissions(amount: u32) -> Weight;
14571455
1480 1478
1481 /// The price of recursive burning a token.1479 /// The price of recursive burning a token.
1482 ///1480 ///
1483 /// `max_selfs` - 1481 /// `max_selfs` -
1484 fn burn_recursively(max_selfs: u32, max_breadth: u32) -> Weight {1482 fn burn_recursively(max_selfs: u32, max_breadth: u32) -> Weight {
1485 Self::burn_recursively_self_raw()1483 Self::burn_recursively_self_raw()
1486 .saturating_mul(max_selfs.max(1) as u64)1484 .saturating_mul(max_selfs.max(1) as u64)
1495}1493}
14961494
1497/// Common collection operations.1495/// Common collection operations.
1498/// 1496///
1499/// It wraps methods in Fungible, Nonfungible and Refungible pallets1497/// It wraps methods in Fungible, Nonfungible and Refungible pallets
1500/// and adds weight info.1498/// and adds weight info.
1501pub trait CommonCollectionOperations<T: Config> {1499pub trait CommonCollectionOperations<T: Config> {
1502 /// Create token.1500 /// Create token.
1503 /// 1501 ///
1504 /// * `sender` - The user who mint the token and pays for the transaction.1502 /// * `sender` - The user who mint the token and pays for the transaction.
1505 /// * `to` - The user who will own the token.1503 /// * `to` - The user who will own the token.
1506 /// * `data` - Token data.1504 /// * `data` - Token data.
1514 ) -> DispatchResultWithPostInfo;1512 ) -> DispatchResultWithPostInfo;
15151513
1516 /// Create multiple tokens.1514 /// Create multiple tokens.
1517 /// 1515 ///
1518 /// * `sender` - The user who mint the token and pays for the transaction.1516 /// * `sender` - The user who mint the token and pays for the transaction.
1519 /// * `to` - The user who will own the token.1517 /// * `to` - The user who will own the token.
1520 /// * `data` - Token data.1518 /// * `data` - Token data.
1528 ) -> DispatchResultWithPostInfo;1526 ) -> DispatchResultWithPostInfo;
1529 1527
1530 /// Create multiple tokens.1528 /// Create multiple tokens.
1531 /// 1529 ///
1532 /// * `sender` - The user who mint the token and pays for the transaction.1530 /// * `sender` - The user who mint the token and pays for the transaction.
1533 /// * `to` - The user who will own the token.1531 /// * `to` - The user who will own the token.
1534 /// * `data` - Token data.1532 /// * `data` - Token data.
1541 ) -> DispatchResultWithPostInfo;1539 ) -> DispatchResultWithPostInfo;
15421540
1543 /// Burn token.1541 /// Burn token.
1544 /// 1542 ///
1545 /// * `sender` - The user who owns the token.1543 /// * `sender` - The user who owns the token.
1546 /// * `token` - Token id that will burned.1544 /// * `token` - Token id that will burned.
1547 /// * `amount` - The number of parts of the token that will be burned.1545 /// * `amount` - The number of parts of the token that will be burned.
1553 ) -> DispatchResultWithPostInfo;1551 ) -> DispatchResultWithPostInfo;
1554 1552
1555 /// Burn token and all nested tokens recursievly.1553 /// Burn token and all nested tokens recursievly.
1556 /// 1554 ///
1557 /// * `sender` - The user who owns the token.1555 /// * `sender` - The user who owns the token.
1558 /// * `token` - Token id that will burned.1556 /// * `token` - Token id that will burned.
1559 /// * `self_budget` - The budget that can be spent on burning tokens.1557 /// * `self_budget` - The budget that can be spent on burning tokens.
1567 ) -> DispatchResultWithPostInfo;1565 ) -> DispatchResultWithPostInfo;
15681566
1569 /// Set collection properties.1567 /// Set collection properties.
1570 /// 1568 ///
1571 /// * `sender` - Must be either the owner of the collection or its admin.1569 /// * `sender` - Must be either the owner of the collection or its admin.
1572 /// * `properties` - Properties to be set.1570 /// * `properties` - Properties to be set.
1573 fn set_collection_properties(1571 fn set_collection_properties(
1577 ) -> DispatchResultWithPostInfo;1575 ) -> DispatchResultWithPostInfo;
15781576
1579 /// Delete collection properties.1577 /// Delete collection properties.
1580 /// 1578 ///
1581 /// * `sender` - Must be either the owner of the collection or its admin.1579 /// * `sender` - Must be either the owner of the collection or its admin.
1582 /// * `properties` - The properties to be removed.1580 /// * `properties` - The properties to be removed.
1583 fn delete_collection_properties(1581 fn delete_collection_properties(
1587 ) -> DispatchResultWithPostInfo;1585 ) -> DispatchResultWithPostInfo;
15881586
1589 /// Set token properties.1587 /// Set token properties.
1590 /// 1588 ///
1591 /// The appropriate [PropertyPermission] for the token property 1589 /// The appropriate [PropertyPermission] for the token property
1592 /// must be set with [Self::set_token_property_permissions].1590 /// must be set with [Self::set_token_property_permissions].
1593 /// 1591 ///
1594 /// * `sender` - Must be either the owner of the token or its admin. 1592 /// * `sender` - Must be either the owner of the token or its admin.
1595 /// * `token_id` - The token for which the properties are being set.1593 /// * `token_id` - The token for which the properties are being set.
1596 /// * `properties` - Properties to be set.1594 /// * `properties` - Properties to be set.
1597 /// * `budget` - Budget for setting properties.1595 /// * `budget` - Budget for setting properties.
1604 ) -> DispatchResultWithPostInfo;1602 ) -> DispatchResultWithPostInfo;
16051603
1606 /// Remove token properties.1604 /// Remove token properties.
1607 /// 1605 ///
1608 /// The appropriate [PropertyPermission] for the token property 1606 /// The appropriate [PropertyPermission] for the token property
1609 /// must be set with [Self::set_token_property_permissions].1607 /// must be set with [Self::set_token_property_permissions].
1610 /// 1608 ///
1611 /// * `sender` - Must be either the owner of the token or its admin. 1609 /// * `sender` - Must be either the owner of the token or its admin.
1612 /// * `token_id` - The token for which the properties are being remove.1610 /// * `token_id` - The token for which the properties are being remove.
1613 /// * `property_keys` - Keys to remove corresponding properties.1611 /// * `property_keys` - Keys to remove corresponding properties.
1614 /// * `budget` - Budget for removing properties.1612 /// * `budget` - Budget for removing properties.
1621 ) -> DispatchResultWithPostInfo;1619 ) -> DispatchResultWithPostInfo;
16221620
1623 /// Set token property permissions.1621 /// Set token property permissions.
1624 /// 1622 ///
1625 /// * `sender` - Must be either the owner of the token or its admin. 1623 /// * `sender` - Must be either the owner of the token or its admin.
1626 /// * `token_id` - The token for which the properties are being set.1624 /// * `token_id` - The token for which the properties are being set.
1627 /// * `properties` - Properties to be set.1625 /// * `properties` - Properties to be set.
1628 /// * `budget` - Budget for setting properties.1626 /// * `budget` - Budget for setting properties.
1633 ) -> DispatchResultWithPostInfo;1631 ) -> DispatchResultWithPostInfo;
16341632
1635 /// Transfer amount of token pieces.1633 /// Transfer amount of token pieces.
1636 /// 1634 ///
1637 /// * `sender` - Donor user.1635 /// * `sender` - Donor user.
1638 /// * `to` - Recepient user.1636 /// * `to` - Recepient user.
1639 /// * `token` - The token of which parts are being sent.1637 /// * `token` - The token of which parts are being sent.
1649 ) -> DispatchResultWithPostInfo;1647 ) -> DispatchResultWithPostInfo;
16501648
1651 /// Grant access to another account to transfer parts of the token owned by the calling user via [Self::transfer_from].1649 /// Grant access to another account to transfer parts of the token owned by the calling user via [Self::transfer_from].
1652 /// 1650 ///
1653 /// * `sender` - The user who grants access to the token.1651 /// * `sender` - The user who grants access to the token.
1654 /// * `spender` - The user to whom the rights are granted.1652 /// * `spender` - The user to whom the rights are granted.
1655 /// * `token` - The token to which access is granted.1653 /// * `token` - The token to which access is granted.
1663 ) -> DispatchResultWithPostInfo;1661 ) -> DispatchResultWithPostInfo;
1664 1662
1665 /// Send parts of a token owned by another user.1663 /// Send parts of a token owned by another user.
1666 /// 1664 ///
1667 /// Before calling this method, you must grant rights to the calling user via [Self::approve].1665 /// Before calling this method, you must grant rights to the calling user via [Self::approve].
1668 /// 1666 ///
1669 /// * `sender` - The user who has access to the token.1667 /// * `sender` - The user who has access to the token.
1670 /// * `from` - The user who owns the token.1668 /// * `from` - The user who owns the token.
1671 /// * `to` - Recepient user.1669 /// * `to` - Recepient user.
1683 ) -> DispatchResultWithPostInfo;1681 ) -> DispatchResultWithPostInfo;
1684 1682
1685 /// Burn parts of a token owned by another user.1683 /// Burn parts of a token owned by another user.
1686 /// 1684 ///
1687 /// Before calling this method, you must grant rights to the calling user via [Self::approve].1685 /// Before calling this method, you must grant rights to the calling user via [Self::approve].
1688 /// 1686 ///
1689 /// * `sender` - The user who has access to the token.1687 /// * `sender` - The user who has access to the token.
1690 /// * `from` - The user who owns the token.1688 /// * `from` - The user who owns the token.
1691 /// * `token` - The token of which parts are being sent.1689 /// * `token` - The token of which parts are being sent.
1701 ) -> DispatchResultWithPostInfo;1699 ) -> DispatchResultWithPostInfo;
17021700
1703 /// Check permission to nest token.1701 /// Check permission to nest token.
1704 /// 1702 ///
1705 /// * `sender` - The user who initiated the check.1703 /// * `sender` - The user who initiated the check.
1706 /// * `from` - The token that is checked for embedding.1704 /// * `from` - The token that is checked for embedding.
1707 /// * `under` - Token under which to check.1705 /// * `under` - Token under which to check.
1715 ) -> DispatchResult;1713 ) -> DispatchResult;
17161714
1717 /// Nest one token into another.1715 /// Nest one token into another.
1718 /// 1716 ///
1719 /// * `under` - Token holder.1717 /// * `under` - Token holder.
1720 /// * `to_nest` - Nested token.1718 /// * `to_nest` - Nested token.
1721 fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId));1719 fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId));
17221720
1723 /// Unnest token.1721 /// Unnest token.
1724 /// 1722 ///
1725 /// * `under` - Token holder.1723 /// * `under` - Token holder.
1726 /// * `to_nest` - Token to unnest.1724 /// * `to_nest` - Token to unnest.
1727 fn unnest(&self, under: TokenId, to_nest: (CollectionId, TokenId));1725 fn unnest(&self, under: TokenId, to_nest: (CollectionId, TokenId));
17281726
1729 /// Get all user tokens.1727 /// Get all user tokens.
1730 /// 1728 ///
1731 /// * `account` - Account for which you need to get tokens.1729 /// * `account` - Account for which you need to get tokens.
1732 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId>;1730 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId>;
17331731
1734 /// Get all the tokens in the collection.1732 /// Get all the tokens in the collection.
1735 fn collection_tokens(&self) -> Vec<TokenId>;1733 fn collection_tokens(&self) -> Vec<TokenId>;
17361734
1737 /// Check if the token exists.1735 /// Check if the token exists.
1738 /// 1736 ///
1739 /// * `token` - Id token to check.1737 /// * `token` - Id token to check.
1740 fn token_exists(&self, token: TokenId) -> bool;1738 fn token_exists(&self, token: TokenId) -> bool;
17411739
1742 /// Get the id of the last minted token.1740 /// Get the id of the last minted token.
1743 fn last_token_id(&self) -> TokenId;1741 fn last_token_id(&self) -> TokenId;
17441742
1745 /// Get the owner of the token.1743 /// Get the owner of the token.
1746 /// 1744 ///
1747 /// * `token` - The token for which you need to find out the owner.1745 /// * `token` - The token for which you need to find out the owner.
1748 fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId>;1746 fn token_owner(&self, token: TokenId) -> Option<T::CrossAccountId>;
17491747
1750 /// Get the value of the token property by key.1748 /// Get the value of the token property by key.
1751 /// 1749 ///
1752 /// * `token` - Token property to get.1750 /// * `token` - Token property to get.
1753 /// * `key` - Property name.1751 /// * `key` - Property name.
1754 fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue>;1752 fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue>;
17551753
1756 /// Get a set of token properties by key vector.1754 /// Get a set of token properties by key vector.
1757 /// 1755 ///
1758 /// * `token` - Token property to get.1756 /// * `token` - Token property to get.
1759 /// * `keys` - Vector of keys. If this parameter is [None](sp_std::result::Result),1757 /// * `keys` - Vector of keys. If this parameter is [None](sp_std::result::Result),
1760 /// then all properties are returned.1758 /// then all properties are returned.
1764 fn total_supply(&self) -> u32;1762 fn total_supply(&self) -> u32;
17651763
1766 /// Amount of different tokens account has.1764 /// Amount of different tokens account has.
1767 /// 1765 ///
1768 /// * `account` - The account for which need to get the balance.1766 /// * `account` - The account for which need to get the balance.
1769 fn account_balance(&self, account: T::CrossAccountId) -> u32;1767 fn account_balance(&self, account: T::CrossAccountId) -> u32;
17701768
1775 fn total_pieces(&self, token: TokenId) -> Option<u128>;1773 fn total_pieces(&self, token: TokenId) -> Option<u128>;
17761774
1777 /// Get the number of parts of the token that a trusted user can manage.1775 /// Get the number of parts of the token that a trusted user can manage.
1778 /// 1776 ///
1779 /// * `sender` - Trusted user.1777 /// * `sender` - Trusted user.
1780 /// * `spender` - Owner of the token.1778 /// * `spender` - Owner of the token.
1781 /// * `token` - The token for which to get the value.1779 /// * `token` - The token for which to get the value.
1796 T: Config,1794 T: Config,
1797{1795{
1798 /// Change the number of parts of the token.1796 /// Change the number of parts of the token.
1799 /// 1797 ///
1800 /// When the value changes down, this function is equivalent to burning parts of the token.1798 /// When the value changes down, this function is equivalent to burning parts of the token.
1801 /// 1799 ///
1802 /// * `sender` - The user calling the repartition operation. Must be the owner of the token.1800 /// * `sender` - The user calling the repartition operation. Must be the owner of the token.
1803 /// * `token` - The token for which you want to change the number of parts.1801 /// * `token` - The token for which you want to change the number of parts.
1804 /// * `amount` - The new value of the parts of the token.1802 /// * `amount` - The new value of the parts of the token.
1811}1809}
18121810
1813/// Merge [DispatchResult] with [Weight] into [DispatchResultWithPostInfo].1811/// Merge [DispatchResult] with [Weight] into [DispatchResultWithPostInfo].
1814/// 1812///
1815/// Used for [CommonCollectionOperations] implementations and flexible enough to do so.1813/// Used for [CommonCollectionOperations] implementations and flexible enough to do so.
1816pub fn with_weight(res: DispatchResult, weight: Weight) -> DispatchResultWithPostInfo {1814pub fn with_weight(res: DispatchResult, weight: Weight) -> DispatchResultWithPostInfo {
1817 let post_info = PostDispatchInfo {1815 let post_info = PostDispatchInfo {