Dedupe token history and pretty print slots (#11636)

This commit is contained in:
Justin Starry 2020-08-14 23:59:39 +08:00 committed by GitHub
parent f6af505ae4
commit 346e982e28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -75,6 +75,7 @@ function TokenHistoryTable({ tokens }: { tokens: TokenInfoWithPubkey[] }) {
return history?.status === FetchStatus.FetchFailed;
});
const sigSet = new Set();
const mintAndTxs = tokens
.map((token) => ({
mint: token.info.mint,
@ -88,7 +89,12 @@ function TokenHistoryTable({ tokens }: { tokens: TokenInfoWithPubkey[] }) {
mint,
tx,
}))
);
)
.filter(({ tx }) => {
if (sigSet.has(tx.signature)) return false;
sigSet.add(tx.signature);
return true;
});
if (mintAndTxs.length === 0) {
if (fetching) {
@ -224,7 +230,9 @@ function TokenTransactionRow({
return (
<tr key={index}>
<td className="w-1">{tx.slot}</td>
<td className="w-1 text-monospace">
{tx.slot.toLocaleString("en-US")}
</td>
<td>
<span className={`badge badge-soft-${statusClass}`}>
@ -261,7 +269,7 @@ function TokenTransactionRow({
return (
<tr key={tx.signature}>
<td className="w-1">{tx.slot}</td>
<td className="w-1 text-monospace">{tx.slot.toLocaleString("en-US")}</td>
<td>
<span className={`badge badge-soft-${statusClass}`}>{statusText}</span>

View File

@ -70,7 +70,7 @@ export function TransactionHistoryCard({ pubkey }: { pubkey: PublicKey }) {
detailsList.push(
<tr key={signature}>
<td className="w-1">{slot}</td>
<td className="w-1 text-monospace">{slot.toLocaleString("en-US")}</td>
<td>
<span className={`badge badge-soft-${statusClass}`}>

View File

@ -45,7 +45,7 @@ export function TransactionDetailsPage({ signature: raw }: Props) {
<div className="header">
<div className="header-body">
<h6 className="header-pretitle">Details</h6>
<h4 className="header-title">Transaction</h4>
<h2 className="header-title">Transaction</h2>
</div>
</div>
{signature === undefined ? (