git.delta.rocks / unique-network / refs/commits / 70cdec4919d9

difftreelog

fmt

Trubnikov Sergey2022-07-28parent: #06c6a41.patch.diff
in: master

2 files changed

modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 //! # Primitives crate.
-//! 
+//!
 //! This crate contains amount of types, traits and constants.
 
 #![cfg_attr(not(feature = "std"), no_std)]
@@ -194,7 +194,7 @@
 
 impl TokenId {
 	/// Try to get next token id.
-	/// 
+	///
 	/// If next id cause overflow, then [`ArithmeticError::Overflow`] returned.
 	pub fn try_next(self) -> Result<TokenId, ArithmeticError> {
 		self.0
@@ -244,7 +244,7 @@
 pub type DecimalPoints = u8;
 
 /// Collection mode.
-/// 
+///
 /// Collection can represent various types of tokens.
 /// Each collection can contain only one type of tokens at a time.
 /// This type helps to understand which tokens the collection contains.
@@ -358,9 +358,9 @@
 pub type CollectionTokenPrefix = BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>;
 
 /// Base structure for represent collection.
-/// 
+///
 /// Used to provide basic functionality for all types of collections.
-/// 
+///
 /// #### Note
 /// Collection parameters, used in storage (see [`RpcCollection`] for the RPC version).
 #[struct_versioning::versioned(version = 2, upper)]
@@ -457,7 +457,7 @@
 }
 
 /// Data used for create collection.
-/// 
+///
 /// All fields are wrapped in [`Option`], where `None` means chain default.
 #[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Derivative, MaxEncodedLen)]
 #[derivative(Debug, Default(bound = ""))]
@@ -505,7 +505,7 @@
 /// Limits and restrictions of a collection.
 ///
 /// All fields are wrapped in [`Option`], where `None` means chain default.
-/// 
+///
 /// Update with `pallet_common::Pallet::clamp_limits`.
 // IMPORTANT: When adding/removing fields from this struct - don't forget to also
 #[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
@@ -526,9 +526,9 @@
 
 	// FIXME should we delete this or repurpose it?
 	/// Times in how many blocks we sponsor data.
-	/// 
+	///
 	/// If is `Some(v)` then **setVariableMetadata** is sponsored if there is `v` block between transactions.
-	/// 
+	///
 	/// * Default - [`SponsoringDisabled`](SponsoringRateLimit::SponsoringDisabled).
 	/// * Limit - [`MAX_SPONSOR_TIMEOUT`].
 	///
@@ -537,38 +537,38 @@
 	/// Maximum amount of tokens inside the collection. Chain default: [`COLLECTION_TOKEN_LIMIT`]
 
 	/// How many tokens can be mined into this collection.
-	/// 
+	///
 	/// * Default - [`COLLECTION_TOKEN_LIMIT`].
 	/// * Limit - [`COLLECTION_TOKEN_LIMIT`].
 	pub token_limit: Option<u32>,
 
 	/// Timeouts for transfer sponsoring.
-	/// 
+	///
 	/// * Default
 	///   - **Fungible** - [`FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT`]
 	///   - **NFT** - [`NFT_SPONSOR_TRANSFER_TIMEOUT`]
 	///   - **Refungible** - [`REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT`]
 	/// * Limit - [`MAX_SPONSOR_TIMEOUT`].
 	pub sponsor_transfer_timeout: Option<u32>,
-	
+
 	/// Timeout for sponsoring an approval in passed blocks.
-	/// 
+	///
 	/// * Default - [`SPONSOR_APPROVE_TIMEOUT`].
 	/// * Limit - [`MAX_SPONSOR_TIMEOUT`].
 	pub sponsor_approve_timeout: Option<u32>,
 
 	/// Whether the collection owner of the collection can send tokens (which belong to other users).
-	/// 
+	///
 	/// * Default - **false**.
 	pub owner_can_transfer: Option<bool>,
 
 	/// Can the collection owner burn other people's tokens.
-	/// 
+	///
 	/// * Default - **true**.
 	pub owner_can_destroy: Option<bool>,
-	
+
 	/// Is it possible to send tokens from this collection between users.
-	/// 
+	///
 	/// * Default - **true**.
 	pub transfers_enabled: Option<bool>,
 }
@@ -643,9 +643,9 @@
 }
 
 /// Permissions on certain operations within a collection.
