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
447}447}
448448
449/// Collection parameters, used in RPC calls (see [`Collection`] for the storage version).449/// Collection parameters, used in RPC calls (see [`Collection`] for the storage version).
450#[struct_versioning::versioned(version = 2, upper)]
450#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]451#[derive(Encode, Decode, Clone, PartialEq, TypeInfo)]
451#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]452#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
452pub struct RpcCollection<AccountId> {453pub struct RpcCollection<AccountId> {
484 pub read_only: bool,485 pub read_only: bool,
485486
486 /// Extra collection flags487 /// Extra collection flags
488 #[version(2.., upper(RpcCollectionFlags {foreign: false, erc721metadata: false}))]
487 pub flags: RpcCollectionFlags,489 pub flags: RpcCollectionFlags,
488}490}
489491
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -16,9 +16,11 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
+extern crate alloc;
+
 use up_data_structs::{
 	CollectionId, TokenId, RpcCollection, CollectionStats, CollectionLimits, Property,
-	PropertyKeyPermission, TokenData, TokenChild,
+	PropertyKeyPermission, TokenData, TokenChild, RpcCollectionVersion1,
 };
 
 use sp_std::vec::Vec;
@@ -28,15 +30,12 @@
 type Result<T> = core::result::Result<T, DispatchError>;
 
 sp_api::decl_runtime_apis! {
-	#[api_version(2)]
+	#[api_version(3)]
 	/// Trait for generate rpc.
 	pub trait UniqueApi<CrossAccountId, AccountId> where
 		AccountId: Decode,
 		CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,
 	{
-		#[changed_in(2)]
-		fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;
-
 		/// Get number of tokens in collection owned by account.
 		fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;
 
@@ -110,6 +109,9 @@
 		/// Get collection by id.
 		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollection<AccountId>>>;
 
+		#[changed_in(3)]
+		fn collection_by_id(collection: CollectionId) -> Result<Option<RpcCollectionVersion1<AccountId>>>;
+
 		/// Get collection stats.
 		fn collection_stats() -> Result<CollectionStats>;