add more registers but generation one fails in run

This commit is contained in:
Jonathan Rainville 2018-04-25 16:27:47 -04:00
parent 61be2c7bd7
commit e4566f9f81
2 changed files with 28 additions and 1 deletions

View File

@ -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 || {};

View File

@ -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;
});
};