mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-10-26 12:49:49 +00:00
feat: initial Pezkuwi Apps rebrand from polkadot-apps
Rebranded terminology: - Polkadot → Pezkuwi - Kusama → Dicle - Westend → Zagros - Rococo → PezkuwiChain - Substrate → Bizinikiwi - parachain → teyrchain Custom logos with Kurdistan brand colors (#e6007a → #86e62a): - bizinikiwi-hexagon.svg - sora-bizinikiwi.svg - hezscanner.svg - heztreasury.svg - pezkuwiscan.svg - pezkuwistats.svg - pezkuwiassembly.svg - pezkuwiholic.svg
This commit is contained in:
commit
d21bfb1320
5867 files changed
+329019
No files matched your search
@@ -0,0 +1,64 @@
|
||||
// Copyright 2017-2025 @pezkuwi/react-hooks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { DeriveBalancesAll } from '@pezkuwi/api-derive/types';
|
||||
import type { BN } from '@pezkuwi/util';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { createNamedHook } from './createNamedHook.js';
|
||||
import { useApi } from './useApi.js';
|
||||
import { useCall } from './useCall.js';
|
||||
import { useStakingAsyncApis } from './useStakingAsyncApis.js';
|
||||
|
||||
export interface VestingInfo {
|
||||
isVesting: boolean;
|
||||
vestedBalance: BN;
|
||||
vestedClaimable: BN;
|
||||
vesting: {
|
||||
startingBlock: BN;
|
||||
endBlock: BN;
|
||||
perBlock: BN;
|
||||
locked: BN;
|
||||
vested: BN;
|
||||
}[];
|
||||
vestingTotal: BN;
|
||||
vestingLocked: BN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the account vesting information from the correct chain.
|
||||
* After Asset Hub migration, vesting data lives on Asset Hub (paraId 1000),
|
||||
* not on the relay chain. This hook automatically queries the correct chain.
|
||||
*
|
||||
* @param accountAddress The account address of which vesting info is to be returned
|
||||
* @returns vesting information for the account
|
||||
*/
|
||||
function useVestingImpl (accountAddress: string): VestingInfo | undefined {
|
||||
const { api } = useApi();
|
||||
const { ahApi, isRelayChain } = useStakingAsyncApis();
|
||||
|
||||
// Determine which API to use for vesting queries
|
||||
// If on relay chain, vesting data is on Asset Hub
|
||||
// Otherwise, vesting data is on the current chain
|
||||
const vestingApi = isRelayChain && ahApi ? ahApi : api;
|
||||
|
||||
const balancesAll = useCall<DeriveBalancesAll>(vestingApi.derive.balances?.all, [accountAddress]);
|
||||
|
||||
return useMemo((): VestingInfo | undefined => {
|
||||
if (!balancesAll) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
isVesting: balancesAll.isVesting,
|
||||
vestedBalance: balancesAll.vestedBalance,
|
||||
vestedClaimable: balancesAll.vestedClaimable,
|
||||
vesting: balancesAll.vesting,
|
||||
vestingLocked: balancesAll.vestingLocked,
|
||||
vestingTotal: balancesAll.vestingTotal
|
||||
};
|
||||
}, [balancesAll]);
|
||||
}
|
||||
|
||||
export const useVesting = createNamedHook('useVesting', useVestingImpl);
|
||||
Reference in new issue
Block a user