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

difftreelog

source

primitives/rpc/src/lib.rs4.9 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<BlockNumber ,CrossAccountId, AccountId> where37		BlockNumber: Decode + Member + AtLeast32BitUnsigned,38		AccountId: Decode,39		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,40	{41		#[changed_in(2)]42		fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;4344		/// Get number of tokens in collection owned by account.45		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;4647		/// Number of existing tokens in collection.48		fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;4950		/// Check token exist.51		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;5253		/// Get token owner.54		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5556		/// Get real owner of nested token.57		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5859		/// Get nested tokens for the specified item.60		fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>>;6162		/// Get collection properties.63		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;6465		/// Get token properties.66		fn token_properties(67			collection: CollectionId,68			token_id: TokenId,69			properties: Option<Vec<Vec<u8>>>70		) -> Result<Vec<Property>>;7172		/// Get permissions for token properties.73		fn property_permissions(74			collection: CollectionId,75			properties: Option<Vec<Vec<u8>>>76		) -> Result<Vec<PropertyKeyPermission>>;7778		/// Get token data.79		fn token_data(80			collection: CollectionId,81			token_id: TokenId,82			keys: Option<Vec<Vec<u8>>>83		) -> Result<TokenData<CrossAccountId>>;8485		/// Total number of tokens in collection.86		fn total_supply(collection: CollectionId) -> Result<u32>;8788		/// Get account balance for collection (sum of tokens pieces).89		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;9091		/// Get account balance for specified token.92		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;9394		/// Amount of token pieces allowed to spend from granded account.95		fn allowance(96			collection: CollectionId,97			sender: CrossAccountId,98			spender: CrossAccountId,99			token: TokenId,100		) -> Result<u128>;101102		/// Get list of collection admins.103		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;104105		/// Get list of users that allowet to mint tikens in collection.106		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;107108		/// Check that user is in allowed list (see [`allowlist`]).109		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;110111		/// Last minted token id.112		fn last_token_id(collection: CollectionId) -> Result<TokenId>;113114		/// Get collection by id.115		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;116117		/// Get collection stats.118		fn collection_stats() -> Result<CollectionStats>;119120		/// Get the number of blocks through which sponsorship will be available.121		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;122123		/// Get effective colletion limits.124		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;125126		/// Get total pieces of token.127		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;128		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;129		fn total_staked(staker: CrossAccountId) -> Result<u128>;130		fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>>;131		fn total_staking_locked(staker: CrossAccountId) -> Result<u128>;132	}133}