@@ -15,15 +15,20 @@ export class TxRunnerWeb3 {
1515 this . _api = api
1616 }
1717
18- _executeTx ( tx , txFee , api , promptCb , callback ) {
18+ _executeTx ( tx , network , txFee , api , promptCb , callback ) {
19+ if ( network && network . lastBlock && network . lastBlock . baseFeePerGas ) {
20+ // the sending stack (web3.js / metamask need to have the type defined)
21+ // this is to avoid the following issue: https://github.com/MetaMask/metamask-extension/issues/11824
22+ tx . type = '0x2'
23+ }
1924 if ( txFee ) {
2025 if ( txFee . baseFeePerGas ) {
21- tx . maxPriorityFee = this . getWeb3 ( ) . utils . toHex ( this . getWeb3 ( ) . utils . toWei ( txFee . maxPriorityFee , 'gwei' ) )
22- tx . maxFee = this . getWeb3 ( ) . utils . toHex ( this . getWeb3 ( ) . utils . toWei ( txFee . maxFee , 'gwei' ) )
23- tx . type = 2
26+ tx . maxPriorityFeePerGas = this . getWeb3 ( ) . utils . toHex ( this . getWeb3 ( ) . utils . toWei ( txFee . maxPriorityFee , 'gwei' ) )
27+ tx . maxFeePerGas = this . getWeb3 ( ) . utils . toHex ( this . getWeb3 ( ) . utils . toWei ( txFee . maxFee , 'gwei' ) )
28+ tx . type = '0x2'
2429 } else {
2530 tx . gasPrice = this . getWeb3 ( ) . utils . toHex ( this . getWeb3 ( ) . utils . toWei ( txFee . gasPrice , 'gwei' ) )
26- tx . type = 1
31+ tx . type = '0x1'
2732 }
2833 }
2934
@@ -100,18 +105,18 @@ export class TxRunnerWeb3 {
100105 // callback is called whenever no error
101106 tx [ 'gas' ] = ! gasEstimation ? gasLimit : gasEstimation
102107
103- if ( this . _api . config . getUnpersistedProperty ( 'doNotShowTransactionConfirmationAgain' ) ) {
104- return this . _executeTx ( tx , null , this . _api , promptCb , callback )
105- }
106-
107108 this . _api . detectNetwork ( ( err , network ) => {
108109 if ( err ) {
109110 console . log ( err )
110111 return
111112 }
112113
114+ if ( this . _api . config . getUnpersistedProperty ( 'doNotShowTransactionConfirmationAgain' ) ) {
115+ return this . _executeTx ( tx , network , null , this . _api , promptCb , callback )
116+ }
117+
113118 confirmCb ( network , tx , tx [ 'gas' ] , ( txFee ) => {
114- return this . _executeTx ( tx , txFee , this . _api , promptCb , callback )
119+ return this . _executeTx ( tx , network , txFee , this . _api , promptCb , callback )
115120 } , ( error ) => {
116121 callback ( error )
117122 } )
0 commit comments