difftreelog
fmt
in: master
3 files changed
pallets/common/src/dispatch.rsdiffbeforeafterboth23}23}242425/// Helper function to implement substrate calls for common collection methods.25/// Helper function to implement substrate calls for common collection methods.26/// 26///27/// * `collection` - The collection on which to call the method.27/// * `collection` - The collection on which to call the method.28/// * `call` - The function in which to call the corresponding method from [CommonCollectionOperations].28/// * `call` - The function in which to call the corresponding method from [CommonCollectionOperations].29pub fn dispatch_tx<29pub fn dispatch_tx<72/// Interface for working with different collections through the dispatcher.72/// Interface for working with different collections through the dispatcher.73pub trait CollectionDispatch<T: Config> {73pub trait CollectionDispatch<T: Config> {74 /// Create a collection. The collection will be created according to the value of [data.mode](CreateCollectionData::mode).74 /// Create a collection. The collection will be created according to the value of [data.mode](CreateCollectionData::mode).75 /// 75 ///76 /// * `sender` - The user who will become the owner of the collection.76 /// * `sender` - The user who will become the owner of the collection.77 /// * `data` - Description of the created collection.77 /// * `data` - Description of the created collection.78 fn create(78 fn create(81 ) -> DispatchResult;81 ) -> DispatchResult;828283 /// Delete the collection.83 /// Delete the collection.84 /// 84 ///85 /// * `sender` - The owner of the collection.85 /// * `sender` - The owner of the collection.86 /// * `handle` - Collection handle.86 /// * `handle` - Collection handle.87 fn destroy(sender: T::CrossAccountId, handle: CollectionHandle<T>) -> DispatchResult;87 fn destroy(sender: T::CrossAccountId, handle: CollectionHandle<T>) -> DispatchResult;888889 /// Get a specialized collection from the handle.89 /// Get a specialized collection from the handle.90 /// 90 ///91 /// * `handle` - Collection handle.91 /// * `handle` - Collection handle.92 fn dispatch(handle: CollectionHandle<T>) -> Self;92 fn dispatch(handle: CollectionHandle<T>) -> Self;9393pallets/common/src/erc.rsdiffbeforeafterboth61 T::AccountId: From<[u8; 32]>,61 T::AccountId: From<[u8; 32]>,62{62{63 /// Set collection property.63 /// Set collection property.64 /// 64 ///65 /// @param key Property key.65 /// @param key Property key.66 /// @param value Propery value.66 /// @param value Propery value.67 fn set_collection_property(67 fn set_collection_property(81 }81 }82 8283 /// Delete collection property.83 /// Delete collection property.84 /// 84 ///85 /// @param key Property key.85 /// @param key Property key.86 fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {86 fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {87 let caller = T::CrossAccountId::from_eth(caller);87 let caller = T::CrossAccountId::from_eth(caller);93 }93 }949495 /// Get collection property.95 /// Get collection property.96 /// 96 ///97 /// @dev Throws error if key not found.97 /// @dev Throws error if key not found.98 /// 98 ///99 /// @param key Property key.99 /// @param key Property key.100 /// @return bytes The property corresponding to the key.100 /// @return bytes The property corresponding to the key.101 fn collection_property(&self, key: string) -> Result<bytes> {101 fn collection_property(&self, key: string) -> Result<bytes> {110 }110 }111111112 /// Set the sponsor of the collection.112 /// Set the sponsor of the collection.113 /// 113 ///114 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.114 /// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.115 /// 115 ///116 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.116 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.117 fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<void> {117 fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<void> {118 check_is_owner_or_admin(caller, self)?;118 check_is_owner_or_admin(caller, self)?;124 }124 }125125126 /// Collection sponsorship confirmation.126 /// Collection sponsorship confirmation.127 /// 127 ///128 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.128 /// @dev After setting the sponsor for the collection, it must be confirmed with this function.129 fn confirm_collection_sponsorship(&mut self, caller: caller) -> Result<void> {129 fn confirm_collection_sponsorship(&mut self, caller: caller) -> Result<void> {130 let caller = T::CrossAccountId::from_eth(caller);130 let caller = T::CrossAccountId::from_eth(caller);261 }256 }262257263 /// Remove collection admin.258 /// Remove collection admin.264 /// 259 ///265 /// @param new_admin Address of the removed administrator.260 /// @param new_admin Address of the removed administrator.266 fn remove_collection_admin(&self, caller: caller, admin: address) -> Result<void> {261 fn remove_collection_admin(&self, caller: caller, admin: address) -> Result<void> {267 let caller = T::CrossAccountId::from_eth(caller);262 let caller = T::CrossAccountId::from_eth(caller);271 }266 }272267273 /// Toggle accessibility of collection nesting.268 /// Toggle accessibility of collection nesting.274 /// 269 ///275 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'270 /// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'276 #[solidity(rename_selector = "setCollectionNesting")]271 #[solidity(rename_selector = "setCollectionNesting")]277 fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<void> {272 fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<void> {294 }289 }295290296 /// Toggle accessibility of collection nesting.291 /// Toggle accessibility of collection nesting.297 /// 292 ///298 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'293 /// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'299 /// @param collections Addresses of collections that will be available for nesting.294 /// @param collections Addresses of collections that will be available for nesting.300 #[solidity(rename_selector = "setCollectionNesting")]295 #[solidity(rename_selector = "setCollectionNesting")]367 }362 }368363369 /// Add the user to the allowed list.364 /// Add the user to the allowed list.370 /// 365 ///371 /// @param user Address of a trusted user.366 /// @param user Address of a trusted user.372 fn add_to_collection_allow_list(&self, caller: caller, user: address) -> Result<void> {367 fn add_to_collection_allow_list(&self, caller: caller, user: address) -> Result<void> {373 let caller = T::CrossAccountId::from_eth(caller);368 let caller = T::CrossAccountId::from_eth(caller);377 }372 }378 373379 /// Remove the user from the allowed list.374 /// Remove the user from the allowed list.380 /// 375 ///381 /// @param user Address of a removed user.376 /// @param user Address of a removed user.382 fn remove_from_collection_allow_list(&self, caller: caller, user: address) -> Result<void> {377 fn remove_from_collection_allow_list(&self, caller: caller, user: address) -> Result<void> {383 let caller = T::CrossAccountId::from_eth(caller);378 let caller = T::CrossAccountId::from_eth(caller);387 }382 }388383389 /// Switch permission for minting.384 /// Switch permission for minting.390 /// 385 ///391 /// @param mode Enable if "true".386 /// @param mode Enable if "true".392 fn set_collection_mint_mode(&mut self, caller: caller, mode: bool) -> Result<void> {387 fn set_collection_mint_mode(&mut self, caller: caller, mode: bool) -> Result<void> {393 check_is_owner_or_admin(caller, self)?;388 check_is_owner_or_admin(caller, self)?;pallets/common/src/lib.rsdiffbeforeafterboth17//! # Common pallet17//! # Common pallet18//!18//!19//! The Common pallet provides functionality for handling collections.19//! The Common pallet provides functionality for handling collections.20//! 20//!21//! ## Overview21//! ## Overview22//! 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//! ### Terminology37//! **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 will38//! 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 various43//! 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 permission46//! 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 right52//! to most actions on the collection.52//! to most actions on the collection.535453131/// Weight info.130/// Weight info.132pub type SelfWeightOf<T> = <T as Config>::WeightInfo;131pub type SelfWeightOf<T> = <T as Config>::WeightInfo;133132134/// 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 }209208210 /// 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 }219218220 /// Confirm sponsorship219 /// Confirm sponsorship221 /// 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 ),384383385 /// New collection was destroyed384 /// New collection was destroyed386 CollectionDestroyed(385 CollectionDestroyed(387 /// Globally unique identifier of collection.386 /// Globally unique identifier of collection.388 CollectionId387 CollectionId,389 ),388 ),390389391 /// New item was created.390 /// New item was created.397 /// Owner of newly created item396 /// Owner of newly created item398 T::CrossAccountId,397 T::CrossAccountId,399 /// Always 1 for NFT398 /// Always 1 for NFT400 u128399 u128,401 ),400 ),402401403 /// 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 ),413413414 /// Item was transferred414 /// Item was transferred444 /// 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 449450 /// 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 457458 /// 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 467468 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 477479 /// 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 }487486735734736impl<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!(886885887impl<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 }992991993 /// 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 }102410231025 /// 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 }104710461048 /// 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 10641066 /// 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 }108310821084 /// 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 11001102 /// 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 11251127 /// 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 11431145 /// 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 }116111601162 /// 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 }119611951197 /// 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;143114301432 /// 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;143614351437 /// 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;144114401445 fn set_token_properties(amount: u32) -> Weight;1444 fn set_token_properties(amount: u32) -> Weight;144614451447 /// 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 14501452 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;145714551480 14781481 /// 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}149614941497/// 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 pallets1500/// 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;151515131516 /// 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 15271530 /// 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;154215401543 /// 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 15521555 /// 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;156815661569 /// 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;157815761579 /// 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;158815861589 /// Set token properties.1587 /// Set token properties.1590 /// 1588 ///1591 /// The appropriate [PropertyPermission] for the token property 1589 /// The appropriate [PropertyPermission] for the token property1592 /// 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;160516031606 /// Remove token properties.1604 /// Remove token properties.1607 /// 1605 ///1608 /// The appropriate [PropertyPermission] for the token property 1606 /// The appropriate [PropertyPermission] for the token property1609 /// 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;162216201623 /// 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;163416321635 /// 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;165016481651 /// 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 16621665 /// 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 16821685 /// 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;170217001703 /// 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;171617141717 /// 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));172217201723 /// 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));172817261729 /// 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>;173317311734 /// 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>;173617341737 /// 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;174117391742 /// 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;174417421745 /// 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>;174917471750 /// 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>;175517531756 /// 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;176517631766 /// 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;177017681775 fn total_pieces(&self, token: TokenId) -> Option<u128>;1773 fn total_pieces(&self, token: TokenId) -> Option<u128>;177617741777 /// 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}181218101813/// 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 {