From e0919d529e8417841c09c97c8099236cd0b8503f Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 27 Apr 2023 10:16:36 +0530 Subject: [PATCH] Fix for wrong type being assigned to the transaction (#18818) Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com> --- app/scripts/metamask-controller.js | 4 ++++ ui/ducks/send/send.js | 6 +++++- ui/store/actions.ts | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index e2e52493e..2fee2e507 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1983,6 +1983,10 @@ export default class MetamaskController extends EventEmitter { this.networkController.upsertNetworkConfiguration.bind( this.networkController, ), + getCurrentNetworkEIP1559Compatibility: + this.networkController.getEIP1559Compatibility.bind( + this.networkController, + ), // PreferencesController setSelectedAddress: preferencesController.setSelectedAddress.bind( preferencesController, diff --git a/ui/ducks/send/send.js b/ui/ducks/send/send.js index 516769295..0aefd5382 100644 --- a/ui/ducks/send/send.js +++ b/ui/ducks/send/send.js @@ -55,6 +55,7 @@ import { showModal, addUnapprovedTransactionAndRouteToConfirmationPage, updateTransactionSendFlowHistory, + getCurrentNetworkEIP1559Compatibility, } from '../../store/actions'; import { setCustomGasLimit } from '../gas/gas.duck'; import { @@ -589,7 +590,10 @@ export const initializeSendState = createAsyncThunk( const state = thunkApi.getState(); const isNonStandardEthChain = getIsNonStandardEthChain(state); const chainId = getCurrentChainId(state); - const eip1559support = checkNetworkAndAccountSupports1559(state); + let eip1559support = checkNetworkAndAccountSupports1559(state); + if (eip1559support === undefined) { + eip1559support = await getCurrentNetworkEIP1559Compatibility(); + } const account = getSelectedAccount(state); const { send: sendState, metamask } = state; const draftTransaction = diff --git a/ui/store/actions.ts b/ui/store/actions.ts index c2e8156fa..59f498158 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -4650,3 +4650,17 @@ export function requestUserApproval({ } }; } + +export async function getCurrentNetworkEIP1559Compatibility(): Promise< + boolean | undefined +> { + let networkEIP1559Compatibility; + try { + networkEIP1559Compatibility = await submitRequestToBackground( + 'getCurrentNetworkEIP1559Compatibility', + ); + } catch (error) { + console.error(error); + } + return networkEIP1559Compatibility; +}