From b4052cd5e65c1d6ac0c81b051ddf59505a480ec6 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 8 Aug 2017 23:34:18 -0700 Subject: [PATCH 01/15] tx utils - detect estimateGas err and set simulationFailed --- app/scripts/lib/tx-utils.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/scripts/lib/tx-utils.js b/app/scripts/lib/tx-utils.js index b64ea6712..5af078dc4 100644 --- a/app/scripts/lib/tx-utils.js +++ b/app/scripts/lib/tx-utils.js @@ -20,7 +20,15 @@ module.exports = class txProvideUtil { async analyzeGasUsage (txMeta) { const block = await this.query.getBlockByNumber('latest', true) - const estimatedGasHex = await this.estimateTxGas(txMeta, block.gasLimit) + let estimatedGasHex + try { + estimatedGasHex = await this.estimateTxGas(txMeta, block.gasLimit) + } catch (err) { + if (err.message.includes('Transaction execution error.')) { + txMeta.simulationFails = true + return txMeta + } + } this.setTxGas(txMeta, block.gasLimit, estimatedGasHex) return txMeta } @@ -35,8 +43,8 @@ module.exports = class txProvideUtil { const saferGasLimitBN = BnMultiplyByFraction(blockGasLimitBN, 19, 20) txParams.gas = bnToHex(saferGasLimitBN) } - // run tx, see if it will OOG - return this.query.estimateGas(txParams) + // run tx + return await this.query.estimateGas(txParams) } setTxGas (txMeta, blockGasLimitHex, estimatedGasHex) { From b6df46337fa0ce5f9ef81c9269b3155a51d0a1e9 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 8 Aug 2017 23:53:32 -0700 Subject: [PATCH 02/15] readme - add waffle.io badge --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e39058790..075db79c2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# MetaMask Plugin [![Build Status](https://circleci.com/gh/MetaMask/metamask-extension.svg?style=shield&circle-token=a1ddcf3cd38e29267f254c9c59d556d513e3a1fd)](https://circleci.com/gh/MetaMask/metamask-extension) [![Coverage Status](https://coveralls.io/repos/github/MetaMask/metamask-extension/badge.svg?branch=master)](https://coveralls.io/github/MetaMask/metamask-extension?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/MetaMask/metamask-extension.svg)](https://greenkeeper.io/) +# MetaMask Plugin +[![Build Status](https://circleci.com/gh/MetaMask/metamask-extension.svg?style=shield&circle-token=a1ddcf3cd38e29267f254c9c59d556d513e3a1fd)](https://circleci.com/gh/MetaMask/metamask-extension) [![Coverage Status](https://coveralls.io/repos/github/MetaMask/metamask-extension/badge.svg?branch=master)](https://coveralls.io/github/MetaMask/metamask-extension?branch=master) [![Greenkeeper badge](https://badges.greenkeeper.io/MetaMask/metamask-extension.svg)](https://greenkeeper.io/) [![Stories in Ready](https://badge.waffle.io/MetaMask/metamask-extension.png?label=in%20progress&title=waffle.io)](http://waffle.io/MetaMask/metamask-extension) ## Support From 84c3d3c6dbb4454a599bb31008e71d052321ae02 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 9 Aug 2017 00:36:18 -0700 Subject: [PATCH 03/15] ui - buy button view - refactor --- ui/app/components/buy-button-subview.js | 150 ++++++++++++++++-------- 1 file changed, 104 insertions(+), 46 deletions(-) diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index 759eb15bd..27014eaf6 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -8,6 +8,11 @@ const ShapeshiftForm = require('./shapeshift-form') const Loading = require('./loading') const AccountPanel = require('./account-panel') const RadioList = require('./custom-radio-list') +const networkNames = { + 3: 'Ropsten', + 4: 'Rinkeby', + 42: 'Kovan', +} module.exports = connect(mapStateToProps)(BuyButtonSubview) @@ -30,16 +35,30 @@ function BuyButtonSubview () { } BuyButtonSubview.prototype.render = function () { + return ( + h('div', { + style: { + width: '100%', + }, + }, [ + this.headerSubview(), + this.primarySubview(), + ]) + ) +} + +BuyButtonSubview.prototype.headerSubview = function () { const props = this.props const isLoading = props.isSubLoading - return ( - h('.buy-eth-section.flex-column', { + + h('.flex-column', { style: { alignItems: 'center', }, }, [ - // back button + + // header bar (back button, label) h('.flex-row', { style: { alignItems: 'center', @@ -63,6 +82,8 @@ BuyButtonSubview.prototype.render = function () { }, }, 'Buy Eth'), ]), + + // loading indication h('div', { style: { position: 'absolute', @@ -70,8 +91,10 @@ BuyButtonSubview.prototype.render = function () { left: '49vw', }, }, [ - h(Loading, {isLoading}), + h(Loading, { isLoading }), ]), + + // account panel h('div', { style: { width: '80%', @@ -83,17 +106,82 @@ BuyButtonSubview.prototype.render = function () { account: props.account, }), ]), - h('h3.text-transform-uppercase', { + + h('.flex-row', { style: { - paddingLeft: '15px', - fontFamily: 'Montserrat Light', - width: '100vw', - background: 'rgb(235, 235, 235)', - color: 'rgb(174, 174, 174)', - paddingTop: '4px', - paddingBottom: '4px', + alignItems: 'center', + justifyContent: 'center', }, - }, 'Select Service'), + }, [ + h('h3.text-transform-uppercase.flex-center', { + style: { + paddingLeft: '15px', + width: '100vw', + background: 'rgb(235, 235, 235)', + color: 'rgb(174, 174, 174)', + paddingTop: '4px', + paddingBottom: '4px', + }, + }, 'Select Service'), + ]), + + ]) + + ) +} + + +BuyButtonSubview.prototype.primarySubview = function () { + const props = this.props + const network = props.network + + switch (network) { + case 'loading': + return + + case '1': + return this.mainnetSubview() + + case '3': + case '4': + case '42': + const networkName = networkNames[network] + const label = `${networkName} Test Faucet` + return ( + h('div.flex-column', { + style: { + alignItems: 'center', + margin: '20px 50px', + }, + }, [ + h('button.text-transform-uppercase', { + onClick: () => this.props.dispatch(actions.buyEth({ network })), + style: { + marginTop: '15px', + }, + }, label), + ]) + ) + + default: + return ( + h('h2.error', 'Unknown network ID') + ) + + } +} + +BuyButtonSubview.prototype.mainnetSubview = function () { + const props = this.props + + return ( + + h('.flex-column', { + style: { + alignItems: 'center', + }, + }, [ + h('.flex-row.selected-exchange', { style: { position: 'relative', @@ -115,6 +203,7 @@ BuyButtonSubview.prototype.render = function () { onClick: this.radioHandler.bind(this), }), ]), + h('h3.text-transform-uppercase', { style: { paddingLeft: '15px', @@ -126,8 +215,10 @@ BuyButtonSubview.prototype.render = function () { paddingBottom: '4px', }, }, props.buyView.subview), + this.formVersionSubview(), ]) + ) } @@ -139,39 +230,6 @@ BuyButtonSubview.prototype.formVersionSubview = function () { } else if (this.props.buyView.formView.shapeshift) { return h(ShapeshiftForm, this.props) } - } else { - return h('div.flex-column', { - style: { - alignItems: 'center', - margin: '20px 50px', - }, - }, [ - h('h3.text-transform-uppercase', { - style: { - width: '225px', - marginBottom: '15px', - }, - }, 'In order to access this feature, please switch to the Main Network'), - ((network === '3') || (network === '4') || (network === '42')) ? h('h3.text-transform-uppercase', 'or go to the') : null, - (network === '3') ? h('button.text-transform-uppercase', { - onClick: () => this.props.dispatch(actions.buyEth({ network })), - style: { - marginTop: '15px', - }, - }, 'Ropsten Test Faucet') : null, - (network === '4') ? h('button.text-transform-uppercase', { - onClick: () => this.props.dispatch(actions.buyEth({ network })), - style: { - marginTop: '15px', - }, - }, 'Rinkeby Test Faucet') : null, - (network === '42') ? h('button.text-transform-uppercase', { - onClick: () => this.props.dispatch(actions.buyEth({ network })), - style: { - marginTop: '15px', - }, - }, 'Kovan Test Faucet') : null, - ]) } } From 897d00efa0cf7b978983fd8d4c40febe40eba446 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 9 Aug 2017 01:00:06 -0700 Subject: [PATCH 04/15] ui - buy eth - add dharma beta to kovan --- ui/app/components/buy-button-subview.js | 34 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index 27014eaf6..e4624ada8 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -138,30 +138,40 @@ BuyButtonSubview.prototype.primarySubview = function () { switch (network) { case 'loading': return - + case '1': return this.mainnetSubview() + // Ropsten, Rinkeby, Kovan case '3': case '4': case '42': - const networkName = networkNames[network] - const label = `${networkName} Test Faucet` - return ( - h('div.flex-column', { + const networkName = networkNames[network] + const label = `${networkName} Test Faucet` + return ( + h('div.flex-column', { + style: { + alignItems: 'center', + margin: '20px 50px', + }, + }, [ + h('button.text-transform-uppercase', { + onClick: () => this.props.dispatch(actions.buyEth({ network })), style: { - alignItems: 'center', - margin: '20px 50px', + marginTop: '15px', }, - }, [ + }, label), + // Kovan only: Dharma loans beta + network === '42' ? ( h('button.text-transform-uppercase', { - onClick: () => this.props.dispatch(actions.buyEth({ network })), + onClick: () => this.navigateTo('https://borrow.dharma.io/'), style: { marginTop: '15px', }, - }, label), - ]) - ) + }, 'Borrow With Dharma (Beta)') + ) : null + ]) + ) default: return ( From 052d338b2b35bbea4cc4b11db6cdb13cbcc69001 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 9 Aug 2017 01:04:42 -0700 Subject: [PATCH 05/15] lint fix --- ui/app/components/buy-button-subview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index e4624ada8..d9ccb36c5 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -169,7 +169,7 @@ BuyButtonSubview.prototype.primarySubview = function () { marginTop: '15px', }, }, 'Borrow With Dharma (Beta)') - ) : null + ) : null, ]) ) From 245125eb18a03f3ea91fa43a90ad59e628471d62 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 9 Aug 2017 12:25:38 -0700 Subject: [PATCH 06/15] ui - buy eth - formatting and moved network names to config --- app/scripts/config.js | 5 +++ ui/app/components/buy-button-subview.js | 42 +++++++++++-------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/app/scripts/config.js b/app/scripts/config.js index 8e28db80e..c5f260583 100644 --- a/app/scripts/config.js +++ b/app/scripts/config.js @@ -12,4 +12,9 @@ module.exports = { kovan: KOVAN_RPC_URL, rinkeby: RINKEBY_RPC_URL, }, + networkNames: { + 3: 'Ropsten', + 4: 'Rinkeby', + 42: 'Kovan', + }, } diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js index d9ccb36c5..15281171c 100644 --- a/ui/app/components/buy-button-subview.js +++ b/ui/app/components/buy-button-subview.js @@ -8,11 +8,7 @@ const ShapeshiftForm = require('./shapeshift-form') const Loading = require('./loading') const AccountPanel = require('./account-panel') const RadioList = require('./custom-radio-list') -const networkNames = { - 3: 'Ropsten', - 4: 'Rinkeby', - 42: 'Kovan', -} +const networkNames = require('../../../app/scripts/config.js').networkNames module.exports = connect(mapStateToProps)(BuyButtonSubview) @@ -146,30 +142,30 @@ BuyButtonSubview.prototype.primarySubview = function () { case '3': case '4': case '42': - const networkName = networkNames[network] - const label = `${networkName} Test Faucet` - return ( - h('div.flex-column', { - style: { - alignItems: 'center', - margin: '20px 50px', - }, - }, [ - h('button.text-transform-uppercase', { - onClick: () => this.props.dispatch(actions.buyEth({ network })), + const networkName = networkNames[network] + const label = `${networkName} Test Faucet` + return ( + h('div.flex-column', { style: { - marginTop: '15px', + alignItems: 'center', + margin: '20px 50px', }, - }, label), - // Kovan only: Dharma loans beta - network === '42' ? ( + }, [ h('button.text-transform-uppercase', { - onClick: () => this.navigateTo('https://borrow.dharma.io/'), + onClick: () => this.props.dispatch(actions.buyEth({ network })), style: { marginTop: '15px', }, - }, 'Borrow With Dharma (Beta)') - ) : null, + }, label), + // Kovan only: Dharma loans beta + network === '42' ? ( + h('button.text-transform-uppercase', { + onClick: () => this.navigateTo('https://borrow.dharma.io/'), + style: { + marginTop: '15px', + }, + }, 'Borrow With Dharma (Beta)') + ) : null, ]) ) From fa6370c68a8834b8ceeb542e6e861beaaae39be5 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 9 Aug 2017 16:18:38 -0700 Subject: [PATCH 07/15] deps - bump ethjs-query --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8f5c6167..f3cf2882a 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9", "ethereumjs-wallet": "^0.6.0", "ethjs-ens": "^2.0.0", - "ethjs-query": "^0.2.6", + "ethjs-query": "^0.2.9", "express": "^4.14.0", "extension-link-enabler": "^1.0.0", "extensionizer": "^1.0.0", From 2b409fb60b3f524a852a895c9d184fc2bf829009 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 9 Aug 2017 23:05:50 -0700 Subject: [PATCH 08/15] 3.9.6 --- CHANGELOG.md | 6 ++++-- app/manifest.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f0151e6d..58779e31e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,14 @@ ## Current Master +## 3.9.6 2017-8-09 + - Replace account screen with an account drop-down menu. -- Replace confusing buttons with a new account-specific drop-down menu. +- Replace account buttons with a new account-specific drop-down menu. ## 3.9.5 2017-8-04 -- Improved phishing detection configuration update rate +- Improved phishing detection configuration update rate ## 3.9.4 2017-8-03 diff --git a/app/manifest.json b/app/manifest.json index 3b9194eb9..f34bdcec3 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "MetaMask", "short_name": "Metamask", - "version": "3.9.5", + "version": "3.9.6", "manifest_version": 2, "author": "https://metamask.io", "description": "Ethereum Browser Extension", From 88f4931c6f875be5186a0071e2cec5b78fb34b57 Mon Sep 17 00:00:00 2001 From: sdtsui Date: Thu, 10 Aug 2017 17:37:36 -0700 Subject: [PATCH 09/15] Fix text overflow for dropdown components flagged by @frankiebee --- ui/app/components/account-dropdowns.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index b23600e9b..bd60db51e 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -27,6 +27,10 @@ class AccountDropdowns extends Component { return Object.keys(identities).map((key, index) => { const identity = identities[key] const isSelected = identity.address === selected + console.log("address", identity.address) + console.log("selected:", selected) + console.log("isSelected:", isSelected) + // debugger; return h( DropdownMenuItem, @@ -51,7 +55,16 @@ class AccountDropdowns extends Component { }, }, ), - h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, identity.name || ''), + h('span', { + style: { + marginLeft: '20px', + fontSize: '24px', + maxWidth: '145px', + whiteSpace: 'nowrap', + overflow: 'hidden', + textOverflow: 'ellipsis', + } + }, identity.name || ''), h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, isSelected ? h('.check', '✓') : null), ] ) From 771f9ec124c758556ebba11067e66c9d4843455d Mon Sep 17 00:00:00 2001 From: sdtsui Date: Thu, 10 Aug 2017 17:37:55 -0700 Subject: [PATCH 10/15] Fix logic for dropdown components attaching checkmark to correct account --- ui/app/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/app/app.js b/ui/app/app.js index 4565bdd37..60d36772a 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -43,6 +43,7 @@ function mapStateToProps (state) { accounts, address, } = state.metamask + console.log("ADDRESS:", address) const selected = address || Object.keys(accounts)[0] return { @@ -185,7 +186,7 @@ App.prototype.renderAppBar = function () { style: {}, enableAccountsSelector: true, identities: this.props.identities, - selected: this.props.selected, + selected: this.props.currentView.context, network: this.props.network, }, []), From 2346c9b6b9322458b350d5afd19501372272f0ec Mon Sep 17 00:00:00 2001 From: sdtsui Date: Thu, 10 Aug 2017 17:49:12 -0700 Subject: [PATCH 11/15] Add overflow support for all account names in account details --- ui/app/account-detail.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js index 22a883096..f6041e856 100644 --- a/ui/app/account-detail.js +++ b/ui/app/account-detail.js @@ -107,14 +107,23 @@ AccountDetailScreen.prototype.render = function () { }, [ h( - 'h2.font-medium.color-forest', + 'div.font-medium.color-forest', { name: 'edit', style: { }, }, [ - identity && identity.name, + h('h2', { + style: { + maxWidth: '180px', + overflowX: 'hidden', + textOverflow: 'ellipsis', + padding: '5px 0px', + }, + }, [ + identity && identity.name, + ]), ] ), h( From 9ec86636050c6d642ff5fa9bf3413d17ccba1a24 Mon Sep 17 00:00:00 2001 From: sdtsui Date: Thu, 10 Aug 2017 17:49:59 -0700 Subject: [PATCH 12/15] Cleanup stray logs and lint --- ui/app/app.js | 1 - ui/app/components/account-dropdowns.js | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ui/app/app.js b/ui/app/app.js index 60d36772a..1f3d5b0f8 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -43,7 +43,6 @@ function mapStateToProps (state) { accounts, address, } = state.metamask - console.log("ADDRESS:", address) const selected = address || Object.keys(accounts)[0] return { diff --git a/ui/app/components/account-dropdowns.js b/ui/app/components/account-dropdowns.js index bd60db51e..7c24e70bd 100644 --- a/ui/app/components/account-dropdowns.js +++ b/ui/app/components/account-dropdowns.js @@ -27,10 +27,6 @@ class AccountDropdowns extends Component { return Object.keys(identities).map((key, index) => { const identity = identities[key] const isSelected = identity.address === selected - console.log("address", identity.address) - console.log("selected:", selected) - console.log("isSelected:", isSelected) - // debugger; return h( DropdownMenuItem, @@ -63,7 +59,7 @@ class AccountDropdowns extends Component { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', - } + }, }, identity.name || ''), h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, isSelected ? h('.check', '✓') : null), ] From ac9e84ff40c0331cda6233be31241d68f05565f3 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 11 Aug 2017 15:52:03 -0700 Subject: [PATCH 13/15] add deprecation warning for web3 --- app/scripts/lib/auto-reload.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/scripts/lib/auto-reload.js b/app/scripts/lib/auto-reload.js index 534047330..dabf4278e 100644 --- a/app/scripts/lib/auto-reload.js +++ b/app/scripts/lib/auto-reload.js @@ -5,7 +5,10 @@ function setupDappAutoReload (web3, observable) { global.web3 = new Proxy(web3, { get: (_web3, name) => { // get the time of use - if (name !== '_used') _web3._used = Date.now() + if (name !== '_used') { + console.warn('MetaMask: web3 will be deprecated in the future in favor of the ethereumProvider \nhttps://github.com/ethereum/mist/releases/tag/v0.9.0') + _web3._used = Date.now() + } return _web3[name] }, set: (_web3, name, value) => { From d4849f67f9247ee5abe6707bc28fda8fe2bb8fb4 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 11 Aug 2017 15:53:01 -0700 Subject: [PATCH 14/15] Add to CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58779e31e..516e8f9e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +- Added a deprecation warning for web3 https://github.com/ethereum/mist/releases/tag/v0.9.0 + ## 3.9.6 2017-8-09 - Replace account screen with an account drop-down menu. From 66a012550edb8b8bb328f2315109bbbab48d3d3f Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 11 Aug 2017 15:54:52 -0700 Subject: [PATCH 15/15] fix wording --- app/scripts/lib/auto-reload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/lib/auto-reload.js b/app/scripts/lib/auto-reload.js index dabf4278e..6abce73ea 100644 --- a/app/scripts/lib/auto-reload.js +++ b/app/scripts/lib/auto-reload.js @@ -6,7 +6,7 @@ function setupDappAutoReload (web3, observable) { get: (_web3, name) => { // get the time of use if (name !== '_used') { - console.warn('MetaMask: web3 will be deprecated in the future in favor of the ethereumProvider \nhttps://github.com/ethereum/mist/releases/tag/v0.9.0') + console.warn('MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider \nhttps://github.com/ethereum/mist/releases/tag/v0.9.0') _web3._used = Date.now() } return _web3[name]