sol2uml 2.1.3 → 2.1.4
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 +2 -2
- package/lib/parserEtherscan.d.ts +1 -1
- package/lib/parserEtherscan.js +58 -7
- package/lib/sol2uml.js +13 -16
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -58,8 +58,8 @@ Options:
|
|
|
58
58
|
-f, --outputFormat <value> output file format. (choices: "svg", "png", "dot", "all", default: "svg")
|
|
59
59
|
-o, --outputFileName <value> output file name
|
|
60
60
|
-i, --ignoreFilesOrFolders <filesOrFolders> comma separated list of files or folders to ignore
|
|
61
|
-
-n, --network <network> Ethereum network (choices: "mainnet", "polygon", "
|
|
62
|
-
-k, --apiKey <key> Etherscan,
|
|
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", "testnet.fantom", "moonbeam", "optimistic", "kovan-optimistic", default: "mainnet", env: ETH_NETWORK)
|
|
62
|
+
-k, --apiKey <key> Blockchain explorer API key. eg Etherscan, Arbiscan, BscScan, CronoScan, FTMScan, PolygonScan or SnowTrace API key (env: SCAN_API_KEY)
|
|
63
63
|
-v, --verbose run with debugging statements (default: false)
|
|
64
64
|
-h, --help display help for command
|
|
65
65
|
|
package/lib/parserEtherscan.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ASTNode } from '@solidity-parser/parser/dist/src/ast-types';
|
|
2
2
|
import { UmlClass } from './umlClass';
|
|
3
|
-
declare const networks: readonly ["mainnet", "ropsten", "kovan", "rinkeby", "goerli", "sepolia", "polygon", "
|
|
3
|
+
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"];
|
|
4
4
|
declare type Network = typeof networks[number];
|
|
5
5
|
export declare class EtherscanParser {
|
|
6
6
|
protected apikey: string;
|
package/lib/parserEtherscan.js
CHANGED
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EtherscanParser = void 0;
|
|
6
|
+
exports.EtherscanParser = exports.networks = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const parser_1 = require("@solidity-parser/parser");
|
|
9
9
|
const converterAST2Classes_1 = require("./converterAST2Classes");
|
|
10
10
|
const filterClasses_1 = require("./filterClasses");
|
|
11
11
|
const debug = require('debug')('sol2uml');
|
|
12
|
-
|
|
12
|
+
exports.networks = [
|
|
13
13
|
'mainnet',
|
|
14
14
|
'ropsten',
|
|
15
15
|
'kovan',
|
|
@@ -17,15 +17,26 @@ const networks = [
|
|
|
17
17
|
'goerli',
|
|
18
18
|
'sepolia',
|
|
19
19
|
'polygon',
|
|
20
|
-
'
|
|
20
|
+
'testnet.polygon',
|
|
21
21
|
'arbitrum',
|
|
22
|
+
'testnet.arbitrum',
|
|
23
|
+
'avalanche',
|
|
24
|
+
'testnet.avalanche',
|
|
25
|
+
'bsc',
|
|
26
|
+
'testnet.bsc',
|
|
27
|
+
'crono',
|
|
28
|
+
'fantom',
|
|
29
|
+
'testnet.fantom',
|
|
30
|
+
'moonbeam',
|
|
31
|
+
'optimistic',
|
|
32
|
+
'kovan-optimistic',
|
|
22
33
|
];
|
|
23
34
|
class EtherscanParser {
|
|
24
35
|
constructor(apikey = 'ZAD4UI2RCXCQTP38EXS3UY2MPHFU5H9KB1', network = 'mainnet') {
|
|
25
36
|
this.apikey = apikey;
|
|
26
37
|
this.network = network;
|
|
27
|
-
if (!networks.includes(network)) {
|
|
28
|
-
throw new Error(`Invalid network "${network}". Must be one of ${networks}`);
|
|
38
|
+
if (!exports.networks.includes(network)) {
|
|
39
|
+
throw new Error(`Invalid network "${network}". Must be one of ${exports.networks}`);
|
|
29
40
|
}
|
|
30
41
|
else if (network === 'mainnet') {
|
|
31
42
|
this.url = 'https://api.etherscan.io/api';
|
|
@@ -34,12 +45,52 @@ class EtherscanParser {
|
|
|
34
45
|
this.url = 'https://api.polygonscan.com/api';
|
|
35
46
|
this.apikey = 'AMHGNTV5A7XYGX2M781JB3RC1DZFVRWQEB';
|
|
36
47
|
}
|
|
48
|
+
else if (network === 'testnet.polygon') {
|
|
49
|
+
this.url = 'https://api-testnet.polygonscan.com/api';
|
|
50
|
+
this.apikey = 'AMHGNTV5A7XYGX2M781JB3RC1DZFVRWQEB';
|
|
51
|
+
}
|
|
52
|
+
else if (network === 'arbitrum') {
|
|
53
|
+
this.url = 'https://api.arbiscan.io/api';
|
|
54
|
+
this.apikey = 'ZGTK2TAGWMAB6IAC12BMK8YYPNCPIM8VDQ';
|
|
55
|
+
}
|
|
56
|
+
else if (network === 'testnet.arbitrum') {
|
|
57
|
+
this.url = 'https://api-testnet.arbiscan.io/api';
|
|
58
|
+
this.apikey = 'ZGTK2TAGWMAB6IAC12BMK8YYPNCPIM8VDQ';
|
|
59
|
+
}
|
|
60
|
+
else if (network === 'avalanche') {
|
|
61
|
+
this.url = 'https://api.snowtrace.io/api';
|
|
62
|
+
this.apikey = 'U5FAN98S5XNH5VI83TI4H35R9I4TDCKEJY';
|
|
63
|
+
}
|
|
64
|
+
else if (network === 'testnet.avalanche') {
|
|
65
|
+
this.url = 'https://api-testnet.snowtrace.io/api';
|
|
66
|
+
this.apikey = 'U5FAN98S5XNH5VI83TI4H35R9I4TDCKEJY';
|
|
67
|
+
}
|
|
37
68
|
else if (network === 'bsc') {
|
|
38
69
|
this.url = 'https://api.bscscan.com/api';
|
|
70
|
+
}
|
|
71
|
+
else if (network === 'testnet.bsc') {
|
|
72
|
+
this.url = 'https://api-testnet.bscscan.com/api';
|
|
73
|
+
}
|
|
74
|
+
else if (network === 'crono') {
|
|
75
|
+
this.url = 'https://api.cronoscan.com/api';
|
|
76
|
+
this.apikey = '76A3RG5WHTPMMR66E9SFI2EIDT6MP976W2';
|
|
39
77
|
this.apikey = 'APYH49FXVY9UA3KTDI6F4WP3KPIC86NITN';
|
|
40
78
|
}
|
|
41
|
-
else if (network === '
|
|
42
|
-
this.url = 'https://api.
|
|
79
|
+
else if (network === 'fantom') {
|
|
80
|
+
this.url = 'https://api.ftmscan.com/api';
|
|
81
|
+
this.apikey = '71KRX13XPZMGR3D1Q85W78G2DSZ4JPMAEX';
|
|
82
|
+
}
|
|
83
|
+
else if (network === 'testnet.fantom') {
|
|
84
|
+
this.url = 'https://api-testnet.ftmscan.com/api';
|
|
85
|
+
this.apikey = '71KRX13XPZMGR3D1Q85W78G2DSZ4JPMAEX';
|
|
86
|
+
}
|
|
87
|
+
else if (network === 'optimistic' || network === 'kovan-optimistic') {
|
|
88
|
+
this.url = `https://api-${network}.etherscan.io/api`;
|
|
89
|
+
this.apikey = 'FEXS1HXVA4Y2RNTMEA8V1UTK21S4JWHH9U';
|
|
90
|
+
}
|
|
91
|
+
else if (network === 'moonbeam') {
|
|
92
|
+
this.url = 'https://api-moonbeam.moonscan.io/api';
|
|
93
|
+
this.apikey = '5EUFXW6TDC16VERF3D9SCWRRU6AEMTBHNJ';
|
|
43
94
|
}
|
|
44
95
|
else {
|
|
45
96
|
this.url = `https://api-${network}.etherscan.io/api`;
|
package/lib/sol2uml.js
CHANGED
|
@@ -10,8 +10,12 @@ const converterClasses2Storage_1 = require("./converterClasses2Storage");
|
|
|
10
10
|
const converterStorage2Dot_1 = require("./converterStorage2Dot");
|
|
11
11
|
const regEx_1 = require("./utils/regEx");
|
|
12
12
|
const writerFiles_1 = require("./writerFiles");
|
|
13
|
+
const path_1 = require("path");
|
|
13
14
|
const program = new commander_1.Command();
|
|
14
|
-
|
|
15
|
+
const version = (0, path_1.basename)(__dirname) === 'lib'
|
|
16
|
+
? require('../package.json').version // used when run from compile js in /lib
|
|
17
|
+
: require('../../package.json').version; // used when run from TypeScript source files under src/ts via ts-node
|
|
18
|
+
program.version(version);
|
|
15
19
|
const debugControl = require('debug');
|
|
16
20
|
const debug = require('debug')('sol2uml');
|
|
17
21
|
program
|
|
@@ -30,20 +34,10 @@ The Solidity code can be pulled from verified source code on Blockchain explorer
|
|
|
30
34
|
.option('-o, --outputFileName <value>', 'output file name')
|
|
31
35
|
.option('-i, --ignoreFilesOrFolders <filesOrFolders>', 'comma separated list of files or folders to ignore')
|
|
32
36
|
.addOption(new commander_1.Option('-n, --network <network>', 'Ethereum network')
|
|
33
|
-
.choices(
|
|
34
|
-
'mainnet',
|
|
35
|
-
'polygon',
|
|
36
|
-
'bsc',
|
|
37
|
-
'arbitrum',
|
|
38
|
-
'ropsten',
|
|
39
|
-
'kovan',
|
|
40
|
-
'rinkeby',
|
|
41
|
-
'goerli',
|
|
42
|
-
'sepolia',
|
|
43
|
-
])
|
|
37
|
+
.choices(parserEtherscan_1.networks)
|
|
44
38
|
.default('mainnet')
|
|
45
39
|
.env('ETH_NETWORK'))
|
|
46
|
-
.addOption(new commander_1.Option('-k, --apiKey <key>', 'Etherscan,
|
|
40
|
+
.addOption(new commander_1.Option('-k, --apiKey <key>', 'Blockchain explorer API key. eg Etherscan, Arbiscan, BscScan, CronoScan, FTMScan, PolygonScan or SnowTrace API key').env('SCAN_API_KEY'))
|
|
47
41
|
.option('-v, --verbose', 'run with debugging statements', false);
|
|
48
42
|
program
|
|
49
43
|
.command('class', { isDefault: true })
|
|
@@ -90,7 +84,8 @@ If an Ethereum address with a 0x prefix is passed, the verified source code from
|
|
|
90
84
|
debug(`Finished generating UML`);
|
|
91
85
|
}
|
|
92
86
|
catch (err) {
|
|
93
|
-
console.error(
|
|
87
|
+
console.error(err);
|
|
88
|
+
process.exit(2);
|
|
94
89
|
}
|
|
95
90
|
});
|
|
96
91
|
program
|
|
@@ -143,7 +138,8 @@ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A k
|
|
|
143
138
|
await (0, writerFiles_1.writeOutputFiles)(dotString, fileFolderAddress, contractName || 'storageDiagram', combinedOptions.outputFormat, combinedOptions.outputFileName);
|
|
144
139
|
}
|
|
145
140
|
catch (err) {
|
|
146
|
-
console.error(
|
|
141
|
+
console.error(err.stack);
|
|
142
|
+
process.exit(2);
|
|
147
143
|
}
|
|
148
144
|
});
|
|
149
145
|
program
|
|
@@ -170,7 +166,8 @@ In order for the merged code to compile, the following is done:
|
|
|
170
166
|
await (0, writerFiles_1.writeSolidity)(solidityCode, outputFilename);
|
|
171
167
|
}
|
|
172
168
|
catch (err) {
|
|
173
|
-
console.error(
|
|
169
|
+
console.error(err);
|
|
170
|
+
process.exit(2);
|
|
174
171
|
}
|
|
175
172
|
});
|
|
176
173
|
program.on('option:verbose', () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sol2uml",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.1.4",
|
|
4
|
+
"description": "Solidity contract visualisation tool.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -54,14 +54,15 @@
|
|
|
54
54
|
"UML",
|
|
55
55
|
"Solidity",
|
|
56
56
|
"Ethereum",
|
|
57
|
-
"Class diagram",
|
|
58
|
-
"Class",
|
|
59
57
|
"diagram",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"SVG",
|
|
58
|
+
"class",
|
|
59
|
+
"diagram",
|
|
60
|
+
"contract",
|
|
64
61
|
"Blockchain",
|
|
65
|
-
"
|
|
62
|
+
"storage",
|
|
63
|
+
"flatten",
|
|
64
|
+
"visual",
|
|
65
|
+
"tool",
|
|
66
|
+
"cli"
|
|
66
67
|
]
|
|
67
68
|
}
|