ghost-portal/packages/ui-app/src/InputStorage/options/section.ts
2018-06-26 12:10:41 +02:00

37 lines
962 B
TypeScript

// Copyright 2017-2018 @polkadot/ui-app authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Storage$Sections } from '@polkadot/storage/types';
import { DropdownOptions } from '../../InputExtrinsic/types';
import map from '@polkadot/storage';
export default function createOptions (): DropdownOptions {
return Object
.keys(map)
.sort()
.filter((name) => {
const section = map[name as Storage$Sections];
// cannot really get here
if (!section) {
return false;
}
const methods = Object
.keys(section.public)
.filter((name) => {
const { isDeprecated, isHidden } = section.public[name];
return !isDeprecated && !isHidden;
});
return !section.isDeprecated && methods.length !== 0;
})
.map((name) => ({
text: name,
value: name
}));
}