From 1ddc7625e0de19114d07a29f14d6984af7c1b8ee Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 21 Nov 2016 12:24:27 -0800 Subject: [PATCH 01/12] Version 2.13.9 --- CHANGELOG.md | 2 ++ app/manifest.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c312f35bc..165562ad9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +## 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. diff --git a/app/manifest.json b/app/manifest.json index 99149f91e..d0afcc297 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "MetaMask", "short_name": "Metamask", - "version": "2.13.8", + "version": "2.13.9", "manifest_version": 2, "author": "https://metamask.io", "description": "Ethereum Browser Extension", From 7d38c4ccb657409f123bde6709ddff6418c90c89 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 21 Nov 2016 19:11:55 -0800 Subject: [PATCH 02/12] Add ropsten link support --- ui/lib/account-link.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js index a6b120c63..a77422142 100644 --- a/ui/lib/account-link.js +++ b/ui/lib/account-link.js @@ -7,10 +7,10 @@ module.exports = function(address, network) { link = `http://etherscan.io/address/${address}` break case 2: // morden test net - link = `http://testnet.etherscan.io/address/${address}` + link = '' break case 3: // ropsten test net - link = '' + link = `http://testnet.etherscan.io/address/${address}` break default: link = '' From aefc346a655320da57ab9d63ec920cc21550ddd8 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 21 Nov 2016 19:14:22 -0800 Subject: [PATCH 03/12] Bump changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 165562ad9..481130201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +- Make Ropsten transactions link to etherscan correctly. + ## 2.13.9 2016-11-21 - Add support for the new, default Ropsten Test Network. From daec4d5c3639f7a97862ba87df749fbcd9a46c17 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 21 Nov 2016 19:19:34 -0800 Subject: [PATCH 04/12] Fix ropsten link test --- test/unit/account-link-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/account-link-test.js b/test/unit/account-link-test.js index 39889b6be..08d190f71 100644 --- a/test/unit/account-link-test.js +++ b/test/unit/account-link-test.js @@ -3,8 +3,8 @@ var linkGen = require('../../ui/lib/account-link') describe('account-link', function() { - it('adds testnet prefix to morden test network', function() { - var result = linkGen('account', '2') + it('adds testnet prefix to ropsten test network', function() { + var result = linkGen('account', '3') assert.notEqual(result.indexOf('testnet'), -1, 'testnet injected') assert.notEqual(result.indexOf('account'), -1, 'account included') }) From 694f34ae9a11dbe0ea6f484defe2d8f9e55da82a Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 21 Nov 2016 19:43:59 -0800 Subject: [PATCH 05/12] Add temporary morden explorer link support --- test/unit/account-link-test.js | 6 ++++++ ui/lib/account-link.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/unit/account-link-test.js b/test/unit/account-link-test.js index 08d190f71..5036f8f5d 100644 --- a/test/unit/account-link-test.js +++ b/test/unit/account-link-test.js @@ -3,6 +3,12 @@ var linkGen = require('../../ui/lib/account-link') describe('account-link', function() { + it('adds morden prefix to morden test network', function() { + var result = linkGen('account', '2') + assert.notEqual(result.indexOf('morden'), -1, 'testnet injected') + assert.notEqual(result.indexOf('account'), -1, 'account included') + }) + it('adds testnet prefix to ropsten test network', function() { var result = linkGen('account', '3') assert.notEqual(result.indexOf('testnet'), -1, 'testnet injected') diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js index a77422142..ff52d9c54 100644 --- a/ui/lib/account-link.js +++ b/ui/lib/account-link.js @@ -7,7 +7,7 @@ module.exports = function(address, network) { link = `http://etherscan.io/address/${address}` break case 2: // morden test net - link = '' + link = `http://morden.etherscan.io/address/${address}` break case 3: // ropsten test net link = `http://testnet.etherscan.io/address/${address}` From e2a9e1cd4ab6329df3de94d136ccb7e912945c48 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 21 Nov 2016 19:45:05 -0800 Subject: [PATCH 06/12] Unify test wording --- test/unit/account-link-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/account-link-test.js b/test/unit/account-link-test.js index 5036f8f5d..4ea12e002 100644 --- a/test/unit/account-link-test.js +++ b/test/unit/account-link-test.js @@ -5,13 +5,13 @@ describe('account-link', function() { it('adds morden prefix to morden test network', function() { var result = linkGen('account', '2') - assert.notEqual(result.indexOf('morden'), -1, 'testnet injected') + assert.notEqual(result.indexOf('morden'), -1, 'testnet included') assert.notEqual(result.indexOf('account'), -1, 'account included') }) it('adds testnet prefix to ropsten test network', function() { var result = linkGen('account', '3') - assert.notEqual(result.indexOf('testnet'), -1, 'testnet injected') + assert.notEqual(result.indexOf('testnet'), -1, 'testnet included') assert.notEqual(result.indexOf('account'), -1, 'account included') }) From 88ed1f191f26849b8451c652d30b81fc6d561a27 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 22 Nov 2016 09:45:28 -0800 Subject: [PATCH 07/12] Add to changelog. --- CHANGELOG.md | 1 + app/scripts/metamask-controller.js | 2 +- ui/app/components/buy-button-subview.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 165562ad9..69764748f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Current Master +- Ropsten networks now properly point to the faucet when attempting to buy ether. ## 2.13.9 2016-11-21 diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 5e76c5ebd..82ad8f9c4 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -364,7 +364,7 @@ module.exports = class MetamaskController { var network = this.idStore._currentState.network var url = `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH` - if (network === '2') { + if ((network === '2') || (network === '3')) { url = 'https://faucet.metamask.io/' } diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index b564733b1..ad1967616 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -115,7 +115,7 @@ BuyButtonSubview.prototype.formVersionSubview = function () { }, }, 'In order to access this feature please switch to the Main Network'), h('h3.text-transform-uppercase', 'or:'), - this.props.network === '2' ? h('button.text-transform-uppercase', { + (this.props.network === '2' || this.props.network === '3') ? h('button.text-transform-uppercase', { onClick: () => this.props.dispatch(actions.buyEth()), style: { marginTop: '15px', From 8d2afccdc0e355c2cf5425de5c21042b08989393 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 22 Nov 2016 10:13:57 -0800 Subject: [PATCH 08/12] Ropsten has sole access to the faucet. --- app/scripts/metamask-controller.js | 2 +- ui/app/components/buy-button-subview.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 82ad8f9c4..631411bed 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -364,7 +364,7 @@ module.exports = class MetamaskController { var network = this.idStore._currentState.network var url = `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH` - if ((network === '2') || (network === '3')) { + if (network === '3') { url = 'https://faucet.metamask.io/' } diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index ad1967616..35eda647e 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -113,9 +113,9 @@ BuyButtonSubview.prototype.formVersionSubview = function () { style: { width: '225px', }, - }, 'In order to access this feature please switch to the Main Network'), - h('h3.text-transform-uppercase', 'or:'), - (this.props.network === '2' || 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', From fa2f0dee285d4a9032f8a756ee8711a7fe767b76 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 22 Nov 2016 12:10:49 -0800 Subject: [PATCH 09/12] idStore - fix estimateGas calculation --- app/scripts/lib/idStore.js | 72 ++++++++++++++++++++++++++------------ test/unit/idStore-test.js | 9 ++--- 2 files changed, 51 insertions(+), 30 deletions(-) diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index ccd5efe69..1077d263d 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -260,24 +260,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 + }) }) } @@ -302,12 +329,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 diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js index 064483ba0..bf8270540 100644 --- a/test/unit/idStore-test.js +++ b/test/unit/idStore-test.js @@ -152,11 +152,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() { @@ -173,13 +171,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') }) }) From d9f8a8f9b2643da962b6baa951bd58f349f96ea3 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 14:51:33 -0800 Subject: [PATCH 10/12] Version 2.13.10 --- CHANGELOG.md | 8 ++++++-- app/manifest.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb7c8a942..53ec23089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ # Changelog ## Current Master -- Ropsten networks now properly point to the faucet when attempting to buy ether. -- Make Ropsten transactions link to etherscan correctly. +## 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 diff --git a/app/manifest.json b/app/manifest.json index d0afcc297..b9d3735ad 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "MetaMask", "short_name": "Metamask", - "version": "2.13.9", + "version": "2.13.10", "manifest_version": 2, "author": "https://metamask.io", "description": "Ethereum Browser Extension", From c0a2eb146a1fdbf37fa3c28a522c4b02d3896cc3 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 23 Nov 2016 10:48:20 -0800 Subject: [PATCH 11/12] rpc - add sync uninstallFilter support --- app/scripts/lib/inpage-provider.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index f1ba2e0ed..71ac69ad1 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -82,6 +82,11 @@ MetamaskInpageProvider.prototype.send = function (payload) { result = selectedAddress || '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 () {} From 36c824889fda785591288220bbe34b1021f9b538 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 23 Nov 2016 11:00:48 -0800 Subject: [PATCH 12/12] changelog - add sync rpc eth_uninstallFilter note --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53ec23089..6bd23e22c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +- Add support for synchronous RPC method "eth_uninstallFilter". + ## 2.13.10 2016-11-22 - Improve gas calculation logic.