From 1bdec8235cab5b036e37a4408a7a89f37f58236a Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Thu, 07 Apr 2022 10:15:28 +0000 Subject: [PATCH] fix: export RpcCollection to metadata --- --- 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 = - StorageValue; + pub type DummyStorageValue = + StorageValue>), QueryKind = OptionQuery>; #[pallet::hooks] impl Hooks> for Pallet { --- 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(core::marker::PhantomData); + +impl TypeInfo for PhantomType { + type Identity = PhantomType; + + fn type_info() -> scale_info::Type { + use scale_info::{Type, Path, build::{FieldsBuilder, UnnamedFields}}; + Type::builder() + .path(Path::new("up_data_structs", "PhantomType")) + .composite(>::default().field(|b| + b.ty::<[T ;0]>() + )) + } +} +impl MaxEncodedLen for PhantomType { + fn max_encoded_len() -> usize { + 0 + } +} \ No newline at end of file --- 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::{ --- a/tests/src/interfaces/unique/definitions.ts +++ b/tests/src/interfaces/unique/definitions.ts @@ -52,7 +52,7 @@ constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec'), variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec'), tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'), - collectionById: fun('Get collection by specified id', [collectionParam], 'Option'), + collectionById: fun('Get collection by specified id', [collectionParam], 'Option'), collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'), allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'), nextSponsored: fun('Get number of blocks when sponsored transaction is available', [collectionParam, crossAccountParam(), tokenParam], 'Option'), -- gitstuff