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