mirror of https://github.com/embarklabs/embark.git
move contractsState from logger to event bus
This commit is contained in:
parent
96df409229
commit
66e9d6afa3
|
@ -11,6 +11,7 @@ class Deploy {
|
||||||
this.web3 = options.web3;
|
this.web3 = options.web3;
|
||||||
this.contractsManager = options.contractsManager;
|
this.contractsManager = options.contractsManager;
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
|
this.events = options.events;
|
||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
this.chainConfig = options.chainConfig;
|
this.chainConfig = options.chainConfig;
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
|
@ -46,7 +47,7 @@ class Deploy {
|
||||||
contract.error = false;
|
contract.error = false;
|
||||||
|
|
||||||
if (contract.deploy === false) {
|
if (contract.deploy === false) {
|
||||||
self.logger.contractsState(self.contractsManager.contractsState());
|
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ class Deploy {
|
||||||
self.deployTracker.trackContract(contract.className, contract.realRuntimeBytecode, realArgs, contract.address);
|
self.deployTracker.trackContract(contract.className, contract.realRuntimeBytecode, realArgs, contract.address);
|
||||||
self.deployTracker.save();
|
self.deployTracker.save();
|
||||||
}
|
}
|
||||||
self.logger.contractsState(self.contractsManager.contractsState());
|
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ class Deploy {
|
||||||
const self = this;
|
const self = this;
|
||||||
self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan);
|
self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan);
|
||||||
contract.deployedAddress = trackedContract.address;
|
contract.deployedAddress = trackedContract.address;
|
||||||
self.logger.contractsState(self.contractsManager.contractsState());
|
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||||
|
|
||||||
// always run contractCode so other functionality like 'afterDeploy' can also work
|
// always run contractCode so other functionality like 'afterDeploy' can also work
|
||||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||||
|
@ -104,7 +105,7 @@ class Deploy {
|
||||||
}
|
}
|
||||||
self.deployTracker.trackContract(contract.className, contract.realRuntimeBytecode, realArgs, address);
|
self.deployTracker.trackContract(contract.className, contract.realRuntimeBytecode, realArgs, address);
|
||||||
self.deployTracker.save();
|
self.deployTracker.save();
|
||||||
self.logger.contractsState(self.contractsManager.contractsState());
|
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||||
|
|
||||||
// always run contractCode so other functionality like 'afterDeploy' can also work
|
// always run contractCode so other functionality like 'afterDeploy' can also work
|
||||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||||
|
@ -298,12 +299,12 @@ class Deploy {
|
||||||
self.logger.info(contract.className.bold.cyan + " deployed at ".green + receipt.contractAddress.bold.cyan);
|
self.logger.info(contract.className.bold.cyan + " deployed at ".green + receipt.contractAddress.bold.cyan);
|
||||||
contract.deployedAddress = receipt.contractAddress;
|
contract.deployedAddress = receipt.contractAddress;
|
||||||
contract.transactionHash = receipt.transactionHash;
|
contract.transactionHash = receipt.transactionHash;
|
||||||
self.logger.contractsState(self.contractsManager.contractsState());
|
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||||
return next(null, receipt.contractAddress);
|
return next(null, receipt.contractAddress);
|
||||||
}
|
}
|
||||||
self.logger.contractsState(self.contractsManager.contractsState());
|
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||||
}).on('error', function(error) {
|
}).on('error', function(error) {
|
||||||
self.logger.contractsState(self.contractsManager.contractsState());
|
self.events.emit('contractsState', self.contractsManager.contractsState());
|
||||||
return next(new Error("error deploying =" + contract.className + "= due to error: " + error.message));
|
return next(new Error("error deploying =" + contract.className + "= due to error: " + error.message));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ class DeployManager {
|
||||||
web3: web3,
|
web3: web3,
|
||||||
contractsManager: contractsManager,
|
contractsManager: contractsManager,
|
||||||
logger: self.logger,
|
logger: self.logger,
|
||||||
|
events: self.events,
|
||||||
chainConfig: self.chainConfig,
|
chainConfig: self.chainConfig,
|
||||||
env: self.config.env,
|
env: self.config.env,
|
||||||
plugins: self.plugins,
|
plugins: self.plugins,
|
||||||
|
|
|
@ -5,8 +5,6 @@ class Logger {
|
||||||
this.logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
|
this.logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
|
||||||
this.logLevel = options.logLevel || 'info';
|
this.logLevel = options.logLevel || 'info';
|
||||||
this.logFunction = options.logFunction || console.log;
|
this.logFunction = options.logFunction || console.log;
|
||||||
this.contractsState = options.contractsState || function () {
|
|
||||||
};
|
|
||||||
this.setStatus = options.setStatus || console.log;
|
this.setStatus = options.setStatus || console.log;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,10 @@ class Dashboard {
|
||||||
function startMonitor(callback) {
|
function startMonitor(callback) {
|
||||||
monitor = new Monitor({env: self.env, console: console});
|
monitor = new Monitor({env: self.env, console: console});
|
||||||
self.logger.logFunction = monitor.logEntry;
|
self.logger.logFunction = monitor.logEntry;
|
||||||
self.logger.contractsState = monitor.setContracts;
|
|
||||||
self.logger.setStatus = monitor.setStatus.bind(monitor);
|
self.logger.setStatus = monitor.setStatus.bind(monitor);
|
||||||
|
|
||||||
|
self.events.on('contractsState', monitor.setContracts);
|
||||||
|
|
||||||
self.logger.info('========================'.bold.green);
|
self.logger.info('========================'.bold.green);
|
||||||
self.logger.info(('Welcome to Embark ' + self.version).yellow.bold);
|
self.logger.info(('Welcome to Embark ' + self.version).yellow.bold);
|
||||||
self.logger.info('========================'.bold.green);
|
self.logger.info('========================'.bold.green);
|
||||||
|
|
Loading…
Reference in New Issue