ghost-portal/packages/react-components/src/util/getAddressMeta.ts
Ewa Kowalska 541213f233
Ek extract type only imports into separate group (#4168)
* Plug new beta of eslint plugin simple import sort

* Apply new configuration to existing imports
2020-12-07 16:04:05 +01:00

21 lines
596 B
TypeScript

// Copyright 2017-2020 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { KeyringItemType, KeyringJson$Meta } from '@polkadot/ui-keyring/types';
import keyring from '@polkadot/ui-keyring';
export default function getAddressMeta (address: string, type: KeyringItemType | null = null): KeyringJson$Meta {
let meta: KeyringJson$Meta | undefined;
try {
const pair = keyring.getAddress(address, type);
meta = pair && pair.meta;
} catch (error) {
// we could pass invalid addresses, so it may throw
}
return meta || {};
}