diff --git a/src/components/ElementDiff.tsx b/src/components/ElementDiff.tsx index 4c374af94..abb14eab0 100644 --- a/src/components/ElementDiff.tsx +++ b/src/components/ElementDiff.tsx @@ -3,10 +3,15 @@ import React from "react"; type ElementDiffProps = { oldElem: React.ReactNode | null; newElem: React.ReactNode | null; + diffElem: React.ReactNode | null; }; -const ElementDiff: React.FC = ({ oldElem, newElem }) => { - return ( +const ElementDiff: React.FC = ({ + oldElem, + newElem, + diffElem, +}) => ( +
{oldElem !== null && (
@@ -25,7 +30,8 @@ const ElementDiff: React.FC = ({ oldElem, newElem }) => {
)}
- ); -}; + {diffElem &&
{diffElem}
} +
+); export default ElementDiff; diff --git a/src/execution/transaction/StateDiff.tsx b/src/execution/transaction/StateDiff.tsx index 593261fab..74e9de61e 100644 --- a/src/execution/transaction/StateDiff.tsx +++ b/src/execution/transaction/StateDiff.tsx @@ -3,7 +3,7 @@ import React, { useContext } from "react"; import ContentFrame from "../../components/ContentFrame"; import DisplayInteger from "../../components/DisplayInteger"; import ElementDiff from "../../components/ElementDiff"; -import { balancePreset, neutralPreset } from "../../components/FiatValue"; +import { balancePreset } from "../../components/FiatValue"; import HexValue from "../../components/HexValue"; import NativeTokenAmountAndFiat from "../../components/NativeTokenAmountAndFiat"; import { TransactionData } from "../../types"; @@ -101,6 +101,7 @@ const buildStateDiffTree = ( } else { result.push(getBranch()); let values: [string | null, string | null] = [group.from, group.to]; + let diffElement: null | React.ReactElement = null; let formatter: (value: string) => React.ReactNode | null = ( value: string, ) => <>{value}; @@ -123,18 +124,16 @@ const buildStateDiffTree = ( formatter = (value: string) => ; break; case "balance": - let diffElement: null | React.ReactElement = null; if (values[0] !== null && values[1] !== null) { let balanceDiff = BigInt(values[1]) - BigInt(values[0]); diffElement = ( - - ({balanceDiff >= 0n ? "+" : ""} + <> + {balanceDiff >= 0n ? "+" : ""} - ) - + ); } formatter = (value: string) => ( @@ -167,6 +166,7 @@ const buildStateDiffTree = (