Skip to content

Commit 3ee95db

Browse files
separate admin key / access token flow in FTUX
1 parent 1ffe89b commit 3ee95db

File tree

4 files changed

+45
-34
lines changed

4 files changed

+45
-34
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/engine/cloud/analytics/send-test-tx.client.tsx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useThirdwebClient } from "@/constants/thirdweb.client";
1515
import { useDashboardRouter } from "@/lib/DashboardRouter";
1616
import { zodResolver } from "@hookform/resolvers/zod";
1717
import { useMutation, useQueryClient } from "@tanstack/react-query";
18-
import { Loader2, LockIcon } from "lucide-react";
18+
import { Loader2Icon, LockIcon } from "lucide-react";
1919
import { useState } from "react";
2020
import { useForm } from "react-hook-form";
2121
import { toast } from "sonner";
@@ -26,6 +26,7 @@ import {
2626
sepolia,
2727
} from "thirdweb/chains";
2828
import * as z from "zod";
29+
import { CopyTextButton } from "../../../../../../../../@/components/ui/CopyTextButton";
2930
import { useTrack } from "../../../../../../../../hooks/analytics/useTrack";
3031
import type { Wallet } from "../server-wallets/wallet-table/types";
3132
import { SmartAccountCell } from "../server-wallets/wallet-table/wallet-table-ui.client";
@@ -146,30 +147,40 @@ export function SendTestTransaction(props: {
146147
)}
147148
<p className="flex items-center gap-2 text-sm text-warning-text">
148149
<LockIcon className="h-4 w-4" />
149-
Every wallet action requires your Vault access token.
150+
{props.userAccessToken
151+
? "Copy your Vault access token, you'll need it for every HTTP call to Engine."
152+
: "Every wallet action requires your Vault access token."}
150153
</p>
151154
<div className="h-4" />
152155
{/* Responsive container */}
153156
<div className="flex flex-col gap-2 md:flex-row md:items-end md:gap-2">
154157
<div className="flex-grow">
155158
<div className="flex flex-col gap-2">
156159
<p className="text-sm">Vault Access Token</p>
157-
<Input
158-
id="access-token"
159-
type={props.userAccessToken ? "text" : "password"}
160-
placeholder="vt_act_1234....ABCD"
161-
{...form.register("accessToken")}
162-
disabled={isLoading}
163-
className="text-xs"
164-
/>
165-
{props.userAccessToken && (
160+
{props.userAccessToken ? (
166161
<div className="flex flex-col gap-2 ">
162+
<CopyTextButton
163+
copyIconPosition="right"
164+
textToCopy={props.userAccessToken}
165+
textToShow={props.userAccessToken}
166+
tooltip="Copy Vault Access Token"
167+
className="!h-auto w-full justify-between bg-background px-3 py-3 font-mono text-xs"
168+
/>
167169
<p className="text-muted-foreground text-xs">
168-
This is the project-wide access token you just created. You
169-
can create more access tokens using your admin key, with
170-
granular scopes and permissions.
170+
This is a project-wide access token to access your server
171+
wallets. You can create more access tokens using your admin
172+
key, with granular scopes and permissions.
171173
</p>
172174
</div>
175+
) : (
176+
<Input
177+
id="access-token"
178+
type={props.userAccessToken ? "text" : "password"}
179+
placeholder="vt_act_1234....ABCD"
180+
{...form.register("accessToken")}
181+
disabled={isLoading}
182+
className="text-xs"
183+
/>
173184
)}
174185
</div>
175186
</div>
@@ -257,7 +268,7 @@ export function SendTestTransaction(props: {
257268
>
258269
{isLoading ? (
259270
<>
260-
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
271+
<Loader2Icon className="mr-2 h-4 w-4 animate-spin" />
261272
Sending...
262273
</>
263274
) : (

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/engine/cloud/vault/components/create-vault-account.client.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useDashboardRouter } from "@/lib/DashboardRouter";
1515
import { cn } from "@/lib/utils";
1616
import { useMutation } from "@tanstack/react-query";
1717
import { createServiceAccount } from "@thirdweb-dev/vault-sdk";
18-
import { CheckIcon, DownloadIcon, Loader2, LockIcon } from "lucide-react";
18+
import { CheckIcon, DownloadIcon, Loader2Icon, LockIcon } from "lucide-react";
1919
import { useState } from "react";
2020
import { toast } from "sonner";
2121
import { useTrack } from "../../../../../../../../../hooks/analytics/useTrack";
@@ -150,7 +150,7 @@ export default function CreateVaultAccountButton(props: {
150150
className="flex flex-row items-center gap-2"
151151
>
152152
{isLoading ? (
153-
<Loader2 className="animate-spin" />
153+
<Loader2Icon className="size-4 animate-spin" />
154154
) : (
155155
<LockIcon className="size-4" />
156156
)}
@@ -177,19 +177,16 @@ export default function CreateVaultAccountButton(props: {
177177
) : initialiseProjectWithVaultMutation.data ? (
178178
<div>
179179
<DialogHeader className="p-6">
180-
<DialogTitle>Vault Management Keys</DialogTitle>
180+
<DialogTitle>Save your Vault Admin Key</DialogTitle>
181181
<p className="text-muted-foreground text-sm">
182-
These keys are used for end-to-end encryption and are required
183-
to interact with Vault, thirdweb's key management system.
182+
You'll need this key to create server wallets and access
183+
tokens.
184184
</p>
185185
</DialogHeader>
186186

187187
<div className="space-y-6 p-6 pt-0">
188188
<div className="space-y-4">
189189
<div>
190-
<h3 className="mb-2 font-medium text-sm">
191-
Vault Admin Key
192-
</h3>
193190
<div className="flex flex-col gap-2">
194191
<CopyTextButton
195192
textToCopy={
@@ -205,12 +202,13 @@ export default function CreateVaultAccountButton(props: {
205202
tooltip="Copy Admin Key"
206203
/>
207204
<p className="text-muted-foreground text-xs">
208-
This key is used to create or revoke your access tokens.
205+
Download this key to your local machine or a password
206+
manager.
209207
</p>
210208
</div>
211209
</div>
212210

213-
<div>
211+
{/* <div>
214212
<h3 className="mb-2 font-medium text-sm">
215213
Vault Access Token
216214
</h3>
@@ -234,10 +232,10 @@ export default function CreateVaultAccountButton(props: {
234232
with your admin key.
235233
</p>
236234
</div>
237-
</div>
235+
</div> */}
238236
</div>
239237
<Alert variant="destructive">
240-
<AlertTitle>Secure your keys</AlertTitle>
238+
<AlertTitle>Secure your admin key</AlertTitle>
241239
<AlertDescription>
242240
These keys will not be displayed again. Store them securely
243241
as they provide access to your server wallets.
@@ -250,7 +248,7 @@ export default function CreateVaultAccountButton(props: {
250248
className="flex h-auto items-center gap-2 p-0 text-sm text-success-text"
251249
>
252250
<DownloadIcon className="size-4" />
253-
{keysDownloaded ? "Keys Downloaded" : "Download Keys"}
251+
{keysDownloaded ? "Key Downloaded" : "Download Admin Key"}
254252
</Button>
255253
{keysDownloaded && (
256254
<span className="text-success-text text-xs">
@@ -264,7 +262,7 @@ export default function CreateVaultAccountButton(props: {
264262
checked={keysConfirmed}
265263
onCheckedChange={(v) => setKeysConfirmed(!!v)}
266264
/>
267-
I confirm that I've securely stored these keys
265+
I confirm that I've securely stored my admin key
268266
</CheckboxWithLabel>
269267
</Alert>
270268
</div>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/engine/cloud/vault/components/list-access-tokens.client.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Input } from "@/components/ui/input";
1414
import { Skeleton } from "@/components/ui/skeleton";
1515
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
1616
import { listAccessTokens, revokeAccessToken } from "@thirdweb-dev/vault-sdk";
17-
import { Loader2, LockIcon, Trash2 } from "lucide-react";
17+
import { Loader2Icon, LockIcon, Trash2Icon } from "lucide-react";
1818
import { useState } from "react";
1919
import { toast } from "sonner";
2020
import { toDateTimeLocal } from "utils/date-utils";
@@ -227,7 +227,10 @@ export default function ListAccessTokens(props: {
227227
{token.accessToken.includes("**") ? (
228228
<div className="flex flex-grow flex-row items-center gap-2 rounded-lg border border-border bg-background px-4 py-3 font-mono text-sm">
229229
<p className="text-muted-foreground text-sm">
230-
{token.accessToken}
230+
{token.accessToken}{" "}
231+
<span className="text-muted-foreground text-xs">
232+
(unlock vault to reveal the full token)
233+
</span>
231234
</p>
232235
</div>
233236
) : (
@@ -258,7 +261,7 @@ export default function ListAccessTokens(props: {
258261
{deletingTokenId === token.id ? (
259262
<Loader2 className="h-4 w-4 animate-spin" />
260263
) : (
261-
<Trash2 className="h-4 w-4" />
264+
<Trash2Icon className="h-4 w-4" />
262265
)}
263266
</Button>
264267
</div>
@@ -291,7 +294,7 @@ export default function ListAccessTokens(props: {
291294
>
292295
{createAccessTokenMutation.isPending ? (
293296
<>
294-
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
297+
<Loader2Icon className="mr-2 size-4 animate-spin" />
295298
Creating new access token...
296299
</>
297300
) : (

packages/thirdweb/src/engine/server-wallet.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ describe.runIf(
8585
tokenId: 0n,
8686
quantity: 1n,
8787
});
88-
console.time("enqueue");
8988
const result = await serverWallet.enqueueTransaction({
9089
transaction: claimTx,
9190
});

0 commit comments

Comments
 (0)