@@ -2,6 +2,7 @@ import { useState, ChangeEvent } from 'react';
2
2
import { Container , Button , Stack , Text , TextField } from '@interchain-ui/react' ;
3
3
import { useChain } from '@interchain-kit/react' ;
4
4
import { useChainStore } from '@/contexts' ;
5
+ import { useToast } from '@/hooks' ;
5
6
6
7
export default function SignMessage ( ) {
7
8
const [ message , setMessage ] = useState ( '' ) ;
@@ -10,10 +11,15 @@ export default function SignMessage() {
10
11
const [ verifying , setVerifying ] = useState ( false ) ;
11
12
const { selectedChain } = useChainStore ( ) ;
12
13
const { address, wallet, chain } = useChain ( selectedChain ) ;
14
+ const { toast } = useToast ( ) ;
13
15
14
16
const handleSign = async ( ) => {
15
17
if ( ! wallet || ! address || ! chain . chainId ) {
16
- alert ( 'Please connect your wallet first' ) ;
18
+ toast ( {
19
+ title : 'Error' ,
20
+ description : 'Please connect your wallet first' ,
21
+ type : 'error'
22
+ } ) ;
17
23
return ;
18
24
}
19
25
@@ -24,7 +30,11 @@ export default function SignMessage() {
24
30
setSignature ( result . signature ) ;
25
31
} catch ( error ) {
26
32
console . error ( 'Error signing message:' , error ) ;
27
- alert ( 'Failed to sign message: ' + ( error instanceof Error ? error . message : String ( error ) ) ) ;
33
+ toast ( {
34
+ title : 'Error' ,
35
+ description : 'Failed to sign message: ' + ( error instanceof Error ? error . message : String ( error ) ) ,
36
+ type : 'error'
37
+ } ) ;
28
38
}
29
39
} ;
30
40
@@ -55,7 +65,11 @@ export default function SignMessage() {
55
65
setIsValid ( data . success ) ;
56
66
} catch ( error ) {
57
67
console . error ( 'Error verifying signature:' , error ) ;
58
- alert ( 'Failed to verify signature' ) ;
68
+ toast ( {
69
+ title : 'Error' ,
70
+ description : 'Failed to verify signature' ,
71
+ type : 'error'
72
+ } ) ;
59
73
} finally {
60
74
setVerifying ( false ) ;
61
75
}
0 commit comments