git.delta.rocks / unique-network / refs/commits / 1bdec8235cab

difftreelog

fix export RpcCollection to metadata

Yaroslav Bolyukin2022-04-07parent: #6be1bb5.patch.diff
in: master

4 files changed

modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -33,7 +33,7 @@
 	COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, TokenId, CollectionStats, MAX_TOKEN_OWNERSHIP,
 	CollectionMode, NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
 	REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,
-	CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField,
+	CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData, SponsoringRateLimit, budget::Budget, COLLECTION_FIELD_LIMIT, CollectionField, PhantomType,
 };
 pub use pallet::*;
 use sp_core::H160;
@@ -415,8 +415,8 @@
 
 	/// Not used by code, exists only to provide some types to metadata
 	#[pallet::storage]
-	pub type DummyStorageValue<T> =
-		StorageValue<Value = (CollectionStats, CollectionId, TokenId), QueryKind = OptionQuery>;
+	pub type DummyStorageValue<T: Config> =
+		StorageValue<Value = (CollectionStats, CollectionId, TokenId, PhantomType<RpcCollection<T::AccountId>>), QueryKind = OptionQuery>;
 
 	#[pallet::hooks]
 	impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -583,3 +583,24 @@
 	pub destroyed: u32,
 	pub alive: u32,
 }
+
+#[derive(Encode, Decode, PartialEq, Clone, Debug)]
+pub struct PhantomType<T>(core::marker::PhantomData<T>);
+
+impl<T: TypeInfo + 'static> TypeInfo for PhantomType<T> {
+	type Identity = PhantomType<T>;
+
+	fn type_info() -> scale_info::Type {
+		use scale_info::{Type, Path, build::{FieldsBuilder, UnnamedFields}};
+		Type::builder()
+			.path(Path::new("up_data_structs", "PhantomType"))
+			.composite(<FieldsBuilder<UnnamedFields>>::default().field(|b|
+				b.ty::<[T ;0]>()
+			))
+	}
+}
+impl<T> MaxEncodedLen for PhantomType<T> {
+	fn max_encoded_len() -> usize {
+		0
+	}
+}
\ No newline at end of file
modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -67,7 +67,7 @@
 	},
 };
 use up_data_structs::mapping::{EvmTokenAddressMapping, CrossTokenAddressMapping};
-use up_data_structs::{CollectionId, TokenId, CollectionStats, Collection, RpcCollection};
+use up_data_structs::{CollectionId, TokenId, CollectionStats, RpcCollection};
 // use pallet_contracts::weights::WeightInfo;
 // #[cfg(any(feature = "std", test))]
 use frame_system::{
modifiedtests/src/interfaces/unique/definitions.tsdiffbeforeafterboth
before · tests/src/interfaces/unique/definitions.ts
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/>.1617import types from '../lookup';1819type RpcParam = {20  name: string;21  type: string;22  isOptional?: true;23};2425const CROSS_ACCOUNT_ID_TYPE = 'PalletEvmAccountBasicCrossAccountIdRepr';2627const collectionParam = {name: 'collection', type: 'u32'};28const tokenParam = {name: 'tokenId', type: 'u32'};29const crossAccountParam = (name = 'account') => ({name, type: CROSS_ACCOUNT_ID_TYPE});30const atParam = {name: 'at', type: 'Hash', isOptional: true};3132const fun = (description: string, params: RpcParam[], type: string) => ({33  description,34  params: [...params, atParam],35  type,36});3738export default {39  types,40  rpc: {41    adminlist: fun('Get admin list', [collectionParam], 'Vec<PalletEvmAccountBasicCrossAccountIdRepr>'),42    allowlist: fun('Get allowlist', [collectionParam], 'Vec<PalletEvmAccountBasicCrossAccountIdRepr>'),4344    accountTokens: fun('Get tokens owned by account', [collectionParam, crossAccountParam()], 'Vec<u32>'),45    collectionTokens: fun('Get tokens contained in collection', [collectionParam], 'Vec<u32>'),4647    lastTokenId: fun('Get last token id', [collectionParam], 'u32'),48    accountBalance: fun('Get amount of different user tokens', [collectionParam, crossAccountParam()], 'u32'),49    balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),50    allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),51    tokenOwner: fun('Get token owner', [collectionParam, tokenParam], CROSS_ACCOUNT_ID_TYPE),52    constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),53    variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),54    tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'),55    collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsCollection>'),56    collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),57    allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),58    nextSponsored: fun('Get number of blocks when sponsored transaction is available', [collectionParam, crossAccountParam(), tokenParam], 'Option<u64>'),59    effectiveCollectionLimits: fun('Get effective collection limits', [collectionParam], 'Option<UpDataStructsCollectionLimits>'),60  },61};