Merge branch 'master' into i328-MultiVault

feature/default_network_editable
Frankie 8 years ago
commit f665b779cb
  1. 6
      CHANGELOG.md
  2. 2
      app/manifest.json
  3. 4
      app/scripts/lib/idStore.js
  4. 1
      app/scripts/metamask-controller.js
  5. 10
      test/unit/idStore-test.js
  6. 21
      ui/app/actions.js
  7. 4
      ui/app/components/coinbase-form.js
  8. 2
      ui/app/components/shapeshift-form.js

@ -1,8 +1,12 @@
# Changelog # Changelog
## Current Master ## Current Master
- Fix bug where 20% of gas estimate was not being added properly.
- Fix gas estimation bug. ## 2.13.7 2016-11-8
- Fix bug where gas estimate would sometimes be very high.
- Increased our gas estimate from 100k gas to 20% of estimate.
- Fix github link on info page to point at current repository. - Fix github link on info page to point at current repository.
## 2.13.6 2016-10-26 ## 2.13.6 2016-10-26

@ -1,7 +1,7 @@
{ {
"name": "MetaMask", "name": "MetaMask",
"short_name": "Metamask", "short_name": "Metamask",
"version": "2.13.6", "version": "2.13.7",
"manifest_version": 2, "manifest_version": 2,
"author": "https://metamask.io", "author": "https://metamask.io",
"description": "Ethereum Browser Extension", "description": "Ethereum Browser Extension",

@ -260,6 +260,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone
query.estimateGas(txParams, function(err, result){ query.estimateGas(txParams, function(err, result){
if (err) return cb(err) if (err) return cb(err)
txData.estimatedGas = self.addGasBuffer(result) txData.estimatedGas = self.addGasBuffer(result)
txData.txParams.gasLimit = txData.estimatedGas
cb() cb()
}) })
} }
@ -285,9 +286,10 @@ IdentityStore.prototype.checkForDelegateCall = function (codeHex) {
} }
} }
const gasBuffer = new BN('100000', 10)
IdentityStore.prototype.addGasBuffer = function (gas) { IdentityStore.prototype.addGasBuffer = function (gas) {
const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16) const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
const five = new BN('5', 10)
const gasBuffer = bnGas.div(five)
const correct = bnGas.add(gasBuffer) const correct = bnGas.add(gasBuffer)
return ethUtil.addHexPrefix(correct.toString(16)) return ethUtil.addHexPrefix(correct.toString(16))
} }

