- case 2:
- if (isConnected) {
- return this.connectSuccess();
- } else if (lastError) {
- return setManual();
- }
- break;
+ if (nextTokenIndex < 0) {
+ return this._setManual();
}
- nextTick();
+ const nextToken = this._tokens[nextTokenIndex];
+ nextToken.tried = true;
+
+ this.updateToken(nextToken.value);
+ }
+
+ _followConnection = () => {
+ const token = this.transport.token;
+
+ return this
+ .transport
+ .connect()
+ .then(() => {
+ if (token === 'initial') {
+ return this.signer
+ .generateAuthorizationToken()
+ .then((token) => {
+ return this.updateToken(token);
+ })
+ .catch((e) => console.error(e));
+ }
+
+ this.connectSuccess();
+ return true;
+ })
+ .catch((e) => {
+ this
+ ._checkNodeUp()
+ .then((isNodeUp) => {
+ // Try again in a few...
+ if (!isNodeUp) {
+ this._isConnecting = false;
+ const timeout = this.transport.retryTimeout;
+
+ window.setTimeout(() => {
+ this._followConnection();
+ }, timeout);
+
+ return;
+ }
+
+ this._tryNextToken();
+ return false;
+ });
+ });
}
connectSuccess () {
this._isConnecting = false;
this._needsToken = false;
- this.setToken();
+ this.saveToken();
Promise
.all([
@@ -152,10 +140,9 @@ export default class SecureApi extends Api {
// DEBUG: console.log('SecureApi:connectSuccess', this._transport.token);
}
- updateToken (token, connectState = 0) {
- this._connectState = connectState;
- this._transport.updateToken(token.replace(/[^a-zA-Z0-9]/g, ''));
- this._followConnection();
+ updateToken (token) {
+ this._transport.updateToken(token.replace(/[^a-zA-Z0-9]/g, ''), false);
+ return this._followConnection();
// DEBUG: console.log('SecureApi:updateToken', this._transport.token, connectState);
}
diff --git a/js/src/serviceWorker.js b/js/src/serviceWorker.js
index c558a57cf..136e6a6b7 100644
--- a/js/src/serviceWorker.js
+++ b/js/src/serviceWorker.js
@@ -140,5 +140,5 @@ function getCompiler (build) {
});
}
- return self.solc[longVersion];
+ return Promise.resolve(self.solc[longVersion]);
}
diff --git a/js/src/ui/BlockStatus/blockStatus.js b/js/src/ui/BlockStatus/blockStatus.js
index df6f44a8c..f50c7a685 100644
--- a/js/src/ui/BlockStatus/blockStatus.js
+++ b/js/src/ui/BlockStatus/blockStatus.js
@@ -62,9 +62,17 @@ class BlockStatus extends Component {
);
}
+ let syncStatus = null;
+
+ if (syncing && syncing.currentBlock && syncing.highestBlock) {
+ syncStatus = (
+ { syncing.currentBlock.toFormat() }/{ syncing.highestBlock.toFormat() } syncing
+ );
+ }
+
return (
- { syncing.currentBlock.toFormat() }/{ syncing.highestBlock.toFormat() } syncing
+ { syncStatus }
{ warpStatus }
);
diff --git a/js/src/views/Connection/connection.js b/js/src/views/Connection/connection.js
index 8cc2378d9..51b0c8018 100644
--- a/js/src/views/Connection/connection.js
+++ b/js/src/views/Connection/connection.js
@@ -34,27 +34,26 @@ class Connection extends Component {
static propTypes = {
isConnected: PropTypes.bool,
isConnecting: PropTypes.bool,
- isPingable: PropTypes.bool,
needsToken: PropTypes.bool
}
state = {
+ loading: false,
token: '',
validToken: false
}
render () {
- const { isConnected, isConnecting, isPingable } = this.props;
- const isOk = !isConnecting && isConnected && isPingable;
+ const { isConnected, needsToken } = this.props;
- if (isOk) {
+ if (isConnected) {
return null;
}
- const typeIcon = isPingable
+ const typeIcon = needsToken
?
: ;
- const description = isPingable
+ const description = needsToken
? this.renderSigner()
: this.renderPing();
@@ -82,7 +81,7 @@ class Connection extends Component {
}
renderSigner () {
- const { token, validToken } = this.state;
+ const { loading, token, validToken } = this.state;
const { isConnecting, needsToken } = this.props;
if (needsToken && !isConnecting) {
@@ -93,9 +92,11 @@ class Connection extends Component {
+ onChange={ this.onChangeToken }
+ />
);
@@ -117,7 +118,7 @@ class Connection extends Component {
}
onChangeToken = (event, token) => {
- const validToken = /[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}/.test(token);
+ const validToken = /[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{4}-?[a-zA-Z0-9]{4}/.test(token);
this.setState({ token, validToken }, () => {
validToken && this.setToken();
});
@@ -127,15 +128,20 @@ class Connection extends Component {
const { api } = this.context;
const { token } = this.state;
- api.updateToken(token, 0);
- this.setState({ token: '', validToken: false });
+ this.setState({ loading: true });
+
+ api
+ .updateToken(token, 0)
+ .then((isValid) => {
+ this.setState({ loading: isValid || false, validToken: isValid });
+ });
}
}
function mapStateToProps (state) {
- const { isConnected, isConnecting, isPingable, needsToken } = state.nodeStatus;
+ const { isConnected, isConnecting, needsToken } = state.nodeStatus;
- return { isConnected, isConnecting, isPingable, needsToken };
+ return { isConnected, isConnecting, needsToken };
}
function mapDispatchToProps (dispatch) {
diff --git a/js/src/views/WriteContract/writeContract.css b/js/src/views/WriteContract/writeContract.css
index c5cefcf7a..3db18bf39 100644
--- a/js/src/views/WriteContract/writeContract.css
+++ b/js/src/views/WriteContract/writeContract.css
@@ -105,6 +105,8 @@
display: flex;
flex-direction: column;
margin-right: 0.5em;
+ overflow: auto;
+
.panel {
background-color: rgba(0, 0, 0, 0.5);
padding: 1em;
diff --git a/js/src/views/WriteContract/writeContract.js b/js/src/views/WriteContract/writeContract.js
index c95c09c04..8adb80b5a 100644
--- a/js/src/views/WriteContract/writeContract.js
+++ b/js/src/views/WriteContract/writeContract.js
@@ -21,6 +21,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import CircularProgress from 'material-ui/CircularProgress';
import moment from 'moment';
+import { throttle } from 'lodash';
import ContentClear from 'material-ui/svg-icons/content/clear';
import SaveIcon from 'material-ui/svg-icons/content/save';
@@ -60,6 +61,8 @@ class WriteContract extends Component {
if (worker !== undefined) {
this.store.setWorker(worker);
}
+
+ this.throttledResize = throttle(this.applyResize, 100, { leading: true });
}
componentDidMount () {
@@ -516,10 +519,16 @@ class WriteContract extends Component {
const x = pageX - left;
- this.setState({ size: 100 * x / width });
+ this.size = 100 * x / width;
+ this.throttledResize();
+
event.stopPropagation();
}
+ applyResize = () => {
+ this.setState({ size: this.size });
+ }
+
}
function mapStateToProps (state) {
diff --git a/js/src/views/WriteContract/writeContractStore.js b/js/src/views/WriteContract/writeContractStore.js
index 141569af2..a1f710f8e 100644
--- a/js/src/views/WriteContract/writeContractStore.js
+++ b/js/src/views/WriteContract/writeContractStore.js
@@ -288,7 +288,7 @@ export default class WriteContractStore {
const build = this.builds[this.selectedBuild];
const version = build.longVersion;
- const sourcecode = this.sourcecode.replace(/\n+/g, '\n').replace(/\s(\s+)/g, ' ');
+ const sourcecode = this.sourcecode.replace(/\s+/g, ' ');
const hash = sha3(JSON.stringify({ version, sourcecode, optimize: this.optimize }));
let promise = Promise.resolve(null);
@@ -302,7 +302,7 @@ export default class WriteContractStore {
} else {
promise = this
.compile({
- sourcecode: sourcecode,
+ sourcecode: this.sourcecode,
build: build,
optimize: this.optimize,
files: this.files
diff --git a/js/webpack/app.js b/js/webpack/app.js
index df801533c..9044d470b 100644
--- a/js/webpack/app.js
+++ b/js/webpack/app.js
@@ -23,6 +23,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
+const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const Shared = require('./shared');
const DAPPS = require('../src/dapps');
@@ -35,10 +36,13 @@ const isProd = ENV === 'production';
module.exports = {
cache: !isProd,
- devtool: isProd ? '#eval' : '#eval-source-map',
+ devtool: isProd ? '#hidden-source-map' : '#source-map',
context: path.join(__dirname, '../src'),
entry: Object.assign({}, Shared.dappsEntry, {
+ modals: './modals/index.js',
+ views: './views/index.js',
+ ui: './ui/index.js',
index: './index.js'
}),
output: {
@@ -162,13 +166,43 @@ module.exports = {
filename: 'index.html',
template: './index.ejs',
favicon: FAVICON,
- chunks: [ isProd ? null : 'commons', 'index' ]
+ chunks: [
+ isProd ? null : 'commons',
+ 'common.modals', 'common.views', 'common.ui',
+ 'modals', 'views', 'ui',
+ 'index'
+ ]
+ }),
+
+ new ScriptExtHtmlWebpackPlugin({
+ sync: [ 'commons', 'vendor.js' ],
+ defaultAttribute: 'defer'
}),
new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, '../src/serviceWorker.js')
}),
+ new webpack.optimize.CommonsChunkPlugin({
+ filename: 'commons.modals.[hash:10].js',
+ name: 'common.modals',
+ minChunks: 2,
+ chunks: [ 'index', 'modals' ]
+ }),
+
+ new webpack.optimize.CommonsChunkPlugin({
+ filename: 'commons.views.[hash:10].js',
+ name: 'common.views',
+ minChunks: 2,
+ chunks: [ 'index', 'views' ]
+ }),
+
+ new webpack.optimize.CommonsChunkPlugin({
+ filename: 'commons.ui.[hash:10].js',
+ name: 'common.ui',
+ minChunks: 2
+ }),
+
DappsHTMLInjection
);
@@ -185,7 +219,7 @@ module.exports = {
new webpack.optimize.CommonsChunkPlugin({
filename: 'commons.[hash:10].js',
name: 'commons',
- minChunks: Infinity
+ minChunks: 2
})
);
}
diff --git a/js/webpack/dev.server.js b/js/webpack/dev.server.js
index fc107488a..ccfd2026f 100644
--- a/js/webpack/dev.server.js
+++ b/js/webpack/dev.server.js
@@ -22,6 +22,7 @@ const webpackHotMiddleware = require('webpack-hot-middleware');
const http = require('http');
const express = require('express');
const ProgressBar = require('progress');
+const proxy = require('http-proxy-middleware');
const webpackConfig = require('./app');
const Shared = require('./shared');
@@ -33,6 +34,8 @@ let progressBar = { update: () => {} };
* and HMR to the plugins
*/
(function updateWebpackConfig () {
+ webpackConfig.performance = { hints: false };
+
Object.keys(webpackConfig.entry).forEach((key) => {
const entry = webpackConfig.entry[key];
@@ -81,13 +84,18 @@ app.use(webpackDevMiddleware(compiler, {
}
}));
-app.use(express.static(webpackConfig.output.path));
+var wsProxy = proxy('ws://127.0.0.1:8180', { changeOrigin: true });
// Add the dev proxies in the express App
Shared.addProxies(app);
+app.use(express.static(webpackConfig.output.path));
+app.use(wsProxy);
+
const server = http.createServer(app);
server.listen(process.env.PORT || 3000, function () {
console.log('Listening on port', server.address().port);
progressBar = new ProgressBar('[:bar] :percent :etas', { total: 50 });
});
+
+server.on('upgrade', wsProxy.upgrade);
diff --git a/js/webpack/vendor.js b/js/webpack/vendor.js
index 7f1114144..daacab379 100644
--- a/js/webpack/vendor.js
+++ b/js/webpack/vendor.js
@@ -31,9 +31,11 @@ let modules = [
'ethereumjs-tx',
'lodash',
'material-ui',
+ 'material-ui-chip-input',
'mobx',
'mobx-react',
'moment',
+ 'phoneformat.js',
'react',
'react-dom',
'react-redux',