Skip to content

Commit 679a4a9

Browse files
author
Vernon Johnson
committed
fix: activity and balance component cleanup
1 parent ed66c51 commit 679a4a9

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

apps/dashboard/src/app/(dashboard)/hackweek/[chain_id]/[address]/actions/fetchERC20Tokens.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export async function fetchERC20Tokens(args: {
9292
lastTransferredDate:
9393
token.queried_wallet_balances[0]?.last_transferred_date,
9494
}));
95-
const fungibleTokens = data.fungibles.map((token) => ({
95+
let fungibleTokens = data.fungibles.map((token) => ({
9696
name: token.name,
9797
symbol: token.symbol,
9898
contractAddress: token.fungible_id.split(".")[1] ?? "--",
@@ -104,6 +104,7 @@ export async function fetchERC20Tokens(args: {
104104
lastTransferredDate:
105105
token.queried_wallet_balances[0]?.last_transferred_date,
106106
}));
107+
fungibleTokens = fungibleTokens.filter(d => d.name != null || d.symbol != null);
107108
return [...nativeTokens, ...fungibleTokens];
108109
} catch (error) {
109110
console.error("Error fetching tokens:", error);

apps/dashboard/src/app/(dashboard)/hackweek/[chain_id]/[address]/actions/fetchTxActivity.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export async function fetchTxActivity(args: {
5151
limit_per_type?: number;
5252
page?: number;
5353
}): Promise<Transaction[]> {
54+
try {
5455
let { chainId, address, limit_per_type, page } = args;
5556
if (!limit_per_type) limit_per_type = 100;
5657
if (!page) page = 0;
@@ -83,4 +84,8 @@ export async function fetchTxActivity(args: {
8384
return [...outgoingTxsData.data, ...incomingTxsData.data].sort(
8485
(a, b) => b.block_number - a.block_number,
8586
);
87+
} catch (err) {
88+
console.log("Failed to fetch tx activity", err);
89+
return [];
90+
}
8691
}

apps/dashboard/src/app/(dashboard)/hackweek/[chain_id]/[address]/components/ActivityOverview.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import {
1010
} from "@/components/ui/table";
1111
import { TabButtons } from "@/components/ui/tabs";
1212
import { useState } from "react";
13+
import { formatDistanceToNow } from "date-fns";
1314

1415
interface Transaction {
1516
id: string;
1617
type: "out" | "in";
17-
amount: string;
18+
value: string;
1819
to?: string;
1920
from?: string;
20-
contract?: string;
2121
method?: string;
2222
date: string;
2323
}
@@ -85,24 +85,23 @@ export function ActivityOverview({
8585
<Table>
8686
<TableHeader>
8787
<TableRow>
88+
<TableHead>Tx Hash</TableHead>
8889
<TableHead>Type</TableHead>
8990
<TableHead>Amount</TableHead>
90-
<TableHead>Details</TableHead>
91+
<TableHead>From</TableHead>
92+
<TableHead>To</TableHead>
9193
<TableHead>Date</TableHead>
9294
</TableRow>
9395
</TableHeader>
9496
<TableBody>
9597
{currentTransactions.map((tx) => (
9698
<TableRow key={tx.id}>
99+
<TableCell>{tx.id.slice(0, 12)}...</TableCell>
97100
<TableCell>{tx.type}</TableCell>
98-
<TableCell>{tx.amount}</TableCell>
99-
<TableCell>
100-
{tx.to && `To: ${tx.to} `}
101-
{tx.from && `From: ${tx.from} `}
102-
{tx.contract && `Contract: ${tx.contract} `}
103-
{tx.method && ` Method: ${tx.method}`}
104-
</TableCell>
105-
<TableCell>{tx.date}</TableCell>
101+
<TableCell>{tx.value}</TableCell>
102+
<TableCell>{tx.from}</TableCell>
103+
<TableCell>{tx.to}</TableCell>
104+
<TableCell>{formatDistanceToNow(tx.date)}</TableCell>
106105
</TableRow>
107106
))}
108107
</TableBody>

apps/dashboard/src/app/(dashboard)/hackweek/[chain_id]/[address]/hooks/useGetTxActivity.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { useEffect, useState } from "react";
22
import { fetchTxActivity as getRecentTransactions } from "../actions/fetchTxActivity";
3+
import { toEther } from "thirdweb/utils";
34

45
export interface TransactionDetails {
56
id: string;
6-
type: "out" | "in";
7-
value: bigint;
7+
type: "in" | "out";
8+
value: string;
89
to?: string;
910
from?: string;
1011
method?: string;
@@ -24,7 +25,7 @@ export function useGetRecentTransactions(chainId: number, address: string) {
2425
return {
2526
id: tx.hash,
2627
type,
27-
value: BigInt(tx.value),
28+
value: toEther(BigInt(tx.value)).toString(),
2829
to: tx.to_address || undefined,
2930
from: tx.from_address,
3031
method: tx.function_selector || undefined,

0 commit comments

Comments
 (0)