// Copyright 2017-2026 @pezkuwi/react-query authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Bytes, Option } from '@pezkuwi/types'; import type { PezpalletIdentityRegistration } from '@pezkuwi/types/lookup'; import type { ITuple } from '@pezkuwi/types/types'; import type { HexString } from '@pezkuwi/util/types'; import React, { useEffect, useState } from 'react'; import { useApi, useCall } from '@pezkuwi/react-hooks'; import Dropdown from '../Dropdown.js'; import Input from '../Input.js'; import InputAddress from '../InputAddress/index.js'; import MarkError from '../MarkError.js'; import Modal from '../Modal/index.js'; import Spinner from '../Spinner.js'; import { useTranslation } from '../translate.js'; import TxButton from '../TxButton.js'; interface Props { address: string; registrars: { address: string; index: number }[]; toggleJudgement: () => void; } const JUDGEMENT_ENUM = [ { text: 'Unknown', value: 0 }, { text: 'Fee paid', value: 1 }, { text: 'Reasonable', value: 2 }, { text: 'Known good', value: 3 }, { text: 'Out of date', value: 4 }, { text: 'Low quality', value: 5 } ]; const OPT_ID = { transform: (optId: Option]>>): HexString | null => { const id = optId.isSome ? optId.unwrap() : null; // Backwards compatibility - https://github.com/pezkuwichain/pezkuwi-apps/issues/10493 return !id ? null : Array.isArray(id) ? id[0].info.hash.toHex() : (id as unknown as PezpalletIdentityRegistration).info.hash.toHex(); } }; function RegistrarJudgement ({ address, registrars, toggleJudgement }: Props): React.ReactElement { const { t } = useTranslation(); const { apiIdentity, enableIdentity } = useApi(); const identityHash = useCall(apiIdentity.query.identity.identityOf, [address], OPT_ID); const [addresses] = useState(() => registrars.map(({ address }) => address)); const [judgementAccountId, setJudgementAccountId] = useState(null); const [judgementEnum, setJudgementEnum] = useState(2); // Reasonable const [registrarIndex, setRegistrarIndex] = useState(-1); // find the id of our registrar in the list useEffect((): void => { const registrar = registrars.find(({ address }) => judgementAccountId === address); setRegistrarIndex( registrar ? registrar.index : -1 ); }, [judgementAccountId, registrars]); return ( {identityHash ? ( ) : identityHash === null ? : } ); } export default React.memo(RegistrarJudgement);