mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-10-23 12:06:25 +00:00
- 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>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/react-query authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiPromise } from '@pezkuwi/api';
|
|
import type { Option } from '@pezkuwi/types';
|
|
import type { PezpalletBrokerStatusRecord } from '@pezkuwi/types/lookup';
|
|
import type { BrokerStatus } from './types.js';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { createNamedHook, useCall } from '@pezkuwi/react-hooks';
|
|
|
|
function useBrokerStatusImpl (api: ApiPromise, ready: boolean): BrokerStatus | undefined {
|
|
const status = useCall<Option<PezpalletBrokerStatusRecord>>(ready && api?.query.broker?.status);
|
|
const [state, setState] = useState<BrokerStatus | undefined>();
|
|
|
|
useEffect((): void => {
|
|
if (!!status && status.isSome) {
|
|
const s = status.unwrap();
|
|
|
|
setState({
|
|
coreCount: s.coreCount?.toNumber(),
|
|
lastCommittedTimeslice: s.lastCommittedTimeslice?.toNumber(),
|
|
lastTimeslice: s.lastTimeslice?.toNumber(),
|
|
privatePoolSize: s.privatePoolSize?.toNumber(),
|
|
systemPoolSize: s.systemPoolSize?.toNumber()
|
|
});
|
|
}
|
|
}, [status]);
|
|
|
|
return state;
|
|
}
|
|
|
|
export const useBrokerStatus = createNamedHook('useBrokerStatus', useBrokerStatusImpl);
|