Merge pull request #682 from embark-framework/features/hide-contract-logs

Hide ENS logs etc
This commit is contained in:
Iuri Matias 2018-08-08 12:08:25 -04:00 committed by GitHub
commit 8be21d0b17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 12 deletions

View File

@ -148,7 +148,12 @@ class ContractsManager {
}
if (contract.code === "") {
self.logger.info(__("assuming %s to be an interface", className));
const message = __("assuming %s to be an interface", className);
if (contract.silent) {
self.logger.trace(message);
} else {
self.logger.info(message);
}
contract.deploy = false;
}
}
@ -403,6 +408,9 @@ class ContractsManager {
for (let className in this.contracts) {
let contract = this.contracts[className];
if (contract.silent) {
continue;
}
let contractData;

View File

@ -145,6 +145,7 @@ class ContractDeployer {
let contractParams = (contract.realArgs || contract.args).slice();
let deploymentAccount = self.blockchain.defaultAccount();
let deployObject;
const logFunction = contract.silent ? self.logger.trace.bind(self.logger) : self.logger.info.bind(self.logger);
async.waterfall([
// TODO: can potentially go to a beforeDeploy plugin
@ -235,7 +236,8 @@ class ContractDeployer {
},
function deployTheContract(next) {
let estimatedCost = contract.gas * contract.gasPrice;
self.logger.info(__("deploying") + " " + contract.className.bold.cyan + " " + __("with").green + " " + contract.gas + " " + __("gas at the price of").green + " " + contract.gasPrice + " " + __("Wei, estimated cost:").green + " " + estimatedCost + " Wei".green);
logFunction(__("deploying") + " " + contract.className.bold.cyan + " " + __("with").green + " " + contract.gas + " " + __("gas at the price of").green + " " + contract.gasPrice + " " + __("Wei, estimated cost:").green + " " + estimatedCost + " Wei".green);
self.blockchain.deployContractFromObject(deployObject, {
from: contract.deploymentAccount,
@ -247,7 +249,7 @@ class ContractDeployer {
self.events.emit("deploy:contract:error", contract);
return next(new Error("error deploying =" + contract.className + "= due to error: " + error.message));
}
self.logger.info(contract.className.bold.cyan + " " + __("deployed at").green + " " + receipt.contractAddress.bold.cyan + " " + __("using").green + " " + receipt.gasUsed + " " + __("gas").green);
logFunction(contract.className.bold.cyan + " " + __("deployed at").green + " " + receipt.contractAddress.bold.cyan + " " + __("using").green + " " + receipt.gasUsed + " " + __("gas").green);
contract.deployedAddress = receipt.contractAddress;
contract.transactionHash = receipt.transactionHash;
receipt.className = contract.className;

View File

@ -210,16 +210,24 @@ class ENS {
configureContracts() {
const config = {
"default": {
"gas": "auto"
"gas": "auto",
"contracts": {
"ENS": {
"deploy": false,
"silent": true
}
}
},
"development": {
"contracts": {
"ENSRegistry": {
"deploy": true,
"silent": true,
"args": []
},
"Resolver": {
"deploy": true,
"silent": true,
"args": ["$ENSRegistry"]
},
"FIFSRegistrar": {
@ -230,7 +238,8 @@ class ENS {
"ropsten": {
"contracts": {
"ENSRegistry": {
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010"
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
"silent": true
},
"Resolver": {
"deploy": false
@ -243,7 +252,8 @@ class ENS {
"rinkeby": {
"contracts": {
"ENSRegistry": {
"address": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A"
"address": "0xe7410170f87102DF0055eB195163A03B7F2Bff4A",
"silent": true
},
"Resolver": {
"deploy": false
@ -256,7 +266,8 @@ class ENS {
"livenet": {
"contracts": {
"ENSRegistry": {
"address": "0x314159265dd8dbb310642f98f50c066173c1259b"
"address": "0x314159265dd8dbb310642f98f50c066173c1259b",
"silent": true
},
"Resolver": {
"deploy": false
@ -273,6 +284,7 @@ class ENS {
const rootNode = namehash.hash(this.registration.rootDomain);
config.development.contracts['FIFSRegistrar'] = {
"deploy": true,
"silent": true,
"args": ["$ENSRegistry", rootNode],
"onDeploy": [
`ENSRegistry.methods.setOwner('${rootNode}', web3.eth.defaultAccount).send().then(() => {

View File

@ -63,10 +63,11 @@ class SpecialConfigs {
});
}
runOnDeployCode(onDeployCode, callback) {
runOnDeployCode(onDeployCode, callback, silent) {
const self = this;
const logFunction = silent ? self.logger.trace.bind(self.logger) : self.logger.info.bind(self.logger);
async.each(onDeployCode, (cmd, eachCb) => {
self.logger.info("==== executing: " + cmd);
logFunction("==== executing: " + cmd);
self.events.request('runcode:eval', cmd, (err) => {
if (err && err.message.indexOf("invalid opcode") >= 0) {
self.logger.error('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation');
@ -85,8 +86,9 @@ class SpecialConfigs {
if (!contract.onDeploy) {
return cb();
}
self.logger.info(__('executing onDeploy commands'));
if (!contract.silent) {
self.logger.info(__('executing onDeploy commands'));
}
let onDeployCmds = contract.onDeploy;
@ -97,7 +99,7 @@ class SpecialConfigs {
return cb(new Error("error running onDeploy for " + contract.className.cyan));
}
self.runOnDeployCode(onDeployCode, cb);
self.runOnDeployCode(onDeployCode, cb, contract.silent);
});
});
}