From 00cc2d0d29ce229cd8c88f6f357d1223abb6db75 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 19 Jul 2021 13:29:49 -0300 Subject: [PATCH] Add contextual global tx from/to addresss highlighting --- src/TokenTransferItem.tsx | 18 ++++++++++++++++-- src/components/DecoratedAddressLink.tsx | 14 +++++++++----- src/components/InternalTransfer.tsx | 14 ++++++++++++-- src/transaction/Details.tsx | 9 ++++++++- src/useSelection.ts | 2 +- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/TokenTransferItem.tsx b/src/TokenTransferItem.tsx index 286d43f..1e171de 100644 --- a/src/TokenTransferItem.tsx +++ b/src/TokenTransferItem.tsx @@ -5,15 +5,22 @@ import AddressHighlighter from "./components/AddressHighlighter"; import DecoratedAddressLink from "./components/DecoratedAddressLink"; import TokenLogo from "./components/TokenLogo"; import FormattedBalance from "./components/FormattedBalance"; -import { AddressContext, TokenMetas, TokenTransfer } from "./types"; +import { + AddressContext, + TokenMetas, + TokenTransfer, + TransactionData, +} from "./types"; type TokenTransferItemProps = { t: TokenTransfer; + txData: TransactionData; tokenMetas: TokenMetas; }; const TokenTransferItem: React.FC = ({ t, + txData, tokenMetas, }) => (
@@ -27,13 +34,20 @@ const TokenTransferItem: React.FC = ({
To - +
diff --git a/src/components/DecoratedAddressLink.tsx b/src/components/DecoratedAddressLink.tsx index 7fb76f7..f82c7a4 100644 --- a/src/components/DecoratedAddressLink.tsx +++ b/src/components/DecoratedAddressLink.tsx @@ -16,6 +16,8 @@ type DecoratedAddressLinkProps = { addressCtx?: AddressContext; miner?: boolean; selfDestruct?: boolean; + txFrom?: boolean; + txTo?: boolean; }; const DecoratedAddresssLink: React.FC = ({ @@ -26,17 +28,19 @@ const DecoratedAddresssLink: React.FC = ({ addressCtx, miner, selfDestruct, + txFrom, + txTo, }) => { const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS; const burn = addressCtx === AddressContext.TO && address === ZERO_ADDRESS; return (
{mint && ( diff --git a/src/components/InternalTransfer.tsx b/src/components/InternalTransfer.tsx index af101e0..d0ccbf2 100644 --- a/src/components/InternalTransfer.tsx +++ b/src/components/InternalTransfer.tsx @@ -33,7 +33,12 @@ const InternalTransfer: React.FC = ({ fromMiner ? "rounded px-2 py-1 bg-yellow-100" : "" }`} > - +
@@ -45,7 +50,12 @@ const InternalTransfer: React.FC = ({ toMiner ? "rounded px-2 py-1 bg-yellow-100" : "" }`} > - + diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 441226a..cba7a9a 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -68,6 +68,7 @@ const Details: React.FC = ({ @@ -79,6 +80,7 @@ const Details: React.FC = ({ @@ -101,7 +103,12 @@ const Details: React.FC = ({
{txData.tokenTransfers.map((t, i) => ( - + ))}
diff --git a/src/useSelection.ts b/src/useSelection.ts index ed66746..a02f1fe 100644 --- a/src/useSelection.ts +++ b/src/useSelection.ts @@ -1,7 +1,7 @@ import React, { useState, useContext } from "react"; export type Selection = { - type: string; + type: "address"; content: string; };