@mysten/sui
Version:
Sui TypeScript API(Work in Progress)
20 lines (14 loc) • 461 B
text/typescript
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
const ELLIPSIS = '\u{2026}';
export function formatAddress(address: string) {
if (address.length <= 6) {
return address;
}
const offset = address.startsWith('0x') ? 2 : 0;
return `0x${address.slice(offset, offset + 4)}${ELLIPSIS}${address.slice(-4)}`;
}
export function formatDigest(digest: string) {
// Use 10 first characters
return `${digest.slice(0, 10)}${ELLIPSIS}`;
}