mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 09:23:21 +01:00
Merge branch 'master' into dev
This commit is contained in:
commit
b899119582
11
CHANGELOG.md
11
CHANGELOG.md
@ -2,6 +2,17 @@
|
||||
|
||||
## Current Master
|
||||
|
||||
- Add support for synchronous RPC method "eth_uninstallFilter".
|
||||
|
||||
## 2.13.10 2016-11-22
|
||||
|
||||
- Improve gas calculation logic.
|
||||
- Default to Dapp-specified gas limits for transactions.
|
||||
- Ropsten networks now properly point to the faucet when attempting to buy ether.
|
||||
- Ropsten transactions now link to etherscan correctly.
|
||||
|
||||
## 2.13.9 2016-11-21
|
||||
|
||||
- Add support for the new, default Ropsten Test Network.
|
||||
- Fix bug that would cause MetaMask to occasionally lose its StreamProvider connection and drop requests.
|
||||
- Fix bug that would cause the Custom RPC menu item to not appear when Localhost 8545 was selected.
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "MetaMask",
|
||||
"short_name": "Metamask",
|
||||
"version": "2.13.8",
|
||||
"version": "2.13.10",
|
||||
"manifest_version": 2,
|
||||
"author": "https://metamask.io",
|
||||
"description": "Ethereum Browser Extension",
|
||||
|
@ -258,24 +258,51 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
|
||||
|
||||
function estimateGas (cb) {
|
||||
var estimationParams = extend(txParams)
|
||||
// 1 billion gas for estimation
|
||||
var gasLimit = '0x3b9aca00'
|
||||
estimationParams.gas = gasLimit
|
||||
query.estimateGas(estimationParams, function (err, result) {
|
||||
if (err) return cb(err.message || err)
|
||||
if (result === estimationParams.gas) {
|
||||
txData.simulationFails = true
|
||||
query.getBlockByNumber('latest', true, function (err, block) {
|
||||
if (err) return cb(err)
|
||||
txData.estimatedGas = block.gasLimit
|
||||
txData.txParams.gas = block.gasLimit
|
||||
cb()
|
||||
})
|
||||
return
|
||||
query.getBlockByNumber('latest', true, function(err, block){
|
||||
if (err) return cb(err)
|
||||
// check if gasLimit is already specified
|
||||
const gasLimitSpecified = Boolean(txParams.gas)
|
||||
// if not, fallback to block gasLimit
|
||||
if (!gasLimitSpecified) {
|
||||
estimationParams.gas = block.gasLimit
|
||||
}
|
||||
txData.estimatedGas = self.addGasBuffer(result)
|
||||
txData.txParams.gas = txData.estimatedGas
|
||||
cb()
|
||||
// run tx, see if it will OOG
|
||||
query.estimateGas(estimationParams, function(err, estimatedGasHex){
|
||||
if (err) return cb(err.message || err)
|
||||
// all gas used - must be an error
|
||||
if (estimatedGasHex === estimationParams.gas) {
|
||||
txData.simulationFails = true
|
||||
txData.estimatedGas = estimatedGasHex
|
||||
txData.txParams.gas = estimatedGasHex
|
||||
cb()
|
||||
return
|
||||
}
|
||||
// otherwise, did not use all gas, must be ok
|
||||
|
||||
// if specified gasLimit and no error, we're done
|
||||
if (gasLimitSpecified) {
|
||||
txData.estimatedGas = txParams.gas
|
||||
cb()
|
||||
return
|
||||
}
|
||||
|
||||
// try adding an additional gas buffer to our estimation for safety
|
||||
const estimatedGasBn = new BN(ethUtil.stripHexPrefix(estimatedGasHex), 16)
|
||||
const blockGasLimitBn = new BN(ethUtil.stripHexPrefix(block.gasLimit), 16)
|
||||
const estimationWithBuffer = self.addGasBuffer(estimatedGasBn)
|
||||
// added gas buffer is too high
|
||||
if (estimationWithBuffer.gt(blockGasLimitBn)) {
|
||||
txData.estimatedGas = estimatedGasHex
|
||||
txData.txParams.gas = estimatedGasHex
|
||||
// added gas buffer is safe
|
||||
} else {
|
||||
const gasWithBufferHex = ethUtil.intToHex(estimationWithBuffer)
|
||||
txData.estimatedGas = gasWithBufferHex
|
||||
txData.txParams.gas = gasWithBufferHex
|
||||
}
|
||||
cb()
|
||||
return
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -300,12 +327,11 @@ IdentityStore.prototype.checkForDelegateCall = function (codeHex) {
|
||||
}
|
||||
}
|
||||
|
||||
IdentityStore.prototype.addGasBuffer = function (gas) {
|
||||
const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
|
||||
const five = new BN('5', 10)
|
||||
const gasBuffer = bnGas.div(five)
|
||||
const correct = bnGas.add(gasBuffer)
|
||||
return ethUtil.addHexPrefix(correct.toString(16))
|
||||
IdentityStore.prototype.addGasBuffer = function (gasBn) {
|
||||
// add 20% to specified gas
|
||||
const gasBuffer = gasBn.div(new BN('5', 10))
|
||||
const gasWithBuffer = gasBn.add(gasBuffer)
|
||||
return gasWithBuffer
|
||||
}
|
||||
|
||||
// comes from metamask ui
|
||||
|
@ -82,6 +82,11 @@ MetamaskInpageProvider.prototype.send = function (payload) {
|
||||
result = selectedAccount || '0x0000000000000000000000000000000000000000'
|
||||
break
|
||||
|
||||
case 'eth_uninstallFilter':
|
||||
self.sendAsync(payload, noop)
|
||||
result = true
|
||||
break
|
||||
|
||||
// throw not-supported Error
|
||||
default:
|
||||
var link = 'https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async---think-of-metamask-as-a-light-client'
|
||||
@ -127,3 +132,5 @@ function eachJsonMessage (payload, transformFn) {
|
||||
return transformFn(payload)
|
||||
}
|
||||
}
|
||||
|
||||
function noop () {}
|
||||
|
@ -151,11 +151,9 @@ describe('IdentityStore', function() {
|
||||
|
||||
const gas = '0x01'
|
||||
const bnGas = new BN(gas, 16)
|
||||
const result = idStore.addGasBuffer(gas)
|
||||
const bnResult = new BN(result, 16)
|
||||
const bnResult = idStore.addGasBuffer(bnGas)
|
||||
|
||||
assert.ok(bnResult.gt(gas), 'added more gas as buffer.')
|
||||
assert.equal(result.indexOf('0x'), 0, 'include hex prefix')
|
||||
})
|
||||
|
||||
it('buffers 20%', function() {
|
||||
@ -172,13 +170,10 @@ describe('IdentityStore', function() {
|
||||
const correctBuffer = bnGas.div(five)
|
||||
const correct = bnGas.add(correctBuffer)
|
||||
|
||||
const result = idStore.addGasBuffer(gas)
|
||||
const bnResult = new BN(ethUtil.stripHexPrefix(result), 16)
|
||||
const bnResult = idStore.addGasBuffer(bnGas)
|
||||
|
||||
assert.equal(result.indexOf('0x'), 0, 'included hex prefix')
|
||||
assert(bnResult.gt(bnGas), 'Estimate increased in value.')
|
||||
assert.equal(bnResult.sub(bnGas).toString(10), correctBuffer.toString(10), 'added 20% gas')
|
||||
assert.equal(result, '0x' + correct.toString(16), 'Added the right amount')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -113,9 +113,9 @@ BuyButtonSubview.prototype.formVersionSubview = function () {
|
||||
style: {
|
||||
width: '225px',
|
||||
},
|
||||
}, 'In order to access this feature please switch to the Main Network'),
|
||||
this.props.network === '3' ? h('h3.text-transform-uppercase', 'or:') : null,
|
||||
this.props.network === '3' ? h('button.text-transform-uppercase', {
|
||||
}, 'In order to access this feature, please switch to the Main Network'),
|
||||
(this.props.network === '3') ? h('h3.text-transform-uppercase', 'or:') : null,
|
||||
(this.props.network === '3') ? h('button.text-transform-uppercase', {
|
||||
onClick: () => this.props.dispatch(actions.buyEth()),
|
||||
style: {
|
||||
marginTop: '15px',
|
||||
|
Loading…
Reference in New Issue
Block a user