Skip to content

Commit 4cfcfbd

Browse files
show smart account address
1 parent 4e4b62e commit 4cfcfbd

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

apps/dashboard/src/app/team/[team_slug]/[project_slug]/transactions/server-wallets/wallet-table/wallet-table-ui.client.tsx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22

3+
import type { Project } from "@/api/projects";
34
import { WalletAddress } from "@/components/blocks/wallet-address";
45
import {
56
Table,
@@ -11,11 +12,18 @@ import {
1112
TableRow,
1213
} from "@/components/ui/table";
1314
import { ToolTipLabel } from "@/components/ui/tooltip";
15+
import { useQuery } from "@tanstack/react-query";
1416
import { formatDistanceToNowStrict } from "date-fns";
1517
import { 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";
1625
import CreateServerWallet from "../components/create-server-wallet.client";
1726
import type { Wallet } from "./types";
18-
import type { Project } from "@/api/projects";
1927
export 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+
85125
function WalletDateCell({ date }: { date: string }) {
86126
if (!date) {
87127
return "N/A";

0 commit comments

Comments
 (0)