Add eoa/contract legend support to internal eth transfers

This commit is contained in:
Willian Mitsuda 2022-03-02 06:46:43 -03:00
parent 1edb7ff002
commit a49f8150da
1 changed files with 17 additions and 1 deletions

View File

@ -1,9 +1,11 @@
import React from "react"; import React, { useContext } from "react";
import { formatEther } from "@ethersproject/units"; import { formatEther } from "@ethersproject/units";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight"; import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight";
import AddressHighlighter from "./AddressHighlighter"; import AddressHighlighter from "./AddressHighlighter";
import DecoratedAddressLink from "./DecoratedAddressLink"; import DecoratedAddressLink from "./DecoratedAddressLink";
import { RuntimeContext } from "../useRuntime";
import { useHasCode } from "../useErigonHooks";
import { TransactionData, InternalOperation } from "../types"; import { TransactionData, InternalOperation } from "../types";
type InternalTransferProps = { type InternalTransferProps = {
@ -22,6 +24,18 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
txData.confirmedData?.miner !== undefined && txData.confirmedData?.miner !== undefined &&
internalOp.to === txData.confirmedData.miner; internalOp.to === txData.confirmedData.miner;
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
);
return ( return (
<div className="flex items-baseline space-x-1 whitespace-nowrap"> <div className="flex items-baseline space-x-1 whitespace-nowrap">
<span className="text-gray-500"> <span className="text-gray-500">
@ -41,6 +55,7 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
miner={fromMiner} miner={fromMiner}
txFrom={internalOp.from === txData.from} txFrom={internalOp.from === txData.from}
txTo={internalOp.from === txData.to} txTo={internalOp.from === txData.to}
eoa={fromHasCode === undefined ? undefined : !fromHasCode}
/> />
</div> </div>
</AddressHighlighter> </AddressHighlighter>
@ -58,6 +73,7 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
miner={toMiner} miner={toMiner}
txFrom={internalOp.to === txData.from} txFrom={internalOp.to === txData.from}
txTo={internalOp.to === txData.to} txTo={internalOp.to === txData.to}
eoa={toHasCode === undefined ? undefined : !toHasCode}
/> />
</div> </div>
</AddressHighlighter> </AddressHighlighter>