-/// 
+///
 /// Some fields are wrapped in [`Option`], where `None` means chain default.
-/// 
+///
 /// Update with `pallet_common::Pallet::clamp_permissions`.
 #[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
 #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
@@ -653,17 +653,17 @@
 // TODO: move `pallet_common::Pallet::clamp_permissions` into `impl CollectionPermissions`.
 pub struct CollectionPermissions {
 	/// Access mode.
-	/// 
+	///
 	/// * Default - [`AccessMode::Normal`].
 	pub access: Option<AccessMode>,
 
 	/// Minting allowance.
-	/// 
+	///
 	/// * Default - **false**.
 	pub mint_mode: Option<bool>,
 
 	/// Permissions for nesting.
-	/// 
+	///
 	/// * Default
 	///   - `token_owner` - **false**
 	///   - `collection_admin` - **false**
@@ -744,7 +744,7 @@
 }
 
 /// Enum denominating how often can sponsoring occur if it is enabled.
-/// 
+///
 /// Used for [`collection limits`](CollectionLimits).
 #[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]
 #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
@@ -968,7 +968,7 @@
 #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
 pub struct PropertyPermission {
 	/// Permission to change the property and property permission.
-	/// 
+	///
 	/// If it **false** then you can not change corresponding property even if [`collection_admin`] and [`token_owner`] are **true**.
 	pub mutable: bool,
 
@@ -1031,13 +1031,13 @@
 #[derive(Debug)]
 pub enum PropertiesError {
 	/// The space allocated for properties has run out.
-	/// 
+	///
 	/// * Limit for colection - [`MAX_COLLECTION_PROPERTIES_SIZE`].
 	/// * Limit for token - [`MAX_TOKEN_PROPERTIES_SIZE`].
 	NoSpaceForProperty,
 
 	/// The property limit has been reached.
-	/// 
+	///
 	/// * Limit - [`MAX_PROPERTIES_PER_ITEM`].
 	PropertyLimitReached,
 
@@ -1045,7 +1045,7 @@
 	InvalidCharacterInPropertyKey,
 
 	/// Property key length is too long.
-	/// 
+	///
 	/// * Limit - [`MAX_PROPERTY_KEY_LENGTH`].
 	PropertyKeyIsTooLong,
 
@@ -1054,7 +1054,7 @@
 }
 
 /// Marker for scope of property.
-/// 
+///
 /// Scoped property can't be changed by user. Used for external collections.
 #[derive(Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq, Clone, Copy)]
 pub enum PropertyScope {
@@ -1088,8 +1088,7 @@
 		key: PropertyKey,
 		value: Self::Value,
 	) -> Result<(), PropertiesError>;
-	
-	
+
 	/// Try to set property with scope from iterator.
 	fn try_scoped_set_from_iter<I, KV>(
 		&mut self,
@@ -1112,7 +1111,7 @@
 	fn try_set(&mut self, key: PropertyKey, value: Self::Value) -> Result<(), PropertiesError> {
 		self.try_scoped_set(PropertyScope::None, key, value)
 	}
-	
+
 	/// Try to set property from iterator.
 	fn try_set_from_iter<I, KV>(&mut self, iter: I) -> Result<(), PropertiesError>
 	where
@@ -1152,7 +1151,7 @@
 	pub fn contains_key(&self, key: &PropertyKey) -> bool {
 		self.0.contains_key(key)
 	}
-	
+
 	/// Check if map contains key with key validation.
 	fn check_property_key(key: &PropertyKey) -> Result<(), PropertiesError> {
 		if key.is_empty() {
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
before · primitives/rpc/src/lib.rs
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/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use up_data_structs::{20	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,21	PropertyKeyPermission, TokenData, TokenChild,22};23use sp_std::vec::Vec;24use codec::Decode;25use sp_runtime::DispatchError;2627type Result<T> = core::result::Result<T, DispatchError>;2829sp_api::decl_runtime_apis! {30	#[api_version(2)]31	/// Trait for generate rpc.32	pub trait UniqueApi<CrossAccountId, AccountId> where33		AccountId: Decode,34		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,35	{36		#[changed_in(2)]37		fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;3839		/// Get number of tokens in collection owned by account.40		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;4142		/// Number of existing tokens in collection.43		fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;4445		/// Check token exist.46		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;4748		/// Get token owner.49		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5051		/// Get real owner of nested token.52		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5354		/// Get nested tokens for the specified item.55		fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>>;5657		/// Get collection properties.58		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;5960		/// Get token properties.61		fn token_properties(62			collection: CollectionId,63			token_id: TokenId,64			properties: Option<Vec<Vec<u8>>>65		) -> Result<Vec<Property>>;6667		/// Get permissions for token properties.68		fn property_permissions(69			collection: CollectionId,70			properties: Option<Vec<Vec<u8>>>71		) -> Result<Vec<PropertyKeyPermission>>;7273		/// Get token data.74		fn token_data(75			collection: CollectionId,76			token_id: TokenId,77			keys: Option<Vec<Vec<u8>>>78		) -> Result<TokenData<CrossAccountId>>;7980		/// Total number of tokens in collection.81		fn total_supply(collection: CollectionId) -> Result<u32>;8283		/// Get account balance for collection (sum of tokens pieces).84		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;85		86		/// Get account balance for specified token.87		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;8889		/// Amount of token pieces allowed to spend from granded account.90		fn allowance(91			collection: CollectionId,92			sender: CrossAccountId,93			spender: CrossAccountId,94			token: TokenId,95		) -> Result<u128>;9697		/// Get list of collection admins.98		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;99100		/// Get list of users that allowet to mint tikens in collection.101		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;102103		/// Check that user is in allowed list (see [`allowlist`]).104		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;105106		/// Last minted token id.107		fn last_token_id(collection: CollectionId) -> Result<TokenId>;108109		/// Get collection by id.110		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;111112		/// Get collection stats.113		fn collection_stats() -> Result<CollectionStats>;114115		/// Get the number of blocks through which sponsorship will be available.116		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;117118		/// Get effective colletion limits.119		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;120121		/// Get total pieces of token.122		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;123		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;124	}125}
after · primitives/rpc/src/lib.rs
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/>.1617#![cfg_attr(not(feature = "std"), no_std)]1819use up_data_structs::{20	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,21	PropertyKeyPermission, TokenData, TokenChild,22};23use sp_std::vec::Vec;24use codec::Decode;25use sp_runtime::DispatchError;2627type Result<T> = core::result::Result<T, DispatchError>;2829sp_api::decl_runtime_apis! {30	#[api_version(2)]31	/// Trait for generate rpc.32	pub trait UniqueApi<CrossAccountId, AccountId> where33		AccountId: Decode,34		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,35	{36		#[changed_in(2)]37		fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;3839		/// Get number of tokens in collection owned by account.40		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;4142		/// Number of existing tokens in collection.43		fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;4445		/// Check token exist.46		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;4748		/// Get token owner.49		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5051		/// Get real owner of nested token.52		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5354		/// Get nested tokens for the specified item.55		fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>>;5657		/// Get collection properties.58		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;5960		/// Get token properties.61		fn token_properties(62			collection: CollectionId,63			token_id: TokenId,64			properties: Option<Vec<Vec<u8>>>65		) -> Result<Vec<Property>>;6667		/// Get permissions for token properties.68		fn property_permissions(69			collection: CollectionId,70			properties: Option<Vec<Vec<u8>>>71		) -> Result<Vec<PropertyKeyPermission>>;7273		/// Get token data.74		fn token_data(75			collection: CollectionId,76			token_id: TokenId,77			keys: Option<Vec<Vec<u8>>>78		) -> Result<TokenData<CrossAccountId>>;7980		/// Total number of tokens in collection.81		fn total_supply(collection: CollectionId) -> Result<u32>;8283		/// Get account balance for collection (sum of tokens pieces).84		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;8586		/// Get account balance for specified token.87		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;8889		/// Amount of token pieces allowed to spend from granded account.90		fn allowance(91			collection: CollectionId,92			sender: CrossAccountId,93			spender: CrossAccountId,94			token: TokenId,95		) -> Result<u128>;9697		/// Get list of collection admins.98		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;99100		/// Get list of users that allowet to mint tikens in collection.101		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;102103		/// Check that user is in allowed list (see [`allowlist`]).104		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;105106		/// Last minted token id.107		fn last_token_id(collection: CollectionId) -> Result<TokenId>;108109		/// Get collection by id.110		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;111112		/// Get collection stats.113		fn collection_stats() -> Result<CollectionStats>;114115		/// Get the number of blocks through which sponsorship will be available.116		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;117118		/// Get effective colletion limits.119		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;120121		/// Get total pieces of token.122		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;123		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;124	}125}