From a1edc3d6324530e7d53ac9aad9608733c9ce15e2 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 11 Apr 2022 14:34:49 -0300 Subject: [PATCH] Push down oracle info read --- src/TransactionPageContent.tsx | 7 ------- src/transaction/Details.tsx | 23 +++++++++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/TransactionPageContent.tsx b/src/TransactionPageContent.tsx index 31a7974..501ff46 100644 --- a/src/TransactionPageContent.tsx +++ b/src/TransactionPageContent.tsx @@ -10,7 +10,6 @@ import { useInternalOperations, useTxData } from "./useErigonHooks"; import { SelectionContext, useSelection } from "./useSelection"; import { SelectedTransactionContext } from "./useSelectedTransaction"; import { BlockNumberContext } from "./useBlockTagContext"; -import { useETHUSDOracle } from "./usePriceOracle"; import { useAppConfigContext } from "./useAppConfig"; import { useSourcify, useTransactionDescription } from "./sourcify/useSourcify"; @@ -60,11 +59,6 @@ const TransactionPageContent: React.FC = ({ const selectionCtx = useSelection(); - const blockETHUSDPrice = useETHUSDOracle( - provider, - txData?.confirmedData?.blockNumber - ); - const { sourcifySource } = useAppConfigContext(); const metadata = useSourcify( txData?.to, @@ -114,7 +108,6 @@ const TransactionPageContent: React.FC = ({ devDoc={metadata?.output.devdoc} internalOps={internalOps} sendsEthToMiner={sendsEthToMiner} - ethUSDPrice={blockETHUSDPrice} /> } /> diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index a5d0661..5764d99 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -1,7 +1,6 @@ import React, { useContext, useMemo, useState } from "react"; import { Tab } from "@headlessui/react"; import { TransactionDescription } from "@ethersproject/abi"; -import { BigNumber } from "@ethersproject/bignumber"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCheckCircle } from "@fortawesome/free-solid-svg-icons/faCheckCircle"; import { faCube } from "@fortawesome/free-solid-svg-icons/faCube"; @@ -47,6 +46,7 @@ import { RuntimeContext } from "../useRuntime"; import { useContractsMetadata } from "../hooks"; import { useTransactionError } from "../useErigonHooks"; import { useChainInfo } from "../useChainInfo"; +import { useETHUSDOracle } from "../usePriceOracle"; type DetailsProps = { txData: TransactionData; @@ -56,7 +56,6 @@ type DetailsProps = { devDoc?: DevDoc | undefined; internalOps?: InternalOperation[]; sendsEthToMiner: boolean; - ethUSDPrice: BigNumber | undefined; }; const Details: React.FC = ({ @@ -67,7 +66,6 @@ const Details: React.FC = ({ devDoc, internalOps, sendsEthToMiner, - ethUSDPrice, }) => { const hasEIP1559 = txData.confirmedData?.blockBaseFeePerGas !== undefined && @@ -90,6 +88,12 @@ const Details: React.FC = ({ const { nativeCurrency: { name, symbol }, } = useChainInfo(); + + const blockETHUSDPrice = useETHUSDOracle( + provider, + txData?.confirmedData?.blockNumber + ); + const addresses = useMemo(() => { const _addresses: ChecksummedAddress[] = []; if (txData.to) { @@ -318,9 +322,12 @@ const Details: React.FC = ({ )} {symbol}{" "} - {!txData.value.isZero() && ethUSDPrice && ( + {!txData.value.isZero() && blockETHUSDPrice && ( - + )} @@ -409,11 +416,11 @@ const Details: React.FC = ({
{symbol}{" "} - {ethUSDPrice && ( + {blockETHUSDPrice && ( )} @@ -422,7 +429,7 @@ const Details: React.FC = ({
- + )}