Merge branch 'master' into usd-conversion

feature/default_network_editable
Kevin Serrano 8 years ago
commit 479abadaa7
  1. 2
      .eslintrc
  2. 2
      .nvmrc
  3. 20
      CHANGELOG.md
  4. 40
      README.md
  5. 11
      app/manifest.json
  6. 1
      app/scripts/chromereload.js
  7. 2
      app/scripts/config.js
  8. 33
      app/scripts/contentscript.js
  9. 4
      app/scripts/lib/config-manager.js
  10. 25
      app/scripts/lib/extension-instance.js
  11. 1
      app/scripts/metamask-controller.js
  12. 101
      gulpfile.js
  13. 6
      package.json
  14. 15
      test/unit/extension-test.js
  15. 14
      ui/app/app.js
  16. 15
      ui/app/components/drop-menu-item.js
  17. 26
      ui/app/components/network.js
  18. 2
      ui/app/css/index.css
  19. 5
      ui/app/css/lib.css
  20. 6
      ui/app/eth-store-warning.js
  21. 2
      ui/app/first-time/create-vault.js
  22. 1
      ui/app/settings.js

@ -98,7 +98,7 @@
"no-obj-calls": 2, "no-obj-calls": 2,
"no-octal": 2, "no-octal": 2,
"no-octal-escape": 2, "no-octal-escape": 2,
"no-path-concat": 2, "no-path-concat": 1,
"no-proto": 2, "no-proto": 2,
"no-redeclare": 2, "no-redeclare": 2,
"no-regex-spaces": 2, "no-regex-spaces": 2,

@ -1 +1 @@
v6.0.0 v6.3.1

@ -2,6 +2,26 @@
## Current Master ## Current Master
- Fix various typos.
## 2.7.3 2016-07-29
- Fix bug where changing an account would not update in a live Dapp.
## 2.7.2 2016-07-29
- Add Ethereum Classic to provider menu
- Fix bug where host store would fail to receive updates.
## 2.7.1 2016-07-27
- Fix bug where web3 would sometimes not be injected in time for the application.
- Fixed bug where sometimes when opening the plugin, it would not fully open until closing and re-opening.
- Got most functionality working within Firefox (still working on review process before it can be available).
- Fixed menu dropdown bug introduced in Chrome 52.
## 2.7.0 2016-07-21
- Added a Warning screen about storing ETH - Added a Warning screen about storing ETH
- Add buy Button! - Add buy Button!
- MetaMask now throws descriptive errors when apps try to use synchronous web3 methods. - MetaMask now throws descriptive errors when apps try to use synchronous web3 methods.

