From d86c26d71a5b2aa114e5ef2c4a34e0cd7c561156 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Sun, 13 Oct 2019 21:42:13 -0400 Subject: [PATCH] Fix VM as a client and cleanup template configs (#1966) * chore(templates): clean up template configs * fix: enable vm as a client Bug was caused by the web3 listening to events too late (race) --- dapps/templates/boilerplate/config/contracts.js | 17 ++--------------- dapps/templates/boilerplate/config/storage.js | 1 - dapps/templates/demo/config/contracts.js | 16 +--------------- dapps/templates/demo/config/storage.js | 1 - packages/plugins/web3/src/index.js | 4 ++-- 5 files changed, 5 insertions(+), 34 deletions(-) diff --git a/dapps/templates/boilerplate/config/contracts.js b/dapps/templates/boilerplate/config/contracts.js index 68d1ccd12..381f53c76 100644 --- a/dapps/templates/boilerplate/config/contracts.js +++ b/dapps/templates/boilerplate/config/contracts.js @@ -3,6 +3,7 @@ module.exports = { default: { // order of connections the dapp should connect to dappConnection: [ + "$EMBARK", "$WEB3", // uses pre existing web3 object if available (e.g in Mist) "ws://localhost:8546", "http://localhost:8545" @@ -38,26 +39,12 @@ module.exports = { // default environment, merges with the settings in default // assumed to be the intended environment by `embark run` - development: { - dappConnection: [ - "ws://localhost:8546", - "http://localhost:8545", - "$WEB3" // uses pre existing web3 object if available (e.g in Mist) - ] - }, + development: {}, // merges with the settings in default // used with "embark run privatenet" privatenet: {}, - // merges with the settings in default - // used with "embark run testnet" - testnet: {}, - - // merges with the settings in default - // used with "embark run livenet" - livenet: {} - // you can name an environment with specific settings and then specify with // "embark run custom_name" or "embark blockchain custom_name" // custom_name: {} diff --git a/dapps/templates/boilerplate/config/storage.js b/dapps/templates/boilerplate/config/storage.js index d7d539014..2ff6fc495 100644 --- a/dapps/templates/boilerplate/config/storage.js +++ b/dapps/templates/boilerplate/config/storage.js @@ -28,7 +28,6 @@ module.exports = { // default environment, merges with the settings in default // assumed to be the intended environment by `embark run` development: { - enabled: true, upload: { provider: "ipfs", host: "localhost", diff --git a/dapps/templates/demo/config/contracts.js b/dapps/templates/demo/config/contracts.js index 8924b4c90..9b0e36811 100644 --- a/dapps/templates/demo/config/contracts.js +++ b/dapps/templates/demo/config/contracts.js @@ -39,26 +39,12 @@ module.exports = { // default environment, merges with the settings in default // assumed to be the intended environment by `embark run` - development: { - dappConnection: [ - "ws://localhost:8546", - "http://localhost:8545", - "$WEB3" // uses pre existing web3 object if available (e.g in Mist) - ] - }, + development: {}, // merges with the settings in default // used with "embark run privatenet" privatenet: {}, - // merges with the settings in default - // used with "embark run testnet" - testnet: {}, - - // merges with the settings in default - // used with "embark run livenet" - livenet: {} - // you can name an environment with specific settings and then specify with // "embark run custom_name" or "embark blockchain custom_name" // custom_name: {} diff --git a/dapps/templates/demo/config/storage.js b/dapps/templates/demo/config/storage.js index 92e919202..5a7bdf280 100644 --- a/dapps/templates/demo/config/storage.js +++ b/dapps/templates/demo/config/storage.js @@ -28,7 +28,6 @@ module.exports = { // default environment, merges with the settings in default // assumed to be the intended environment by `embark run` development: { - enabled: true, upload: { provider: "ipfs", host: "localhost", diff --git a/packages/plugins/web3/src/index.js b/packages/plugins/web3/src/index.js index 95d68291f..c09d16e48 100644 --- a/packages/plugins/web3/src/index.js +++ b/packages/plugins/web3/src/index.js @@ -26,12 +26,12 @@ class EmbarkWeb3 { } async setupEmbarkJS() { - this.events.request("embarkjs:plugin:register", 'blockchain', 'web3', 'embarkjs-web3'); - await this.events.request2("embarkjs:console:register", 'blockchain', 'web3', 'embarkjs-web3'); this.events.on("blockchain:started", async () => { await this.registerWeb3Object(); this.events.request("embarkjs:console:setProvider", 'blockchain', 'web3', '{web3}'); }); + this.events.request("embarkjs:plugin:register", 'blockchain', 'web3', 'embarkjs-web3'); + await this.events.request2("embarkjs:console:register", 'blockchain', 'web3', 'embarkjs-web3'); } async setupWeb3Api() {