mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-11-29 00:49:55 +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,52 @@
|
||||
// Copyright 2017-2025 @pezkuwi/react-hooks authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Option } from '@pezkuwi/types';
|
||||
import type { RegistrarInfo } from '@pezkuwi/types/interfaces';
|
||||
import type { Registrar } from './types.js';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { createNamedHook } from './createNamedHook.js';
|
||||
import { useAccounts } from './useAccounts.js';
|
||||
import { useApi } from './useApi.js';
|
||||
import { useCall } from './useCall.js';
|
||||
|
||||
interface RegistrarNull {
|
||||
address: string | null;
|
||||
index: number;
|
||||
}
|
||||
|
||||
interface State {
|
||||
isRegistrar: boolean;
|
||||
registrars: Registrar[];
|
||||
skipQuery?: boolean;
|
||||
}
|
||||
|
||||
function useRegistrarsImpl (skipQuery?: boolean): State {
|
||||
const { apiIdentity } = useApi();
|
||||
const { allAccounts, hasAccounts } = useAccounts();
|
||||
const query = useCall<Option<RegistrarInfo>[]>(!skipQuery && apiIdentity.query.identity?.registrars);
|
||||
|
||||
// determine if we have a registrar or not - registrars are allowed to approve
|
||||
return useMemo(
|
||||
(): State => {
|
||||
const registrars = (query || [])
|
||||
.map((registrar, index): RegistrarNull => ({
|
||||
address: registrar.isSome
|
||||
? registrar.unwrap().account.toString()
|
||||
: null,
|
||||
index
|
||||
}))
|
||||
.filter((registrar): registrar is Registrar => !!registrar.address);
|
||||
|
||||
return {
|
||||
isRegistrar: hasAccounts && registrars.some(({ address }) => allAccounts.includes(address)),
|
||||
registrars
|
||||
};
|
||||
},
|
||||
[allAccounts, hasAccounts, query]
|
||||
);
|
||||
}
|
||||
|
||||
export const useRegistrars = createNamedHook('useRegistrars', useRegistrarsImpl);
|
||||
Reference in new issue
Block a user