1
1
import { getAddress } from "viem" ;
2
- import {
3
- addToStore ,
4
- getFromStore ,
5
- removeFromStore ,
6
- StorageKey ,
7
- } from "./storage" ;
2
+ import { addToStore , getFromStore , StorageKey } from "./storage" ;
8
3
import { getWalletClient } from "./wallet" ;
9
4
10
5
const API_URL = "http://localhost:3210" ;
@@ -27,13 +22,18 @@ const submitAction = async (transition: string, inputs: any) => {
27
22
const { domain, schemas } = mruInfo ;
28
23
const msgSender = getAddress ( walletClient . account . address ) ;
29
24
30
- const signature = await walletClient . signTypedData ( {
31
- domain,
32
- primaryType : schemas [ transition ] . primaryType ,
33
- types : schemas [ transition ] . types ,
34
- message : inputs ,
35
- account : msgSender ,
36
- } ) ;
25
+ let signature ;
26
+ try {
27
+ signature = await walletClient . signTypedData ( {
28
+ domain,
29
+ primaryType : schemas [ transition ] . primaryType ,
30
+ types : schemas [ transition ] . types ,
31
+ message : inputs ,
32
+ account : msgSender ,
33
+ } ) ;
34
+ } catch ( e ) {
35
+ console . error ( "Error signing message" , e ) ;
36
+ }
37
37
38
38
const response = await fetch ( `${ API_URL } /${ transition } ` , {
39
39
method : "POST" ,
@@ -52,7 +52,6 @@ const submitAction = async (transition: string, inputs: any) => {
52
52
53
53
const endGame = async ( inputs : any ) => {
54
54
await submitAction ( "endGame" , inputs ) ;
55
- removeFromStore ( StorageKey . GAME_ID ) ;
56
55
} ;
57
56
58
57
const startGame = async ( ) => {
0 commit comments