2021-07-06 00:08:58 +00:00
|
|
|
import React from "react";
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
2021-08-08 06:51:21 +00:00
|
|
|
import { faCaretRight } from "@fortawesome/free-solid-svg-icons/faCaretRight";
|
2021-07-14 07:43:58 +00:00
|
|
|
import AddressHighlighter from "./components/AddressHighlighter";
|
2021-07-20 02:33:19 +00:00
|
|
|
import ValueHighlighter from "./components/ValueHighlighter";
|
2021-07-19 03:38:38 +00:00
|
|
|
import DecoratedAddressLink from "./components/DecoratedAddressLink";
|
2021-07-06 00:08:58 +00:00
|
|
|
import FormattedBalance from "./components/FormattedBalance";
|
2021-07-19 16:29:49 +00:00
|
|
|
import {
|
|
|
|
AddressContext,
|
|
|
|
TokenMetas,
|
|
|
|
TokenTransfer,
|
|
|
|
TransactionData,
|
|
|
|
} from "./types";
|
2021-07-06 00:08:58 +00:00
|
|
|
|
|
|
|
type TokenTransferItemProps = {
|
|
|
|
t: TokenTransfer;
|
2021-07-19 16:29:49 +00:00
|
|
|
txData: TransactionData;
|
2021-07-06 00:08:58 +00:00
|
|
|
tokenMetas: TokenMetas;
|
|
|
|
};
|
|
|
|
|
|
|
|
const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
|
|
|
|
t,
|
2021-07-19 16:29:49 +00:00
|
|
|
txData,
|
2021-07-06 00:08:58 +00:00
|
|
|
tokenMetas,
|
|
|
|
}) => (
|
2021-07-19 03:55:21 +00:00
|
|
|
<div className="flex items-baseline space-x-2 px-2 py-1 truncate hover:bg-gray-100">
|
2021-07-06 00:08:58 +00:00
|
|
|
<span className="text-gray-500">
|
|
|
|
<FontAwesomeIcon icon={faCaretRight} size="1x" />
|
|
|
|
</span>
|
2021-07-14 18:35:53 +00:00
|
|
|
<div className="grid grid-cols-5 gap-x-1">
|
|
|
|
<div className="flex space-x-1">
|
2021-07-06 05:00:54 +00:00
|
|
|
<span className="font-bold">From</span>
|
2021-07-14 07:43:58 +00:00
|
|
|
<AddressHighlighter address={t.from}>
|
2021-07-19 03:38:38 +00:00
|
|
|
<DecoratedAddressLink
|
|
|
|
address={t.from}
|
|
|
|
addressCtx={AddressContext.FROM}
|
2021-07-19 16:29:49 +00:00
|
|
|
txFrom={t.from === txData.from}
|
|
|
|
txTo={t.from === txData.to}
|
2021-07-19 03:38:38 +00:00
|
|
|
/>
|
2021-07-14 07:43:58 +00:00
|
|
|
</AddressHighlighter>
|
2021-07-06 05:00:54 +00:00
|
|
|
</div>
|
2021-07-14 18:35:53 +00:00
|
|
|
<div className="flex space-x-1">
|
2021-07-06 05:00:54 +00:00
|
|
|
<span className="font-bold">To</span>
|
2021-07-14 07:43:58 +00:00
|
|
|
<AddressHighlighter address={t.to}>
|
2021-07-19 16:29:49 +00:00
|
|
|
<DecoratedAddressLink
|
|
|
|
address={t.to}
|
|
|
|
addressCtx={AddressContext.TO}
|
|
|
|
txFrom={t.to === txData.from}
|
|
|
|
txTo={t.to === txData.to}
|
|
|
|
/>
|
2021-07-14 07:43:58 +00:00
|
|
|
</AddressHighlighter>
|
2021-07-06 05:00:54 +00:00
|
|
|
</div>
|
2021-07-14 18:35:53 +00:00
|
|
|
<div className="col-span-3 flex space-x-1">
|
2021-07-06 05:00:54 +00:00
|
|
|
<span className="font-bold">For</span>
|
|
|
|
<span>
|
2021-07-20 02:33:19 +00:00
|
|
|
<ValueHighlighter value={t.value}>
|
|
|
|
<FormattedBalance
|
|
|
|
value={t.value}
|
|
|
|
decimals={tokenMetas[t.token].decimals}
|
|
|
|
/>
|
|
|
|
</ValueHighlighter>
|
2021-07-06 05:00:54 +00:00
|
|
|
</span>
|
2021-07-19 18:00:15 +00:00
|
|
|
<AddressHighlighter address={t.token}>
|
|
|
|
<DecoratedAddressLink
|
|
|
|
address={t.token}
|
|
|
|
text={
|
|
|
|
tokenMetas[t.token]
|
|
|
|
? `${tokenMetas[t.token].name} (${tokenMetas[t.token].symbol})`
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
tokenMeta={tokenMetas[t.token]}
|
|
|
|
/>
|
|
|
|
</AddressHighlighter>
|
2021-07-06 05:00:54 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-06 00:08:58 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default React.memo(TokenTransferItem);
|