1
+ import config from 'config' ;
1
2
import { TransactionLocal } from 'config/types' ;
2
3
import { isEmptyObject } from 'utils' ;
3
4
4
- const LOCAL_STORAGE_KEY = 'wormhole-connect: transactions:inprogress' ;
5
+ const LOCAL_STORAGE_KEY = 'transactions:inprogress' ;
5
6
const LOCAL_STORAGE_MAX = 3 ;
6
7
7
8
// Bigint types cannot be serialized to a string
@@ -112,7 +113,10 @@ export const getTxsFromLocalStorage = ():
112
113
// Find the in-progress transactions list in localStorage
113
114
for ( let i = 0 ; i < ls . length ; i ++ ) {
114
115
const itemKey = ls . key ( i ) ;
115
- if ( itemKey ?. toLowerCase ( ) === LOCAL_STORAGE_KEY ) {
116
+ if (
117
+ itemKey ?. toLowerCase ( ) ===
118
+ config . cacheKey ( LOCAL_STORAGE_KEY ) . toLowerCase ( )
119
+ ) {
116
120
const item = ls . getItem ( itemKey ) ;
117
121
if ( item ) {
118
122
try {
@@ -124,7 +128,7 @@ export const getTxsFromLocalStorage = ():
124
128
`Error while parsing localStorage item ${ LOCAL_STORAGE_KEY } : Not an array of valid transactions` ,
125
129
) ;
126
130
// Remove invalid transactions entry
127
- ls . removeItem ( LOCAL_STORAGE_KEY ) ;
131
+ ls . removeItem ( config . cacheKey ( LOCAL_STORAGE_KEY ) ) ;
128
132
return ;
129
133
}
130
134
} catch ( e : any ) {
@@ -135,7 +139,7 @@ export const getTxsFromLocalStorage = ():
135
139
`Error while parsing localStorage item ${ LOCAL_STORAGE_KEY } : ${ e } ` ,
136
140
) ;
137
141
// Remove item
138
- ls . removeItem ( LOCAL_STORAGE_KEY ) ;
142
+ ls . removeItem ( config . cacheKey ( LOCAL_STORAGE_KEY ) ) ;
139
143
return ;
140
144
}
141
145
}
@@ -167,7 +171,10 @@ export const addTxToLocalStorage = (
167
171
168
172
// Update the list
169
173
try {
170
- ls . setItem ( LOCAL_STORAGE_KEY , JSON . stringify ( newList , JSONReplacer ) ) ;
174
+ ls . setItem (
175
+ config . cacheKey ( LOCAL_STORAGE_KEY ) ,
176
+ JSON . stringify ( newList , JSONReplacer ) ,
177
+ ) ;
171
178
} catch ( e : any ) {
172
179
// We can get two different errors:
173
180
// 1- TypeError from JSON.stringify
@@ -191,7 +198,10 @@ export const removeTxFromLocalStorage = (txHash: string) => {
191
198
// remove the item and update localStorage
192
199
items . splice ( removeIndex , 1 ) ;
193
200
try {
194
- ls . setItem ( LOCAL_STORAGE_KEY , JSON . stringify ( items , JSONReplacer ) ) ;
201
+ ls . setItem (
202
+ config . cacheKey ( LOCAL_STORAGE_KEY ) ,
203
+ JSON . stringify ( items , JSONReplacer ) ,
204
+ ) ;
195
205
} catch ( e : any ) {
196
206
// We can get two different errors:
197
207
// 1- TypeError from JSON.stringify
@@ -221,7 +231,10 @@ export const updateTxInLocalStorage = (
221
231
// Update item property and put back in local storage
222
232
items [ idx ] [ key ] = value ;
223
233
try {
224
- ls . setItem ( LOCAL_STORAGE_KEY , JSON . stringify ( items , JSONReplacer ) ) ;
234
+ ls . setItem (
235
+ config . cacheKey ( LOCAL_STORAGE_KEY ) ,
236
+ JSON . stringify ( items , JSONReplacer ) ,
237
+ ) ;
225
238
} catch ( e : any ) {
226
239
// We can get two different errors:
227
240
// 1- TypeError from JSON.stringify
0 commit comments