Files
pezkuwi-apps/packages/page-teyrchains/src/useActionsQueue.ts
T
pezkuwichain 7a4bbeac25 fix: update extension packages and fix type compatibility for pezkuwi-sdk
- Update @pezkuwi/extension-inject to ^0.62.13 with proper /types exports
- Update @pezkuwi/extension-dapp to ^0.62.13
- Update @pezkuwi/extension-compat-metamask to ^0.62.13
- Fix IconTheme type to include 'bizinikiwi' and 'pezkuwi' themes
- Fix endpoint array issues (getTeleports -> direct array references)
- Add type assertions for external package compatibility (acala, moonbeam, parallel)
- Fix subspace.ts dynamic class typing
- Fix conviction type in page-referenda
- Update Pallet type names to Pezpallet prefix across codebase
- Define InjectedExtension types locally for module resolution
- Add styled-components DefaultTheme augmentation
- Add react-copy-to-clipboard type declaration for React 18

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 16:24:19 +03:00

40 lines
1.4 KiB
TypeScript

// Copyright 2017-2026 @pezkuwi/app-teyrchains authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ParaId, SessionIndex } from '@pezkuwi/types/interfaces';
import type { BN } from '@pezkuwi/util';
import type { QueuedAction } from './types.js';
import { useMemo } from 'react';
import { createNamedHook, useApi, useCall } from '@pezkuwi/react-hooks';
import { BN_EIGHT, BN_FIVE, BN_FOUR, BN_NINE, BN_ONE, BN_SEVEN, BN_SIX, BN_TEN, BN_THREE, BN_TWO } from '@pezkuwi/util';
const INC = [BN_ONE, BN_TWO, BN_THREE, BN_FOUR, BN_FIVE, BN_SIX, BN_SEVEN, BN_EIGHT, BN_NINE, BN_TEN];
const OPT_NEXT = {
withParams: true
};
function useActionsQueueImpl (): QueuedAction[] {
const { api } = useApi();
const currentIndex = useCall<SessionIndex>(api.query.session.currentIndex);
const queryIndexes = useMemo(() => currentIndex && INC.map((i) => currentIndex.add(i)), [currentIndex]);
const nextActions = useCall<[[BN[]], ParaId[][]]>(queryIndexes && api.query.paras.actionsQueue.multi, [queryIndexes], OPT_NEXT);
return useMemo(
(): QueuedAction[] =>
nextActions
? nextActions[0][0]
.map((sessionIndex, index) => ({
paraIds: nextActions[1][index],
sessionIndex
}))
.filter(({ paraIds }) => paraIds.length)
: [],
[nextActions]
);
}
export default createNamedHook('useActionsQueue', useActionsQueueImpl);