diff --git a/boilerplate/config/blockchain.json b/boilerplate/config/blockchain.json index ee83f1006..3453a87d7 100644 --- a/boilerplate/config/blockchain.json +++ b/boilerplate/config/blockchain.json @@ -1,5 +1,6 @@ { "development": { + "enabled": true, "networkType": "custom", "genesisBlock": "config/development/genesis.json", "datadir": ".embark/development/datadir", @@ -14,6 +15,7 @@ } }, "testnet": { + "enabled": true, "networkType": "testnet", "light": true, "rpcHost": "localhost", @@ -24,6 +26,7 @@ } }, "livenet": { + "enabled": true, "networkType": "livenet", "light": true, "rpcHost": "localhost", @@ -34,6 +37,7 @@ } }, "privatenet": { + "enabled": true, "networkType": "custom", "rpcHost": "localhost", "rpcPort": 8545, diff --git a/boilerplate/config/communication.json b/boilerplate/config/communication.json index fb96acac5..264cc646f 100644 --- a/boilerplate/config/communication.json +++ b/boilerplate/config/communication.json @@ -1,5 +1,6 @@ { "default": { + "enabled": true, "provider": "whisper" } } diff --git a/demo/config/blockchain.json b/demo/config/blockchain.json index ffa089803..0bc6ca2cc 100644 --- a/demo/config/blockchain.json +++ b/demo/config/blockchain.json @@ -1,5 +1,6 @@ { "development": { + "enabled": true, "networkType": "custom", "genesisBlock": "config/development/genesis.json", "datadir": ".embark/development/datadir", @@ -14,6 +15,7 @@ } }, "testnet": { + "enabled": true, "networkType": "testnet", "light": true, "rpcHost": "localhost", @@ -24,6 +26,7 @@ } }, "livenet": { + "enabled": true, "networkType": "livenet", "light": true, "rpcHost": "localhost", @@ -34,6 +37,7 @@ } }, "privatenet": { + "enabled": true, "networkType": "custom", "rpcHost": "localhost", "rpcPort": 8545, diff --git a/demo/config/communication.json b/demo/config/communication.json index fb96acac5..264cc646f 100644 --- a/demo/config/communication.json +++ b/demo/config/communication.json @@ -1,5 +1,6 @@ { "default": { + "enabled": true, "provider": "whisper" } } diff --git a/lib/contracts/abi.js b/lib/contracts/abi.js index 580144099..f6f175d0b 100644 --- a/lib/contracts/abi.js +++ b/lib/contracts/abi.js @@ -66,7 +66,7 @@ ABIGenerator.prototype.generateContracts = function(useEmbarkJS) { return result; }; -ABIGenerator.prototype.generateStorageInitialiation = function(useEmbarkJS) { +ABIGenerator.prototype.generateStorageInitialization = function(useEmbarkJS) { var self = this; var result = "\n"; @@ -79,13 +79,28 @@ ABIGenerator.prototype.generateStorageInitialiation = function(useEmbarkJS) { return result; }; +ABIGenerator.prototype.generateCommunicationInitialization = function(useEmbarkJS) { + var self = this; + var result = "\n"; + + if (!useEmbarkJS || self.communicationConfig === {}) return; + + if (self.communicationConfig.provider === 'ipfs' && self.communicationConfig.enabled === true) { + result += "\n" + "EmbarkJS.Storage.setProvider('" + self.communicationConfig.provider + "');"; + } else if (self.communicationConfig.provider === 'orbit' && self.communicationConfig.enabled === true) { + result += "\n" + "EmbarkJS.Storage.setProvider('" + self.communicationConfig.provider + "', {server: '" + self.communicationConfig.host + "', port: '" + self.communicationConfig.port + "'});"; + } + + return result; +}; ABIGenerator.prototype.generateABI = function(options) { var result = ""; result += this.generateProvider(); result += this.generateContracts(options.useEmbarkJS); - result += this.generateStorageInitialiation(options.useEmbarkJS); + result += this.generateStorageInitialization(options.useEmbarkJS); + result += this.generateCommunicationInitialization(options.useEmbarkJS); return result; };