2022-03-02 09:46:43 +00:00
|
|
|
import React, { useContext } from "react";
|
2021-08-08 22:49:45 +00:00
|
|
|
import { formatEther } from "@ethersproject/units";
|
2021-07-05 03:03:01 +00:00
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
2021-08-08 06:51:21 +00:00
|
|
|
import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight";
|
2021-07-14 07:43:58 +00:00
|
|
|
import AddressHighlighter from "./AddressHighlighter";
|
2021-07-19 03:38:38 +00:00
|
|
|
import DecoratedAddressLink from "./DecoratedAddressLink";
|
2022-03-02 09:46:43 +00:00
|
|
|
import { RuntimeContext } from "../useRuntime";
|
|
|
|
import { useHasCode } from "../useErigonHooks";
|
2021-07-21 19:06:51 +00:00
|
|
|
import { TransactionData, InternalOperation } from "../types";
|
2021-07-05 03:03:01 +00:00
|
|
|
|
|
|
|
type InternalTransferProps = {
|
|
|
|
txData: TransactionData;
|
2021-07-21 19:06:51 +00:00
|
|
|
internalOp: InternalOperation;
|
2021-07-05 03:03:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const InternalTransfer: React.FC<InternalTransferProps> = ({
|
|
|
|
txData,
|
2021-07-21 19:06:51 +00:00
|
|
|
internalOp,
|
2021-07-05 03:03:01 +00:00
|
|
|
}) => {
|
|
|
|
const fromMiner =
|
2021-09-04 06:19:42 +00:00
|
|
|
txData.confirmedData?.miner !== undefined &&
|
|
|
|
internalOp.from === txData.confirmedData.miner;
|
|
|
|
const toMiner =
|
|
|
|
txData.confirmedData?.miner !== undefined &&
|
|
|
|
internalOp.to === txData.confirmedData.miner;
|
2021-07-05 03:03:01 +00:00
|
|
|
|
2022-03-02 09:46:43 +00:00
|
|
|
const { provider } = useContext(RuntimeContext);
|
|
|
|
const fromHasCode = useHasCode(
|
|
|
|
provider,
|
|
|
|
internalOp.from,
|
|
|
|
txData.confirmedData ? txData.confirmedData.blockNumber - 1 : undefined
|
|
|
|
);
|
|
|
|
const toHasCode = useHasCode(
|
|
|
|
provider,
|
|
|
|
internalOp.to,
|
|
|
|
txData.confirmedData ? txData.confirmedData.blockNumber - 1 : undefined
|
|
|
|
);
|
|
|
|
|
2021-07-05 03:03:01 +00:00
|
|
|
return (
|
2021-11-18 18:46:09 +00:00
|
|
|
<div className="flex items-baseline space-x-1 whitespace-nowrap">
|
2021-07-05 03:03:01 +00:00
|
|
|
<span className="text-gray-500">
|
|
|
|
<FontAwesomeIcon icon={faAngleRight} size="1x" /> TRANSFER
|
|
|
|
</span>
|
2021-08-08 22:49:45 +00:00
|
|
|
<span>{formatEther(internalOp.value)} Ether</span>
|
2021-07-14 18:35:53 +00:00
|
|
|
<div className="flex items-baseline">
|
|
|
|
<span className="text-gray-500">From</span>
|
2021-07-21 19:06:51 +00:00
|
|
|
<AddressHighlighter address={internalOp.from}>
|
2021-07-14 18:35:53 +00:00
|
|
|
<div
|
|
|
|
className={`flex items-baseline space-x-1 ${
|
|
|
|
fromMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
|
|
|
|
}`}
|
|
|
|
>
|
2021-07-19 16:29:49 +00:00
|
|
|
<DecoratedAddressLink
|
2021-07-21 19:06:51 +00:00
|
|
|
address={internalOp.from}
|
2021-07-19 16:29:49 +00:00
|
|
|
miner={fromMiner}
|
2021-07-21 19:06:51 +00:00
|
|
|
txFrom={internalOp.from === txData.from}
|
|
|
|
txTo={internalOp.from === txData.to}
|
2022-03-02 09:46:43 +00:00
|
|
|
eoa={fromHasCode === undefined ? undefined : !fromHasCode}
|
2021-07-19 16:29:49 +00:00
|
|
|
/>
|
2021-07-14 18:35:53 +00:00
|
|
|
</div>
|
|
|
|
</AddressHighlighter>
|
|
|
|
</div>
|
|
|
|
<div className="flex items-baseline">
|
|
|
|
<span className="text-gray-500">To</span>
|
2021-07-21 19:06:51 +00:00
|
|
|
<AddressHighlighter address={internalOp.to}>
|
2021-07-14 18:35:53 +00:00
|
|
|
<div
|
|
|
|
className={`flex items-baseline space-x-1 ${
|
|
|
|
toMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
|
|
|
|
}`}
|
|
|
|
>
|
2021-07-19 16:29:49 +00:00
|
|
|
<DecoratedAddressLink
|
2021-07-21 19:06:51 +00:00
|
|
|
address={internalOp.to}
|
2021-07-19 16:29:49 +00:00
|
|
|
miner={toMiner}
|
2021-07-21 19:06:51 +00:00
|
|
|
txFrom={internalOp.to === txData.from}
|
|
|
|
txTo={internalOp.to === txData.to}
|
2022-03-02 09:46:43 +00:00
|
|
|
eoa={toHasCode === undefined ? undefined : !toHasCode}
|
2021-07-19 16:29:49 +00:00
|
|
|
/>
|
2021-07-14 18:35:53 +00:00
|
|
|
</div>
|
|
|
|
</AddressHighlighter>
|
|
|
|
</div>
|
2021-07-05 03:03:01 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-11-18 18:51:08 +00:00
|
|
|
export default InternalTransfer;
|