From e734ade40a0a307ffc9327e3a458d1cacb0110f5 Mon Sep 17 00:00:00 2001 From: Jaco Date: Tue, 21 Sep 2021 16:24:00 +0300 Subject: [PATCH] Fix map query iteration/non-iteration (#6165) --- packages/page-storage/src/Query.tsx | 4 +--- packages/page-storage/src/Selection/Modules.tsx | 13 ++++--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/page-storage/src/Query.tsx b/packages/page-storage/src/Query.tsx index abce6e7377..2d2b190624 100644 --- a/packages/page-storage/src/Query.tsx +++ b/packages/page-storage/src/Query.tsx @@ -104,9 +104,7 @@ function getCachedComponent (registry: Registry, query: QueryTypes): CacheInstan const { creator: { meta: { type } } } = key; const allCount = type.isPlain ? 0 - : type.isMap - ? 1 - : 2; + : type.asMap.hashers.length; renderHelper = withCallDiv('subscribe', { paramName: 'params', diff --git a/packages/page-storage/src/Selection/Modules.tsx b/packages/page-storage/src/Selection/Modules.tsx index 0a432de60a..ff7ab99abf 100644 --- a/packages/page-storage/src/Selection/Modules.tsx +++ b/packages/page-storage/src/Selection/Modules.tsx @@ -3,7 +3,7 @@ import type { QueryableStorageEntry } from '@polkadot/api/types'; import type { RawParams } from '@polkadot/react-params/types'; -import type { SiLookupTypeId, StorageEntryTypeLatest } from '@polkadot/types/interfaces'; +import type { StorageEntryTypeLatest } from '@polkadot/types/interfaces'; import type { Registry, TypeDef } from '@polkadot/types/types'; import type { ComponentProps as Props } from '../types'; @@ -14,6 +14,7 @@ import { Button, InputStorage } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import Params from '@polkadot/react-params'; import { getTypeDef } from '@polkadot/types'; +import { getSiName } from '@polkadot/types/metadata/util'; import { TypeDefInfo } from '@polkadot/types/types'; import { isNull, isUndefined } from '@polkadot/util'; @@ -46,12 +47,6 @@ function areParamsValid ({ creator: { meta: { type } } }: QueryableStorageEntry< (values.length === (type.isPlain ? 0 : type.asMap.hashers.length))); } -function expandSiKey (registry: Registry, key: SiLookupTypeId): string { - const typeDef = registry.lookup.getTypeDef(key); - - return typeDef.lookupName || typeDef.type; -} - function expandParams (registry: Registry, st: StorageEntryTypeLatest, isIterable: boolean): ParamsType { let types: string[] = []; @@ -59,8 +54,8 @@ function expandParams (registry: Registry, st: StorageEntryTypeLatest, isIterabl const { hashers, key } = st.asMap; types = hashers.length === 1 - ? [expandSiKey(registry, key)] - : registry.lookup.getSiType(key).def.asTuple.map((k) => expandSiKey(registry, k)); + ? [getSiName(registry.lookup, key)] + : registry.lookup.getSiType(key).def.asTuple.map((k) => getSiName(registry.lookup, k)); } return types.map((str, index) => {