mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-08-08 13:35:41 +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
40 lines
1.2 KiB
TypeScript
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);
|