Migrate remaining token decoration support to the new resolver framework
This commit is contained in:
parent
e22b564a71
commit
91a888c73b
|
@ -11,11 +11,13 @@ import {
|
||||||
TokenTransfer,
|
TokenTransfer,
|
||||||
TransactionData,
|
TransactionData,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
|
import { ResolvedAddresses } from "./api/address-resolver";
|
||||||
|
|
||||||
type TokenTransferItemProps = {
|
type TokenTransferItemProps = {
|
||||||
t: TokenTransfer;
|
t: TokenTransfer;
|
||||||
txData: TransactionData;
|
txData: TransactionData;
|
||||||
tokenMeta?: TokenMeta | undefined;
|
tokenMeta?: TokenMeta | undefined;
|
||||||
|
resolvedAddresses: ResolvedAddresses | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: handle partial
|
// TODO: handle partial
|
||||||
|
@ -23,6 +25,7 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
|
||||||
t,
|
t,
|
||||||
txData,
|
txData,
|
||||||
tokenMeta,
|
tokenMeta,
|
||||||
|
resolvedAddresses,
|
||||||
}) => (
|
}) => (
|
||||||
<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">
|
||||||
<span className="text-gray-500">
|
<span className="text-gray-500">
|
||||||
|
@ -64,10 +67,7 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
|
||||||
<AddressHighlighter address={t.token}>
|
<AddressHighlighter address={t.token}>
|
||||||
<DecoratedAddressLink
|
<DecoratedAddressLink
|
||||||
address={t.token}
|
address={t.token}
|
||||||
text={
|
resolvedAddresses={resolvedAddresses}
|
||||||
tokenMeta ? `${tokenMeta.name} (${tokenMeta.symbol})` : undefined
|
|
||||||
}
|
|
||||||
tokenMeta={tokenMeta}
|
|
||||||
/>
|
/>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,7 +8,6 @@ import PlainAddress from "./PlainAddress";
|
||||||
type AddressOrENSNameProps = {
|
type AddressOrENSNameProps = {
|
||||||
address: string;
|
address: string;
|
||||||
selectedAddress?: string;
|
selectedAddress?: string;
|
||||||
text?: string;
|
|
||||||
dontOverrideColors?: boolean;
|
dontOverrideColors?: boolean;
|
||||||
resolvedAddresses?: ResolvedAddresses | undefined;
|
resolvedAddresses?: ResolvedAddresses | undefined;
|
||||||
};
|
};
|
||||||
|
@ -16,7 +15,6 @@ type AddressOrENSNameProps = {
|
||||||
const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
||||||
address,
|
address,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
text,
|
|
||||||
dontOverrideColors,
|
dontOverrideColors,
|
||||||
resolvedAddresses,
|
resolvedAddresses,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -27,7 +25,6 @@ const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
||||||
return (
|
return (
|
||||||
<PlainAddress
|
<PlainAddress
|
||||||
address={address}
|
address={address}
|
||||||
text={text}
|
|
||||||
linkable={linkable}
|
linkable={linkable}
|
||||||
dontOverrideColors={dontOverrideColors}
|
dontOverrideColors={dontOverrideColors}
|
||||||
/>
|
/>
|
||||||
|
@ -40,7 +37,6 @@ const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
||||||
return (
|
return (
|
||||||
<PlainAddress
|
<PlainAddress
|
||||||
address={address}
|
address={address}
|
||||||
text={text}
|
|
||||||
linkable={linkable}
|
linkable={linkable}
|
||||||
dontOverrideColors={dontOverrideColors}
|
dontOverrideColors={dontOverrideColors}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -5,36 +5,31 @@ import { faBomb } from "@fortawesome/free-solid-svg-icons/faBomb";
|
||||||
import { faMoneyBillAlt } from "@fortawesome/free-solid-svg-icons/faMoneyBillAlt";
|
import { faMoneyBillAlt } from "@fortawesome/free-solid-svg-icons/faMoneyBillAlt";
|
||||||
import { faBurn } from "@fortawesome/free-solid-svg-icons/faBurn";
|
import { faBurn } from "@fortawesome/free-solid-svg-icons/faBurn";
|
||||||
import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
|
import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
|
||||||
import TokenLogo from "./TokenLogo";
|
|
||||||
import AddressOrENSName from "./AddressOrENSName";
|
import AddressOrENSName from "./AddressOrENSName";
|
||||||
import { AddressContext, TokenMeta, ZERO_ADDRESS } from "../types";
|
import { AddressContext, ZERO_ADDRESS } from "../types";
|
||||||
import { ResolvedAddresses } from "../api/address-resolver";
|
import { ResolvedAddresses } from "../api/address-resolver";
|
||||||
|
|
||||||
type DecoratedAddressLinkProps = {
|
type DecoratedAddressLinkProps = {
|
||||||
address: string;
|
address: string;
|
||||||
selectedAddress?: string;
|
selectedAddress?: string;
|
||||||
text?: string;
|
|
||||||
addressCtx?: AddressContext;
|
addressCtx?: AddressContext;
|
||||||
creation?: boolean;
|
creation?: boolean;
|
||||||
miner?: boolean;
|
miner?: boolean;
|
||||||
selfDestruct?: boolean;
|
selfDestruct?: boolean;
|
||||||
txFrom?: boolean;
|
txFrom?: boolean;
|
||||||
txTo?: boolean;
|
txTo?: boolean;
|
||||||
tokenMeta?: TokenMeta;
|
|
||||||
resolvedAddresses?: ResolvedAddresses | undefined;
|
resolvedAddresses?: ResolvedAddresses | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DecoratedAddressLink: React.FC<DecoratedAddressLinkProps> = ({
|
const DecoratedAddressLink: React.FC<DecoratedAddressLinkProps> = ({
|
||||||
address,
|
address,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
text,
|
|
||||||
addressCtx,
|
addressCtx,
|
||||||
creation,
|
creation,
|
||||||
miner,
|
miner,
|
||||||
selfDestruct,
|
selfDestruct,
|
||||||
txFrom,
|
txFrom,
|
||||||
txTo,
|
txTo,
|
||||||
tokenMeta,
|
|
||||||
resolvedAddresses,
|
resolvedAddresses,
|
||||||
}) => {
|
}) => {
|
||||||
const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS;
|
const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS;
|
||||||
|
@ -75,15 +70,9 @@ const DecoratedAddressLink: 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}
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
text={text}
|
|
||||||
dontOverrideColors={mint || burn}
|
dontOverrideColors={mint || burn}
|
||||||
resolvedAddresses={resolvedAddresses}
|
resolvedAddresses={resolvedAddresses}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,14 +3,12 @@ import { NavLink } from "react-router-dom";
|
||||||
|
|
||||||
type PlainAddressProps = {
|
type PlainAddressProps = {
|
||||||
address: string;
|
address: string;
|
||||||
text: string | undefined;
|
|
||||||
linkable: boolean;
|
linkable: boolean;
|
||||||
dontOverrideColors: boolean | undefined;
|
dontOverrideColors: boolean | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const PlainAddress: React.FC<PlainAddressProps> = ({
|
const PlainAddress: React.FC<PlainAddressProps> = ({
|
||||||
address,
|
address,
|
||||||
text,
|
|
||||||
linkable,
|
linkable,
|
||||||
dontOverrideColors,
|
dontOverrideColors,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -21,9 +19,9 @@ const PlainAddress: React.FC<PlainAddressProps> = ({
|
||||||
dontOverrideColors ? "" : "text-link-blue hover:text-link-blue-hover"
|
dontOverrideColors ? "" : "text-link-blue hover:text-link-blue-hover"
|
||||||
} font-address truncate`}
|
} font-address truncate`}
|
||||||
to={`/address/${address}`}
|
to={`/address/${address}`}
|
||||||
title={text ?? address}
|
title={address}
|
||||||
>
|
>
|
||||||
<>{text ?? address}</>
|
{address}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,7 @@ const Details: React.FC<DetailsProps> = ({
|
||||||
t={t}
|
t={t}
|
||||||
txData={txData}
|
txData={txData}
|
||||||
tokenMeta={txData.tokenMetas[t.token]}
|
tokenMeta={txData.tokenMetas[t.token]}
|
||||||
|
resolvedAddresses={resolvedAddresses}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue