diff --git a/src/components/InternalTransactionOperation.tsx b/src/components/InternalTransactionOperation.tsx index 3037dd2..d102be9 100644 --- a/src/components/InternalTransactionOperation.tsx +++ b/src/components/InternalTransactionOperation.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { BigNumber } from "@ethersproject/bignumber"; import InternalTransfer from "./InternalTransfer"; import InternalSelfDestruct from "./InternalSelfDestruct"; import InternalCreate from "./InternalCreate"; @@ -8,20 +7,14 @@ import { TransactionData, InternalOperation, OperationType } from "../types"; type InternalTransactionOperationProps = { txData: TransactionData; internalOp: InternalOperation; - // TODO: migrate all this logic to SWR - ethUSDPrice: BigNumber | undefined; }; const InternalTransactionOperation: React.FC< InternalTransactionOperationProps -> = ({ txData, internalOp, ethUSDPrice }) => ( +> = ({ txData, internalOp }) => ( <> {internalOp.type === OperationType.TRANSFER && ( - + )} {internalOp.type === OperationType.SELF_DESTRUCT && ( diff --git a/src/components/InternalTransfer.tsx b/src/components/InternalTransfer.tsx index 173c74e..0faeb77 100644 --- a/src/components/InternalTransfer.tsx +++ b/src/components/InternalTransfer.tsx @@ -1,5 +1,4 @@ import React, { useContext } from "react"; -import { BigNumber } from "@ethersproject/bignumber"; import { formatEther } from "@ethersproject/units"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight"; @@ -11,19 +10,17 @@ import USDAmount from "./USDAmount"; import { RuntimeContext } from "../useRuntime"; import { useHasCode } from "../useErigonHooks"; import { useChainInfo } from "../useChainInfo"; +import { useETHUSDOracle } from "../usePriceOracle"; import { TransactionData, InternalOperation } from "../types"; type InternalTransferProps = { txData: TransactionData; internalOp: InternalOperation; - // TODO: migrate all this logic to SWR - ethUSDPrice: BigNumber | undefined; }; const InternalTransfer: React.FC = ({ txData, internalOp, - ethUSDPrice, }) => { const { nativeCurrency: { symbol, decimals }, @@ -36,6 +33,10 @@ const InternalTransfer: React.FC = ({ internalOp.to === txData.confirmedData.miner; const { provider } = useContext(RuntimeContext); + const blockETHUSDPrice = useETHUSDOracle( + provider, + txData.confirmedData?.blockNumber + ); const fromHasCode = useHasCode( provider, internalOp.from, @@ -99,12 +100,12 @@ const InternalTransfer: React.FC = ({ {formatEther(internalOp.value)} {symbol} - {ethUSDPrice && ( + {blockETHUSDPrice && ( diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 5b6e972..5db70f2 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -286,7 +286,6 @@ const Details: React.FC = ({ txData }) => { key={i} txData={txData} internalOp={op} - ethUSDPrice={blockETHUSDPrice} /> ))}