File tree Expand file tree Collapse file tree 4 files changed +53
-8
lines changed
apps/dashboard/src/app/(dashboard)/hackweek/[chain_id]/[address] Expand file tree Collapse file tree 4 files changed +53
-8
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export async function fetchERC20Tokens(args: {
7575 lastTransferredDate :
7676 token . queried_wallet_balances [ 0 ] ?. last_transferred_date ,
7777 } ) ) ;
78- const fungibleTokens = data . fungibles . map ( ( token ) => ( {
78+ let fungibleTokens = data . fungibles . map ( ( token ) => ( {
7979 name : token . name ,
8080 symbol : token . symbol ,
8181 contractAddress : token . fungible_id . split ( "." ) [ 1 ] ?? "--" ,
@@ -90,6 +90,7 @@ export async function fetchERC20Tokens(args: {
9090 lastTransferredDate :
9191 token . queried_wallet_balances [ 0 ] ?. last_transferred_date ,
9292 } ) ) ;
93+ fungibleTokens = fungibleTokens . filter ( d => d . name != null || d . symbol != null ) ;
9394 return [ ...nativeTokens , ...fungibleTokens ] ;
9495 } catch ( error ) {
9596 console . error ( "Error fetching tokens:" , error ) ;
Original file line number Diff line number Diff line change @@ -86,4 +86,8 @@ export async function fetchRecentTransactions(args: {
8686 return [ ...outgoingTxsData . data , ...incomingTxsData . data ] . sort (
8787 ( a , b ) => b . block_number - a . block_number ,
8888 ) ;
89+ } catch ( err ) {
90+ console . log ( "Failed to fetch tx activity" , err ) ;
91+ return [ ] ;
92+ }
8993}
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import {
1111 TableRow ,
1212} from "@/components/ui/table" ;
1313import { TabButtons } from "@/components/ui/tabs" ;
14- import { formatDistanceToNow } from "date-fns" ;
1514import { ArrowLeft , ArrowRight , WalletIcon } from "lucide-react" ;
1615import { useState } from "react" ;
1716import type { ChainMetadata } from "thirdweb/chains" ;
@@ -68,12 +67,12 @@ export function ActivityOverview({
6867 isEnabled : true ,
6968 onClick : ( ) => setActiveTab ( "transactions" ) ,
7069 } ,
71- {
72- name : "Contracts" ,
73- isActive : activeTab === "contracts" ,
74- isEnabled : true ,
75- onClick : ( ) => setActiveTab ( "contracts" ) ,
76- } ,
70+ // {
71+ // name: "Contracts",
72+ // isActive: activeTab === "contracts",
73+ // isEnabled: true,
74+ // onClick: () => setActiveTab("contracts"),
75+ // },
7776 ] }
7877 tabClassName = "font-medium !text-sm"
7978 />
Original file line number Diff line number Diff line change 1+ import { useEffect , useState } from "react" ;
2+ import { fetchTxActivity as getRecentTransactions } from "../actions/fetchTxActivity" ;
3+ import { toEther } from "thirdweb/utils" ;
4+
5+ export interface TransactionDetails {
6+ id : string ;
7+ type : "in" | "out" ;
8+ value : string ;
9+ to ?: string ;
10+ from ?: string ;
11+ method ?: string ;
12+ date : string ;
13+ }
14+
15+ export function useGetRecentTransactions ( chainId : number , address : string ) {
16+ const [ txActivity , setTxActivity ] = useState < TransactionDetails [ ] > ( [ ] ) ;
17+ const [ isLoading , setIsLoading ] = useState ( true ) ;
18+
19+ useEffect ( ( ) => {
20+ ( async ( ) => {
21+ const response = await getRecentTransactions ( { chainId, address } ) ;
22+ const activity = response . map ( ( tx ) : TransactionDetails => {
23+ const type =
24+ tx . to_address ?. toLowerCase ( ) === address . toLowerCase ( ) ? "in" : "out" ;
25+ return {
26+ id : tx . hash ,
27+ type,
28+ value : toEther ( BigInt ( tx . value ) ) . toString ( ) ,
29+ to : tx . to_address || undefined ,
30+ from : tx . from_address ,
31+ method : tx . function_selector || undefined ,
32+ date : new Date ( tx . block_timestamp * 1000 ) . toLocaleString ( ) ,
33+ } ;
34+ } ) ;
35+ setTxActivity ( activity ) ;
36+ setIsLoading ( false ) ;
37+ } ) ( ) ;
38+ } , [ address , chainId ] ) ;
39+
40+ return { txActivity, isLoading } ;
41+ }
You can’t perform that action at this time.
0 commit comments