Skip to content

Commit 975eb6c

Browse files
committed
reolace alert with toast
1 parent 8ebd14f commit 975eb6c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

templates/chain-template/pages/sign-message.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useState, ChangeEvent } from 'react';
22
import { Container, Button, Stack, Text, TextField } from '@interchain-ui/react';
33
import { useChain } from '@interchain-kit/react';
44
import { useChainStore } from '@/contexts';
5+
import { useToast } from '@/hooks';
56

67
export default function SignMessage() {
78
const [message, setMessage] = useState('');
@@ -10,10 +11,15 @@ export default function SignMessage() {
1011
const [verifying, setVerifying] = useState(false);
1112
const { selectedChain } = useChainStore();
1213
const { address, wallet, chain } = useChain(selectedChain);
14+
const { toast } = useToast();
1315

1416
const handleSign = async () => {
1517
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+
});
1723
return;
1824
}
1925

@@ -24,7 +30,11 @@ export default function SignMessage() {
2430
setSignature(result.signature);
2531
} catch (error) {
2632
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+
});
2838
}
2939
};
3040

@@ -55,7 +65,11 @@ export default function SignMessage() {
5565
setIsValid(data.success);
5666
} catch (error) {
5767
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+
});
5973
} finally {
6074
setVerifying(false);
6175
}

0 commit comments

Comments
 (0)