git.delta.rocks / unique-network / refs/commits / 2203d0f0ed69

difftreelog

source

primitives/rpc/src/lib.rs4.6 KiBsourcehistory
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};2324use sp_std::vec::Vec;25use codec::Decode;26use sp_runtime::{27	DispatchError,28	traits::{AtLeast32BitUnsigned, Member},29};3031type Result<T> = core::result::Result<T, DispatchError>;3233sp_api::decl_runtime_apis! {34	#[api_version(2)]35	/// Trait for generate rpc.36	pub trait UniqueApi<CrossAccountId, AccountId> where37		AccountId: Decode,38		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,39	{40		#[changed_in(2)]41		fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;4243		/// Get number of tokens in collection owned by account.44		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;4546		/// Number of existing tokens in collection.47		fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;4849		/// Check token exist.50		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;5152		/// Get token owner.53		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5455		/// Get real owner of nested token.56		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5758		/// Get nested tokens for the specified item.59		fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>>;6061		/// Get collection properties.62		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;6364		/// Get token properties.65		fn token_properties(66			collection: CollectionId,67			token_id: TokenId,68			properties: Option<Vec<Vec<u8>>>69		) -> Result<Vec<Property>>;7071		/// Get permissions for token properties.72		fn property_permissions(73			collection: CollectionId,74			properties: Option<Vec<Vec<u8>>>75		) -> Result<Vec<PropertyKeyPermission>>;7677		/// Get token data.78		fn token_data(79			collection: CollectionId,80			token_id: TokenId,81			keys: Option<Vec<Vec<u8>>>82		) -> Result<TokenData<CrossAccountId>>;8384		/// Total number of tokens in collection.85		fn total_supply(collection: CollectionId) -> Result<u32>;8687		/// Get account balance for collection (sum of tokens pieces).88		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;8990		/// Get account balance for specified token.91		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;9293		/// Amount of token pieces allowed to spend from granded account.94		fn allowance(95			collection: CollectionId,96			sender: CrossAccountId,97			spender: CrossAccountId,98			token: TokenId,99		) -> Result<u128>;100101		/// Get list of collection admins.102		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;103104		/// Get list of users that allowet to mint tikens in collection.105		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;106107		/// Check that user is in allowed list (see [`allowlist`]).108		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;109110		/// Last minted token id.111		fn last_token_id(collection: CollectionId) -> Result<TokenId>;112113		/// Get collection by id.114		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;115116		/// Get collection stats.117		fn collection_stats() -> Result<CollectionStats>;118119		/// Get the number of blocks through which sponsorship will be available.120		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;121122		/// Get effective colletion limits.123		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;124125		/// Get total pieces of token.126		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;127128		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;129	}130}