1
1
import React , { createContext , useState , useContext , useEffect } from "react" ;
2
2
3
+ export interface IToken {
4
+ symbol : string ;
5
+ address : string ;
6
+ logo : string ;
7
+ }
8
+
3
9
interface INewTransactionContext {
4
10
escrowType : string ;
5
11
setEscrowType : ( type : string ) => void ;
@@ -23,8 +29,8 @@ interface INewTransactionContext {
23
29
setSellerAddress : ( address : string ) => void ;
24
30
sendingQuantity : string ;
25
31
setSendingQuantity : ( quantity : string ) => void ;
26
- sendingToken : string ;
27
- setSendingToken : ( token : string ) => void ;
32
+ sendingToken : IToken ;
33
+ setSendingToken : ( token : IToken ) => void ;
28
34
buyerAddress : string ;
29
35
setBuyerAddress : ( address : string ) => void ;
30
36
deadline : string ;
@@ -61,7 +67,7 @@ const NewTransactionContext = createContext<INewTransactionContext>({
61
67
setSellerAddress : ( ) => { } ,
62
68
sendingQuantity : "" ,
63
69
setSendingQuantity : ( ) => { } ,
64
- sendingToken : "" ,
70
+ sendingToken : { address : "native" , symbol : "" , logo : "" } ,
65
71
setSendingToken : ( ) => { } ,
66
72
buyerAddress : "" ,
67
73
setBuyerAddress : ( ) => { } ,
@@ -93,7 +99,9 @@ export const NewTransactionProvider: React.FC<{ children: React.ReactNode }> = (
93
99
const [ receivingToken , setReceivingToken ] = useState < string > ( localStorage . getItem ( "receivingToken" ) || "" ) ;
94
100
const [ sellerAddress , setSellerAddress ] = useState < string > ( localStorage . getItem ( "sellerAddress" ) || "" ) ;
95
101
const [ sendingQuantity , setSendingQuantity ] = useState < string > ( localStorage . getItem ( "sendingQuantity" ) || "" ) ;
96
- const [ sendingToken , setSendingToken ] = useState < string > ( localStorage . getItem ( "sendingToken" ) || "" ) ;
102
+ const [ sendingToken , setSendingToken ] = useState < IToken > (
103
+ JSON . parse ( localStorage . getItem ( "sendingToken" ) ) || { address : "native" , symbol : "" , logo : "" }
104
+ ) ;
97
105
const [ buyerAddress , setBuyerAddress ] = useState < string > ( localStorage . getItem ( "buyerAddress" ) || "" ) ;
98
106
const [ isRecipientAddressResolved , setIsRecipientAddressResolved ] = useState ( false ) ;
99
107
const [ deadline , setDeadline ] = useState < string > ( localStorage . getItem ( "deadline" ) || "" ) ;
@@ -111,7 +119,7 @@ export const NewTransactionProvider: React.FC<{ children: React.ReactNode }> = (
111
119
setReceivingToken ( "" ) ;
112
120
setSellerAddress ( "" ) ;
113
121
setSendingQuantity ( "" ) ;
114
- setSendingToken ( "" ) ;
122
+ setSendingToken ( { address : "native" , symbol : "" , logo : "" } ) ;
115
123
setBuyerAddress ( "" ) ;
116
124
setDeadline ( "" ) ;
117
125
setNotificationEmail ( "" ) ;
@@ -128,7 +136,7 @@ export const NewTransactionProvider: React.FC<{ children: React.ReactNode }> = (
128
136
localStorage . setItem ( "receivingToken" , receivingToken ) ;
129
137
localStorage . setItem ( "buyerAddress" , buyerAddress ) ;
130
138
localStorage . setItem ( "sendingQuantity" , sendingQuantity ) ;
131
- localStorage . setItem ( "sendingToken" , sendingToken ) ;
139
+ localStorage . setItem ( "sendingToken" , JSON . stringify ( sendingToken ) ) ;
132
140
localStorage . setItem ( "sellerAddress" , sellerAddress ) ;
133
141
localStorage . setItem ( "deadline" , deadline ) ;
134
142
localStorage . setItem ( "notificationEmail" , notificationEmail ) ;
0 commit comments