Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
support configurable network list
Browse files Browse the repository at this point in the history
 * use `gulp prep --networks eth_mew,blah,blah` command to show selected networks only
  • Loading branch information
hackmod committed Aug 31, 2018
1 parent 6f9c4d6 commit db04a15
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
10 changes: 5 additions & 5 deletions app/includes/header-node-modal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
</div>

<div class="clearfix col-xs-12 radio">
<label><input name="options" type="radio" ng-model="customNode.options" value="eth"> ETH </label>
<label><input name="options" type="radio" ng-model="customNode.options" value="etc"> ETC </label>
<label><input name="options" type="radio" ng-model="customNode.options" value="rop"> Ropsten </label>
<label><input name="options" type="radio" ng-model="customNode.options" value="kov"> Kovan </label>
<label><input name="options" type="radio" ng-model="customNode.options" value="rin"> Rinkeby </label>
<label><input name="options" type="radio" ng-disabled="!nodeList.eth_ethscan" ng-model="customNode.options" value="eth"> ETH </label>
<label><input name="options" type="radio" ng-disabled="!nodeList.etc_epool" ng-model="customNode.options" value="etc"> ETC </label>
<label><input name="options" type="radio" ng-disabled="!nodeList.rop_mew" ng-model="customNode.options" value="rop"> Ropsten </label>
<label><input name="options" type="radio" ng-disabled="!nodeList.kov_ethscan" ng-model="customNode.options" value="kov"> Kovan </label>
<label><input name="options" type="radio" ng-disabled="!nodeList.rin_ethscan" ng-model="customNode.options" value="rin"> Rinkeby </label>
<label><input name="options" type="radio" ng-model="customNode.options" value="cus"> Custom </label>
<label ng-show="customNode.options == 'cus'"><input type="checkbox" ng-model="customNode.eip155" value="true"> Supports EIP-155 </label>
</div>
Expand Down
16 changes: 16 additions & 0 deletions app/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ if (IS_CX) {
var mainPopCtrl = require('./controllers/CX/mainPopCtrl');
var quickSendCtrl = require('./controllers/CX/quickSendCtrl');
}

// prepare some variables
var nodeList = {};
if (typeof selectedNetworks !== 'undefined') {
var found = 0;
selectedNetworks.forEach(function(n) {
if (nodes.nodeList[n]) {
nodeList[n] = nodes.nodeList[n];
found++;
}
});
if (found > 0) {
nodes.nodeList = nodeList;
}
}

var app = angular.module('mewApp', ['pascalprecht.translate', 'ngSanitize','ngAnimate']);
app.config(['$compileProvider', function($compileProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(|blob|https|mailto):/);
Expand Down
26 changes: 22 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ const dist_CX = './chrome-extension/';
// default Settings
const Settings = require('./config.default.json');

// get selected nodeList to override the nodes.nodeList
let selectedNetworks, i = process.argv.indexOf("--networks");
if (i > -1 && process.argv[i + 1]) {
selectedNetworks = process.argv[i + 1].split(",");
console.log("Selected networks =", selectedNetworks);
}

// load custom settings
try {
let local = require('./config.json');
Expand Down Expand Up @@ -124,13 +131,23 @@ let js_srcFile = app + 'scripts/main.js';
let js_destFolder = dist + 'js/';
let js_destFolder_CX = dist_CX + 'js/';
let js_destFile = 'etherwallet-master.js';
let browseOpts = { debug: true }; // generates inline source maps - only in js-debug
let js_opts = {}; // browserify opts
let babelOpts = {
presets: ['es2015'],
compact: false,
global: true
};

// have selected nodes ?
if (selectedNetworks) {
// setup browserify opts
js_opts.insertGlobalVars = {
selectedNetworks: function() {
return JSON.stringify(selectedNetworks);
}
};
}

function bundle_js(bundler) {
return bundler.bundle()
.pipe(plumber({ errorHandler: onError }))
Expand All @@ -155,17 +172,18 @@ function bundle_js_debug(bundler) {


gulp.task('js', function() {
let bundler = browserify(js_srcFile).transform(babelify).transform(html2js);
let bundler = browserify(js_srcFile, js_opts).transform(babelify).transform(html2js);
bundle_js(bundler)
});

gulp.task('js-production', function() {
let bundler = browserify(js_srcFile).transform(babelify, babelOpts).transform(html2js);
let bundler = browserify(js_srcFile, js_opts).transform(babelify, babelOpts).transform(html2js);
bundle_js(bundler)
});

gulp.task('js-debug', function() {
let bundler = browserify(js_srcFile, browseOpts).transform(babelify, babelOpts).transform(html2js);
js_opts.debug = true; // generates inline source maps - only in js-debug
let bundler = browserify(js_srcFile, js_opts).transform(babelify, babelOpts).transform(html2js);
bundle_js_debug(bundler)
});

Expand Down

0 comments on commit db04a15

Please sign in to comment.