Files
api/packages/api-derive/src/collective/prime.ts
T
Jaco 84621a26cb Adjust derive definitions for no reexport of types (#5536)
* Adjust derive definitions for no reexport of types

* Additional for hasProposals
2023-03-11 17:49:27 +02:00

26 lines
707 B
TypeScript

// Copyright 2017-2023 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { AccountId } from '@polkadot/types/interfaces';
import type { Collective, PrimeFnRet } from './types.js';
import { map, of } from 'rxjs';
import { isFunction } from '@polkadot/util';
import { withSection } from './helpers.js';
export function prime (section: Collective): PrimeFnRet {
return withSection(section, (query) =>
(): Observable<AccountId | null> =>
isFunction(query?.prime)
? query.prime().pipe(
map((o): AccountId | null =>
o.unwrapOr(null)
)
)
: of(null)
);
}