mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-20 14:01:09 +00:00
60a800b33e
- 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-parachains authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { BlockNumber } from '@polkadot/types/interfaces';
|
|
import type { LeasePeriod } from './types.js';
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
import { createNamedHook, useApi, useBestNumber } from '@polkadot/react-hooks';
|
|
import { BN_ZERO } from '@polkadot/util';
|
|
|
|
function useLeasePeriodImpl (): LeasePeriod | undefined {
|
|
const { api } = useApi();
|
|
const bestNumber = useBestNumber();
|
|
|
|
return useMemo((): LeasePeriod | undefined => {
|
|
if (!api.consts.slots.leasePeriod || !bestNumber) {
|
|
return;
|
|
}
|
|
|
|
const length = api.consts.slots.leasePeriod as BlockNumber;
|
|
const startNumber = bestNumber.sub((api.consts.slots.leaseOffset as BlockNumber) || BN_ZERO);
|
|
const progress = startNumber.mod(length);
|
|
|
|
return {
|
|
currentPeriod: startNumber.div(length),
|
|
length,
|
|
progress,
|
|
remainder: length.sub(progress)
|
|
};
|
|
}, [api, bestNumber]);
|
|
}
|
|
|
|
export default createNamedHook('useLeasePeriod', useLeasePeriodImpl);
|