From 7ef38f0c50075437cca1216b91eadfad0bb42ba7 Mon Sep 17 00:00:00 2001 From: Jaco Date: Fri, 25 Nov 2022 17:35:56 +0200 Subject: [PATCH] Render MultiAddress.Id via Address component (#8424) * Render MultiAddress.Id via Address component * Remove stray log --- packages/react-params/src/Param/Account.tsx | 12 +++++++++++- packages/react-params/src/Param/findComponent.ts | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/react-params/src/Param/Account.tsx b/packages/react-params/src/Param/Account.tsx index 6b4dbc2aa8..fdf084130b 100644 --- a/packages/react-params/src/Param/Account.tsx +++ b/packages/react-params/src/Param/Account.tsx @@ -1,6 +1,7 @@ // Copyright 2017-2022 @polkadot/react-params authors & contributors // SPDX-License-Identifier: Apache-2.0 +import type { MultiAddress } from '@polkadot/types/interfaces'; import type { Props } from '../types'; import React, { useCallback, useState } from 'react'; @@ -9,6 +10,7 @@ import { InputAddress } from '@polkadot/react-components'; import { keyring } from '@polkadot/ui-keyring'; import Bare from './Bare'; +import Enum from './Enum'; function isValidAddress (value?: string | null): boolean { if (value) { @@ -24,7 +26,8 @@ function isValidAddress (value?: string | null): boolean { return false; } -function Account ({ className = '', defaultValue: { value }, isDisabled, isError, isInOption, label, onChange, withLabel }: Props): React.ReactElement { +function Account (props: Props): React.ReactElement { + const { className = '', defaultValue: { value }, isDisabled, isError, isInOption, label, onChange, type, withLabel } = props; const [defaultValue] = useState(() => (value as string)?.toString()); const _onChange = useCallback( @@ -36,6 +39,13 @@ function Account ({ className = '', defaultValue: { value }, isDisabled, isError [onChange] ); + // special handling for MultiAddress + if (type.type === 'MultiAddress') { + if (!isDisabled || !value || (value as MultiAddress).type !== 'Id') { + return ; + } + } + return (