Skip to content

Commit 19a0c14

Browse files
committed
show access token for FTUX flow
1 parent 368c57d commit 19a0c14

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

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

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
import type { Project } from "@/api/projects";
33
import { type Step, StepsCard } from "components/dashboard/StepsCard";
44
import Link from "next/link";
5-
import { useMemo } from "react";
5+
import { useMemo, useState } from "react";
66
import { Button } from "../../../../../../../@/components/ui/button";
77
import CreateServerWallet from "../server-wallets/components/create-server-wallet.client";
88
import type { Wallet } from "../server-wallets/wallet-table/types";
99
import CreateVaultAccountButton from "../vault/components/create-vault-account.client";
1010
import { SendTestTransaction } from "./send-test-tx.client";
11+
import { CopyTextButton } from "@/components/ui/CopyTextButton";
12+
import { maskSecret } from "../lib/vault.client";
1113

1214
interface Props {
1315
managementAccessToken: string | undefined;
@@ -17,13 +19,20 @@ interface Props {
1719
}
1820

1921
export const EngineChecklist: React.FC<Props> = (props) => {
22+
const [userAccessToken, setUserAccessToken] = useState<string | undefined>();
23+
2024
const finalSteps = useMemo(() => {
2125
const steps: Step[] = [];
2226
steps.push({
2327
title: "Create a Vault Admin Account",
2428
description:
2529
"Your Vault admin account will be used to create server wallets and manage access tokens.",
26-
children: <CreateVaultAccountStep project={props.project} />,
30+
children: (
31+
<CreateVaultAccountStep
32+
project={props.project}
33+
onUserAccessTokenCreated={(token) => setUserAccessToken(token)}
34+
/>
35+
),
2736
completed: !!props.managementAccessToken,
2837
showCompletedChildren: false,
2938
});
@@ -45,7 +54,32 @@ export const EngineChecklist: React.FC<Props> = (props) => {
4554
title: "Send a Test Transaction",
4655
description: "Send a test transaction to see Engine in action.",
4756
children: (
48-
<SendTestTransaction wallets={props.wallets} project={props.project} />
57+
<>
58+
<div className="w-full py-4">
59+
{userAccessToken && (
60+
<div className="flex flex-col gap-2 ">
61+
<CopyTextButton
62+
textToCopy={userAccessToken}
63+
className="!h-auto w-full justify-between bg-background px-3 py-3 font-mono text-xs"
64+
textToShow={maskSecret(userAccessToken)}
65+
copyIconPosition="right"
66+
tooltip="Copy Vault Access Token"
67+
/>
68+
<p className="text-muted-foreground text-xs">
69+
This is the access token you just created. You need it to
70+
authorize every wallet action. You can create more access
71+
tokens with your admin key. Each access token can be scoped
72+
and permissioned with flexible policies. You can copy this one
73+
now to send a test transaction.
74+
</p>
75+
</div>
76+
)}
77+
</div>
78+
<SendTestTransaction
79+
wallets={props.wallets}
80+
project={props.project}
81+
/>
82+
</>
4983
),
5084
completed: props.hasTransactions,
5185
showIncompleteChildren: true,
@@ -57,6 +91,7 @@ export const EngineChecklist: React.FC<Props> = (props) => {
5791
props.project,
5892
props.wallets,
5993
props.hasTransactions,
94+
userAccessToken,
6095
]);
6196

6297
if (finalSteps.length === 1) {
@@ -68,7 +103,10 @@ export const EngineChecklist: React.FC<Props> = (props) => {
68103
);
69104
};
70105

71-
function CreateVaultAccountStep(props: { project: Project }) {
106+
function CreateVaultAccountStep(props: {
107+
project: Project;
108+
onUserAccessTokenCreated: (userAccessToken: string) => void;
109+
}) {
72110
return (
73111
<div className="mt-4 flex flex-col rounded-md border bg-background p-4">
74112
<p className="font-medium text-primary-foreground text-sm">
@@ -85,7 +123,10 @@ function CreateVaultAccountStep(props: { project: Project }) {
85123
<Link href="https://portal.thirdweb.com/engine/vault" target="_blank">
86124
<Button variant="outline">Learn more about Vault</Button>
87125
</Link>
88-
<CreateVaultAccountButton project={props.project} />
126+
<CreateVaultAccountButton
127+
project={props.project}
128+
onUserAccessTokenCreated={props.onUserAccessTokenCreated}
129+
/>
89130
</div>
90131
</div>
91132
);

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import {
2525
maskSecret,
2626
} from "../../lib/vault.client";
2727

28-
export default function CreateVaultAccountButton(props: { project: Project }) {
28+
export default function CreateVaultAccountButton(props: {
29+
project: Project;
30+
onUserAccessTokenCreated?: (userAccessToken: string) => void;
31+
}) {
2932
const [modalOpen, setModalOpen] = useState(false);
3033
const [keysConfirmed, setKeysConfirmed] = useState(false);
3134
const [keysDownloaded, setKeysDownloaded] = useState(false);
@@ -76,6 +79,8 @@ export default function CreateVaultAccountButton(props: { project: Project }) {
7679
throw new Error("Failed to create access token");
7780
}
7881

82+
props.onUserAccessTokenCreated?.(userAccessTokenRes.data.accessToken);
83+
7984
return {
8085
serviceAccount: serviceAccount.data,
8186
userAccessToken: userAccessTokenRes.data,

0 commit comments

Comments
 (0)