remove console logs; fix events

This commit is contained in:
Iuri Matias 2019-08-23 11:42:26 -04:00
parent 13df7b57ca
commit 661f390650
19 changed files with 1 additions and 91 deletions

View File

@ -58,13 +58,8 @@ class CodeRunner {
return cb(null, "");
}
console.dir("running");
console.dir(code);
this.vm.doEval(code, tolerateError, (err, result) => {
if (err) {
console.dir("error")
console.dir(err)
return cb(err);
}

View File

@ -18,9 +18,6 @@ class Compiler {
}
private compile_contracts(contractFiles: any[], cb: any) {
console.dir("----- compile_contracts")
console.dir(contractFiles)
console.dir(cb)
if (contractFiles.length === 0) {
return cb(null, {});
}

View File

@ -38,8 +38,6 @@ class ContractsManager {
cb(null, this.contracts[contract.className]);
});
console.dir("---- contracts manager---- ");
// this.registerCommands()
// this.registerAPIs()
}
@ -536,7 +534,6 @@ class ContractsManager {
self.compileError = false;
}
self.logger.trace("finished".underline);
console.dir("done!!");
done(err, self.contracts, self.contractDependencies);
});

View File

@ -44,7 +44,6 @@ class Deployment {
}
deployContract(contract, callback) {
console.dir("requesting to deploy contract")
this.events.request('deployment:contract:deploy', contract, (err) => {
if (err) {
contract.error = err.message || err;
@ -61,13 +60,11 @@ class Deployment {
deployAll(contracts, contractDependencies, done) {
const self = this;
console.dir("doing deployAll")
const contractDeploys = {};
const errors = [];
Object.values(contracts).forEach((contract) => {
function deploy(result, callback) {
console.dir("== deploy")
if (typeof result === 'function') callback = result;
self.deployContract(contract, (err) => {
if (err) {

View File

@ -226,8 +226,6 @@ class IPFS {
}
self.logger.trace(`Storage module: Launching ipfs process...`);
return this.storageProcessesLauncher.launchProcess('ipfs', (err) => {
console.dir("--- launchProcess callback")
console.dir(err)
callback(err, true);
});
});

View File

@ -81,9 +81,7 @@ class IPFS {
], function (err, dir_hash) {
if (err) {
console.log(__("error uploading to ipfs").red);
console.log("---------------");
console.dir(err);
console.log("---------------");
cb(err);
}
else cb(null, dir_hash);

View File

@ -22,8 +22,6 @@ class Pipeline {
}
generateAll(cb) {
console.dir("generating all files");
async.waterfall([
(next) => {
this.plugins.runActionsForEvent("pipeline:generateAll:before", {}, (err) => {

View File

@ -194,19 +194,14 @@ class TestRunner {
return next(err);
}
console.log('got accounts from web3');
console.dir(accts);
accounts = accts;
next();
});
},
(next) => { // get contract files
console.log('getting contract files');
events.request("config:contractsFiles", next);
},
(cf, next) => { // compile contracts
console.log('compiling contracts');
console.dir(cf);
events.request("compiler:contracts:compile", cf, next);
},
(cc, next) => { // override require

View File

@ -7,7 +7,6 @@ let <%- className %> = new web3.eth.Contract(<%- className %>Abi);
<%- className %>.options.from = web3.eth.defaultAccount;
web3.execWhenReady(() => {
console.dir("running execWhenReady")
<%- className %>.options.from = web3.eth.defaultAccount;
if (!<%- className %>.currentProvider) {
<%- className %>.setProvider(web3.currentProvider);

View File

@ -6,9 +6,7 @@ let todo = [];
let done = false;
web3.execWhenReady = function(cb) {
console.dir("adding execWhenReady")
if (done) {
console.dir("already done")
return cb();
}
todo.push(cb);
@ -93,8 +91,6 @@ let doConnect = function(connectionList, opts, doneCb) {
if (connectionString === '$WEB3') {
connectWeb3(next);
} else if (connectionString.indexOf('ws://') >= 0) {
console.dir("connectionString")
console.dir(connectionString)
connectWebsocket(connectionString, next);
} else {
connectHttp(connectionString, next);
@ -140,8 +136,6 @@ let doConnect = function(connectionList, opts, doneCb) {
__whenEnvIsLoaded(() => {
let connectList = [<%- connectionList.map(x => "'" + x + "'").join(",") %>];
console.dir(connectList);
console.log("test2")
doConnect(connectList, {
warnAboutMetamask: false, // TODO: can/should be part as the code generation instead...

View File

@ -62,7 +62,6 @@ class EmbarkController {
engine.startService("blockchain");
engine.startEngine(() => {
console.dir("done!")
// callback();
});
});
@ -176,9 +175,7 @@ class EmbarkController {
engine.registerModulePackage('embark-deploy-tracker', {plugins: engine.plugins});
engine.events.on('deployment:deployContracts:afterAll', () => {
console.dir("--- generating files...")
engine.events.request('pipeline:generateAll', () => {
console.dir("outputDone")
engine.events.emit('outputDone');
});
});
@ -214,7 +211,6 @@ class EmbarkController {
engine.events.on('file-event', async ({fileType, path}) => {
// TODO: re-add async.cargo / or use rxjs to use latest request in the queue
console.dir("-- before timeout - file changed")
if (fileType === 'contract' || fileType === 'config') {
try {
@ -224,7 +220,6 @@ class EmbarkController {
}
} else if (fileType === 'asset') {
engine.events.request('pipeline:generateAll', () => {
console.dir("outputDone")
engine.events.emit('outputDone');
});
}
@ -242,7 +237,6 @@ class EmbarkController {
let contractsConfig = cloneDeep(_contractsConfig);
let [contractsList, contractDependencies] = await engine.events.request2("contracts:build", contractsConfig, compiledContracts);
await engine.events.request2("deployment:contracts:deploy", contractsList, contractDependencies);
console.dir("deployment done");
await engine.events.request2("watcher:start");
} catch (e) {
@ -874,7 +868,6 @@ class EmbarkController {
}
runTests(options) {
console.dir(options);
this.context = [constants.contexts.test];
const Engine = require('../lib/core/engine.js');
@ -916,7 +909,6 @@ class EmbarkController {
let plugin = engine.plugins.createPlugin('cmdcontrollerplugin', {});
plugin.registerActionForEvent("embark:engine:started", async (_params, cb) => {
console.dir(engine.config.blockchainConfig);
await engine.events.request2("blockchain:node:start", engine.config.blockchainConfig, cb);
});

View File

@ -60,7 +60,6 @@ class Dashboard {
// this.events.on('contractsState', monitor.setContracts);
this.events.on("deployment:contract:error", (_contract) => {
console.dir("---- contract error event")
this.events.request("contracts:state", (err, contracts) => {
monitor.setContracts(contracts)
});
@ -68,7 +67,6 @@ class Dashboard {
});
this.events.on("deployment:contract:deployed", (_contract) => {
console.dir("---- contract deployed event")
// self.events.emit('contractsState', self.contractsState());
this.events.request("contracts:state", (err, contracts) => {
monitor.setContracts(contracts)
@ -76,7 +74,6 @@ class Dashboard {
});
this.events.on("deployment:contract:undeployed", (_contract) => {
console.dir("---- contract undeployed event")
// self.events.emit('contractsState', self.contractsState());
this.events.request("contracts:state", (err, contracts) => {
monitor.setContracts(contracts)

View File

@ -134,7 +134,6 @@ class Engine {
let plugin = this.plugins.createPlugin('coreservicesplugin', {});
plugin.registerActionForEvent("embark:engine:started", (_params, cb) => {
console.dir("----- startMonitor")
this.servicesMonitor.startMonitor();
cb();
});

View File

@ -32,6 +32,7 @@ function log(eventType, eventName, origin) {
// origin = getOrigin();
}
fs.ensureDirSync(".embark/");
fs.appendFileSync(".embark/events.log", eventType + ": " + eventName + " -- (" + origin + ")\n");
}
@ -96,7 +97,6 @@ EmbarkEmitter.prototype.request2 = function() {
let other_args = [].slice.call(arguments, 1);
log("\nREQUEST", requestName);
console.log("requesting: " + requestName);
warnIfLegacy(requestName);
if (this._events && !this._events['request:' + requestName]) {
log("NO REQUEST LISTENER", requestName)
@ -105,8 +105,6 @@ EmbarkEmitter.prototype.request2 = function() {
}
let promise = new Promise((resolve, reject) => {
console.dir("emitting... " + requestName)
other_args.push(
(err, ...res) => {
if (err) return reject(err);
@ -117,10 +115,6 @@ EmbarkEmitter.prototype.request2 = function() {
}
)
console.dir("----- other_args")
console.dir(other_args)
// this.emit('request:' + requestName, ...other_args)
this._emit('request:' + requestName, ...other_args)
});
@ -132,7 +126,6 @@ EmbarkEmitter.prototype.request = function() {
let other_args = [].slice.call(arguments, 1);
log("\nREQUEST(OLD)", requestName);
console.log("requesting: " + requestName);
warnIfLegacy(requestName);
if (this._events && !this._events['request:' + requestName]) {
log("NO REQUEST LISTENER", requestName)
@ -167,12 +160,6 @@ EmbarkEmitter.prototype.setCommandHandler = function(requestName, cb) {
let listener = function(_cb) {
log("== REQUEST RESPONSE", requestName, origin);
console.dir(requestName)
// console.dir(cb)
// console.dir(Object.getOwnPropertyNames(cb))
// console.dir(cb.length)
// console.dir(Object.values(cb))
// process.exit(0)
cb.call(this, ...arguments);
};
const listenerName = 'request:' + requestName;

View File

@ -59,8 +59,6 @@ ServicesMonitor.prototype.addCheck = function (checkName, checkFn, time, initial
this.logger.trace('add check: ' + checkName);
this.checkList[checkName] = {fn: checkFn, interval: time || 5000, status: initialState};
console.dir("this.working")
console.dir(this.working)
if (this.working) {
this.initCheck(checkName);
}

View File

@ -37,7 +37,6 @@ class BasicPipeline {
}
webpackAssets(params, done) {
console.dir("=======================> webpackAssets");
let self = this;
let placeholderPage;
const importsList = {};
@ -50,13 +49,11 @@ class BasicPipeline {
async.waterfall([
(next) => {
console.dir("=======================> importsList");
importsList["Embark/EmbarkJS"] = dappPath(self.embarkConfig.generationDir, 'embarkjs.js');
importsList["Embark/contracts"] = this.embarkConfig.generationDir;
next();
},
function shouldRunWebpack(next) {
console.dir("=======================> shouldRunWebpack");
// assuming we got here because an asset was changed, let's check our webpack config
// to see if the changed asset requires webpack to run
if (!(modifiedAssets && modifiedAssets.length)) return next(null, false);
@ -73,7 +70,6 @@ class BasicPipeline {
});
},
function runWebpack(shouldNotRun, next) {
console.dir("=======================> runWebpack");
if (shouldNotRun) return next();
const assets = Object.keys(self.assetFiles).filter(key => key.match(/\.js$/));
if (!assets || !assets.length) {
@ -135,7 +131,6 @@ class BasicPipeline {
});
},
function assetFileWrite(next) {
console.dir("=======================> assetFileWrite 136");
async.eachOf(
// assetFileWrite should not process .js files
Object.keys(self.assetFiles)
@ -145,20 +140,17 @@ class BasicPipeline {
return obj;
}, {}),
function (files, targetFile, cb) {
console.dir("== eachOf: " + targetFile);
const isDir = targetFile.slice(-1) === '/' || targetFile.slice(-1) === '\\' || targetFile.indexOf('.') === -1;
// if it's not a directory
if (!isDir) {
self.logger.info('Pipeline: '.cyan + __("_1_ writing file") + " " + (joinPath(self.buildDir, targetFile)).bold.dim);
}
console.dir("async.map")
// async.map(
async.mapLimit(
files,
1,
function (file, fileCb) {
self.logger.trace("reading " + file.path);
console.dir(":::::::: reading " + file.path);
file.content.then((fileContent) => {
self.runPlugins(file, fileContent, fileCb);
}).catch(fileCb);
@ -167,7 +159,6 @@ class BasicPipeline {
try {
if (err) {
self.logger.error('Pipeline: '.cyan + __('errors found while generating') + ' ' + targetFile);
console.dir(err);
}
let dir = targetFile.split('/').slice(0, -1).join('/');
self.logger.trace(`${'Pipeline:'.cyan} creating dir ` + joinPath(self.buildDir, dir));
@ -175,16 +166,12 @@ class BasicPipeline {
// if it's a directory
if (isDir) {
console.dir("---> isDir")
let targetDir = targetFile;
if (targetDir.slice(-1) !== '/') {
targetDir = targetDir + '/';
}
console.dir("===> contentFiles")
console.dir(contentFiles)
console.dir("----------")
async.each(contentFiles, function (file, eachCb) {
let filename = file.path.replace(file.basedir + '/', '');
self.logger.info(`${'Pipeline:'.cyan} __ writing file ` + (joinPath(self.buildDir, targetDir, filename)).bold.dim);
@ -194,7 +181,6 @@ class BasicPipeline {
return;
}
console.dir("---> not a dir")
let content = contentFiles.map(file => {
if (file === undefined) {
return "";
@ -206,7 +192,6 @@ class BasicPipeline {
targetFile = targetFile.replace('index', 'index-temp');
placeholderPage = targetFile;
}
console.dir("--> writing file")
self.fs.writeFile(joinPath(self.buildDir, targetFile), content, cb);
} catch(err) {
console.dir(err)
@ -218,7 +203,6 @@ class BasicPipeline {
);
},
function removePlaceholderPage(next) {
console.dir("=======================> removePlaceholderPage");
let placeholderFile = joinPath(self.buildDir, placeholderPage);
self.fs.access(joinPath(self.buildDir, placeholderPage), (err) => {
if (err) return next(); // index-temp doesn't exist, do nothing

View File

@ -34,7 +34,6 @@ class EthereumBlockchainClient {
let accounts = await web3.eth.getAccounts();
let account = accounts[0];
// let contractObject = this.blockchain.ContractObject({abi: contract.abiDefinition});
console.dir("== ethereum contract deployer");
let contractObj = new web3.eth.Contract(contract.abiDefinition, contract.address);
// let deployObject = this.blockchain.deployContractObject(contractObject, {arguments: contractParams, data: dataCode});
let contractObject = contractObj.deploy({arguments: (contract.args || []), data: ("0x" + contract.code)});
@ -50,10 +49,6 @@ class EthereumBlockchainClient {
contract.gasPrice = contract.gasPrice || gasPrice;
}
// this.blockchain.deployContractFromObject(deployObject,
console.dir({arguments: contract.args, data: ("0x" + contract.code)});
console.dir("------- send");
embarkJsUtils.secureSend(web3, contractObject, {
from: account, gas: contract.gas
}, true, (err, receipt) => {
@ -65,7 +60,6 @@ class EthereumBlockchainClient {
contract.log(`${contract.className.bold.cyan} ${__('deployed at').green} ${receipt.contractAddress.bold.cyan} ${__("using").green} ${receipt.gasUsed} ${__("gas").green} (txHash: ${receipt.transactionHash.bold.cyan})`);
done(err, receipt);
}, (hash) => {
console.dir('hash is ' + hash);
});
// })
}
@ -73,8 +67,6 @@ class EthereumBlockchainClient {
async doLinking(params, callback) {
let contract = params.contract;
console.dir("= doLinking");
if (!contract.linkReferences || !Object.keys(contract.linkReferences).length) {
return callback(null, params);
}
@ -205,7 +197,6 @@ class EthereumBlockchainClient {
}
addContractJSONToPipeline(params, cb) {
console.dir("-- addContractJSONToPipeline");
// TODO: check if this is correct json object to generate
const contract = params.contract;

View File

@ -15,15 +15,12 @@ class Geth {
this.isDev = options.isDev;
this.events = embark.events;
this.plugins = options.plugins;
// let plugin = this.plugins.createPlugin('gethplugin', {});
if (!this.shouldInit()) {
return;
}
this.events.request("blockchain:node:register", constants.blockchain.clients.geth, (readyCb) => {
console.dir('registering blockchain node');
console.dir(readyCb);
this.events.request('processes:register', 'blockchain', {
launchFn: (cb) => {
// this.startBlockchainNode(readyCb);
@ -71,7 +68,6 @@ class Geth {
}
startBlockchainNode(callback) {
console.log('startBlockchainNode');
this.blockchainProcess = new BlockchainProcessLauncher({
events: this.events,
logger: this.logger,

View File

@ -22,8 +22,6 @@ class Parity {
}
this.events.request("blockchain:node:register", constants.blockchain.clients.parity, (readyCb) => {
console.dir('registering blockchain node');
console.dir(readyCb);
this.events.request('processes:register', 'blockchain', {
launchFn: (cb) => {
// this.startBlockchainNode(readyCb);