21 lines
592 B
TypeScript
21 lines
592 B
TypeScript
// Copyright 2017-2022 @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 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 || {};
|
|
}
|