|
|
@ -15,15 +15,20 @@ export class TxRunnerWeb3 { |
|
|
|
this._api = api |
|
|
|
this._api = api |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_executeTx (tx, txFee, api, promptCb, callback) { |
|
|
|
_executeTx (tx, network, txFee, api, promptCb, callback) { |
|
|
|
|
|
|
|
if (network && network.lastBlock && network.lastBlock.baseFeePerGas) { |
|
|
|
|
|
|
|
// the sending stack (web3.js / metamask need to have the type defined)
|
|
|
|
|
|
|
|
// this is to avoid the following issue: https://github.com/MetaMask/metamask-extension/issues/11824
|
|
|
|
|
|
|
|
tx.type = '0x2' |
|
|
|
|
|
|
|
} |
|
|
|
if (txFee) { |
|
|
|
if (txFee) { |
|
|
|
if (txFee.baseFeePerGas) { |
|
|
|
if (txFee.baseFeePerGas) { |
|
|
|
tx.maxPriorityFee = this.getWeb3().utils.toHex(this.getWeb3().utils.toWei(txFee.maxPriorityFee, 'gwei')) |
|
|
|
tx.maxPriorityFeePerGas = this.getWeb3().utils.toHex(this.getWeb3().utils.toWei(txFee.maxPriorityFee, 'gwei')) |
|
|
|
tx.maxFee = this.getWeb3().utils.toHex(this.getWeb3().utils.toWei(txFee.maxFee, 'gwei')) |
|
|
|
tx.maxFeePerGas = this.getWeb3().utils.toHex(this.getWeb3().utils.toWei(txFee.maxFee, 'gwei')) |
|
|
|
tx.type = 2 |
|
|
|
tx.type = '0x2' |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tx.gasPrice = this.getWeb3().utils.toHex(this.getWeb3().utils.toWei(txFee.gasPrice, 'gwei')) |
|
|
|
tx.gasPrice = this.getWeb3().utils.toHex(this.getWeb3().utils.toWei(txFee.gasPrice, 'gwei')) |
|
|
|
tx.type = 1 |
|
|
|
tx.type = '0x1' |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -100,18 +105,18 @@ export class TxRunnerWeb3 { |
|
|
|
// callback is called whenever no error
|
|
|
|
// callback is called whenever no error
|
|
|
|
tx['gas'] = !gasEstimation ? gasLimit : gasEstimation |
|
|
|
tx['gas'] = !gasEstimation ? gasLimit : gasEstimation |
|
|
|
|
|
|
|
|
|
|
|
if (this._api.config.getUnpersistedProperty('doNotShowTransactionConfirmationAgain')) { |
|
|
|
|
|
|
|
return this._executeTx(tx, null, this._api, promptCb, callback) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._api.detectNetwork((err, network) => { |
|
|
|
this._api.detectNetwork((err, network) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
console.log(err) |
|
|
|
console.log(err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this._api.config.getUnpersistedProperty('doNotShowTransactionConfirmationAgain')) { |
|
|
|
|
|
|
|
return this._executeTx(tx, network, null, this._api, promptCb, callback) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
confirmCb(network, tx, tx['gas'], (txFee) => { |
|
|
|
confirmCb(network, tx, tx['gas'], (txFee) => { |
|
|
|
return this._executeTx(tx, txFee, this._api, promptCb, callback) |
|
|
|
return this._executeTx(tx, network, txFee, this._api, promptCb, callback) |
|
|
|
}, (error) => { |
|
|
|
}, (error) => { |
|
|
|
callback(error) |
|
|
|
callback(error) |
|
|
|
}) |
|
|
|
}) |
|
|
|