otterscan/src/components/TransactionValue.tsx
2021-07-03 19:14:03 -03:00

30 lines
663 B
TypeScript

import React from "react";
import { BigNumber } from "ethers";
import { formatValue } from "./formatter";
type TransactionValueProps = {
value: BigNumber;
decimals?: number;
hideUnit?: boolean;
};
const TransactionValue: React.FC<TransactionValueProps> = ({
value,
decimals = 18,
hideUnit,
}) => {
const formattedValue = formatValue(value, decimals);
return (
<span
className={`text-sm ${value.isZero() ? "text-gray-400" : ""}`}
title={`${formattedValue} Ether`}
>
<span className={`font-balance`}>{formattedValue}</span>
{!hideUnit && " Ether"}
</span>
);
};
export default React.memo(TransactionValue);