git.delta.rocks / unique-network / refs/commits / 424362fb52a4

difftreelog

Merge pull request #683 from UniqueNetwork/fix/collection-rpc-runtime-versioning

Yaroslav Bolyukin2022-10-26parents: #778aa39 #6fd4079.patch.diff
in: master

3 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -557,7 +557,10 @@
 	pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>, unique_api);
 	pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool, unique_api);
 	pass_method!(last_token_id(collection: CollectionId) -> TokenId, unique_api);
-	pass_method!(collection_by_id(collection: CollectionId) -> Option<RpcCollection<AccountId>>, unique_api);
+	pass_method!(
+		collection_by_id(collection: CollectionId) -> Option<RpcCollection<AccountId>>, unique_api;
+		changed_in 3, collection_by_id_before_version_3(collection) => |value| value.map(|coll| coll.into())
+	);
 	pass_method!(collection_stats() -> CollectionStats, unique_api);
 	pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);
 	pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -447,6 +447,7 @@
 }
 
 /// Collection parameters, used in RPC calls (see [`Collection`] for the storage version).
+#[struct_versioning::versioned(version = 2, upper)]
 #[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
 #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
 pub struct RpcCollection<AccountId> {
@@ -484,6 +485,7 @@
 	pub read_only: bool,
 
 	/// Extra collection flags
+	#[version(2.., upper(RpcCollectionFlags {foreign: false, erc721metadata: false}))]
 	pub flags: RpcCollectionFlags,
 }
 
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
before · primitives/rpc/src/lib.rs
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::DispatchError;2728type Result<T> = core::result::Result<T, DispatchError>;2930sp_api::decl_runtime_apis! {31	#[api_version(2)]32	/// Trait for generate rpc.33	pub trait UniqueApi<CrossAccountId, AccountId> where34		AccountId: Decode,35		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,36	{37		#[changed_in(2)]38		fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;3940		/// Get number of tokens in collection owned by account.41		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;4243		/// Number of existing tokens in collection.44		fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;4546		/// Check token exist.47		fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;4849		/// Get token owner.50		fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5152		/// Get real owner of nested token.53		fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;5455		/// Get nested tokens for the specified item.56		fn token_children(collection: CollectionId, token: TokenId) -> Result<Vec<TokenChild>>;5758		/// Get collection properties.59		fn collection_properties(collection: CollectionId, properties: Option<Vec<Vec<u8>>>) -> Result<Vec<Property>>;6061		/// Get token properties.62		fn token_properties(63			collection: CollectionId,64			token_id: TokenId,65			properties: Option<Vec<Vec<u8>>>66		) -> Result<Vec<Property>>;6768		/// Get permissions for token properties.69		fn property_permissions(70			collection: CollectionId,71			properties: Option<Vec<Vec<u8>>>72		) -> Result<Vec<PropertyKeyPermission>>;7374		/// Get token data.75		fn token_data(76			collection: CollectionId,77			token_id: TokenId,78			keys: Option<Vec<Vec<u8>>>79		) -> Result<TokenData<CrossAccountId>>;8081		/// Total number of tokens in collection.82		fn total_supply(collection: CollectionId) -> Result<u32>;8384		/// Get account balance for collection (sum of tokens pieces).85		fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;8687		/// Get account balance for specified token.88		fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;8990		/// Amount of token pieces allowed to spend from granded account.91		fn allowance(92			collection: CollectionId,93			sender: CrossAccountId,94			spender: CrossAccountId,95			token: TokenId,96		) -> Result<u128>;9798		/// Get list of collection admins.99		fn adminlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;100101		/// Get list of users that allowet to mint tikens in collection.102		fn allowlist(collection: CollectionId) -> Result<Vec<CrossAccountId>>;103104		/// Check that user is in allowed list (see [`allowlist`]).105		fn allowed(collection: CollectionId, user: CrossAccountId) -> Result<bool>;106107		/// Last minted token id.108		fn last_token_id(collection: CollectionId) -> Result<TokenId>;109110		/// Get collection by id.111		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;112113		/// Get collection stats.114		fn collection_stats() -> Result<CollectionStats>;115116		/// Get the number of blocks through which sponsorship will be available.117		fn next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<Option<u64>>;118119		/// Get effective colletion limits.120		fn effective_collection_limits(collection_id: CollectionId) -> Result<Option<CollectionLimits>>;121122		/// Get total pieces of token.123		fn total_pieces(collection_id: CollectionId, token_id: TokenId) -> Result<Option<u128>>;124125		fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;126	}127}