-
Notifications
You must be signed in to change notification settings - Fork 618
[Dashboard] Move server wallet sections to wallets tab #8174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||
| import { createVaultClient, listEoas } from "@thirdweb-dev/vault-sdk"; | ||||||||
| import { redirect } from "next/navigation"; | ||||||||
| import { ResponsiveSearchParamsProvider } from "responsive-rsc"; | ||||||||
| import { getAuthToken } from "@/api/auth-token"; | ||||||||
|
|
@@ -6,10 +7,13 @@ import type { DurationId } from "@/components/analytics/date-range-selector"; | |||||||
| import { ResponsiveTimeFilters } from "@/components/analytics/responsive-time-filters"; | ||||||||
| import { ProjectPage } from "@/components/blocks/project-page/project-page"; | ||||||||
| import { InAppWalletUsersPageContent } from "@/components/in-app-wallet-users-content/in-app-wallet-users-content"; | ||||||||
| import { NEXT_PUBLIC_THIRDWEB_VAULT_URL } from "@/constants/public-envs"; | ||||||||
| import { getClientThirdwebClient } from "@/constants/thirdweb-client.client"; | ||||||||
| import { WalletProductIcon } from "@/icons/WalletProductIcon"; | ||||||||
| import { getFiltersFromSearchParams } from "@/lib/time"; | ||||||||
| import { loginRedirect } from "@/utils/redirects"; | ||||||||
| import type { Wallet } from "../transactions/server-wallets/wallet-table/types"; | ||||||||
| import { ServerWalletsTable } from "../transactions/server-wallets/wallet-table/wallet-table"; | ||||||||
| import { InAppWalletAnalytics } from "./analytics/chart"; | ||||||||
| import { InAppWalletsSummary } from "./analytics/chart/Summary"; | ||||||||
|
|
||||||||
|
|
@@ -20,6 +24,7 @@ export default async function Page(props: { | |||||||
| to?: string; | ||||||||
| type?: string; | ||||||||
| interval?: string; | ||||||||
| page?: string; | ||||||||
| }>; | ||||||||
| }) { | ||||||||
| const [searchParams, params] = await Promise.all([ | ||||||||
|
|
@@ -40,12 +45,47 @@ export default async function Page(props: { | |||||||
| to: searchParams.to, | ||||||||
| }); | ||||||||
|
|
||||||||
| const project = await getProject(params.team_slug, params.project_slug); | ||||||||
| const [vaultClient, project] = await Promise.all([ | ||||||||
| createVaultClient({ | ||||||||
| baseUrl: NEXT_PUBLIC_THIRDWEB_VAULT_URL, | ||||||||
| }).catch(() => undefined), | ||||||||
| getProject(params.team_slug, params.project_slug), | ||||||||
| ]); | ||||||||
|
|
||||||||
| if (!project) { | ||||||||
| redirect(`/team/${params.team_slug}`); | ||||||||
| } | ||||||||
|
|
||||||||
| const projectEngineCloudService = project.services.find( | ||||||||
| (service) => service.name === "engineCloud", | ||||||||
| ); | ||||||||
|
|
||||||||
| const managementAccessToken = | ||||||||
| projectEngineCloudService?.managementAccessToken; | ||||||||
|
|
||||||||
| // Fetch server wallets with pagination (5 per page) | ||||||||
| const pageSize = 5; | ||||||||
| const currentPage = Number.parseInt(searchParams.page ?? "1"); | ||||||||
|
|
||||||||
| const eoas = | ||||||||
| vaultClient && managementAccessToken | ||||||||
| ? await listEoas({ | ||||||||
| client: vaultClient, | ||||||||
| request: { | ||||||||
| auth: { | ||||||||
| accessToken: managementAccessToken, | ||||||||
| }, | ||||||||
| options: { | ||||||||
| page: currentPage - 1, | ||||||||
| // @ts-expect-error - TODO: fix this | ||||||||
| page_size: pageSize, | ||||||||
|
Comment on lines
+80
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
Spotted by Diamond This comment came from an experimental review—please leave feedback if it was helpful/unhelpful. Learn more about experimental comments here. |
||||||||
| }, | ||||||||
| }, | ||||||||
| }) | ||||||||
| : { data: { items: [], totalRecords: 0 }, error: null, success: true }; | ||||||||
|
|
||||||||
| const serverWallets = eoas.data?.items as Wallet[] | undefined; | ||||||||
|
|
||||||||
| const client = getClientThirdwebClient({ | ||||||||
| jwt: authToken, | ||||||||
| teamId: project.teamId, | ||||||||
|
|
@@ -103,12 +143,34 @@ export default async function Page(props: { | |||||||
| authToken={authToken} | ||||||||
| /> | ||||||||
|
|
||||||||
| <InAppWalletUsersPageContent | ||||||||
| authToken={authToken} | ||||||||
| client={client} | ||||||||
| projectClientId={project.publishableKey} | ||||||||
| teamId={project.teamId} | ||||||||
| /> | ||||||||
| {/* Server Wallets Section */} | ||||||||
| <div className="flex flex-col gap-4"> | ||||||||
| {eoas.error ? null : ( | ||||||||
| <ServerWalletsTable | ||||||||
| client={client} | ||||||||
| currentPage={currentPage} | ||||||||
| managementAccessToken={managementAccessToken ?? undefined} | ||||||||
| project={project} | ||||||||
| teamSlug={params.team_slug} | ||||||||
| totalPages={Math.ceil(eoas.data.totalRecords / pageSize)} | ||||||||
| totalRecords={eoas.data.totalRecords} | ||||||||
| wallets={serverWallets ?? []} | ||||||||
| /> | ||||||||
| )} | ||||||||
| </div> | ||||||||
|
|
||||||||
| {/* User Wallets Section */} | ||||||||
| <div className="flex flex-col gap-4"> | ||||||||
| <h2 className="font-semibold text-2xl tracking-tight"> | ||||||||
| User wallets | ||||||||
| </h2> | ||||||||
| <InAppWalletUsersPageContent | ||||||||
| authToken={authToken} | ||||||||
| client={client} | ||||||||
| projectClientId={project.publishableKey} | ||||||||
| teamId={project.teamId} | ||||||||
| /> | ||||||||
| </div> | ||||||||
| </div> | ||||||||
| </ProjectPage> | ||||||||
| </ResponsiveSearchParamsProvider> | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix vault client fallback when env is unset.
Passing
baseUrlas an empty string makescreateVaultClientthrow (the URL constructor rejects""), so we silently fall back tovaultClient = undefinedand the server wallet list never loads unless the env var is set. Coerce the value toundefinedso the SDK’s default base URL is used when the env is absent.📝 Committable suggestion
🤖 Prompt for AI Agents