From 9e469cc83ed0c7ef778c57e6ce20b83697522b6c Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 22 Mar 2018 10:43:29 -0400 Subject: [PATCH 1/9] Initial commit for graphviz functionality - Added required packages - Added command to cmd.js - Created graph.js to contain graph logic --- lib/cmd.js | 15 +++++++++++++++ lib/cmds/graph.js | 17 +++++++++++++++++ lib/index.js | 7 +++++++ package.json | 3 +++ 4 files changed, 42 insertions(+) create mode 100644 lib/cmds/graph.js diff --git a/lib/cmd.js b/lib/cmd.js index ab76482a3..2977d69e8 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -18,6 +18,7 @@ class Cmd { this.simulator(); this.test(); this.reset(); + this.graph(); this.upload(); this.versionCmd(); this.otherCommands(); @@ -171,6 +172,19 @@ class Cmd { }); } + graph() { + program + .command('graph [environment]') + .description('generates documentation based on the smart contracts configured') + .action(function (env, options) { + embark.initConfig(env || 'development', { + embarkConfig: 'embark.json', + interceptLogs: false + }); + embark.graph(); + }); + } + reset() { program .command('reset') @@ -206,6 +220,7 @@ class Cmd { process.exit(0); }); } + } diff --git a/lib/cmds/graph.js b/lib/cmds/graph.js new file mode 100644 index 000000000..dba9c2aad --- /dev/null +++ b/lib/cmds/graph.js @@ -0,0 +1,17 @@ +const fs = require("fs"); +const klaw = require('klaw'); +const path = require('path'); +const SolidityParser = require("solidity-parser"); +const Viz = require('viz.js'); + +class GraphGenerator { + constructor(config) { + this.config = config; + } + + generate() { + console.log("TODO"); + } +} + +module.exports = GraphGenerator; diff --git a/lib/index.js b/lib/index.js index e08870ae0..14a789112 100644 --- a/lib/index.js +++ b/lib/index.js @@ -185,6 +185,13 @@ class Embark { return new Test(options); } + graph() { + const GraphGenerator = new require('./cmds/graph.js'); + console.log(this.config); + let graphGen = new GraphGenerator(this.config); + graphGen.generate(); + } + reset() { let resetCmd = require('./cmds/reset.js'); resetCmd(); diff --git a/package.json b/package.json index 9de8bab93..7807007df 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "globule": "^1.1.0", "http-shutdown": "^1.2.0", "ipfs-api": "17.2.4", + "klaw": "^2.1.1", "merge": "^1.2.0", "mocha": "^2.2.5", "orbit-db": "^0.17.3", @@ -51,12 +52,14 @@ "serve-static": "^1.11.1", "shelljs": "^0.5.0", "solc": "0.4.17", + "solidity-parser": "^0.4.0", "style-loader": "^0.19.0", "tar": "^3.1.5", "toposort": "^1.0.0", "underscore": "^1.8.3", "underscore.string": "^3.3.4", "url-loader": "^0.6.2", + "viz.js": "^1.8.1", "web3": "1.0.0-beta.27", "webpack": "^3.10.0", "window-size": "^1.1.0" From d7b33a309be2c49cecee99950244164bb9d36a71 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 22 Mar 2018 15:09:01 -0400 Subject: [PATCH 2/9] Changed logic of deploy manager to be able to only compile the code and not deploy it --- lib/cmd.js | 7 ++-- lib/contracts/deploy_manager.js | 8 ++++ lib/core/engine.js | 3 +- lib/index.js | 69 ++++++++++++++++++++++++++++++--- 4 files changed, 77 insertions(+), 10 deletions(-) diff --git a/lib/cmd.js b/lib/cmd.js index 2977d69e8..5df6eb615 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -177,11 +177,10 @@ class Cmd { .command('graph [environment]') .description('generates documentation based on the smart contracts configured') .action(function (env, options) { - embark.initConfig(env || 'development', { - embarkConfig: 'embark.json', - interceptLogs: false + embark.graph({ + env: env || 'development', + logfile: options.logfile }); - embark.graph(); }); } diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index 0562574eb..edcd49e71 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -17,6 +17,7 @@ class DeployManager { this.gasLimit = false; this.fatalErrors = false; this.deployOnlyOnConfig = false; + this.onlyCompile = options.onlyCompile !== undefined ? options.onlyCompile : false; } deployContracts(done) { @@ -33,6 +34,13 @@ class DeployManager { self.contractsManager.deployOnlyOnConfig = self.deployOnlyOnConfig; // temporary, should refactor self.contractsManager.build(callback); }, + function checkCompileOnly(contractsManager, callback){ + if(self.onlyCompile){ + self.events.emit('contractsDeployed', contractsManager); + return done(); + } + return callback(contractsManager, null); + }, function checkWeb3IsConnected(contractsManager, callback) { if (!self.web3) { return callback(Error("no web3 instance found")); diff --git a/lib/core/engine.js b/lib/core/engine.js index 53ee62032..4d3bb00e3 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -153,7 +153,8 @@ class Engine { logger: this.logger, plugins: this.plugins, events: this.events, - contractsManager: this.contractsManager + contractsManager: this.contractsManager, + onlyCompile: options.onlyCompile }); this.events.on('file-event', function (fileType, _path) { diff --git a/lib/index.js b/lib/index.js index 14a789112..21bc71f44 100644 --- a/lib/index.js +++ b/lib/index.js @@ -185,11 +185,70 @@ class Embark { return new Test(options); } - graph() { - const GraphGenerator = new require('./cmds/graph.js'); - console.log(this.config); - let graphGen = new GraphGenerator(this.config); - graphGen.generate(); + graph(options) { + + + + let self = this; + + options.onlyCompile = true; + + let engine = new Engine({ + env: options.env, + version: this.version, + embarkConfig: options.embarkConfig || 'embark.json', + logfile: options.logfile + }); + engine.init(); + + + async.parallel([ + + function (callback) { + let pluginList = engine.plugins.listPlugins(); + if (pluginList.length > 0) { + engine.logger.info("loaded plugins: " + pluginList.join(", ")); + } + + engine.startMonitor(); + engine.startService("libraryManager"); + engine.startService("pipeline"); + engine.startService("codeGenerator"); + engine.startService("deployment", {onlyCompile: true}); + + engine.deployManager.deployContracts(function (err) { + callback(err); + }); + } + ], function (err, _result) { + if (err) { + engine.logger.error(err.message); + engine.logger.info(err.stack); + } else { + + const GraphGenerator = require('./cmds/graph.js'); + let graphGen = new GraphGenerator(engine.config); + graphGen.generate(); + + engine.logger.info("Done".underline); + process.exit(); + } + }); + + + + + + + + + + + + + + + } reset() { From 01eaa0fe7f15a7891ee70271c31b6c02474c4c63 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 22 Mar 2018 16:18:13 -0400 Subject: [PATCH 3/9] Generating basic diagram that includes methods --- lib/cmds/graph.js | 61 +++++++++++++++++++++++++++++++++++++++++------ lib/index.js | 16 +------------ 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/lib/cmds/graph.js b/lib/cmds/graph.js index dba9c2aad..8bc670865 100644 --- a/lib/cmds/graph.js +++ b/lib/cmds/graph.js @@ -1,16 +1,63 @@ -const fs = require("fs"); -const klaw = require('klaw'); -const path = require('path'); -const SolidityParser = require("solidity-parser"); const Viz = require('viz.js'); +const fs = require('fs'); class GraphGenerator { - constructor(config) { - this.config = config; + constructor(engine) { + this.engine = engine; } generate() { - console.log("TODO"); + let id = 0; + let contractString = ""; + + for (let contract in this.engine.contractsManager.contracts) { + id++; + let contractLabel = ""; + + contractLabel += `${contract}`; + + let fHashes = this.engine.contractsManager.contracts[contract].functionHashes; + if(fHashes != {} && fHashes != undefined){ + contractLabel += "|"; + for(let method in this.engine.contractsManager.contracts[contract].functionHashes){ + contractLabel += method + '\\l'; + } + } + + for(let i = 0; i < this.engine.contractsManager.contracts[contract].abiDefinition.length; i++){ + if(this.engine.contractsManager.contracts[contract].abiDefinition[i].type == 'fallback') + contractLabel += "«fallback»()" + '\\l'; + } + + /*if(c.methods.length > 0){ + contractLabel += "|"; + c.methods.forEach(function(a){ + contractLabel += a + '\\l'; + }) + + } */ + + contractString += `${id}[label = "{${contractLabel}}"]` + contractString += "\n"; + } + + + let dot = ` + digraph hierarchy { + node[shape=record,style=filled,fillcolor=gray95] + edge[dir=back, arrowtail=empty] + ${contractString} + }`; + + let svg = Viz(dot); + + let filename = "diagram.svg"; + + fs.writeFileSync(filename, svg, (err) => { + if (err) throw err; + }); + + } } diff --git a/lib/index.js b/lib/index.js index 21bc71f44..d31decd98 100644 --- a/lib/index.js +++ b/lib/index.js @@ -227,7 +227,7 @@ class Embark { } else { const GraphGenerator = require('./cmds/graph.js'); - let graphGen = new GraphGenerator(engine.config); + let graphGen = new GraphGenerator(engine); graphGen.generate(); engine.logger.info("Done".underline); @@ -235,20 +235,6 @@ class Embark { } }); - - - - - - - - - - - - - - } reset() { From 403f2daee2e18ff4d6eb946da76fb54936e71696 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 22 Mar 2018 17:11:11 -0400 Subject: [PATCH 4/9] Added relationships between contracts --- lib/cmds/graph.js | 61 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/lib/cmds/graph.js b/lib/cmds/graph.js index 8bc670865..b9dfcb4c7 100644 --- a/lib/cmds/graph.js +++ b/lib/cmds/graph.js @@ -9,44 +9,77 @@ class GraphGenerator { generate() { let id = 0; let contractString = ""; + let relationshipString = ""; + let idMapping = {}; + let contractInheritance = {}; + for (let contract in this.engine.contractsManager.contracts) { id++; + + idMapping[contract] = id; + let contractLabel = ""; contractLabel += `${contract}`; + if(this.engine.contractsManager.contracts[contract].instanceOf !== undefined && + this.engine.contractsManager.contracts[this.engine.contractsManager.contracts[contract].instanceOf] !== undefined){ + contractInheritance[contract] = this.engine.contractsManager.contracts[contract].instanceOf; + } + + contractLabel += "|"; + + for(let i = 0; i < this.engine.contractsManager.contracts[contract].abiDefinition.length; i++){ + switch(this.engine.contractsManager.contracts[contract].abiDefinition[i].type){ + case 'fallback': + contractLabel += "«fallback»()" + '\\l'; + break; + case 'constructor': + contractLabel += "«constructor»("; + for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ + contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; + } + contractLabel += ")\\l"; + break; + default: break; + } + } + let fHashes = this.engine.contractsManager.contracts[contract].functionHashes; if(fHashes != {} && fHashes != undefined){ - contractLabel += "|"; for(let method in this.engine.contractsManager.contracts[contract].functionHashes){ contractLabel += method + '\\l'; } } - - for(let i = 0; i < this.engine.contractsManager.contracts[contract].abiDefinition.length; i++){ - if(this.engine.contractsManager.contracts[contract].abiDefinition[i].type == 'fallback') - contractLabel += "«fallback»()" + '\\l'; - } - - /*if(c.methods.length > 0){ - contractLabel += "|"; - c.methods.forEach(function(a){ - contractLabel += a + '\\l'; - }) - - } */ + contractString += `${id}[label = "{${contractLabel}}"]` contractString += "\n"; } + for (let c in this.engine.contractsManager.contractDependencies){ + let contractDependencies = Array.from(new Set(this.engine.contractsManager.contractDependencies[c])); + contractDependencies.forEach(function(d){ + if(idMapping[c] !== undefined && idMapping[d] !== undefined){ + relationshipString += `${idMapping[d]}->${idMapping[c]}[constraint=true, arrowtail=diamond]` + relationshipString += "\n"; + } + }); + } + + for (let c in contractInheritance){ + relationshipString += `${idMapping[contractInheritance[c]]}->${idMapping[c]}` + relationshipString += "\n"; + } + let dot = ` digraph hierarchy { node[shape=record,style=filled,fillcolor=gray95] edge[dir=back, arrowtail=empty] ${contractString} + ${relationshipString} }`; let svg = Viz(dot); From 7dcae55b8bf1e4afacf7e3644f2b1735c7a88e9e Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Fri, 23 Mar 2018 08:28:42 -0400 Subject: [PATCH 5/9] Added events to graph and fixed problems in IDE --- lib/cmds/graph.js | 21 +++++++++++++-------- lib/index.js | 5 ----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/cmds/graph.js b/lib/cmds/graph.js index b9dfcb4c7..073ddd6c2 100644 --- a/lib/cmds/graph.js +++ b/lib/cmds/graph.js @@ -33,15 +33,22 @@ class GraphGenerator { for(let i = 0; i < this.engine.contractsManager.contracts[contract].abiDefinition.length; i++){ switch(this.engine.contractsManager.contracts[contract].abiDefinition[i].type){ case 'fallback': - contractLabel += "«fallback»()" + '\\l'; + contractLabel += "«fallback»()\\l"; break; - case 'constructor': + case 'constructor': contractLabel += "«constructor»("; for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; } contractLabel += ")\\l"; break; + case 'event': + contractLabel += "«event»" + this.engine.contractsManager.contracts[contract].abiDefinition[i].name + "("; + for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ + contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; + } + contractLabel += ")\\l"; + break; default: break; } } @@ -54,23 +61,21 @@ class GraphGenerator { } - contractString += `${id}[label = "{${contractLabel}}"]` - contractString += "\n"; + contractString += `${id}[label = "{${contractLabel}}"]\n`; + } for (let c in this.engine.contractsManager.contractDependencies){ let contractDependencies = Array.from(new Set(this.engine.contractsManager.contractDependencies[c])); contractDependencies.forEach(function(d){ if(idMapping[c] !== undefined && idMapping[d] !== undefined){ - relationshipString += `${idMapping[d]}->${idMapping[c]}[constraint=true, arrowtail=diamond]` - relationshipString += "\n"; + relationshipString += `${idMapping[d]}->${idMapping[c]}[constraint=true, arrowtail=diamond]\n`; } }); } for (let c in contractInheritance){ - relationshipString += `${idMapping[contractInheritance[c]]}->${idMapping[c]}` - relationshipString += "\n"; + relationshipString += `${idMapping[contractInheritance[c]]}->${idMapping[c]}\n`; } diff --git a/lib/index.js b/lib/index.js index d31decd98..423153736 100644 --- a/lib/index.js +++ b/lib/index.js @@ -186,11 +186,6 @@ class Embark { } graph(options) { - - - - let self = this; - options.onlyCompile = true; let engine = new Engine({ From 5d0e86bb727c8d28585e8e8cf6441111b0774a9c Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Fri, 23 Mar 2018 11:27:21 -0400 Subject: [PATCH 6/9] Removed unneeded packages and added tooltips and colors --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index 7807007df..905914204 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "globule": "^1.1.0", "http-shutdown": "^1.2.0", "ipfs-api": "17.2.4", - "klaw": "^2.1.1", "merge": "^1.2.0", "mocha": "^2.2.5", "orbit-db": "^0.17.3", @@ -52,7 +51,6 @@ "serve-static": "^1.11.1", "shelljs": "^0.5.0", "solc": "0.4.17", - "solidity-parser": "^0.4.0", "style-loader": "^0.19.0", "tar": "^3.1.5", "toposort": "^1.0.0", From 58b5ea329e9af8a10e6c392110b47e029e2b84cd Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Fri, 23 Mar 2018 11:37:56 -0400 Subject: [PATCH 7/9] Styles for contract instances --- lib/cmds/graph.js | 80 ++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/lib/cmds/graph.js b/lib/cmds/graph.js index 073ddd6c2..28fb9ac61 100644 --- a/lib/cmds/graph.js +++ b/lib/cmds/graph.js @@ -22,46 +22,54 @@ class GraphGenerator { let contractLabel = ""; contractLabel += `${contract}`; + let tooltip = contract; if(this.engine.contractsManager.contracts[contract].instanceOf !== undefined && this.engine.contractsManager.contracts[this.engine.contractsManager.contracts[contract].instanceOf] !== undefined){ contractInheritance[contract] = this.engine.contractsManager.contracts[contract].instanceOf; - } + contractLabel += ": " + this.engine.contractsManager.contracts[contract].instanceOf; + tooltip += " instance of " + this.engine.contractsManager.contracts[contract].instanceOf; + } else { + contractLabel += "|"; - contractLabel += "|"; + for(let i = 0; i < this.engine.contractsManager.contracts[contract].abiDefinition.length; i++){ + switch(this.engine.contractsManager.contracts[contract].abiDefinition[i].type){ + case 'fallback': + contractLabel += "«fallback»()\\l"; + break; + case 'constructor': + contractLabel += "«constructor»("; + for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ + contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; + } + contractLabel += ")\\l"; + break; + case 'event': + contractLabel += "«event»" + this.engine.contractsManager.contracts[contract].abiDefinition[i].name + "("; + for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ + contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; + } + contractLabel += ")\\l"; + break; + default: break; + } + } - for(let i = 0; i < this.engine.contractsManager.contracts[contract].abiDefinition.length; i++){ - switch(this.engine.contractsManager.contracts[contract].abiDefinition[i].type){ - case 'fallback': - contractLabel += "«fallback»()\\l"; - break; - case 'constructor': - contractLabel += "«constructor»("; - for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ - contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; - } - contractLabel += ")\\l"; - break; - case 'event': - contractLabel += "«event»" + this.engine.contractsManager.contracts[contract].abiDefinition[i].name + "("; - for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ - contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; - } - contractLabel += ")\\l"; - break; - default: break; - } - } - - let fHashes = this.engine.contractsManager.contracts[contract].functionHashes; - if(fHashes != {} && fHashes != undefined){ - for(let method in this.engine.contractsManager.contracts[contract].functionHashes){ - contractLabel += method + '\\l'; + let fHashes = this.engine.contractsManager.contracts[contract].functionHashes; + if(fHashes != {} && fHashes != undefined){ + for(let method in this.engine.contractsManager.contracts[contract].functionHashes){ + contractLabel += method + '\\l'; + } } } - - contractString += `${id}[label = "{${contractLabel}}"]\n`; + let others = '' + if(!this.engine.contractsManager.contracts[contract].deploy){ + others = 'fontcolor="#c3c3c3", color="#a0a0a0"'; + tooltip += " (not deployed)"; + } + + contractString += `${id}[label = "{${contractLabel}}", tooltip="${tooltip}", fillcolor=gray95, ${others}]\n`; } @@ -69,20 +77,20 @@ class GraphGenerator { let contractDependencies = Array.from(new Set(this.engine.contractsManager.contractDependencies[c])); contractDependencies.forEach(function(d){ if(idMapping[c] !== undefined && idMapping[d] !== undefined){ - relationshipString += `${idMapping[d]}->${idMapping[c]}[constraint=true, arrowtail=diamond]\n`; + relationshipString += `${idMapping[d]}->${idMapping[c]}[constraint=true, arrowtail=diamond, tooltip="${d} uses ${c}"]\n`; } }); } for (let c in contractInheritance){ - relationshipString += `${idMapping[contractInheritance[c]]}->${idMapping[c]}\n`; + relationshipString += `${idMapping[contractInheritance[c]]}->${idMapping[c]}[tooltip="${c} instance of ${contractInheritance[c]}"]\n`; } let dot = ` - digraph hierarchy { - node[shape=record,style=filled,fillcolor=gray95] - edge[dir=back, arrowtail=empty] + digraph Contracts { + node[shape=record,style=filled] + edge[dir=back, arrowtail=empty] ${contractString} ${relationshipString} }`; From 0326890abeb6967e739f21d80ff0157fafac8802 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Fri, 23 Mar 2018 11:39:42 -0400 Subject: [PATCH 8/9] Fix: Relationship was incorrect --- lib/cmds/graph.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cmds/graph.js b/lib/cmds/graph.js index 28fb9ac61..ef401111a 100644 --- a/lib/cmds/graph.js +++ b/lib/cmds/graph.js @@ -68,7 +68,7 @@ class GraphGenerator { others = 'fontcolor="#c3c3c3", color="#a0a0a0"'; tooltip += " (not deployed)"; } - + contractString += `${id}[label = "{${contractLabel}}", tooltip="${tooltip}", fillcolor=gray95, ${others}]\n`; } @@ -77,7 +77,7 @@ class GraphGenerator { let contractDependencies = Array.from(new Set(this.engine.contractsManager.contractDependencies[c])); contractDependencies.forEach(function(d){ if(idMapping[c] !== undefined && idMapping[d] !== undefined){ - relationshipString += `${idMapping[d]}->${idMapping[c]}[constraint=true, arrowtail=diamond, tooltip="${d} uses ${c}"]\n`; + relationshipString += `${idMapping[d]}->${idMapping[c]}[constraint=true, arrowtail=diamond, tooltip="${c} uses ${d}"]\n`; } }); } From f56b42d91ff13a1520d96cb5eefbcfcd1dfbad46 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 5 Apr 2018 11:41:28 -0400 Subject: [PATCH 9/9] Linting --- lib/cmds/graph.js | 14 +++++++------- package-lock.json | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/cmds/graph.js b/lib/cmds/graph.js index ef401111a..7621fe655 100644 --- a/lib/cmds/graph.js +++ b/lib/cmds/graph.js @@ -39,16 +39,16 @@ class GraphGenerator { break; case 'constructor': contractLabel += "«constructor»("; - for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ - contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; - } + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.forEach(function(elem, index){ + contractLabel += (index == 0 ? "" : ", ") + elem.type; + }); contractLabel += ")\\l"; break; case 'event': contractLabel += "«event»" + this.engine.contractsManager.contracts[contract].abiDefinition[i].name + "("; - for(let j = 0; j < this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.length; j++){ - contractLabel += (j == 0 ? "" : ", ") + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs[j].type; - } + this.engine.contractsManager.contracts[contract].abiDefinition[i].inputs.forEach(function(elem, index){ + contractLabel += (index == 0 ? "" : ", ") + elem.type; + }); contractLabel += ")\\l"; break; default: break; @@ -63,7 +63,7 @@ class GraphGenerator { } } - let others = '' + let others = ''; if(!this.engine.contractsManager.contracts[contract].deploy){ others = 'fontcolor="#c3c3c3", color="#a0a0a0"'; tooltip += " (not deployed)"; diff --git a/package-lock.json b/package-lock.json index e2e62dd00..188cefdf9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10063,6 +10063,11 @@ "extsprintf": "1.3.0" } }, + "viz.js": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/viz.js/-/viz.js-1.8.1.tgz", + "integrity": "sha512-KrSNgnIxec+JCAqDPliO6xYA69ToH2WTYB2Kbt8Bp/XRUvm23rTyfffFi4rvQLFkIRNUz/xCnnqhh/gChhsgGA==" + }, "vlq": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz",