From c9f7f46ebc3dd43a001486e6670fee3df5cbf1bd Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Thu, 18 Nov 2021 15:46:09 -0300 Subject: [PATCH] Add generic resolvers support to internal ops --- src/components/InternalCreate.tsx | 12 +++++- src/components/InternalSelfDestruct.tsx | 40 ++++++++++++------- .../InternalTransactionOperation.tsx | 12 +++++- src/components/InternalTransfer.tsx | 4 +- src/transaction/Details.tsx | 2 +- 5 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src/components/InternalCreate.tsx b/src/components/InternalCreate.tsx index 7a723ce..dcf050f 100644 --- a/src/components/InternalCreate.tsx +++ b/src/components/InternalCreate.tsx @@ -4,26 +4,33 @@ import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight"; import AddressHighlighter from "./AddressHighlighter"; import DecoratedAddressLink from "./DecoratedAddressLink"; import { TransactionData, InternalOperation } from "../types"; +import { ResolvedAddresses } from "../api/address-resolver"; type InternalCreateProps = { txData: TransactionData; internalOp: InternalOperation; + resolvedAddresses: ResolvedAddresses | undefined; }; const InternalCreate: React.FC = ({ txData, internalOp, + resolvedAddresses, }) => { return ( <> -
+
CREATE Contract
- +
@@ -33,6 +40,7 @@ const InternalCreate: React.FC = ({ address={internalOp.from} txFrom={internalOp.from === txData.from} txTo={internalOp.from === txData.to} + resolvedAddresses={resolvedAddresses} /> ) diff --git a/src/components/InternalSelfDestruct.tsx b/src/components/InternalSelfDestruct.tsx index 007fb32..be71afd 100644 --- a/src/components/InternalSelfDestruct.tsx +++ b/src/components/InternalSelfDestruct.tsx @@ -1,11 +1,12 @@ -import React, { useContext } from "react"; +import React from "react"; import { formatEther } from "@ethersproject/units"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight"; import AddressHighlighter from "./AddressHighlighter"; import DecoratedAddressLink from "./DecoratedAddressLink"; -import { RuntimeContext } from "../useRuntime"; import { TransactionData, InternalOperation } from "../types"; +import { ResolvedAddresses } from "../api/address-resolver"; +import TransactionAddress from "./TransactionAddress"; const CHI_ADDRESS = "0x0000000000004946c0e9F43F4Dee607b0eF1fA1c"; const GST2_ADDRESS = "0x0000000000b3F879cb30FE243b4Dfee438691c04"; @@ -13,40 +14,47 @@ const GST2_ADDRESS = "0x0000000000b3F879cb30FE243b4Dfee438691c04"; type InternalSelfDestructProps = { txData: TransactionData; internalOp: InternalOperation; + resolvedAddresses: ResolvedAddresses | undefined; }; const InternalSelfDestruct: React.FC = ({ txData, internalOp, + resolvedAddresses, }) => { - const { provider } = useContext(RuntimeContext); - const network = provider?.network; - const toMiner = txData.confirmedData?.miner !== undefined && internalOp.to === txData.confirmedData.miner; return ( <> -
+
SELF DESTRUCT Contract
- +
- {network?.chainId === 1 && internalOp.to === CHI_ADDRESS && ( - (Chi Gastoken) - )} - {network?.chainId === 1 && internalOp.to === GST2_ADDRESS && ( - (GST2 Gastoken) + {internalOp.value.isZero() && ( +
+ (To:{" "} + + ) +
)}
{!internalOp.value.isZero() && ( -
+
TRANSFER @@ -59,7 +67,11 @@ const InternalSelfDestruct: React.FC = ({ toMiner ? "rounded px-2 py-1 bg-yellow-100" : "" }`} > - +
diff --git a/src/components/InternalTransactionOperation.tsx b/src/components/InternalTransactionOperation.tsx index 7de3bb2..f35319d 100644 --- a/src/components/InternalTransactionOperation.tsx +++ b/src/components/InternalTransactionOperation.tsx @@ -22,11 +22,19 @@ const InternalTransactionOperation: React.FC /> )} {internalOp.type === OperationType.SELF_DESTRUCT && ( - + )} {(internalOp.type === OperationType.CREATE || internalOp.type === OperationType.CREATE2) && ( - + )} ); diff --git a/src/components/InternalTransfer.tsx b/src/components/InternalTransfer.tsx index 2958452..1dce1db 100644 --- a/src/components/InternalTransfer.tsx +++ b/src/components/InternalTransfer.tsx @@ -26,7 +26,7 @@ const InternalTransfer: React.FC = ({ internalOp.to === txData.confirmedData.miner; return ( -
+
TRANSFER @@ -44,6 +44,7 @@ const InternalTransfer: React.FC = ({ miner={fromMiner} txFrom={internalOp.from === txData.from} txTo={internalOp.from === txData.to} + resolvedAddresses={resolvedAddresses} />
@@ -61,6 +62,7 @@ const InternalTransfer: React.FC = ({ miner={toMiner} txFrom={internalOp.to === txData.from} txTo={internalOp.to === txData.to} + resolvedAddresses={resolvedAddresses} />
diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 1fc10bd..0b474af 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -206,7 +206,7 @@ const Details: React.FC = ({
)} {internalOps && internalOps.length > 0 && ( -
+
{internalOps.map((op, i) => (