11import { zodResolver } from '@hookform/resolvers/zod' ;
22import { addSecrets } from '@lib/api/tunnels' ;
33import { getDevAddress , isUsingDevAddress } from '@lib/config' ;
4+ import { InteractionContextType , useInteractionContext } from '@lib/contexts/interaction' ;
45import { buildDeeployMessage } from '@lib/deeploy-utils' ;
56import { addSecretsSchema } from '@schemas/secrets' ;
67import { SlateCard } from '@shared/cards/SlateCard' ;
@@ -22,6 +23,8 @@ export default function TunnelingSecretsForm({
2223 onSuccess : ( secrets : TunnelingSecrets ) => void ;
2324 wrapInCard ?: boolean ;
2425} ) {
26+ const { openSignMessageModal, closeSignMessageModal } = useInteractionContext ( ) as InteractionContextType ;
27+
2528 const { address } = isUsingDevAddress ? getDevAddress ( ) : useAccount ( ) ;
2629 const { signMessageAsync } = useSignMessage ( ) ;
2730
@@ -51,11 +54,15 @@ export default function TunnelingSecretsForm({
5154 cloudflare_domain : data . domain ,
5255 } ) ;
5356
57+ openSignMessageModal ( ) ;
58+
5459 const signature = await signMessageAsync ( {
5560 account : address ,
5661 message,
5762 } ) ;
5863
64+ closeSignMessageModal ( ) ;
65+
5966 const payload = {
6067 nonce,
6168 EE_ETH_SIGN : signature ,
@@ -80,9 +87,16 @@ export default function TunnelingSecretsForm({
8087 } else {
8188 throw new Error ( response . result ?. error ) ;
8289 }
83- } catch ( error ) {
90+ } catch ( error : any ) {
8491 console . error ( '[TunnelingSecretsForm] Error adding secrets:' , error ) ;
85- toast . error ( 'Failed to add secrets, please try again.' ) ;
92+
93+ if ( error ?. message . includes ( 'User rejected the request' ) ) {
94+ toast . error ( 'Please sign the message to continue.' ) ;
95+ } else {
96+ toast . error ( 'Failed to add secrets, please try again.' ) ;
97+ }
98+
99+ closeSignMessageModal ( ) ;
86100 } finally {
87101 setLoading ( false ) ;
88102 }
0 commit comments