refactor(@embark/blockchain-client): move module into own package (#1955)

refactor(@embark/blockchain-client): move module into own package

update package.json
This commit is contained in:
Eric Mastro 2019-10-16 22:41:17 +09:00 committed by Iuri Matias
parent e2efbbd846
commit 3b8f8f9ea7
6 changed files with 76 additions and 42 deletions

View File

@ -95,6 +95,7 @@
"embark-authenticator": "^4.1.1",
"embark-basic-pipeline": "^4.1.1",
"embark-blockchain": "^4.1.1",
"embark-blockchain-client": "^4.1.1",
"embark-code-runner": "^4.1.1",
"embark-communication": "^4.1.1",
"embark-compiler": "^4.1.1",

View File

@ -174,7 +174,7 @@ class Engine {
this.registerModulePackage('embark-compiler', {plugins: this.plugins, isCoverage: options.isCoverage});
this.registerModulePackage('embark-contracts-manager', {plugins: this.plugins, compileOnceOnly: options.compileOnceOnly});
this.registerModulePackage('embark-deployment', {plugins: this.plugins, onlyCompile: options.onlyCompile});
this.registerModule('blockchain-client');
this.registerModulePackage('embark-blockchain-client');
this.registerModulePackage('embark-storage');
this.registerModulePackage('embark-communication');
this.registerModulePackage('embark-namesystem');

View File

@ -1,41 +0,0 @@
const Web3 = require('web3');
class BlockchainClient {
constructor(embark, _options) {
this.embark = embark;
this.events = embark.events;
this.blockchainClients = {};
this.client = null;
this.events.setCommandHandler("blockchain:client:register", (clientName, blockchainClient) => {
this.blockchainClients[clientName] = blockchainClient;
this.client = blockchainClient;
});
// TODO: unclear currently if this belongs here so it's a bit hardcoded for now
this.events.setCommandHandler("blockchain:client:provider", (clientName, cb) => {
this.events.request("proxy:endpoint:get", (err, endpoint) => {
if (err) {
return cb(err);
}
const web3 = new Web3(endpoint);
cb(null, web3.currentProvider);
});
});
// TODO: maybe not the ideal event to listen to?
// for e.g, could wait for all stack components to be ready
// TODO: probably better to have 2 stages in engine, services start, then connections, etc..
this.events.on("blockchain:started", (_clientName) => {
// make connections
// this.client.initAndConnect(); // and config options
// should do stuff like
// connect to endpoint given
// set default account
});
}
}
module.exports = BlockchainClient;

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-blockchain-client`
> Provides ability to register a blockchain technology in Embark, ie Ethereum.
Visit [embark.status.im](https://embark.status.im/) to get started with
[Embark](https://github.com/embark-framework/embark).

View File

@ -0,0 +1,64 @@
{
"name": "embark-blockchain-client",
"version": "4.1.1",
"author": "Iuri Matias <iuri.matias@gmail.com>",
"contributors": [],
"description": "Provides ability to register a blockchain technology in Embark, ie Ethereum.",
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/blockchain-client/proxy#readme",
"bugs": "https://github.com/embark-framework/embark/issues",
"keywords": [
"blockchain",
"dapps",
"ethereum",
"ipfs",
"serverless",
"solc",
"solidity"
],
"files": [
"dist"
],
"license": "MIT",
"repository": {
"directory": "packages/stack/blockchain-client",
"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",
"web3": "1.2.1"
},
"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"
}
}