33import { AlertCircle , CheckCircle2 , Loader2 , Wallet } from "lucide-react" ;
44import { useEffect , useState } from "react" ;
55import { toast } from "sonner" ;
6- import { type Address , isAddress } from "viem" ;
6+ import { type Address , isAddress , parseEther } from "viem" ;
77import { useAccount } from "wagmi" ;
88import { Button } from "@/components/ui/button" ;
99import {
@@ -36,6 +36,7 @@ export function WalletDeployment({
3636
3737 const [ entryPointAddress , setEntryPointAddress ] = useState < string > ( "" ) ;
3838 const [ verifierAddress , setVerifierAddress ] = useState < string > ( "" ) ;
39+ const [ initialFunding , setInitialFunding ] = useState < string > ( "" ) ;
3940 const [ deployedWallet , setDeployedWallet ] = useState < Address | null > ( null ) ;
4041
4142 // Load default addresses on mount
@@ -86,11 +87,16 @@ export function WalletDeployment({
8687 verifierAddress : verifierAddress as Address ,
8788 ownerAddress : userAddress ,
8889 initialSecretHash : secretHash ,
90+ initialFunding : initialFunding ? parseEther ( initialFunding ) : undefined ,
8991 } ) ;
9092
9193 if ( walletAddress ) {
9294 setDeployedWallet ( walletAddress ) ;
93- toast . success ( "Wallet deployed successfully!" ) ;
95+ toast . success (
96+ initialFunding
97+ ? "Wallet deployed and funded successfully!"
98+ : "Wallet deployed successfully!" ,
99+ ) ;
94100 onDeployed ?.( walletAddress ) ;
95101 }
96102 } catch ( error ) {
@@ -249,6 +255,24 @@ export function WalletDeployment({
249255 />
250256 </ div >
251257 ) }
258+
259+ < div className = "space-y-2" >
260+ < Label htmlFor = "funding" > Initial Funding (ETH) - Optional</ Label >
261+ < Input
262+ id = "funding"
263+ type = "number"
264+ step = "0.001"
265+ min = "0"
266+ placeholder = "0.1"
267+ value = { initialFunding }
268+ onChange = { ( e ) => setInitialFunding ( e . target . value ) }
269+ disabled = { isDeploying || ! secretHash }
270+ />
271+ < p className = "text-xs text-muted-foreground" >
272+ Fund your wallet during deployment to skip the separate funding
273+ step. Recommended: 0.01 ETH or more for gas fees
274+ </ p >
275+ </ div >
252276 </ CardContent >
253277 < CardFooter >
254278 < Button
@@ -259,12 +283,14 @@ export function WalletDeployment({
259283 { isDeploying ? (
260284 < >
261285 < Loader2 className = "mr-2 h-4 w-4 animate-spin" />
262- Deploying Wallet...
286+ { initialFunding
287+ ? "Deploying & Funding..."
288+ : "Deploying Wallet..." }
263289 </ >
264290 ) : (
265291 < >
266292 < Wallet className = "mr-2 h-4 w-4" />
267- Deploy Wallet
293+ { initialFunding ? " Deploy & Fund Wallet" : "Deploy Wallet" }
268294 </ >
269295 ) }
270296 </ Button >
0 commit comments