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

Commit 499fcc6

Browse files
committed
support configurable network list
* use `gulp prep --networks eth_mew,blah,blah` command to show selected networks only
1 parent 9a59e48 commit 499fcc6

3 files changed

Lines changed: 43 additions & 9 deletions

File tree

app/includes/header-node-modal.tpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
</div>
4949

5050
<div class="clearfix col-xs-12 radio">
51-
<label><input name="options" type="radio" ng-model="customNode.options" value="eth"> ETH </label>
52-
<label><input name="options" type="radio" ng-model="customNode.options" value="etc"> ETC </label>
53-
<label><input name="options" type="radio" ng-model="customNode.options" value="rop"> Ropsten </label>
54-
<label><input name="options" type="radio" ng-model="customNode.options" value="kov"> Kovan </label>
55-
<label><input name="options" type="radio" ng-model="customNode.options" value="rin"> Rinkeby </label>
51+
<label><input name="options" type="radio" ng-disabled="!nodeList.eth_ethscan" ng-model="customNode.options" value="eth"> ETH </label>
52+
<label><input name="options" type="radio" ng-disabled="!nodeList.etc_epool" ng-model="customNode.options" value="etc"> ETC </label>
53+
<label><input name="options" type="radio" ng-disabled="!nodeList.rop_mew" ng-model="customNode.options" value="rop"> Ropsten </label>
54+
<label><input name="options" type="radio" ng-disabled="!nodeList.kov_ethscan" ng-model="customNode.options" value="kov"> Kovan </label>
55+
<label><input name="options" type="radio" ng-disabled="!nodeList.rin_ethscan" ng-model="customNode.options" value="rin"> Rinkeby </label>
5656
<label><input name="options" type="radio" ng-model="customNode.options" value="cus"> Custom </label>
5757
<label ng-show="customNode.options == 'cus'"><input type="checkbox" ng-model="customNode.eip155" value="true"> Supports EIP-155 </label>
5858
</div>

app/scripts/main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ if (IS_CX) {
131131
var mainPopCtrl = require("./controllers/CX/mainPopCtrl");
132132
var quickSendCtrl = require("./controllers/CX/quickSendCtrl");
133133
}
134+
135+
// prepare some variables
136+
var nodeList = {};
137+
if (typeof selectedNetworks !== 'undefined') {
138+
var found = 0;
139+
selectedNetworks.forEach(function(n) {
140+
if (nodes.nodeList[n]) {
141+
nodeList[n] = nodes.nodeList[n];
142+
found++;
143+
}
144+
});
145+
if (found > 0) {
146+
nodes.nodeList = nodeList;
147+
}
148+
}
149+
134150
var app = angular.module("mewApp", [
135151
"pascalprecht.translate",
136152
"ngSanitize",

gulpfile.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ const dist_CX = "./chrome-extension/";
3030
// default Settings
3131
const Settings = require('./config.default.json');
3232

33+
// get selected nodeList to override the nodes.nodeList
34+
let selectedNetworks, i = process.argv.indexOf("--networks");
35+
if (i > -1 && process.argv[i + 1]) {
36+
selectedNetworks = process.argv[i + 1].split(",");
37+
console.log("Selected networks =", selectedNetworks);
38+
}
39+
3340
// load custom settings
3441
try {
3542
let local = require('./config.json');
@@ -123,12 +130,22 @@ let js_srcFile = app + "scripts/main.js";
123130
let js_destFolder = dist + "js/";
124131
let js_destFolder_CX = dist_CX + "js/";
125132
let js_destFile = "etherwallet-master.js";
126-
let browseOpts = { debug: true }; // generates inline source maps - only in js-debug
133+
let js_opts = {}; // browserify opts
127134
let babelOpts = {
128135
presets: ["env"],
129136
compact: false
130137
};
131138

139+
// have selected nodes ?
140+
if (selectedNetworks) {
141+
// setup browserify opts
142+
js_opts.insertGlobalVars = {
143+
selectedNetworks: function() {
144+
return JSON.stringify(selectedNetworks);
145+
}
146+
};
147+
}
148+
132149
function bundle_js(bundler) {
133150
return bundler
134151
.bundle()
@@ -154,21 +171,22 @@ function bundle_js_debug(bundler) {
154171
}
155172

156173
gulp.task("js", function() {
157-
let bundler = browserify(js_srcFile)
174+
let bundler = browserify(js_srcFilei, js_opts)
158175
.transform(babelify)
159176
.transform(html2js);
160177
bundle_js(bundler);
161178
});
162179

163180
gulp.task("js-production", function() {
164-
let bundler = browserify(js_srcFile)
181+
let bundler = browserify(js_srcFile, js_opts)
165182
.transform(babelify, babelOpts)
166183
.transform(html2js);
167184
bundle_js(bundler);
168185
});
169186

170187
gulp.task("js-debug", function() {
171-
let bundler = browserify(js_srcFile, browseOpts)
188+
js_opts.debug = true; // generates inline source maps - only in js-debug
189+
let bundler = browserify(js_srcFile, js_opts)
172190
.transform(babelify, babelOpts)
173191
.transform(html2js);
174192
bundle_js_debug(bundler);

0 commit comments

Comments
 (0)