git.delta.rocks / unique-network / refs/commits / bce2cc1e9ab8

difftreelog

source

primitives/rpc/src/lib.rs5.0 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)]1819extern crate alloc;2021use up_data_structs::{22	CollectionId, TokenId, RawEncoded, RpcCollection, CollectionStats, CollectionLimits, Property,23	PropertyKeyPermission, TokenData, TokenChild, TokenDataVersion1,24};2526use sp_std::vec::Vec;27use codec::Decode;28use sp_runtime::DispatchError;2930type Result<T> = core::result::Result<T, DispatchError>;3132sp_api::decl_runtime_apis! {33	#[api_version(3)]34	/// Trait for generate rpc.35	pub trait UniqueApi<CrossAccountId, AccountId> where36		AccountId: Decode,37		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,38	{39		/// 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		#[changed_in(3)]81		fn token_data(82			collection: CollectionId,83			token_id: TokenId,84			keys: Option<Vec<Vec<u8>>>85		) -> Result<TokenDataVersion1<CrossAccountId>>;8687		/// Total number of tokens in collection.88		fn total_supply(collection: CollectionId) -> Result<u32>;8990		/// Get account balance for collection (sum of tokens pieces).91		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;9293		/// Get account balance for specified token.94		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;9596		/// Amount of token pieces allowed to spend from granded account.97		fn allowance(98			collection: CollectionId,99			sender: CrossAccountId,100			spender: CrossAccountId,101			token: TokenId,102		) -> Result<u128>;103104		/// Get list of collection admins.105		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;106107		/// Get list of users that allowet to mint tikens in collection.108		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;109110		/// Check that user is in allowed list (see [`allowlist`]).111		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;112113		/// Last minted token id.114		fn last_token_id(collection: CollectionId) -> Result<TokenId>;115116		/// Get collection by id.117		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;118119		#[changed_in(3)]120		fn collection_by_id(collection: CollectionId) -> Result<Option<RawEncoded>>;121122		/// Get collection stats.123		fn collection_stats() -> Result<CollectionStats>;124125		/// Get the number of blocks through which sponsorship will be available.126		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;127128		/// Get effective colletion limits.129		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;130131		/// Get total pieces of token.132		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;133134		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;135136		/// Get whether an operator is approved by a given owner.137		fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool>;138	}139}