From deb54e535c79fbad8821fe1678fd7013f1af41c0 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 21 Jun 2018 11:41:44 -0400 Subject: [PATCH] fix indentation --- lib/modules/console_listener/index.js | 152 +++++++++++++------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/lib/modules/console_listener/index.js b/lib/modules/console_listener/index.js index 210b6ae2..7d5082a6 100644 --- a/lib/modules/console_listener/index.js +++ b/lib/modules/console_listener/index.js @@ -1,92 +1,92 @@ const utils = require('../../utils/utils.js'); class ConsoleListener { - constructor(embark, options) { - this.logger = embark.logger; - this.ipc = options.ipc; - this.events = embark.events; - this.addressToContract = []; - this.contractsConfig = embark.config.contractsConfig; - this.contractsDeployed = false; - this._listenForLogRequests(); + constructor(embark, options) { + this.logger = embark.logger; + this.ipc = options.ipc; + this.events = embark.events; + this.addressToContract = []; + this.contractsConfig = embark.config.contractsConfig; + this.contractsDeployed = false; + this._listenForLogRequests(); - this.events.on("contractsDeployed", () => { - this.contractsDeployed = true; - this._updateContractList(); - }); - } + this.events.on("contractsDeployed", () => { + this.contractsDeployed = true; + this._updateContractList(); + }); + } - _updateContractList(){ - this.events.request("contracts:list", (_err, contractsList) => { - if(_err) { - this.logger.error(__("no contracts found")); - return; - } - contractsList.forEach(contract => { - if(!contract.deployedAddress) return; - - let address = contract.deployedAddress.toLowerCase(); - if(!this.addressToContract[address]){ - let funcSignatures = {}; - contract.abiDefinition - .filter(func => func.type == "function") - .map(func => { - const name = func.name + - '(' + - (func.inputs ? func.inputs.map(input => input.type).join(',') : '') + - ')'; - funcSignatures[utils.sha3(name).substring(0, 10)] = { - name, - abi: func, - functionName: func.name - }; - }); + _updateContractList() { + this.events.request("contracts:list", (_err, contractsList) => { + if (_err) { + this.logger.error(__("no contracts found")); + return; + } + contractsList.forEach(contract => { + if (!contract.deployedAddress) return; - this.addressToContract[address] = { - name: contract.className, - functions: funcSignatures - }; - } + let address = contract.deployedAddress.toLowerCase(); + if (!this.addressToContract[address]) { + let funcSignatures = {}; + contract.abiDefinition + .filter(func => func.type === "function") + .map(func => { + const name = func.name + + '(' + + (func.inputs ? func.inputs.map(input => input.type).join(',') : '') + + ')'; + funcSignatures[utils.sha3(name).substring(0, 10)] = { + name, + abi: func, + functionName: func.name + }; }); - }); - } - _listenForLogRequests(){ - if(this.ipc.ipcRole !== 'server') return; - this.ipc.on('log', (request) => { - if(request.type == 'contract-log'){ - if(!this.contractsDeployed) return; + this.addressToContract[address] = { + name: contract.className, + functions: funcSignatures + }; + } + }); + }); + } - let {address, data, transactionHash, blockNumber, gasUsed, status} = request; - if(!this.addressToContract[address]){ - this._updateContractList(); - } - if(!this.addressToContract[address]) return; + _listenForLogRequests() { + if (this.ipc.ipcRole !== 'server') return; + this.ipc.on('log', (request) => { + if (request.type === 'contract-log') { + if (!this.contractsDeployed) return; + + let {address, data, transactionHash, blockNumber, gasUsed, status} = request; + if (!this.addressToContract[address]) { + this._updateContractList(); + } + if (!this.addressToContract[address]) return; - const name = this.addressToContract[address].name; - const func = this.addressToContract[address].functions[data.substring(0, 10)]; - const functionName = func.functionName; + const name = this.addressToContract[address].name; + const func = this.addressToContract[address].functions[data.substring(0, 10)]; + const functionName = func.functionName; - const decodedParameters = utils.decodeParams(func.abi.inputs, data.substring(10)); - let paramString = ""; - if(func.abi.inputs){ - func.abi.inputs.forEach((input) => { - let quote = input.type.indexOf("int") == -1 ? '"' : ''; - paramString += quote + decodedParameters[input.name] + quote + ", "; - }); - paramString = paramString.substring(0, paramString.length - 2); - } + const decodedParameters = utils.decodeParams(func.abi.inputs, data.substring(10)); + let paramString = ""; + if (func.abi.inputs) { + func.abi.inputs.forEach((input) => { + let quote = input.type.indexOf("int") === -1 ? '"' : ''; + paramString += quote + decodedParameters[input.name] + quote + ", "; + }); + paramString = paramString.substring(0, paramString.length - 2); + } - gasUsed = utils.hexToNumber(gasUsed); - blockNumber = utils.hexToNumber(blockNumber); - - this.logger.info(`Blockchain>`.underline + ` ${name}.${functionName}(${paramString})`.bold + ` | ${transactionHash} | gas:${gasUsed} | blk:${blockNumber} | status:${status}`); - } else { - this.logger.info(JSON.stringify(request)); - } - }); - } + gasUsed = utils.hexToNumber(gasUsed); + blockNumber = utils.hexToNumber(blockNumber); + + this.logger.info(`Blockchain>`.underline + ` ${name}.${functionName}(${paramString})`.bold + ` | ${transactionHash} | gas:${gasUsed} | blk:${blockNumber} | status:${status}`); + } else { + this.logger.info(JSON.stringify(request)); + } + }); + } } module.exports = ConsoleListener;