diff --git a/packages/embark/package.json b/packages/embark/package.json index a337753ba..e94734d3a 100644 --- a/packages/embark/package.json +++ b/packages/embark/package.json @@ -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", diff --git a/packages/embark/src/lib/core/engine.js b/packages/embark/src/lib/core/engine.js index d398bcfb8..71dbf8923 100644 --- a/packages/embark/src/lib/core/engine.js +++ b/packages/embark/src/lib/core/engine.js @@ -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'); diff --git a/packages/embark/src/lib/modules/blockchain-client/index.js b/packages/embark/src/lib/modules/blockchain-client/index.js deleted file mode 100644 index 650579db2..000000000 --- a/packages/embark/src/lib/modules/blockchain-client/index.js +++ /dev/null @@ -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; diff --git a/packages/stack/blockchain-client/.npmrc b/packages/stack/blockchain-client/.npmrc new file mode 100644 index 000000000..e031d3432 --- /dev/null +++ b/packages/stack/blockchain-client/.npmrc @@ -0,0 +1,4 @@ +engine-strict = true +package-lock = false +save-exact = true +scripts-prepend-node-path = true diff --git a/packages/stack/blockchain-client/README.md b/packages/stack/blockchain-client/README.md new file mode 100644 index 000000000..712aa7182 --- /dev/null +++ b/packages/stack/blockchain-client/README.md @@ -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). diff --git a/packages/stack/blockchain-client/package.json b/packages/stack/blockchain-client/package.json new file mode 100644 index 000000000..49ed5f45b --- /dev/null +++ b/packages/stack/blockchain-client/package.json @@ -0,0 +1,64 @@ +{ + "name": "embark-blockchain-client", + "version": "4.1.1", + "author": "Iuri Matias ", + "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" + } +}