@ -2,7 +2,7 @@
import { EventManager } from '../eventManager'
import { EventManager } from '../eventManager'
import type { Transaction as InternalTransaction } from './txRunner'
import type { Transaction as InternalTransaction } from './txRunner'
import Web3 from 'web3'
import Web3 from 'web3'
import { toBigInt , toHex } from 'web3-utils'
import { toBigInt , toHex } from 'web3-utils'
export class TxRunnerWeb3 {
export class TxRunnerWeb3 {
event
event
@ -65,9 +65,9 @@ export class TxRunnerWeb3 {
promptCb (
promptCb (
async ( value ) = > {
async ( value ) = > {
try {
try {
const res = await ( this . getWeb3 ( ) as any ) . eth . personal . sendTransaction ( { . . . tx , value } , { checkRevertBeforeSending : false , ignoreGasPricing : true } )
const res = await ( this . getWeb3 ( ) as any ) . eth . personal . sendTransaction ( { . . . tx , value } , { checkRevertBeforeSending : false , ignoreGasPricing : true } )
cb ( null , res . transactionHash )
cb ( null , res . transactionHash )
} catch ( e ) {
} catch ( e ) {
console . log ( ` Send transaction failed: ${ e . message } . if you use an injected provider, please check it is properly unlocked. ` )
console . log ( ` Send transaction failed: ${ e . message } . if you use an injected provider, please check it is properly unlocked. ` )
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// So we don't consider this to be an error.
// So we don't consider this to be an error.
@ -81,9 +81,9 @@ export class TxRunnerWeb3 {
)
)
} else {
} else {
try {
try {
const res = await this . getWeb3 ( ) . eth . sendTransaction ( tx , null , { checkRevertBeforeSending : false , ignoreGasPricing : true } )
const res = await this . getWeb3 ( ) . eth . sendTransaction ( tx , null , { checkRevertBeforeSending : false , ignoreGasPricing : true } )
cb ( null , res . transactionHash )
cb ( null , res . transactionHash )
} catch ( e ) {
} catch ( e ) {
console . log ( ` Send transaction failed: ${ e . message } . if you use an injected provider, please check it is properly unlocked. ` )
console . log ( ` Send transaction failed: ${ e . message } . if you use an injected provider, please check it is properly unlocked. ` )
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// in case the receipt is available, we consider that only the execution failed but the transaction went through.
// So we don't consider this to be an error.
// So we don't consider this to be an error.
@ -121,7 +121,7 @@ export class TxRunnerWeb3 {
console . log ( errNetWork )
console . log ( errNetWork )
return
return
}
}
const txCopy = { . . . tx , type : undefined , maxFeePerGas : undefined , gasPrice : undefined }
const txCopy = { . . . tx , type : undefined , maxFeePerGas : undefined , gasPrice : undefined }
if ( network && network . lastBlock ) {
if ( network && network . lastBlock ) {
if ( network . lastBlock . baseFeePerGas ) {
if ( network . lastBlock . baseFeePerGas ) {
// the sending stack (web3.js / metamask need to have the type defined)
// the sending stack (web3.js / metamask need to have the type defined)
@ -138,17 +138,17 @@ export class TxRunnerWeb3 {
gasEstimationForceSend ( null , ( ) = > {
gasEstimationForceSend ( null , ( ) = > {
/ *
/ *
* gasLimit is a value that can be set in the UI to hardcap value that can be put in a tx .
* gasLimit is a value that can be set in the UI to hardcap value that can be put in a tx .
* e . g if the gasestimate
* e . g if the gasestimate
* /
* /
if ( gasLimit !== '0x0' && gasEstimation > gasLimit ) {
if ( gasLimit !== '0x0' && gasEstimation > gasLimit ) {
return callback ( ` estimated gas for this transaction ( ${ gasEstimation } ) is higher than gasLimit set in the configuration ( ${ gasLimit } ). Please raise the gas limit. ` )
return callback ( ` estimated gas for this transaction ( ${ gasEstimation } ) is higher than gasLimit set in the configuration ( ${ gasLimit } ). Please raise the gas limit. ` )
}
}
if ( gasLimit === '0x0' ) {
if ( gasLimit === '0x0' ) {
tx [ 'gas' ] = gasEstimation
tx [ 'gas' ] = gasEstimation
} else {
} else {
tx [ 'gas' ] = gasLimit
tx [ 'gas' ] = gasLimit
}
}
if ( this . _api . config . getUnpersistedProperty ( 'doNotShowTransactionConfirmationAgain' ) ) {
if ( this . _api . config . getUnpersistedProperty ( 'doNotShowTransactionConfirmationAgain' ) ) {
return this . _executeTx ( tx , network , null , this . _api , promptCb , callback )
return this . _executeTx ( tx , network , null , this . _api , promptCb , callback )