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

difftreelog

source

primitives/rmrk-rpc/src/lib.rs2.5 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 sp_api::{Encode, Decode};20use sp_std::vec::Vec;21use sp_runtime::DispatchError;22use rmrk_traits::{primitives::*, NftChild};2324pub type Result<T> = core::result::Result<T, DispatchError>;2526pub type RpcString = Vec<u8>;2728pub type PropertyKey = RpcString;2930pub type ThemeName = RpcString;3132sp_api::decl_runtime_apis! {33	pub trait RmrkApi<34		AccountId,35		CollectionInfo,36		NftInfo,37		ResourceInfo,38		PropertyInfo,39		BaseInfo,40		PartType,41		Theme42	>43	where44		AccountId: Encode,45		CollectionInfo: Decode,46		NftInfo: Decode,47		ResourceInfo: Decode,48		PropertyInfo: Decode,49		BaseInfo: Decode,50		PartType: Decode,51		Theme: Decode,52	{53		fn last_collection_idx() -> Result<CollectionId>;5455		fn collection_by_id(id: CollectionId) -> Result<Option<CollectionInfo>>;5657		fn nft_by_id(collection_id: CollectionId, nft_id: NftId) -> Result<Option<NftInfo>>;5859		fn account_tokens(account_id: AccountId, collection_id: CollectionId) -> Result<Vec<NftId>>;6061		fn nft_children(collection_id: CollectionId, nft_id: NftId) -> Result<Vec<NftChild>>;6263		fn collection_properties(collection_id: CollectionId, filter_keys: Option<Vec<PropertyKey>>) -> Result<Vec<PropertyInfo>>;6465		fn nft_properties(collection_id: CollectionId, nft_id: NftId, filter_keys: Option<Vec<PropertyKey>>) -> Result<Vec<PropertyInfo>>;6667		fn nft_resources(collection_id: CollectionId, nft_id: NftId) -> Result<Vec<ResourceInfo>>;6869		fn nft_resource_priority(collection_id: CollectionId, nft_id: NftId, resource_id: ResourceId) -> Result<Option<u32>>;7071		fn base(base_id: BaseId) -> Result<Option<BaseInfo>>;7273		fn base_parts(base_id: BaseId) -> Result<Vec<PartType>>;7475		fn theme_names(base_id: BaseId) -> Result<Vec<ThemeName>>;7677		fn theme(base_id: BaseId, theme_name: ThemeName, filter_keys: Option<Vec<PropertyKey>>) -> Result<Option<Theme>>;78	}79}