refactor: rename SolaceScanScout to Solace and update related configurations
- Updated branding from "SolaceScanScout" to "Solace" across various files including deployment scripts, API responses, and documentation. - Changed default base URL for Playwright tests and updated security headers to reflect the new branding. - Enhanced README and API documentation to include new authentication endpoints and product access details. This refactor aligns the project branding and improves clarity in the API documentation.
This commit is contained in:
@@ -28,3 +28,43 @@ export function formatWeiAsEth(value: string, fractionDigits = 4): string {
|
||||
return '0 ETH'
|
||||
}
|
||||
}
|
||||
|
||||
export function formatUnits(value: string | number | null | undefined, decimals = 18, fractionDigits = 4): string {
|
||||
try {
|
||||
const safeDecimals = Math.max(0, Math.min(36, decimals))
|
||||
const normalizedDigits = Math.max(0, Math.min(12, fractionDigits))
|
||||
const amount = BigInt(typeof value === 'number' ? value.toString() : value || '0')
|
||||
const divisor = 10n ** BigInt(safeDecimals)
|
||||
const whole = amount / divisor
|
||||
const fraction = amount % divisor
|
||||
|
||||
if (normalizedDigits === 0 || safeDecimals === 0) {
|
||||
return whole.toString()
|
||||
}
|
||||
|
||||
const scale = 10n ** BigInt(Math.max(0, safeDecimals - normalizedDigits))
|
||||
const truncatedFraction = fraction / scale
|
||||
const paddedFraction = truncatedFraction
|
||||
.toString()
|
||||
.padStart(Math.min(normalizedDigits, safeDecimals), '0')
|
||||
.replace(/0+$/, '')
|
||||
|
||||
return paddedFraction ? `${whole.toString()}.${paddedFraction}` : whole.toString()
|
||||
} catch {
|
||||
return '0'
|
||||
}
|
||||
}
|
||||
|
||||
export function formatTokenAmount(value: string | number | null | undefined, decimals = 18, symbol?: string | null, fractionDigits = 4): string {
|
||||
const formatted = formatUnits(value, decimals, fractionDigits)
|
||||
return symbol ? `${formatted} ${symbol}` : formatted
|
||||
}
|
||||
|
||||
export function formatTimestamp(value?: string | null): string {
|
||||
if (!value) return 'Unknown'
|
||||
const date = new Date(value)
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return value
|
||||
}
|
||||
return date.toLocaleString()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user