Files
pwap/pezkuwi-sdk-ui/packages/page-staking/src/Payouts/useEraBlocks.ts
T
Claude c71ddb6e0d Add Pezkuwi SDK UI - Polkadot.js Apps clone
- 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
2025-11-14 00:55:17 +00:00

40 lines
1.2 KiB
TypeScript

// Copyright 2017-2025 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DeriveSessionProgress } from '@polkadot/api-derive/types';
import type { Forcing } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util';
import { useMemo } from 'react';
import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
import { BN_ONE } from '@polkadot/util';
function useEraBlocksImpl (historyDepth?: BN, era?: BN): BN | undefined {
const { api } = useApi();
const progress = useCall<DeriveSessionProgress>(api.derive.session.progress);
const forcing = useCall<Forcing>(api.query.staking.forceEra);
return useMemo(
() => (historyDepth && era && forcing && progress && progress.sessionLength.gt(BN_ONE))
? (
forcing.isForceAlways
? progress.sessionLength
: progress.eraLength
).mul(
historyDepth
.sub(progress.activeEra)
.iadd(era)
.iadd(BN_ONE)
).isub(
forcing.isForceAlways
? progress.sessionProgress
: progress.eraProgress
)
: undefined,
[era, forcing, historyDepth, progress]
);
}
export default createNamedHook('useEraBlocks', useEraBlocksImpl);