From 930ca947cbe299e4f3d61627d12ec43fa0a0dd6e Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 13:27:51 -0400 Subject: [PATCH 01/11] Remove unused API_KEY variable. Replace signal.ether.ai proxy with rpc.ethapi.org --- src/redux/actions/connection-actions.js | 2 +- src/redux/actions/position-actions.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/redux/actions/connection-actions.js b/src/redux/actions/connection-actions.js index 9d77ab1..321cfce 100644 --- a/src/redux/actions/connection-actions.js +++ b/src/redux/actions/connection-actions.js @@ -7,7 +7,7 @@ else if (typeof Web3 !== 'undefined') { web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) if (!web3.isConnected()) { const Web3 = require('web3') - web3 = new Web3(new Web3.providers.HttpProvider('https://signal.ether.ai/proxy')) + web3 = new Web3(new Web3.providers.HttpProvider('http://rpc.ethapi.org:8545')) } } diff --git a/src/redux/actions/position-actions.js b/src/redux/actions/position-actions.js index f406358..c4d71b9 100644 --- a/src/redux/actions/position-actions.js +++ b/src/redux/actions/position-actions.js @@ -1,5 +1,3 @@ -const API_KEY = process.env.ETHERSCAN_API_KEY - import querystring from 'querystring' import fetch from 'isomorphic-fetch' import getSignalPerBlock from './utils/getSignalPerBlock' @@ -20,7 +18,7 @@ else if (typeof Web3 !== 'undefined') { web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) if (!web3.isConnected()) { const Web3 = require('web3') - web3 = new Web3(new Web3.providers.HttpProvider('https://signal.ether.ai/proxy')) + web3 = new Web3(new Web3.providers.HttpProvider('http://rpc.ethapi.org:8545')) } } From 932d06f92e3d49bc482a9eff627631e25143f07f Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 13:46:33 -0400 Subject: [PATCH 02/11] Rewrite #getPositionDeposit to use async methods of web3. --- src/redux/actions/position-actions.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/redux/actions/position-actions.js b/src/redux/actions/position-actions.js index c4d71b9..bd1bdc5 100644 --- a/src/redux/actions/position-actions.js +++ b/src/redux/actions/position-actions.js @@ -94,12 +94,12 @@ function getPositions(fromBlock, endBlock) { function getPositionDeposit(position) { return new Promise((resolve, reject) => { - const block = web3.eth.getBlock(position.blockNumber) - const deposit = Number(web3.fromWei( - web3.eth.getBalance(position.args.sigAddr), - 'finney' - )) - resolve(Object.assign({}, position, {block, deposit})) + web3.eth.getBlock(position.blockNumber, (err, block) => { + web3.eth.getBalance(position.args.sigAddr, (err, balance) => { + const deposit = Number(web3.fromWei(balance, 'finney')) + resolve(Object.assign({}, position, {block, deposit})) + }) + }) }) } @@ -170,6 +170,7 @@ function calculateCurrentSignal(position) { for (const address in position.proMap) { const balance = web3.fromWei(web3.eth.getBalance(address)) + position.proMap[address] = position.proMap[address] * balance position.againstMap[address] = position.againstMap[address] * balance @@ -187,6 +188,7 @@ function calculateCurrentSignal(position) { } } }) + } for (const index in web3.eth.accounts) { From ac254a7523963b2dce3d8b9a1e6dc2aadf49d5f5 Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 14:15:28 -0400 Subject: [PATCH 03/11] Update #calculateCurrentSignal. --- src/redux/actions/position-actions.js | 65 ++++++++++++++++----------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/redux/actions/position-actions.js b/src/redux/actions/position-actions.js index bd1bdc5..7795bcd 100644 --- a/src/redux/actions/position-actions.js +++ b/src/redux/actions/position-actions.js @@ -1,6 +1,7 @@ import querystring from 'querystring' import fetch from 'isomorphic-fetch' import getSignalPerBlock from './utils/getSignalPerBlock' +import _ from 'lodash' /* * connection to local blockchain node. @@ -158,38 +159,47 @@ function getPositionVoteMaps(position) { */ function calculateCurrentSignal(position) { - return new Promise((resolve, reject) => { - - position.totalPro = 0 - position.totalAgainst = 0 - position.isMine = false - position.iHaveSignalled = false - position.myVote - - // Call getBalance once per address - for (const address in position.proMap) { - const balance = web3.fromWei(web3.eth.getBalance(address)) + position.totalPro = 0 + position.totalAgainst = 0 + position.isMine = false + position.iHaveSignalled = false + position.myVote + + return Promise.all( + _.map(position.proMap, (key, address) => { + return new Promise((resolve, reject) => { + web3.eth.getBalance(address, (err, balance) => { + + balance = web3.fromWei(balance) + + position.proMap[address] = position.proMap[address] * balance + position.againstMap[address] = position.againstMap[address] * balance + + position.totalPro += parseFloat(position.proMap[address]) + position.totalAgainst += parseFloat(position.againstMap[address]) + + web3.eth.accounts.find(account => { + if (address === account) { + position.iHaveSignalled = true + if (position.proMap[address]) { + position.myVote = 'pro' + } + else if (position.againstMap[address]) { + position.myVote = 'against' + } + } + }) - position.proMap[address] = position.proMap[address] * balance - position.againstMap[address] = position.againstMap[address] * balance + }) - position.totalPro += parseFloat(position.proMap[address]) - position.totalAgainst += parseFloat(position.againstMap[address]) + resolve() - web3.eth.accounts.find(account => { - if (address === account) { - position.iHaveSignalled = true - if (position.proMap[address]) { - position.myVote = 'pro' - } - else if (position.againstMap[address]) { - position.myVote = 'against' - } - } }) - } + }) + ) + .then(() => { for (const index in web3.eth.accounts) { if (web3.eth.accounts[index] === position.args.regAddr) { @@ -197,9 +207,10 @@ function calculateCurrentSignal(position) { } } - resolve(position) + return position }) + } /* From 83b4bd46ff8dc1eafdb1733feb4b781369509bd2 Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 14:38:57 -0400 Subject: [PATCH 04/11] Update a call to #sendTransaction to be async. --- src/redux/actions/connection-actions.js | 1 - src/redux/actions/position-actions.js | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/redux/actions/connection-actions.js b/src/redux/actions/connection-actions.js index 321cfce..df9e87d 100644 --- a/src/redux/actions/connection-actions.js +++ b/src/redux/actions/connection-actions.js @@ -72,7 +72,6 @@ export function watchNetworkStatus() { const latestStatus = web3.eth.filter('latest') latestStatus.watch((err, blockHash) => { - return new Promise((resolve, reject) => { web3.eth.getBlock(blockHash, false, function(err, block) { if (err) reject(err) diff --git a/src/redux/actions/position-actions.js b/src/redux/actions/position-actions.js index 7795bcd..42f7c8a 100644 --- a/src/redux/actions/position-actions.js +++ b/src/redux/actions/position-actions.js @@ -397,13 +397,20 @@ export function submitNewPosition(title, description, account) { return dispatch => { dispatch(submitNewPositionRequest()) try { - const result = positionRegistry.registerPosition.sendTransaction( - title, - description, - { from: sender, to: address, gas: gas } + positionRegistry.registerPosition.sendTransaction( + { + title, + description, + from: sender, + to: address, + gas: gas + }, + (err, result) => { + if (err) throw err + dispatch(addTimedAlert('The position was submitted!', 'success')) + dispatch(submitNewPositionSuccess(result)) + } ) - dispatch(addTimedAlert('The position was submitted!', 'success')) - dispatch(submitNewPositionSuccess(result)) } catch (error) { dispatch(addTimedAlert(error.message, 'danger')) From 01b4d084d402c5c895f4ffded0d88f654a174e6b Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 14:55:52 -0400 Subject: [PATCH 05/11] Update #submitNewPosition to be async. --- src/redux/actions/position-actions.js | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/redux/actions/position-actions.js b/src/redux/actions/position-actions.js index 42f7c8a..520a803 100644 --- a/src/redux/actions/position-actions.js +++ b/src/redux/actions/position-actions.js @@ -392,30 +392,34 @@ export function submitNewPosition(title, description, account) { // Todo: there should be an account selector const sender = account const data = positionRegistry.registerPosition.getData(title, description) - const gas = web3.eth.estimateGas({from: sender, to: address, data: data}) return dispatch => { dispatch(submitNewPositionRequest()) - try { - positionRegistry.registerPosition.sendTransaction( - { + web3.eth.estimateGas({from: sender, to: address, data: data}, (err, gas) => { + try { + positionRegistry.registerPosition.sendTransaction( title, description, - from: sender, - to: address, - gas: gas - }, - (err, result) => { - if (err) throw err - dispatch(addTimedAlert('The position was submitted!', 'success')) - dispatch(submitNewPositionSuccess(result)) - } - ) - } - catch (error) { - dispatch(addTimedAlert(error.message, 'danger')) - dispatch(submitNewPositionFailure(error)) - } + { + from: sender, + to: address, + gas: gas + }, + (err, result) => { + if (err) throw err + dispatch(addTimedAlert('The position was submitted!', 'success')) + dispatch(submitNewPositionSuccess(result)) + } + ) + } + + catch (error) { + dispatch(addTimedAlert(error.message, 'danger')) + dispatch(submitNewPositionFailure(error)) + } + + }) + } } From e9194c82778db09647a5c3dc72ed6eeb21c89ebd Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 19:11:14 -0400 Subject: [PATCH 06/11] Replace browserHistory with hashHistory, as the former caused the app to crash on GHPages. --- src/components/environments/Frame.js | 8 ++++---- src/index.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/environments/Frame.js b/src/components/environments/Frame.js index c0680e7..79ec6f8 100644 --- a/src/components/environments/Frame.js +++ b/src/components/environments/Frame.js @@ -1,6 +1,5 @@ import React, { PropTypes, Component } from 'react' import './../../styles/environments/Frame.css' -import { browserHistory } from 'react-router' import { Navbar, @@ -16,13 +15,14 @@ import { routes } from './../../index' class Frame extends Component { handleSelect(selectedKey) { - browserHistory.push(routes[selectedKey].path) + this.props.history.push(routes[selectedKey].path) } getActiveRouteIndex() { - const path = window.location.pathname + let hash = window.location.hash + hash = hash.substring(hash.indexOf('#') + 1, hash.indexOf('?')) return routes.findIndex(route => { - return route.path === path + return hash === route.path }) } diff --git a/src/index.js b/src/index.js index b678f26..72c9fe5 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import React from 'react' import {render} from 'react-dom' -import { Router, Route, browserHistory, IndexRoute } from 'react-router' +import { Router, Route, hashHistory, IndexRoute } from 'react-router' import { Provider } from 'react-redux' import { createStore, applyMiddleware } from 'redux' @@ -38,7 +38,7 @@ store.dispatch(getAccounts()) render( - + { From a20e531c1374acc0a11f5d135e093f60a8c23e64 Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 19:58:46 -0400 Subject: [PATCH 07/11] Graft fresh react app from to get new build tool. --- .eslintrc.json | 6 -- config/babel.dev.js | 13 --- config/babel.prod.js | 13 --- config/eslint.js | 39 --------- config/flow/css.js.flow | 1 - config/flow/file.js.flow | 2 - config/webpack.config.dev.js | 101 ---------------------- config/webpack.config.prod.js | 122 --------------------------- index.html | 21 ----- package.json | 67 +++++---------- public/favicon.ico | Bin 0 -> 24838 bytes public/index.html | 31 +++++++ scripts/build.js | 30 ------- scripts/openChrome.applescript | 39 --------- scripts/start.js | 150 --------------------------------- 15 files changed, 51 insertions(+), 584 deletions(-) delete mode 100644 .eslintrc.json delete mode 100644 config/babel.dev.js delete mode 100644 config/babel.prod.js delete mode 100644 config/eslint.js delete mode 100644 config/flow/css.js.flow delete mode 100644 config/flow/file.js.flow delete mode 100644 config/webpack.config.dev.js delete mode 100644 config/webpack.config.prod.js delete mode 100644 index.html create mode 100644 public/favicon.ico create mode 100644 public/index.html delete mode 100644 scripts/build.js delete mode 100644 scripts/openChrome.applescript delete mode 100644 scripts/start.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index cf9da76..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "trails/react", - "parserOptions": { - "sourceType": "module" - } -} diff --git a/config/babel.dev.js b/config/babel.dev.js deleted file mode 100644 index e3660a1..0000000 --- a/config/babel.dev.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - cacheDirectory: true, - presets: [ - 'babel-preset-es2015', - 'babel-preset-es2016', - 'babel-preset-react' - ].map(require.resolve), - plugins: [ - 'babel-plugin-syntax-trailing-function-commas', - 'babel-plugin-transform-class-properties', - 'babel-plugin-transform-object-rest-spread' - ].map(require.resolve) -}; diff --git a/config/babel.prod.js b/config/babel.prod.js deleted file mode 100644 index ed86d47..0000000 --- a/config/babel.prod.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - presets: [ - 'babel-preset-es2015', - 'babel-preset-es2016', - 'babel-preset-react' - ].map(require.resolve), - plugins: [ - 'babel-plugin-syntax-trailing-function-commas', - 'babel-plugin-transform-class-properties', - 'babel-plugin-transform-object-rest-spread', - 'babel-plugin-transform-react-constant-elements' - ].map(require.resolve) -}; diff --git a/config/eslint.js b/config/eslint.js deleted file mode 100644 index 3f42b9e..0000000 --- a/config/eslint.js +++ /dev/null @@ -1,39 +0,0 @@ -// Inspired by https://github.com/airbnb/javascript but less opinionated. - -// We use eslint-loader so even warnings are very visibile. -// This is why we only use "WARNING" level for potential errors, -// and we don't use "ERROR" level at all. - -// In the future, we might create a separate list of rules for production. -// It would probably be more strict. - -var WARNING = 1; - -module.exports = { - root: true, - - parser: 'babel-eslint', - - extends: 'trails/react', - parserOptions: { - sourceType: 'module', - }, - - rules: { - 'new-cap': [ 'error', { 'capIsNew': false }] - }, - - settings: { - 'import/ignore': [ - 'node_modules', - '\\.(json|css|jpg|png|gif|eot|svg|ttf|woff|woff2|mp4|webm)$', - ], - 'import/extensions': ['.js'], - 'import/resolver': { - node: { - extensions: ['.js', '.json'] - } - } - } - -}; diff --git a/config/flow/css.js.flow b/config/flow/css.js.flow deleted file mode 100644 index 46e7f7c..0000000 --- a/config/flow/css.js.flow +++ /dev/null @@ -1 +0,0 @@ -// @flow diff --git a/config/flow/file.js.flow b/config/flow/file.js.flow deleted file mode 100644 index 701b670..0000000 --- a/config/flow/file.js.flow +++ /dev/null @@ -1,2 +0,0 @@ -// @flow -declare export default string; diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js deleted file mode 100644 index 0b88d1c..0000000 --- a/config/webpack.config.dev.js +++ /dev/null @@ -1,101 +0,0 @@ -var path = require('path'); -var autoprefixer = require('autoprefixer'); -var webpack = require('webpack'); -var HtmlWebpackPlugin = require('html-webpack-plugin'); - -// TODO: hide this behind a flag and eliminate dead code on eject. -// This shouldn't be exposed to the user. -var isInNodeModules = 'node_modules' === - path.basename(path.resolve(path.join(__dirname, '..', '..'))); -var relativePath = isInNodeModules ? '../../..' : '..'; -var isInDebugMode = process.argv.some(arg => - arg.indexOf('--debug-template') > -1 -); -if (isInDebugMode) { - relativePath = '../template'; -} -var srcPath = path.resolve(__dirname, relativePath, 'src'); -var nodeModulesPath = path.join(__dirname, '..', 'node_modules'); -var indexHtmlPath = path.resolve(__dirname, relativePath, 'index.html'); -var faviconPath = path.resolve(__dirname, relativePath, 'favicon.ico'); -var buildPath = path.join(__dirname, isInNodeModules ? '../../..' : '..', 'build'); - -module.exports = { - devtool: 'eval', - entry: [ - require.resolve('webpack-dev-server/client') + '?http://localhost:8080', - require.resolve('webpack/hot/dev-server'), - path.join(srcPath, 'index') - ], - output: { - // Next line is not used in dev but WebpackDevServer crashes without it: - path: buildPath, - pathinfo: true, - filename: 'bundle.js', - publicPath: '/' - }, - devServer: { - headers: { "Access-Control-Allow-Origin": "*" } - }, - resolve: { - extensions: ['', '.js'], - }, - resolveLoader: { - root: nodeModulesPath, - moduleTemplates: ['*-loader'] - }, - module: { - preLoaders: [ - { - test: /\.js$/, - loader: 'eslint', - include: srcPath, - } - ], - loaders: [ - { - test: /\.js$/, - include: srcPath, - loader: 'babel', - query: require('./babel.dev') - }, - { - test: /\.css$/, - include: [ - srcPath, - nodeModulesPath - ], - loader: 'style!css!postcss' - }, - { - test: /\.json$/, - loader: 'json' - }, - { - test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/, - loader: 'file', - }, - { - test: /\.(mp4|webm)$/, - loader: 'url?limit=10000' - } - ] - }, - eslint: { - configFile: path.join(__dirname, 'eslint.js'), - useEslintrc: false - }, - postcss: function() { - return [autoprefixer]; - }, - plugins: [ - new HtmlWebpackPlugin({ - inject: true, - template: indexHtmlPath, - favicon: faviconPath, - }), - new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' }), - // Note: only CSS is currently hot reloaded - new webpack.HotModuleReplacementPlugin() - ] -}; diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js deleted file mode 100644 index f93daa9..0000000 --- a/config/webpack.config.prod.js +++ /dev/null @@ -1,122 +0,0 @@ -var path = require('path'); -var autoprefixer = require('autoprefixer'); -var webpack = require('webpack'); -var HtmlWebpackPlugin = require('html-webpack-plugin'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); - -// TODO: hide this behind a flag and eliminate dead code on eject. -// This shouldn't be exposed to the user. -var isInNodeModules = 'node_modules' === - path.basename(path.resolve(path.join(__dirname, '..', '..'))); -var relativePath = isInNodeModules ? '../../..' : '..'; -if (process.argv[2] === '--debug-template') { - relativePath = '../template'; -} -var srcPath = path.resolve(__dirname, relativePath, 'src'); -var nodeModulesPath = path.join(__dirname, '..', 'node_modules'); -var indexHtmlPath = path.resolve(__dirname, relativePath, 'index.html'); -var faviconPath = path.resolve(__dirname, relativePath, 'favicon.ico'); -var buildPath = path.join(__dirname, isInNodeModules ? '../../..' : '..', 'build'); - -module.exports = { - bail: true, - devtool: 'source-map', - entry: path.join(srcPath, 'index'), - output: { - path: buildPath, - filename: '[name].[chunkhash].js', - chunkFilename: '[name].[chunkhash].chunk.js', - // TODO: this wouldn't work for e.g. GH Pages. - // Good news: we can infer it from package.json :-) - publicPath: '/' - }, - resolve: { - extensions: ['', '.js'], - }, - resolveLoader: { - root: nodeModulesPath, - moduleTemplates: ['*-loader'] - }, - module: { - preLoaders: [ - { - test: /\.js$/, - loader: 'eslint', - include: srcPath - } - ], - loaders: [ - { - test: /\.js$/, - include: srcPath, - loader: 'babel', - query: require('./babel.prod') - }, - { - test: /\.css$/, - include: srcPath, - // Disable autoprefixer in css-loader itself: - // https://github.com/webpack/css-loader/issues/281 - // We already have it thanks to postcss. - loader: ExtractTextPlugin.extract('style', 'css?-autoprefixer!postcss') - }, - { - test: /\.json$/, - loader: 'json' - }, - { - test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/, - loader: 'file', - }, - { - test: /\.(mp4|webm)$/, - loader: 'url?limit=10000' - } - ] - }, - eslint: { - // TODO: consider separate config for production, - // e.g. to enable no-console and no-debugger only in prod. - configFile: path.join(__dirname, 'eslint.js'), - useEslintrc: false - }, - postcss: function() { - return [autoprefixer]; - }, - plugins: [ - new HtmlWebpackPlugin({ - inject: true, - template: indexHtmlPath, - favicon: faviconPath, - minify: { - removeComments: true, - collapseWhitespace: true, - removeRedundantAttributes: true, - useShortDoctype: true, - removeEmptyAttributes: true, - removeStyleLinkTypeAttributes: true, - keepClosingSlash: true, - minifyJS: true, - minifyCSS: true, - minifyURLs: true - } - }), - new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"production"' }), - new webpack.optimize.OccurrenceOrderPlugin(), - new webpack.optimize.DedupePlugin(), - new webpack.optimize.UglifyJsPlugin({ - compressor: { - screw_ie8: true, - warnings: false - }, - mangle: { - screw_ie8: true - }, - output: { - comments: false, - screw_ie8: true - } - }), - new ExtractTextPlugin('[name].[contenthash].css') - ] -}; diff --git a/index.html b/index.html deleted file mode 100644 index 7fb5b36..0000000 --- a/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - EtherSignal - - -
- - - diff --git a/package.json b/package.json index 8241efd..c23a33c 100644 --- a/package.json +++ b/package.json @@ -1,62 +1,35 @@ { - "name": "ethersignal", + "name": "ethersignal-ghpages", "version": "0.0.1", "private": true, + "homepage": "http://wbprice.github.io/ethersignal-ghpages", "devDependencies": { - "autoprefixer": "6.3.7", - "babel-core": "6.10.4", - "babel-eslint": "6.1.2", - "babel-loader": "6.2.4", - "babel-plugin-syntax-trailing-function-commas": "6.8.0", - "babel-plugin-transform-class-properties": "6.10.2", - "babel-plugin-transform-object-rest-spread": "6.8.0", - "babel-plugin-transform-react-constant-elements": "6.9.1", - "babel-preset-es2015": "6.9.0", - "babel-preset-es2016": "6.11.3", - "babel-preset-react": "6.11.1", - "chalk": "1.1.3", - "cross-spawn": "4.0.0", - "css-loader": "0.23.1", - "eslint": "^3.3.0", + "eslint": "^3.8.1", "eslint-config-trails": "^1.0.7", - "eslint-loader": "1.4.1", - "eslint-plugin-import": "1.10.3", - "eslint-plugin-react": "^5.2.2", - "extract-text-webpack-plugin": "1.0.1", - "file-loader": "0.9.0", - "fs-extra": "^0.30.0", - "html-webpack-plugin": "2.22.0", - "json-loader": "0.5.4", - "opn": "4.0.2", - "postcss-loader": "0.9.1", - "rimraf": "2.5.3", - "style-loader": "0.13.1", - "url-loader": "0.5.7", - "webpack": "1.13.1", - "webpack-dev-server": "1.14.1" + "eslint-plugin-react": "^6.4.1", + "gh-pages": "^0.11.0", + "react-scripts": "0.6.1" }, "dependencies": { - "animate.css": "^3.5.1", + "animate.css": "^3.5.2", "bootstrap": "^3.3.7", - "isomorphic-fetch": "^2.2.1", - "lodash": "^4.14.1", - "moment": "^2.14.1", - "querystring": "^0.2.0", - "react": "^15.2.1", - "react-bootstrap": "^0.30.0", - "react-d3": "^0.4.0", - "react-d3-basic": "^1.6.11", + "moment": "^2.15.1", + "react": "^15.3.2", + "react-bootstrap": "^0.30.5", "react-d3-shape": "^0.3.25", - "react-dom": "^15.3.0", + "react-dom": "^15.3.2", "react-redux": "^4.4.5", - "react-router": "^2.6.0", - "redux": "^3.5.2", - "redux-logger": "^2.6.1", + "react-router": "^2.8.1", + "redux": "^3.6.0", + "redux-logger": "^2.7.0", "redux-thunk": "^2.1.0", - "web3": "^0.17.0-alpha" + "web3": "^0.17.0-beta" }, "scripts": { - "start": "node ./scripts/start.js", - "build": "node ./scripts/build.js" + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject", + "deploy": "gh-pages -d build" } } diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..5c125de5d897c1ff5692a656485b3216123dcd89 GIT binary patch literal 24838 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 + + + + + + + React App + + +
+ + + diff --git a/scripts/build.js b/scripts/build.js deleted file mode 100644 index 1e1310b..0000000 --- a/scripts/build.js +++ /dev/null @@ -1,30 +0,0 @@ -process.env.NODE_ENV = 'production'; - -var path = require('path'); -var rimrafSync = require('rimraf').sync; -var webpack = require('webpack'); -var config = require('../config/webpack.config.prod'); - -var isInNodeModules = 'node_modules' === - path.basename(path.resolve(path.join(__dirname, '..', '..'))); -var relative = isInNodeModules ? '../..' : '.'; -rimrafSync(relative + '/build'); - -webpack(config).run(function(err, stats) { - if (err) { - console.error('Failed to create a production build. Reason:'); - console.error(err.message || err); - process.exit(1); - } - - var openCommand = process.platform === 'win32' ? 'start' : 'open'; - console.log('Successfully generated a bundle in the build folder!'); - console.log(); - console.log('You can now serve it with any static server, for example:'); - console.log(' cd build'); - console.log(' npm install -g http-server'); - console.log(' hs'); - console.log(' ' + openCommand + ' http://localhost:8080'); - console.log(); - console.log('The bundle is optimized and ready to be deployed to production.'); -}); diff --git a/scripts/openChrome.applescript b/scripts/openChrome.applescript deleted file mode 100644 index cf8aa49..0000000 --- a/scripts/openChrome.applescript +++ /dev/null @@ -1,39 +0,0 @@ -on run argv - set theURL to item 1 of argv - - tell application "Chrome" - - if (count every window) = 0 then - make new window - end if - - -- Find a tab currently running the debugger - set found to false - set theTabIndex to -1 - repeat with theWindow in every window - set theTabIndex to 0 - repeat with theTab in every tab of theWindow - set theTabIndex to theTabIndex + 1 - if theTab's URL is theURL then - set found to true - exit repeat - end if - end repeat - - if found then - exit repeat - end if - end repeat - - if found then - tell theTab to reload - set index of theWindow to 1 - set theWindow's active tab index to theTabIndex - else - tell window 1 - activate - make new tab with properties {URL:theURL} - end tell - end if - end tell -end run diff --git a/scripts/start.js b/scripts/start.js deleted file mode 100644 index cab417f..0000000 --- a/scripts/start.js +++ /dev/null @@ -1,150 +0,0 @@ -process.env.NODE_ENV = 'development'; - -var path = require('path'); -var chalk = require('chalk'); -var webpack = require('webpack'); -var WebpackDevServer = require('webpack-dev-server'); -var config = require('../config/webpack.config.dev'); -var execSync = require('child_process').execSync; -var opn = require('opn'); - -// TODO: hide this behind a flag and eliminate dead code on eject. -// This shouldn't be exposed to the user. -var handleCompile; -var isSmokeTest = process.argv.some(arg => - arg.indexOf('--smoke-test') > -1 -); -if (isSmokeTest) { - handleCompile = function (err, stats) { - if (err || stats.hasErrors() || stats.hasWarnings()) { - process.exit(1); - } else { - process.exit(0); - } - }; -} - -var friendlySyntaxErrorLabel = 'Syntax error:'; - -function isLikelyASyntaxError(message) { - return message.indexOf(friendlySyntaxErrorLabel) !== -1; -} - -// This is a little hacky. -// It would be easier if webpack provided a rich error object. - -function formatMessage(message) { - return message - // Make some common errors shorter: - .replace( - // Babel syntax error - 'Module build failed: SyntaxError:', - friendlySyntaxErrorLabel - ) - .replace( - // Webpack file not found error - /Module not found: Error: Cannot resolve 'file' or 'directory'/, - 'Module not found:' - ) - // Internal stacks are generally useless so we strip them - .replace(/^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, '') // at ... ...:x:y - // Webpack loader names obscure CSS filenames - .replace('./~/css-loader!./~/postcss-loader!', ''); -} - -function clearConsole() { - process.stdout.write('\x1B[2J\x1B[0f'); -} - -var compiler = webpack(config, handleCompile); -compiler.plugin('invalid', function () { - clearConsole(); - console.log('Compiling...'); -}); -compiler.plugin('done', function (stats) { - clearConsole(); - var hasErrors = stats.hasErrors(); - var hasWarnings = stats.hasWarnings(); - if (!hasErrors && !hasWarnings) { - console.log(chalk.green('Compiled successfully!')); - console.log(); - console.log('The app is running at http://localhost:8080/'); - console.log(); - return; - } - - var json = stats.toJson(); - var formattedErrors = json.errors.map(message => - 'Error in ' + formatMessage(message) - ); - var formattedWarnings = json.warnings.map(message => - 'Warning in ' + formatMessage(message) - ); - - if (hasErrors) { - console.log(chalk.red('Failed to compile.')); - console.log(); - if (formattedErrors.some(isLikelyASyntaxError)) { - // If there are any syntax errors, show just them. - // This prevents a confusing ESLint parsing error - // preceding a much more useful Babel syntax error. - formattedErrors = formattedErrors.filter(isLikelyASyntaxError); - } - formattedErrors.forEach(message => { - console.log(message); - console.log(); - }); - // If errors exist, ignore warnings. - return; - } - - if (hasWarnings) { - console.log(chalk.yellow('Compiled with warnings.')); - console.log(); - formattedWarnings.forEach(message => { - console.log(message); - console.log(); - }); - - console.log('You may use special comments to disable some warnings.'); - console.log('Use ' + chalk.yellow('// eslint-disable-next-line') + ' to ignore the next line.'); - console.log('Use ' + chalk.yellow('/* eslint-disable */') + ' to ignore all warnings in a file.'); - } -}); - -function openBrowser() { - if (process.platform === 'darwin') { - try { - // Try our best to reuse existing tab - // on OS X Google Chrome with AppleScript - execSync('ps cax | grep "Google Chrome"'); - execSync( - 'osascript ' + - path.resolve(__dirname, './openChrome.applescript') + - ' http://localhost:8080/' - ); - return; - } catch (err) { - // Ignore errors. - } - } - // Fallback to opn - // (It will always open new tab) - opn('http://localhost:8080/'); -} - -new WebpackDevServer(compiler, { - historyApiFallback: true, - hot: true, // Note: only CSS is currently hot reloaded - publicPath: config.output.publicPath, - quiet: true -}).listen(8080, 'localhost', function (err, result) { - if (err) { - return console.log(err); - } - - clearConsole(); - console.log(chalk.cyan('Starting the development server...')); - console.log(); - // openBrowser(); -}); From 1f03b2adb7d4b7b3a12c4e3e9f570fcf465a658c Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 20:13:30 -0400 Subject: [PATCH 08/11] Address or silence various eslint errors. --- package.json | 4 ++-- src/components/environments/Frame.js | 2 +- src/redux/actions/connection-actions.js | 3 +++ src/redux/actions/position-actions.js | 12 ++++++++---- src/redux/actions/utils/getSignalPerBlock.js | 5 +++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index c23a33c..85ecd99 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "ethersignal-ghpages", + "name": "ethersignal-1", "version": "0.0.1", "private": true, - "homepage": "http://wbprice.github.io/ethersignal-ghpages", + "homepage": "http://vulcanize.github.io/ethersignal-1", "devDependencies": { "eslint": "^3.8.1", "eslint-config-trails": "^1.0.7", diff --git a/src/components/environments/Frame.js b/src/components/environments/Frame.js index 79ec6f8..0db89f2 100644 --- a/src/components/environments/Frame.js +++ b/src/components/environments/Frame.js @@ -34,7 +34,7 @@ class Frame extends Component { - + ethersignal logo EtherSignal diff --git a/src/redux/actions/connection-actions.js b/src/redux/actions/connection-actions.js index df9e87d..b2c6bb9 100644 --- a/src/redux/actions/connection-actions.js +++ b/src/redux/actions/connection-actions.js @@ -1,12 +1,15 @@ /* global Web3, web3 */ if (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') { + // eslint-disable-next-line web3 = new Web3(web3.currentProvider) } else if (typeof Web3 !== 'undefined') { + // eslint-disable-next-line web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) if (!web3.isConnected()) { const Web3 = require('web3') + // eslint-disable-next-line web3 = new Web3(new Web3.providers.HttpProvider('http://rpc.ethapi.org:8545')) } } diff --git a/src/redux/actions/position-actions.js b/src/redux/actions/position-actions.js index 520a803..ca2cc9f 100644 --- a/src/redux/actions/position-actions.js +++ b/src/redux/actions/position-actions.js @@ -13,12 +13,15 @@ import etherSignalAbi from './abi/etherSignalAbi' import positionRegistryAbi from './abi/positionRegistryAbi' if (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') { + // eslint-disable-next-line web3 = new Web3(web3.currentProvider) } else if (typeof Web3 !== 'undefined') { + // eslint-disable-next-line web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545')) if (!web3.isConnected()) { const Web3 = require('web3') + // eslint-disable-next-line web3 = new Web3(new Web3.providers.HttpProvider('http://rpc.ethapi.org:8545')) } } @@ -164,7 +167,7 @@ function calculateCurrentSignal(position) { position.totalAgainst = 0 position.isMine = false position.iHaveSignalled = false - position.myVote + position.myVote = null return Promise.all( _.map(position.proMap, (key, address) => { @@ -173,12 +176,13 @@ function calculateCurrentSignal(position) { balance = web3.fromWei(balance) - position.proMap[address] = position.proMap[address] * balance - position.againstMap[address] = position.againstMap[address] * balance + position.proMap[address] *= balance + position.againstMap[address] *= balance position.totalPro += parseFloat(position.proMap[address]) position.totalAgainst += parseFloat(position.againstMap[address]) + // eslint-disable-next-line web3.eth.accounts.find(account => { if (address === account) { position.iHaveSignalled = true @@ -631,7 +635,7 @@ export function fetchHistoricalSignal(position, opts) { .then(response => { if (response.message === 'NOTOK') { - throw 'There was an error with the testnet API.' + throw Error('There was an error with the testnet API.') } return Promise.all( diff --git a/src/redux/actions/utils/getSignalPerBlock.js b/src/redux/actions/utils/getSignalPerBlock.js index 3dc9ce7..ee88694 100644 --- a/src/redux/actions/utils/getSignalPerBlock.js +++ b/src/redux/actions/utils/getSignalPerBlock.js @@ -1,5 +1,3 @@ -'use strict' - const _ = require('lodash') module.exports = function getSignalPerBlock(input) { @@ -16,6 +14,7 @@ module.exports = function getSignalPerBlock(input) { function backfillHistory(input) { const keys = Object.keys(input) + // eslint-disable-next-line for (let blockNumber in input) { const index = keys.indexOf(blockNumber) if (index >= 1) { @@ -30,6 +29,7 @@ module.exports = function getSignalPerBlock(input) { function dedupeTransactions(input) { let output = [] const grouped = _.groupBy(input, 'from') + // eslint-disable-next-line for (let address in grouped) { output = [ ...output, @@ -43,6 +43,7 @@ module.exports = function getSignalPerBlock(input) { let output = [] + // eslint-disable-next-line for (let address in input) { input[address] = input[address].reduce((memo, current) => { if (current.vote === '1') memo.pro.push(current) From 9808ef4014ccc9844e3aefdb4f459d33708a9426 Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 20:16:15 -0400 Subject: [PATCH 09/11] Update readme. --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 694a9e4..e72c443 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,19 @@ A React implementation of https://github.com/vulcanize/ethersignal ## Setting up development server From terminal: ```js -git clone git@github.com:langateam/ethersignal.git && cd ethersignal +git clone git@github.com:vulcanize/ethersignal-1.git && cd ethersignal-1 npm install npm start ``` -Open localhost:8080 in MIST. +Open localhost:3000 in MIST or Chrome running Metamask. + +## Deploying to production +The build tool can create a production ready version of the app and deploy it to `gh-pages +` +```js +npm run build +npm run deploy +``` ### Contract on TestNet http://testnet.etherscan.io/address/0x9e75993a7a9b9f92a1978bcc15c30cbcb967bc81#code From d4578e107218840378187ffac05f2ffc328c0884 Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 20:26:18 -0400 Subject: [PATCH 10/11] Update title of app. --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index c89bbf3..e777d5a 100644 --- a/public/index.html +++ b/public/index.html @@ -13,7 +13,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - React App + EtherSignal
From b8a90a3dbce6b255870368b74ef51e3466d90752 Mon Sep 17 00:00:00 2001 From: Blaine Price <1wbprice@gmail.com> Date: Thu, 20 Oct 2016 21:20:39 -0400 Subject: [PATCH 11/11] Remove try/catch blocks in calls to web3.js since callbacks provide an error to work with. Confirm that error messages are being displayed correctly. --- src/redux/actions/position-actions.js | 56 +++++++++++++-------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/redux/actions/position-actions.js b/src/redux/actions/position-actions.js index ca2cc9f..7f523a0 100644 --- a/src/redux/actions/position-actions.js +++ b/src/redux/actions/position-actions.js @@ -306,12 +306,12 @@ export function voteOnPosition(positionSignalAddress, vote) { Promise.all( web3.eth.accounts.map(account => { return new Promise((resolve, reject) => { - try { - resolve(etherSignal.setSignal(vote, {from: account})) - } - catch (err) { - reject(err) - } + etherSignal.setSignal(vote, {from: account}, (err, result) => { + if (err) { + reject(err.message) + } + resolve(result) + }) }) }) ) @@ -320,7 +320,7 @@ export function voteOnPosition(positionSignalAddress, vote) { dispatch(voteOnPositionSuccess(response)) }) .catch(error => { - dispatch(addTimedAlert(error.message, 'danger')) + dispatch(addTimedAlert('Your vote was not submited.', 'danger')) dispatch(voteOnPositionFailure(error)) }) } @@ -400,30 +400,26 @@ export function submitNewPosition(title, description, account) { return dispatch => { dispatch(submitNewPositionRequest()) web3.eth.estimateGas({from: sender, to: address, data: data}, (err, gas) => { - try { - positionRegistry.registerPosition.sendTransaction( - title, - description, - { - from: sender, - to: address, - gas: gas - }, - (err, result) => { - if (err) throw err + positionRegistry.registerPosition.sendTransaction( + title, + description, + { + from: sender, + to: address, + gas: gas + }, + (err, result) => { + if (err) { + dispatch(addTimedAlert('The position was not submitted.', 'danger')) + dispatch(submitNewPositionFailure(err)) + } + else { dispatch(addTimedAlert('The position was submitted!', 'success')) dispatch(submitNewPositionSuccess(result)) } - ) - } - - catch (error) { - dispatch(addTimedAlert(error.message, 'danger')) - dispatch(submitNewPositionFailure(error)) - } - + } + ) }) - } } @@ -568,17 +564,17 @@ export function addPositionDeposit(value, denomination, senderAddr, recipientAdd from: senderAddr, to: recipientAddr }, (err, result) => { - if (err) reject(err) + if (err) reject('The deposit was not submitted.') resolve(result) }) }) .then(response => { - dispatch(addTimedAlert('The deposit was submitted successfully', 'success')) + dispatch(addTimedAlert('The deposit was submitted successfully!', 'success')) dispatch(hidePositionDepositModal()) dispatch(addPositionDepositSuccess(response)) }) .catch(error => { - dispatch(addTimedAlert('The transaction was not confirmed', 'danger')) + dispatch(addTimedAlert('The deposit was not submitted.', 'danger')) dispatch(hidePositionDepositModal()) dispatch(addPositionDepositFailure(error)) })