88 DialogHeader ,
99 DialogTitle ,
1010} from "@/components/ui/dialog" ;
11- import { Form } from "@/components/ui/form" ;
11+ import { Form , FormDescription } from "@/components/ui/form" ;
1212import { Input } from "@/components/ui/input" ;
1313import {
1414 Select ,
@@ -50,6 +50,11 @@ export const CreateBackendWalletButton: React.FC<
5050 instance . url ,
5151 "HETEROGENEOUS_WALLET_TYPES" ,
5252 ) ;
53+ const { isSupported : supportsSmartBackendWallets } = useHasEngineFeature (
54+ instance . url ,
55+ "SMART_BACKEND_WALLETS" ,
56+ ) ;
57+
5358 const [ isOpen , setIsOpen ] = useState ( false ) ;
5459 const createWallet = useEngineCreateBackendWallet ( instance . url ) ;
5560 const trackEvent = useTrack ( ) ;
@@ -93,17 +98,22 @@ export const CreateBackendWalletButton: React.FC<
9398 invariant ( selectedOption , "Selected a valid backend wallet type." ) ;
9499
95100 // List all wallet types only if Engine is updated to support it.
96- const walletTypeOptions = supportsMultipleWalletTypes
97- ? EngineBackendWalletOptions
98- : [ selectedOption ] ;
101+ let walletTypeOptions = [ selectedOption ] ;
102+ if ( supportsSmartBackendWallets ) {
103+ walletTypeOptions = EngineBackendWalletOptions ;
104+ } else if ( supportsMultipleWalletTypes ) {
105+ walletTypeOptions = EngineBackendWalletOptions . filter (
106+ ( { key } ) => ! key . startsWith ( "smart:" ) ,
107+ ) ;
108+ }
99109
100110 const isAwsKmsConfigured = ! ! walletConfig . awsAccessKeyId ;
101111 const isGcpKmsConfigured = ! ! walletConfig . gcpKmsKeyRingId ;
102112
103- const isFormValid =
104- walletType === "local" ||
105- ( walletType === "aws-kms" && isAwsKmsConfigured ) ||
106- ( walletType === " gcp-kms" && isGcpKmsConfigured ) ;
113+ const isNotConfigured =
114+ ( [ "aws-kms" , "smart:aws-kms" ] . includes ( walletType ) &&
115+ ! isAwsKmsConfigured ) ||
116+ ( [ "gcp-kms" , "smart: gcp-kms"] . includes ( walletType ) && ! isGcpKmsConfigured ) ;
107117
108118 return (
109119 < >
@@ -154,6 +164,17 @@ export const CreateBackendWalletButton: React.FC<
154164 </ SelectGroup >
155165 </ SelectContent >
156166 </ Select >
167+
168+ < FormDescription className = "py-2" >
169+ Learn more about{ " " }
170+ < Link
171+ href = "https://portal.thirdweb.com/engine/features/backend-wallets"
172+ className = "text-link-foreground hover:text-foreground"
173+ >
174+ backend wallet types
175+ </ Link >
176+ .
177+ </ FormDescription >
157178 </ FormFieldSetup >
158179
159180 { ( walletType === "aws-kms" && ! isAwsKmsConfigured ) ||
@@ -186,14 +207,14 @@ export const CreateBackendWalletButton: React.FC<
186207 ?. message
187208 }
188209 htmlFor = "wallet-label"
189- isRequired = { false }
210+ isRequired
190211 tooltip = { null }
191212 >
192213 < Input
193214 id = "wallet-label"
194215 type = "text"
195216 placeholder = "A description to identify this backend wallet"
196- { ...form . register ( "label" ) }
217+ { ...form . register ( "label" , { required : true } ) }
197218 />
198219 </ FormFieldSetup >
199220 ) }
@@ -207,7 +228,11 @@ export const CreateBackendWalletButton: React.FC<
207228 < Button
208229 type = "submit"
209230 className = "min-w-28 gap-2"
210- disabled = { ! isFormValid || createWallet . isPending }
231+ disabled = {
232+ ! form . formState . isValid ||
233+ isNotConfigured ||
234+ createWallet . isPending
235+ }
211236 >
212237 { createWallet . isPending && < Spinner className = "size-4" /> }
213238 Create
0 commit comments