difftreelog
doc: clarifications to primitives and rpcs
in: master
3 files changed
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -42,7 +42,7 @@
#[rpc(server)]
#[async_trait]
pub trait UniqueApi<BlockHash, CrossAccountId, AccountId> {
- /// Get tokens owned by account
+ /// Get tokens owned by account.
#[method(name = "unique_accountTokens")]
fn account_tokens(
&self,
@@ -51,7 +51,7 @@
at: Option<BlockHash>,
) -> Result<Vec<TokenId>>;
- /// Get tokens contained in collection
+ /// Get tokens contained within a collection.
#[method(name = "unique_collectionTokens")]
fn collection_tokens(
&self,
@@ -59,7 +59,7 @@
at: Option<BlockHash>,
) -> Result<Vec<TokenId>>;
- /// Check if token exists
+ /// Check if the token exists.
#[method(name = "unique_tokenExists")]
fn token_exists(
&self,
@@ -68,7 +68,7 @@
at: Option<BlockHash>,
) -> Result<bool>;
- /// Get token owner
+ /// Get the token owner.
#[method(name = "unique_tokenOwner")]
fn token_owner(
&self,
@@ -77,7 +77,7 @@
at: Option<BlockHash>,
) -> Result<Option<CrossAccountId>>;
- /// Get token owner, in case of nested token - find the parent recursively
+ /// Get the topmost token owner in the hierarchy of a possibly nested token.
#[method(name = "unique_topmostTokenOwner")]
fn topmost_token_owner(
&self,
@@ -86,7 +86,7 @@
at: Option<BlockHash>,
) -> Result<Option<CrossAccountId>>;
- /// Get tokens nested directly into the token
+ /// Get tokens nested directly into the token.
#[method(name = "unique_tokenChildren")]
fn token_children(
&self,
@@ -95,7 +95,7 @@
at: Option<BlockHash>,
) -> Result<Vec<TokenChild>>;
- /// Get collection properties
+ /// Get collection properties, optionally limited to the provided keys.
#[method(name = "unique_collectionProperties")]
fn collection_properties(
&self,
@@ -104,7 +104,7 @@
at: Option<BlockHash>,
) -> Result<Vec<Property>>;
- /// Get token properties
+ /// Get token properties, optionally limited to the provided keys.
#[method(name = "unique_tokenProperties")]
fn token_properties(
&self,
@@ -114,7 +114,7 @@
at: Option<BlockHash>,
) -> Result<Vec<Property>>;
- /// Get property permissions
+ /// Get property permissions, optionally limited to the provided keys.
#[method(name = "unique_propertyPermissions")]
fn property_permissions(
&self,
@@ -123,7 +123,7 @@
at: Option<BlockHash>,
) -> Result<Vec<PropertyKeyPermission>>;
- /// Get token data
+ /// Get token data, including properties, optionally limited to the provided keys, and total pieces for an RFT.
#[method(name = "unique_tokenData")]
fn token_data(
&self,
@@ -133,11 +133,11 @@
at: Option<BlockHash>,
) -> Result<TokenData<CrossAccountId>>;
- /// Get amount of unique collection tokens
+ /// Get the amount of distinctive tokens present in a collection.
#[method(name = "unique_totalSupply")]
fn total_supply(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;
- /// Get owned amount of any user tokens
+ /// Get the amount of any user tokens owned by an account.
#[method(name = "unique_accountBalance")]
fn account_balance(
&self,
@@ -146,7 +146,7 @@
at: Option<BlockHash>,
) -> Result<u32>;
- /// Get owned amount of specific account token
+ /// Get the amount of a specific token owned by an account.
#[method(name = "unique_balance")]
fn balance(
&self,
@@ -156,7 +156,7 @@
at: Option<BlockHash>,
) -> Result<String>;
- /// Get allowed amount
+ /// Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor.
#[method(name = "unique_allowance")]
fn allowance(
&self,
@@ -167,7 +167,7 @@
at: Option<BlockHash>,
) -> Result<String>;
- /// Get admin list
+ /// Get the list of admin accounts of a collection.
#[method(name = "unique_adminlist")]
fn adminlist(
&self,
@@ -175,7 +175,7 @@
at: Option<BlockHash>,
) -> Result<Vec<CrossAccountId>>;
- /// Get allowlist
+ /// Get the list of accounts allowed to operate within a collection.
#[method(name = "unique_allowlist")]
fn allowlist(
&self,
@@ -183,7 +183,7 @@
at: Option<BlockHash>,
) -> Result<Vec<CrossAccountId>>;
- /// Check if user is allowed to use collection
+ /// Check if a user is allowed to operate within a collection.
#[method(name = "unique_allowed")]
fn allowed(
&self,
@@ -192,11 +192,11 @@
at: Option<BlockHash>,
) -> Result<bool>;
- /// Get last token ID created in a collection
+ /// Get the last token ID created in a collection.
#[method(name = "unique_lastTokenId")]
fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;
- /// Get collection by specified ID
+ /// Get collection info by the specified ID.
#[method(name = "unique_collectionById")]
fn collection_by_id(
&self,
@@ -204,11 +204,11 @@
at: Option<BlockHash>,
) -> Result<Option<RpcCollection<AccountId>>>;
- /// Get collection stats
+ /// Get chain stats about collections.
#[method(name = "unique_collectionStats")]
fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;
- /// Get number of blocks when sponsored transaction is available
+ /// Get the number of blocks until sponsoring a transaction is available.
#[method(name = "unique_nextSponsored")]
fn next_sponsored(
&self,
@@ -218,7 +218,7 @@
at: Option<BlockHash>,
) -> Result<Option<u64>>;
- /// Get effective collection limits
+ /// Get effective collection limits. If not explicitly set, get the chain defaults.
#[method(name = "unique_effectiveCollectionLimits")]
fn effective_collection_limits(
&self,
@@ -226,7 +226,7 @@
at: Option<BlockHash>,
) -> Result<Option<CollectionLimits>>;
- /// Get total pieces of token
+ /// Get the total amount of pieces of an RFT.
#[method(name = "unique_totalPieces")]
fn total_pieces(
&self,
@@ -253,20 +253,20 @@
Theme,
>
{
+ /// Get the latest created collection ID.
#[method(name = "rmrk_lastCollectionIdx")]
- /// Get the latest created collection id
fn last_collection_idx(&self, at: Option<BlockHash>) -> Result<RmrkCollectionId>;
+ /// Get collection info by ID.
#[method(name = "rmrk_collectionById")]
- /// Get collection by id
fn collection_by_id(
&self,
id: RmrkCollectionId,
at: Option<BlockHash>,
) -> Result<Option<CollectionInfo>>;
+ /// Get NFT info by collection and NFT IDs.
#[method(name = "rmrk_nftById")]
- /// Get NFT by collection id and NFT id
fn nft_by_id(
&self,
collection_id: RmrkCollectionId,
@@ -274,8 +274,8 @@
at: Option<BlockHash>,
) -> Result<Option<NftInfo>>;
+ /// Get tokens owned by an account in a collection.
#[method(name = "rmrk_accountTokens")]
- /// Get tokens owned by an account in a collection
fn account_tokens(
&self,
account_id: AccountId,
@@ -283,8 +283,8 @@
at: Option<BlockHash>,
) -> Result<Vec<RmrkNftId>>;
+ /// Get tokens nested in an NFT - its direct children (not the children's children).
#[method(name = "rmrk_nftChildren")]
- /// Get NFT children
fn nft_children(
&self,
collection_id: RmrkCollectionId,
@@ -292,8 +292,8 @@
at: Option<BlockHash>,
) -> Result<Vec<RmrkNftChild>>;
+ /// Get collection properties, created by the user - not the proxy-specific properties.
#[method(name = "rmrk_collectionProperties")]
- /// Get collection properties
fn collection_properties(
&self,
collection_id: RmrkCollectionId,
@@ -301,8 +301,8 @@
at: Option<BlockHash>,
) -> Result<Vec<PropertyInfo>>;
+ /// Get NFT properties, created by the user - not the proxy-specific properties.
#[method(name = "rmrk_nftProperties")]
- /// Get NFT properties
fn nft_properties(
&self,
collection_id: RmrkCollectionId,
@@ -311,8 +311,8 @@
at: Option<BlockHash>,
) -> Result<Vec<PropertyInfo>>;
+ /// Get data of resources of an NFT.
#[method(name = "rmrk_nftResources")]
- /// Get NFT resources
fn nft_resources(
&self,
collection_id: RmrkCollectionId,
@@ -320,8 +320,8 @@
at: Option<BlockHash>,
) -> Result<Vec<ResourceInfo>>;
+ /// Get the priority of a resource in an NFT.
#[method(name = "rmrk_nftResourcePriority")]
- /// Get NFT resource priority
fn nft_resource_priority(
&self,
collection_id: RmrkCollectionId,
@@ -330,24 +330,24 @@
at: Option<BlockHash>,
) -> Result<Option<u32>>;
+ /// Get base info by its ID.
#[method(name = "rmrk_base")]
- /// Get base info
fn base(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Option<BaseInfo>>;
+ /// Get all parts of a base.
#[method(name = "rmrk_baseParts")]
- /// Get all Base's parts
fn base_parts(&self, base_id: RmrkBaseId, at: Option<BlockHash>) -> Result<Vec<PartType>>;
+ /// Get the theme names belonging to a base.
#[method(name = "rmrk_themeNames")]
- /// Get Base's theme names
fn theme_names(
&self,
base_id: RmrkBaseId,
at: Option<BlockHash>,
) -> Result<Vec<RmrkThemeName>>;
+ /// Get theme info, including properties, optionally limited to the provided keys.
#[method(name = "rmrk_themes")]
- /// Get Theme info -- name, properties, and inherit flag
fn theme(
&self,
base_id: RmrkBaseId,
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -367,32 +367,37 @@
/// Limits and restrictions of a collection.
/// All fields are wrapped in `Option`s, where None means chain default.
-// When adding/removing fields from this struct - don't forget to also update clamp_limits
+///
+/// todo:doc links to chain defaults
+// IMPORTANT: When adding/removing fields from this struct - don't forget to also
+// update clamp_limits() in pallet-common.
#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct CollectionLimits {
- /// Maximum number of owned tokens per account
+ /// Maximum number of owned tokens per account. Chain default: [`ACCOUNT_TOKEN_OWNERSHIP_LIMIT`]
pub account_token_ownership_limit: Option<u32>,
- /// Maximum size of data of a sponsored transaction
+ /// Maximum size of data in bytes of a sponsored transaction. Chain default: [`CUSTOM_DATA_LIMIT`]
pub sponsored_data_size: Option<u32>,
/// FIXME should we delete this or repurpose it?
/// None - setVariableMetadata is not sponsored
/// Some(v) - setVariableMetadata is sponsored
/// if there is v block between txs
+ ///
+ /// In any case, chain default: [`SponsoringRateLimit::SponsoringDisabled`]
pub sponsored_data_rate_limit: Option<SponsoringRateLimit>,
- /// Maximum amount of tokens inside the collection
+ /// Maximum amount of tokens inside the collection. Chain default: [`COLLECTION_TOKEN_LIMIT`]
pub token_limit: Option<u32>,
- /// Timeout for sponsoring a token transfer in passed blocks
+ /// Timeout for sponsoring a token transfer in passed blocks. Chain default: [`MAX_SPONSOR_TIMEOUT`]
pub sponsor_transfer_timeout: Option<u32>,
- /// Timeout for sponsoring an approval in passed blocks
+ /// Timeout for sponsoring an approval in passed blocks. Chain default: [`SPONSOR_APPROVE_TIMEOUT`]
pub sponsor_approve_timeout: Option<u32>,
- /// Can a token be transferred by the owner
+ /// Can a token be transferred by the owner. Chain default: `false`
pub owner_can_transfer: Option<bool>,
- /// Can a token be burned by the owner
+ /// Can a token be burned by the owner. Chain default: `true`
pub owner_can_destroy: Option<bool>,
- /// Can a token be transferred at all
+ /// Can a token be transferred at all. Chain default: `true`
pub transfers_enabled: Option<bool>,
}
@@ -445,7 +450,10 @@
}
}
-// When adding/removing fields from this struct - don't forget to also update clamp_limits
+/// Permissions on certain operations within a collection.
+/// All fields are wrapped in `Option`s, where None means chain default.
+// IMPORTANT: When adding/removing fields from this struct - don't forget to also
+// update clamp_limits() in pallet-common.
#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct CollectionPermissions {
@@ -500,6 +508,7 @@
}
}
+/// Part of collection permissions, if set, defines who is able to nest tokens into other tokens.
#[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen, Derivative)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[derivative(Debug)]
@@ -516,14 +525,17 @@
pub permissive: bool,
}
+/// Enum denominating how often can sponsoring occur if it is enabled.
#[derive(Encode, Decode, Debug, Clone, Copy, PartialEq, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub enum SponsoringRateLimit {
+ /// Sponsoring is disabled, and the collection sponsor will not pay for transactions
SponsoringDisabled,
/// Once per how many blocks can sponsorship of a transaction type occur
Blocks(u32),
}
+/// Data used to describe an NFT at creation.
#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[derivative(Debug)]
@@ -534,17 +546,20 @@
pub properties: CollectionPropertiesVec,
}
+/// Data used to describe a Fungible token at creation.
#[derive(Encode, Decode, MaxEncodedLen, Default, Debug, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct CreateFungibleData {
- /// Number of fungible tokens minted
+ /// Number of fungible coins minted
pub value: u128,
}
+/// Data used to describe a Refungible token at creation.
#[derive(Encode, Decode, MaxEncodedLen, Default, PartialEq, Clone, Derivative, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[derivative(Debug)]
pub struct CreateReFungibleData {
+ /// Immutable metadata of the token
#[cfg_attr(feature = "serde1", serde(with = "bounded::vec_serde"))]
#[derivative(Debug(format_with = "bounded::vec_debug"))]
pub const_data: BoundedVec<u8, CustomDataLimit>,
@@ -560,6 +575,7 @@
None,
}
+/// Enum holding data used for creation of all three item types.
#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, Debug, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub enum CreateItemData {
tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth1// 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/>.1617type RpcParam = {18 name: string;19 type: string;20 isOptional?: true;21};2223const CROSS_ACCOUNT_ID_TYPE = 'PalletEvmAccountBasicCrossAccountIdRepr';2425const collectionParam = {name: 'collection', type: 'u32'};26const tokenParam = {name: 'tokenId', type: 'u32'};27const propertyKeysParam = {name: 'propertyKeys', type: 'Vec<String>', isOptional: true};28const crossAccountParam = (name = 'account') => ({name, type: CROSS_ACCOUNT_ID_TYPE});29const atParam = {name: 'at', type: 'Hash', isOptional: true};3031const fun = (description: string, params: RpcParam[], type: string) => ({32 description,33 params: [...params, atParam],34 type,35});3637export default {38 types: {},39 rpc: {40 adminlist: fun('Get admin list', [collectionParam], 'Vec<PalletEvmAccountBasicCrossAccountIdRepr>'),41 allowlist: fun('Get allowlist', [collectionParam], 'Vec<PalletEvmAccountBasicCrossAccountIdRepr>'),4243 accountTokens: fun('Get tokens owned by account', [collectionParam, crossAccountParam()], 'Vec<u32>'),44 collectionTokens: fun('Get tokens contained in collection', [collectionParam], 'Vec<u32>'),4546 lastTokenId: fun('Get last token ID created in a collection', [collectionParam], 'u32'),47 totalSupply: fun('Get amount of unique collection tokens', [collectionParam], 'u32'),48 accountBalance: fun('Get owned amount of any user tokens', [collectionParam, crossAccountParam()], 'u32'),49 balance: fun('Get owned amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),50 allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),51 tokenOwner: fun('Get token owner', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),52 topmostTokenOwner: fun('Get token owner, in case of nested token - find the parent recursively', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),53 tokenChildren: fun('Get tokens nested directly into the token', [collectionParam, tokenParam], 'Vec<UpDataStructsTokenChild>'),54 constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),55 variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),56 collectionProperties: fun(57 'Get collection properties',58 [collectionParam, propertyKeysParam],59 'Vec<UpDataStructsProperty>',60 ),61 tokenProperties: fun(62 'Get token properties',63 [collectionParam, tokenParam, propertyKeysParam],64 'Vec<UpDataStructsProperty>',65 ),66 propertyPermissions: fun(67 'Get property permissions',68 [collectionParam, propertyKeysParam],69 'Vec<UpDataStructsPropertyKeyPermission>',70 ),71 tokenData: fun(72 'Get token data',73 [collectionParam, tokenParam, propertyKeysParam],74 'UpDataStructsTokenData',75 ),76 tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'),77 collectionById: fun('Get collection by specified ID', [collectionParam], 'Option<UpDataStructsRpcCollection>'),78 collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),79 allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),80 nextSponsored: fun('Get number of blocks when sponsored transaction is available', [collectionParam, crossAccountParam(), tokenParam], 'Option<u64>'),81 effectiveCollectionLimits: fun('Get effective collection limits', [collectionParam], 'Option<UpDataStructsCollectionLimits>'),82 totalPieces: fun('Get total pieces of token', [collectionParam, tokenParam], 'Option<u128>'),83 },84};