From 71cc3397bf6d8566c7bf503a04c5d1498891d52a Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Wed, 3 Aug 2022 14:24:35 -0230 Subject: [PATCH] Ensure that if max is selected in send flow, the correct value is set after network switch (#15444) --- ui/ducks/send/send.js | 3 +++ ui/store/actions.js | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/ducks/send/send.js b/ui/ducks/send/send.js index 6ba9ee87b..baa3c07bb 100644 --- a/ui/ducks/send/send.js +++ b/ui/ducks/send/send.js @@ -1563,6 +1563,9 @@ const slice = createSlice({ }, }); } + if (state.amountMode === AMOUNT_MODES.MAX) { + slice.caseReducers.updateAmountToMax(state); + } slice.caseReducers.validateAmountField(state); slice.caseReducers.validateGasField(state); slice.caseReducers.validateSendState(state); diff --git a/ui/store/actions.js b/ui/store/actions.js index 8e79b69bd..483291c53 100644 --- a/ui/store/actions.js +++ b/ui/store/actions.js @@ -1444,6 +1444,10 @@ export function updateMetamaskState(newState) { }, }); } + dispatch({ + type: actionConstants.UPDATE_METAMASK_STATE, + value: newState, + }); if (provider.chainId !== newProvider.chainId) { dispatch({ type: actionConstants.CHAIN_CHANGED, @@ -1455,10 +1459,6 @@ export function updateMetamaskState(newState) { // progress. dispatch(initializeSendState({ chainHasChanged: true })); } - dispatch({ - type: actionConstants.UPDATE_METAMASK_STATE, - value: newState, - }); }; }