mirror of https://github.com/embarklabs/embark.git
conflict in code_generator
This commit is contained in:
parent
30b1975e34
commit
592b4ed4fd
|
@ -26,6 +26,7 @@ class CodeGenerator {
|
|||
this.contractsConfig = options.contractsConfig || {};
|
||||
this.storageConfig = options.storageConfig || {};
|
||||
this.communicationConfig = options.communicationConfig || {};
|
||||
// TODO: this should also be removed and use events instead
|
||||
this.contractsManager = options.contractsManager;
|
||||
this.plugins = options.plugins;
|
||||
this.events = options.events;
|
||||
|
@ -107,6 +108,10 @@ class CodeGenerator {
|
|||
self.buildContractJS(contractName, self.generateContractJSON(contractName, contract), cb);
|
||||
});
|
||||
|
||||
self.events.setCommandHandler('code-generator:contract:vanilla', (contract, gasLimit, cb) => {
|
||||
cb(self.generateContractCode(contract, gasLimit));
|
||||
});
|
||||
|
||||
this.events.setCommandHandler('embark-building-placeholder', (cb) => {
|
||||
this.buildPlaceholderPage(cb);
|
||||
});
|
||||
|
|
|
@ -4,13 +4,10 @@ let utils = require('../utils/utils.js');
|
|||
|
||||
let RunCode = require('../core/runCode.js');
|
||||
|
||||
let CodeGenerator = require('./code_generator.js');
|
||||
|
||||
class Deploy {
|
||||
constructor(options) {
|
||||
this.blockchain = options.blockchain;
|
||||
this.web3 = this.blockchain.web3;
|
||||
this.contractsManager = options.contractsManager;
|
||||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
this.plugins = options.plugins;
|
||||
|
@ -129,12 +126,12 @@ class Deploy {
|
|||
contract.deployedAddress = trackedContract.address;
|
||||
self.events.emit("deploy:contract:deployed", contract);
|
||||
|
||||
// always run contractCode so other functionality like 'afterDeploy' can also work
|
||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||
let contractCode = codeGenerator.generateContractCode(contract, self.gasLimit);
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
|
||||
return callback();
|
||||
// TODO: can be moved into a afterDeploy event
|
||||
// just need to figure out the gasLimit coupling issue
|
||||
self.events.request('code-generator:contract:vanilla', contract, self.gasLimit, (contractCode) => {
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
|
||||
contractToDeploy(contract, params, callback) {
|
||||
|
@ -152,18 +149,21 @@ class Deploy {
|
|||
contract.address = address;
|
||||
self.events.emit("deploy:contract:deployed", contract);
|
||||
|
||||
// always run contractCode so other functionality like 'afterDeploy' can also work
|
||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||
let contractCode = codeGenerator.generateContractCode(contract, self.gasLimit);
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
// TODO: can be moved into a afterDeploy event
|
||||
// just need to figure out the gasLimit coupling issue
|
||||
self.events.request('code-generator:contract:vanilla', contract, self.gasLimit, (contractCode) => {
|
||||
RunCode.doEval(contractCode, self.web3);
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
|
||||
let onDeployPlugins = self.plugins.getPluginsProperty('onDeployActions', 'onDeployActions');
|
||||
let onDeployPlugins = self.plugins.getPluginsProperty('onDeployActions', 'onDeployActions');
|
||||
|
||||
async.eachLimit(onDeployPlugins, 1, function(plugin, nextEach) {
|
||||
plugin.call(plugin, contract, nextEach);
|
||||
}, () => {
|
||||
callback();
|
||||
async.eachLimit(onDeployPlugins, 1, function(plugin, nextEach) {
|
||||
plugin.call(plugin, contract, nextEach);
|
||||
}, () => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -162,18 +162,19 @@ class Engine {
|
|||
codeGeneratorService(_options) {
|
||||
let self = this;
|
||||
|
||||
const generateCode = function (contractsManager) {
|
||||
let codeGenerator = new CodeGenerator({
|
||||
blockchainConfig: self.config.blockchainConfig,
|
||||
contractsConfig: self.config.contractsConfig,
|
||||
contractsManager: contractsManager,
|
||||
plugins: self.plugins,
|
||||
storageConfig: self.config.storageConfig,
|
||||
communicationConfig: self.config.communicationConfig,
|
||||
events: self.events
|
||||
});
|
||||
codeGenerator.listenToCommands();
|
||||
codeGenerator.buildEmbarkJS(function() {
|
||||
this.codeGenerator = new CodeGenerator({
|
||||
blockchainConfig: self.config.blockchainConfig,
|
||||
contractsConfig: self.config.contractsConfig,
|
||||
contractsManager: this.contractsManager,
|
||||
plugins: self.plugins,
|
||||
storageConfig: self.config.storageConfig,
|
||||
communicationConfig: self.config.communicationConfig,
|
||||
events: self.events
|
||||
});
|
||||
this.codeGenerator.listenToCommands();
|
||||
|
||||
const generateCode = function () {
|
||||
self.codeGenerator.buildEmbarkJS(function() {
|
||||
self.events.emit('code-generator-ready');
|
||||
});
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ EventEmitter.prototype.request = function() {
|
|||
};
|
||||
|
||||
EventEmitter.prototype.setCommandHandler = function(requestName, cb) {
|
||||
log("setting command handler for: ", requestName);
|
||||
log("setting command handler for: " + requestName);
|
||||
let listener = function(_cb) {
|
||||
cb.call(this, ...arguments);
|
||||
};
|
||||
|
|
|
@ -130,8 +130,8 @@ class Embark {
|
|||
engine.startService("libraryManager");
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("codeGenerator");
|
||||
engine.startService("deployment");
|
||||
engine.startService("codeGenerator");
|
||||
// TODO: this should be just 'storage' and the storage should figure out the module
|
||||
engine.startService(engine.config.storageConfig.provider);
|
||||
|
||||
|
@ -204,8 +204,8 @@ class Embark {
|
|||
engine.startService("libraryManager");
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("codeGenerator");
|
||||
engine.startService("deployment", {onlyCompile: options.onlyCompile});
|
||||
engine.startService("codeGenerator");
|
||||
// TODO: this should be just 'storage' and the storage should figure out the modules to load
|
||||
engine.startService("ipfs");
|
||||
engine.startService("swarm");
|
||||
|
@ -260,8 +260,8 @@ class Embark {
|
|||
engine.startMonitor();
|
||||
engine.startService("libraryManager");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("codeGenerator");
|
||||
engine.startService("deployment", {onlyCompile: true});
|
||||
engine.startService("codeGenerator");
|
||||
|
||||
engine.deployManager.deployContracts(function (err) {
|
||||
callback(err);
|
||||
|
@ -319,8 +319,8 @@ class Embark {
|
|||
engine.startService("libraryManager");
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("codeGenerator");
|
||||
engine.startService("deployment");
|
||||
engine.startService("codeGenerator");
|
||||
// TODO: this should be just 'storage' and the storage should figure out the modules to load
|
||||
engine.startService(platform.toLowerCase());
|
||||
engine.startMonitor();
|
||||
|
|
|
@ -68,13 +68,13 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
|
|||
function startServices(callback) {
|
||||
//{abiType: 'contracts', embarkJS: false}
|
||||
self.engine.startService("libraryManager");
|
||||
self.engine.startService("codeGenerator");
|
||||
self.engine.startService("web3", {
|
||||
web3: self.web3
|
||||
});
|
||||
self.engine.startService("deployment", {
|
||||
trackContracts: false
|
||||
});
|
||||
self.engine.startService("codeGenerator");
|
||||
callback();
|
||||
},
|
||||
function deploy(callback) {
|
||||
|
|
Loading…
Reference in New Issue