Merge branch 'feature/ui-tweaks' into feature/self-destruct-trace

This commit is contained in:
Willian Mitsuda 2021-07-19 15:38:01 -03:00
commit 590ffd60dc
6 changed files with 73 additions and 32 deletions

View File

@ -3,17 +3,23 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCaretRight } from "@fortawesome/free-solid-svg-icons"; import { faCaretRight } from "@fortawesome/free-solid-svg-icons";
import AddressHighlighter from "./components/AddressHighlighter"; import AddressHighlighter from "./components/AddressHighlighter";
import DecoratedAddressLink from "./components/DecoratedAddressLink"; import DecoratedAddressLink from "./components/DecoratedAddressLink";
import TokenLogo from "./components/TokenLogo";
import FormattedBalance from "./components/FormattedBalance"; import FormattedBalance from "./components/FormattedBalance";
import { AddressContext, TokenMetas, TokenTransfer } from "./types"; import {
AddressContext,
TokenMetas,
TokenTransfer,
TransactionData,
} from "./types";
type TokenTransferItemProps = { type TokenTransferItemProps = {
t: TokenTransfer; t: TokenTransfer;
txData: TransactionData;
tokenMetas: TokenMetas; tokenMetas: TokenMetas;
}; };
const TokenTransferItem: React.FC<TokenTransferItemProps> = ({ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
t, t,
txData,
tokenMetas, tokenMetas,
}) => ( }) => (
<div className="flex items-baseline space-x-2 px-2 py-1 truncate hover:bg-gray-100"> <div className="flex items-baseline space-x-2 px-2 py-1 truncate hover:bg-gray-100">
@ -27,13 +33,20 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
<DecoratedAddressLink <DecoratedAddressLink
address={t.from} address={t.from}
addressCtx={AddressContext.FROM} addressCtx={AddressContext.FROM}
txFrom={t.from === txData.from}
txTo={t.from === txData.to}
/> />
</AddressHighlighter> </AddressHighlighter>
</div> </div>
<div className="flex space-x-1"> <div className="flex space-x-1">
<span className="font-bold">To</span> <span className="font-bold">To</span>
<AddressHighlighter address={t.to}> <AddressHighlighter address={t.to}>
<DecoratedAddressLink address={t.to} addressCtx={AddressContext.TO} /> <DecoratedAddressLink
address={t.to}
addressCtx={AddressContext.TO}
txFrom={t.to === txData.from}
txTo={t.to === txData.to}
/>
</AddressHighlighter> </AddressHighlighter>
</div> </div>
<div className="col-span-3 flex space-x-1"> <div className="col-span-3 flex space-x-1">
@ -44,23 +57,17 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
decimals={tokenMetas[t.token].decimals} decimals={tokenMetas[t.token].decimals}
/> />
</span> </span>
<span className="flex space-x-1 items-baseline truncate"> <AddressHighlighter address={t.token}>
{tokenMetas[t.token] ? (
<>
<div className="self-center">
<TokenLogo address={t.token} name={tokenMetas[t.token].name} />
</div>
<DecoratedAddressLink <DecoratedAddressLink
address={t.token} address={t.token}
text={`${tokenMetas[t.token].name} (${ text={
tokenMetas[t.token].symbol tokenMetas[t.token]
})`} ? `${tokenMetas[t.token].name} (${tokenMetas[t.token].symbol})`
: ""
}
tokenMeta={tokenMetas[t.token]}
/> />
</> </AddressHighlighter>
) : (
<DecoratedAddressLink address={t.token} />
)}
</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -5,8 +5,9 @@ import {
faBurn, faBurn,
faCoins, faCoins,
} from "@fortawesome/free-solid-svg-icons"; } from "@fortawesome/free-solid-svg-icons";
import TokenLogo from "./TokenLogo";
import AddressOrENSName from "./AddressOrENSName"; import AddressOrENSName from "./AddressOrENSName";
import { AddressContext, ZERO_ADDRESS } from "../types"; import { AddressContext, TokenMeta, ZERO_ADDRESS } from "../types";
type DecoratedAddressLinkProps = { type DecoratedAddressLinkProps = {
address: string; address: string;
@ -16,6 +17,9 @@ type DecoratedAddressLinkProps = {
addressCtx?: AddressContext; addressCtx?: AddressContext;
miner?: boolean; miner?: boolean;
selfDestruct?: boolean; selfDestruct?: boolean;
txFrom?: boolean;
txTo?: boolean;
tokenMeta?: TokenMeta;
}; };
const DecoratedAddresssLink: React.FC<DecoratedAddressLinkProps> = ({ const DecoratedAddresssLink: React.FC<DecoratedAddressLinkProps> = ({
@ -26,17 +30,20 @@ const DecoratedAddresssLink: React.FC<DecoratedAddressLinkProps> = ({
addressCtx, addressCtx,
miner, miner,
selfDestruct, selfDestruct,
txFrom,
txTo,
tokenMeta,
}) => { }) => {
const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS; const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS;
const burn = addressCtx === AddressContext.TO && address === ZERO_ADDRESS; const burn = addressCtx === AddressContext.TO && address === ZERO_ADDRESS;
return ( return (
<div <div
className={`flex items-baseline space-x-1 ${ className={`flex items-baseline space-x-1 ${txFrom ? "bg-red-50" : ""} ${
mint ? "italic text-green-500 hover:text-green-700" : "" txTo ? "bg-green-50" : ""
} ${burn ? "line-through text-orange-500 hover:text-orange-700" : ""} ${ } ${mint ? "italic text-green-500 hover:text-green-700" : ""} ${
selfDestruct ? "line-through" : "" burn ? "line-through text-orange-500 hover:text-orange-700" : ""
}`} } ${selfDestruct ? "line-through opacity-70 hover:opacity-100" : ""}`}
> >
{mint && ( {mint && (
<span className="text-green-500" title="Mint address"> <span className="text-green-500" title="Mint address">
@ -53,6 +60,11 @@ const DecoratedAddresssLink: React.FC<DecoratedAddressLinkProps> = ({
<FontAwesomeIcon icon={faCoins} size="1x" /> <FontAwesomeIcon icon={faCoins} size="1x" />
</span> </span>
)} )}
{tokenMeta && (
<div className="self-center">
<TokenLogo address={address} name={tokenMeta.name} />
</div>
)}
<AddressOrENSName <AddressOrENSName
address={address} address={address}
ensName={ensName} ensName={ensName}

View File

@ -33,7 +33,12 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
fromMiner ? "rounded px-2 py-1 bg-yellow-100" : "" fromMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
}`} }`}
> >
<DecoratedAddressLink address={transfer.from} miner={fromMiner} /> <DecoratedAddressLink
address={transfer.from}
miner={fromMiner}
txFrom={transfer.from === txData.from}
txTo={transfer.from === txData.to}
/>
</div> </div>
</AddressHighlighter> </AddressHighlighter>
</div> </div>
@ -45,7 +50,12 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
toMiner ? "rounded px-2 py-1 bg-yellow-100" : "" toMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
}`} }`}
> >
<DecoratedAddressLink address={transfer.to} miner={toMiner} /> <DecoratedAddressLink
address={transfer.to}
miner={toMiner}
txFrom={transfer.to === txData.from}
txTo={transfer.to === txData.to}
/>
</div> </div>
</AddressHighlighter> </AddressHighlighter>
</div> </div>

View File

@ -68,6 +68,7 @@ const Details: React.FC<DetailsProps> = ({
<DecoratedAddressLink <DecoratedAddressLink
address={txData.from} address={txData.from}
miner={txData.from === txData.miner} miner={txData.from === txData.miner}
txFrom
/> />
</AddressHighlighter> </AddressHighlighter>
<Copy value={txData.from} /> <Copy value={txData.from} />
@ -79,6 +80,7 @@ const Details: React.FC<DetailsProps> = ({
<DecoratedAddressLink <DecoratedAddressLink
address={txData.to} address={txData.to}
miner={txData.to === txData.miner} miner={txData.to === txData.miner}
txTo
/> />
</AddressHighlighter> </AddressHighlighter>
<Copy value={txData.to} /> <Copy value={txData.to} />
@ -101,7 +103,12 @@ const Details: React.FC<DetailsProps> = ({
<InfoRow title={`Tokens Transferred (${txData.tokenTransfers.length})`}> <InfoRow title={`Tokens Transferred (${txData.tokenTransfers.length})`}>
<div> <div>
{txData.tokenTransfers.map((t, i) => ( {txData.tokenTransfers.map((t, i) => (
<TokenTransferItem key={i} t={t} tokenMetas={txData.tokenMetas} /> <TokenTransferItem
key={i}
t={t}
txData={txData}
tokenMetas={txData.tokenMetas}
/>
))} ))}
</div> </div>
</InfoRow> </InfoRow>

View File

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import ContentFrame from "../ContentFrame"; import ContentFrame from "../ContentFrame";
import AddressOrENSName from "../components/AddressOrENSName"; import DecoratedAddressLink from "../components/DecoratedAddressLink";
import { TransactionData } from "../types"; import { TransactionData } from "../types";
type LogsProps = { type LogsProps = {
@ -22,7 +22,12 @@ const Logs: React.FC<LogsProps> = ({ txData }) => (
<div className="grid grid-cols-12 gap-x-3 gap-y-5 text-sm"> <div className="grid grid-cols-12 gap-x-3 gap-y-5 text-sm">
<div className="font-bold text-right">Address</div> <div className="font-bold text-right">Address</div>
<div className="col-span-11"> <div className="col-span-11">
<AddressOrENSName address={l.address} /> <DecoratedAddressLink
address={l.address}
miner={l.address === txData.miner}
txFrom={l.address === txData.from}
txTo={l.address === txData.to}
/>
</div> </div>
</div> </div>
{l.topics.map((t, i) => ( {l.topics.map((t, i) => (

View File

@ -1,7 +1,7 @@
import React, { useState, useContext } from "react"; import React, { useState, useContext } from "react";
export type Selection = { export type Selection = {
type: string; type: "address";
content: string; content: string;
}; };