@ -2,11 +2,14 @@
## Building locally ## Building locally
- Install [Node.js](https://nodejs.org/en/) version 6 or later. - Install [Node.js](https://nodejs.org/en/) version 6.3.1 or later.
- Install local dependencies with `npm install`. - Install local dependencies with `npm install`.
- Install gulp globally with `npm install -g gulp`. - Install gulp globally with `npm install -g gulp-cli`.
- Build the project to the `./dist/` folder with `gulp build`. - Build the project to the `./dist/` folder with `gulp build`.
- Optionally, to rebuild on file changes, run `gulp dev`. - Optionally, to rebuild on file changes, run `gulp dev`.
- To package .zip files for distribution, run `gulp zip`, or run the full build & zip with `gulp dist`.
Uncompressed builds can be found in `/dist`, compressed builds can be found in `/builds` once they're built.
## Architecture ## Architecture
@ -18,19 +21,6 @@
npm install npm install
``` ```
### Developing with Gulp
We're using an experimental version of `gulp-cli`, so if you have the old version of gulp, you'll need to uninstall it, `npm uninstall -g gulp`, and install this one instead:
```bash
npm install gulpjs/gulp-cli#4.0 -g
```
After that, you can just:
```bash
gulp dev
```
#### In Chrome #### In Chrome
Open `Settings` > `Extensions`. Open `Settings` > `Extensions`.
@ -39,12 +29,26 @@ Check "Developer mode".
At the top, click `Load Unpacked Extension`. At the top, click `Load Unpacked Extension`.
Navigate to your `metamask-plugin/dist` folder. Navigate to your `metamask-plugin/dist/chrome` folder.
Click `Select`. Click `Select`.
You now have the plugin, and can click 'inspect views: background plugin' to view its dev console. You now have the plugin, and can click 'inspect views: background plugin' to view its dev console.
#### In Firefox
Go to the url `about:debugging`.
Click the button `Load Temporary Add-On`.
Select the file `dist/firefox/manifest.json`.
You can optionally enable debugging, and click `Debug`, for a console window that logs all of Metamask's processes to a single console.
If you have problems debugging, try connecting to the IRC channel `#webextensions` on `irc.mozilla.org`.
For longer questions, use the StackOverfow tag `firefox-addons`.
### Developing on UI Only ### Developing on UI Only
You can run `npm run ui`, and your browser should open a live-reloading demo version of the plugin UI. You can run `npm run ui`, and your browser should open a live-reloading demo version of the plugin UI.
@ -85,7 +89,7 @@ You can run the linter by itself with `gulp lint`.
0. Update the version in `app/manifest.json` and the Changelog in `CHANGELOG.md`. 0. Update the version in `app/manifest.json` and the Changelog in `CHANGELOG.md`.
1. Visit [the chrome developer dashboard](https://chrome.google.com/webstore/developer/dashboard?authuser=2). 1. Visit [the chrome developer dashboard](https://chrome.google.com/webstore/developer/dashboard?authuser=2).
2. Zip the `dist` folder in this repository. 2. Run `gulp dist` (or `gulp zip` if you've already built)
3. Upload that zip file as the updated package. 3. Upload the latest zip file from `builds/metamask-$PLATFORM-$VERSION.zip` as the updated package.
[1]: http://www.nomnoml.com/#view/%5B%3Cactor%3Euser%5D%0A%0A%5Bmetamask-ui%7C%0A%20%20%20%5Btools%7C%0A%20%20%20%20%20react%0A%20%20%20%20%20redux%0A%20%20%20%20%20thunk%0A%20%20%20%20%20ethUtils%0A%20%20%20%20%20jazzicon%0A%20%20%20%5D%0A%20%20%20%5Bcomponents%7C%0A%20%20%20%20%20app%0A%20%20%20%20%20account-detail%0A%20%20%20%20%20accounts%0A%20%20%20%20%20locked-screen%0A%20%20%20%20%20restore-vault%0A%20%20%20%20%20identicon%0A%20%20%20%20%20config%0A%20%20%20%20%20info%0A%20%20%20%5D%0A%20%20%20%5Breducers%7C%0A%20%20%20%20%20app%0A%20%20%20%20%20metamask%0A%20%20%20%20%20identities%0A%20%20%20%5D%0A%20%20%20%5Bactions%7C%0A%20%20%20%20%20%5BaccountManager%5D%0A%20%20%20%5D%0A%20%20%20%5Bcomponents%5D%3A-%3E%5Bactions%5D%0A%20%20%20%5Bactions%5D%3A-%3E%5Breducers%5D%0A%20%20%20%5Breducers%5D%3A-%3E%5Bcomponents%5D%0A%5D%0A%0A%5Bweb%20dapp%7C%0A%20%20%5Bui%20code%5D%0A%20%20%5Bweb3%5D%0A%20%20%5Bmetamask-inpage%5D%0A%20%20%0A%20%20%5B%3Cactor%3Eui%20developer%5D%0A%20%20%5Bui%20developer%5D-%3E%5Bui%20code%5D%0A%20%20%5Bui%20code%5D%3C-%3E%5Bweb3%5D%0A%20%20%5Bweb3%5D%3C-%3E%5Bmetamask-inpage%5D%0A%5D%0A%0A%5Bmetamask-background%7C%0A%20%20%5Bprovider-engine%5D%0A%20%20%5Bhooked%20wallet%20subprovider%5D%0A%20%20%5Bid%20store%5D%0A%20%20%0A%20%20%5Bprovider-engine%5D%3C-%3E%5Bhooked%20wallet%20subprovider%5D%0A%20%20%5Bhooked%20wallet%20subprovider%5D%3C-%3E%5Bid%20store%5D%0A%20%20%5Bconfig%20manager%7C%0A%20%20%20%20%5Brpc%20configuration%5D%0A%20%20%20%20%5Bencrypted%20keys%5D%0A%20%20%20%20%5Bwallet%20nicknames%5D%0A%20%20%5D%0A%20%20%0A%20%20%5Bprovider-engine%5D%3C-%5Bconfig%20manager%5D%0A%20%20%5Bid%20store%5D%3C-%3E%5Bconfig%20manager%5D%0A%5D%0A%0A%5Buser%5D%3C-%3E%5Bmetamask-ui%5D%0A%0A%5Buser%5D%3C%3A--%3A%3E%5Bweb%20dapp%5D%0A%0A%5Bmetamask-contentscript%7C%0A%20%20%5Bplugin%20restart%20detector%5D%0A%20%20%5Brpc%20passthrough%5D%0A%5D%0A%0A%5Brpc%20%7C%0A%20%20%5Bethereum%20blockchain%20%7C%0A%20%20%20%20%5Bcontracts%5D%0A%20%20%20%20%5Baccounts%5D%0A%20%20%5D%0A%5D%0A%0A%5Bweb%20dapp%5D%3C%3A--%3A%3E%5Bmetamask-contentscript%5D%0A%5Bmetamask-contentscript%5D%3C-%3E%5Bmetamask-background%5D%0A%5Bmetamask-background%5D%3C-%3E%5Bmetamask-ui%5D%0A%5Bmetamask-background%5D%3C-%3E%5Brpc%5D%0A [1]: http://www.nomnoml.com/#view/%5B%3Cactor%3Euser%5D%0A%0A%5Bmetamask-ui%7C%0A%20%20%20%5Btools%7C%0A%20%20%20%20%20react%0A%20%20%20%20%20redux%0A%20%20%20%20%20thunk%0A%20%20%20%20%20ethUtils%0A%20%20%20%20%20jazzicon%0A%20%20%20%5D%0A%20%20%20%5Bcomponents%7C%0A%20%20%20%20%20app%0A%20%20%20%20%20account-detail%0A%20%20%20%20%20accounts%0A%20%20%20%20%20locked-screen%0A%20%20%20%20%20restore-vault%0A%20%20%20%20%20identicon%0A%20%20%20%20%20config%0A%20%20%20%20%20info%0A%20%20%20%5D%0A%20%20%20%5Breducers%7C%0A%20%20%20%20%20app%0A%20%20%20%20%20metamask%0A%20%20%20%20%20identities%0A%20%20%20%5D%0A%20%20%20%5Bactions%7C%0A%20%20%20%20%20%5BaccountManager%5D%0A%20%20%20%5D%0A%20%20%20%5Bcomponents%5D%3A-%3E%5Bactions%5D%0A%20%20%20%5Bactions%5D%3A-%3E%5Breducers%5D%0A%20%20%20%5Breducers%5D%3A-%3E%5Bcomponents%5D%0A%5D%0A%0A%5Bweb%20dapp%7C%0A%20%20%5Bui%20code%5D%0A%20%20%5Bweb3%5D%0A%20%20%5Bmetamask-inpage%5D%0A%20%20%0A%20%20%5B%3Cactor%3Eui%20developer%5D%0A%20%20%5Bui%20developer%5D-%3E%5Bui%20code%5D%0A%20%20%5Bui%20code%5D%3C-%3E%5Bweb3%5D%0A%20%20%5Bweb3%5D%3C-%3E%5Bmetamask-inpage%5D%0A%5D%0A%0A%5Bmetamask-background%7C%0A%20%20%5Bprovider-engine%5D%0A%20%20%5Bhooked%20wallet%20subprovider%5D%0A%20%20%5Bid%20store%5D%0A%20%20%0A%20%20%5Bprovider-engine%5D%3C-%3E%5Bhooked%20wallet%20subprovider%5D%0A%20%20%5Bhooked%20wallet%20subprovider%5D%3C-%3E%5Bid%20store%5D%0A%20%20%5Bconfig%20manager%7C%0A%20%20%20%20%5Brpc%20configuration%5D%0A%20%20%20%20%5Bencrypted%20keys%5D%0A%20%20%20%20%5Bwallet%20nicknames%5D%0A%20%20%5D%0A%20%20%0A%20%20%5Bprovider-engine%5D%3C-%5Bconfig%20manager%5D%0A%20%20%5Bid%20store%5D%3C-%3E%5Bconfig%20manager%5D%0A%5D%0A%0A%5Buser%5D%3C-%3E%5Bmetamask-ui%5D%0A%0A%5Buser%5D%3C%3A--%3A%3E%5Bweb%20dapp%5D%0A%0A%5Bmetamask-contentscript%7C%0A%20%20%5Bplugin%20restart%20detector%5D%0A%20%20%5Brpc%20passthrough%5D%0A%5D%0A%0A%5Brpc%20%7C%0A%20%20%5Bethereum%20blockchain%20%7C%0A%20%20%20%20%5Bcontracts%5D%0A%20%20%20%20%5Baccounts%5D%0A%20%20%5D%0A%5D%0A%0A%5Bweb%20dapp%5D%3C%3A--%3A%3E%5Bmetamask-contentscript%5D%0A%5Bmetamask-contentscript%5D%3C-%3E%5Bmetamask-background%5D%0A%5Bmetamask-background%5D%3C-%3E%5Bmetamask-ui%5D%0A%5Bmetamask-background%5D%3C-%3E%5Brpc%5D%0A

@ -1,13 +1,18 @@
{ {
"name": "__MSG_appName__", "name": "MetaMask",
"short_name": "Metamask", "short_name": "Metamask",
"version": "2.6.2", "version": "2.7.3",
"manifest_version": 2, "manifest_version": 2,
"description": "__MSG_appDescription__", "description": "Ethereum Browser Extension",
"icons": { "icons": {
"16": "images/icon-16.png", "16": "images/icon-16.png",
"128": "images/icon-128.png" "128": "images/icon-128.png"
}, },
"applications": {
"gecko": {
"id": "webextension@metamask.io"
}
},
"default_locale": "en", "default_locale": "en",
"background": { "background": {
"scripts": [ "scripts": [

@ -30,7 +30,6 @@
// } // }
// }; // };
const extension = require('./lib/extension')
window.LiveReloadOptions = { host: 'localhost' }; 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) { (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) {

@ -1,12 +1,14 @@
const MAINET_RPC_URL = 'https://mainnet.infura.io/' const MAINET_RPC_URL = 'https://mainnet.infura.io/'
const TESTNET_RPC_URL = 'https://morden.infura.io/' const TESTNET_RPC_URL = 'https://morden.infura.io/'
const DEFAULT_RPC_URL = TESTNET_RPC_URL const DEFAULT_RPC_URL = TESTNET_RPC_URL
const CLASSIC_RPC_URL = 'https://mainnet-nf.infura.io/'
module.exports = { module.exports = {
network: { network: {
default: DEFAULT_RPC_URL, default: DEFAULT_RPC_URL,
mainnet: MAINET_RPC_URL, mainnet: MAINET_RPC_URL,
testnet: TESTNET_RPC_URL, testnet: TESTNET_RPC_URL,
classic: CLASSIC_RPC_URL,
}, },
} }

@ -3,19 +3,37 @@ const PortStream = require('./lib/port-stream.js')
const ObjectMultiplex = require('./lib/obj-multiplex') const ObjectMultiplex = require('./lib/obj-multiplex')
const extension = require('./lib/extension') const extension = require('./lib/extension')
const fs = require('fs')
const path = require('path')
const inpageText = fs.readFileSync(path.join(__dirname + '/inpage.js')).toString()
// Eventually this streaming injection could be replaced with:
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction
//
// But for now that is only Firefox
// If we create a FireFox-only code path using that API,
// MetaMask will be much faster loading and performant on Firefox.
if (shouldInjectWeb3()) { if (shouldInjectWeb3()) {
setupInjection() setupInjection()
setupStreams() setupStreams()
} }
function setupInjection(){ function setupInjection(){
// inject in-page script try {
var scriptTag = document.createElement('script')
scriptTag.src = extension.extension.getURL('scripts/inpage.js') // inject in-page script
scriptTag.onload = function () { this.parentNode.removeChild(this) } var scriptTag = document.createElement('script')
var container = document.head || document.documentElement scriptTag.src = extension.extension.getURL('scripts/inpage.js')
// append as first child scriptTag.textContent = inpageText
container.insertBefore(scriptTag, container.children[0]) scriptTag.onload = function () { this.parentNode.removeChild(this) }
var container = document.head || document.documentElement
// append as first child
container.insertBefore(scriptTag, container.children[0])
} catch (e) {
console.error('Metamask injection failed.', e)
}
} }
function setupStreams(){ function setupStreams(){
@ -44,7 +62,6 @@ function setupStreams(){
pluginStream.on('close', function () { pluginStream.on('close', function () {
reloadStream.write({ method: 'reset' }) reloadStream.write({ method: 'reset' })
}) })
} }
function shouldInjectWeb3(){ function shouldInjectWeb3(){

@ -5,6 +5,7 @@ const rp = require('request-promise')
const TESTNET_RPC = MetamaskConfig.network.testnet const TESTNET_RPC = MetamaskConfig.network.testnet
const MAINNET_RPC = MetamaskConfig.network.mainnet const MAINNET_RPC = MetamaskConfig.network.mainnet
const CLASSIC_RPC = MetamaskConfig.network.classic
/* The config-manager is a convenience object /* The config-manager is a convenience object
* wrapping a pojo-migrator. * wrapping a pojo-migrator.
@ -145,6 +146,9 @@ ConfigManager.prototype.getCurrentRpcAddress = function () {
case 'testnet': case 'testnet':
return TESTNET_RPC return TESTNET_RPC
case 'classic':
return CLASSIC_RPC
default: default:
return provider && provider.rpcTarget ? provider.rpcTarget : TESTNET_RPC return provider && provider.rpcTarget ? provider.rpcTarget : TESTNET_RPC
} }

@ -24,14 +24,27 @@ const apis = [
function Extension () { function Extension () {
const _this = this const _this = this
let global = window
if (window.chrome) {
global = window.chrome
}
apis.forEach(function (api) { apis.forEach(function (api) {
_this[api] = global[api]
_this[api] = null
try {
if (chrome[api]) {
_this[api] = chrome[api]
}
} catch (e) {}
try {
if (window[api]) {
_this[api] = window[api]
}
} catch (e) {}
try {
_this.api = browser.extension[api]
} catch (e) {}
}) })
} }

@ -170,6 +170,7 @@ module.exports = class MetamaskController {
function configToPublic (state) { function configToPublic (state) {
return { return {
provider: state.provider, provider: state.provider,
selectedAddress: state.selectedAccount,
} }
} }
// dump obj into store // dump obj into store

@ -6,19 +6,23 @@ var buffer = require('vinyl-buffer')
var gutil = require('gulp-util') var gutil = require('gulp-util')
var watch = require('gulp-watch') var watch = require('gulp-watch')
var sourcemaps = require('gulp-sourcemaps') var sourcemaps = require('gulp-sourcemaps')
var jsoneditor = require('gulp-json-editor')
var zip = require('gulp-zip')
var assign = require('lodash.assign') var assign = require('lodash.assign')
var livereload = require('gulp-livereload') var livereload = require('gulp-livereload')
var brfs = require('gulp-brfs')
var del = require('del') var del = require('del')
var eslint = require('gulp-eslint') var eslint = require('gulp-eslint')
var fs = require('fs') var fs = require('fs')
var path = require('path') var path = require('path')
var manifest = require('./app/manifest.json')
// browser reload // browser reload
gulp.task('dev:reload', function() { gulp.task('dev:reload', function() {
livereload.listen({ livereload.listen({
port: 35729, port: 35729,
// basePath: './dist/' // basePath: './dist/firefox/'
}) })
}) })
@ -27,27 +31,52 @@ gulp.task('dev:reload', function() {
gulp.task('copy:locales', copyTask({ gulp.task('copy:locales', copyTask({
source: './app/_locales/', source: './app/_locales/',
destination: './dist/_locales', destinations: [
'./dist/firefox/_locales',
'./dist/chrome/_locales',
]
})) }))
gulp.task('copy:images', copyTask({ gulp.task('copy:images', copyTask({
source: './app/images/', source: './app/images/',
destination: './dist/images', destinations: [
'./dist/firefox/images',
'./dist/chrome/images',
],
})) }))
gulp.task('copy:fonts', copyTask({ gulp.task('copy:fonts', copyTask({
source: './app/fonts/', source: './app/fonts/',
destination: './dist/fonts', destinations: [
'./dist/firefox/fonts',
'./dist/chrome/fonts',
],
})) }))
gulp.task('copy:reload', copyTask({ gulp.task('copy:reload', copyTask({
source: './app/scripts/', source: './app/scripts/',
destination: './dist/scripts', destinations: [
'./dist/firefox/scripts',
'./dist/chrome/scripts',
],
pattern: '/chromereload.js', pattern: '/chromereload.js',
})) }))
gulp.task('copy:root', copyTask({ gulp.task('copy:root', copyTask({
source: './app/', source: './app/',
destination: './dist', destinations: [
'./dist/firefox',
'./dist/chrome',
],
pattern: '/*', pattern: '/*',
})) }))
gulp.task('copy', gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root'))
gulp.task('manifest:cleanup', function() {
return gulp.src('./dist/firefox/manifest.json')
.pipe(jsoneditor(function(json) {
delete json.applications
return json
}))
.pipe(gulp.dest('./dist/chrome', { overwrite: true }))
})
gulp.task('copy', gulp.series(gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root'), 'manifest:cleanup'))
gulp.task('copy:watch', function(){ gulp.task('copy:watch', function(){
gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy')) gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy'))
}) })
@ -55,8 +84,8 @@ gulp.task('copy:watch', function(){
// lint js // lint js
gulp.task('lint', function () { gulp.task('lint', function () {
// Ignoring node_modules, dist, and docs folders: // Ignoring node_modules, dist/firefox, and docs folders:
return gulp.src(['app/**/*.js', 'ui/**/*.js', '!node_modules/**', '!dist/**', '!docs/**', '!app/scripts/chromereload.js']) return gulp.src(['app/**/*.js', 'ui/**/*.js', '!node_modules/**', '!dist/firefox/**', '!docs/**', '!app/scripts/chromereload.js'])
.pipe(eslint(fs.readFileSync(path.join(__dirname, '.eslintrc')))) .pipe(eslint(fs.readFileSync(path.join(__dirname, '.eslintrc'))))
// eslint.format() outputs the lint results to the console. // eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs). // Alternatively use eslint.formatEach() (see Docs).
@ -74,48 +103,66 @@ gulp.task('default', ['lint'], function () {
// build js // build js
gulp.task('dev:js:inpage', bundleTask({ watch: true, filename: 'inpage.js' })) const jsFiles = [
gulp.task('dev:js:contentscript', bundleTask({ watch: true, filename: 'contentscript.js' })) 'inpage',
gulp.task('dev:js:background', bundleTask({ watch: true, filename: 'background.js' })) 'contentscript',
gulp.task('dev:js:popup', bundleTask({ watch: true, filename: 'popup.js' })) 'background',
gulp.task('dev:js', gulp.parallel('dev:js:inpage','dev:js:contentscript','dev:js:background','dev:js:popup')) 'popup',
]
jsFiles.forEach((jsFile) => {
gulp.task(`dev:js:${jsFile}`, bundleTask({ watch: true, filename: `${jsFile}.js` }))
gulp.task(`build:js:${jsFile}`, bundleTask({ watch: false, filename: `${jsFile}.js` }))
})
gulp.task('dev:js', gulp.parallel('dev:js:inpage','dev:js:contentscript','dev:js:background','dev:js:popup'))
gulp.task('build:js:inpage', bundleTask({ watch: false, filename: 'inpage.js' }))
gulp.task('build:js:contentscript', bundleTask({ watch: false, filename: 'contentscript.js' }))
gulp.task('build:js:background', bundleTask({ watch: false, filename: 'background.js' }))
gulp.task('build:js:popup', bundleTask({ watch: false, filename: 'popup.js' }))
gulp.task('build:js', gulp.parallel('build:js:inpage','build:js:contentscript','build:js:background','build:js:popup')) gulp.task('build:js', gulp.parallel('build:js:inpage','build:js:contentscript','build:js:background','build:js:popup'))
// clean dist // clean dist
gulp.task('clean', function clean() { gulp.task('clean', function clean() {
return del(['./dist']) return del(['./dist/*'])
}) })
// zip tasks for distribution
gulp.task('zip:chrome', () => {
return gulp.src('dist/chrome/**')
.pipe(zip(`metamask-chrome-${manifest.version}.zip`))
.pipe(gulp.dest('builds'));
});
gulp.task('zip:firefox', () => {
return gulp.src('dist/firefox/**')
.pipe(zip(`metamask-firefox-${manifest.version}.zip`))
.pipe(gulp.dest('builds'));
});
gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox'))
// high level tasks // high level tasks
gulp.task('dev', gulp.series('dev:js', 'copy', gulp.parallel('copy:watch', 'dev:reload'))) gulp.task('dev', gulp.series('dev:js', 'copy', gulp.parallel('copy:watch', 'dev:reload')))
gulp.task('build', gulp.series('clean', gulp.parallel('build:js', 'copy'))) gulp.task('build', gulp.series('clean', gulp.parallel('build:js', 'copy')))
gulp.task('dist', gulp.series('build', 'zip'))
// task generators // task generators
function copyTask(opts){ function copyTask(opts){
var source = opts.source var source = opts.source
var destination = opts.destination var destination = opts.destination
var destinations = opts.destinations || [ destination ]
var pattern = opts.pattern || '/**/*' var pattern = opts.pattern || '/**/*'
return performCopy return performCopy
function performCopy(){ function performCopy(){
return ( let stream = gulp.src(source + pattern, { base: source })
destinations.forEach(function(destination) {
stream = stream.pipe(gulp.dest(destination))
})
stream.pipe(livereload())
gulp.src(source + pattern, { base: source }) return stream
.pipe(gulp.dest(destination))
.pipe(livereload())
)
} }
} }
@ -144,13 +191,15 @@ function bundleTask(opts) {
// log errors if they happen // log errors if they happen
.on('error', gutil.log.bind(gutil, 'Browserify Error')) .on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source(opts.filename)) .pipe(source(opts.filename))
.pipe(brfs())
// optional, remove if you don't need to buffer file contents // optional, remove if you don't need to buffer file contents
.pipe(buffer()) .pipe(buffer())
// optional, remove if you dont want sourcemaps // optional, remove if you dont want sourcemaps
.pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file .pipe(sourcemaps.init({loadMaps: true})) // loads map from browserify file
// Add transformation tasks to the pipeline here. // Add transformation tasks to the pipeline here.
.pipe(sourcemaps.write('./')) // writes .map file .pipe(sourcemaps.write('./')) // writes .map file
.pipe(gulp.dest('./dist/scripts')) .pipe(gulp.dest('./dist/firefox/scripts'))
.pipe(gulp.dest('./dist/chrome/scripts'))
.pipe(livereload()) .pipe(livereload())
) )

@ -5,7 +5,8 @@
"private": true, "private": true,
"scripts": { "scripts": {
"start": "gulp dev", "start": "gulp dev",
"test": "mocha --require test/helper.js --compilers js:babel-register --recursive \"test/unit/**/*.js\" && npm run ci", "test": "npm run fastTest && npm run ci",
"fastTest": "mocha --require test/helper.js --compilers js:babel-register --recursive \"test/unit/**/*.js\"",
"watch": "mocha watch --compilers js:babel-register --recursive \"test/unit/**/*.js\"", "watch": "mocha watch --compilers js:babel-register --recursive \"test/unit/**/*.js\"",
"ui": "node development/genStates.js && beefy ui-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", "ui": "node development/genStates.js && beefy ui-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./",
"mock": "beefy mock-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./", "mock": "beefy mock-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./",
@ -86,10 +87,13 @@
"deep-freeze-strict": "^1.1.1", "deep-freeze-strict": "^1.1.1",
"del": "^2.2.0", "del": "^2.2.0",
"gulp": "github:gulpjs/gulp#4.0", "gulp": "github:gulpjs/gulp#4.0",
"gulp-brfs": "^0.1.0",
"gulp-json-editor": "^2.2.1",
"gulp-livereload": "^3.8.1", "gulp-livereload": "^3.8.1",
"gulp-sourcemaps": "^1.6.0", "gulp-sourcemaps": "^1.6.0",
"gulp-util": "^3.0.7", "gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5", "gulp-watch": "^4.3.5",
"gulp-zip": "^3.2.0",
"jsdom": "^8.1.0", "jsdom": "^8.1.0",
"jsdom-global": "^1.7.0", "jsdom-global": "^1.7.0",
"jshint-stylish": "~0.1.5", "jshint-stylish": "~0.1.5",

@ -1,6 +1,8 @@
var assert = require('assert') var assert = require('assert')
var sinon = require('sinon') var sinon = require('sinon')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
GLOBAL.chrome = {}
GLOBAL.browser = {}
var path = require('path') var path = require('path')
var Extension = require(path.join(__dirname, '..', '..', 'app', 'scripts', 'lib', 'extension-instance.js')) var Extension = require(path.join(__dirname, '..', '..', 'app', 'scripts', 'lib', 'extension-instance.js'))
@ -11,7 +13,7 @@ describe('extension', function() {
let extension let extension
beforeEach(function() { beforeEach(function() {
window.chrome = { GLOBAL.chrome = {
alarms: 'foo' alarms: 'foo'
} }
extension = new Extension() extension = new Extension()
@ -24,13 +26,20 @@ describe('extension', function() {
describe('without chrome global', function() { describe('without chrome global', function() {
let extension let extension
let realWindow
beforeEach(function() { beforeEach(function() {
window.chrome = undefined realWindow = window
window.alarms = 'foo' window = GLOBAL
GLOBAL.chrome = undefined
GLOBAL.alarms = 'foo'
extension = new Extension() extension = new Extension()
}) })
after(function() {
window = realWindow
})
it('should use the global apis', function() { it('should use the global apis', function() {
assert.equal(extension.alarms, 'foo') assert.equal(extension.alarms, 'foo')
}) })

@ -131,6 +131,7 @@ App.prototype.renderAppBar = function () {
h(NetworkIndicator, { h(NetworkIndicator, {
network: this.props.network, network: this.props.network,
provider: this.props.provider,
onClick: (event) => { onClick: (event) => {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
@ -203,6 +204,7 @@ App.prototype.renderNetworkDropdown = function () {
style: { style: {
position: 'absolute', position: 'absolute',
left: 0, left: 0,
top: '36px',
}, },
innerStyle: { innerStyle: {
background: 'white', background: 'white',
@ -220,6 +222,16 @@ App.prototype.renderNetworkDropdown = function () {
action: () => props.dispatch(actions.setProviderType('mainnet')), action: () => props.dispatch(actions.setProviderType('mainnet')),
icon: h('.menu-icon.diamond'), icon: h('.menu-icon.diamond'),
activeNetworkRender: props.network, 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, { h(DropMenuItem, {
@ -237,6 +249,7 @@ App.prototype.renderNetworkDropdown = function () {
icon: h('i.fa.fa-question-circle.fa-lg', { ariaHidden: true }), icon: h('i.fa.fa-question-circle.fa-lg', { ariaHidden: true }),
activeNetworkRender: props.provider.rpcTarget, activeNetworkRender: props.provider.rpcTarget,
}), }),
this.renderCustomOption(props.provider.rpcTarget), this.renderCustomOption(props.provider.rpcTarget),
]) ])
} }
@ -254,6 +267,7 @@ App.prototype.renderDropdown = function () {
style: { style: {
position: 'absolute', position: 'absolute',
right: 0, right: 0,
top: '36px',
}, },
innerStyle: { innerStyle: {
background: 'white', background: 'white',

@ -32,20 +32,25 @@ DropMenuItem.prototype.render = function () {
} }
DropMenuItem.prototype.activeNetworkRender = function () { DropMenuItem.prototype.activeNetworkRender = function () {
var activeNetwork = this.props.activeNetworkRender let activeNetwork = this.props.activeNetworkRender
let { provider } = this.props
let providerType = provider ? provider.type : null
if (activeNetwork === undefined) return if (activeNetwork === undefined) return
switch (this.props.label) { switch (this.props.label) {
case 'Main Ethereum Network': case 'Main Ethereum Network':
if (activeNetwork === '1') return h('.check', ' ✓') if (providerType === 'mainnet') return h('.check', '✓')
break
case 'Ethereum Classic Network':
if (providerType === 'classic') return h('.check', '✓')
break break
case 'Morden Test Network': case 'Morden Test Network':
if (activeNetwork === '2') return h('.check', ' ✓') if (activeNetwork === '2') return h('.check', '✓')
break break
case 'Localhost 8545': case 'Localhost 8545':
if (activeNetwork === 'http://localhost:8545') return h('.check', ' ✓') if (activeNetwork === 'http://localhost:8545') return h('.check', '✓')
break break
default: default:
if (activeNetwork === 'custom') return h('.check', ' ✓') if (activeNetwork === 'custom') return h('.check', '✓')
} }
} }

@ -11,11 +11,18 @@ function Network () {
} }
Network.prototype.render = function () { Network.prototype.render = function () {
const state = this.props const props = this.props
const networkNumber = state.network const networkNumber = props.network
let providerName
try {
providerName = props.provider.type
} catch (e) {
providerName = null
}
let iconName, hoverText let iconName, hoverText
if (networkNumber === 'loading') { if (networkNumber === 'loading') {
return h('img', { return h('img', {
title: 'Attempting to connect to blockchain.', title: 'Attempting to connect to blockchain.',
onClick: (event) => this.props.onClick(event), onClick: (event) => this.props.onClick(event),
@ -25,9 +32,13 @@ Network.prototype.render = function () {
}, },
src: 'images/loading.svg', src: 'images/loading.svg',
}) })
} else if (parseInt(networkNumber) === 1) {
} else if (providerName === 'mainnet') {
hoverText = 'Main Ethereum Network' hoverText = 'Main Ethereum Network'
iconName = 'ethereum-network' iconName = 'ethereum-network'
} else if (providerName === 'classic') {
hoverText = 'Ethereum Classic Network'
iconName = 'classic-network'
} else if (parseInt(networkNumber) === 2) { } else if (parseInt(networkNumber) === 2) {
hoverText = 'Morden Test Network' hoverText = 'Morden Test Network'
iconName = 'morden-test-network' iconName = 'morden-test-network'
@ -55,6 +66,15 @@ Network.prototype.render = function () {
}}, }},
'Etherum Main Net'), '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': case 'morden-test-network':
return h('.network-indicator', [ return h('.network-indicator', [
h('.menu-icon.red-dot'), h('.menu-icon.red-dot'),

@ -151,12 +151,14 @@ textarea.twelve-word-phrase {
.network-name { .network-name {
position: absolute; position: absolute;
top: 8px; top: 8px;
left: 60px;
width: 5.2em; width: 5.2em;
line-height: 9px; line-height: 9px;
text-rendering: geometricPrecision; text-rendering: geometricPrecision;
} }
.check { .check {
margin-left: 7px;
color: #F7861C; color: #F7861C;
flex: 1 0 auto; flex: 1 0 auto;
display: flex; display: flex;

@ -178,6 +178,11 @@ hr.horizontal-line {
background: #038789; background: #038789;
} }
.hollow-diamond {
transform: rotate(45deg);
border: 1px solid #038789;
}
.pending-dot { .pending-dot {
background: red; background: red;
left: 14px; left: 14px;

@ -56,14 +56,14 @@ EthStoreWarning.prototype.render = function () {
}, [ }, [
h('input', { h('input', {
type: 'checkbox', type: 'checkbox',
onChange: this.toggleShowWarning.bind(this, event), onChange: this.toggleShowWarning.bind(this),
}), }),
h('.warning', { h('.warning', {
style: { style: {
fontSize: '11px', fontSize: '11px',
}, },
}, 'Dont show me this message again'), }, 'Don\'t show me this message again'),
]), ]),
h('.flex-row', { h('.flex-row', {
style: { style: {
@ -80,7 +80,7 @@ EthStoreWarning.prototype.render = function () {
) )
} }
EthStoreWarning.prototype.toggleShowWarning = function (event) { EthStoreWarning.prototype.toggleShowWarning = function () {
this.props.dispatch(actions.agreeToEthWarning()) this.props.dispatch(actions.agreeToEthWarning())
} }

@ -120,7 +120,7 @@ CreateVaultScreen.prototype.createNewVault = function () {
return return
} }
if (password !== passwordConfirm) { if (password !== passwordConfirm) {
this.warning = 'passwords dont match' this.warning = 'passwords don\'t match'
this.props.dispatch(actions.displayWarning(this.warning)) this.props.dispatch(actions.displayWarning(this.warning))
return return
} }

@ -32,7 +32,6 @@ AppSettingsPage.prototype.render = function () {
htmlFor: 'settings-rpc-endpoint', htmlFor: 'settings-rpc-endpoint',
}, 'RPC Endpoint:'), }, 'RPC Endpoint:'),
h('input', { h('input', {
// value: '//testrpc.metamask.io',
type: 'url', type: 'url',
id: 'settings-rpc-endpoint', id: 'settings-rpc-endpoint',
onKeyPress: this.onKeyPress.bind(this), onKeyPress: this.onKeyPress.bind(this),

Loading…
Cancel
Save