ghost-portal/packages/react-components/src/InputStorage/options/section.ts
2021-01-03 11:33:39 +01:00

18 lines
509 B
TypeScript

// Copyright 2017-2021 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DropdownOptions } from '../../util/types';
import { ApiPromise } from '@polkadot/api';
export default function createOptions (api: ApiPromise): DropdownOptions {
return Object
.keys(api.query)
.sort()
.filter((name): number => Object.keys(api.query[name]).length)
.map((name): { text: string; value: string } => ({
text: name,
value: name
}));
}