mirror of
https://github.com/selfxyz/self.git
synced 2026-02-19 02:24:25 -05:00
* Display user ID on prove screen * Add user ID formatting util and tests * Clarify user ID formatting * fix nice * add tests and save toggle wip * update tests based on feedback * say connected wallet when wallet
22 lines
666 B
TypeScript
22 lines
666 B
TypeScript
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
|
|
|
|
/**
|
|
* Format a user identifier for display.
|
|
*
|
|
* Hex addresses are truncated to keep the UI compact while
|
|
* UUIDs (and other string values) are shown in full.
|
|
*/
|
|
export function formatUserId(
|
|
userId: string | null | undefined,
|
|
userIdType: 'hex' | 'uuid' | undefined,
|
|
): string | null {
|
|
if (!userId) {
|
|
return null;
|
|
}
|
|
if (userIdType === 'hex') {
|
|
const address = userId.startsWith('0x') ? userId : `0x${userId}`;
|
|
return `${address.slice(0, 4)}...${address.slice(-4)}`;
|
|
}
|
|
return userId;
|
|
}
|