@@ -127,43 +127,46 @@ export interface TransferInputState {
127
127
supportedDestTokens : TokenConfig [ ] ;
128
128
}
129
129
130
- const initialState : TransferInputState = {
131
- showValidationState : false ,
132
- validations : {
133
- fromChain : '' ,
134
- toChain : '' ,
135
- token : '' ,
130
+ // This is a function because config might have changed since we last cleared this store
131
+ function getInitialState ( ) : TransferInputState {
132
+ return {
133
+ showValidationState : false ,
134
+ validations : {
135
+ fromChain : '' ,
136
+ toChain : '' ,
137
+ token : '' ,
138
+ destToken : '' ,
139
+ amount : '' ,
140
+ route : '' ,
141
+ toNativeToken : '' ,
142
+ sendingWallet : '' ,
143
+ receivingWallet : '' ,
144
+ foreignAsset : '' ,
145
+ relayerFee : '' ,
146
+ receiveAmount : '' ,
147
+ } ,
148
+ routeStates : undefined ,
149
+ fromChain : config . bridgeDefaults ?. fromNetwork || undefined ,
150
+ toChain : config . bridgeDefaults ?. toNetwork || undefined ,
151
+ token : config . bridgeDefaults ?. token || '' ,
136
152
destToken : '' ,
137
153
amount : '' ,
138
- route : '' ,
139
- toNativeToken : '' ,
140
- sendingWallet : '' ,
141
- receivingWallet : '' ,
154
+ receiveAmount : getEmptyDataWrapper ( ) ,
155
+ route : undefined ,
156
+ balances : { } ,
142
157
foreignAsset : '' ,
143
- relayerFee : '' ,
144
- receiveAmount : '' ,
145
- } ,
146
- routeStates : undefined ,
147
- fromChain : config . bridgeDefaults ?. fromNetwork || undefined ,
148
- toChain : config . bridgeDefaults ?. toNetwork || undefined ,
149
- token : config . bridgeDefaults ?. token || '' ,
150
- destToken : '' ,
151
- amount : '' ,
152
- receiveAmount : getEmptyDataWrapper ( ) ,
153
- route : undefined ,
154
- balances : { } ,
155
- foreignAsset : '' ,
156
- associatedTokenAddress : '' ,
157
- gasEst : {
158
- send : '' ,
159
- claim : '' ,
160
- } ,
161
- isTransactionInProgress : false ,
162
- receiverNativeBalance : '' ,
163
- supportedSourceTokens : [ ] ,
164
- allSupportedDestTokens : [ ] ,
165
- supportedDestTokens : [ ] ,
166
- } ;
158
+ associatedTokenAddress : '' ,
159
+ gasEst : {
160
+ send : '' ,
161
+ claim : '' ,
162
+ } ,
163
+ isTransactionInProgress : false ,
164
+ receiverNativeBalance : '' ,
165
+ supportedSourceTokens : [ ] ,
166
+ allSupportedDestTokens : [ ] ,
167
+ supportedDestTokens : [ ] ,
168
+ } ;
169
+ }
167
170
168
171
const performModificationsIfFromChainChanged = ( state : TransferInputState ) => {
169
172
const { fromChain, token, route } = state ;
@@ -259,7 +262,7 @@ const establishRoute = (state: TransferInputState) => {
259
262
260
263
export const transferInputSlice = createSlice ( {
261
264
name : 'transfer' ,
262
- initialState,
265
+ initialState : getInitialState ( ) ,
263
266
reducers : {
264
267
// validations
265
268
setValidations : (
@@ -409,6 +412,7 @@ export const transferInputSlice = createSlice({
409
412
} ,
410
413
// clear inputs
411
414
clearTransfer : ( state : TransferInputState ) => {
415
+ const initialState = getInitialState ( ) ;
412
416
Object . keys ( state ) . forEach ( ( key ) => {
413
417
// @ts -ignore
414
418
state [ key ] = initialState [ key ] ;
0 commit comments