diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index 3072cd81b..6b8306aec 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -19,6 +19,8 @@ const Templates = { class CodeGenerator { constructor(options) { this.blockchainConfig = options.blockchainConfig || {}; + this.rpcHost = this.blockchainConfig.rpcHost || ''; + this.rpcPort = this.blockchainConfig.rpcPort || ''; this.contractsConfig = options.contractsConfig || {}; this.storageConfig = options.storageConfig || {}; this.communicationConfig = options.communicationConfig || {}; diff --git a/test_apps/test_app/extensions/embark-service/index.js b/test_apps/test_app/extensions/embark-service/index.js index be4f4366e..773c00b13 100644 --- a/test_apps/test_app/extensions/embark-service/index.js +++ b/test_apps/test_app/extensions/embark-service/index.js @@ -23,8 +23,33 @@ module.exports = function (embark) { embark.addFileToPipeline('./fileInPipeline.js'); embark.addFileToPipeline('./fileInPipeline.js', 'js/fileInPipeline.js'); - embark.registerBeforeDeploy(function(options, callback) { + embark.registerBeforeDeploy(function (options, callback) { // Just calling register to prove it works. We don't actually want to change the contracts callback({contractCode: options.contract.code}); }); + + embark.registerClientWeb3Provider(function(options) { + return "web3 = new Web3(new Web3.providers.HttpProvider('http://" + options.rpcHost + ":" + options.rpcPort + "'));"; + }); + + /*embark.registerContractsGeneration(function (options) { + const contractGenerations = []; + Object.keys(options.contracts).map(className => { + const contract = options.contracts[className]; + const abi = JSON.stringify(contract.abiDefinition); + + contractGenerations.push(`${className} = new this.web3.eth.contract('${abi}').at('${contract.deployedAddress}')`); + }); + return contractGenerations.join('\n'); + // return ''; + });*/ + + embark.registerConsoleCommand((cmd) => { + if (cmd === "hello") { + return "hello there!"; + } + // continue to embark or next plugin; + return false; + }); + };