mirror of
https://github.com/luxfhe/example-redact.git
synced 2026-10-30 18:13:20 +00:00
22 lines
610 B
TypeScript
22 lines
610 B
TypeScript
import { useMemo } from "react";
|
|
import { DisplayValue, DisplayValueProps } from "./DisplayValue";
|
|
import { formatTokenAmount } from "~~/lib/common";
|
|
|
|
export function DisplayBalance({
|
|
balance,
|
|
decimals = 18,
|
|
precision,
|
|
...props
|
|
}: DisplayValueProps & {
|
|
balance: bigint | null | undefined;
|
|
decimals?: number;
|
|
precision?: number;
|
|
}) {
|
|
const display = useMemo(() => {
|
|
if (balance == null) return "...";
|
|
if (balance < 0n) return "N/A";
|
|
return formatTokenAmount(balance, decimals, precision);
|
|
}, [balance, decimals, precision]);
|
|
return <DisplayValue value={display} {...props} />;
|
|
}
|