mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-14 04:01:11 +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:
@@ -0,0 +1,42 @@
|
||||
// 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);
|
||||
Reference in New Issue
Block a user