@ -218,7 +218,6 @@ module.exports = class MetamaskController {
let err = this.enforceTxValidations(txParams) let err = this.enforceTxValidations(txParams)
if (err) return onTxDoneCb(err) if (err) return onTxDoneCb(err)
keyringController.addUnconfirmedTransaction(txParams, onTxDoneCb, (err, txData) => { keyringController.addUnconfirmedTransaction(txParams, onTxDoneCb, (err, txData) => {
if (err) return onTxDoneCb(err) if (err) return onTxDoneCb(err)
this.sendUpdate() this.sendUpdate()

@ -159,7 +159,7 @@ describe('IdentityStore', function() {
assert.equal(result.indexOf('0x'), 0, 'include hex prefix') assert.equal(result.indexOf('0x'), 0, 'include hex prefix')
}) })
it('buffers reasonably', function() { it('buffers 20%', function() {
const idStore = new IdentityStore({ const idStore = new IdentityStore({
configManager: configManagerGen(), configManager: configManagerGen(),
ethStore: { ethStore: {
@ -168,20 +168,18 @@ describe('IdentityStore', function() {
}) })
const gas = '0x04ee59' // Actual estimated gas example const gas = '0x04ee59' // Actual estimated gas example
const tooBigOutput = '0x80674f9' // Actual bad output
const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16) const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
const correctBuffer = new BN('100000', 10) const five = new BN('5', 10)
const correctBuffer = bnGas.div(five)
const correct = bnGas.add(correctBuffer) const correct = bnGas.add(correctBuffer)
const tooBig = new BN(tooBigOutput, 16)
const result = idStore.addGasBuffer(gas) const result = idStore.addGasBuffer(gas)
const bnResult = new BN(ethUtil.stripHexPrefix(result), 16) const bnResult = new BN(ethUtil.stripHexPrefix(result), 16)
assert.equal(result.indexOf('0x'), 0, 'included hex prefix') assert.equal(result.indexOf('0x'), 0, 'included hex prefix')
assert(bnResult.gt(bnGas), 'Estimate increased in value.') assert(bnResult.gt(bnGas), 'Estimate increased in value.')
assert.equal(bnResult.sub(bnGas).toString(10), '100000', 'added 100k gas') assert.equal(bnResult.sub(bnGas).toString(10), correctBuffer.toString(10), 'added 20% gas')
assert.equal(result, '0x' + correct.toString(16), 'Added the right amount') assert.equal(result, '0x' + correct.toString(16), 'Added the right amount')
assert.notEqual(result, tooBigOutput, 'not that bad estimate')
}) })
}) })

@ -44,7 +44,6 @@ var actions = {
unlockInProgress: unlockInProgress, unlockInProgress: unlockInProgress,
// error handling // error handling
displayWarning: displayWarning, displayWarning: displayWarning,
showWarning: showWarning, // alias
DISPLAY_WARNING: 'DISPLAY_WARNING', DISPLAY_WARNING: 'DISPLAY_WARNING',
HIDE_WARNING: 'HIDE_WARNING', HIDE_WARNING: 'HIDE_WARNING',
hideWarning: hideWarning, hideWarning: hideWarning,
@ -184,7 +183,7 @@ function confirmSeedWords () {
background.clearSeedWordCache((err, account) => { background.clearSeedWordCache((err, account) => {
dispatch(actions.hideLoadingIndication()) dispatch(actions.hideLoadingIndication())
if (err) { if (err) {
return dispatch(actions.showWarning(err.message)) return dispatch(actions.displayWarning(err.message))
} }
console.log('Seed word cache cleared. ' + account) console.log('Seed word cache cleared. ' + account)
@ -384,7 +383,7 @@ function agreeToDisclaimer () {
dispatch(this.showLoadingIndication()) dispatch(this.showLoadingIndication())
background.agreeToDisclaimer((err) => { background.agreeToDisclaimer((err) => {
if (err) { if (err) {
return dispatch(actions.showWarning(err.message)) return dispatch(actions.displayWarning(err.message))
} }
dispatch(this.hideLoadingIndication()) dispatch(this.hideLoadingIndication())
@ -456,7 +455,7 @@ function lockMetamask () {
background.setLocked((err) => { background.setLocked((err) => {
dispatch(actions.hideLoadingIndication()) dispatch(actions.hideLoadingIndication())
if (err) { if (err) {
return dispatch(actions.showWarning(err.message)) return dispatch(actions.displayWarning(err.message))
} }
dispatch({ dispatch({
@ -472,7 +471,7 @@ function showAccountDetail (address) {
background.setSelectedAddress(address, (err, address) => { background.setSelectedAddress(address, (err, address) => {
dispatch(actions.hideLoadingIndication()) dispatch(actions.hideLoadingIndication())
if (err) { if (err) {
return dispatch(actions.showWarning(err.message)) return dispatch(actions.displayWarning(err.message))
} }
dispatch({ dispatch({
@ -586,10 +585,6 @@ function hideSubLoadingIndication () {
} }
} }
function showWarning (text) {
return this.displayWarning(text)
}
function displayWarning (text) { function displayWarning (text) {
return { return {
type: actions.DISPLAY_WARNING, type: actions.DISPLAY_WARNING,
@ -641,7 +636,7 @@ function saveAccountLabel (account, label) {
background.saveAccountLabel(account, label, (err) => { background.saveAccountLabel(account, label, (err) => {
dispatch(actions.hideLoadingIndication()) dispatch(actions.hideLoadingIndication())
if (err) { if (err) {
return dispatch(actions.showWarning(err.message)) return dispatch(actions.displayWarning(err.message))
} }
dispatch({ dispatch({
type: actions.SAVE_ACCOUNT_LABEL, type: actions.SAVE_ACCOUNT_LABEL,
@ -717,7 +712,7 @@ function shapeShiftSubview (network) {
shapeShiftRequest('marketinfo', {pair}, (mktResponse) => { shapeShiftRequest('marketinfo', {pair}, (mktResponse) => {
shapeShiftRequest('getcoins', {}, (response) => { shapeShiftRequest('getcoins', {}, (response) => {
dispatch(actions.hideSubLoadingIndication()) dispatch(actions.hideSubLoadingIndication())
if (mktResponse.error) return dispatch(actions.showWarning(mktResponse.error)) if (mktResponse.error) return dispatch(actions.displayWarning(mktResponse.error))
dispatch({ dispatch({
type: actions.SHAPESHIFT_SUBVIEW, type: actions.SHAPESHIFT_SUBVIEW,
value: { value: {
@ -734,7 +729,7 @@ function coinShiftRquest (data, marketData) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
shapeShiftRequest('shift', { method: 'POST', data}, (response) => { shapeShiftRequest('shift', { method: 'POST', data}, (response) => {
if (response.error) return dispatch(actions.showWarning(response.error)) if (response.error) return dispatch(actions.displayWarning(response.error))
var message = ` var message = `
Deposit your ${response.depositType} to the address bellow:` Deposit your ${response.depositType} to the address bellow:`
background.createShapeShiftTx(response.deposit, response.depositType) background.createShapeShiftTx(response.deposit, response.depositType)
@ -756,7 +751,7 @@ function reshowQrCode (data, coin) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
shapeShiftRequest('marketinfo', {pair: `${coin.toLowerCase()}_eth`}, (mktResponse) => { shapeShiftRequest('marketinfo', {pair: `${coin.toLowerCase()}_eth`}, (mktResponse) => {
if (mktResponse.error) return dispatch(actions.showWarning(mktResponse.error)) if (mktResponse.error) return dispatch(actions.displayWarning(mktResponse.error))
var message = [ var message = [
`Deposit your ${coin} to the address bellow:`, `Deposit your ${coin} to the address bellow:`,

@ -116,10 +116,10 @@ CoinbaseForm.prototype.toCoinbase = function () {
props.dispatch(actions.buyEth(address, props.buyView.amount)) props.dispatch(actions.buyEth(address, props.buyView.amount))
} else if (!isValidAmountforCoinBase(amount).valid) { } else if (!isValidAmountforCoinBase(amount).valid) {
message = isValidAmountforCoinBase(amount).message message = isValidAmountforCoinBase(amount).message
return props.dispatch(actions.showWarning(message)) return props.dispatch(actions.displayWarning(message))
} else { } else {
message = 'Receiving address is invalid.' message = 'Receiving address is invalid.'
return props.dispatch(actions.showWarning(message)) return props.dispatch(actions.displayWarning(message))
} }
} }

@ -244,7 +244,7 @@ ShapeshiftForm.prototype.updateCoin = function (event) {
if (!coinOptions[coin.toUpperCase()] || coin.toUpperCase() === 'ETH') { if (!coinOptions[coin.toUpperCase()] || coin.toUpperCase() === 'ETH') {
var message = 'Not a valid coin' var message = 'Not a valid coin'
return props.dispatch(actions.showWarning(message)) return props.dispatch(actions.displayWarning(message))
} else { } else {
return props.dispatch(actions.pairUpdate(coin)) return props.dispatch(actions.pairUpdate(coin))
} }

Loading…
Cancel
Save