@@ -8,6 +8,7 @@ import abi from "./abi/abi.json";
88import { parseEther } from "viem" ;
99import { citreaTestnet } from "./CitreaTestnet" ;
1010type Inputs = {
11+ fundingType : "ETH" | "ERC20" ;
1112 title : string ;
1213 url : string ;
1314 description : string ;
@@ -19,13 +20,15 @@ type Inputs = {
1920 ptaAmount : string ;
2021 rate : string ;
2122 developerPercentage : string ;
23+ fundingToken ?: `0x${string } `; // Add fundingToken for ERC20 vaults
2224} ;
2325
2426const Create = ( ) => {
2527 const { writeContractAsync } = useWriteContract ( ) ;
2628 const {
2729 register,
2830 handleSubmit,
31+ watch,
2932 formState : { errors, isSubmitting } ,
3033 } = useForm < Inputs > ( ) ;
3134 const onSubmit : SubmitHandler < Inputs > = async ( data ) => {
@@ -57,6 +60,7 @@ const Create = () => {
5760 timestamp ,
5861 data . rate ,
5962 data . withdrawAddress ,
63+ data . fundingType === "ETH" ? "0x0000000000000000000000000000000000000000" : data . fundingToken , // Handle native ETH
6064 "0x1bAab7d90eceB510f9424a41A86D9eA5ADce8717" ,
6165 "4" ,
6266 data . url ,
@@ -79,6 +83,39 @@ const Create = () => {
7983 < div className = "py-3 flex flex-col gap-2" >
8084 < h1 className = "text-2xl text-white" > Create new Funding Vault</ h1 >
8185 </ div >
86+ < div className = "mt-4" >
87+ < label className = "text-lg text-white font-medium " > Funding Type</ label >
88+ < div className = "flex gap-4 text-white mt-2" >
89+ < label className = "flex items-center gap-2 " >
90+ < input
91+ type = "radio"
92+ value = "ETH"
93+ { ...register ( "fundingType" , { required : true } ) }
94+ />
95+ Native ETH
96+ </ label >
97+ < label className = "flex items-center gap-2" >
98+ < input
99+ type = "radio"
100+ value = "ERC20"
101+ { ...register ( "fundingType" , { required : true } ) }
102+ />
103+ ERC20 Token
104+ </ label >
105+ </ div >
106+ </ div >
107+ { watch ( "fundingType" ) === "ERC20" && (
108+ < div className = "pt-4" >
109+ < label className = { `text-sm text-white` } > ERC20 Funding Token Address</ label >
110+ < input
111+ id = "fundingToken"
112+ placeholder = "Enter ERC20 token address"
113+ className = "bg-transparent p-2 text-sm w-full outline-none border border-slate-600 rounded-md text-white"
114+ { ...register ( "fundingToken" , { required : watch ( "fundingType" ) === "ERC20" } ) }
115+ />
116+ </ div >
117+
118+ ) }
82119
83120 < form onSubmit = { handleSubmit ( onSubmit ) } className = "text-white" >
84121 < div className = "grid grid-cols-1 md:grid-cols-2 gap-10 py-5" >
0 commit comments