11"use client" ;
22
3+ import type { Project } from "@/api/projects" ;
34import { WalletAddress } from "@/components/blocks/wallet-address" ;
45import {
56 Table ,
@@ -11,11 +12,18 @@ import {
1112 TableRow ,
1213} from "@/components/ui/table" ;
1314import { ToolTipLabel } from "@/components/ui/tooltip" ;
15+ import { useQuery } from "@tanstack/react-query" ;
1416import { formatDistanceToNowStrict } from "date-fns" ;
1517import { format } from "date-fns/format" ;
18+ import {
19+ DEFAULT_ACCOUNT_FACTORY_V0_7 ,
20+ predictSmartAccountAddress ,
21+ } from "thirdweb/wallets/smart" ;
22+ import { Spinner } from "../../../../../../../@/components/ui/Spinner/Spinner" ;
23+ import { getThirdwebClient } from "../../../../../../../@/constants/thirdweb.server" ;
24+ import { useV5DashboardChain } from "../../../../../../../lib/v5-adapter" ;
1625import CreateServerWallet from "../components/create-server-wallet.client" ;
1726import type { Wallet } from "./types" ;
18- import type { Project } from "@/api/projects" ;
1927export function ServerWalletsTableUI ( {
2028 wallets,
2129 project,
@@ -48,7 +56,8 @@ export function ServerWalletsTableUI({
4856 < Table >
4957 < TableHeader >
5058 < TableRow >
51- < TableHead > Address</ TableHead >
59+ < TableHead > Signer</ TableHead >
60+ < TableHead > Smart Account</ TableHead >
5261 < TableHead > Created At</ TableHead >
5362 < TableHead > Updated At</ TableHead >
5463 </ TableRow >
@@ -66,6 +75,9 @@ export function ServerWalletsTableUI({
6675 < TableCell >
6776 < WalletAddress address = { wallet . address } />
6877 </ TableCell >
78+ < TableCell >
79+ < SmartAccountCell wallet = { wallet } />
80+ </ TableCell >
6981 < TableCell >
7082 < WalletDateCell date = { wallet . createdAt } />
7183 </ TableCell >
@@ -82,6 +94,34 @@ export function ServerWalletsTableUI({
8294 ) ;
8395}
8496
97+ function SmartAccountCell ( { wallet } : { wallet : Wallet } ) {
98+ const chainId = 1 ; // TODO: add chain switcher for balance + smart account address
99+ const chain = useV5DashboardChain ( chainId ) ;
100+
101+ const smartAccountAddressQuery = useQuery ( {
102+ queryKey : [ "smart-account-address" , wallet . address ] ,
103+ queryFn : async ( ) => {
104+ const smartAccountAddress = await predictSmartAccountAddress ( {
105+ client : getThirdwebClient ( ) ,
106+ adminAddress : wallet . address ,
107+ chain,
108+ factoryAddress : DEFAULT_ACCOUNT_FACTORY_V0_7 ,
109+ } ) ;
110+ return smartAccountAddress ;
111+ } ,
112+ } ) ;
113+
114+ return (
115+ < div >
116+ { smartAccountAddressQuery . data ? (
117+ < WalletAddress address = { smartAccountAddressQuery . data } />
118+ ) : (
119+ < Spinner className = "h-4 w-4" />
120+ ) }
121+ </ div >
122+ ) ;
123+ }
124+
85125function WalletDateCell ( { date } : { date : string } ) {
86126 if ( ! date ) {
87127 return "N/A" ;
0 commit comments