From 9b43ec2278a5647c427c426ed798ab90bbf093cc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 28 Jul 2016 10:53:51 -0700 Subject: [PATCH 1/5] Add eth classic to provider menu --- app/scripts/chromereload.js | 1 - app/scripts/config.js | 2 ++ app/scripts/lib/config-manager.js | 4 ++++ ui/app/app.js | 12 ++++++++++++ ui/app/components/drop-menu-item.js | 14 +++++++++----- ui/app/components/network.js | 21 ++++++++++++++++++--- ui/app/css/lib.css | 5 +++++ ui/app/settings.js | 1 - 8 files changed, 50 insertions(+), 10 deletions(-) diff --git a/app/scripts/chromereload.js b/app/scripts/chromereload.js index cd85a8114..88333ba8a 100644 --- a/app/scripts/chromereload.js +++ b/app/scripts/chromereload.js @@ -30,7 +30,6 @@ // } // }; -const extension = require('./lib/extension') window.LiveReloadOptions = { host: 'localhost' }; (function e (t, n, r) { function s (o, u) { if (!n[o]) { if (!t[o]) { var a = typeof require === 'function' && require; if (!u && a) return a(o, !0); if (i) return i(o, !0); var f = new Error("Cannot find module '" + o + "'"); throw f.code = 'MODULE_NOT_FOUND', f } var l = n[o] = {exports: {}}; t[o][0].call(l.exports, function (e) { var n = t[o][1][e]; return s(n ? n : e) }, l, l.exports, e, t, n, r) } return n[o].exports } var i = typeof require === 'function' && require; for (var o = 0; o < r.length; o++)s(r[o]); return s })({1: [function (require, module, exports) { diff --git a/app/scripts/config.js b/app/scripts/config.js index f26e6778d..5f6ffd936 100644 --- a/app/scripts/config.js +++ b/app/scripts/config.js @@ -1,12 +1,14 @@ const MAINET_RPC_URL = 'https://mainnet.infura.io/' const TESTNET_RPC_URL = 'https://morden.infura.io/' const DEFAULT_RPC_URL = TESTNET_RPC_URL +const CLASSIC_RPC_URL = 'https://mainnet-nf.infura.io/' module.exports = { network: { default: DEFAULT_RPC_URL, mainnet: MAINET_RPC_URL, testnet: TESTNET_RPC_URL, + classic: CLASSIC_RPC_URL, }, } diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index d7df5343b..727cd46fc 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -4,6 +4,7 @@ const migrations = require('./migrations') const TESTNET_RPC = MetamaskConfig.network.testnet const MAINNET_RPC = MetamaskConfig.network.mainnet +const CLASSIC_RPC = MetamaskConfig.network.classic /* The config-manager is a convenience object * wrapping a pojo-migrator. @@ -144,6 +145,9 @@ ConfigManager.prototype.getCurrentRpcAddress = function () { case 'testnet': return TESTNET_RPC + case 'classic': + return CLASSIC_RPC + default: return provider && provider.rpcTarget ? provider.rpcTarget : TESTNET_RPC } diff --git a/ui/app/app.js b/ui/app/app.js index df5350f67..b8deedc13 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -131,6 +131,7 @@ App.prototype.renderAppBar = function () { h(NetworkIndicator, { network: this.props.network, + provider: this.props.provider, onClick: (event) => { event.preventDefault() event.stopPropagation() @@ -221,6 +222,16 @@ App.prototype.renderNetworkDropdown = function () { action: () => props.dispatch(actions.setProviderType('mainnet')), icon: h('.menu-icon.diamond'), activeNetworkRender: props.network, + provider: props.provider, + }), + + h(DropMenuItem, { + label: 'Ethereum Classic Network', + closeMenu: () => this.setState({ isNetworkMenuOpen: false }), + action: () => props.dispatch(actions.setProviderType('classic')), + icon: h('.menu-icon.hollow-diamond'), + activeNetworkRender: props.network, + provider: props.provider, }), h(DropMenuItem, { @@ -238,6 +249,7 @@ App.prototype.renderNetworkDropdown = function () { icon: h('i.fa.fa-question-circle.fa-lg', { ariaHidden: true }), activeNetworkRender: props.provider.rpcTarget, }), + this.renderCustomOption(props.provider.rpcTarget), ]) } diff --git a/ui/app/components/drop-menu-item.js b/ui/app/components/drop-menu-item.js index f5800f799..8bff3e131 100644 --- a/ui/app/components/drop-menu-item.js +++ b/ui/app/components/drop-menu-item.js @@ -32,20 +32,24 @@ DropMenuItem.prototype.render = function () { } DropMenuItem.prototype.activeNetworkRender = function () { - var activeNetwork = this.props.activeNetworkRender + let activeNetwork = this.props.activeNetworkRender + let { provider } = this.props if (activeNetwork === undefined) return switch (this.props.label) { case 'Main Ethereum Network': - if (activeNetwork === '1') return h('.check', ' ✓') + if (provider.type === 'mainnet') return h('.check', '✓') + break + case 'Ethereum Classic Network': + if (provider.type === 'classic') return h('.check', '✓') break case 'Morden Test Network': - if (activeNetwork === '2') return h('.check', ' ✓') + if (activeNetwork === '2') return h('.check', '✓') break case 'Localhost 8545': - if (activeNetwork === 'http://localhost:8545') return h('.check', ' ✓') + if (activeNetwork === 'http://localhost:8545') return h('.check', '✓') break default: - if (activeNetwork === 'custom') return h('.check', ' ✓') + if (activeNetwork === 'custom') return h('.check', '✓') } } diff --git a/ui/app/components/network.js b/ui/app/components/network.js index 032e71699..22b11aa6c 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -11,11 +11,13 @@ function Network () { } Network.prototype.render = function () { - const state = this.props - const networkNumber = state.network + const props = this.props + const networkNumber = props.network + const providerName = props.provider.type let iconName, hoverText if (networkNumber === 'loading') { + return h('img', { title: 'Attempting to connect to blockchain.', onClick: (event) => this.props.onClick(event), @@ -25,9 +27,13 @@ Network.prototype.render = function () { }, src: 'images/loading.svg', }) - } else if (parseInt(networkNumber) === 1) { + + } else if (providerName === 'mainnet') { hoverText = 'Main Ethereum Network' iconName = 'ethereum-network' + } else if (providerName === 'classic') { + hoverText = 'Ethereum Classic Network' + iconName = 'classic-network' } else if (parseInt(networkNumber) === 2) { hoverText = 'Morden Test Network' iconName = 'morden-test-network' @@ -55,6 +61,15 @@ Network.prototype.render = function () { }}, 'Etherum Main Net'), ]) + case 'classic-network': + return h('.network-indicator', [ + h('.menu-icon.hollow-diamond'), + h('.network-name', { + style: { + color: '#039396', + }}, + 'Etherum Classic'), + ]) case 'morden-test-network': return h('.network-indicator', [ h('.menu-icon.red-dot'), diff --git a/ui/app/css/lib.css b/ui/app/css/lib.css index 22b26d4f1..bcd6a4a67 100644 --- a/ui/app/css/lib.css +++ b/ui/app/css/lib.css @@ -178,6 +178,11 @@ hr.horizontal-line { background: #038789; } +.hollow-diamond { + transform: rotate(45deg); + border: 1px solid #038789; +} + .pending-dot { background: red; left: 14px; diff --git a/ui/app/settings.js b/ui/app/settings.js index e56f4ee63..454cc95e0 100644 --- a/ui/app/settings.js +++ b/ui/app/settings.js @@ -32,7 +32,6 @@ AppSettingsPage.prototype.render = function () { htmlFor: 'settings-rpc-endpoint', }, 'RPC Endpoint:'), h('input', { - // value: '//testrpc.metamask.io', type: 'url', id: 'settings-rpc-endpoint', onKeyPress: this.onKeyPress.bind(this), From 51535ab0cc489baf8410e3cbd2ab99c6376716d0 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 28 Jul 2016 10:54:00 -0700 Subject: [PATCH 2/5] Fix margin on provider checkmarks --- ui/app/css/index.css | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/app/css/index.css b/ui/app/css/index.css index 77bf7bf97..612dc9d9a 100644 --- a/ui/app/css/index.css +++ b/ui/app/css/index.css @@ -158,6 +158,7 @@ textarea.twelve-word-phrase { } .check { + margin-left: 7px; color: #F7861C; flex: 1 0 auto; display: flex; From 5d83b9176b8f5c8186dcdf5ac57757b3c0d4dd65 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 28 Jul 2016 10:54:25 -0700 Subject: [PATCH 3/5] Bump changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2e3e8209..94ba2c351 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Current Master +- Add Ethereum Classic to provider menu + ## 2.7.1 2016-07-27 - Fix bug where web3 would sometimes not be injected in time for the application. From 5feff0b1f5d14bb723ff16224d67e87668d72757 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 28 Jul 2016 11:04:02 -0700 Subject: [PATCH 4/5] Add missing reference for provider --- ui/app/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/app.js b/ui/app/app.js index b8deedc13..0bafb07ae 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -131,7 +131,7 @@ App.prototype.renderAppBar = function () { h(NetworkIndicator, { network: this.props.network, - provider: this.props.provider, + provider: this.props.provider onClick: (event) => { event.preventDefault() event.stopPropagation() From c805963a22715b3d575a2dc8f7b6585e673614e2 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 28 Jul 2016 11:10:54 -0700 Subject: [PATCH 5/5] Linted --- ui/app/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/app/app.js b/ui/app/app.js index 0bafb07ae..b8deedc13 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -131,7 +131,7 @@ App.prototype.renderAppBar = function () { h(NetworkIndicator, { network: this.props.network, - provider: this.props.provider + provider: this.props.provider, onClick: (event) => { event.preventDefault() event.stopPropagation()