@@ -11,7 +11,6 @@ import {
1111 SelectTrigger ,
1212 SelectValue ,
1313} from "@/components/ui/select" ;
14- import { THIRDWEB_ENGINE_CLOUD_URL } from "@/constants/env" ;
1514import { useThirdwebClient } from "@/constants/thirdweb.client" ;
1615import { zodResolver } from "@hookform/resolvers/zod" ;
1716import { useMutation , useQueryClient } from "@tanstack/react-query" ;
@@ -22,9 +21,9 @@ import { toast } from "sonner";
2221import { shortenAddress } from "thirdweb/utils" ;
2322import * as z from "zod" ;
2423import type { Wallet } from "../server-wallets/wallet-table/types" ;
24+ import { engineCloudProxy } from "@/actions/proxies" ;
2525
2626const formSchema = z . object ( {
27- projectSecretKey : z . string ( ) . min ( 1 , "Project secret key is required" ) ,
2827 accessToken : z . string ( ) . min ( 1 , "Access token is required" ) ,
2928 walletIndex : z . string ( ) ,
3029 chainId : z . number ( ) ,
@@ -44,7 +43,6 @@ export function SendTestTransaction(props: {
4443 const form = useForm < FormValues > ( {
4544 resolver : zodResolver ( formSchema ) ,
4645 defaultValues : {
47- projectSecretKey : "" ,
4846 accessToken : "" ,
4947 walletIndex : "0" ,
5048 chainId : 84532 ,
@@ -60,36 +58,36 @@ export function SendTestTransaction(props: {
6058 accessToken : string ;
6159 chainId : number ;
6260 } ) => {
63- const response = await fetch (
64- `${ THIRDWEB_ENGINE_CLOUD_URL } /write/transaction` ,
65- {
66- method : "POST" ,
67- headers : {
68- "Content-Type" : "application/json" ,
69- "x-secret-key" : form . getValues ( "projectSecretKey" ) ,
70- "x-vault-access-token" : args . accessToken ,
61+ const response = await engineCloudProxy ( {
62+ pathname : "/write/transaction" ,
63+ method : "POST" ,
64+ headers : {
65+ "Content-Type" : "application/json" ,
66+ "x-team-id" : props . project . teamId ,
67+ "x-client-id" : props . project . publishableKey ,
68+ "x-vault-access-token" : args . accessToken ,
69+ } ,
70+ body : JSON . stringify ( {
71+ executionOptions : {
72+ type : "AA" ,
73+ signerAddress : args . walletAddress ,
74+ chainId : args . chainId . toString ( ) ,
7175 } ,
72- body : JSON . stringify ( {
73- executionOptions : {
74- type : "AA" ,
75- signerAddress : args . walletAddress ,
76- chainId : args . chainId . toString ( ) ,
76+ params : [
77+ {
78+ to : args . walletAddress ,
79+ value : "0" ,
7780 } ,
78- params : [
79- {
80- to : args . walletAddress ,
81- value : "0" ,
82- } ,
83- ] ,
84- } ) ,
85- } ,
86- ) ;
87- const result = await response . json ( ) ;
81+ ] ,
82+ } ) ,
83+ } ) ;
84+
8885 if ( ! response . ok ) {
89- const errorMsg = result ? .error ?. message || "Failed to send transaction" ;
86+ const errorMsg = response . error ?? "Failed to send transaction" ;
9087 throw new Error ( errorMsg ) ;
9188 }
92- return result ;
89+
90+ return response . data ;
9391 } ,
9492 onSuccess : ( ) => {
9593 toast . success ( "Test transaction sent successfully!" ) ;
@@ -146,24 +144,11 @@ export function SendTestTransaction(props: {
146144 className = "space-y-4 px-3 pb-3"
147145 >
148146 < p className = "flex items-center gap-2 text-sm text-warning-text" >
149- < LockIcon className = "h-4 w-4" /> This action requires a project
150- secret key and a vault access token.
147+ < LockIcon className = "h-4 w-4" /> This action requires your vault
148+ access token.
151149 </ p >
152150 { /* Responsive container */ }
153151 < div className = "flex flex-col gap-2 md:flex-row md:items-end md:gap-2" >
154- < div className = "flex-grow" >
155- < div className = "flex flex-col gap-2" >
156- < p className = "text-sm" > Project Secret Key</ p >
157- < Input
158- id = "secret-key"
159- type = "password"
160- placeholder = "abcd....1234"
161- { ...form . register ( "projectSecretKey" ) }
162- disabled = { isLoading }
163- className = "text-xs"
164- />
165- </ div >
166- </ div >
167152 < div className = "flex-grow" >
168153 < div className = "flex flex-col gap-2" >
169154 < p className = "text-sm" > Vault Access Token</ p >
0 commit comments