ghost-portal/packages/react-components/src/util/getAddressMeta.ts
Jaco Greeff 93b38ece21
Cleanup WebPack (#4258)
* Remove unused WP5 override

* Adjust

* Additional imports

* Adjust
2020-12-21 13:15:40 +01:00

21 lines
600 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 || {};
}