22import type { Project } from "@/api/projects" ;
33import { type Step , StepsCard } from "components/dashboard/StepsCard" ;
44import Link from "next/link" ;
5- import { useMemo } from "react" ;
5+ import { useMemo , useState } from "react" ;
66import { Button } from "../../../../../../../@/components/ui/button" ;
77import CreateServerWallet from "../server-wallets/components/create-server-wallet.client" ;
88import type { Wallet } from "../server-wallets/wallet-table/types" ;
99import CreateVaultAccountButton from "../vault/components/create-vault-account.client" ;
1010import { SendTestTransaction } from "./send-test-tx.client" ;
11+ import { CopyTextButton } from "@/components/ui/CopyTextButton" ;
12+ import { maskSecret } from "../lib/vault.client" ;
1113
1214interface Props {
1315 managementAccessToken : string | undefined ;
@@ -17,13 +19,20 @@ interface Props {
1719}
1820
1921export 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 ) ;
0 commit comments