mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-10-22 11:36:20 +00:00
- dev ^0.86.4 at the root and in packages/apps; directives renamed by pezkuwi-dev-migrate-eslint10. - eslint --fix with the 0.86.4 config; one fix broke syntax (typescript-eslint prefer-optional-chain turned `(isStarted && onStart) && onStart()` into `(isStarted && onStart?.();` in TxButton) and is corrected by hand. - The remaining findings fixed rather than disabled: optional chains (each suggestion reviewed), `cause` on rethrown errors, `if` instead of `a && promise` in effects, parallel instead of sequential awaits in Promise.all, Error rejections, no `delete` on arrays (the storage query cache is a Map; an upload's file list no longer keeps a hole), no `[object Object]` stringification (TFunction's second argument is text or options), dead code removed (referenda's never-shown expand button, react-query's unused CoreDescriptor).
25 lines
785 B
TypeScript
25 lines
785 B
TypeScript
// Copyright 2017-2026 @pezkuwi/app-staking authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { DeriveSessionInfo } from '@pezkuwi/api-derive/types';
|
|
import type { BN } from '@pezkuwi/util';
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
import { createNamedHook, useApi, useCall } from '@pezkuwi/react-hooks';
|
|
import { BN_ONE } from '@pezkuwi/util';
|
|
|
|
function useUnbondDurationImpl (): BN | undefined {
|
|
const { api } = useApi();
|
|
const sessionInfo = useCall<DeriveSessionInfo>(api.derive.session.info);
|
|
|
|
return useMemo(
|
|
() => (sessionInfo?.sessionLength.gt(BN_ONE))
|
|
? sessionInfo.eraLength.mul(api.consts.staking.bondingDuration)
|
|
: undefined,
|
|
[api, sessionInfo]
|
|
);
|
|
}
|
|
|
|
export default createNamedHook('useUnbondDuration', useUnbondDurationImpl);
|