diff --git a/js/package.json b/js/package.json index 1ba973b2e..090602e00 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", @@ -158,11 +159,13 @@ "yargs": "6.6.0" }, "dependencies": { + "@parity/abi": "file:src/abi", + "@parity/api": "file:src/api", + "@parity/jsonrpc": "file:src/jsonrpc", "@parity/ui": "file:src/ui", "@parity/wordlist": "1.0.1", "base32.js": "0.1.0", "bignumber.js": "3.0.1", - "blockies": "0.0.2", "bytes": "2.4.0", "debounce": "1.0.0", "es6-error": "4.0.0", @@ -174,8 +177,6 @@ "format-number": "2.0.1", "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", @@ -204,13 +205,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 new file mode 100644 index 000000000..946d15e57 --- /dev/null +++ b/js/src/abi/package.json @@ -0,0 +1,30 @@ +{ + "name": "@parity/abi", + "description": "The Parity ABI library", + "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": [ + "Ethereum", + "ABI", + "Parity" + ], + "scripts": { + }, + "devDependencies": { + }, + "dependencies": { + "bignumber.js": "3.0.1", + "js-sha3": "0.5.5" + } +} diff --git a/js/src/api/api.spec.js b/js/src/api/api.spec.js index 1c5ebf514..aa18333a0 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/contract/contract.js b/js/src/api/contract/contract.js index 2156b8af1..77c9568a9 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/contract/contract.spec.js b/js/src/api/contract/contract.spec.js index bd8b0fbda..53889e320 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 df40b59a0..ddb8b79f8 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/package.json b/js/src/api/package.json new file mode 100644 index 000000000..0856c9170 --- /dev/null +++ b/js/src/api/package.json @@ -0,0 +1,40 @@ +{ + "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", + "Nicolas Gotchac" + ], + "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", + "@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", + "keythereum": "0.4.6", + "node-fetch": "1.6.3", + "secp256k1": "3.2.5" + } +} diff --git a/js/src/api/util/decode.js b/js/src/api/util/decode.js index 926a5a8a1..995118a72 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/encode.js b/js/src/api/util/encode.js index f18fbbe2b..e936faa38 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'; diff --git a/js/src/api/util/index.js b/js/src/api/util/index.js index cc8fc9b93..d174c3431 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'; diff --git a/js/src/jsonrpc/package.json b/js/src/jsonrpc/package.json new file mode 100644 index 000000000..1bdc7596a --- /dev/null +++ b/js/src/jsonrpc/package.json @@ -0,0 +1,28 @@ +{ + "name": "@parity/jsonrpc", + "description": "JSON and JS interface defintions for RPC", + "version": "0.0.0", + "main": "index.js", + "author": "Parity Team ", + "maintainers": [ + "Jaco Greeff", + "Maciej Hirsz" + ], + "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/test/babel.js b/js/test/babel.js index c9c1d9dae..95a988d42 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))/ +}); diff --git a/js/webpack/app.js b/js/webpack/app.js index ded5c4468..ba8e9a765 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,16 +62,13 @@ module.exports = { module: { rules: [ + rulesParity, + rulesEs6, { test: /\.js$/, exclude: /(node_modules)/, use: [ 'happypack/loader?id=babel-js' ] }, - { - test: /\.js$/, - include: /node_modules\/(material-chip-input|ethereumjs-tx|@parity\/wordlist)/, - use: 'babel-loader' - }, { test: /\.json$/, use: [ 'json-loader' ] diff --git a/js/webpack/libraries.js b/js/webpack/libraries.js index 1fcb39eba..d9ddaf53c 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,11 +62,6 @@ module.exports = { 'babel-loader?cacheDirectory=true' ] }, - { - test: /\.js$/, - include: /node_modules\/(ethereumjs-tx|@parity\/wordlist)/, - use: 'babel-loader' - }, { test: /\.json$/, use: [ 'json-loader' ] diff --git a/js/webpack/npm.js b/js/webpack/npm.js index 2230bf90f..33951fee4 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,18 +70,15 @@ module.exports = { 'babel-loader?cacheDirectory=true' ], exclude: /node_modules/ - }, - { - test: /\.js$/, - include: /node_modules\/(ethereumjs-tx|@parity\/wordlist)/, - use: 'babel-loader' } ] }, 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'), diff --git a/js/webpack/rules/es6.js b/js/webpack/rules/es6.js new file mode 100644 index 000000000..8e485424e --- /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 000000000..6897b218e --- /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' +};