difftreelog
fmt
in: master
2 files changed
primitives/data-structs/src/lib.rsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617//! # Primitives crate.17//! # Primitives crate.18//! 18//!19//! This crate contains amount of types, traits and constants.19//! This crate contains amount of types, traits and constants.202021#![cfg_attr(not(feature = "std"), no_std)]21#![cfg_attr(not(feature = "std"), no_std)]194194195impl TokenId {195impl TokenId {196 /// Try to get next token id.196 /// Try to get next token id.197 /// 197 ///198 /// If next id cause overflow, then [`ArithmeticError::Overflow`] returned.198 /// If next id cause overflow, then [`ArithmeticError::Overflow`] returned.199 pub fn try_next(self) -> Result<TokenId, ArithmeticError> {199 pub fn try_next(self) -> Result<TokenId, ArithmeticError> {200 self.0200 self.0244pub type DecimalPoints = u8;244pub type DecimalPoints = u8;245245246/// Collection mode.246/// Collection mode.247/// 247///248/// Collection can represent various types of tokens.248/// Collection can represent various types of tokens.249/// Each collection can contain only one type of tokens at a time.249/// Each collection can contain only one type of tokens at a time.250/// This type helps to understand which tokens the collection contains.250/// This type helps to understand which tokens the collection contains.358pub type CollectionTokenPrefix = BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>;358pub type CollectionTokenPrefix = BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>;359359360/// Base structure for represent collection.360/// Base structure for represent collection.361/// 361///362/// Used to provide basic functionality for all types of collections.362/// Used to provide basic functionality for all types of collections.363/// 363///364/// #### Note364/// #### Note365/// Collection parameters, used in storage (see [`RpcCollection`] for the RPC version).365/// Collection parameters, used in storage (see [`RpcCollection`] for the RPC version).366#[struct_versioning::versioned(version = 2, upper)]366#[struct_versioning::versioned(version = 2, upper)]457}457}458458459/// Data used for create collection.459/// Data used for create collection.460/// 460///461/// All fields are wrapped in [`Option`], where `None` means chain default.461/// All fields are wrapped in [`Option`], where `None` means chain default.462#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Derivative, MaxEncodedLen)]462#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, Derivative, MaxEncodedLen)]463#[derivative(Debug, Default(bound = ""))]463#[derivative(Debug, Default(bound = ""))]505/// Limits and restrictions of a collection.505/// Limits and restrictions of a collection.506///506///507/// All fields are wrapped in [`Option`], where `None` means chain default.507/// All fields are wrapped in [`Option`], where `None` means chain default.508/// 508///509/// Update with `pallet_common::Pallet::clamp_limits`.509/// Update with `pallet_common::Pallet::clamp_limits`.510// IMPORTANT: When adding/removing fields from this struct - don't forget to also510// IMPORTANT: When adding/removing fields from this struct - don't forget to also511#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]511#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]526526527 // FIXME should we delete this or repurpose it?527 // FIXME should we delete this or repurpose it?528 /// Times in how many blocks we sponsor data.528 /// Times in how many blocks we sponsor data.529 /// 529 ///530 /// If is `Some(v)` then **setVariableMetadata** is sponsored if there is `v` block between transactions.530 /// If is `Some(v)` then **setVariableMetadata** is sponsored if there is `v` block between transactions.531 /// 531 ///532 /// * Default - [`SponsoringDisabled`](SponsoringRateLimit::SponsoringDisabled).532 /// * Default - [`SponsoringDisabled`](SponsoringRateLimit::SponsoringDisabled).533 /// * Limit - [`MAX_SPONSOR_TIMEOUT`].533 /// * Limit - [`MAX_SPONSOR_TIMEOUT`].534 ///534 ///537 /// Maximum amount of tokens inside the collection. Chain default: [`COLLECTION_TOKEN_LIMIT`]537 /// Maximum amount of tokens inside the collection. Chain default: [`COLLECTION_TOKEN_LIMIT`]538538539 /// How many tokens can be mined into this collection.539 /// How many tokens can be mined into this collection.540 /// 540 ///541 /// * Default - [`COLLECTION_TOKEN_LIMIT`].541 /// * Default - [`COLLECTION_TOKEN_LIMIT`].542 /// * Limit - [`COLLECTION_TOKEN_LIMIT`].542 /// * Limit - [`COLLECTION_TOKEN_LIMIT`].543 pub token_limit: Option<u32>,543 pub token_limit: Option<u32>,544544545 /// Timeouts for transfer sponsoring.545 /// Timeouts for transfer sponsoring.546 /// 546 ///547 /// * Default547 /// * Default548 /// - **Fungible** - [`FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT`]548 /// - **Fungible** - [`FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT`]549 /// - **NFT** - [`NFT_SPONSOR_TRANSFER_TIMEOUT`]549 /// - **NFT** - [`NFT_SPONSOR_TRANSFER_TIMEOUT`]552 pub sponsor_transfer_timeout: Option<u32>,552 pub sponsor_transfer_timeout: Option<u32>,553 553554 /// Timeout for sponsoring an approval in passed blocks.554 /// Timeout for sponsoring an approval in passed blocks.555 /// 555 ///556 /// * Default - [`SPONSOR_APPROVE_TIMEOUT`].556 /// * Default - [`SPONSOR_APPROVE_TIMEOUT`].557 /// * Limit - [`MAX_SPONSOR_TIMEOUT`].557 /// * Limit - [`MAX_SPONSOR_TIMEOUT`].558 pub sponsor_approve_timeout: Option<u32>,558 pub sponsor_approve_timeout: Option<u32>,559559560 /// Whether the collection owner of the collection can send tokens (which belong to other users).560 /// Whether the collection owner of the collection can send tokens (which belong to other users).561 /// 561 ///562 /// * Default - **false**.562 /// * Default - **false**.563 pub owner_can_transfer: Option<bool>,563 pub owner_can_transfer: Option<bool>,564564565 /// Can the collection owner burn other people's tokens.565 /// Can the collection owner burn other people's tokens.566 /// 566 ///567 /// * Default - **true**.567 /// * Default - **true**.568 pub owner_can_destroy: Option<bool>,568 pub owner_can_destroy: Option<bool>,569 569570 /// Is it possible to send tokens from this collection between users.570 /// Is it possible to send tokens from this collection between users.571 /// 571 ///572 /// * Default - **true**.572 /// * Default - **true**.573 pub transfers_enabled: Option<bool>,573 pub transfers_enabled: Option<bool>,574}574}643}643}644644645/// Permissions on certain operations within a collection.645/// Permissions on certain operations within a collection.646/// 646///647/// Some fields are wrapped in [`Option`], where `None` means chain default.647/// Some fields are wrapped in [`Option`], where `None` means chain default.648/// 648///649/// Update with `pallet_common::Pallet::clamp_permissions`.649/// Update with `pallet_common::Pallet::clamp_permissions`.650#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]650#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]651#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]651#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]652// When adding/removing fields from this struct - don't forget to also update `pallet_common::Pallet::clamp_permissions`.652// When adding/removing fields from this struct - don't forget to also update `pallet_common::Pallet::clamp_permissions`.653// TODO: move `pallet_common::Pallet::clamp_permissions` into `impl CollectionPermissions`.653// TODO: move `pallet_common::Pallet::clamp_permissions` into `impl CollectionPermissions`.654pub struct CollectionPermissions {654pub struct CollectionPermissions {655 /// Access mode.655 /// Access mode.656 /// 656 ///657 /// * Default - [`AccessMode::Normal`].657 /// * Default - [`AccessMode::Normal`].658 pub access: Option<AccessMode>,658 pub access: Option<AccessMode>,659659660 /// Minting allowance.660 /// Minting allowance.661 /// 661 ///662 /// * Default - **false**.662 /// * Default - **false**.663 pub mint_mode: Option<bool>,663 pub mint_mode: Option<bool>,664664665 /// Permissions for nesting.665 /// Permissions for nesting.666 /// 666 ///667 /// * Default667 /// * Default668 /// - `token_owner` - **false**668 /// - `token_owner` - **false**669 /// - `collection_admin` - **false**669 /// - `collection_admin` - **false**744}744}745745746/// Enum denominating how often can sponsoring occur if it is enabled.746/// Enum denominating how often can sponsoring occur if it is enabled.747/// 747///748/// Used for [`collection limits`](CollectionLimits).748/// Used for [`collection limits`](CollectionLimits).749#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]749#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]750#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]750#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]968#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]968#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]969pub struct PropertyPermission {969pub struct PropertyPermission {970 /// Permission to change the property and property permission.970 /// Permission to change the property and property permission.971 /// 971 ///972 /// If it **false** then you can not change corresponding property even if [`collection_admin`] and [`token_owner`] are **true**.972 /// If it **false** then you can not change corresponding property even if [`collection_admin`] and [`token_owner`] are **true**.973 pub mutable: bool,973 pub mutable: bool,9749741031#[derive(Debug)]1031#[derive(Debug)]1032pub enum PropertiesError {1032pub enum PropertiesError {1033 /// The space allocated for properties has run out.1033 /// The space allocated for properties has run out.1034 /// 1034 ///1035 /// * Limit for colection - [`MAX_COLLECTION_PROPERTIES_SIZE`].1035 /// * Limit for colection - [`MAX_COLLECTION_PROPERTIES_SIZE`].1036 /// * Limit for token - [`MAX_TOKEN_PROPERTIES_SIZE`].1036 /// * Limit for token - [`MAX_TOKEN_PROPERTIES_SIZE`].1037 NoSpaceForProperty,1037 NoSpaceForProperty,103810381039 /// The property limit has been reached.1039 /// The property limit has been reached.1040 /// 1040 ///1041 /// * Limit - [`MAX_PROPERTIES_PER_ITEM`].1041 /// * Limit - [`MAX_PROPERTIES_PER_ITEM`].1042 PropertyLimitReached,1042 PropertyLimitReached,104310431044 /// Property key contains not allowed character.1044 /// Property key contains not allowed character.1045 InvalidCharacterInPropertyKey,1045 InvalidCharacterInPropertyKey,104610461047 /// Property key length is too long.1047 /// Property key length is too long.1048 /// 1048 ///1049 /// * Limit - [`MAX_PROPERTY_KEY_LENGTH`].1049 /// * Limit - [`MAX_PROPERTY_KEY_LENGTH`].1050 PropertyKeyIsTooLong,1050 PropertyKeyIsTooLong,105110511054}1054}105510551056/// Marker for scope of property.1056/// Marker for scope of property.1057/// 1057///1058/// Scoped property can't be changed by user. Used for external collections.1058/// Scoped property can't be changed by user. Used for external collections.1059#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq, Clone, Copy)]1059#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, PartialEq, Clone, Copy)]1060pub enum PropertyScope {1060pub enum PropertyScope {primitives/rpc/src/lib.rsdiffbeforeafterbothno syntactic changes