sol2uml 2.5.1 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Solidity 2 UML
2
2
 
3
- [![npm version](https://badge.fury.io/js/sol2uml.svg)](https://badge.fury.io/js/sol2uml)
3
+ [![npm (tag)](https://img.shields.io/npm/v/sol2uml)](https://www.npmjs.com/package/sol2uml)
4
+ [![Twitter Follow](https://img.shields.io/twitter/follow/naddison?style=social)](https://twitter.com/naddison)
4
5
 
5
6
  A visualisation tool for [Solidity](https://solidity.readthedocs.io/) contracts featuring:
6
7
  1. [Unified Modeling Language (UML)](https://en.wikipedia.org/wiki/Unified_Modeling_Language) [class diagram](https://en.wikipedia.org/wiki/Class_diagram) generator for Solidity contracts.
@@ -44,22 +45,17 @@ npm ls sol2uml -g
44
45
  ## Command Line Interface (CLI)
45
46
 
46
47
  ```
47
- Usage: sol2uml [subcommand] <options>
48
- The three subcommands:
49
- * class: Generates a UML class diagram from Solidity source code. default
50
- * storage: Generates a diagram of a contract's storage slots.
51
- * flatten: Merges verified source files from a Blockchain explorer into one local file.
52
- * diff: Compares the flattened Solidity code from a Blockchain explorer for two contracts.
48
+ Usage: sol2uml [command] <options>
53
49
 
54
- The Solidity code can be pulled from verified source code on Blockchain explorers like Etherscan or from local Solidity files.
50
+ Generate UML class or storage diagrams from local Solidity code or verified Solidity code on Etherscan-like explorers.
51
+ Can also flatten or compare verified source files on Etherscan-like explorers.
55
52
 
56
53
  Options:
57
54
  -sf, --subfolders <value> number of subfolders that will be recursively searched for Solidity files. (default: all)
58
55
  -f, --outputFormat <value> output file format. (choices: "svg", "png", "dot", "all", default: "svg")
59
56
  -o, --outputFileName <value> output file name
60
57
  -i, --ignoreFilesOrFolders <filesOrFolders> comma separated list of files or folders to ignore
61
- -n, --network <network> Ethereum network (choices: "mainnet", "ropsten", "kovan", "rinkeby", "goerli", "sepolia", "polygon", "testnet.polygon", "arbitrum", "testnet.arbitrum", "avalanche", "testnet.avalanche", "bsc", "testnet.bsc", "crono", "fantom",
62
- "testnet.fantom", "moonbeam", "optimistic", "kovan-optimistic", "gnosisscan", default: "mainnet", env: ETH_NETWORK)
58
+ -n, --network <network> Ethereum network (choices: "mainnet", "goerli", "sepolia", "polygon", "arbitrum", "avalanche", "bsc", "crono", "fantom", "moonbeam", "optimism", "gnosis", default: "mainnet", env: ETH_NETWORK)
63
59
  -k, --apiKey <key> Blockchain explorer API key. eg Etherscan, Arbiscan, Optimism, BscScan, CronoScan, FTMScan, PolygonScan or SnowTrace API key (env: SCAN_API_KEY)
64
60
  -bc, --backColor <color> Canvas background color. "none" will use a transparent canvas. (default: "white")
65
61
  -sc, --shapeColor <color> Basic drawing color for graphics, not text (default: "black")
@@ -70,9 +66,24 @@ Options:
70
66
  -h, --help display help for command
71
67
 
72
68
  Commands:
73
- class [options] [fileFolderAddress] Generates a UML class diagram from Solidity source code.
74
- storage [options] <fileFolderAddress> output a contracts storage slots
75
- flatten <contractAddress> get all verified source code for a contract from the Blockchain explorer into one local file
69
+ class [options] <fileFolderAddress> Generates a UML class diagram from Solidity source code.
70
+ storage [options] <fileFolderAddress> Visually display a contract's storage slots.
71
+
72
+ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A known example is fixed-sized arrays declared with an expression will fail to be sized.
73
+ flatten <contractAddress> Merges verified source files for a contract from a Blockchain explorer into one local file.
74
+
75
+ In order for the merged code to compile, the following is done:
76
+ 1. pragma solidity is set using the compiler of the verified contract.
77
+ 2. All pragma solidity lines in the source files are commented out.
78
+ 3. File imports are commented out.
79
+ 4. "SPDX-License-Identifier" is renamed to "SPDX--License-Identifier".
80
+ 5. Contract dependencies are analysed so the files are merged in an order that will compile.
81
+ diff [options] <addressA> <addressB> Compare verified Solidity code differences between two contracts.
82
+
83
+ The results show the comparison of contract A to B.
84
+ The green sections are additions to contract B that are not in contract A.
85
+ The red sections are removals from contract A that are not in contract B.
86
+ The line numbers are from contract B. There are no line numbers for the red sections as they are not in contract B.
76
87
  help [command] display help for command
77
88
  ```
78
89
 
@@ -81,20 +92,15 @@ Commands:
81
92
  ```
82
93
  Usage: sol2uml class [options] <fileFolderAddress>
83
94
 
84
- Generates UML diagrams from Solidity source code.
85
-
86
- If no file, folder or address is passed as the first argument, the working folder is used.
87
- When a folder is used, all *.sol files are found in that folder and all sub folders.
88
- A comma separated list of files and folders can also be used. For example
89
- sol2uml contracts,node_modules/openzeppelin-solidity
90
-
91
- If an Ethereum address with a 0x prefix is passed, the verified source code from Etherscan will be used. For example
92
- sol2uml 0x79fEbF6B9F76853EDBcBc913e6aAE8232cFB9De9
93
-
94
95
  Generates a UML class diagram from Solidity source code.
95
96
 
96
97
  Arguments:
97
- fileFolderAddress file name, base folder or contract address (default: "/Users/nicholasaddison/Documents/workspaces/sol2uml")
98
+ fileFolderAddress file name, folder(s) or contract address.
99
+ When a folder is used, all *.sol files in that folder and all sub folders are used.
100
+ A comma-separated list of files and folders can also be used. For example
101
+ sol2uml contracts,node_modules/openzeppelin-solidity
102
+ If an Ethereum address with a 0x prefix is passed, the verified source code from Etherscan will be used. For example
103
+ sol2uml 0x79fEbF6B9F76853EDBcBc913e6aAE8232cFB9De9
98
104
 
99
105
  Options:
100
106
  -b, --baseContractNames <value> only output contracts connected to these comma separated base contract names
@@ -106,6 +112,7 @@ Options:
106
112
  -hm, --hideModifiers hide modifier functions from contracts (default: false)
107
113
  -ht, --hideEvents hide events from contracts, interfaces and libraries (default: false)
108
114
  -hc, --hideConstants hide file level constants (default: false)
115
+ -hx, --hideContracts hide contracts (default: false)
109
116
  -he, --hideEnums hide enum types (default: false)
110
117
  -hs, --hideStructs hide data structures (default: false)
111
118
  -hl, --hideLibraries hide libraries (default: false)
@@ -122,12 +129,17 @@ Options:
122
129
  ```
123
130
  Usage: sol2uml storage [options] <fileFolderAddress>
124
131
 
125
- WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A known example is fixed-sized arrays declared with an expression will fail to be sized.
126
-
127
132
  Visually display a contract's storage slots.
128
133
 
134
+ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A known example is fixed-sized arrays declared with an expression will fail to be sized.
135
+
129
136
  Arguments:
130
- fileFolderAddress file name, base folder or contract address
137
+ fileFolderAddress file name, folder(s) or contract address.
138
+ When a folder is used, all *.sol files in that folder and all sub folders are used.
139
+ A comma-separated list of files and folders can also be used. For example
140
+ sol2uml contracts,node_modules/openzeppelin-solidity
141
+ If an Ethereum address with a 0x prefix is passed, the verified source code from Etherscan will be used. For example
142
+ sol2uml 0x79fEbF6B9F76853EDBcBc913e6aAE8232cFB9De9
131
143
 
132
144
  Options:
133
145
  -c, --contract <name> Contract name in the local Solidity files. Not needed when using an address as the first argument as the contract name can be derived from Etherscan.
@@ -137,7 +149,7 @@ Options:
137
149
  -u, --url <url> URL of the Ethereum node to get storage values if the `data` option is used. (default: "http://localhost:8545", env: NODE_URL)
138
150
  -bn, --block <number> Block number to get the contract storage values from. (default: "latest")
139
151
  -a, --array <number> Number of slots to display at the start and end of arrays. (default: "2")
140
- -hv, --hideValue Hide storage slot value column.
152
+ -hv, --hideValue Hide storage slot value column. (default: false)
141
153
  -h, --help display help for command
142
154
  ```
143
155
 
@@ -146,6 +158,8 @@ Options:
146
158
  ```
147
159
  Usage: sol2uml flatten <contractAddress>
148
160
 
161
+ Merges verified source files for a contract from a Blockchain explorer into one local Solidity file.
162
+
149
163
  In order for the merged code to compile, the following is done:
150
164
  1. pragma solidity is set using the compiler of the verified contract.
151
165
  2. All pragma solidity lines in the source files are commented out.
@@ -153,8 +167,6 @@ In order for the merged code to compile, the following is done:
153
167
  4. "SPDX-License-Identifier" is renamed to "SPDX--License-Identifier".
154
168
  5. Contract dependencies are analysed so the files are merged in an order that will compile.
155
169
 
156
- Merges verified source files for a contract from a Blockchain explorer into one local file.
157
-
158
170
  Arguments:
159
171
  contractAddress Contract address in hexadecimal format with a 0x prefix.
160
172
 
@@ -167,16 +179,16 @@ Options:
167
179
  ```
168
180
  Usage: sol2uml diff [options] <addressA> <addressB>
169
181
 
170
- The results show the comparison of contracts A to B.
182
+ Compare verified Solidity code differences between two contracts.
183
+
184
+ The results show the comparison of contract A to B.
171
185
  The green sections are additions to contract B that are not in contract A.
172
186
  The red sections are removals from contract A that are not in contract B.
173
187
  The line numbers are from contract B. There are no line numbers for the red sections as they are not in contract B.
174
188
 
175
- Compare verified Solidity code differences between two contracts.
176
-
177
189
  Arguments:
178
- addressA Contract address in hexadecimal format with a 0x prefix.
179
- addressB Contract address in hexadecimal format with a 0x prefix.
190
+ addressA Contract address in hexadecimal format with a 0x prefix of the first contract.
191
+ addressB Contract address in hexadecimal format with a 0x prefix of the second contract.
180
192
 
181
193
  Options:
182
194
  -l, --lineBuffer <value> Minimum number of lines before and after changes (default: "4")
@@ -1,6 +1,7 @@
1
1
  import { UmlClass } from './umlClass';
2
2
  export interface ClassOptions {
3
3
  hideConstants?: boolean;
4
+ hideContracts?: boolean;
4
5
  hideVariables?: boolean;
5
6
  hideFunctions?: boolean;
6
7
  hideModifiers?: boolean;
@@ -22,8 +22,9 @@ const filterHiddenClasses = (umlClasses, options) => {
22
22
  !options.hideConstants) ||
23
23
  (u.stereotype === umlClass_1.ClassStereotype.Library &&
24
24
  !options.hideLibraries) ||
25
- u.stereotype === umlClass_1.ClassStereotype.None ||
26
- u.stereotype === umlClass_1.ClassStereotype.Contract);
25
+ ((u.stereotype === umlClass_1.ClassStereotype.None ||
26
+ u.stereotype === umlClass_1.ClassStereotype.Contract) &&
27
+ !options.hideContracts));
27
28
  };
28
29
  exports.filterHiddenClasses = filterHiddenClasses;
29
30
  /**
@@ -4,7 +4,7 @@ export interface Remapping {
4
4
  from: RegExp;
5
5
  to: string;
6
6
  }
7
- export declare const networks: readonly ["mainnet", "ropsten", "kovan", "rinkeby", "goerli", "sepolia", "polygon", "testnet.polygon", "arbitrum", "testnet.arbitrum", "avalanche", "testnet.avalanche", "bsc", "testnet.bsc", "crono", "fantom", "testnet.fantom", "moonbeam", "optimistic", "kovan-optimistic", "gnosisscan"];
7
+ export declare const networks: readonly ["mainnet", "goerli", "sepolia", "polygon", "arbitrum", "avalanche", "bsc", "crono", "fantom", "moonbeam", "optimism", "gnosis"];
8
8
  export type Network = (typeof networks)[number];
9
9
  export declare class EtherscanParser {
10
10
  protected apikey: string;
@@ -13,26 +13,17 @@ require('axios-debug-log');
13
13
  const debug = require('debug')('sol2uml');
14
14
  exports.networks = [
15
15
  'mainnet',
16
- 'ropsten',
17
- 'kovan',
18
- 'rinkeby',
19
16
  'goerli',
20
17
  'sepolia',
21
18
  'polygon',
22
- 'testnet.polygon',
23
19
  'arbitrum',
24
- 'testnet.arbitrum',
25
20
  'avalanche',
26
- 'testnet.avalanche',
27
21
  'bsc',
28
- 'testnet.bsc',
29
22
  'crono',
30
23
  'fantom',
31
- 'testnet.fantom',
32
24
  'moonbeam',
33
- 'optimistic',
34
- 'kovan-optimistic',
35
- 'gnosisscan',
25
+ 'optimism',
26
+ 'gnosis',
36
27
  ];
37
28
  class EtherscanParser {
38
29
  constructor(apikey = 'ZAD4UI2RCXCQTP38EXS3UY2MPHFU5H9KB1', network = 'mainnet') {
@@ -48,34 +39,18 @@ class EtherscanParser {
48
39
  this.url = 'https://api.polygonscan.com/api';
49
40
  this.apikey = 'AMHGNTV5A7XYGX2M781JB3RC1DZFVRWQEB';
50
41
  }
51
- else if (network === 'testnet.polygon') {
52
- this.url = 'https://api-testnet.polygonscan.com/api';
53
- this.apikey = 'AMHGNTV5A7XYGX2M781JB3RC1DZFVRWQEB';
54
- }
55
42
  else if (network === 'arbitrum') {
56
43
  this.url = 'https://api.arbiscan.io/api';
57
44
  this.apikey = 'ZGTK2TAGWMAB6IAC12BMK8YYPNCPIM8VDQ';
58
45
  }
59
- else if (network === 'testnet.arbitrum') {
60
- this.url = 'https://api-testnet.arbiscan.io/api';
61
- this.apikey = 'ZGTK2TAGWMAB6IAC12BMK8YYPNCPIM8VDQ';
62
- }
63
46
  else if (network === 'avalanche') {
64
47
  this.url = 'https://api.snowtrace.io/api';
65
48
  this.apikey = 'U5FAN98S5XNH5VI83TI4H35R9I4TDCKEJY';
66
49
  }
67
- else if (network === 'testnet.avalanche') {
68
- this.url = 'https://api-testnet.snowtrace.io/api';
69
- this.apikey = 'U5FAN98S5XNH5VI83TI4H35R9I4TDCKEJY';
70
- }
71
50
  else if (network === 'bsc') {
72
51
  this.url = 'https://api.bscscan.com/api';
73
52
  this.apikey = 'APYH49FXVY9UA3KTDI6F4WP3KPIC86NITN';
74
53
  }
75
- else if (network === 'testnet.bsc') {
76
- this.url = 'https://api-testnet.bscscan.com/api';
77
- this.apikey = 'APYH49FXVY9UA3KTDI6F4WP3KPIC86NITN';
78
- }
79
54
  else if (network === 'crono') {
80
55
  this.url = 'https://api.cronoscan.com/api';
81
56
  this.apikey = '76A3RG5WHTPMMR66E9SFI2EIDT6MP976W2';
@@ -84,19 +59,15 @@ class EtherscanParser {
84
59
  this.url = 'https://api.ftmscan.com/api';
85
60
  this.apikey = '71KRX13XPZMGR3D1Q85W78G2DSZ4JPMAEX';
86
61
  }
87
- else if (network === 'testnet.fantom') {
88
- this.url = 'https://api-testnet.ftmscan.com/api';
89
- this.apikey = '71KRX13XPZMGR3D1Q85W78G2DSZ4JPMAEX';
90
- }
91
- else if (network === 'optimistic' || network === 'kovan-optimistic') {
92
- this.url = `https://api-${network}.etherscan.io/api`;
62
+ else if (network === 'optimism') {
63
+ this.url = `https://api-optimistic.etherscan.io/api`;
93
64
  this.apikey = 'FEXS1HXVA4Y2RNTMEA8V1UTK21S4JWHH9U';
94
65
  }
95
66
  else if (network === 'moonbeam') {
96
67
  this.url = 'https://api-moonbeam.moonscan.io/api';
97
68
  this.apikey = '5EUFXW6TDC16VERF3D9SCWRRU6AEMTBHNJ';
98
69
  }
99
- else if (network === 'gnosisscan') {
70
+ else if (network === 'gnosis') {
100
71
  this.url = 'https://api.gnosisscan.io/api';
101
72
  this.apikey = '2RWGXIWK538EJ8XSP9DE2JUINSCG7UCSJB';
102
73
  }
package/lib/sol2uml.js CHANGED
@@ -20,15 +20,9 @@ const program = new commander_1.Command();
20
20
  const debugControl = require('debug');
21
21
  const debug = require('debug')('sol2uml');
22
22
  program
23
- .usage(`[subcommand] <options>
24
-
25
- sol2uml comes with three subcommands:
26
- * class: Generates a UML class diagram from Solidity source code. (default)
27
- * storage: Generates a diagram of a contract's storage slots.
28
- * flatten: Merges verified Solidity files from a Blockchain explorer into one local file.
29
- * diff: Compares the flattened Solidity code from a Blockchain explorer for two contracts.
30
-
31
- The Solidity code can be pulled from verified source code on Blockchain explorers like Etherscan or from local Solidity files.`)
23
+ .usage('[command] <options>')
24
+ .description(`Generate UML class or storage diagrams from local Solidity code or verified Solidity code on Etherscan-like explorers.
25
+ Can also flatten or compare verified source files on Etherscan-like explorers.`)
32
26
  .addOption(new commander_1.Option('-sf, --subfolders <value>', 'number of subfolders that will be recursively searched for Solidity files.').default('-1', 'all'))
33
27
  .addOption(new commander_1.Option('-f, --outputFormat <value>', 'output file format.')
34
28
  .choices(['svg', 'png', 'dot', 'all'])
@@ -49,21 +43,17 @@ const version = (0, path_1.basename)(__dirname) === 'lib'
49
43
  ? require('../package.json').version // used when run from compile js in /lib
50
44
  : require('../../package.json').version; // used when run from TypeScript source files under src/ts via ts-node
51
45
  program.version(version);
46
+ const argumentText = `file name, folder(s) or contract address.
47
+ \t\t\t\t When a folder is used, all *.sol files in that folder and all sub folders are used.
48
+ \t\t\t\t A comma-separated list of files and folders can also be used. For example
49
+ \t\t\t\t\tsol2uml contracts,node_modules/openzeppelin-solidity
50
+ \t\t\t\t If an Ethereum address with a 0x prefix is passed, the verified source code from Etherscan will be used. For example
51
+ \t\t\t\t\tsol2uml 0x79fEbF6B9F76853EDBcBc913e6aAE8232cFB9De9`;
52
52
  program
53
53
  .command('class', { isDefault: true })
54
+ .usage('[options] <fileFolderAddress>')
54
55
  .description('Generates a UML class diagram from Solidity source code.')
55
- .usage(`sol2uml [options] <fileFolderAddress>
56
-
57
- Generates UML diagrams from Solidity source code.
58
-
59
- If no file, folder or address is passed as the first argument, the working folder is used.
60
- When a folder is used, all *.sol files are found in that folder and all sub folders.
61
- A comma separated list of files and folders can also be used. For example
62
- sol2uml contracts,node_modules/openzeppelin-solidity
63
-
64
- If an Ethereum address with a 0x prefix is passed, the verified source code from Etherscan will be used. For example
65
- sol2uml 0x79fEbF6B9F76853EDBcBc913e6aAE8232cFB9De9`)
66
- .argument('[fileFolderAddress]', 'file name, base folder or contract address', process.cwd())
56
+ .argument('fileFolderAddress', argumentText)
67
57
  .option('-b, --baseContractNames <value>', 'only output contracts connected to these comma separated base contract names')
68
58
  .addOption(new commander_1.Option('-d, --depth <value>', 'depth of connected classes to the base contracts. 1 will only show directly connected contracts, interfaces, libraries, structs and enums.').default('100', 'all'))
69
59
  .option('-c, --clusterFolders', 'cluster contracts into source folders', false)
@@ -73,6 +63,7 @@ If an Ethereum address with a 0x prefix is passed, the verified source code from
73
63
  .option('-hm, --hideModifiers', 'hide modifier functions from contracts', false)
74
64
  .option('-ht, --hideEvents', 'hide events from contracts, interfaces and libraries', false)
75
65
  .option('-hc, --hideConstants', 'hide file level constants', false)
66
+ .option('-hx, --hideContracts', 'hide contracts', false)
76
67
  .option('-he, --hideEnums', 'hide enum types', false)
77
68
  .option('-hs, --hideStructs', 'hide data structures', false)
78
69
  .option('-hl, --hideLibraries', 'hide libraries', false)
@@ -91,21 +82,27 @@ If an Ethereum address with a 0x prefix is passed, the verified source code from
91
82
  let { umlClasses, contractName } = await (0, parserGeneral_1.parserUmlClasses)(fileFolderAddress, combinedOptions);
92
83
  if (options.squash &&
93
84
  // Must specify base contract(s) or parse from Etherscan to get contractName
94
- !(options.baseContractNames || contractName)) {
85
+ !options.baseContractNames &&
86
+ !contractName) {
95
87
  throw Error('Must specify base contract(s) when using the squash option against local Solidity files.');
96
88
  }
97
- // Filter out any class stereotypes that are to be hidden
98
- let filteredUmlClasses = (0, filterClasses_1.filterHiddenClasses)(umlClasses, options);
89
+ if (options.squash && options.hideContracts) {
90
+ throw Error('Can not hide contracts when squashing contracts.');
91
+ }
99
92
  const baseContractNames = options.baseContractNames?.split(',');
100
93
  if (baseContractNames) {
101
- // Find all the classes connected to the base classes
102
- filteredUmlClasses = (0, filterClasses_1.classesConnectedToBaseContracts)(filteredUmlClasses, baseContractNames, options.depth);
103
94
  contractName = baseContractNames[0];
104
95
  }
96
+ // Filter out any class stereotypes that are to be hidden
97
+ let filteredUmlClasses = (0, filterClasses_1.filterHiddenClasses)(umlClasses, options);
105
98
  // squash contracts
106
99
  if (options.squash) {
107
100
  filteredUmlClasses = (0, squashClasses_1.squashUmlClasses)(filteredUmlClasses, baseContractNames || [contractName]);
108
101
  }
102
+ if (baseContractNames || options.squash) {
103
+ // Find all the classes connected to the base classes after they have been squashed
104
+ filteredUmlClasses = (0, filterClasses_1.classesConnectedToBaseContracts)(filteredUmlClasses, baseContractNames || [contractName], options.depth);
105
+ }
109
106
  // Convert UML classes to Graphviz dot format.
110
107
  const dotString = (0, converterClasses2Dot_1.convertUmlClasses2Dot)(filteredUmlClasses, combinedOptions.clusterFolders, combinedOptions);
111
108
  // Convert Graphviz dot format to file formats. eg svg or png
@@ -119,11 +116,11 @@ If an Ethereum address with a 0x prefix is passed, the verified source code from
119
116
  });
120
117
  program
121
118
  .command('storage')
122
- .description("Visually display a contract's storage slots.")
123
- .usage(`[options] <fileFolderAddress>
119
+ .usage('[options] <fileFolderAddress>')
120
+ .description(`Visually display a contract's storage slots.
124
121
 
125
- WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A known example is fixed-sized arrays declared with an expression will fail to be sized.`)
126
- .argument('<fileFolderAddress>', 'file name, base folder or contract address')
122
+ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A known example is fixed-sized arrays declared with an expression will fail to be sized.\n`)
123
+ .argument('fileFolderAddress', argumentText)
127
124
  .option('-c, --contract <name>', 'Contract name in the local Solidity files. Not needed when using an address as the first argument as the contract name can be derived from Etherscan.')
128
125
  .option('-cf, --contractFile <filename>', 'Filename the contract is located in. This can include the relative path to the desired file.')
129
126
  .option('-d, --data', 'Gets the values in the storage slots from an Ethereum node.', false)
@@ -188,15 +185,15 @@ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A k
188
185
  });
189
186
  program
190
187
  .command('flatten')
191
- .description('Merges verified source files for a contract from a Blockchain explorer into one local file.')
192
- .usage(`<contractAddress>
188
+ .usage('<contractAddress>')
189
+ .description(`Merges verified source files for a contract from a Blockchain explorer into one local Solidity file.
193
190
 
194
191
  In order for the merged code to compile, the following is done:
195
192
  1. pragma solidity is set using the compiler of the verified contract.
196
193
  2. All pragma solidity lines in the source files are commented out.
197
194
  3. File imports are commented out.
198
195
  4. "SPDX-License-Identifier" is renamed to "SPDX--License-Identifier".
199
- 5. Contract dependencies are analysed so the files are merged in an order that will compile.`)
196
+ 5. Contract dependencies are analysed so the files are merged in an order that will compile.\n`)
200
197
  .argument('<contractAddress>', 'Contract address in hexadecimal format with a 0x prefix.')
201
198
  .action(async (contractAddress, options, command) => {
202
199
  try {
@@ -218,15 +215,15 @@ In order for the merged code to compile, the following is done:
218
215
  });
219
216
  program
220
217
  .command('diff')
221
- .description('Compare verified Solidity code differences between two contracts.')
222
- .usage(`[options] <addressA> <addressB>
218
+ .usage('[options] <addressA> <addressB>')
219
+ .description(`Compare verified Solidity code differences between two contracts.
223
220
 
224
- The results show the comparison of contracts A to B.
221
+ The results show the comparison of contract A to B.
225
222
  The ${clc.green('green')} sections are additions to contract B that are not in contract A.
226
223
  The ${clc.red('red')} sections are removals from contract A that are not in contract B.
227
- The line numbers are from contract B. There are no line numbers for the red sections as they are not in contract B.`)
228
- .argument('<addressA>', 'Contract address in hexadecimal format with a 0x prefix.')
229
- .argument('<addressB>', 'Contract address in hexadecimal format with a 0x prefix.')
224
+ The line numbers are from contract B. There are no line numbers for the red sections as they are not in contract B.\n`)
225
+ .argument('<addressA>', 'Contract address in hexadecimal format with a 0x prefix of the first contract.')
226
+ .argument('<addressB>', 'Contract address in hexadecimal format with a 0x prefix of the second contract.')
230
227
  .addOption(new commander_1.Option('-l, --lineBuffer <value>', 'Minimum number of lines before and after changes').default('4'))
231
228
  .option('-s, --saveFiles', 'Save the flattened contract code to the filesystem. The file names will be the contract address with a .sol extension.', false)
232
229
  .action(async (addressA, addressB, options, command) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sol2uml",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "Solidity contract visualisation tool.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -8,9 +8,12 @@
8
8
  "buildSol": "cd ./src/contracts && solc **/*.sol",
9
9
  "build": "tsc --build ./tsconfig.json",
10
10
  "clean": "tsc --build --clean ./tsconfig.json",
11
+ "package-lock": "npm i --package-lock-only",
12
+ "permit": " chmod 775 lib/sol2uml.js",
11
13
  "prettier": "prettier --write src/**/*.ts **/*.md",
12
14
  "prettier:check": "prettier --check src/**/*.ts **/*.md",
13
- "test": "npx jest"
15
+ "test": "npx jest",
16
+ "prepublishOnly": "npm run clean && npm run package-lock && npm run build && npm run permit"
14
17
  },
15
18
  "preferGlobal": true,
16
19
  "contributors": [