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/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 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..85ecd99 100644 --- a/package.json +++ b/package.json @@ -1,62 +1,35 @@ { - "name": "ethersignal", + "name": "ethersignal-1", "version": "0.0.1", "private": true, + "homepage": "http://vulcanize.github.io/ethersignal-1", "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 0000000..5c125de Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..e777d5a --- /dev/null +++ b/public/index.html @@ -0,0 +1,31 @@ + + + + + + + + EtherSignal + + +
+ + + 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(); -}); 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..7f523a0 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 @@ -302,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) + }) }) }) ) @@ -316,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)) }) } @@ -396,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)) - } - + } + ) }) - } } @@ -564,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)) }) @@ -631,7 +631,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)