Skip to content

Commit 4111d0e

Browse files
[Dashboard] Add error handling and refactor vault account rotation (#7592)
1 parent ffb7b64 commit 4111d0e

File tree

8 files changed

+272
-267
lines changed

8 files changed

+272
-267
lines changed

apps/dashboard/src/@/components/project/create-project-modal/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ const CreateProjectDialog = (props: CreateProjectDialogProps) => {
6767
await createVaultAccountAndAccessToken({
6868
project: res.project,
6969
projectSecretKey: res.secret,
70+
}).catch((error) => {
71+
console.error(
72+
"Failed to create vault account and access token",
73+
error,
74+
);
75+
throw error;
7076
});
7177
return {
7278
project: res.project,

apps/dashboard/src/@/hooks/useApi.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
22
import { useActiveAccount } from "thirdweb/react";
33
import { apiServerProxy } from "@/actions/proxies";
44
import type { Project } from "@/api/projects";
5-
import { createVaultAccountAndAccessToken } from "../../app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/lib/vault.client";
5+
import { rotateVaultAccountAndAccessToken } from "../../app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/lib/vault.client";
66
import { accountKeys, authorizedWallets } from "../query-keys/cache-keys";
77

88
// FIXME: We keep repeating types, API server should provide them
@@ -331,12 +331,17 @@ export async function rotateSecretKeyClient(params: { project: Project }) {
331331
}
332332

333333
try {
334-
// if the project has a vault admin key, rotate it as well
335-
await createVaultAccountAndAccessToken({
336-
project: params.project,
337-
projectSecretKey: res.data.data.secret,
338-
projectSecretHash: res.data.data.secretHash,
339-
});
334+
// if the project has an encrypted vault admin key, rotate it as well
335+
const service = params.project.services.find(
336+
(service) => service.name === "engineCloud",
337+
);
338+
if (service?.encryptedAdminKey) {
339+
await rotateVaultAccountAndAccessToken({
340+
project: params.project,
341+
projectSecretKey: res.data.data.secret,
342+
projectSecretHash: res.data.data.secretHash,
343+
});
344+
}
340345
} catch (error) {
341346
console.error("Failed to rotate vault admin key", error);
342347
}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/transactions/analytics/ftux.client.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
"use client";
2-
import Link from "next/link";
32
import { useMemo } from "react";
43
import type { ThirdwebClient } from "thirdweb";
54
import type { Project } from "@/api/projects";
65
import { type Step, StepsCard } from "@/components/blocks/StepsCard";
7-
import { Button } from "@/components/ui/button";
8-
import { CreateVaultAccountButton } from "../../vault/components/create-vault-account.client";
96
import CreateServerWallet from "../server-wallets/components/create-server-wallet.client";
107
import type { Wallet } from "../server-wallets/wallet-table/types";
118
import { SendTestTransaction } from "./send-test-tx.client";
@@ -97,27 +94,6 @@ export const EngineChecklist: React.FC<Props> = (props) => {
9794
);
9895
};
9996

100-
function CreateVaultAccountStep(props: {
101-
project: Project;
102-
teamSlug: string;
103-
onUserAccessTokenCreated: (userAccessToken: string) => void;
104-
}) {
105-
return (
106-
<div className="mt-4 flex flex-row gap-4">
107-
<CreateVaultAccountButton project={props.project} />
108-
<Button asChild variant="outline">
109-
<Link
110-
href="https://portal.thirdweb.com/vault"
111-
rel="noopener noreferrer"
112-
target="_blank"
113-
>
114-
Learn more about Vault
115-
</Link>
116-
</Button>
117-
</div>
118-
);
119-
}
120-
12197
function CreateServerWalletStep(props: {
12298
project: Project;
12399
teamSlug: string;

0 commit comments

Comments
 (0)