ghost-portal/packages/react-components/src/util/toShortAddress.ts
Jaco 829830b83a
Adjust query type display (#6150)
* Adjust query type display

* linting

* Fix test page
2021-09-19 17:58:56 +02:00

13 lines
466 B
TypeScript

// Copyright 2017-2021 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
export function toShortAddress (_address?: AccountId | AccountIndex | Address | string | null | Uint8Array): string {
const address = (_address || '').toString();
return (address.length > 13)
? `${address.slice(0, 6)}…${address.slice(-6)}`
: address;
}