diff --git a/packages/react-components/src/InputAddress/createItem.tsx b/packages/react-components/src/InputAddress/createItem.tsx index 685b48ac68..b724b75a20 100644 --- a/packages/react-components/src/InputAddress/createItem.tsx +++ b/packages/react-components/src/InputAddress/createItem.tsx @@ -12,24 +12,26 @@ import { decodeAddress } from '@polkadot/util-crypto'; import KeyPair from './KeyPair'; export default function createItem (option: KeyringSectionOption, isUppercase = true): Option | null { - try { - const u8a = decodeAddress(option.key); + const allowedLength = keyring.keyring.type === 'ethereum' + ? 20 + : 32; - if (u8a.length !== (keyring.keyring.type === 'ethereum' ? 20 : 32)) { - return null; + try { + if (decodeAddress(option.key).length >= allowedLength) { + return { + ...option, + text: ( + + ) + }; } } catch { - return null; + // ignore } - return { - ...option, - text: ( - - ) - }; + return null; } diff --git a/packages/react-hooks/src/ctx/Keyring.tsx b/packages/react-hooks/src/ctx/Keyring.tsx index ae13179625..34bb3e6911 100644 --- a/packages/react-hooks/src/ctx/Keyring.tsx +++ b/packages/react-hooks/src/ctx/Keyring.tsx @@ -48,12 +48,10 @@ function filter (isEthereum: boolean, items: string[], others: string[] = []): s return items.reduce((result, a) => { if (!result.includes(a) && !others.includes(a)) { try { - const u8a = decodeAddress(a); - - if (u8a.length === allowedLength) { + if (decodeAddress(a).length >= allowedLength) { result.push(a); } else { - console.warn(`Not adding address ${a}, not in correct format for chain (requires ${allowedLength}-byte publickey)`); + console.warn(`Not adding address ${a}, not in correct format for chain (requires publickey from address)`); } } catch { console.error(a, allowedLength);