* feat(types): add correct tuple type to storage key * refactor(types): remove unneeded type assertions
22 lines
715 B
TypeScript
22 lines
715 B
TypeScript
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
|
import type { AccountId } from '@polkadot/types/interfaces';
|
|
import type { Observable } from '@polkadot/x-rxjs';
|
|
|
|
import { map } from '@polkadot/x-rxjs/operators';
|
|
|
|
import { memo } from '../util';
|
|
|
|
/**
|
|
* @description Retrieve the list of all validator stashes
|
|
*/
|
|
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
|
|
return memo(instanceId, (): Observable<AccountId[]> =>
|
|
api.query.staking.validators.keys().pipe(
|
|
map((keys) => keys.map((key) => key.args[0]).filter((a) => a))
|
|
)
|
|
);
|
|
}
|