Files
pezkuwi-apps/packages/page-gilt/src/useProxies.ts
T
pezkuwichain d21bfb1320 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
2026-01-07 13:05:27 +03:00

43 lines
1.4 KiB
TypeScript

// Copyright 2017-2025 @pezkuwi/app-gilt authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Vec } from '@pezkuwi/types';
import type { BalanceOf, ProxyDefinition } from '@pezkuwi/types/interfaces';
import type { ITuple } from '@pezkuwi/types/types';
import { useEffect, useState } from 'react';
import { createNamedHook, useAccounts, useApi, useIsMountedRef } from '@pezkuwi/react-hooks';
type ProxyResult = ITuple<[Vec<ProxyDefinition>, BalanceOf]>;
function useProxiesImpl (): Record<string, string[]> {
const { api } = useApi();
const { allAccounts } = useAccounts();
const mountedRef = useIsMountedRef();
const [state, setState] = useState<Record<string, string[]>>({});
useEffect((): void => {
if (allAccounts.length) {
api.query.proxy.proxies
.multi<ProxyResult>(allAccounts)
.then((result) =>
mountedRef.current && setState(
result
.map(([p], index): [string, string[]] => [
allAccounts[index],
p.map(({ delegate }) => delegate.toString())
])
.filter(([, p]) => p.length)
.reduce((all, [a, p]) => ({ ...all, [a]: p }), {})
)
)
.catch(console.error);
}
}, [allAccounts, api, mountedRef]);
return state;
}
export const useProxies = createNamedHook('useProxies', useProxiesImpl);