mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
transactions gasLimit - use the block gasLimit if getCode fails
This commit is contained in:
parent
e8a480aac4
commit
ab126b8c78
@ -187,12 +187,12 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
// validate
|
// validate
|
||||||
await this.txGasUtil.validateTxParams(txParams)
|
await this.txGasUtil.validateTxParams(txParams)
|
||||||
// construct txMeta
|
// construct txMeta
|
||||||
const txMeta = this.txStateManager.generateTxMeta({txParams})
|
let txMeta = this.txStateManager.generateTxMeta({txParams})
|
||||||
this.addTx(txMeta)
|
this.addTx(txMeta)
|
||||||
this.emit('newUnapprovedTx', txMeta)
|
this.emit('newUnapprovedTx', txMeta)
|
||||||
// add default tx params
|
// add default tx params
|
||||||
try {
|
try {
|
||||||
await this.addTxDefaults(txMeta)
|
txMeta = await this.addTxDefaults(txMeta)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
this.txStateManager.setTxStatusFailed(txMeta.id, error)
|
this.txStateManager.setTxStatusFailed(txMeta.id, error)
|
||||||
@ -215,6 +215,7 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
}
|
}
|
||||||
txParams.gasPrice = ethUtil.addHexPrefix(gasPrice.toString(16))
|
txParams.gasPrice = ethUtil.addHexPrefix(gasPrice.toString(16))
|
||||||
txParams.value = txParams.value || '0x0'
|
txParams.value = txParams.value || '0x0'
|
||||||
|
if (txParams.to === null) delete txParams.to
|
||||||
// set gasLimit
|
// set gasLimit
|
||||||
return await this.txGasUtil.analyzeGasUsage(txMeta)
|
return await this.txGasUtil.analyzeGasUsage(txMeta)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,9 @@ module.exports = class TxGasUtil {
|
|||||||
// if recipient has no code, gas is 21k max:
|
// if recipient has no code, gas is 21k max:
|
||||||
const recipient = txParams.to
|
const recipient = txParams.to
|
||||||
const hasRecipient = Boolean(recipient)
|
const hasRecipient = Boolean(recipient)
|
||||||
const code = await this.query.getCode(recipient)
|
let code
|
||||||
|
if (recipient) code = await this.query.getCode(recipient)
|
||||||
|
|
||||||
if (hasRecipient && (!code || code === '0x')) {
|
if (hasRecipient && (!code || code === '0x')) {
|
||||||
txParams.gas = SIMPLE_GAS_COST
|
txParams.gas = SIMPLE_GAS_COST
|
||||||
txMeta.simpleSend = true // Prevents buffer addition
|
txMeta.simpleSend = true // Prevents buffer addition
|
||||||
|
Loading…
Reference in New Issue
Block a user