From 22df6366ae4d0b51795af44bb3e26139520d2113 Mon Sep 17 00:00:00 2001 From: Jaco Date: Mon, 18 Jul 2022 06:35:54 +0200 Subject: [PATCH] Filter section/method options (#7881) --- packages/react-components/src/InputCalls/options/method.tsx | 1 + packages/react-components/src/InputCalls/options/section.ts | 1 + packages/react-components/src/InputConsts/options/key.tsx | 1 + packages/react-components/src/InputConsts/options/section.ts | 1 + packages/react-components/src/InputExtrinsic/options/method.tsx | 1 + packages/react-components/src/InputExtrinsic/options/section.ts | 1 + packages/react-components/src/InputRpc/options/method.tsx | 1 + packages/react-components/src/InputRpc/options/section.ts | 1 + packages/react-components/src/InputStorage/options/key.tsx | 1 + packages/react-components/src/InputStorage/options/section.ts | 1 + 10 files changed, 10 insertions(+) diff --git a/packages/react-components/src/InputCalls/options/method.tsx b/packages/react-components/src/InputCalls/options/method.tsx index f6d2d04251..a653551949 100644 --- a/packages/react-components/src/InputCalls/options/method.tsx +++ b/packages/react-components/src/InputCalls/options/method.tsx @@ -19,6 +19,7 @@ export default function createOptions (runtime: Record !s.startsWith('$')) .sort() .map((m) => section[m]) .map(({ description, method, params }): DropdownOption => { diff --git a/packages/react-components/src/InputCalls/options/section.ts b/packages/react-components/src/InputCalls/options/section.ts index c434096cb0..4116c8e032 100644 --- a/packages/react-components/src/InputCalls/options/section.ts +++ b/packages/react-components/src/InputCalls/options/section.ts @@ -7,6 +7,7 @@ import type { DropdownOptions } from '../../util/types'; export default function createOptions (runtime: Record>): DropdownOptions { return Object .keys(runtime) + .filter((s) => !s.startsWith('$')) .sort() .filter((s) => Object.keys(runtime[s]).length !== 0) .map((value): { text: string; value: string } => ({ diff --git a/packages/react-components/src/InputConsts/options/key.tsx b/packages/react-components/src/InputConsts/options/key.tsx index 36e33e6d28..07426e9a37 100644 --- a/packages/react-components/src/InputConsts/options/key.tsx +++ b/packages/react-components/src/InputConsts/options/key.tsx @@ -18,6 +18,7 @@ export default function createOptions (api: ApiPromise, sectionName: string): Dr return Object .keys(section) + .filter((s) => !s.startsWith('$')) .sort() .map((value): DropdownOption => { const method = (section[value] as ConstantCodec); diff --git a/packages/react-components/src/InputConsts/options/section.ts b/packages/react-components/src/InputConsts/options/section.ts index 66ab17d18b..5bd25b3ab3 100644 --- a/packages/react-components/src/InputConsts/options/section.ts +++ b/packages/react-components/src/InputConsts/options/section.ts @@ -8,6 +8,7 @@ import { ApiPromise } from '@polkadot/api'; export default function createOptions (api: ApiPromise): DropdownOptions { return Object .keys(api.consts) + .filter((s) => !s.startsWith('$')) .sort() .filter((name): number => Object.keys(api.consts[name]).length) .map((name): { text: string; value: string } => ({ diff --git a/packages/react-components/src/InputExtrinsic/options/method.tsx b/packages/react-components/src/InputExtrinsic/options/method.tsx index 2e364fcf6f..eebd39bba0 100644 --- a/packages/react-components/src/InputExtrinsic/options/method.tsx +++ b/packages/react-components/src/InputExtrinsic/options/method.tsx @@ -16,6 +16,7 @@ export default function createOptions (api: ApiPromise, sectionName: string): Dr return Object .keys(section) + .filter((s) => !s.startsWith('$')) .sort() .map((value): DropdownOption => { const method = section[value]; diff --git a/packages/react-components/src/InputExtrinsic/options/section.ts b/packages/react-components/src/InputExtrinsic/options/section.ts index 51d97eff23..3d0b75ae41 100644 --- a/packages/react-components/src/InputExtrinsic/options/section.ts +++ b/packages/react-components/src/InputExtrinsic/options/section.ts @@ -8,6 +8,7 @@ import { ApiPromise } from '@polkadot/api'; export default function createOptions (api: ApiPromise): DropdownOptions { return Object .keys(api.tx) + .filter((s) => !s.startsWith('$')) .sort() .filter((name): number => Object.keys(api.tx[name]).length) .map((name): { text: string; value: string } => ({ diff --git a/packages/react-components/src/InputRpc/options/method.tsx b/packages/react-components/src/InputRpc/options/method.tsx index 45fbc39fd0..aba06e7159 100644 --- a/packages/react-components/src/InputRpc/options/method.tsx +++ b/packages/react-components/src/InputRpc/options/method.tsx @@ -17,6 +17,7 @@ export default function createOptions (api: ApiPromise, rpcs: Record>)[sectionName]) + .filter((s) => !s.startsWith('$')) .sort() .map((methodName) => section[methodName]) .filter((ext): ext is DefinitionRpcExt => !!ext) diff --git a/packages/react-components/src/InputRpc/options/section.ts b/packages/react-components/src/InputRpc/options/section.ts index b2b01d18a2..8cdebfde9d 100644 --- a/packages/react-components/src/InputRpc/options/section.ts +++ b/packages/react-components/src/InputRpc/options/section.ts @@ -8,6 +8,7 @@ import { ApiPromise } from '@polkadot/api'; export default function createOptions (api: ApiPromise): DropdownOptions { return Object .keys(api.rpc) + .filter((s) => !s.startsWith('$')) .sort() .filter((section) => Object.keys((api.rpc as Record>)[section]).length !== 0) .map((name): { text: string; value: string } => ({ diff --git a/packages/react-components/src/InputStorage/options/key.tsx b/packages/react-components/src/InputStorage/options/key.tsx index 36a548ba6c..77150ec5a0 100644 --- a/packages/react-components/src/InputStorage/options/key.tsx +++ b/packages/react-components/src/InputStorage/options/key.tsx @@ -19,6 +19,7 @@ export function keyOptions (api: ApiPromise, sectionName: string): DropdownOptio return Object .keys(section) + .filter((s) => !s.startsWith('$')) .sort() .map((value): DropdownOption => { const { meta: { docs, modifier, name, type } } = section[value] as unknown as StorageEntry; diff --git a/packages/react-components/src/InputStorage/options/section.ts b/packages/react-components/src/InputStorage/options/section.ts index 30dc791a4e..a60d3c3add 100644 --- a/packages/react-components/src/InputStorage/options/section.ts +++ b/packages/react-components/src/InputStorage/options/section.ts @@ -8,6 +8,7 @@ import { ApiPromise } from '@polkadot/api'; export function sectionOptions (api: ApiPromise): DropdownOptions { return Object .keys(api.query) + .filter((s) => !s.startsWith('$')) .sort() .filter((n) => Object.keys(api.query[n]).length) .map((value): DropdownOption => ({