git.delta.rocks / unique-network / refs/heads / master

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 parity_scale_codec::Decode;22use sp_runtime::DispatchError;23use sp_std::vec::Vec;24use up_data_structs::{25	CollectionId, CollectionLimits, CollectionStats, Property, PropertyKeyPermission,26	RpcCollection, TokenChild, TokenData, TokenId,27};2829type Result<T> = core::result::Result<T, DispatchError>;3031sp_api::decl_runtime_apis! {32	#[api_version(3)]33	/// Trait for generate rpc.34	pub trait UniqueApi<CrossAccountId, AccountId> where35		AccountId: Decode,36		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,37	{38		/// Get number of tokens in collection owned by account.39		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;4041		/// Number of existing tokens in collection.42		fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;4344		/// Check token exist.45		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;4647		/// Get token owner.48		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;4950		/// Get real owner of nested token.51		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5253		/// Get nested tokens for the specified item.54		fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>>;5556		/// Get collection properties.57		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;5859		/// Get token properties.60		fn token_properties(61			collection: CollectionId,62			token_id: TokenId,63			properties: Option<Vec<Vec<u8>>>64		) -> Result<Vec<Property>>;6566		/// Get permissions for token properties.67		fn property_permissions(68			collection: CollectionId,69			properties: Option<Vec<Vec<u8>>>70		) -> Result<Vec<PropertyKeyPermission>>;7172		/// Get token data.73		fn token_data(74			collection: CollectionId,75			token_id: TokenId,76			keys: Option<Vec<Vec<u8>>>77		) -> Result<TokenData<CrossAccountId>>;7879		#[changed_in(3)]80		fn token_data(81			collection: CollectionId,82			token_id: TokenId,83			keys: Option<Vec<Vec<u8>>>84		) -> Result<up_data_structs::TokenDataVersion1<CrossAccountId>>;8586		/// Total number of tokens in collection.87		fn total_supply(collection: CollectionId) -> Result<u32>;8889		/// Get account balance for collection (sum of tokens pieces).90		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;9192		/// Get account balance for specified token.93		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;9495		/// Amount of token pieces allowed to spend from granded account.96		fn allowance(97			collection: CollectionId,98			sender: CrossAccountId,99			spender: CrossAccountId,100			token: TokenId,101		) -> Result<u128>;102103		/// Get list of collection admins.104		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;105106		/// Get list of users that allowet to mint tikens in collection.107		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;108109		/// Check that user is in allowed list (see [`allowlist`]).110		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;111112		/// Last minted token id.113		fn last_token_id(collection: CollectionId) -> Result<TokenId>;114115		/// Get collection by id.116		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;117118		#[changed_in(3)]119		fn collection_by_id(collection: CollectionId) -> Result<Option<up_data_structs::RawEncoded>>;120121		/// Get collection stats.122		fn collection_stats() -> Result<CollectionStats>;123124		/// Get the number of blocks through which sponsorship will be available.125		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;126127		/// Get effective colletion limits.128		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;129130		/// Get total pieces of token.131		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;132133		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;134135		/// Get whether an operator is approved by a given owner.136		fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool>;137	}138}