sol2uml 2.5.1 → 2.5.2
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 +46 -35
- package/lib/parserEtherscan.d.ts +1 -1
- package/lib/parserEtherscan.js +5 -34
- package/lib/sol2uml.js +30 -38
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Solidity 2 UML
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/sol2uml)
|
|
4
|
+
[](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 [
|
|
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
|
-
|
|
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", "
|
|
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]
|
|
74
|
-
storage [options] <fileFolderAddress>
|
|
75
|
-
|
|
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,
|
|
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
|
|
@@ -122,12 +128,17 @@ Options:
|
|
|
122
128
|
```
|
|
123
129
|
Usage: sol2uml storage [options] <fileFolderAddress>
|
|
124
130
|
|
|
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
131
|
Visually display a contract's storage slots.
|
|
128
132
|
|
|
133
|
+
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.
|
|
134
|
+
|
|
129
135
|
Arguments:
|
|
130
|
-
fileFolderAddress
|
|
136
|
+
fileFolderAddress file name, folder(s) or contract address.
|
|
137
|
+
When a folder is used, all *.sol files in that folder and all sub folders are used.
|
|
138
|
+
A comma-separated list of files and folders can also be used. For example
|
|
139
|
+
sol2uml contracts,node_modules/openzeppelin-solidity
|
|
140
|
+
If an Ethereum address with a 0x prefix is passed, the verified source code from Etherscan will be used. For example
|
|
141
|
+
sol2uml 0x79fEbF6B9F76853EDBcBc913e6aAE8232cFB9De9
|
|
131
142
|
|
|
132
143
|
Options:
|
|
133
144
|
-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 +148,7 @@ Options:
|
|
|
137
148
|
-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
149
|
-bn, --block <number> Block number to get the contract storage values from. (default: "latest")
|
|
139
150
|
-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.
|
|
151
|
+
-hv, --hideValue Hide storage slot value column. (default: false)
|
|
141
152
|
-h, --help display help for command
|
|
142
153
|
```
|
|
143
154
|
|
|
@@ -146,6 +157,8 @@ Options:
|
|
|
146
157
|
```
|
|
147
158
|
Usage: sol2uml flatten <contractAddress>
|
|
148
159
|
|
|
160
|
+
Merges verified source files for a contract from a Blockchain explorer into one local Solidity file.
|
|
161
|
+
|
|
149
162
|
In order for the merged code to compile, the following is done:
|
|
150
163
|
1. pragma solidity is set using the compiler of the verified contract.
|
|
151
164
|
2. All pragma solidity lines in the source files are commented out.
|
|
@@ -153,8 +166,6 @@ In order for the merged code to compile, the following is done:
|
|
|
153
166
|
4. "SPDX-License-Identifier" is renamed to "SPDX--License-Identifier".
|
|
154
167
|
5. Contract dependencies are analysed so the files are merged in an order that will compile.
|
|
155
168
|
|
|
156
|
-
Merges verified source files for a contract from a Blockchain explorer into one local file.
|
|
157
|
-
|
|
158
169
|
Arguments:
|
|
159
170
|
contractAddress Contract address in hexadecimal format with a 0x prefix.
|
|
160
171
|
|
|
@@ -167,16 +178,16 @@ Options:
|
|
|
167
178
|
```
|
|
168
179
|
Usage: sol2uml diff [options] <addressA> <addressB>
|
|
169
180
|
|
|
170
|
-
|
|
181
|
+
Compare verified Solidity code differences between two contracts.
|
|
182
|
+
|
|
183
|
+
The results show the comparison of contract A to B.
|
|
171
184
|
The green sections are additions to contract B that are not in contract A.
|
|
172
185
|
The red sections are removals from contract A that are not in contract B.
|
|
173
186
|
The line numbers are from contract B. There are no line numbers for the red sections as they are not in contract B.
|
|
174
187
|
|
|
175
|
-
Compare verified Solidity code differences between two contracts.
|
|
176
|
-
|
|
177
188
|
Arguments:
|
|
178
|
-
addressA Contract address in hexadecimal format with a 0x prefix.
|
|
179
|
-
addressB Contract address in hexadecimal format with a 0x prefix.
|
|
189
|
+
addressA Contract address in hexadecimal format with a 0x prefix of the first contract.
|
|
190
|
+
addressB Contract address in hexadecimal format with a 0x prefix of the second contract.
|
|
180
191
|
|
|
181
192
|
Options:
|
|
182
193
|
-l, --lineBuffer <value> Minimum number of lines before and after changes (default: "4")
|
package/lib/parserEtherscan.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface Remapping {
|
|
|
4
4
|
from: RegExp;
|
|
5
5
|
to: string;
|
|
6
6
|
}
|
|
7
|
-
export declare const networks: readonly ["mainnet", "
|
|
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;
|
package/lib/parserEtherscan.js
CHANGED
|
@@ -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
|
-
'
|
|
34
|
-
'
|
|
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 === '
|
|
88
|
-
this.url =
|
|
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 === '
|
|
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(
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
.
|
|
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)
|
|
@@ -94,18 +84,20 @@ If an Ethereum address with a 0x prefix is passed, the verified source code from
|
|
|
94
84
|
!(options.baseContractNames || contractName)) {
|
|
95
85
|
throw Error('Must specify base contract(s) when using the squash option against local Solidity files.');
|
|
96
86
|
}
|
|
97
|
-
// Filter out any class stereotypes that are to be hidden
|
|
98
|
-
let filteredUmlClasses = (0, filterClasses_1.filterHiddenClasses)(umlClasses, options);
|
|
99
87
|
const baseContractNames = options.baseContractNames?.split(',');
|
|
100
88
|
if (baseContractNames) {
|
|
101
|
-
// Find all the classes connected to the base classes
|
|
102
|
-
filteredUmlClasses = (0, filterClasses_1.classesConnectedToBaseContracts)(filteredUmlClasses, baseContractNames, options.depth);
|
|
103
89
|
contractName = baseContractNames[0];
|
|
104
90
|
}
|
|
91
|
+
// Filter out any class stereotypes that are to be hidden
|
|
92
|
+
let filteredUmlClasses = (0, filterClasses_1.filterHiddenClasses)(umlClasses, options);
|
|
105
93
|
// squash contracts
|
|
106
94
|
if (options.squash) {
|
|
107
95
|
filteredUmlClasses = (0, squashClasses_1.squashUmlClasses)(filteredUmlClasses, baseContractNames || [contractName]);
|
|
108
96
|
}
|
|
97
|
+
if (baseContractNames || options.squash) {
|
|
98
|
+
// Find all the classes connected to the base classes after they have been squashed
|
|
99
|
+
filteredUmlClasses = (0, filterClasses_1.classesConnectedToBaseContracts)(filteredUmlClasses, baseContractNames || [contractName], options.depth);
|
|
100
|
+
}
|
|
109
101
|
// Convert UML classes to Graphviz dot format.
|
|
110
102
|
const dotString = (0, converterClasses2Dot_1.convertUmlClasses2Dot)(filteredUmlClasses, combinedOptions.clusterFolders, combinedOptions);
|
|
111
103
|
// Convert Graphviz dot format to file formats. eg svg or png
|
|
@@ -119,11 +111,11 @@ If an Ethereum address with a 0x prefix is passed, the verified source code from
|
|
|
119
111
|
});
|
|
120
112
|
program
|
|
121
113
|
.command('storage')
|
|
122
|
-
.
|
|
123
|
-
.
|
|
114
|
+
.usage('[options] <fileFolderAddress>')
|
|
115
|
+
.description(`Visually display a contract's storage slots.
|
|
124
116
|
|
|
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('
|
|
117
|
+
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`)
|
|
118
|
+
.argument('fileFolderAddress', argumentText)
|
|
127
119
|
.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
120
|
.option('-cf, --contractFile <filename>', 'Filename the contract is located in. This can include the relative path to the desired file.')
|
|
129
121
|
.option('-d, --data', 'Gets the values in the storage slots from an Ethereum node.', false)
|
|
@@ -188,15 +180,15 @@ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A k
|
|
|
188
180
|
});
|
|
189
181
|
program
|
|
190
182
|
.command('flatten')
|
|
191
|
-
.
|
|
192
|
-
.
|
|
183
|
+
.usage('<contractAddress>')
|
|
184
|
+
.description(`Merges verified source files for a contract from a Blockchain explorer into one local Solidity file.
|
|
193
185
|
|
|
194
186
|
In order for the merged code to compile, the following is done:
|
|
195
187
|
1. pragma solidity is set using the compiler of the verified contract.
|
|
196
188
|
2. All pragma solidity lines in the source files are commented out.
|
|
197
189
|
3. File imports are commented out.
|
|
198
190
|
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
|
|
191
|
+
5. Contract dependencies are analysed so the files are merged in an order that will compile.\n`)
|
|
200
192
|
.argument('<contractAddress>', 'Contract address in hexadecimal format with a 0x prefix.')
|
|
201
193
|
.action(async (contractAddress, options, command) => {
|
|
202
194
|
try {
|
|
@@ -218,15 +210,15 @@ In order for the merged code to compile, the following is done:
|
|
|
218
210
|
});
|
|
219
211
|
program
|
|
220
212
|
.command('diff')
|
|
221
|
-
.
|
|
222
|
-
.
|
|
213
|
+
.usage('[options] <addressA> <addressB>')
|
|
214
|
+
.description(`Compare verified Solidity code differences between two contracts.
|
|
223
215
|
|
|
224
|
-
The results show the comparison of
|
|
216
|
+
The results show the comparison of contract A to B.
|
|
225
217
|
The ${clc.green('green')} sections are additions to contract B that are not in contract A.
|
|
226
218
|
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.')
|
|
219
|
+
The line numbers are from contract B. There are no line numbers for the red sections as they are not in contract B.\n`)
|
|
220
|
+
.argument('<addressA>', 'Contract address in hexadecimal format with a 0x prefix of the first contract.')
|
|
221
|
+
.argument('<addressB>', 'Contract address in hexadecimal format with a 0x prefix of the second contract.')
|
|
230
222
|
.addOption(new commander_1.Option('-l, --lineBuffer <value>', 'Minimum number of lines before and after changes').default('4'))
|
|
231
223
|
.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
224
|
.action(async (addressA, addressB, options, command) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sol2uml",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
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": [
|