2021-07-01 18:21:40 +00:00
|
|
|
import React from "react";
|
2021-08-08 22:49:45 +00:00
|
|
|
import { BigNumber } from "@ethersproject/bignumber";
|
2021-07-01 18:21:40 +00:00
|
|
|
import { formatValue } from "./formatter";
|
|
|
|
|
|
|
|
type TransactionValueProps = {
|
|
|
|
value: BigNumber;
|
|
|
|
decimals?: number;
|
2021-07-03 22:14:03 +00:00
|
|
|
hideUnit?: boolean;
|
2021-07-01 18:21:40 +00:00
|
|
|
};
|
|
|
|
|
2022-02-19 18:19:56 +00:00
|
|
|
/**
|
|
|
|
* Standard component for displaying balances. It:
|
|
|
|
*
|
|
|
|
* - Commify non-decimal parts, i.e., 1,000,000.00
|
|
|
|
* - Light gray absolute zero values
|
|
|
|
* - Cut out decimal part is it is 0 to reduce UI clutter, i.e., show
|
|
|
|
* 123 instead of 123.00
|
|
|
|
*
|
|
|
|
* TODO: remove duplication with FormattedBalance
|
|
|
|
*/
|
2021-07-01 18:21:40 +00:00
|
|
|
const TransactionValue: React.FC<TransactionValueProps> = ({
|
|
|
|
value,
|
|
|
|
decimals = 18,
|
2021-07-03 22:14:03 +00:00
|
|
|
hideUnit,
|
2021-07-01 18:21:40 +00:00
|
|
|
}) => {
|
|
|
|
const formattedValue = formatValue(value, decimals);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<span
|
|
|
|
className={`text-sm ${value.isZero() ? "text-gray-400" : ""}`}
|
|
|
|
title={`${formattedValue} Ether`}
|
|
|
|
>
|
2021-07-03 22:14:03 +00:00
|
|
|
<span className={`font-balance`}>{formattedValue}</span>
|
|
|
|
{!hideUnit && " Ether"}
|
2021-07-01 18:21:40 +00:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default React.memo(TransactionValue);
|