diff --git a/packages/page-accounts/src/Sidebar/RegistrarJudgement.tsx b/packages/page-accounts/src/Sidebar/RegistrarJudgement.tsx index e33d672199..10699e5ba9 100644 --- a/packages/page-accounts/src/Sidebar/RegistrarJudgement.tsx +++ b/packages/page-accounts/src/Sidebar/RegistrarJudgement.tsx @@ -1,10 +1,14 @@ // Copyright 2017-2022 @polkadot/react-query authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { Option } from '@polkadot/types'; +import type { PalletIdentityRegistration } from '@polkadot/types/lookup'; +import type { HexString } from '@polkadot/util/types'; + import React, { useEffect, useState } from 'react'; -import { Dropdown, Input, InputAddress, Modal, TxButton } from '@polkadot/react-components'; -import { useApi } from '@polkadot/react-hooks'; +import { Dropdown, Input, InputAddress, MarkError, Modal, Spinner, TxButton } from '@polkadot/react-components'; +import { useApi, useCall } from '@polkadot/react-hooks'; import { useTranslation } from '../translate'; @@ -23,9 +27,17 @@ const JUDGEMENT_ENUM = [ { text: 'Low quality', value: 5 } ]; +const OPT_ID = { + transform: (optId: Option): HexString | null => + optId.isSome + ? optId.unwrap().info.hash.toHex() + : null +}; + function RegistrarJudgement ({ address, registrars, toggleJudgement }: Props): React.ReactElement { const { t } = useTranslation(); const { api } = useApi(); + const identityHash = useCall(api.query.identity.identityOf, [address], OPT_ID); const [addresses] = useState(() => registrars.map(({ address }) => address)); const [judgementAccountId, setJudgementAccountId] = useState(null); const [judgementEnum, setJudgementEnum] = useState(2); // Reasonable @@ -66,15 +78,31 @@ function RegistrarJudgement ({ address, registrars, toggleJudgement }: Props): R options={JUDGEMENT_ENUM} value={judgementEnum} /> + {identityHash + ? ( + ('identity hash')} + /> + ) + : identityHash === null + ? ('No identity associated with account')} /> + : + } ('Judge')} onStart={toggleJudgement} - params={[registrarIndex, address, judgementEnum]} + params={ + api.tx.identity.provideJudgement.meta.args.length === 4 + ? [registrarIndex, address, judgementEnum, identityHash] + : [registrarIndex, address, judgementEnum] + } tx={api.tx.identity.provideJudgement} />