2021-07-19 03:38:38 +00:00
|
|
|
import React from "react";
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
2021-08-08 06:51:21 +00:00
|
|
|
import { faStar } from "@fortawesome/free-solid-svg-icons/faStar";
|
|
|
|
import { faBomb } from "@fortawesome/free-solid-svg-icons/faBomb";
|
|
|
|
import { faMoneyBillAlt } from "@fortawesome/free-solid-svg-icons/faMoneyBillAlt";
|
|
|
|
import { faBurn } from "@fortawesome/free-solid-svg-icons/faBurn";
|
|
|
|
import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
|
2021-07-19 17:56:36 +00:00
|
|
|
import TokenLogo from "./TokenLogo";
|
2021-07-19 03:38:38 +00:00
|
|
|
import AddressOrENSName from "./AddressOrENSName";
|
2021-07-19 17:56:36 +00:00
|
|
|
import { AddressContext, TokenMeta, ZERO_ADDRESS } from "../types";
|
2021-07-19 03:38:38 +00:00
|
|
|
|
|
|
|
type DecoratedAddressLinkProps = {
|
|
|
|
address: string;
|
|
|
|
ensName?: string;
|
|
|
|
selectedAddress?: string;
|
|
|
|
text?: string;
|
|
|
|
addressCtx?: AddressContext;
|
2021-07-21 04:23:44 +00:00
|
|
|
creation?: boolean;
|
2021-07-19 03:38:38 +00:00
|
|
|
miner?: boolean;
|
2021-07-19 07:19:24 +00:00
|
|
|
selfDestruct?: boolean;
|
2021-07-19 16:29:49 +00:00
|
|
|
txFrom?: boolean;
|
|
|
|
txTo?: boolean;
|
2021-07-19 17:56:36 +00:00
|
|
|
tokenMeta?: TokenMeta;
|
2021-07-19 03:38:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const DecoratedAddresssLink: React.FC<DecoratedAddressLinkProps> = ({
|
|
|
|
address,
|
|
|
|
ensName,
|
|
|
|
selectedAddress,
|
|
|
|
text,
|
|
|
|
addressCtx,
|
2021-07-21 04:23:44 +00:00
|
|
|
creation,
|
2021-07-19 03:38:38 +00:00
|
|
|
miner,
|
2021-07-19 07:19:24 +00:00
|
|
|
selfDestruct,
|
2021-07-19 16:29:49 +00:00
|
|
|
txFrom,
|
|
|
|
txTo,
|
2021-07-19 17:56:36 +00:00
|
|
|
tokenMeta,
|
2021-07-19 03:38:38 +00:00
|
|
|
}) => {
|
|
|
|
const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS;
|
|
|
|
const burn = addressCtx === AddressContext.TO && address === ZERO_ADDRESS;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2021-07-19 16:29:49 +00:00
|
|
|
className={`flex items-baseline space-x-1 ${txFrom ? "bg-red-50" : ""} ${
|
|
|
|
txTo ? "bg-green-50" : ""
|
|
|
|
} ${mint ? "italic text-green-500 hover:text-green-700" : ""} ${
|
|
|
|
burn ? "line-through text-orange-500 hover:text-orange-700" : ""
|
|
|
|
} ${selfDestruct ? "line-through opacity-70 hover:opacity-100" : ""}`}
|
2021-07-19 03:38:38 +00:00
|
|
|
>
|
2021-07-21 04:23:44 +00:00
|
|
|
{creation && (
|
|
|
|
<span className="text-yellow-300" title="Contract creation">
|
|
|
|
<FontAwesomeIcon icon={faStar} size="1x" />
|
|
|
|
</span>
|
|
|
|
)}
|
2021-07-21 20:51:34 +00:00
|
|
|
{selfDestruct && (
|
|
|
|
<span className="text-red-800" title="Self destruct">
|
|
|
|
<FontAwesomeIcon icon={faBomb} size="1x" />
|
|
|
|
</span>
|
|
|
|
)}
|
2021-07-19 03:38:38 +00:00
|
|
|
{mint && (
|
|
|
|
<span className="text-green-500" title="Mint address">
|
|
|
|
<FontAwesomeIcon icon={faMoneyBillAlt} size="1x" />
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{burn && (
|
|
|
|
<span className="text-orange-500" title="Burn address">
|
|
|
|
<FontAwesomeIcon icon={faBurn} size="1x" />
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{miner && (
|
|
|
|
<span className="text-yellow-400" title="Miner address">
|
|
|
|
<FontAwesomeIcon icon={faCoins} size="1x" />
|
|
|
|
</span>
|
|
|
|
)}
|
2021-07-19 17:56:36 +00:00
|
|
|
{tokenMeta && (
|
|
|
|
<div className="self-center">
|
|
|
|
<TokenLogo address={address} name={tokenMeta.name} />
|
|
|
|
</div>
|
|
|
|
)}
|
2021-07-19 03:38:38 +00:00
|
|
|
<AddressOrENSName
|
|
|
|
address={address}
|
|
|
|
ensName={ensName}
|
|
|
|
selectedAddress={selectedAddress}
|
|
|
|
text={text}
|
2021-07-19 03:50:32 +00:00
|
|
|
dontOverrideColors={mint || burn}
|
2021-07-19 03:38:38 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default React.memo(DecoratedAddresssLink);
|