Add hint to GST2/CHI gastoken selfdestructs on mainnet

This commit is contained in:
Willian Mitsuda 2021-07-19 04:14:56 -03:00
parent 6bf905d33a
commit 03ce994a5c
4 changed files with 31 additions and 52 deletions

View File

@ -1,15 +1,15 @@
import React from "react"; import React, { useContext } from "react";
import { ethers } from "ethers"; import { ethers } from "ethers";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { import { faAngleRight, faBomb } from "@fortawesome/free-solid-svg-icons";
faAngleRight,
faBomb,
faCoins,
} from "@fortawesome/free-solid-svg-icons";
import AddressHighlighter from "./AddressHighlighter"; import AddressHighlighter from "./AddressHighlighter";
import AddressLink from "./AddressLink"; import DecoratedAddressLink from "./DecoratedAddressLink";
import { RuntimeContext } from "../useRuntime";
import { TransactionData, Transfer } from "../types"; import { TransactionData, Transfer } from "../types";
const CHI_ADDRESS = "0x0000000000004946c0e9F43F4Dee607b0eF1fA1c";
const GST2_ADDRESS = "0x0000000000b3F879cb30FE243b4Dfee438691c04";
type InternalSelfDestructProps = { type InternalSelfDestructProps = {
txData: TransactionData; txData: TransactionData;
transfer: Transfer; transfer: Transfer;
@ -19,8 +19,9 @@ const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
txData, txData,
transfer, transfer,
}) => { }) => {
const fromMiner = const { provider } = useContext(RuntimeContext);
txData.miner !== undefined && transfer.from === txData.miner; const network = provider?.network;
const toMiner = txData.miner !== undefined && transfer.to === txData.miner; const toMiner = txData.miner !== undefined && transfer.to === txData.miner;
return ( return (
@ -35,20 +36,15 @@ const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
<span>Contract</span> <span>Contract</span>
<div className="flex items-baseline"> <div className="flex items-baseline">
<AddressHighlighter address={transfer.from}> <AddressHighlighter address={transfer.from}>
<div <DecoratedAddressLink address={transfer.from} />
className={`flex items-baseline space-x-1 ${
fromMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
}`}
>
{fromMiner && (
<span className="text-yellow-400" title="Miner address">
<FontAwesomeIcon icon={faCoins} size="1x" />
</span>
)}
<AddressLink address={transfer.from} />
</div>
</AddressHighlighter> </AddressHighlighter>
</div> </div>
{network?.chainId === 1 && transfer.to === CHI_ADDRESS && (
<span className="text-gray-400">(CHI Gastoken)</span>
)}
{network?.chainId === 1 && transfer.to === GST2_ADDRESS && (
<span className="text-gray-400">(GST2 Gastoken)</span>
)}
</div> </div>
{!transfer.value.isZero() && ( {!transfer.value.isZero() && (
<div className="ml-5 flex items-baseline space-x-1 text-xs"> <div className="ml-5 flex items-baseline space-x-1 text-xs">
@ -64,12 +60,7 @@ const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
toMiner ? "rounded px-2 py-1 bg-yellow-100" : "" toMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
}`} }`}
> >
{toMiner && ( <DecoratedAddressLink address={transfer.to} miner={toMiner} />
<span className="text-yellow-400" title="Miner address">
<FontAwesomeIcon icon={faCoins} size="1x" />
</span>
)}
<AddressLink address={transfer.to} />
</div> </div>
</AddressHighlighter> </AddressHighlighter>
</div> </div>

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { ethers } from "ethers"; import { ethers } from "ethers";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAngleRight, faCoins } from "@fortawesome/free-solid-svg-icons"; import { faAngleRight } from "@fortawesome/free-solid-svg-icons";
import AddressHighlighter from "./AddressHighlighter"; import AddressHighlighter from "./AddressHighlighter";
import DecoratedAddressLink from "./DecoratedAddressLink"; import DecoratedAddressLink from "./DecoratedAddressLink";
import { TransactionData, Transfer } from "../types"; import { TransactionData, Transfer } from "../types";
@ -33,12 +33,7 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
fromMiner ? "rounded px-2 py-1 bg-yellow-100" : "" fromMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
}`} }`}
> >
{fromMiner && ( <DecoratedAddressLink address={transfer.from} miner={fromMiner} />
<span className="text-yellow-400" title="Miner address">
<FontAwesomeIcon icon={faCoins} size="1x" />
</span>
)}
<DecoratedAddressLink address={transfer.from} />
</div> </div>
</AddressHighlighter> </AddressHighlighter>
</div> </div>
@ -50,12 +45,7 @@ const InternalTransfer: React.FC<InternalTransferProps> = ({
toMiner ? "rounded px-2 py-1 bg-yellow-100" : "" toMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
}`} }`}
> >
{toMiner && ( <DecoratedAddressLink address={transfer.to} miner={toMiner} />
<span className="text-yellow-400" title="Miner address">
<FontAwesomeIcon icon={faCoins} size="1x" />
</span>
)}
<DecoratedAddressLink address={transfer.to} />
</div> </div>
</AddressHighlighter> </AddressHighlighter>
</div> </div>

View File

@ -84,18 +84,14 @@ const Details: React.FC<DetailsProps> = ({
<Copy value={txData.to} /> <Copy value={txData.to} />
</div> </div>
{internalTransfers && ( {internalTransfers && (
<> <div className="mt-2 space-y-1">
<div className="mt-2 space-y-1"> {internalTransfers.transfers.map((t, i) => (
{internalTransfers.transfers.map((t, i) => ( <InternalTransfer key={i} txData={txData} transfer={t} />
<InternalTransfer key={i} txData={txData} transfer={t} /> ))}
))} {internalTransfers.selfDestructs.map((t, i) => (
</div> <InternalSelfDestruct key={i} txData={txData} transfer={t} />
<div className="mt-2 space-y-1"> ))}
{internalTransfers.selfDestructs.map((t, i) => ( </div>
<InternalSelfDestruct key={i} txData={txData} transfer={t} />
))}
</div>
</>
)} )}
</InfoRow> </InfoRow>
<InfoRow title="Transaction Action"> <InfoRow title="Transaction Action">

View File

@ -24,6 +24,8 @@ export const useInternalTransfers = (
txData txData
); );
for (const s of _selfDestructs) { for (const s of _selfDestructs) {
s.from = provider.formatter.address(s.from);
s.to = provider.formatter.address(s.to);
s.value = provider.formatter.bigNumber(s.value); s.value = provider.formatter.bigNumber(s.value);
} }
setIntTransfers({ transfers: _transfers, selfDestructs: _selfDestructs }); setIntTransfers({ transfers: _transfers, selfDestructs: _selfDestructs });