From b3056cd0ab36ef6c27c39ff8f6b4166499fefad3 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 10:33:37 +0200 Subject: [PATCH 001/314] Add ABI/API package.json --- js/src/abi/package.json | 29 +++++++++++++++++++++++++++++ js/src/api/package.json | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 js/src/abi/package.json create mode 100644 js/src/api/package.json diff --git a/js/src/abi/package.json b/js/src/abi/package.json new file mode 100644 index 0000000000..b09f52c039 --- /dev/null +++ b/js/src/abi/package.json @@ -0,0 +1,29 @@ +{ + "name": "@parity/abi", + "description": "The Parity ABI library", + "version": "0.0.0", + "main": "index.js", + "author": "Parity Team ", + "maintainers": [ + "Jaco Greeff" + ], + "contributors": [], + "license": "GPL-3.0", + "repository": { + "type": "git", + "url": "git+https://github.com/paritytech/parity.git" + }, + "keywords": [ + "Ethereum", + "ABI", + "Parity" + ], + "scripts": { + }, + "devDependencies": { + }, + "dependencies": { + "bignumber.js": "~2.3.0", + "js-sha3": "~0.5.2" + } +} diff --git a/js/src/api/package.json b/js/src/api/package.json new file mode 100644 index 0000000000..acbd37001d --- /dev/null +++ b/js/src/api/package.json @@ -0,0 +1,34 @@ +{ + "name": "@parity/api", + "description": "The Parity Promise-based API library for interfacing with Ethereum over RPC", + "version": "0.0.0", + "main": "index.js", + "author": "Parity Team ", + "maintainers": [ + "Jaco Greeff" + ], + "contributors": [], + "license": "GPL-3.0", + "repository": { + "type": "git", + "url": "git+https://github.com/paritytech/parity.git" + }, + "keywords": [ + "Ethereum", + "API", + "RPC", + "Parity", + "Promise" + ], + "scripts": { + }, + "devDependencies": { + }, + "dependencies": { + "@parity/abi": "file:../abi", + "bignumber.js": "~2.3.0", + "eventemitter3": "2.0.2", + "js-sha3": "~0.5.2", + "node-fetch": "~1.6.3" + } +} -- GitLab From 4568300d9bda79692384ffd1706b0882f8e75d8a Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 10:34:00 +0200 Subject: [PATCH 002/314] Use @parity/abi --- js/src/api/contract/contract.js | 2 +- js/src/api/util/encode.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/src/api/contract/contract.js b/js/src/api/contract/contract.js index 2156b8af12..77c9568a9c 100644 --- a/js/src/api/contract/contract.js +++ b/js/src/api/contract/contract.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import Abi from '~/abi'; +import Abi from '@parity/abi'; let nextSubscriptionId = 0; diff --git a/js/src/api/util/encode.js b/js/src/api/util/encode.js index f18fbbe2b7..e936faa382 100644 --- a/js/src/api/util/encode.js +++ b/js/src/api/util/encode.js @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import Abi from '~/abi'; -import Func from '~/abi/spec/function'; +import Abi from '@parity/abi'; +import Func from '@parity/abi/spec/function'; import { abiDecode } from './decode'; import { cleanupValue } from './format'; -- GitLab From 0d9e849162baae82b458e4d258e59229828b8278 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 10:34:23 +0200 Subject: [PATCH 003/314] Build with @parity/(abi|api) packages --- js/package.json | 2 ++ js/webpack/app.js | 8 +++++++- js/webpack/libraries.js | 8 +++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/js/package.json b/js/package.json index ac1731b916..64d2a24cf4 100644 --- a/js/package.json +++ b/js/package.json @@ -158,6 +158,8 @@ "yargs": "6.6.0" }, "dependencies": { + "@parity/abi": "file:src/abi", + "@parity/api": "file:src/api", "@parity/wordlist": "1.0.1", "base32.js": "0.1.0", "bignumber.js": "3.0.1", diff --git a/js/webpack/app.js b/js/webpack/app.js index ded5c44686..6d61f7518e 100644 --- a/js/webpack/app.js +++ b/js/webpack/app.js @@ -65,9 +65,15 @@ module.exports = { exclude: /(node_modules)/, use: [ 'happypack/loader?id=babel-js' ] }, + // duplicated for clarity since the number of @parity modules will increase { test: /\.js$/, - include: /node_modules\/(material-chip-input|ethereumjs-tx|@parity\/wordlist)/, + include: /node_modules\/@parity\/(abi|api|wordlist)/, + use: 'babel-loader' + }, + { + test: /\.js$/, + include: /node_modules\/(material-chip-input|ethereumjs-tx)/, use: 'babel-loader' }, { diff --git a/js/webpack/libraries.js b/js/webpack/libraries.js index 1fcb39ebaa..ff41132be1 100644 --- a/js/webpack/libraries.js +++ b/js/webpack/libraries.js @@ -58,9 +58,15 @@ module.exports = { 'babel-loader?cacheDirectory=true' ] }, + // duplicated for clarity since the number of @parity modules will increase { test: /\.js$/, - include: /node_modules\/(ethereumjs-tx|@parity\/wordlist)/, + include: /node_modules\/@parity\/(abi|api|wordlist)/, + use: 'babel-loader' + }, + { + test: /\.js$/, + include: /node_modules\/ethereumjs-tx/, use: 'babel-loader' }, { -- GitLab From 94c8cceb42e20e5ab8a8173c7f37fc07f18f2bcf Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 10:41:06 +0200 Subject: [PATCH 004/314] Add @parity/jsonrpc --- js/package.json | 1 + js/src/api/api.spec.js | 4 ++-- js/src/api/package.json | 1 + js/src/jsonrpc/package.json | 27 +++++++++++++++++++++++++++ js/webpack/app.js | 2 +- js/webpack/libraries.js | 2 +- 6 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 js/src/jsonrpc/package.json diff --git a/js/package.json b/js/package.json index 64d2a24cf4..924191ee3d 100644 --- a/js/package.json +++ b/js/package.json @@ -160,6 +160,7 @@ "dependencies": { "@parity/abi": "file:src/abi", "@parity/api": "file:src/api", + "@parity/jsonrpc": "file:src/jsonrpc", "@parity/wordlist": "1.0.1", "base32.js": "0.1.0", "bignumber.js": "3.0.1", diff --git a/js/src/api/api.spec.js b/js/src/api/api.spec.js index 1c5ebf514d..aa18333a08 100644 --- a/js/src/api/api.spec.js +++ b/js/src/api/api.spec.js @@ -14,13 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import ethereumRpc from '@parity/jsonrpc'; + import { TEST_HTTP_URL, endpointTest } from '../../test/mockRpc'; import util from './util'; import Api from './api'; -import ethereumRpc from '../jsonrpc/'; - describe('api/Api', () => { describe('constructor', () => { it('requires defined/non-null transport object', () => { diff --git a/js/src/api/package.json b/js/src/api/package.json index acbd37001d..f544ffe4f6 100644 --- a/js/src/api/package.json +++ b/js/src/api/package.json @@ -26,6 +26,7 @@ }, "dependencies": { "@parity/abi": "file:../abi", + "@parity/jsonrpc": "file:../jsonrpc", "bignumber.js": "~2.3.0", "eventemitter3": "2.0.2", "js-sha3": "~0.5.2", diff --git a/js/src/jsonrpc/package.json b/js/src/jsonrpc/package.json new file mode 100644 index 0000000000..d148126c0c --- /dev/null +++ b/js/src/jsonrpc/package.json @@ -0,0 +1,27 @@ +{ + "name": "@parity/jsonrpc", + "description": "JSON and JS interface defintions for RPC", + "version": "0.0.0", + "main": "index.js", + "author": "Parity Team ", + "maintainers": [ + "Jaco Greeff" + ], + "contributors": [], + "license": "GPL-3.0", + "repository": { + "type": "git", + "url": "git+https://github.com/paritytech/parity.git" + }, + "keywords": [ + "Ethereum", + "RPC", + "Parity" + ], + "scripts": { + }, + "devDependencies": { + }, + "dependencies": { + } +} diff --git a/js/webpack/app.js b/js/webpack/app.js index 6d61f7518e..e849ad825a 100644 --- a/js/webpack/app.js +++ b/js/webpack/app.js @@ -68,7 +68,7 @@ module.exports = { // duplicated for clarity since the number of @parity modules will increase { test: /\.js$/, - include: /node_modules\/@parity\/(abi|api|wordlist)/, + include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, use: 'babel-loader' }, { diff --git a/js/webpack/libraries.js b/js/webpack/libraries.js index ff41132be1..0c151b8289 100644 --- a/js/webpack/libraries.js +++ b/js/webpack/libraries.js @@ -61,7 +61,7 @@ module.exports = { // duplicated for clarity since the number of @parity modules will increase { test: /\.js$/, - include: /node_modules\/@parity\/(abi|api|wordlist)/, + include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, use: 'babel-loader' }, { -- GitLab From 8b144bedd1af0770221bcdaa41f66bdbc51f6484 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 11:17:58 +0200 Subject: [PATCH 005/314] Shared build rules --- js/webpack/app.js | 15 ++++----------- js/webpack/libraries.js | 15 ++++----------- js/webpack/npm.js | 10 +++++----- js/webpack/rules/es6.js | 21 +++++++++++++++++++++ js/webpack/rules/parity.js | 21 +++++++++++++++++++++ 5 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 js/webpack/rules/es6.js create mode 100644 js/webpack/rules/parity.js diff --git a/js/webpack/app.js b/js/webpack/app.js index e849ad825a..ba8e9a7650 100644 --- a/js/webpack/app.js +++ b/js/webpack/app.js @@ -25,6 +25,8 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin'); const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin'); +const rulesEs6 = require('./rules/es6'); +const rulesParity = require('./rules/parity'); const Shared = require('./shared'); const DAPPS = require('../src/views/Dapps/builtin.json'); @@ -60,22 +62,13 @@ module.exports = { module: { rules: [ + rulesParity, + rulesEs6, { test: /\.js$/, exclude: /(node_modules)/, use: [ 'happypack/loader?id=babel-js' ] }, - // duplicated for clarity since the number of @parity modules will increase - { - test: /\.js$/, - include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, - use: 'babel-loader' - }, - { - test: /\.js$/, - include: /node_modules\/(material-chip-input|ethereumjs-tx)/, - use: 'babel-loader' - }, { test: /\.json$/, use: [ 'json-loader' ] diff --git a/js/webpack/libraries.js b/js/webpack/libraries.js index 0c151b8289..d9ddaf53cf 100644 --- a/js/webpack/libraries.js +++ b/js/webpack/libraries.js @@ -18,6 +18,8 @@ const path = require('path'); +const rulesEs6 = require('./rules/es6'); +const rulesParity = require('./rules/parity'); const Shared = require('./shared'); const DEST = process.env.BUILD_DEST || '.build'; @@ -49,6 +51,8 @@ module.exports = { module: { rules: [ + rulesParity, + rulesEs6, { test: /\.js$/, exclude: /node_modules/, @@ -58,17 +62,6 @@ module.exports = { 'babel-loader?cacheDirectory=true' ] }, - // duplicated for clarity since the number of @parity modules will increase - { - test: /\.js$/, - include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, - use: 'babel-loader' - }, - { - test: /\.js$/, - include: /node_modules\/ethereumjs-tx/, - use: 'babel-loader' - }, { test: /\.json$/, use: [ 'json-loader' ] diff --git a/js/webpack/npm.js b/js/webpack/npm.js index 2230bf90f3..94d8cdc1e9 100644 --- a/js/webpack/npm.js +++ b/js/webpack/npm.js @@ -18,6 +18,8 @@ const path = require('path'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const packageJson = require('../package.json'); +const rulesEs6 = require('./rules/es6'); +const rulesParity = require('./rules/parity'); const Shared = require('./shared'); const ENV = process.env.NODE_ENV || 'development'; @@ -26,6 +28,7 @@ const isProd = ENV === 'production'; const LIBRARY = process.env.LIBRARY; if (!LIBRARY) { + console.error('$LIBRARY environment variable not defined'); process.exit(-1); } @@ -57,6 +60,8 @@ module.exports = { /babel-polyfill/ ], rules: [ + rulesParity, + rulesEs6, { test: /(\.jsx|\.js)$/, // use: [ 'happypack/loader?id=js' ], @@ -65,11 +70,6 @@ module.exports = { 'babel-loader?cacheDirectory=true' ], exclude: /node_modules/ - }, - { - test: /\.js$/, - include: /node_modules\/(ethereumjs-tx|@parity\/wordlist)/, - use: 'babel-loader' } ] }, diff --git a/js/webpack/rules/es6.js b/js/webpack/rules/es6.js new file mode 100644 index 0000000000..8e485424ee --- /dev/null +++ b/js/webpack/rules/es6.js @@ -0,0 +1,21 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +module.exports = { + test: /\.js$/, + include: /node_modules\/(material-chip-input|ethereumjs-tx)/, + use: 'babel-loader' +}; diff --git a/js/webpack/rules/parity.js b/js/webpack/rules/parity.js new file mode 100644 index 0000000000..6897b218e9 --- /dev/null +++ b/js/webpack/rules/parity.js @@ -0,0 +1,21 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +module.exports = { + test: /\.js$/, + include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, + use: 'babel-loader' +}; -- GitLab From 8a46a4b5675a758a10034fac58f0d47e7d3926ef Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 11:24:49 +0200 Subject: [PATCH 006/314] Move API dependencies --- js/package.json | 4 +--- js/src/abi/package.json | 4 ++-- js/src/api/package.json | 9 ++++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/js/package.json b/js/package.json index 924191ee3d..908a5fbd6d 100644 --- a/js/package.json +++ b/js/package.json @@ -148,6 +148,7 @@ "stylelint": "7.9.0", "stylelint-config-standard": "16.0.0", "to-source": "2.0.3", + "uglify-js": "2.8.16", "url-loader": "0.5.7", "webpack": "2.2.1", "webpack-bundle-size-analyzer": "2.5.0", @@ -179,7 +180,6 @@ "geopattern": "1.2.3", "isomorphic-fetch": "2.2.1", "js-sha3": "0.5.5", - "keythereum": "0.4.6", "lodash": "4.17.2", "loglevel": "1.4.1", "marked": "0.3.6", @@ -217,13 +217,11 @@ "redux-thunk": "2.1.0", "rlp": "2.0.0", "scryptsy": "2.0.0", - "secp256k1": "3.2.5", "solc": "ngotchac/solc-js", "store": "1.3.20", "sw-toolbox": "^3.6.0", "u2f-api": "0.0.9", "u2f-api-polyfill": "0.4.3", - "uglify-js": "2.8.16", "useragent.js": "0.5.6", "utf8": "2.1.2", "valid-url": "1.0.9", diff --git a/js/src/abi/package.json b/js/src/abi/package.json index b09f52c039..7567370fe7 100644 --- a/js/src/abi/package.json +++ b/js/src/abi/package.json @@ -23,7 +23,7 @@ "devDependencies": { }, "dependencies": { - "bignumber.js": "~2.3.0", - "js-sha3": "~0.5.2" + "bignumber.js": "3.0.1", + "js-sha3": "0.5.5" } } diff --git a/js/src/api/package.json b/js/src/api/package.json index f544ffe4f6..bb08987041 100644 --- a/js/src/api/package.json +++ b/js/src/api/package.json @@ -27,9 +27,12 @@ "dependencies": { "@parity/abi": "file:../abi", "@parity/jsonrpc": "file:../jsonrpc", - "bignumber.js": "~2.3.0", + "bignumber.js": "3.0.1", + "ethereumjs-tx": "1.2.5", "eventemitter3": "2.0.2", - "js-sha3": "~0.5.2", - "node-fetch": "~1.6.3" + "js-sha3": "0.5.5", + "keythereum": "0.4.6", + "node-fetch": "1.6.3", + "secp256k1": "3.2.5" } } -- GitLab From bb628bca8830aa693eb033f53e7d4d545c54f81f Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 11:42:32 +0200 Subject: [PATCH 007/314] Add missing npm aliasses --- js/webpack/npm.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/webpack/npm.js b/js/webpack/npm.js index 94d8cdc1e9..33951fee4c 100644 --- a/js/webpack/npm.js +++ b/js/webpack/npm.js @@ -76,7 +76,9 @@ module.exports = { resolve: { alias: { - '~': path.resolve(__dirname, '../src') + '~': path.resolve(__dirname, '../src'), + 'secp256k1': path.resolve(__dirname, '../node_modules/secp256k1/js'), + 'keythereum': path.resolve(__dirname, '../node_modules/keythereum/dist/keythereum') }, modules: [ path.resolve('./src'), -- GitLab From 887b7b50909d2a4f77f4568d556b8ee942d234bd Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 11:48:42 +0200 Subject: [PATCH 008/314] Update maintainers --- js/src/abi/package.json | 3 ++- js/src/api/package.json | 3 ++- js/src/jsonrpc/package.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/js/src/abi/package.json b/js/src/abi/package.json index 7567370fe7..946d15e572 100644 --- a/js/src/abi/package.json +++ b/js/src/abi/package.json @@ -5,7 +5,8 @@ "main": "index.js", "author": "Parity Team ", "maintainers": [ - "Jaco Greeff" + "Jaco Greeff", + "Nicolas Gotchac" ], "contributors": [], "license": "GPL-3.0", diff --git a/js/src/api/package.json b/js/src/api/package.json index bb08987041..91042501cc 100644 --- a/js/src/api/package.json +++ b/js/src/api/package.json @@ -5,7 +5,8 @@ "main": "index.js", "author": "Parity Team ", "maintainers": [ - "Jaco Greeff" + "Jaco Greeff", + "Nicolas Gotchac" ], "contributors": [], "license": "GPL-3.0", diff --git a/js/src/jsonrpc/package.json b/js/src/jsonrpc/package.json index d148126c0c..1bdc7596a9 100644 --- a/js/src/jsonrpc/package.json +++ b/js/src/jsonrpc/package.json @@ -5,7 +5,8 @@ "main": "index.js", "author": "Parity Team ", "maintainers": [ - "Jaco Greeff" + "Jaco Greeff", + "Maciej Hirsz" ], "contributors": [], "license": "GPL-3.0", -- GitLab From 75d9fa3fe94ab044b799bc3ef7c6822d2913d9c4 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 11:56:13 +0200 Subject: [PATCH 009/314] mocha babel ignores (@parity modules) --- js/test/babel.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/test/babel.js b/js/test/babel.js index c9c1d9daec..95a988d42c 100644 --- a/js/test/babel.js +++ b/js/test/babel.js @@ -14,4 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -require('babel-register')(); +require('babel-register')({ + ignore: /node_modules\/(?!@parity\/(abi|api|jsonrpc))/ +}); -- GitLab From 11bcfa05e37ec237f57c13f6c48565fc22049b08 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 12:03:07 +0200 Subject: [PATCH 010/314] Update remaining ../abi to @parity/abi --- js/src/api/contract/contract.spec.js | 3 ++- js/src/api/format/output.js | 3 ++- js/src/api/util/decode.js | 4 ++-- js/src/api/util/index.js | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/src/api/contract/contract.spec.js b/js/src/api/contract/contract.spec.js index bd8b0fbdae..53889e3204 100644 --- a/js/src/api/contract/contract.spec.js +++ b/js/src/api/contract/contract.spec.js @@ -17,9 +17,10 @@ import BigNumber from 'bignumber.js'; import sinon from 'sinon'; +import Abi from '@parity/abi'; + import { TEST_HTTP_URL, mockHttp } from '../../../test/mockRpc'; -import Abi from '../../abi'; import { sha3 } from '../util/sha3'; import Api from '../api'; diff --git a/js/src/api/format/output.js b/js/src/api/format/output.js index df40b59a0b..ddb8b79f89 100644 --- a/js/src/api/format/output.js +++ b/js/src/api/format/output.js @@ -16,7 +16,8 @@ import BigNumber from 'bignumber.js'; -import { toChecksumAddress } from '../../abi/util/address'; +import { toChecksumAddress } from '@parity/abi/util/address'; + import { isString } from '../util/types'; export function outAccountInfo (infos) { diff --git a/js/src/api/util/decode.js b/js/src/api/util/decode.js index 926a5a8a15..995118a720 100644 --- a/js/src/api/util/decode.js +++ b/js/src/api/util/decode.js @@ -16,8 +16,8 @@ import { isHex } from './types'; -import Func from '../../abi/spec/function'; -import { fromParamType, toParamType } from '../../abi/spec/paramType/format'; +import Func from '@parity/abi/spec/function'; +import { fromParamType, toParamType } from '@parity/abi/spec/paramType/format'; export function decodeCallData (data) { if (!isHex(data)) { diff --git a/js/src/api/util/index.js b/js/src/api/util/index.js index cc8fc9b939..d174c34313 100644 --- a/js/src/api/util/index.js +++ b/js/src/api/util/index.js @@ -14,7 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import { isAddress as isAddressValid, toChecksumAddress } from '../../abi/util/address'; +import { isAddress as isAddressValid, toChecksumAddress } from '@parity/abi/util/address'; + import { abiDecode, decodeCallData, decodeMethodInput, methodToAbi } from './decode'; import { abiEncode, abiUnencode, abiSignature, encodeMethodCallAbi } from './encode'; import { bytesToHex, hexToAscii, asciiToHex, cleanupValue } from './format'; -- GitLab From 9652c0fabb9288560f9a5a5b9d60c11eba9c78cb Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 15:45:31 +0200 Subject: [PATCH 011/314] UI packages to ui --- js/package.json | 17 +++----------- js/src/ui/package.json | 50 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 js/src/ui/package.json diff --git a/js/package.json b/js/package.json index 07314f84de..1ba973b2e4 100644 --- a/js/package.json +++ b/js/package.json @@ -158,33 +158,30 @@ "yargs": "6.6.0" }, "dependencies": { + "@parity/ui": "file:src/ui", "@parity/wordlist": "1.0.1", "base32.js": "0.1.0", "bignumber.js": "3.0.1", "blockies": "0.0.2", - "brace": "0.9.0", "bytes": "2.4.0", "debounce": "1.0.0", "es6-error": "4.0.0", "es6-promise": "4.0.5", "ethereumjs-tx": "1.2.5", "eventemitter3": "2.0.2", - "file-saver": "1.3.3", "flat": "2.0.1", "format-json": "1.0.3", "format-number": "2.0.1", - "geopattern": "1.2.3", "isomorphic-fetch": "2.2.1", "js-sha3": "0.5.5", + "keycode": "2.1.8", "keythereum": "0.4.6", "lodash": "4.17.2", "loglevel": "1.4.1", "marked": "0.3.6", "material-ui": "0.16.5", - "material-ui-chip-input": "0.11.1", "mobx": "2.6.4", "mobx-react": "4.0.3", - "mobx-react-devtools": "4.2.10", "moment": "2.17.0", "napa": "2.3.0", "phoneformat.js": "1.0.3", @@ -192,23 +189,16 @@ "push.js": "0.0.11", "qs": "6.3.0", "react": "15.4.2", - "react-ace": "4.1.0", "react-addons-css-transition-group": "15.4.2", - "react-copy-to-clipboard": "4.2.3", "react-dom": "15.4.2", - "react-dropzone": "3.7.3", "react-element-to-jsx-string": "6.0.0", - "react-event-listener": "0.4.1", "react-intl": "2.1.5", "react-markdown": "2.4.4", - "react-portal": "3.0.0", - "react-qr-reader": "1.0.3", "react-redux": "4.4.6", "react-router": "3.0.0", "react-router-redux": "4.0.7", "react-tap-event-plugin": "2.0.1", "react-tooltip": "3.2.2", - "recharts": "0.15.2", "redux": "3.6.0", "redux-actions": "1.1.0", "redux-thunk": "2.1.0", @@ -227,7 +217,6 @@ "validator": "6.2.0", "web3": "0.17.0-beta", "whatwg-fetch": "2.0.1", - "worker-loader": "^0.8.0", - "zxcvbn": "4.4.1" + "worker-loader": "^0.8.0" } } diff --git a/js/src/ui/package.json b/js/src/ui/package.json new file mode 100644 index 0000000000..c299efc72d --- /dev/null +++ b/js/src/ui/package.json @@ -0,0 +1,50 @@ +{ + "name": "@parity/ui", + "description": "Parity React UI components", + "version": "0.0.0", + "main": "index.js", + "author": "Parity Team ", + "maintainers": [ + "Jaco Greeff", + "Nicolas Gotchac" + ], + "contributors": [], + "license": "GPL-3.0", + "repository": { + "type": "git", + "url": "git+https://github.com/paritytech/parity.git" + }, + "keywords": [], + "scripts": {}, + "devDependencies": {}, + "dependencies": { + "bignumber.js": "3.0.1", + "brace": "0.9.0", + "file-saver": "1.3.3", + "geopattern": "1.2.3", + "js-sha3": "0.5.5", + "keycode": "2.1.8", + "lodash": "4.17.2", + "material-ui": "0.16.5", + "material-ui-chip-input": "0.11.1", + "moment": "2.17.0", + "react-ace": "4.1.0", + "react-copy-to-clipboard": "4.2.3", + "react-dropzone": "3.7.3", + "react-event-listener": "0.4.1", + "react-portal": "3.0.0", + "react-qr-reader": "1.0.3", + "recharts": "0.15.2", + "zxcvbn": "4.4.1" + }, + "peerDependencies": { + "mobx": "*", + "mobx-react": "*", + "react": "*", + "react-dom": "*", + "react-intl": "*", + "react-redux": "*", + "react-router": "*", + "redux": "*" + } +} -- GitLab From 89e5601ec034c7f8898112d3a87e80bb540dac26 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 20 Apr 2017 15:47:20 +0200 Subject: [PATCH 012/314] blockies dep -> api --- js/package.json | 1 - js/src/api/package.json | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/js/package.json b/js/package.json index 908a5fbd6d..4424c9129b 100644 --- a/js/package.json +++ b/js/package.json @@ -165,7 +165,6 @@ "@parity/wordlist": "1.0.1", "base32.js": "0.1.0", "bignumber.js": "3.0.1", - "blockies": "0.0.2", "brace": "0.9.0", "bytes": "2.4.0", "debounce": "1.0.0", diff --git a/js/src/api/package.json b/js/src/api/package.json index 91042501cc..0856c9170a 100644 --- a/js/src/api/package.json +++ b/js/src/api/package.json @@ -29,6 +29,7 @@ "@parity/abi": "file:../abi", "@parity/jsonrpc": "file:../jsonrpc", "bignumber.js": "3.0.1", + "blockies": "0.0.2", "ethereumjs-tx": "1.2.5", "eventemitter3": "2.0.2", "js-sha3": "0.5.5", -- GitLab From 23469a99e8b6dd96422c0d158647b9568ac3b0b7 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 21 Apr 2017 11:40:22 +0200 Subject: [PATCH 013/314] Fix API references to @parity/api --- js/src/api/local/ethkey/worker.js | 3 ++- js/src/modals/CreateAccount/createAccount.js | 3 ++- js/src/modals/CreateAccount/store.js | 2 +- js/src/modals/CreateWallet/WalletInfo/walletInfo.js | 3 ++- js/src/modals/CreateWallet/createWalletStore.js | 5 +++-- js/src/modals/ExecuteContract/executeContract.js | 3 ++- js/src/modals/Faucet/store.js | 3 ++- js/src/modals/FirstRun/firstRun.js | 3 ++- js/src/modals/Transfer/store.js | 5 +++-- js/src/modals/Verification/GatherData/gatherData.js | 3 ++- js/src/modals/Verification/email-store.js | 5 +++-- js/src/modals/Verification/store.js | 7 ++++--- js/src/modals/WalletSettings/walletSettings.js | 3 ++- js/src/redux/providers/balances.js | 3 ++- js/src/redux/providers/balancesActions.js | 3 ++- js/src/redux/providers/certifications/middleware.js | 5 +++-- js/src/redux/providers/imagesReducer.js | 3 ++- js/src/redux/providers/personalActions.js | 3 ++- js/src/redux/providers/requestsActions.js | 3 ++- js/src/redux/providers/signerMiddleware.js | 3 ++- js/src/redux/providers/walletActions.js | 7 ++++--- js/src/secureApi.js | 2 +- js/src/ui/Balance/balance.spec.js | 2 +- js/src/ui/Form/AddressSelect/addressSelect.js | 4 ++-- js/src/ui/Form/AddressSelect/addressSelectStore.js | 3 ++- js/src/ui/Form/InputAddress/inputAddress.js | 3 ++- js/src/ui/Form/TypedInput/typedInput.js | 5 +++-- js/src/ui/IdentityIcon/identityIcon.js | 3 ++- js/src/ui/MethodDecoding/methodDecodingStore.js | 2 +- js/src/ui/TxList/TxRow/txRow.spec.js | 2 +- js/src/ui/TxList/txList.spec.js | 2 +- js/src/util/dapps.js | 3 ++- js/src/util/qrscan.js | 4 ++-- js/src/util/signer.js | 4 ++-- js/src/util/tokens.js | 5 +++-- js/src/util/validation.js | 2 +- js/src/util/wallets.js | 7 ++++--- js/src/views/Application/Requests/savedRequests.js | 2 +- js/src/views/Wallet/Confirmations/confirmations.js | 3 ++- js/src/views/Wallet/Transactions/transactions.js | 3 ++- js/src/views/WriteContract/writeContractStore.js | 3 ++- 41 files changed, 86 insertions(+), 56 deletions(-) diff --git a/js/src/api/local/ethkey/worker.js b/js/src/api/local/ethkey/worker.js index ffb99d0e85..d5fce2a713 100644 --- a/js/src/api/local/ethkey/worker.js +++ b/js/src/api/local/ethkey/worker.js @@ -16,7 +16,8 @@ import secp256k1 from 'secp256k1'; import { keccak_256 as keccak256 } from 'js-sha3'; -import { bytesToHex } from '~/api/util/format'; + +import { bytesToHex } from '../../util/format'; const isWorker = typeof self !== 'undefined'; diff --git a/js/src/modals/CreateAccount/createAccount.js b/js/src/modals/CreateAccount/createAccount.js index 56f1db7517..1fdc660038 100644 --- a/js/src/modals/CreateAccount/createAccount.js +++ b/js/src/modals/CreateAccount/createAccount.js @@ -20,8 +20,9 @@ import { FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; +import { createIdentityImg } from '@parity/api/util/identity'; + import ParityLogo from '~/../assets/images/parity-logo-black-no-text.svg'; -import { createIdentityImg } from '~/api/util/identity'; import { newError } from '~/redux/actions'; import { Button, ModalBox, Portal } from '~/ui'; import { CancelIcon, CheckIcon, DoneIcon, NextIcon, PrevIcon, PrintIcon } from '~/ui/Icons'; diff --git a/js/src/modals/CreateAccount/store.js b/js/src/modals/CreateAccount/store.js index 9f78360faf..287536d531 100644 --- a/js/src/modals/CreateAccount/store.js +++ b/js/src/modals/CreateAccount/store.js @@ -16,7 +16,7 @@ import { action, computed, observable, transaction } from 'mobx'; -import apiutil from '~/api/util'; +import apiutil from '@parity/api/util'; import ERRORS from './errors'; diff --git a/js/src/modals/CreateWallet/WalletInfo/walletInfo.js b/js/src/modals/CreateWallet/WalletInfo/walletInfo.js index bd65a24709..46bb82985d 100644 --- a/js/src/modals/CreateWallet/WalletInfo/walletInfo.js +++ b/js/src/modals/CreateWallet/WalletInfo/walletInfo.js @@ -17,7 +17,8 @@ import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; -import { fromWei } from '~/api/util/wei'; +import { fromWei } from '@parity/api/util/wei'; + import { CompletedStep, IdentityIcon, CopyToClipboard } from '~/ui'; import styles from '../createWallet.css'; diff --git a/js/src/modals/CreateWallet/createWalletStore.js b/js/src/modals/CreateWallet/createWalletStore.js index 740aa8f171..c4526e5829 100644 --- a/js/src/modals/CreateWallet/createWalletStore.js +++ b/js/src/modals/CreateWallet/createWalletStore.js @@ -19,13 +19,14 @@ import { observable, computed, action, transaction } from 'mobx'; import React from 'react'; import { FormattedMessage } from 'react-intl'; -import Contract from '~/api/contract'; +import Contract from '@parity/api/contract'; +import { toWei } from '@parity/api/util/wei'; + import Contracts from '~/contracts'; import { wallet as walletAbi } from '~/contracts/abi'; import { wallet as walletCode, walletLibrary as walletLibraryCode, walletLibraryRegKey, fullWalletCode } from '~/contracts/code/wallet'; import { validateUint, validateAddress, validateName } from '~/util/validation'; -import { toWei } from '~/api/util/wei'; import { deploy } from '~/util/tx'; import WalletsUtils from '~/util/wallets'; diff --git a/js/src/modals/ExecuteContract/executeContract.js b/js/src/modals/ExecuteContract/executeContract.js index e0566f7df0..db7fefbab9 100644 --- a/js/src/modals/ExecuteContract/executeContract.js +++ b/js/src/modals/ExecuteContract/executeContract.js @@ -19,7 +19,8 @@ import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; -import { toWei } from '~/api/util/wei'; +import { toWei } from '@parity/api/util/wei'; + import { Button, GasPriceEditor, IdentityIcon, Portal, Warning } from '~/ui'; import { CancelIcon, NextIcon, PrevIcon } from '~/ui/Icons'; import { MAX_GAS_ESTIMATION } from '~/util/constants'; diff --git a/js/src/modals/Faucet/store.js b/js/src/modals/Faucet/store.js index 356a4c080c..18c2269716 100644 --- a/js/src/modals/Faucet/store.js +++ b/js/src/modals/Faucet/store.js @@ -15,7 +15,8 @@ // along with Parity. If not, see . import { action, computed, observable, transaction } from 'mobx'; -import apiutil from '~/api/util'; + +import apiutil from '@parity/api/util'; const ENDPOINT = 'http://faucet.kovan.network/api/'; diff --git a/js/src/modals/FirstRun/firstRun.js b/js/src/modals/FirstRun/firstRun.js index 1376a71b0f..826a02d99a 100644 --- a/js/src/modals/FirstRun/firstRun.js +++ b/js/src/modals/FirstRun/firstRun.js @@ -20,8 +20,9 @@ import { FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; +import { createIdentityImg } from '@parity/api/util/identity'; + import ParityLogo from '~/../assets/images/parity-logo-black-no-text.svg'; -import { createIdentityImg } from '~/api/util/identity'; import { newError } from '~/redux/actions'; import { Button, Portal } from '~/ui'; import { CheckIcon, DoneIcon, NextIcon, PrintIcon } from '~/ui/Icons'; diff --git a/js/src/modals/Transfer/store.js b/js/src/modals/Transfer/store.js index a0f99503c8..5098952234 100644 --- a/js/src/modals/Transfer/store.js +++ b/js/src/modals/Transfer/store.js @@ -18,9 +18,10 @@ import { noop } from 'lodash'; import { observable, computed, action, transaction } from 'mobx'; import BigNumber from 'bignumber.js'; +import Contract from '@parity/api/contract'; +import { fromWei } from '@parity/api/util/wei'; + import { eip20 as tokenAbi, wallet as walletAbi } from '~/contracts/abi'; -import { fromWei } from '~/api/util/wei'; -import Contract from '~/api/contract'; import ERRORS from './errors'; import { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION } from '~/util/constants'; import { ETH_TOKEN } from '~/util/tokens'; diff --git a/js/src/modals/Verification/GatherData/gatherData.js b/js/src/modals/Verification/GatherData/gatherData.js index b5f7bf06b3..79a0de29f9 100644 --- a/js/src/modals/Verification/GatherData/gatherData.js +++ b/js/src/modals/Verification/GatherData/gatherData.js @@ -19,7 +19,8 @@ import { FormattedMessage } from 'react-intl'; import BigNumber from 'bignumber.js'; import { Checkbox } from 'material-ui'; -import { fromWei } from '~/api/util/wei'; +import { fromWei } from '@parity/api/util/wei'; + import { Form, Input } from '~/ui'; import { DoneIcon, ErrorIcon, InfoIcon } from '~/ui/Icons'; import { nullableProptype } from '~/util/proptypes'; diff --git a/js/src/modals/Verification/email-store.js b/js/src/modals/Verification/email-store.js index d18d5fac93..b5a996a8bf 100644 --- a/js/src/modals/Verification/email-store.js +++ b/js/src/modals/Verification/email-store.js @@ -15,8 +15,9 @@ // along with Parity. If not, see . import { observable, computed, action } from 'mobx'; -import { sha3 } from '~/api/util/sha3'; -import { bytesToHex } from '~/api/util/format'; + +import { bytesToHex } from '@parity/api/util/format'; +import { sha3 } from '@parity/api/util/sha3'; import EmailVerificationABI from '~/contracts/abi/email-verification.json'; import VerificationStore, { diff --git a/js/src/modals/Verification/store.js b/js/src/modals/Verification/store.js index e7986f6ae8..a4102cc7d5 100644 --- a/js/src/modals/Verification/store.js +++ b/js/src/modals/Verification/store.js @@ -15,10 +15,11 @@ // along with Parity. If not, see . import { observable, autorun, action } from 'mobx'; -import { sha3 } from '~/api/util/sha3'; -import Contract from '~/api/contract'; -import Contracts from '~/contracts'; +import Contract from '@parity/api/contract'; +import { sha3 } from '@parity/api/util/sha3'; + +import Contracts from '~/contracts'; import { checkIfVerified, findLastRequested, awaitPuzzle } from '~/contracts/verification'; import { checkIfTxFailed, waitForConfirmations } from '~/util/tx'; diff --git a/js/src/modals/WalletSettings/walletSettings.js b/js/src/modals/WalletSettings/walletSettings.js index 359dca697b..73d8215301 100644 --- a/js/src/modals/WalletSettings/walletSettings.js +++ b/js/src/modals/WalletSettings/walletSettings.js @@ -20,9 +20,10 @@ import { connect } from 'react-redux'; import { observer } from 'mobx-react'; import { pick } from 'lodash'; +import { fromWei } from '@parity/api/util/wei'; + import { AddressSelect, Button, Form, TypedInput, Input, InputAddress, Portal } from '~/ui'; import { CancelIcon, NextIcon } from '~/ui/Icons'; -import { fromWei } from '~/api/util/wei'; import WalletSettingsStore from './walletSettingsStore.js'; import styles from './walletSettings.css'; diff --git a/js/src/redux/providers/balances.js b/js/src/redux/providers/balances.js index cc7df73dd3..34c0bb4137 100644 --- a/js/src/redux/providers/balances.js +++ b/js/src/redux/providers/balances.js @@ -16,9 +16,10 @@ import { throttle } from 'lodash'; +import { padRight } from '@parity/api/util/format'; + import { fetchBalances, fetchTokensBalances, queryTokensFilter } from './balancesActions'; import { loadTokens, fetchTokens } from './tokensActions'; -import { padRight } from '~/api/util/format'; import Contracts from '~/contracts'; diff --git a/js/src/redux/providers/balancesActions.js b/js/src/redux/providers/balancesActions.js index 73726e825e..b4b250fdcf 100644 --- a/js/src/redux/providers/balancesActions.js +++ b/js/src/redux/providers/balancesActions.js @@ -17,10 +17,11 @@ import { uniq, isEqual } from 'lodash'; import { push } from 'react-router-redux'; +import { sha3 } from '@parity/api/util/sha3'; + import { notifyTransaction } from '~/util/notifications'; import { ETH_TOKEN, fetchAccountsBalances } from '~/util/tokens'; import { LOG_KEYS, getLogger } from '~/config'; -import { sha3 } from '~/api/util/sha3'; const TRANSFER_SIGNATURE = sha3('Transfer(address,address,uint256)'); diff --git a/js/src/redux/providers/certifications/middleware.js b/js/src/redux/providers/certifications/middleware.js index a1403ee3a6..bf4729ae70 100644 --- a/js/src/redux/providers/certifications/middleware.js +++ b/js/src/redux/providers/certifications/middleware.js @@ -16,13 +16,14 @@ import { uniq, range, debounce } from 'lodash'; -import { addCertification, removeCertification } from './actions'; +import Contract from '@parity/api/contract'; import { getLogger, LOG_KEYS } from '~/config'; -import Contract from '~/api/contract'; import Contracts from '~/contracts'; import CertifierABI from '~/contracts/abi/certifier.json'; +import { addCertification, removeCertification } from './actions'; + const log = getLogger(LOG_KEYS.CertificationsMiddleware); // TODO: move this to a more general place diff --git a/js/src/redux/providers/imagesReducer.js b/js/src/redux/providers/imagesReducer.js index a96600e700..9413f7be6d 100644 --- a/js/src/redux/providers/imagesReducer.js +++ b/js/src/redux/providers/imagesReducer.js @@ -15,7 +15,8 @@ // along with Parity. If not, see . import { handleActions } from 'redux-actions'; -import { bytesToHex } from '~/api/util/format'; + +import { bytesToHex } from '@parity/api/util/format'; const ZERO = '0x0000000000000000000000000000000000000000000000000000000000000000'; diff --git a/js/src/redux/providers/personalActions.js b/js/src/redux/providers/personalActions.js index 6200537c33..62d32048d7 100644 --- a/js/src/redux/providers/personalActions.js +++ b/js/src/redux/providers/personalActions.js @@ -16,11 +16,12 @@ import { isEqual, intersection } from 'lodash'; +import Contract from '@parity/api/contract'; + import BalancesProvider from './balances'; import { updateTokensFilter } from './balancesActions'; import { attachWallets } from './walletActions'; -import Contract from '~/api/contract'; import MethodDecodingStore from '~/ui/MethodDecoding/methodDecodingStore'; import WalletsUtils from '~/util/wallets'; import { wallet as WalletAbi } from '~/contracts/abi'; diff --git a/js/src/redux/providers/requestsActions.js b/js/src/redux/providers/requestsActions.js index 970bcba917..aa6e39eb32 100644 --- a/js/src/redux/providers/requestsActions.js +++ b/js/src/redux/providers/requestsActions.js @@ -16,7 +16,8 @@ import BigNumber from 'bignumber.js'; -import { outTransaction } from '~/api/format/output'; +import { outTransaction } from '@parity/api/format/output'; + import { trackRequest as trackRequestUtil, parseTransactionReceipt } from '~/util/tx'; import SavedRequests from '~/views/Application/Requests/savedRequests'; diff --git a/js/src/redux/providers/signerMiddleware.js b/js/src/redux/providers/signerMiddleware.js index f50057abe3..6fb2efa826 100644 --- a/js/src/redux/providers/signerMiddleware.js +++ b/js/src/redux/providers/signerMiddleware.js @@ -16,7 +16,8 @@ import * as actions from './signerActions'; -import { inHex } from '~/api/format/input'; +import { inHex } from '@parity/api/format/input'; + import HardwareStore from '~/mobx/hardwareStore'; import { createSignedTx } from '~/util/qrscan'; import { Signer } from '~/util/signer'; diff --git a/js/src/redux/providers/walletActions.js b/js/src/redux/providers/walletActions.js index b31a2b35b7..4d5c902ae2 100644 --- a/js/src/redux/providers/walletActions.js +++ b/js/src/redux/providers/walletActions.js @@ -16,9 +16,10 @@ import { isEqual, uniq } from 'lodash'; -import Contract from '~/api/contract'; -import { bytesToHex, toHex } from '~/api/util/format'; -import { ERROR_CODES } from '~/api/transport/error'; +import Contract from '@parity/api/contract'; +import { ERROR_CODES } from '@parity/api/transport/error'; +import { bytesToHex, toHex } from '@parity/api/util/format'; + import { wallet as WALLET_ABI } from '~/contracts/abi'; import { MAX_GAS_ESTIMATION } from '~/util/constants'; import WalletsUtils from '~/util/wallets'; diff --git a/js/src/secureApi.js b/js/src/secureApi.js index e19d7ae998..1c288a09fc 100644 --- a/js/src/secureApi.js +++ b/js/src/secureApi.js @@ -17,7 +17,7 @@ import { uniq } from 'lodash'; import store from 'store'; -import Api from './api'; +import Api from '@parity/api'; import { LOG_KEYS, getLogger } from '~/config'; const log = getLogger(LOG_KEYS.Signer); diff --git a/js/src/ui/Balance/balance.spec.js b/js/src/ui/Balance/balance.spec.js index d5601a489f..2f541e8282 100644 --- a/js/src/ui/Balance/balance.spec.js +++ b/js/src/ui/Balance/balance.spec.js @@ -18,7 +18,7 @@ import BigNumber from 'bignumber.js'; import { shallow } from 'enzyme'; import React from 'react'; -import apiutil from '~/api/util'; +import apiutil from '@parity/api/util'; import { Balance } from './balance'; diff --git a/js/src/ui/Form/AddressSelect/addressSelect.js b/js/src/ui/Form/AddressSelect/addressSelect.js index c424424651..4b228a6c25 100644 --- a/js/src/ui/Form/AddressSelect/addressSelect.js +++ b/js/src/ui/Form/AddressSelect/addressSelect.js @@ -20,10 +20,10 @@ import { connect } from 'react-redux'; import keycode, { codes } from 'keycode'; import { FormattedMessage } from 'react-intl'; import { observer } from 'mobx-react'; - import TextFieldUnderline from 'material-ui/TextField/TextFieldUnderline'; -import apiutil from '~/api/util'; +import apiutil from '@parity/api/util'; + import AccountCard from '~/ui/AccountCard'; import CopyToClipboard from '~/ui/CopyToClipboard'; import InputAddress from '~/ui/Form/InputAddress'; diff --git a/js/src/ui/Form/AddressSelect/addressSelectStore.js b/js/src/ui/Form/AddressSelect/addressSelectStore.js index 7fc1db4802..ecf6a8db7a 100644 --- a/js/src/ui/Form/AddressSelect/addressSelectStore.js +++ b/js/src/ui/Form/AddressSelect/addressSelectStore.js @@ -19,8 +19,9 @@ import { observable, action, transaction } from 'mobx'; import { flatMap, uniqBy } from 'lodash'; import { FormattedMessage } from 'react-intl'; +import { sha3 } from '@parity/api/util/sha3'; + import Contracts from '~/contracts'; -import { sha3 } from '~/api/util/sha3'; const ZERO = /^(0x)?0*$/; diff --git a/js/src/ui/Form/InputAddress/inputAddress.js b/js/src/ui/Form/InputAddress/inputAddress.js index f17d7b4cfe..a590beddda 100644 --- a/js/src/ui/Form/InputAddress/inputAddress.js +++ b/js/src/ui/Form/InputAddress/inputAddress.js @@ -17,7 +17,8 @@ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; -import util from '~/api/util'; +import util from '@parity/api/util'; + import { nodeOrStringProptype } from '~/util/proptypes'; import { isNullAddress } from '~/util/validation'; diff --git a/js/src/ui/Form/TypedInput/typedInput.js b/js/src/ui/Form/TypedInput/typedInput.js index 0118e152d3..a3d7e3b7fa 100644 --- a/js/src/ui/Form/TypedInput/typedInput.js +++ b/js/src/ui/Form/TypedInput/typedInput.js @@ -23,8 +23,9 @@ import IconButton from 'material-ui/IconButton'; import AddIcon from 'material-ui/svg-icons/content/add'; import RemoveIcon from 'material-ui/svg-icons/content/remove'; -import { fromWei, toWei } from '~/api/util/wei'; -import { bytesToHex } from '~/api/util/format'; +import { fromWei, toWei } from '@parity/api/util/wei'; +import { bytesToHex } from '@parity/api/util/format'; + import Input from '~/ui/Form/Input'; import InputAddressSelect from '~/ui/Form/InputAddressSelect'; import Select from '~/ui/Form/Select'; diff --git a/js/src/ui/IdentityIcon/identityIcon.js b/js/src/ui/IdentityIcon/identityIcon.js index 3db1bc7631..a1843261c0 100644 --- a/js/src/ui/IdentityIcon/identityIcon.js +++ b/js/src/ui/IdentityIcon/identityIcon.js @@ -17,7 +17,8 @@ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; -import { createIdentityImg } from '~/api/util/identity'; +import { createIdentityImg } from '@parity/api/util/identity'; + import { isNullAddress } from '~/util/validation'; import { CancelIcon, ContractIcon } from '../Icons'; diff --git a/js/src/ui/MethodDecoding/methodDecodingStore.js b/js/src/ui/MethodDecoding/methodDecodingStore.js index 66f5b30c44..9f2c651f5a 100644 --- a/js/src/ui/MethodDecoding/methodDecodingStore.js +++ b/js/src/ui/MethodDecoding/methodDecodingStore.js @@ -18,7 +18,7 @@ import Contracts from '~/contracts'; import Abi from '~/abi'; import * as abis from '~/contracts/abi'; -import { decodeMethodInput } from '~/api/util/decode'; +import { decodeMethodInput } from '@parity/api/util/decode'; const CONTRACT_CREATE = '0x60606040'; diff --git a/js/src/ui/TxList/TxRow/txRow.spec.js b/js/src/ui/TxList/TxRow/txRow.spec.js index 9ff5ffbe31..a265f8d3af 100644 --- a/js/src/ui/TxList/TxRow/txRow.spec.js +++ b/js/src/ui/TxList/TxRow/txRow.spec.js @@ -19,7 +19,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import sinon from 'sinon'; -import Api from '~/api'; +import Api from '@parity/api'; import TxRow from './txRow'; diff --git a/js/src/ui/TxList/txList.spec.js b/js/src/ui/TxList/txList.spec.js index 58a5237ac6..6a60f07b01 100644 --- a/js/src/ui/TxList/txList.spec.js +++ b/js/src/ui/TxList/txList.spec.js @@ -18,7 +18,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import sinon from 'sinon'; -import Api from '~/api'; +import Api from '@parity/api'; import TxList from './txList'; diff --git a/js/src/util/dapps.js b/js/src/util/dapps.js index 2ca416e1a2..75363a4c04 100644 --- a/js/src/util/dapps.js +++ b/js/src/util/dapps.js @@ -17,9 +17,10 @@ import BigNumber from 'bignumber.js'; import { pick, range, uniq } from 'lodash'; +import { bytesToHex } from '@parity/api/util/format'; + import Contracts from '~/contracts'; import { hashToImageUrl } from '~/redux/util'; -import { bytesToHex } from '~/api/util/format'; import builtinJson from '~/views/Dapps/builtin.json'; diff --git a/js/src/util/qrscan.js b/js/src/util/qrscan.js index f3cf2f9e95..e77ab15797 100644 --- a/js/src/util/qrscan.js +++ b/js/src/util/qrscan.js @@ -16,8 +16,8 @@ import Transaction from 'ethereumjs-tx'; -import { inAddress, inHex, inNumber10 } from '~/api/format/input'; -import { sha3 } from '~/api/util/sha3'; +import { inAddress, inHex, inNumber10 } from '@parity/api/format/input'; +import { sha3 } from '@parity/api/util/sha3'; export function createUnsignedTx (api, netVersion, gasStore, transaction) { const { data, from, gas, gasPrice, to, value } = gasStore.overrideTransaction(transaction); diff --git a/js/src/util/signer.js b/js/src/util/signer.js index 1194ff2514..4e5632ee33 100644 --- a/js/src/util/signer.js +++ b/js/src/util/signer.js @@ -19,8 +19,8 @@ import Transaction from 'ethereumjs-tx'; import { pbkdf2Sync } from 'crypto'; import { createDecipheriv } from 'browserify-aes'; -import { inHex } from '~/api/format/input'; -import { sha3 } from '~/api/util/sha3'; +import { inHex } from '@parity/api/format/input'; +import { sha3 } from '@parity/api/util/sha3'; // Adapted from https://github.com/kvhnuke/etherwallet/blob/mercury/app/scripts/myetherwallet.js diff --git a/js/src/util/tokens.js b/js/src/util/tokens.js index 63e6e9f02d..7372143456 100644 --- a/js/src/util/tokens.js +++ b/js/src/util/tokens.js @@ -17,9 +17,10 @@ import { range } from 'lodash'; import BigNumber from 'bignumber.js'; -import { hashToImageUrl } from '~/redux/util'; -import { sha3 } from '~/api/util/sha3'; +import { sha3 } from '@parity/api/util/sha3'; + import imagesEthereum from '~/../assets/images/contracts/ethereum-black-64x64.png'; +import { hashToImageUrl } from '~/redux/util'; const BALANCEOF_SIGNATURE = sha3('balanceOf(address)'); const ADDRESS_PADDING = range(24).map(() => '0').join(''); diff --git a/js/src/util/validation.js b/js/src/util/validation.js index e0551a3390..fb0534827a 100644 --- a/js/src/util/validation.js +++ b/js/src/util/validation.js @@ -16,7 +16,7 @@ import BigNumber from 'bignumber.js'; -import apiutil from '~/api/util'; +import apiutil from '@parity/api/util'; import { NULL_ADDRESS } from './constants'; diff --git a/js/src/util/wallets.js b/js/src/util/wallets.js index e90f4115fd..8196989531 100644 --- a/js/src/util/wallets.js +++ b/js/src/util/wallets.js @@ -18,9 +18,10 @@ import BigNumber from 'bignumber.js'; import { intersection, range, uniq } from 'lodash'; import store from 'store'; -import Abi from '~/abi'; -import Contract from '~/api/contract'; -import { bytesToHex, toHex } from '~/api/util/format'; +import Abi from '@parity/abi'; +import Contract from '@parity/api/contract'; +import { bytesToHex, toHex } from '@parity/api/util/format'; + import { validateAddress } from '~/util/validation'; import WalletAbi from '~/contracts/abi/wallet.json'; import OldWalletAbi from '~/contracts/abi/old-wallet.json'; diff --git a/js/src/views/Application/Requests/savedRequests.js b/js/src/views/Application/Requests/savedRequests.js index 54f1a7a9a6..691b63d25c 100644 --- a/js/src/views/Application/Requests/savedRequests.js +++ b/js/src/views/Application/Requests/savedRequests.js @@ -16,7 +16,7 @@ import store from 'store'; -import { ERROR_CODES } from '~/api/transport/error'; +import { ERROR_CODES } from '@parity/api/transport/error'; export const LS_REQUESTS_KEY = '_parity::requests'; diff --git a/js/src/views/Wallet/Confirmations/confirmations.js b/js/src/views/Wallet/Confirmations/confirmations.js index bea1ffd956..4cbc224a6d 100644 --- a/js/src/views/Wallet/Confirmations/confirmations.js +++ b/js/src/views/Wallet/Confirmations/confirmations.js @@ -21,8 +21,9 @@ import ReactTooltip from 'react-tooltip'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; +import { bytesToHex } from '@parity/api/util/format'; + import { confirmOperation, revokeOperation } from '~/redux/providers/walletActions'; -import { bytesToHex } from '~/api/util/format'; import { Container, InputAddress, Button, IdentityIcon } from '~/ui'; import TxRow from '~/ui/TxList/TxRow'; diff --git a/js/src/views/Wallet/Transactions/transactions.js b/js/src/views/Wallet/Transactions/transactions.js index aa1fae6727..173caab0ed 100644 --- a/js/src/views/Wallet/Transactions/transactions.js +++ b/js/src/views/Wallet/Transactions/transactions.js @@ -17,7 +17,8 @@ import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; -import { bytesToHex } from '~/api/util/format'; +import { bytesToHex } from '@parity/api/util/format'; + import { Container } from '~/ui'; import TxRow from '~/ui/TxList/TxRow'; diff --git a/js/src/views/WriteContract/writeContractStore.js b/js/src/views/WriteContract/writeContractStore.js index 8774f6ce02..b10a8e0ef7 100644 --- a/js/src/views/WriteContract/writeContractStore.js +++ b/js/src/views/WriteContract/writeContractStore.js @@ -20,7 +20,8 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; import store from 'store'; -import { sha3 } from '~/api/util/sha3'; +import { sha3 } from '@parity/api/util/sha3'; + import SolidityUtils from '~/util/solidity'; const SOLIDITY_LIST_URL = 'https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/bin/list.json'; -- GitLab From 2459501f4ee8b923474c61402df2c54e5fd17fbe Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 21 Apr 2017 13:14:07 +0200 Subject: [PATCH 014/314] Home as dapp --- .../builtin.json => config/dappsBuiltin.json} | 0 js/src/config/dappsViews.json | 13 +++++++ js/src/contracts/contracts.js | 10 ++--- js/src/dapps/chaindeploy/_dapps.js | 2 +- js/src/dapps/chaindeploy/dapps/console.js | 2 +- js/src/dapps/chaindeploy/dapps/dappreg.js | 2 +- js/src/dapps/chaindeploy/dapps/githubhint.js | 2 +- js/src/dapps/chaindeploy/dapps/localtx.js | 2 +- js/src/dapps/chaindeploy/dapps/registry.js | 2 +- .../dapps/chaindeploy/dapps/signaturereg.js | 2 +- js/src/dapps/chaindeploy/dapps/tokendeploy.js | 2 +- js/src/dapps/chaindeploy/dapps/tokenreg.js | 2 +- js/src/dapps/chaindeploy/dapps/web.js | 2 +- js/src/dapps/dappreg/dappsStore.js | 4 +- js/src/dapps/registry/actions.js | 2 +- js/src/embed.js | 2 +- js/src/index.js | 2 +- js/src/modals/Verification/store.js | 4 +- js/src/redux/middleware.js | 2 +- js/src/redux/providers/balances.js | 2 +- .../providers/certifications/middleware.js | 5 +-- .../redux/providers/chainMiddleware.spec.js | 2 +- js/src/redux/providers/registry/middleware.js | 2 +- js/src/routes.js | 10 +++-- .../Form/AddressSelect/addressSelectStore.js | 2 +- js/src/util/dapps.js | 5 ++- js/src/views/Dapps/dappsStore.js | 6 +-- js/src/views/Home/index.js | 33 ++++++++++++++++- js/src/views/Home/parity.js | 21 +++++++++++ js/src/views/Settings/Views/defaults.js | 16 -------- js/src/views/index.ejs | 37 +++++++++++++++++++ js/src/views/index.js | 1 - js/webpack/app.js | 31 +++++++++++----- js/webpack/shared.js | 19 +++++++--- 34 files changed, 176 insertions(+), 75 deletions(-) rename js/src/{views/Dapps/builtin.json => config/dappsBuiltin.json} (100%) create mode 100644 js/src/config/dappsViews.json create mode 100644 js/src/views/Home/parity.js create mode 100644 js/src/views/index.ejs diff --git a/js/src/views/Dapps/builtin.json b/js/src/config/dappsBuiltin.json similarity index 100% rename from js/src/views/Dapps/builtin.json rename to js/src/config/dappsBuiltin.json diff --git a/js/src/config/dappsViews.json b/js/src/config/dappsViews.json new file mode 100644 index 0000000000..bd88e26ca9 --- /dev/null +++ b/js/src/config/dappsViews.json @@ -0,0 +1,13 @@ +[ + { + "id": "viewHome", + "url": "viewHome", + "src": "Home", + "name": "Home", + "description": "Display a status of the node, recently accessed applications, accounts and news", + "author": "Parity Team ", + "version": "2.0.0", + "visible": true, + "secure": true + } +] diff --git a/js/src/contracts/contracts.js b/js/src/contracts/contracts.js index 59b3bccfc3..4935ce8cf8 100644 --- a/js/src/contracts/contracts.js +++ b/js/src/contracts/contracts.js @@ -69,15 +69,11 @@ export default class Contracts { return verification; } - static create (api) { - if (instance) { - return instance; + static get (api) { + if (!instance) { + instance = new Contracts(api); } - return new Contracts(api); - } - - static get () { return instance; } } diff --git a/js/src/dapps/chaindeploy/_dapps.js b/js/src/dapps/chaindeploy/_dapps.js index 4a8da242f6..e9eaa83a83 100644 --- a/js/src/dapps/chaindeploy/_dapps.js +++ b/js/src/dapps/chaindeploy/_dapps.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtinsJson from '~/views/Dapps/builtin.json'; +import builtinsJson from '~/config/dappsBuiltin.json'; const REGISTER_URLS = { console: 'https://raw.githubusercontent.com/paritytech/console/3ea0dbfefded359ccdbea37bc4cf350c0aa16948/console.jpeg', diff --git a/js/src/dapps/chaindeploy/dapps/console.js b/js/src/dapps/chaindeploy/dapps/console.js index 4e599b2faa..bc9cc7d43b 100644 --- a/js/src/dapps/chaindeploy/dapps/console.js +++ b/js/src/dapps/chaindeploy/dapps/console.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'console'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/chaindeploy/dapps/dappreg.js b/js/src/dapps/chaindeploy/dapps/dappreg.js index fec35ef763..c3939015aa 100644 --- a/js/src/dapps/chaindeploy/dapps/dappreg.js +++ b/js/src/dapps/chaindeploy/dapps/dappreg.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'dappreg'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/chaindeploy/dapps/githubhint.js b/js/src/dapps/chaindeploy/dapps/githubhint.js index 49fb4be9cd..8a6b75d124 100644 --- a/js/src/dapps/chaindeploy/dapps/githubhint.js +++ b/js/src/dapps/chaindeploy/dapps/githubhint.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'githubhint'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/chaindeploy/dapps/localtx.js b/js/src/dapps/chaindeploy/dapps/localtx.js index 6fc275a134..61f1f142d8 100644 --- a/js/src/dapps/chaindeploy/dapps/localtx.js +++ b/js/src/dapps/chaindeploy/dapps/localtx.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'localtx'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/chaindeploy/dapps/registry.js b/js/src/dapps/chaindeploy/dapps/registry.js index 49ff4757bb..5a28e36041 100644 --- a/js/src/dapps/chaindeploy/dapps/registry.js +++ b/js/src/dapps/chaindeploy/dapps/registry.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'registry'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/chaindeploy/dapps/signaturereg.js b/js/src/dapps/chaindeploy/dapps/signaturereg.js index 12efcff362..acf939d725 100644 --- a/js/src/dapps/chaindeploy/dapps/signaturereg.js +++ b/js/src/dapps/chaindeploy/dapps/signaturereg.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'signaturereg'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/chaindeploy/dapps/tokendeploy.js b/js/src/dapps/chaindeploy/dapps/tokendeploy.js index 43ea8f22b0..592e94c2ec 100644 --- a/js/src/dapps/chaindeploy/dapps/tokendeploy.js +++ b/js/src/dapps/chaindeploy/dapps/tokendeploy.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'tokendeploy'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/chaindeploy/dapps/tokenreg.js b/js/src/dapps/chaindeploy/dapps/tokenreg.js index 784febba05..d8d81cd156 100644 --- a/js/src/dapps/chaindeploy/dapps/tokenreg.js +++ b/js/src/dapps/chaindeploy/dapps/tokenreg.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'tokenreg'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/chaindeploy/dapps/web.js b/js/src/dapps/chaindeploy/dapps/web.js index 0726e2bf71..7fb6da5e00 100644 --- a/js/src/dapps/chaindeploy/dapps/web.js +++ b/js/src/dapps/chaindeploy/dapps/web.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import builtins from '~/views/Dapps/builtin.json'; +import builtins from '~/config/dappsBuiltin.json'; const id = 'web'; const app = builtins.find((app) => app.url === id); diff --git a/js/src/dapps/dappreg/dappsStore.js b/js/src/dapps/dappreg/dappsStore.js index c6f45922a8..20941e2296 100644 --- a/js/src/dapps/dappreg/dappsStore.js +++ b/js/src/dapps/dappreg/dappsStore.js @@ -20,7 +20,7 @@ import { flatten } from 'lodash'; import * as abis from '~/contracts/abi'; import Contracts from '~/contracts'; -import builtinJson from '~/views/Dapps/builtin.json'; +import builtinJson from '~/config/dappsBuiltin.json'; import Dapp from './dappStore.js'; import { deleteDapp, registerDapp, updateDapp } from './utils'; @@ -489,7 +489,7 @@ export default class DappsStore { } _loadRegistry () { - return Contracts.create(api).registry + return Contracts.get(api).registry .fetchContract() .then((contract) => { this._registry = contract.instance; diff --git a/js/src/dapps/registry/actions.js b/js/src/dapps/registry/actions.js index 8c77743976..ddb0b04b16 100644 --- a/js/src/dapps/registry/actions.js +++ b/js/src/dapps/registry/actions.js @@ -44,7 +44,7 @@ export const fetchIsTestnet = () => (dispatch) => export const setContract = (contract) => ({ type: 'set contract', contract }); export const fetchContract = () => (dispatch) => { - return Contracts.create(api).registry + return Contracts.get(api).registry .fetchContract() .then((contract) => { dispatch(setContract(contract)); diff --git a/js/src/embed.js b/js/src/embed.js index 75cb5e45ad..4e7f8d6ed2 100644 --- a/js/src/embed.js +++ b/js/src/embed.js @@ -92,7 +92,7 @@ class FrameSecureApi extends SecureApi { const api = new FrameSecureApi(window.secureTransport || new FakeTransport()); patchApi(api); -ContractInstances.create(api); +ContractInstances.get(api); const store = initStore(api, null, true); diff --git a/js/src/index.js b/js/src/index.js index 28abe953b8..602ccb1bbf 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -66,7 +66,7 @@ if (window.location.hash && window.location.hash.indexOf(AUTH_HASH) === 0) { const api = new SecureApi(`${urlScheme}${parityUrl}`, token); patchApi(api); -ContractInstances.create(api); +ContractInstances.get(api); const store = initStore(api, hashHistory); diff --git a/js/src/modals/Verification/store.js b/js/src/modals/Verification/store.js index a4102cc7d5..b3c375dccc 100644 --- a/js/src/modals/Verification/store.js +++ b/js/src/modals/Verification/store.js @@ -51,12 +51,12 @@ export default class VerificationStore { @observable confirmationTx = null; constructor (api, abi, certifierName, account, isTestnet) { - this.api = api; + this._api = api; this.account = account; this.isTestnet = isTestnet; this.step = LOADING; - Contracts.get().badgeReg.fetchCertifierByName(certifierName) + Contracts.get(this._api).badgeReg.fetchCertifierByName(certifierName) .then(({ address }) => { this.contract = new Contract(api, abi).at(address); this.load(); diff --git a/js/src/redux/middleware.js b/js/src/redux/middleware.js index 9cc413dc02..691a8ecd1d 100644 --- a/js/src/redux/middleware.js +++ b/js/src/redux/middleware.js @@ -37,7 +37,7 @@ export default function (api, browserHistory, forEmbed = false) { ]; if (!forEmbed) { - const certifications = new CertificationsMiddleware().toMiddleware(); + const certifications = new CertificationsMiddleware().toMiddleware(api); const registry = new RegistryMiddleware(api); middleware.push(certifications, registry); diff --git a/js/src/redux/providers/balances.js b/js/src/redux/providers/balances.js index 34c0bb4137..a07385c205 100644 --- a/js/src/redux/providers/balances.js +++ b/js/src/redux/providers/balances.js @@ -270,7 +270,7 @@ export default class Balances { } getTokenRegistry () { - return Contracts.get().tokenReg.getContract(); + return Contracts.get(this._api).tokenReg.getContract(); } _loadTokens (options = {}) { diff --git a/js/src/redux/providers/certifications/middleware.js b/js/src/redux/providers/certifications/middleware.js index bf4729ae70..b494b75d2a 100644 --- a/js/src/redux/providers/certifications/middleware.js +++ b/js/src/redux/providers/certifications/middleware.js @@ -59,9 +59,8 @@ const updatableFilter = (api, onFilter) => { }; export default class CertificationsMiddleware { - toMiddleware () { - const api = Contracts.get()._api; - const badgeReg = Contracts.get().badgeReg; + toMiddleware (api) { + const badgeReg = Contracts.get(api).badgeReg; const contract = new Contract(api, CertifierABI); const Confirmed = contract.events.find((e) => e.name === 'Confirmed'); diff --git a/js/src/redux/providers/chainMiddleware.spec.js b/js/src/redux/providers/chainMiddleware.spec.js index 837031c29f..fcd4c47444 100644 --- a/js/src/redux/providers/chainMiddleware.spec.js +++ b/js/src/redux/providers/chainMiddleware.spec.js @@ -28,7 +28,7 @@ let clock; const api = createWsApi(); -Contracts.create(api); +Contracts.get(api); function stubGlobals () { clock = sinon.useFakeTimers(); diff --git a/js/src/redux/providers/registry/middleware.js b/js/src/redux/providers/registry/middleware.js index c6c961765f..ce13620634 100644 --- a/js/src/redux/providers/registry/middleware.js +++ b/js/src/redux/providers/registry/middleware.js @@ -90,7 +90,7 @@ export default (api) => (store) => { break; case 'startCachingReverses': - const { registry } = Contracts.get(); + const { registry } = Contracts.get(api); const cached = read(store.getState().nodeStatus.netChain); if (cached) { diff --git a/js/src/routes.js b/js/src/routes.js index 72097ae627..abafdef4b5 100644 --- a/js/src/routes.js +++ b/js/src/routes.js @@ -17,12 +17,15 @@ import HistoryStore from '~/mobx/historyStore'; import { Accounts, Account, Addresses, Address, Application, - Contract, Contracts, Dapp, Dapps, Home, + Contract, Contracts, Dapp, Dapps, Settings, SettingsBackground, SettingsParity, SettingsProxy, SettingsViews, Signer, Status, Vaults, Wallet, Web, WriteContract } from '~/views'; -import builtinDapps from '~/views/Dapps/builtin.json'; +import builtinDapps from '~/config/dappsBuiltin.json'; +import viewsDapps from '~/config/dappsViews.json'; + +const dapps = [].concat(viewsDapps, builtinDapps); const accountsHistory = HistoryStore.get('accounts'); const dappsHistory = HistoryStore.get('dapps'); @@ -129,13 +132,12 @@ const childRoutes = [ path: 'app/:id', component: Dapp, onEnter: ({ params }) => { - if (!builtinDapps[params.id] || !builtinDapps[params.id].skipHistory) { + if (!dapps[params.id] || !dapps[params.id].skipHistory) { dappsHistory.add(params.id); } } }, { path: 'apps', component: Dapps }, - { path: 'home', component: Home }, { path: 'web', component: Web }, { path: 'web/:url', component: Web }, { path: 'signer', component: Signer } diff --git a/js/src/ui/Form/AddressSelect/addressSelectStore.js b/js/src/ui/Form/AddressSelect/addressSelectStore.js index ecf6a8db7a..24cdf7c9f0 100644 --- a/js/src/ui/Form/AddressSelect/addressSelectStore.js +++ b/js/src/ui/Form/AddressSelect/addressSelectStore.js @@ -78,7 +78,7 @@ export default class AddressSelectStore { constructor (api) { this.api = api; - const { registry } = Contracts.create(api); + const { registry } = Contracts.get(api); registry .getContract('emailverification') diff --git a/js/src/util/dapps.js b/js/src/util/dapps.js index 75363a4c04..975a4fe2f3 100644 --- a/js/src/util/dapps.js +++ b/js/src/util/dapps.js @@ -22,9 +22,10 @@ import { bytesToHex } from '@parity/api/util/format'; import Contracts from '~/contracts'; import { hashToImageUrl } from '~/redux/util'; -import builtinJson from '~/views/Dapps/builtin.json'; +import builtinJson from '~/config/dappsBuiltin.json'; +import viewsJson from '~/config/dappsViews.json'; -const builtinApps = builtinJson.filter((app) => app.id); +const builtinApps = [].concat(viewsJson, builtinJson).filter((app) => app.id); function getHost (api) { const host = process.env.DAPPS_URL || diff --git a/js/src/views/Dapps/dappsStore.js b/js/src/views/Dapps/dappsStore.js index b0570dc8f3..cb759d6a8c 100644 --- a/js/src/views/Dapps/dappsStore.js +++ b/js/src/views/Dapps/dappsStore.js @@ -66,7 +66,7 @@ export default class DappsStore extends EventEmitter { * apps, else fetch from the node */ loadApp (id) { - const { dappReg } = Contracts.get(); + const { dappReg } = Contracts.get(this._api); return this .loadLocalApps() @@ -94,7 +94,7 @@ export default class DappsStore extends EventEmitter { } loadAllApps () { - const { dappReg } = Contracts.get(); + const { dappReg } = Contracts.get(this._api); return Promise .all([ @@ -105,7 +105,7 @@ export default class DappsStore extends EventEmitter { } subscribeToChanges () { - const { dappReg } = Contracts.get(); + const { dappReg } = Contracts.get(this._api); // Unsubscribe from previous subscriptions, if any if (this._subscriptions.block) { diff --git a/js/src/views/Home/index.js b/js/src/views/Home/index.js index 12e31704a7..2b3efbfa7c 100644 --- a/js/src/views/Home/index.js +++ b/js/src/views/Home/index.js @@ -14,4 +14,35 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -export default from './home'; +import ReactDOM from 'react-dom'; +import React from 'react'; +import { hashHistory } from 'react-router'; + +import injectTapEventPlugin from 'react-tap-event-plugin'; +injectTapEventPlugin(); + +import { api } from './parity'; + +import { initStore } from '~/redux'; +import { setApi } from '~/redux/providers/apiActions'; +import ContextProvider from '~/ui/ContextProvider'; +import muiTheme from '~/ui/Theme'; + +import Home from './home'; + +import '~/../assets/fonts/Roboto/font.css'; +import '~/../assets/fonts/RobotoMono/font.css'; + +import './home.css'; + +const store = initStore(api, hashHistory); + +store.dispatch({ type: 'initAll', api }); +store.dispatch(setApi(api)); + +ReactDOM.render( + + + , + document.querySelector('#container') +); diff --git a/js/src/views/Home/parity.js b/js/src/views/Home/parity.js new file mode 100644 index 0000000000..7118ce0878 --- /dev/null +++ b/js/src/views/Home/parity.js @@ -0,0 +1,21 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +const api = window.parent.secureApi; + +export { + api +}; diff --git a/js/src/views/Settings/Views/defaults.js b/js/src/views/Settings/Views/defaults.js index c7a6bbce86..96afaa177f 100644 --- a/js/src/views/Settings/Views/defaults.js +++ b/js/src/views/Settings/Views/defaults.js @@ -16,25 +16,9 @@ import React from 'react'; -import imagesEthcoreBlock from '~/../assets/images/parity-logo-white-no-text.svg'; import { AccountsIcon, AddressesIcon, AppsIcon, ContactsIcon, FingerprintIcon, SettingsIcon, StatusIcon } from '~/ui/Icons'; -import styles from './views.css'; - const defaultViews = { - home: { - active: true, - fixed: true, - icon: ( - - ), - route: '/home', - value: 'home' - }, - accounts: { active: true, fixed: true, diff --git a/js/src/views/index.ejs b/js/src/views/index.ejs new file mode 100644 index 0000000000..aab652fa66 --- /dev/null +++ b/js/src/views/index.ejs @@ -0,0 +1,37 @@ + + + + + + + <%= htmlWebpackPlugin.options.title %> + + + +
+
Loading
+
+ + <% if (!htmlWebpackPlugin.options.secure) { %> + + <% } %> + + diff --git a/js/src/views/index.js b/js/src/views/index.js index 7460868ae2..c4f524835f 100644 --- a/js/src/views/index.js +++ b/js/src/views/index.js @@ -23,7 +23,6 @@ export Contract from './Contract'; export Contracts from './Contracts'; export Dapp from './Dapp'; export Dapps from './Dapps'; -export Home from './Home'; export ParityBar from './ParityBar'; export Settings, { SettingsBackground, SettingsParity, SettingsProxy, SettingsViews } from './Settings'; export Signer from './Signer'; diff --git a/js/webpack/app.js b/js/webpack/app.js index ba8e9a7650..5f6a2c4818 100644 --- a/js/webpack/app.js +++ b/js/webpack/app.js @@ -28,7 +28,15 @@ const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin'); const rulesEs6 = require('./rules/es6'); const rulesParity = require('./rules/parity'); const Shared = require('./shared'); -const DAPPS = require('../src/views/Dapps/builtin.json'); + +const DAPPS_BUILTIN = require('../src/config/dappsBuiltin.json').map((dapp) => { + dapp.srcPath = './dapps'; + return dapp; +}); +const DAPPS_VIEWS = require('../src/config/dappsViews.json').map((dapp) => { + dapp.srcPath = './views'; + return dapp; +}); const FAVICON = path.resolve(__dirname, '../assets/images/parity-logo-black-no-text.png'); @@ -149,16 +157,19 @@ module.exports = { }, plugins: (function () { - const DappsHTMLInjection = DAPPS.filter((dapp) => !dapp.skipBuild).map((dapp) => { - return new HtmlWebpackPlugin({ - title: dapp.name, - filename: dapp.url + '.html', - template: './dapps/index.ejs', - favicon: FAVICON, - secure: dapp.secure, - chunks: [ isProd ? null : 'commons', dapp.url ] + const DappsHTMLInjection = [] + .concat(DAPPS_BUILTIN, DAPPS_VIEWS) + .filter((dapp) => !dapp.skipBuild) + .map((dapp) => { + return new HtmlWebpackPlugin({ + title: dapp.name, + filename: dapp.url + '.html', + template: dapp.srcPath + '/index.ejs', + favicon: FAVICON, + secure: dapp.secure, + chunks: [ isProd ? null : 'commons', dapp.url ] + }); }); - }); let plugins = Shared.getPlugins().concat( new WebpackErrorNotificationPlugin() diff --git a/js/webpack/shared.js b/js/webpack/shared.js index 3e2eef8f12..ae39d37da2 100644 --- a/js/webpack/shared.js +++ b/js/webpack/shared.js @@ -151,12 +151,19 @@ function getPlugins (_isProd = isProd) { } function getDappsEntry () { - const DAPPS = require('../src/views/Dapps/builtin.json'); - - return DAPPS.filter((dapp) => !dapp.skipBuild).reduce((_entry, dapp) => { - _entry[dapp.url] = './dapps/' + dapp.url + '.js'; - return _entry; - }, {}); + const builtins = require('../src/config/dappsBuiltin.json'); + const views = require('../src/config/dappsViews.json'); + + return Object.assign( + builtins.filter((dapp) => !dapp.skipBuild).reduce((_entry, dapp) => { + _entry[dapp.url] = './dapps/' + dapp.url + '.js'; + return _entry; + }, {}), + views.reduce((_entry, dapp) => { + _entry[dapp.url] = './views/' + dapp.src + '/index.js'; + return _entry; + }, {}) + ); } function addProxies (app) { -- GitLab From 5fc6a5627e85124932b0a7fa18cc1db3f4798b0a Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 21 Apr 2017 15:20:43 +0200 Subject: [PATCH 015/314] First iteration of Status page (WIP) --- js/src/config/dappsViews.json | 15 ++++++-- js/src/index.js | 4 --- js/src/redux/providers/personalActions.js | 2 ++ js/src/redux/providers/registry/middleware.js | 9 ++--- js/src/redux/providers/tokensActions.js | 5 +-- js/src/redux/store.js | 8 ++++- js/src/routes.js | 15 ++------ js/src/ui/ContextProvider/contextProvider.js | 2 +- .../ui/MethodDecoding/methodDecodingStore.js | 2 +- js/src/util/dapps.js | 8 ++--- js/src/views/Dapps/dappsStore.js | 4 +-- js/src/views/Home/News/news.js | 8 +++-- js/src/views/Home/News/store.js | 10 ++++-- js/src/views/Home/Urls/urls.js | 4 --- js/src/views/Home/index.js | 4 --- js/src/views/Settings/Views/defaults.js | 9 +---- js/src/views/Settings/Views/views.js | 11 ------ .../Status/MiningSettings/miningSettings.js | 2 +- js/src/views/Status/index.js | 32 ++++++++++++++++- js/src/views/Status/parity.js | 21 ++++++++++++ js/src/views/Status/status.js | 34 ++++++++++--------- js/src/views/index.js | 1 - js/webpack/app.js | 3 +- js/webpack/rules/parity.js | 2 +- 24 files changed, 126 insertions(+), 89 deletions(-) create mode 100644 js/src/views/Status/parity.js diff --git a/js/src/config/dappsViews.json b/js/src/config/dappsViews.json index bd88e26ca9..eb587d106d 100644 --- a/js/src/config/dappsViews.json +++ b/js/src/config/dappsViews.json @@ -1,7 +1,7 @@ [ { - "id": "viewHome", - "url": "viewHome", + "id": "home", + "url": "home", "src": "Home", "name": "Home", "description": "Display a status of the node, recently accessed applications, accounts and news", @@ -9,5 +9,16 @@ "version": "2.0.0", "visible": true, "secure": true + }, + { + "id": "status", + "url": "status", + "src": "Status", + "name": "Status", + "description": "Display an overview of the node including settings, logs and connections", + "author": "Parity Team ", + "version": "2.0.0", + "visible": true, + "secure": true } ] diff --git a/js/src/index.js b/js/src/index.js index 602ccb1bbf..1ac4b5e84b 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -37,7 +37,6 @@ import muiTheme from '~/ui/Theme'; import MainApplication from './main'; import { patchApi } from '~/util/tx'; -import { setApi } from '~/redux/providers/apiActions'; import './environment'; @@ -70,9 +69,6 @@ ContractInstances.get(api); const store = initStore(api, hashHistory); -store.dispatch({ type: 'initAll', api }); -store.dispatch(setApi(api)); - window.secureApi = api; ReactDOM.render( diff --git a/js/src/redux/providers/personalActions.js b/js/src/redux/providers/personalActions.js index 62d32048d7..a5cc6e485d 100644 --- a/js/src/redux/providers/personalActions.js +++ b/js/src/redux/providers/personalActions.js @@ -63,6 +63,8 @@ export function personalAccountsInfo (accountsInfo) { return (dispatch, getState) => { const { api } = getState(); + console.log('_fetchOwners', api); + const _fetchOwners = Object .values(wallets) .map((wallet) => { diff --git a/js/src/redux/providers/registry/middleware.js b/js/src/redux/providers/registry/middleware.js index ce13620634..8d48d5cd76 100644 --- a/js/src/redux/providers/registry/middleware.js +++ b/js/src/redux/providers/registry/middleware.js @@ -21,7 +21,7 @@ import subscribeToEvents from '~/util/subscribe-to-events'; import registryABI from '~/contracts/abi/registry.json'; -import { setReverse, startCachingReverses } from './actions'; +import { setReverse } from './actions'; const STORE_KEY = '_parity::reverses'; @@ -83,12 +83,6 @@ export default (api) => (store) => { return (next) => (action) => { switch (action.type) { - case 'initAll': - next(action); - store.dispatch(startCachingReverses()); - - break; - case 'startCachingReverses': const { registry } = Contracts.get(api); const cached = read(store.getState().nodeStatus.netChain); @@ -120,6 +114,7 @@ export default (api) => (store) => { }); break; + case 'stopCachingReverses': if (subscription) { subscription.unsubscribe(); diff --git a/js/src/redux/providers/tokensActions.js b/js/src/redux/providers/tokensActions.js index 6f902882d5..e20b98832f 100644 --- a/js/src/redux/providers/tokensActions.js +++ b/js/src/redux/providers/tokensActions.js @@ -36,7 +36,8 @@ export function loadTokens (options = {}) { log.debug('loading tokens', Object.keys(options).length ? options : ''); return (dispatch, getState) => { - const { tokenReg } = Contracts.get(); + const { api } = getState(); + const { tokenReg } = Contracts.get(api); tokenReg.getInstance() .then((tokenRegInstance) => { @@ -54,7 +55,7 @@ export function fetchTokens (_tokenIndexes, options = {}) { return (dispatch, getState) => { const { api, images } = getState(); - const { tokenReg } = Contracts.get(); + const { tokenReg } = Contracts.get(api); return tokenReg.getInstance() .then((tokenRegInstance) => { diff --git a/js/src/redux/store.js b/js/src/redux/store.js index 5740cb6188..ab4f2c881f 100644 --- a/js/src/redux/store.js +++ b/js/src/redux/store.js @@ -19,8 +19,10 @@ import { applyMiddleware, createStore } from 'redux'; import initMiddleware from './middleware'; import initReducers from './reducers'; -import { load as loadWallet } from './providers/walletActions'; +import { setApi } from './providers/apiActions'; +import { startCachingReverses } from './providers/registry/actions'; import { init as initRequests } from './providers/requestsActions'; +import { load as loadWallet } from './providers/walletActions'; import { setupWorker } from './providers/workerWrapper'; import { @@ -44,8 +46,12 @@ export default function (api, browserHistory, forEmbed = false) { new PersonalProvider(store, api).start(); new SignerProvider(store, api).start(); + store.dispatch(setApi(api)); + + store.dispatch(startCachingReverses()); store.dispatch(loadWallet(api)); store.dispatch(initRequests(api)); + setupWorker(store); return store; diff --git a/js/src/routes.js b/js/src/routes.js index abafdef4b5..0f7aacc47c 100644 --- a/js/src/routes.js +++ b/js/src/routes.js @@ -19,7 +19,7 @@ import { Accounts, Account, Addresses, Address, Application, Contract, Contracts, Dapp, Dapps, Settings, SettingsBackground, SettingsParity, SettingsProxy, - SettingsViews, Signer, Status, + SettingsViews, Signer, Vaults, Wallet, Web, WriteContract } from '~/views'; import builtinDapps from '~/config/dappsBuiltin.json'; @@ -87,18 +87,14 @@ const settingsRoutes = [ { path: 'parity', component: SettingsParity } ]; -const statusRoutes = [ - { path: ':subpage', component: Status } -]; - const routes = [ // Backward Compatible routes { path: '/account/:address', onEnter: handleDeprecatedRoute }, { path: '/address/:address', onEnter: handleDeprecatedRoute }, { path: '/contract/:address', onEnter: handleDeprecatedRoute }, - { path: '/', onEnter: redirectTo('/home') }, - { path: '/auth', onEnter: redirectTo('/home') }, + { path: '/', onEnter: redirectTo('/apps') }, + { path: '/auth', onEnter: redirectTo('/apps') }, { path: '/settings', onEnter: redirectTo('/settings/views') } ]; @@ -118,11 +114,6 @@ const childRoutes = [ indexRoute: { component: Contracts }, childRoutes: contractsRoutes }, - { - path: 'status', - indexRoute: { component: Status }, - childRoutes: statusRoutes - }, { path: 'settings', component: Settings, diff --git a/js/src/ui/ContextProvider/contextProvider.js b/js/src/ui/ContextProvider/contextProvider.js index 9d8efea929..1666a30bea 100644 --- a/js/src/ui/ContextProvider/contextProvider.js +++ b/js/src/ui/ContextProvider/contextProvider.js @@ -25,7 +25,7 @@ export default class ContextProvider extends Component { static propTypes = { api: PropTypes.object.isRequired, muiTheme: PropTypes.object.isRequired, - store: PropTypes.object.isRequired, + store: PropTypes.object, children: PropTypes.node.isRequired } diff --git a/js/src/ui/MethodDecoding/methodDecodingStore.js b/js/src/ui/MethodDecoding/methodDecodingStore.js index 9f2c651f5a..d16f334396 100644 --- a/js/src/ui/MethodDecoding/methodDecodingStore.js +++ b/js/src/ui/MethodDecoding/methodDecodingStore.js @@ -278,7 +278,7 @@ export default class MethodDecodingStore { return Promise.resolve(this._methods[signature]); } - this._methods[signature] = Contracts.get() + this._methods[signature] = Contracts.get(this.api) .signatureReg .lookup(signature) .then((method) => { diff --git a/js/src/util/dapps.js b/js/src/util/dapps.js index 975a4fe2f3..0eb49135f6 100644 --- a/js/src/util/dapps.js +++ b/js/src/util/dapps.js @@ -89,8 +89,8 @@ export function subscribeToChanges (api, dappReg, callback) { }); } -export function fetchBuiltinApps () { - const { dappReg } = Contracts.get(); +export function fetchBuiltinApps (api) { + const { dappReg } = Contracts.get(api); return Promise .all(builtinApps.map((app) => dappReg.getImage(app.id))) @@ -127,8 +127,8 @@ export function fetchLocalApps (api) { }); } -export function fetchRegistryAppIds () { - const { dappReg } = Contracts.get(); +export function fetchRegistryAppIds (api) { + const { dappReg } = Contracts.get(api); return dappReg .count() diff --git a/js/src/views/Dapps/dappsStore.js b/js/src/views/Dapps/dappsStore.js index cb759d6a8c..47bdb89e96 100644 --- a/js/src/views/Dapps/dappsStore.js +++ b/js/src/views/Dapps/dappsStore.js @@ -137,7 +137,7 @@ export default class DappsStore extends EventEmitter { return Promise.resolve(this._cachedApps[BUILTIN_APPS_KEY]); } - this._cachedApps[BUILTIN_APPS_KEY] = fetchBuiltinApps() + this._cachedApps[BUILTIN_APPS_KEY] = fetchBuiltinApps(this._api) .then((apps) => { this._cachedApps[BUILTIN_APPS_KEY] = apps; return apps; @@ -155,7 +155,7 @@ export default class DappsStore extends EventEmitter { return Promise.resolve(this._registryAppsIds); } - this._registryAppsIds = fetchRegistryAppIds() + this._registryAppsIds = fetchRegistryAppIds(this._api) .then((appIds) => { this._registryAppsIds = appIds; return this._registryAppsIds; diff --git a/js/src/views/Home/News/news.js b/js/src/views/Home/News/news.js index 8af395a6b7..ea540c3f3d 100644 --- a/js/src/views/Home/News/news.js +++ b/js/src/views/Home/News/news.js @@ -15,7 +15,7 @@ // along with Parity. If not, see . import { observer } from 'mobx-react'; -import React, { Component } from 'react'; +import React, { Component, PropTypes } from 'react'; import ReactMarkdown from 'react-markdown'; import { SectionList } from '~/ui'; @@ -28,7 +28,11 @@ const VERSION_ID = '1'; @observer export default class News extends Component { - store = Store.get(); + static contextTypes = { + api: PropTypes.object.isRequired + }; + + store = Store.get(this.context.api); componentWillMount () { return this.store.retrieveNews(VERSION_ID); diff --git a/js/src/views/Home/News/store.js b/js/src/views/Home/News/store.js index dd07d3b80b..cf46227ae5 100644 --- a/js/src/views/Home/News/store.js +++ b/js/src/views/Home/News/store.js @@ -22,12 +22,16 @@ let instance = null; export default class Store { @observable newsItems = null; + constructor (api) { + this._api = api; + } + @action setNewsItems = (newsItems) => { this.newsItems = newsItems; } retrieveNews (versionId) { - const contracts = Contracts.get(); + const contracts = Contracts.get(this._api); return contracts.registry .lookupMeta('paritynews', 'CONTENT') @@ -57,9 +61,9 @@ export default class Store { }); } - static get () { + static get (api) { if (!instance) { - instance = new Store(); + instance = new Store(api); } return instance; diff --git a/js/src/views/Home/Urls/urls.js b/js/src/views/Home/Urls/urls.js index 7ded1ecdaf..3b38be6371 100644 --- a/js/src/views/Home/Urls/urls.js +++ b/js/src/views/Home/Urls/urls.js @@ -26,10 +26,6 @@ import styles from './urls.css'; @observer export default class Urls extends Component { - static contextTypes = { - router: PropTypes.object.isRequired - }; - static propTypes = { extensionStore: PropTypes.object.isRequired, store: PropTypes.object.isRequired diff --git a/js/src/views/Home/index.js b/js/src/views/Home/index.js index 2b3efbfa7c..aed8a06e45 100644 --- a/js/src/views/Home/index.js +++ b/js/src/views/Home/index.js @@ -24,7 +24,6 @@ injectTapEventPlugin(); import { api } from './parity'; import { initStore } from '~/redux'; -import { setApi } from '~/redux/providers/apiActions'; import ContextProvider from '~/ui/ContextProvider'; import muiTheme from '~/ui/Theme'; @@ -37,9 +36,6 @@ import './home.css'; const store = initStore(api, hashHistory); -store.dispatch({ type: 'initAll', api }); -store.dispatch(setApi(api)); - ReactDOM.render( diff --git a/js/src/views/Settings/Views/defaults.js b/js/src/views/Settings/Views/defaults.js index 96afaa177f..e3761ba698 100644 --- a/js/src/views/Settings/Views/defaults.js +++ b/js/src/views/Settings/Views/defaults.js @@ -16,7 +16,7 @@ import React from 'react'; -import { AccountsIcon, AddressesIcon, AppsIcon, ContactsIcon, FingerprintIcon, SettingsIcon, StatusIcon } from '~/ui/Icons'; +import { AccountsIcon, AddressesIcon, AppsIcon, ContactsIcon, FingerprintIcon, SettingsIcon } from '~/ui/Icons'; const defaultViews = { accounts: { @@ -48,13 +48,6 @@ const defaultViews = { value: 'contract' }, - status: { - active: false, - icon: , - route: '/status', - value: 'status' - }, - signer: { active: true, fixed: true, diff --git a/js/src/views/Settings/Views/views.js b/js/src/views/Settings/Views/views.js index 42a21c9ea9..160926b217 100644 --- a/js/src/views/Settings/Views/views.js +++ b/js/src/views/Settings/Views/views.js @@ -112,17 +112,6 @@ class Views extends Component { /> ) } - { - this.renderView('status', - , - - ) - } { this.renderView('signer', +
. -export default from './status'; +import ReactDOM from 'react-dom'; +import React from 'react'; +import { hashHistory } from 'react-router'; + +import injectTapEventPlugin from 'react-tap-event-plugin'; +injectTapEventPlugin(); + +import { api } from './parity'; + +import ContractInstances from '~/contracts'; +import { initStore } from '~/redux'; +import ContextProvider from '~/ui/ContextProvider'; +import muiTheme from '~/ui/Theme'; + +import Status from './status'; + +import '~/../assets/fonts/Roboto/font.css'; +import '~/../assets/fonts/RobotoMono/font.css'; + +import './status.css'; + +ContractInstances.get(api); + +const store = initStore(api, hashHistory); + +ReactDOM.render( + + + , + document.querySelector('#container') +); diff --git a/js/src/views/Status/parity.js b/js/src/views/Status/parity.js new file mode 100644 index 0000000000..7118ce0878 --- /dev/null +++ b/js/src/views/Status/parity.js @@ -0,0 +1,21 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +const api = window.parent.secureApi; + +export { + api +}; diff --git a/js/src/views/Status/status.js b/js/src/views/Status/status.js index b1892631e7..45e736b3a3 100644 --- a/js/src/views/Status/status.js +++ b/js/src/views/Status/status.js @@ -25,19 +25,21 @@ import NodeStatus from './NodeStatus'; import styles from './status.css'; -export default () => ( - - } - > -
- - - -
-
-); +export default function Status () { + return ( + + } + > +
+ + + +
+
+ ); +} diff --git a/js/src/views/index.js b/js/src/views/index.js index c4f524835f..a50bd1d207 100644 --- a/js/src/views/index.js +++ b/js/src/views/index.js @@ -26,7 +26,6 @@ export Dapps from './Dapps'; export ParityBar from './ParityBar'; export Settings, { SettingsBackground, SettingsParity, SettingsProxy, SettingsViews } from './Settings'; export Signer from './Signer'; -export Status from './Status'; export Vaults from './Vaults'; export Wallet from './Wallet'; export Web from './Web'; diff --git a/js/webpack/app.js b/js/webpack/app.js index 5f6a2c4818..88e2366dfe 100644 --- a/js/webpack/app.js +++ b/js/webpack/app.js @@ -35,6 +35,7 @@ const DAPPS_BUILTIN = require('../src/config/dappsBuiltin.json').map((dapp) => { }); const DAPPS_VIEWS = require('../src/config/dappsViews.json').map((dapp) => { dapp.srcPath = './views'; + dapp.commons = true; return dapp; }); @@ -167,7 +168,7 @@ module.exports = { template: dapp.srcPath + '/index.ejs', favicon: FAVICON, secure: dapp.secure, - chunks: [ isProd ? null : 'commons', dapp.url ] + chunks: [ !isProd || dapp.commons ? 'commons' : null, dapp.url ] }); }); diff --git a/js/webpack/rules/parity.js b/js/webpack/rules/parity.js index 6897b218e9..34ec314196 100644 --- a/js/webpack/rules/parity.js +++ b/js/webpack/rules/parity.js @@ -16,6 +16,6 @@ module.exports = { test: /\.js$/, - include: /node_modules\/@parity\/(abi|api|jsonrpc|wordlist)/, + include: /node_modules\/@parity\/(abi|api|jsonrpc|ui|wordlist)/, use: 'babel-loader' }; -- GitLab From c044534d6a4246298ecc789b10ca913443ff025a Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 21 Apr 2017 16:03:50 +0200 Subject: [PATCH 016/314] Allow status updates on 2nd API instance --- js/src/redux/providers/apiReducer.js | 2 +- js/src/redux/providers/personalActions.js | 2 -- js/src/redux/providers/status.js | 4 ++++ js/src/redux/store.js | 4 ++-- js/src/views/Home/package.json | 19 +++++++++++++++++++ js/src/views/Status/package.json | 19 +++++++++++++++++++ 6 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 js/src/views/Home/package.json create mode 100644 js/src/views/Status/package.json diff --git a/js/src/redux/providers/apiReducer.js b/js/src/redux/providers/apiReducer.js index 853e909eee..787aee73db 100644 --- a/js/src/redux/providers/apiReducer.js +++ b/js/src/redux/providers/apiReducer.js @@ -16,7 +16,7 @@ import { handleActions } from 'redux-actions'; -const initialState = {}; +const initialState = null; export default handleActions({ setApi (state, action) { diff --git a/js/src/redux/providers/personalActions.js b/js/src/redux/providers/personalActions.js index a5cc6e485d..62d32048d7 100644 --- a/js/src/redux/providers/personalActions.js +++ b/js/src/redux/providers/personalActions.js @@ -63,8 +63,6 @@ export function personalAccountsInfo (accountsInfo) { return (dispatch, getState) => { const { api } = getState(); - console.log('_fetchOwners', api); - const _fetchOwners = Object .values(wallets) .map((wallet) => { diff --git a/js/src/redux/providers/status.js b/js/src/redux/providers/status.js index 19bec2c0ac..ba953b8989 100644 --- a/js/src/redux/providers/status.js +++ b/js/src/redux/providers/status.js @@ -49,6 +49,10 @@ export default class Status { api.on('disconnected', this.stop, this); this.updateApiStatus(); + + if (api.isConnected) { + this.start(); + } } static instantiate (store, api) { diff --git a/js/src/redux/store.js b/js/src/redux/store.js index ab4f2c881f..056e8d56c9 100644 --- a/js/src/redux/store.js +++ b/js/src/redux/store.js @@ -41,13 +41,13 @@ export default function (api, browserHistory, forEmbed = false) { const middleware = initMiddleware(api, browserHistory, forEmbed); const store = applyMiddleware(...middleware)(storeCreation)(reducers); + store.dispatch(setApi(api)); + BalancesProvider.instantiate(store, api); StatusProvider.instantiate(store, api); new PersonalProvider(store, api).start(); new SignerProvider(store, api).start(); - store.dispatch(setApi(api)); - store.dispatch(startCachingReverses()); store.dispatch(loadWallet(api)); store.dispatch(initRequests(api)); diff --git a/js/src/views/Home/package.json b/js/src/views/Home/package.json new file mode 100644 index 0000000000..0b2b8cf171 --- /dev/null +++ b/js/src/views/Home/package.json @@ -0,0 +1,19 @@ +{ + "name": "@parity/view-home", + "description": "Parity default Home view", + "version": "0.0.0", + "main": "index.js", + "author": "Parity Team ", + "maintainers": [], + "contributors": [], + "license": "GPL-3.0", + "repository": { + "type": "git", + "url": "git+https://github.com/paritytech/parity.git" + }, + "keywords": [], + "scripts": {}, + "devDependencies": {}, + "dependencies": {}, + "peerDependencies": {} +} diff --git a/js/src/views/Status/package.json b/js/src/views/Status/package.json new file mode 100644 index 0000000000..395da4be67 --- /dev/null +++ b/js/src/views/Status/package.json @@ -0,0 +1,19 @@ +{ + "name": "@parity/view-status", + "description": "Parity default Status view", + "version": "0.0.0", + "main": "index.js", + "author": "Parity Team ", + "maintainers": [], + "contributors": [], + "license": "GPL-3.0", + "repository": { + "type": "git", + "url": "git+https://github.com/paritytech/parity.git" + }, + "keywords": [], + "scripts": {}, + "devDependencies": {}, + "dependencies": {}, + "peerDependencies": {} +} -- GitLab From 262169c8a42a29773a630ac3eb4aece41df5c17d Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 24 Apr 2017 09:53:27 +0200 Subject: [PATCH 017/314] Add Vaults as dapp --- js/src/config/dappsViews.json | 15 +++++++++++++-- js/src/routes.js | 3 +-- js/src/views/Accounts/accounts.js | 18 +---------------- js/src/views/Vaults/index.js | 32 ++++++++++++++++++++++++++++++- js/src/views/Vaults/package.json | 19 ++++++++++++++++++ js/src/views/Vaults/parity.js | 21 ++++++++++++++++++++ js/src/views/index.js | 1 - 7 files changed, 86 insertions(+), 23 deletions(-) create mode 100644 js/src/views/Vaults/package.json create mode 100644 js/src/views/Vaults/parity.js diff --git a/js/src/config/dappsViews.json b/js/src/config/dappsViews.json index eb587d106d..9d2c88f53a 100644 --- a/js/src/config/dappsViews.json +++ b/js/src/config/dappsViews.json @@ -4,7 +4,7 @@ "url": "home", "src": "Home", "name": "Home", - "description": "Display a status of the node, recently accessed applications, accounts and news", + "description": "Display the status of the node, recently accessed applications, accounts and news", "author": "Parity Team ", "version": "2.0.0", "visible": true, @@ -15,7 +15,18 @@ "url": "status", "src": "Status", "name": "Status", - "description": "Display an overview of the node including settings, logs and connections", + "description": "Displays an overview of the node including settings, logs and connections", + "author": "Parity Team ", + "version": "2.0.0", + "visible": true, + "secure": true + }, + { + "id": "vaults", + "url": "vaults", + "src": "Vaults", + "name": "Vaults", + "description": "Allows the management of the Account Vaults, including creation, locking and account assignment", "author": "Parity Team ", "version": "2.0.0", "visible": true, diff --git a/js/src/routes.js b/js/src/routes.js index 0f7aacc47c..1cd8f2eea0 100644 --- a/js/src/routes.js +++ b/js/src/routes.js @@ -20,7 +20,7 @@ import { Contract, Contracts, Dapp, Dapps, Settings, SettingsBackground, SettingsParity, SettingsProxy, SettingsViews, Signer, - Vaults, Wallet, Web, WriteContract + Wallet, Web, WriteContract } from '~/views'; import builtinDapps from '~/config/dappsBuiltin.json'; import viewsDapps from '~/config/dappsViews.json'; @@ -61,7 +61,6 @@ const accountsRoutes = [ accountsHistory.add(params.address, 'account'); } }, - { path: '/vaults', component: Vaults }, { path: '/wallet/:address', component: Wallet, diff --git a/js/src/views/Accounts/accounts.js b/js/src/views/Accounts/accounts.js index 40bd31bf5a..09e4e84755 100644 --- a/js/src/views/Accounts/accounts.js +++ b/js/src/views/Accounts/accounts.js @@ -20,13 +20,12 @@ import { uniq, isEqual, pickBy } from 'lodash'; import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; import { connect } from 'react-redux'; -import { Link } from 'react-router'; import { bindActionCreators } from 'redux'; import HardwareStore from '~/mobx/hardwareStore'; import { CreateAccount, CreateWallet } from '~/modals'; import { Actionbar, ActionbarExport, ActionbarSearch, ActionbarSort, Button, Page, Tooltip } from '~/ui'; -import { AddIcon, KeyIcon } from '~/ui/Icons'; +import { AddIcon } from '~/ui/Icons'; import { setVisibleAccounts } from '~/redux/providers/personalActions'; import List from './List'; @@ -247,21 +246,6 @@ class Accounts extends Component { const { accounts } = this.props; const buttons = [ - -
@@ -262,8 +262,8 @@ export default class UpgradeParity extends Component { } renderConsensusInfo () { - const { store } = this.props; - const { consensusCapability } = store; + const { upgradeStore } = this.props; + const { consensusCapability } = upgradeStore; if (consensusCapability) { if (consensusCapability === 'capable') { @@ -320,11 +320,11 @@ export default class UpgradeParity extends Component { } onClose = () => { - this.props.store.closeModal(); + this.props.upgradeStore.closeModal(); } onDone = () => { - if (this.props.store.error) { + if (this.props.upgradeStore.error) { this.onClose(); } else { window.location.reload(); @@ -332,6 +332,6 @@ export default class UpgradeParity extends Component { } onUpgrade = () => { - this.props.store.upgradeNow(); + this.props.upgradeStore.upgradeNow(); } } diff --git a/js/src/views/Application/Container/container.js b/js/src/views/Application/Container/container.js index 5138450e20..c4c5ea4385 100644 --- a/js/src/views/Application/Container/container.js +++ b/js/src/views/Application/Container/container.js @@ -17,7 +17,7 @@ import React, { Component, PropTypes } from 'react'; import { FirstRun, UpgradeParity } from '~/modals'; -import { Errors, ParityBackground, Tooltips } from '~/ui'; +import { Errors, Tooltips } from '~/ui'; import styles from '../application.css'; @@ -33,19 +33,16 @@ export default class Container extends Component { const { children, onCloseFirstRun, showFirstRun, upgradeStore } = this.props; return ( - +
- + { children } - +
); } } -- GitLab From cda12ec995924cea3fd9a3720bbadc4d2bb65f79 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 24 Apr 2017 10:52:08 +0200 Subject: [PATCH 020/314] Remove unused RpcCalls --- js/src/views/RpcCalls/actions/localstorage.js | 19 - js/src/views/RpcCalls/actions/logger.js | 24 - js/src/views/RpcCalls/actions/rpc.js | 28 - .../components/AutoComplete/AutoComplete.js | 42 - .../AutoComplete/AutoComplete.spec.js | 44 - .../RpcCalls/components/AutoComplete/index.js | 17 - js/src/views/RpcCalls/components/Box/Box.js | 45 - .../views/RpcCalls/components/Box/Box.spec.js | 70 -- js/src/views/RpcCalls/components/Box/index.js | 17 - .../views/RpcCalls/components/Call/Call.css | 40 - js/src/views/RpcCalls/components/Call/Call.js | 68 - .../RpcCalls/components/Call/Call.spec.js | 92 -- .../views/RpcCalls/components/Call/index.js | 17 - .../views/RpcCalls/components/Calls/Calls.css | 44 - .../views/RpcCalls/components/Calls/Calls.js | 138 --- .../RpcCalls/components/Calls/Calls.spec.js | 135 -- .../views/RpcCalls/components/Calls/index.js | 17 - .../components/CallsToolbar/CallsToolbar.css | 66 - .../components/CallsToolbar/CallsToolbar.js | 153 --- .../CallsToolbar/CallsToolbar.spec.js | 118 -- .../RpcCalls/components/CallsToolbar/index.js | 17 - .../EditableValue/EditableValue.css | 74 -- .../components/EditableValue/EditableValue.js | 204 --- .../components/EditableValue/index.js | 17 - .../components/JsonEditor/JsonEditor.css | 28 - .../components/JsonEditor/JsonEditor.js | 99 -- .../RpcCalls/components/JsonEditor/index.js | 17 - .../RpcCalls/components/Markdown/Markdown.css | 20 - .../RpcCalls/components/Markdown/Markdown.js | 57 - .../RpcCalls/components/Markdown/index.js | 17 - .../RpcCalls/components/Response/Response.css | 20 - .../RpcCalls/components/Response/Response.js | 65 - .../components/Response/Response.spec.js | 47 - .../RpcCalls/components/Response/index.js | 17 - .../RpcCalls/components/RpcCalls/RpcCalls.css | 32 - .../RpcCalls/components/RpcCalls/RpcCalls.js | 373 ------ .../RpcCalls/components/RpcCalls/index.js | 17 - .../RpcCalls/components/RpcDocs/RpcDocs.css | 35 - .../RpcCalls/components/RpcDocs/RpcDocs.js | 142 --- .../RpcCalls/components/RpcDocs/index.js | 17 - .../RpcCalls/components/RpcNav/RpcNav.css | 28 - .../RpcCalls/components/RpcNav/RpcNav.js | 34 - .../views/RpcCalls/components/RpcNav/index.js | 17 - .../ScrollTopButton/ScrollTopButton.css | 41 - .../ScrollTopButton/ScrollTopButton.js | 70 -- .../components/ScrollTopButton/index.js | 17 - .../components/ScrollTopButton/util.js | 48 - js/src/views/RpcCalls/constants/index.js | 17 - .../RpcCalls/containers/RpcPage/RpcPage.js | 57 - .../RpcCalls/containers/RpcPage/index.js | 17 - js/src/views/RpcCalls/data/rpc.json | 1093 ----------------- js/src/views/RpcCalls/middleware/index.js | 25 - .../views/RpcCalls/middleware/localstorage.js | 75 -- .../RpcCalls/middleware/localstorage.spec.js | 205 ---- js/src/views/RpcCalls/reducers/index.js | 23 - js/src/views/RpcCalls/reducers/logger.js | 32 - js/src/views/RpcCalls/reducers/rpc.js | 65 - js/src/views/RpcCalls/util/error.js | 30 - js/src/views/RpcCalls/util/error.spec.js | 109 -- js/src/views/RpcCalls/util/index.js | 38 - js/src/views/RpcCalls/util/index.spec.js | 51 - js/src/views/RpcCalls/util/react.js | 21 - js/src/views/RpcCalls/util/rpc-md.js | 27 - 63 files changed, 4649 deletions(-) delete mode 100644 js/src/views/RpcCalls/actions/localstorage.js delete mode 100644 js/src/views/RpcCalls/actions/logger.js delete mode 100644 js/src/views/RpcCalls/actions/rpc.js delete mode 100644 js/src/views/RpcCalls/components/AutoComplete/AutoComplete.js delete mode 100644 js/src/views/RpcCalls/components/AutoComplete/AutoComplete.spec.js delete mode 100644 js/src/views/RpcCalls/components/AutoComplete/index.js delete mode 100644 js/src/views/RpcCalls/components/Box/Box.js delete mode 100644 js/src/views/RpcCalls/components/Box/Box.spec.js delete mode 100644 js/src/views/RpcCalls/components/Box/index.js delete mode 100644 js/src/views/RpcCalls/components/Call/Call.css delete mode 100644 js/src/views/RpcCalls/components/Call/Call.js delete mode 100644 js/src/views/RpcCalls/components/Call/Call.spec.js delete mode 100644 js/src/views/RpcCalls/components/Call/index.js delete mode 100644 js/src/views/RpcCalls/components/Calls/Calls.css delete mode 100644 js/src/views/RpcCalls/components/Calls/Calls.js delete mode 100644 js/src/views/RpcCalls/components/Calls/Calls.spec.js delete mode 100644 js/src/views/RpcCalls/components/Calls/index.js delete mode 100644 js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.css delete mode 100644 js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.js delete mode 100644 js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.spec.js delete mode 100644 js/src/views/RpcCalls/components/CallsToolbar/index.js delete mode 100644 js/src/views/RpcCalls/components/EditableValue/EditableValue.css delete mode 100644 js/src/views/RpcCalls/components/EditableValue/EditableValue.js delete mode 100644 js/src/views/RpcCalls/components/EditableValue/index.js delete mode 100644 js/src/views/RpcCalls/components/JsonEditor/JsonEditor.css delete mode 100644 js/src/views/RpcCalls/components/JsonEditor/JsonEditor.js delete mode 100644 js/src/views/RpcCalls/components/JsonEditor/index.js delete mode 100644 js/src/views/RpcCalls/components/Markdown/Markdown.css delete mode 100644 js/src/views/RpcCalls/components/Markdown/Markdown.js delete mode 100644 js/src/views/RpcCalls/components/Markdown/index.js delete mode 100644 js/src/views/RpcCalls/components/Response/Response.css delete mode 100644 js/src/views/RpcCalls/components/Response/Response.js delete mode 100644 js/src/views/RpcCalls/components/Response/Response.spec.js delete mode 100644 js/src/views/RpcCalls/components/Response/index.js delete mode 100644 js/src/views/RpcCalls/components/RpcCalls/RpcCalls.css delete mode 100644 js/src/views/RpcCalls/components/RpcCalls/RpcCalls.js delete mode 100644 js/src/views/RpcCalls/components/RpcCalls/index.js delete mode 100644 js/src/views/RpcCalls/components/RpcDocs/RpcDocs.css delete mode 100644 js/src/views/RpcCalls/components/RpcDocs/RpcDocs.js delete mode 100644 js/src/views/RpcCalls/components/RpcDocs/index.js delete mode 100644 js/src/views/RpcCalls/components/RpcNav/RpcNav.css delete mode 100644 js/src/views/RpcCalls/components/RpcNav/RpcNav.js delete mode 100644 js/src/views/RpcCalls/components/RpcNav/index.js delete mode 100644 js/src/views/RpcCalls/components/ScrollTopButton/ScrollTopButton.css delete mode 100644 js/src/views/RpcCalls/components/ScrollTopButton/ScrollTopButton.js delete mode 100644 js/src/views/RpcCalls/components/ScrollTopButton/index.js delete mode 100644 js/src/views/RpcCalls/components/ScrollTopButton/util.js delete mode 100644 js/src/views/RpcCalls/constants/index.js delete mode 100644 js/src/views/RpcCalls/containers/RpcPage/RpcPage.js delete mode 100644 js/src/views/RpcCalls/containers/RpcPage/index.js delete mode 100644 js/src/views/RpcCalls/data/rpc.json delete mode 100644 js/src/views/RpcCalls/middleware/index.js delete mode 100644 js/src/views/RpcCalls/middleware/localstorage.js delete mode 100644 js/src/views/RpcCalls/middleware/localstorage.spec.js delete mode 100644 js/src/views/RpcCalls/reducers/index.js delete mode 100644 js/src/views/RpcCalls/reducers/logger.js delete mode 100644 js/src/views/RpcCalls/reducers/rpc.js delete mode 100644 js/src/views/RpcCalls/util/error.js delete mode 100644 js/src/views/RpcCalls/util/error.spec.js delete mode 100644 js/src/views/RpcCalls/util/index.js delete mode 100644 js/src/views/RpcCalls/util/index.spec.js delete mode 100644 js/src/views/RpcCalls/util/react.js delete mode 100644 js/src/views/RpcCalls/util/rpc-md.js diff --git a/js/src/views/RpcCalls/actions/localstorage.js b/js/src/views/RpcCalls/actions/localstorage.js deleted file mode 100644 index 2581591055..0000000000 --- a/js/src/views/RpcCalls/actions/localstorage.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import { createAction } from 'redux-actions'; - -export const syncRpcStateFromLocalStorage = createAction('sync rpcStateFromLocalStorage'); diff --git a/js/src/views/RpcCalls/actions/logger.js b/js/src/views/RpcCalls/actions/logger.js deleted file mode 100644 index e8f8556e1a..0000000000 --- a/js/src/views/RpcCalls/actions/logger.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import { createAction } from 'redux-actions'; - -import { identity } from '../util'; -import { withError } from '~/redux/util'; - -export const updateLogging = createAction( - 'update logging', identity, withError(flag => `logging updated to ${flag}`) -); diff --git a/js/src/views/RpcCalls/actions/rpc.js b/js/src/views/RpcCalls/actions/rpc.js deleted file mode 100644 index 1c6f5a169a..0000000000 --- a/js/src/views/RpcCalls/actions/rpc.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import { createAction } from 'redux-actions'; - -import { identity } from '../util'; -import { withError } from '~/redux/util'; - -export const error = createAction('error rpc', identity, - withError(() => 'error processing rpc call. check console for details', 'error') -); -export const fireRpc = createAction('fire rpc'); -export const addRpcReponse = createAction('add rpcResponse'); -export const selectRpcMethod = createAction('select rpcMethod'); -export const resetRpcPrevCalls = createAction('reset rpcPrevCalls'); diff --git a/js/src/views/RpcCalls/components/AutoComplete/AutoComplete.js b/js/src/views/RpcCalls/components/AutoComplete/AutoComplete.js deleted file mode 100644 index 6584f34a55..0000000000 --- a/js/src/views/RpcCalls/components/AutoComplete/AutoComplete.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; -import AutoComplete from 'material-ui/AutoComplete'; - -export default class WrappedAutoComplete extends Component { - render () { - return ( - - ); - } - - static defaultProps = { - openOnFocus: true, - filter: (searchText, key) => searchText === '' || key.toLowerCase().indexOf(searchText.toLowerCase()) !== -1 - } - - static propTypes = { - dataSource: PropTypes.array.isRequired, - filter: PropTypes.func, - name: PropTypes.string.isRequired, - openOnFocus: PropTypes.bool - } - - static contextTypes = { - muiTheme: PropTypes.object.isRequired - } -} diff --git a/js/src/views/RpcCalls/components/AutoComplete/AutoComplete.spec.js b/js/src/views/RpcCalls/components/AutoComplete/AutoComplete.spec.js deleted file mode 100644 index 87bc9a1e82..0000000000 --- a/js/src/views/RpcCalls/components/AutoComplete/AutoComplete.spec.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React from 'react'; -import { shallow } from 'enzyme'; - -import getMuiTheme from 'material-ui/styles/getMuiTheme'; - -import WrappedAutoComplete from './AutoComplete'; - -describe('views/Status/components/AutoComplete', () => { - describe('rendering', () => { - let rendered; - - beforeEach(() => { - const dataSource = ['abc', 'def', 'ghi']; - const component = - ; - - rendered = shallow(component, { context: { muiTheme: getMuiTheme({}) } }); - }); - - it('renders the material AutoComplete component', () => { - expect(rendered).to.be.ok; - expect(rendered).to.have.exactly(1).descendants('AutoComplete'); - }); - }); -}); diff --git a/js/src/views/RpcCalls/components/AutoComplete/index.js b/js/src/views/RpcCalls/components/AutoComplete/index.js deleted file mode 100644 index d84245ff66..0000000000 --- a/js/src/views/RpcCalls/components/AutoComplete/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './AutoComplete'; diff --git a/js/src/views/RpcCalls/components/Box/Box.js b/js/src/views/RpcCalls/components/Box/Box.js deleted file mode 100644 index 1d6f525d2c..0000000000 --- a/js/src/views/RpcCalls/components/Box/Box.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -export default class Box extends Component { - renderValue () { - if (!this.props.value) { - return; - } - - return ( -

{ this.props.value }

- ); - } - - render () { - return ( -
-

{ this.props.title }

- { this.renderValue() } - { this.props.children } -
- ); - } - - static propTypes = { - title: PropTypes.string.isRequired, - value: PropTypes.string, - children: PropTypes.element - } -} diff --git a/js/src/views/RpcCalls/components/Box/Box.spec.js b/js/src/views/RpcCalls/components/Box/Box.spec.js deleted file mode 100644 index 34154425c5..0000000000 --- a/js/src/views/RpcCalls/components/Box/Box.spec.js +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React from 'react'; -import { shallow } from 'enzyme'; - -import Box from './Box'; - -describe('views/Status/components/Box', () => { - describe('rendering', () => { - const title = 'test title'; - let rendered; - - beforeEach(() => { - rendered = shallow(); - }); - - it('renders the component', () => { - expect(rendered).to.be.ok; - expect(rendered).to.have.className('dapp-box'); - }); - - it('renders the title', () => { - expect(rendered.find('h2')).to.have.text(title); - }); - - it('renders no default value', () => { - expect(rendered).to.not.have.descendants('h1'); - }); - }); - - describe('contents', () => { - const value = 'test value'; - const child = 'this is the child value'; - - let rendered; - - beforeEach(() => { - rendered = shallow( - -
{ child }
-
- ); - }); - - it('renders the value', () => { - expect(rendered.find('h1')).to.have.text(value); - }); - - it('wraps the children', () => { - expect(rendered.find('pre')).to.have.text(child); - }); - }); -}); diff --git a/js/src/views/RpcCalls/components/Box/index.js b/js/src/views/RpcCalls/components/Box/index.js deleted file mode 100644 index 35e9da0cbb..0000000000 --- a/js/src/views/RpcCalls/components/Box/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './Box'; diff --git a/js/src/views/RpcCalls/components/Call/Call.css b/js/src/views/RpcCalls/components/Call/Call.css deleted file mode 100644 index 8dcf36e9e5..0000000000 --- a/js/src/views/RpcCalls/components/Call/Call.css +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright 2015-2017 Parity Technologies (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.call { - position: relative; - border-bottom: 2px solid #CCC6C6; - margin-bottom: 18.4px; - background: #f5f4f2; -} - -.call:first-child { - border-color: #6691C2; -} - -.call pre { - margin: 0; -} - -.call pre:nth-child(3) { - padding-top: 0; - color: #bbb; -} - -.callNo { - float: right; - color: #ccc; -} diff --git a/js/src/views/RpcCalls/components/Call/Call.js b/js/src/views/RpcCalls/components/Call/Call.js deleted file mode 100644 index 52a120fec2..0000000000 --- a/js/src/views/RpcCalls/components/Call/Call.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import Response from '../Response'; -import styles from './Call.css'; - -export default class Call extends Component { - render () { - let { callNo, name, params, response } = this.props.call; - - params = this.formatParams(params); - return ( -
- #{ callNo } -
{ name }({ params })
- -
- ); - } - - setElement = el => { - this.element = el; - } - - setActiveCall = () => { - this.props.setActiveCall(this.props.call, this.element); - } - - formatParams (params) { - return params.reduce((str, p) => { - if (str !== '') { - str += ', '; - } - if (p === undefined) { - return str; - } - if (typeof p === 'object' || typeof p === 'string') { - p = JSON.stringify(p); - } - return str + p; - }, ''); - } - - static propTypes = { - call: PropTypes.object.isRequired, - setActiveCall: PropTypes.func.isRequired - } -} diff --git a/js/src/views/RpcCalls/components/Call/Call.spec.js b/js/src/views/RpcCalls/components/Call/Call.spec.js deleted file mode 100644 index af7e633e65..0000000000 --- a/js/src/views/RpcCalls/components/Call/Call.spec.js +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React from 'react'; -import { shallow } from 'enzyme'; -import sinon from 'sinon'; - -import '../../../../environment/tests'; - -import Call from './Call'; - -describe('views/Status/components/Call', () => { - const call = { callIdx: 123, callNo: 456, name: 'eth_call', params: [{ name: '123' }], response: '' }; - const element = 'dummyElement'; - - let rendered; - let instance; - let setActiveCall = sinon.stub(); - - beforeEach(() => { - rendered = shallow( - - ); - instance = rendered.instance(); - }); - - describe('rendering', () => { - it('renders the component', () => { - expect(rendered).to.be.ok; - expect(rendered).to.have.exactly(1).descendants(`div[data-test="Call-call-${call.callNo}"]`); - }); - - it('adds onMouseEnter to setActiveElement', () => { - expect(rendered.find('div').first()).to.have.prop('onMouseEnter', instance.setActiveCall); - }); - }); - - describe('actions', () => { - it('sets the element via setElement', () => { - expect(instance.element).to.not.be.ok; - instance.setElement(element); - expect(instance.element).to.equal(element); - }); - - it('calls parent setActive call on setActiveCall', () => { - instance.setElement(element); - instance.setActiveCall(); - - expect(setActiveCall).to.be.calledWith(call, element); - }); - }); - - describe('utility', () => { - describe('.formatParams', () => { - it('correctly returns a single parameter', () => { - expect(instance.formatParams([1])).to.equal('1'); - }); - - it('correctly joins 2 parameters', () => { - expect(instance.formatParams([1, 2])).to.equal('1, 2'); - }); - - it('stringifies a string object', () => { - expect(instance.formatParams(['1'])).to.equal('"1"'); - }); - - it('stringifies an object object', () => { - expect(instance.formatParams([{ name: '1' }])).to.equal('{"name":"1"}'); - }); - - it('skips an undefined value', () => { - expect(instance.formatParams(['1', undefined, 3])).to.equal('"1", , 3'); - }); - }); - }); -}); diff --git a/js/src/views/RpcCalls/components/Call/index.js b/js/src/views/RpcCalls/components/Call/index.js deleted file mode 100644 index 0620b46ded..0000000000 --- a/js/src/views/RpcCalls/components/Call/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './Call'; diff --git a/js/src/views/RpcCalls/components/Calls/Calls.css b/js/src/views/RpcCalls/components/Calls/Calls.css deleted file mode 100644 index 0266579ac8..0000000000 --- a/js/src/views/RpcCalls/components/Calls/Calls.css +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2015-2017 Parity Technologies (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.historyInfo { - margin-top: 0; - text-transform: initial; -} - -.header { - margin: 0; -} - -.removeIcon { - float: right; - color: #bbb; - cursor: pointer; - transition: opacity ease-in-out 0.2s; - transition-delay: 0.2s; - opacity: 0; -} - -div:hover > .removeIcon { - opacity: 1.0; -} - -.history { - margin-top: calc(1em + 18.4px); - padding-top: 0; - overflow: auto; - max-height: 60vh; -} diff --git a/js/src/views/RpcCalls/components/Calls/Calls.js b/js/src/views/RpcCalls/components/Calls/Calls.js deleted file mode 100644 index 3a1023bc6d..0000000000 --- a/js/src/views/RpcCalls/components/Calls/Calls.js +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; -import { FormattedMessage } from 'react-intl'; - -import Call from '../Call'; -import CallsToolbar from '../CallsToolbar'; -import styles from './Calls.css'; - -export default class Calls extends Component { - state = { - activeCall: null, - activeChild: null - } - - render () { - return ( -
- { this.renderClear() } -

- -

-
- { this.renderNoCallsMsg() } - { this.renderCalls() } -
- -
- ); - } - - renderClear () { - if (!this.props.calls.length) { - return; - } - - return ( - - } - onClick={ this.clearHistory } - className={ styles.removeIcon } - > - - - ); - } - - renderNoCallsMsg () { - if (this.props.calls.length) { - return; - } - - return ( -
-

- -

-
- ); - } - - renderCalls () { - const { calls } = this.props; - - if (!calls.length) { - return; - } - - return calls.map((call, idx) => ( - - )); - } - - clearActiveCall = () => { - this.setState({ activeCall: null, activeChild: null }); - } - - setActiveCall = (call, el) => { - this.setState({ activeCall: call, activeChild: el }); - } - - setCallsHistory = el => { - this._callsHistory = el; - } - - clearHistory = () => { - this.props.reset(); - } - - static propTypes = { - calls: PropTypes.arrayOf(PropTypes.object).isRequired, - actions: PropTypes.shape({ - fireRpc: PropTypes.func.isRequired, - copyToClipboard: PropTypes.func.isRequired, - selectRpcMethod: PropTypes.func.isRequired - }).isRequired, - reset: PropTypes.func - } -} diff --git a/js/src/views/RpcCalls/components/Calls/Calls.spec.js b/js/src/views/RpcCalls/components/Calls/Calls.spec.js deleted file mode 100644 index 4127f65cbe..0000000000 --- a/js/src/views/RpcCalls/components/Calls/Calls.spec.js +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React from 'react'; -import { shallow } from 'enzyme'; - -import '../../../../environment/tests'; - -import Calls from './Calls'; - -describe('views/Status/components/Calls', () => { - describe('rendering (no calls)', () => { - let rendered; - - before(() => { - const calls = []; - - rendered = shallow(); - }); - - it('renders the component and container', () => { - expect(rendered).to.be.ok; - expect(rendered).to.have.className('calls-container'); - }); - - it('renders no calls', () => { - expect(rendered.find('div[data-test="Calls-empty-wrapper"]')).to.have.exactly(1).descendants('h3'); - }); - - it('renders no clear button', () => { - expect(rendered.find('a[data-test="Calls-remove"]')).to.not.exist; - }); - - it('renders an attached CallsToolbar', () => { - expect(rendered).to.have.exactly(1).descendants('CallsToolbar'); - }); - }); - - describe('rendering (calls supplied)', () => { - const calls = [ - { callNo: 0, name: 'eth_call', params: '', response: '' }, - { callNo: 1, name: 'eth_sendTransaction', params: '', response: '' } - ]; - const actions = { action1: true, action2: true }; - - let rendered; - let instance; - - before(() => { - rendered = shallow(); - instance = rendered.instance(); - }); - - it('renders the clear button', () => { - expect(rendered).to.have.exactly(1).descendants('a[data-test="Calls-remove"]'); - }); - - it('renders calls', () => { - expect(rendered.find('div[data-test="Calls-empty-wrapper"]')).to.not.exist; - expect(rendered.find('div.row div')).to.have.exactly(2).descendants('Call'); - }); - - it('passes the correct properties to Call', () => { - const call = rendered.find('Call').first(); - - expect(call).to.have.prop('setActiveCall', instance.setActiveCall); - expect(call).to.have.prop('call').deep.equal(calls[0]); - }); - - it('passes the correct properties to CallsToolbar', () => { - const child = { offsetTop: 0 }; - const container = { scrollTop: 0 }; - - instance.setCallsHistory(container); - rendered.setState({ activeCall: 'dummyActiveCall', activeChild: child }); - - const toolbar = rendered.find('CallsToolbar').first(); - - expect(toolbar).to.have.prop('call', 'dummyActiveCall'); - expect(toolbar).to.have.prop('actions').deep.equal(actions); - expect(toolbar).to.have.prop('callEl').deep.equal(child); - expect(toolbar).to.have.prop('containerEl').deep.equal(container); - }); - }); - - describe('actions', () => { - let rendered; - let instance; - - before(() => { - const calls = [ - { callNo: 0, name: 'eth_call', params: '', response: '' }, - { callNo: 1, name: 'eth_sendTransaction', params: '', response: '' } - ]; - - rendered = shallow(); - instance = rendered.instance(); - }); - - it('sets the element via setCallsHistory', () => { - instance.setCallsHistory('dummyElement'); - - expect(instance._callsHistory).to.equal('dummyElement'); - }); - - it('sets state via setActiveCall', () => { - instance.setActiveCall('dummyActiveCall', 'dummyActiveChild'); - - expect(rendered).to.have.state('activeCall', 'dummyActiveCall'); - expect(rendered).to.have.state('activeChild', 'dummyActiveChild'); - }); - - it('clears state via clearActiveCall', () => { - instance.setActiveCall('dummyActiveCall', 'dummyActiveChild'); - expect(rendered).to.have.state('activeCall', 'dummyActiveCall'); - instance.clearActiveCall(); - - expect(rendered).to.have.state('activeCall', null); - expect(rendered).to.have.state('activeChild', null); - }); - }); -}); diff --git a/js/src/views/RpcCalls/components/Calls/index.js b/js/src/views/RpcCalls/components/Calls/index.js deleted file mode 100644 index 4e625ded8f..0000000000 --- a/js/src/views/RpcCalls/components/Calls/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './Calls'; diff --git a/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.css b/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.css deleted file mode 100644 index 8c34e1921d..0000000000 --- a/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.css +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright 2015-2017 Parity Technologies (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.callActionsWrap { - position: absolute; - animation: fadein .5s; - right: 0; - height: 28px; -} - -.callActionsButton { - padding: 0 !important; - height: 24px !important; -} - -.callActionsWrap:hover .callActionsButton { - display: none !important; -} - -.callActions { - display: none; - height: 100%; - margin-top: 1px; - margin-right: 10px; -} - -.callActionsWrap:hover .callActions { - display: block; -} - -.callAction { - float: right; - transition: opacity ease-in-out .2s; - transition-delay: .2s; - opacity: 0; - padding: 3px !important; - height: 22px !important; - width: 22px !important; -} - -.callActions:hover .callAction { - opacity: 1; -} - -.callActionIcon { - height: 100% !important; - width: 100% !important; -} - -@keyframes fadein { - from { opacity: 0; } - to { opacity: 1; } -} diff --git a/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.js b/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.js deleted file mode 100644 index 618a5de266..0000000000 --- a/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.js +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; -import CopyToClipboard from 'react-copy-to-clipboard'; -import { FormattedMessage } from 'react-intl'; -import { sortBy, find, extend } from 'lodash'; - -import IconButton from 'material-ui/IconButton'; -import MoreHorizIcon from 'material-ui/svg-icons/navigation/more-horiz'; -import CallIcon from 'material-ui/svg-icons/communication/call'; -import AssignmentIcon from 'material-ui/svg-icons/action/assignment'; -import InputIcon from 'material-ui/svg-icons/action/input'; - -import { SCROLLBAR_WIDTH } from '../../constants'; -import styles from './CallsToolbar.css'; -import rpcData from '../../data/rpc.json'; -const rpcMethods = sortBy(rpcData.methods, 'name'); - -export default class CallsToolbar extends Component { - render () { - const { call, callEl, containerEl } = this.props; - - if (!call) { - return null; - } - - const wrapStyle = { top: callEl.offsetTop - SCROLLBAR_WIDTH - containerEl.scrollTop }; - - if (this.hasScrollbar(containerEl)) { - wrapStyle.right = 13; - } - - return ( -
- - - -
- - } - tooltipPosition='top-left' - { ...this._test('button-setCall') } - > - - - - } - tooltipPosition='top-left' - { ...this._test('button-makeCall') } - > - - - - - } - tooltipPosition='top-left' - { ...this._test('copyCallToClipboard') } - > - - - -
-
- ); - } - - setCall = () => { - const { call } = this.props; - let method = find(rpcMethods, { name: call.name }); - - this.props.actions.selectRpcMethod(extend({}, method, { paramsValues: call.params })); - } - - makeCall = () => { - const { call } = this.props; - let method = find(rpcMethods, { name: call.name }); - - this.setCall(); - this.props.actions.fireRpc({ - method: method.name, - outputFormatter: method.outputFormatter, - inputFormatters: method.inputFormatters, - params: call.params - }); - } - - copyToClipboard = () => { - this.props.actions.copyToClipboard( - - ); - } - - hasScrollbar (el) { - return el.clientHeight < el.scrollHeight; - } -} - -CallsToolbar.propTypes = { - call: PropTypes.object.isRequired, - callEl: PropTypes.node.isRequired, - containerEl: PropTypes.node.isRequired, - actions: PropTypes.shape({ - fireRpc: PropTypes.func.isRequired, - copyToClipboard: PropTypes.func.isRequired, - selectRpcMethod: PropTypes.func.isRequired - }).isRequired -}; diff --git a/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.spec.js b/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.spec.js deleted file mode 100644 index e326f730ef..0000000000 --- a/js/src/views/RpcCalls/components/CallsToolbar/CallsToolbar.spec.js +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React from 'react'; -import sinon from 'sinon'; -import { shallow } from 'enzyme'; - -import '../../../../environment/tests'; - -import CallsToolbar from './CallsToolbar'; - -describe('views/Status/components/CallsToolbar', () => { - const callEl = { offsetTop: 0 }; - const containerEl = { scrollTop: 0, clientHeight: 0, scrollHeight: 999 }; - - describe('rendering (no call)', () => { - let rendered; - - before(() => { - const call = null; - - rendered = shallow(); - }); - - it('does not render the component', () => { - expect(rendered).to.not.have.descendants('[data-test="CallsToolbar-button-more"]'); - }); - }); - - describe('rendering', () => { - const call = { callNo: 456, name: 'eth_call', params: '', response: '' }; - let rendered; - let btncontainer; - - before(() => { - rendered = shallow(); - btncontainer = rendered.find('[data-test="CallsToolbar-button-container"]'); - }); - - it('renders the More button', () => { - expect(rendered).to.have.descendants('[data-test="CallsToolbar-button-more"]'); - }); - - it('renders the Set button', () => { - expect(btncontainer).to.have.descendants('[data-test="CallsToolbar-button-setCall"]'); - }); - - it('renders the Fire button', () => { - expect(btncontainer).to.have.descendants('[data-test="CallsToolbar-button-makeCall"]'); - }); - - it('renders the Copy button', () => { - expect(btncontainer).to.have.descendants('[data-test="CallsToolbar-copyCallToClipboard"]'); - }); - }); - - describe('actions', () => { - const call = { callNo: 456, name: 'eth_call', params: '', response: '' }; - const actions = { fireRpc: sinon.stub(), copyToClipboard: sinon.stub(), selectRpcMethod: sinon.stub() }; - - let rendered; - let instance; - - before(() => { - rendered = shallow(); - instance = rendered.instance(); - }); - - it('calls copyToClipboard with action copyToClipboard', () => { - instance.copyToClipboard(); - expect(actions.copyToClipboard).to.be.calledOnce; - }); - - it('calls setCall with action selectRpcMethod', () => { - instance.setCall(); - expect(actions.selectRpcMethod).to.be.calledOnce; - }); - - it('calls makeCall with action fireRpc', () => { - instance.makeCall(); - expect(actions.fireRpc).to.be.calledOnce; - }); - }); - - describe('utility', () => { - const call = { callNo: 456, name: 'eth_call', params: '', response: '' }; - let rendered; - let instance; - - before(() => { - rendered = shallow(); - instance = rendered.instance(); - }); - - describe('.hasScrollbar', () => { - it('correctly returns true when scrollbar', () => { - expect(instance.hasScrollbar({ clientHeight: 123, scrollHeight: 456 })).to.be.true; - }); - - it('correctly returns false when no scrollbar', () => { - expect(instance.hasScrollbar({ clientHeight: 456, scrollHeight: 123 })).to.be.false; - }); - }); - }); -}); diff --git a/js/src/views/RpcCalls/components/CallsToolbar/index.js b/js/src/views/RpcCalls/components/CallsToolbar/index.js deleted file mode 100644 index 1baac06366..0000000000 --- a/js/src/views/RpcCalls/components/CallsToolbar/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './CallsToolbar'; diff --git a/js/src/views/RpcCalls/components/EditableValue/EditableValue.css b/js/src/views/RpcCalls/components/EditableValue/EditableValue.css deleted file mode 100644 index bfa3dc674e..0000000000 --- a/js/src/views/RpcCalls/components/EditableValue/EditableValue.css +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2015-2017 Parity Technologies (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.input { - margin-top: 0; - width: 100%; - padding-left: 10px; - padding-right: 50px; -} - -.icon, .iconSuccess, .firstIcon { - display: block; - cursor: pointer; - flex: 1; - margin: 3px 3px; - color: #bbb; -} - -.success, .iconSuccess { - color: #8bc34a; -} - -.icon i, .iconSuccess i, .firstIcon i { - vertical-align: middle; -} - -.icons, .iconsVisible, .firstIcon { - z-index: 10; - position: absolute; - right: 0; - top: 0; - bottom: 0; - display: flex; - opacity: 0; - transition: opacity ease-in-out .2s; - transition-delay: 0.2s; -} - -.iconsVisible { - opacity: 1.0; -} - -.container:hover .icons, .container:hover .firstIcon { - opacity: 1.0; -} - -.firstIcon { - position: absolute; - left: -10px; - right: auto; - top: 0; - bottom: 0; - margin: 3px 0; - display: block; -} - -.autocomplete input { - margin-top: 0; - padding-left: 10px !important; - padding-right: 50px !important; -} diff --git a/js/src/views/RpcCalls/components/EditableValue/EditableValue.js b/js/src/views/RpcCalls/components/EditableValue/EditableValue.js deleted file mode 100644 index 98ad223ca4..0000000000 --- a/js/src/views/RpcCalls/components/EditableValue/EditableValue.js +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; -import { FormattedMessage } from 'react-intl'; -import AutoComplete from 'material-ui/AutoComplete'; - -import styles from './EditableValue.css'; -import valueStyles from '../Value/Value.css'; - -export default class EditableValue extends Component { - state = { - value: this.props.value, - inEditMode: false - } - - componentWillReceiveProps (newProps) { - if (newProps.value === this.state.value || this.state.inEditMode) { - return; - } - this.setState({ - value: newProps.value - }); - } - - onChange = value => { - this.setState({ - value: value - }); - } - - onOpenEdit = evt => { - this.setState({ - inEditMode: true - }); - - if (!this._input) { - return; - } - this._input.focus(); - } - - onCancel = evt => { - this.setState({ - inEditMode: false, - value: this.props.value - }); - } - - onSubmit = () => { - this.setState({ - inEditMode: false - }); - this.props.onSubmit(this.state.value, false); - } - - onResetToDefault = () => { - this.props.onSubmit(this.props.defaultValue, true); - } - - render () { - return ( -
- { this.renderResetButton() } -
- { this.props.children } - { this.renderButtons() } -
- { this.renderInput() } -
- ); - } - - renderInput () { - const { inEditMode, value } = this.state; - - const setInput = el => { this._input = el; }; - const onChange = evt => this.onChange(evt.target.value); - - if (!inEditMode || !this.props.autocomplete) { - return ( - - ); - } - - return ( - - ); - } - - renderResetButton () { - if (this.state.inEditMode) { - return; - } - - if (!this.props.defaultValue || this.state.value === this.props.defaultValue) { - return; - } - - return ( - - } - { ...this._testInherit('reset') } - > - - - ); - } - - renderButtons () { - if (this.state.inEditMode) { - return [ - - - , - - - - ]; - } - - return ( - - } - { ...this._testInherit('edit') } - > - - - ); - } - - static propTypes = { - onSubmit: PropTypes.func.isRequired, - value: PropTypes.string, - defaultValue: PropTypes.string, - children: PropTypes.element, - autocomplete: PropTypes.bool, - dataSource: PropTypes.arrayOf(PropTypes.string) - } -} diff --git a/js/src/views/RpcCalls/components/EditableValue/index.js b/js/src/views/RpcCalls/components/EditableValue/index.js deleted file mode 100644 index 480a8772b2..0000000000 --- a/js/src/views/RpcCalls/components/EditableValue/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './EditableValue'; diff --git a/js/src/views/RpcCalls/components/JsonEditor/JsonEditor.css b/js/src/views/RpcCalls/components/JsonEditor/JsonEditor.css deleted file mode 100644 index 87b7e10d9f..0000000000 --- a/js/src/views/RpcCalls/components/JsonEditor/JsonEditor.css +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2015-2017 Parity Technologies (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.editor { - width: 100%; - height: 200px; -} - -.error { - border: 1px solid red !important; -} - -.errorMsg { - color: red; -} diff --git a/js/src/views/RpcCalls/components/JsonEditor/JsonEditor.js b/js/src/views/RpcCalls/components/JsonEditor/JsonEditor.js deleted file mode 100644 index 75bc59e871..0000000000 --- a/js/src/views/RpcCalls/components/JsonEditor/JsonEditor.js +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2015-2017 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; -import { isEqual } from 'lodash'; -import formatJson from 'format-json'; - -import styles from './JsonEditor.css'; - -export default class JsonEditor extends Component { - constructor (...args) { - super(...args); - let { value } = this.props; - - value = formatJson.plain(value); - this.state = { value }; - } - - componentDidMount () { - const mockedEvt = { target: { value: this.state.value } }; - - this.onChange(mockedEvt); - } - - componentWillReceiveProps (nextProps) { - let { value } = nextProps; - - if (!isEqual(value, this.props.value)) { - value = formatJson.plain(value); - this.setState({ value }); - } - } - - render () { - let errorClass = this.state.error ? styles.error : ''; - - return ( -
-