20 lines
763 B
TypeScript
20 lines
763 B
TypeScript
// Copyright 2017-2020 @polkadot/react-components authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
|
|
import { KeyringItemType } from '@polkadot/ui-keyring/types';
|
|
|
|
import getAddressMeta from './getAddressMeta';
|
|
import toShortAddress from './toShortAddress';
|
|
|
|
// isName, isDefault, name
|
|
export default function getAddressName (address: string, type: KeyringItemType | null = null, defaultName?: string): [boolean, boolean, string] {
|
|
const meta = getAddressMeta(address, type);
|
|
|
|
return meta.name
|
|
? [false, false, meta.name.toUpperCase()]
|
|
: defaultName
|
|
? [false, true, defaultName.toUpperCase()]
|
|
: [true, false, toShortAddress(address)];
|
|
}
|