UNPKG

591 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/api authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { lazyDeriveSection } from '@polkadot/api-derive';
4
5/**
6 * This is a section decorator which keeps all type information.
7 */
8export function decorateDeriveSections(decorateMethod, derives) {
9 const getKeys = s => Object.keys(derives[s]);
10
11 const creator = (s, m) => decorateMethod(derives[s][m]);
12
13 const result = {};
14 const names = Object.keys(derives);
15
16 for (let i = 0; i < names.length; i++) {
17 lazyDeriveSection(result, names[i], getKeys, creator);
18 }
19
20 return result;
21}
\No newline at end of file