refactor(@embark/parity): move module into own package (#1951)

Contains bug fixes to get parity to work as a blockchain client.

**NOTE:** Please merge https://github.com/embark-framework/embark/pull/1950 first before merging this PR, as this PR contains removal of dependencies from `packages/embark` that are needed for geth. So if this is merged first, and the geth PR (https://github.com/embark-framework/embark/pull/1950) is not merged, then geth will not have some of the dependencies it needs.
This commit is contained in:
Eric Mastro 2019-10-16 22:35:26 +09:00 committed by Iuri Matias
parent ed0d3afb4f
commit e2efbbd846
17 changed files with 104 additions and 24 deletions

View File

@ -65,7 +65,8 @@
"shelljs": "0.8.3", "shelljs": "0.8.3",
"web3": "1.2.1", "web3": "1.2.1",
"web3-eth": "1.2.1", "web3-eth": "1.2.1",
"web3-eth-abi": "1.2.1" "web3-eth-abi": "1.2.1",
"ws": "7.1.2"
}, },
"devDependencies": { "devDependencies": {
"@types/follow-redirects": "1.5.0", "@types/follow-redirects": "1.5.0",

View File

@ -116,6 +116,7 @@
"embark-logger": "^4.1.1", "embark-logger": "^4.1.1",
"embark-mocha-tests": "^4.1.1", "embark-mocha-tests": "^4.1.1",
"embark-namesystem": "^4.1.1", "embark-namesystem": "^4.1.1",
"embark-parity": "^4.1.1",
"embark-pipeline": "^4.1.1", "embark-pipeline": "^4.1.1",
"embark-plugin-cmd": "^4.1.1", "embark-plugin-cmd": "^4.1.1",
"embark-process-logs-api-manager": "^4.1.1", "embark-process-logs-api-manager": "^4.1.1",
@ -162,7 +163,6 @@
"lodash.clonedeep": "4.5.0", "lodash.clonedeep": "4.5.0",
"mocha": "6.2.0", "mocha": "6.2.0",
"neo-blessed": "0.2.0", "neo-blessed": "0.2.0",
"netcat": "1.3.5",
"node-http-proxy-json": "0.1.6", "node-http-proxy-json": "0.1.6",
"node-ipc": "9.1.1", "node-ipc": "9.1.1",
"node-sass": "4.9.3", "node-sass": "4.9.3",
@ -211,7 +211,6 @@
"web3-shh": "1.2.1", "web3-shh": "1.2.1",
"web3-utils": "1.2.1", "web3-utils": "1.2.1",
"window-size": "1.1.1", "window-size": "1.1.1",
"ws": "7.1.2",
"yo-yoify": "4.3.0" "yo-yoify": "4.3.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -191,7 +191,7 @@ class Engine {
plugins: this.plugins, plugins: this.plugins,
ipc: this.ipc ipc: this.ipc
}); });
this.registerModule('parity', { this.registerModulePackage('embark-parity', {
client: this.client, client: this.client,
locale: this.locale, locale: this.locale,
isDev: this.isDev, isDev: this.isDev,

View File

@ -1,4 +0,0 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"]
}

View File

@ -1,3 +0,0 @@
{
"extends": "../../tslint.json"
}

View File

@ -0,0 +1,4 @@
engine-strict = true
package-lock = false
save-exact = true
scripts-prepend-node-path = true

View File

@ -0,0 +1,6 @@
# `embark-parity`
> Implementation of the Parity blockchain for Embark
Visit [embark.status.im](https://embark.status.im/) to get started with
[Embark](https://github.com/embark-framework/embark).

View File

@ -0,0 +1,71 @@
{
"name": "embark-parity",
"version": "4.1.1",
"author": "Iuri Matias <iuri.matias@gmail.com>",
"contributors": [],
"description": "Implementation of the Parity blockchain for Embark",
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/plugins/parity#readme",
"bugs": "https://github.com/embark-framework/embark/issues",
"keywords": [
"blockchain",
"dapps",
"ethereum",
"ipfs",
"serverless",
"solc",
"solidity"
],
"files": [
"dist"
],
"license": "MIT",
"repository": {
"directory": "packages/plugins/parity",
"type": "git",
"url": "https://github.com/embark-framework/embark.git"
},
"main": "./dist/index.js",
"embark-collective": {
"build:node": true
},
"scripts": {
"_build": "npm run solo -- build",
"ci": "npm run qa",
"clean": "npm run reset",
"lint": "npm-run-all lint:*",
"lint:ts": "tslint -c tslint.json \"src/**/*.ts\"",
"qa": "npm-run-all lint typecheck _build",
"reset": "npx rimraf dist embark-*.tgz package",
"solo": "embark-solo",
"typecheck": "tsc",
"watch": "run-p watch:*",
"watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch"
},
"eslintConfig": {
"extends": "../../../.eslintrc.json"
},
"dependencies": {
"@babel/runtime-corejs2": "7.6.2",
"async": "2.6.1",
"embark-core": "^4.1.1",
"embark-i18n": "^4.1.1",
"embark-utils": "^4.1.1",
"fs-extra": "8.1.0",
"netcat": "1.3.5",
"semver": "5.6.0",
"ws": "7.1.2"
},
"devDependencies": {
"embark-solo": "^4.1.1",
"eslint": "5.7.0",
"npm-run-all": "4.1.5",
"rimraf": "3.0.0",
"tslint": "5.16.0",
"typescript": "3.6.3"
},
"engines": {
"node": ">=8.12.0 <12.0.0",
"npm": ">=6.4.1",
"yarn": ">=1.12.3"
}
}

View File

@ -104,7 +104,6 @@ var Blockchain = function (userConfig, clientClass) {
this.logger.error(__(spaceMessage, 'genesisBlock')); this.logger.error(__(spaceMessage, 'genesisBlock'));
process.exit(1); process.exit(1);
} }
this.initProxy();
this.client = new clientClass({config: this.config, env: this.env, isDev: this.isDev}); this.client = new clientClass({config: this.config, env: this.env, isDev: this.isDev});
this.initStandaloneProcess(); this.initStandaloneProcess();
@ -154,13 +153,6 @@ Blockchain.prototype.initStandaloneProcess = function () {
} }
}; };
Blockchain.prototype.initProxy = function () {
if (this.config.proxy) {
this.config.rpcPort += constants.blockchain.servicePortOnProxy;
this.config.wsPort += constants.blockchain.servicePortOnProxy;
}
};
Blockchain.prototype.setupProxy = async function () { Blockchain.prototype.setupProxy = async function () {
// if (!this.proxyIpc) this.proxyIpc = new IPC({ipcRole: 'client'}); // if (!this.proxyIpc) this.proxyIpc = new IPC({ipcRole: 'client'});

View File

@ -23,7 +23,8 @@ class Parity {
return; return;
} }
this.events.request("blockchain:node:register", constants.blockchain.clients.parity, (readyCb) => { this.events.request("blockchain:node:register", constants.blockchain.clients.parity, {
launchFn: (readyCb) => {
this.events.request('processes:register', 'blockchain', { this.events.request('processes:register', 'blockchain', {
launchFn: (cb) => { launchFn: (cb) => {
// this.startBlockchainNode(readyCb); // this.startBlockchainNode(readyCb);
@ -40,12 +41,17 @@ class Parity {
readyCb(); readyCb();
}); });
this.registerServiceCheck(); this.registerServiceCheck();
}); },
stopFn: async (cb) => {
await this.events.request("processes:stop", "blockchain");
cb();
}
});
} }
shouldInit() { shouldInit() {
return ( return (
this.blockchainConfig.client === constants.blockchain.clients.geth && this.blockchainConfig.client === constants.blockchain.clients.parity &&
this.blockchainConfig.enabled this.blockchainConfig.enabled
); );
} }
@ -64,9 +70,9 @@ class Parity {
this.events.request("services:register", 'Ethereum', (cb) => { this.events.request("services:register", 'Ethereum', (cb) => {
const {rpcHost, rpcPort, wsRPC, wsHost, wsPort} = this.blockchainConfig; const {rpcHost, rpcPort, wsRPC, wsHost, wsPort} = this.blockchainConfig;
if (wsRPC) { if (wsRPC) {
return ws(wsHost, wsPort + 10, (err, version) => this._getNodeState(err, version, cb)); return ws(wsHost, wsPort, (err, version) => this._getNodeState(err, version, cb));
} }
rpc(rpcHost, rpcPort + 10, (err, version) => this._getNodeState(err, version, cb)); rpc(rpcHost, rpcPort, (err, version) => this._getNodeState(err, version, cb));
}, 5000, 'off'); }, 5000, 'off');
} }

View File

@ -0,0 +1,5 @@
{
"compilerOptions": { "baseUrl": ".", "paths": { "*": ["types/*"] } },
"extends": "../../../tsconfig.json",
"include": ["src/**/*"]
}

View File

@ -0,0 +1,3 @@
{
"extends": "../../../tslint.json"
}