Add contract creation display on transaction details page

This commit is contained in:
Willian Mitsuda 2021-07-21 01:23:44 -03:00
parent a5fc5e595e
commit dcc121ccc2
4 changed files with 34 additions and 11 deletions

View File

@ -88,6 +88,7 @@ const Transaction: React.FC = () => {
miner: _block.miner, miner: _block.miner,
from: _receipt.from, from: _receipt.from,
to: _receipt.to, to: _receipt.to,
createdContractAddress: _receipt.contractAddress,
value: _response.value, value: _response.value,
tokenTransfers, tokenTransfers,
tokenMetas, tokenMetas,

View File

@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { import {
faStar,
faMoneyBillAlt, faMoneyBillAlt,
faBurn, faBurn,
faCoins, faCoins,
@ -15,6 +16,7 @@ type DecoratedAddressLinkProps = {
selectedAddress?: string; selectedAddress?: string;
text?: string; text?: string;
addressCtx?: AddressContext; addressCtx?: AddressContext;
creation?: boolean;
miner?: boolean; miner?: boolean;
selfDestruct?: boolean; selfDestruct?: boolean;
txFrom?: boolean; txFrom?: boolean;
@ -28,6 +30,7 @@ const DecoratedAddresssLink: React.FC<DecoratedAddressLinkProps> = ({
selectedAddress, selectedAddress,
text, text,
addressCtx, addressCtx,
creation,
miner, miner,
selfDestruct, selfDestruct,
txFrom, txFrom,
@ -45,6 +48,11 @@ const DecoratedAddresssLink: React.FC<DecoratedAddressLinkProps> = ({
burn ? "line-through text-orange-500 hover:text-orange-700" : "" burn ? "line-through text-orange-500 hover:text-orange-700" : ""
} ${selfDestruct ? "line-through opacity-70 hover:opacity-100" : ""}`} } ${selfDestruct ? "line-through opacity-70 hover:opacity-100" : ""}`}
> >
{creation && (
<span className="text-yellow-300" title="Contract creation">
<FontAwesomeIcon icon={faStar} size="1x" />
</span>
)}
{mint && ( {mint && (
<span className="text-green-500" title="Mint address"> <span className="text-green-500" title="Mint address">
<FontAwesomeIcon icon={faMoneyBillAlt} size="1x" /> <FontAwesomeIcon icon={faMoneyBillAlt} size="1x" />

View File

@ -73,7 +73,8 @@ const Details: React.FC<DetailsProps> = ({
<Copy value={txData.from} /> <Copy value={txData.from} />
</div> </div>
</InfoRow> </InfoRow>
<InfoRow title="Interacted With (To)"> <InfoRow title={txData.to ? "Interacted With (To)" : "Contract Created"}>
{txData.to ? (
<div className="flex items-baseline space-x-2 -ml-1"> <div className="flex items-baseline space-x-2 -ml-1">
<AddressHighlighter address={txData.to}> <AddressHighlighter address={txData.to}>
<DecoratedAddressLink <DecoratedAddressLink
@ -84,6 +85,18 @@ const Details: React.FC<DetailsProps> = ({
</AddressHighlighter> </AddressHighlighter>
<Copy value={txData.to} /> <Copy value={txData.to} />
</div> </div>
) : (
<div className="flex items-baseline space-x-2 -ml-1">
<AddressHighlighter address={txData.createdContractAddress!}>
<DecoratedAddressLink
address={txData.createdContractAddress!}
creation
txTo
/>
</AddressHighlighter>
<Copy value={txData.createdContractAddress!} />
</div>
)}
{internalTransfers && ( {internalTransfers && (
<div className="mt-2 space-y-1"> <div className="mt-2 space-y-1">
{internalTransfers.map((t, i) => ( {internalTransfers.map((t, i) => (

View File

@ -44,6 +44,7 @@ export type TransactionData = {
miner?: string; miner?: string;
from: string; from: string;
to: string; to: string;
createdContractAddress?: string;
value: BigNumber; value: BigNumber;
tokenTransfers: TokenTransfer[]; tokenTransfers: TokenTransfer[];
tokenMetas: TokenMetas; tokenMetas: TokenMetas;