mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 05:37:56 +00:00
Reorganize repository into monorepo structure
Restructured the project to support multiple frontend applications: - Move web app to web/ directory - Create pezkuwi-sdk-ui/ for Polkadot SDK clone (planned) - Create mobile/ directory for mobile app development - Add shared/ directory with common utilities, types, and blockchain code - Update README.md with comprehensive documentation - Remove obsolete DKSweb/ directory This monorepo structure enables better code sharing and organized development across web, mobile, and SDK UI projects.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Formatting utilities
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format a blockchain address for display
|
||||
* @param address - Full blockchain address
|
||||
* @param chars - Number of characters to show at start and end
|
||||
* @returns Formatted address (e.g., "0x1234...5678")
|
||||
*/
|
||||
export function formatAddress(address: string, chars = 4): string {
|
||||
if (!address) return '';
|
||||
if (address.length <= chars * 2) return address;
|
||||
return `${address.slice(0, chars)}...${address.slice(-chars)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a number with thousand separators
|
||||
* @param value - Number to format
|
||||
* @param decimals - Number of decimal places
|
||||
* @returns Formatted number string
|
||||
*/
|
||||
export function formatNumber(value: number, decimals = 2): string {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: decimals,
|
||||
maximumFractionDigits: decimals,
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a token amount with proper decimals
|
||||
* @param amount - Amount in smallest unit
|
||||
* @param decimals - Token decimals (e.g., 18 for most tokens)
|
||||
* @returns Formatted token amount
|
||||
*/
|
||||
export function formatTokenAmount(amount: string | number, decimals = 18): string {
|
||||
const value = typeof amount === 'string' ? parseFloat(amount) : amount;
|
||||
return formatNumber(value / Math.pow(10, decimals), 4);
|
||||
}
|
||||
Reference in New Issue
Block a user