mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-29 16:35:44 +00:00
c71ddb6e0d
- Clone Polkadot.js Apps repository - Update package.json with Pezkuwi branding - Add Pezkuwi endpoint to production chains (wss://pezkuwichain.app:9944) - Create comprehensive README for SDK UI - Set up project structure with all packages Next steps: - Apply Kurdistan colors (Kesk, Sor, Zer, Spi + Black) to UI theme - Replace logos with Pezkuwi branding - Test build and deployment
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
// Copyright 2017-2025 @polkadot/app-staking authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { StorageKey, u32 } from '@polkadot/types';
|
|
import type { AccountId32 } from '@polkadot/types/interfaces';
|
|
import type { SessionInfo } from './types.js';
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
import { createNamedHook, useApi, useMapKeys } from '@polkadot/react-hooks';
|
|
|
|
import { useCacheValue } from './useCache.js';
|
|
|
|
const OPT_ELECTED = {
|
|
transform: (keys: StorageKey<[u32, AccountId32]>[]): string[] =>
|
|
keys.map(({ args: [, stashId] }) =>
|
|
stashId.toString()
|
|
)
|
|
};
|
|
|
|
function useElectedValidatorsImpl ({ currentEra }: SessionInfo): string[] | undefined {
|
|
const { api } = useApi();
|
|
|
|
const electedParams = useMemo(
|
|
() => currentEra && [currentEra],
|
|
[currentEra]
|
|
);
|
|
|
|
const elected = useMapKeys(electedParams && api.query.staking.erasStakers, electedParams, OPT_ELECTED);
|
|
|
|
return useCacheValue('useElectedValidators', elected);
|
|
}
|
|
|
|
export default createNamedHook('useElectedValidators', useElectedValidatorsImpl);
|