mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Increase gas estimate by 100000 wei
To prevent minor gas estimation errors, probably usually related to operating on dynamic state. Fixes #738.
This commit is contained in:
parent
101e839f9a
commit
91f43fa213
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
|
- Increase default max gas to `100000` over the RPC's `estimateGas` response.
|
||||||
|
|
||||||
## 2.13.4 2016-10-17
|
## 2.13.4 2016-10-17
|
||||||
|
|
||||||
- Add custom transaction fee field to send form.
|
- Add custom transaction fee field to send form.
|
||||||
|
@ -2,6 +2,7 @@ const EventEmitter = require('events').EventEmitter
|
|||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const async = require('async')
|
const async = require('async')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
const BN = ethUtil.BN
|
||||||
const EthQuery = require('eth-query')
|
const EthQuery = require('eth-query')
|
||||||
const KeyStore = require('eth-lightwallet').keystore
|
const KeyStore = require('eth-lightwallet').keystore
|
||||||
const clone = require('clone')
|
const clone = require('clone')
|
||||||
@ -266,7 +267,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
|
|||||||
function estimateGas(cb){
|
function estimateGas(cb){
|
||||||
query.estimateGas(txParams, function(err, result){
|
query.estimateGas(txParams, function(err, result){
|
||||||
if (err) return cb(err)
|
if (err) return cb(err)
|
||||||
txData.estimatedGas = result
|
txData.estimatedGas = self.addGasBuffer(result)
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -281,6 +282,13 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IdentityStore.prototype.addGasBuffer = function (gasHex) {
|
||||||
|
var gas = new BN(gasHex, 16)
|
||||||
|
var buffer = new BN('100000', 10)
|
||||||
|
var result = gas.add(buffer)
|
||||||
|
return result.toString(16)
|
||||||
|
}
|
||||||
|
|
||||||
// comes from metamask ui
|
// comes from metamask ui
|
||||||
IdentityStore.prototype.approveTransaction = function (txId, cb) {
|
IdentityStore.prototype.approveTransaction = function (txId, cb) {
|
||||||
const configManager = this.configManager
|
const configManager = this.configManager
|
||||||
|
@ -2,6 +2,7 @@ var assert = require('assert')
|
|||||||
var IdentityStore = require('../../app/scripts/lib/idStore')
|
var IdentityStore = require('../../app/scripts/lib/idStore')
|
||||||
var configManagerGen = require('../lib/mock-config-manager')
|
var configManagerGen = require('../lib/mock-config-manager')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
const BN = ethUtil.BN
|
||||||
const async = require('async')
|
const async = require('async')
|
||||||
|
|
||||||
describe('IdentityStore', function() {
|
describe('IdentityStore', function() {
|
||||||
@ -138,4 +139,20 @@ describe('IdentityStore', function() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('#addGasBuffer', function() {
|
||||||
|
const idStore = new IdentityStore({
|
||||||
|
configManager: configManagerGen(),
|
||||||
|
ethStore: {
|
||||||
|
addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const gas = '0x01'
|
||||||
|
const bnGas = new BN(gas, 16)
|
||||||
|
const result = idStore.addGasBuffer(gas)
|
||||||
|
const bnResult = new BN(result, 16)
|
||||||
|
|
||||||
|
assert.ok(bnResult.gt(gas), 'added more gas as buffer.')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user