sol2uml 2.5.0 → 2.5.1
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
|
@@ -14,7 +14,7 @@ See more contract diagrams [here](./examples/README.md).
|
|
|
14
14
|
Storage layout diagram of USDC's [verified source code](https://etherscan.io/address/0xa2327a938febf5fec13bacfb16ae10ecbc4cbdcf#code) on Etherscan.
|
|
15
15
|

|
|
16
16
|
|
|
17
|
-
See an explanation of how storage diagrams work with lots of examples [here](./examples/storage/README.md).
|
|
17
|
+
See an explanation of how storage diagrams work with lots of examples [here](./examples/storage/README.md#example-storage-diagrams).
|
|
18
18
|
|
|
19
19
|
# Install
|
|
20
20
|
|
|
@@ -137,6 +137,7 @@ Options:
|
|
|
137
137
|
-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
138
|
-bn, --block <number> Block number to get the contract storage values from. (default: "latest")
|
|
139
139
|
-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.
|
|
140
141
|
-h, --help display help for command
|
|
141
142
|
```
|
|
142
143
|
|
|
@@ -267,7 +267,7 @@ const parseStorageSectionFromAttribute = (attribute, umlClass, otherClasses, sto
|
|
|
267
267
|
}
|
|
268
268
|
if (attribute.attributeType === umlClass_1.AttributeType.UserDefined) {
|
|
269
269
|
// Is the user defined type linked to another Contract, Struct or Enum?
|
|
270
|
-
const typeClass = findTypeClass(attribute.type, attribute, otherClasses);
|
|
270
|
+
const typeClass = findTypeClass(attribute.type, attribute, umlClass, otherClasses);
|
|
271
271
|
if (typeClass.stereotype === umlClass_1.ClassStereotype.Struct) {
|
|
272
272
|
const variables = parseVariables(typeClass, otherClasses, [], storageSections, [], mapping, arrayItems);
|
|
273
273
|
const storageSection = {
|
|
@@ -296,7 +296,7 @@ const parseStorageSectionFromAttribute = (attribute, umlClass, otherClasses, sto
|
|
|
296
296
|
// If mapping of user defined type
|
|
297
297
|
if (result !== null && result[1] && !(0, exports.isElementary)(result[1])) {
|
|
298
298
|
// Find UserDefined type can be a contract, struct or enum
|
|
299
|
-
const typeClass = findTypeClass(result[1], attribute, otherClasses);
|
|
299
|
+
const typeClass = findTypeClass(result[1], attribute, umlClass, otherClasses);
|
|
300
300
|
if (typeClass.stereotype === umlClass_1.ClassStereotype.Struct) {
|
|
301
301
|
let variables = parseVariables(typeClass, otherClasses, [], storageSections, [], true, arrayItems);
|
|
302
302
|
const storageSection = {
|
|
@@ -380,12 +380,17 @@ const addArrayVariables = (arrayLength, arrayItems, variables) => {
|
|
|
380
380
|
* Finds an attribute's user defined type that can be a Contract, Struct or Enum
|
|
381
381
|
* @param userType User defined type that is being looked for. This can be the base type of an attribute.
|
|
382
382
|
* @param attribute the attribute in the class that is user defined. This is just used for logging purposes
|
|
383
|
+
* @param umlClass the attribute is part of.
|
|
383
384
|
* @param otherClasses
|
|
384
385
|
*/
|
|
385
|
-
const findTypeClass = (userType, attribute, otherClasses) => {
|
|
386
|
+
const findTypeClass = (userType, attribute, umlClass, otherClasses) => {
|
|
386
387
|
// Find associated UserDefined type
|
|
387
|
-
|
|
388
|
-
const
|
|
388
|
+
const types = userType.split('.');
|
|
389
|
+
const association = {
|
|
390
|
+
referenceType: umlClass_1.ReferenceType.Memory,
|
|
391
|
+
targetUmlClassName: types.length === 1 ? types[0] : types[1],
|
|
392
|
+
};
|
|
393
|
+
const typeClass = (0, associations_1.findAssociatedClass)(association, umlClass, otherClasses);
|
|
389
394
|
if (!typeClass) {
|
|
390
395
|
throw Error(`Failed to find user defined type "${userType}" in attribute "${attribute.name}" of type "${attribute.attributeType}""`);
|
|
391
396
|
}
|
|
@@ -471,7 +476,7 @@ const calcStorageByteSize = (attribute, umlClass, otherClasses) => {
|
|
|
471
476
|
// TODO need to handle User Defined Value Types when they are added to Solidity
|
|
472
477
|
if (attribute.attributeType === umlClass_1.AttributeType.UserDefined) {
|
|
473
478
|
// Is the user defined type linked to another Contract, Struct or Enum?
|
|
474
|
-
const attributeTypeClass = findTypeClass(attribute.type, attribute, otherClasses);
|
|
479
|
+
const attributeTypeClass = findTypeClass(attribute.type, attribute, umlClass, otherClasses);
|
|
475
480
|
switch (attributeTypeClass.stereotype) {
|
|
476
481
|
case umlClass_1.ClassStereotype.Enum:
|
|
477
482
|
return { size: 1, dynamic: false };
|
|
@@ -491,7 +496,7 @@ const calcStorageByteSize = (attribute, umlClass, otherClasses) => {
|
|
|
491
496
|
else if (structAttribute.attributeType ===
|
|
492
497
|
umlClass_1.AttributeType.UserDefined) {
|
|
493
498
|
// UserDefined types can be a struct or enum, so we need to check if it's a struct
|
|
494
|
-
const userDefinedClass = findTypeClass(structAttribute.type, structAttribute, otherClasses);
|
|
499
|
+
const userDefinedClass = findTypeClass(structAttribute.type, structAttribute, umlClass, otherClasses);
|
|
495
500
|
// If a struct
|
|
496
501
|
if (userDefinedClass.stereotype ===
|
|
497
502
|
umlClass_1.ClassStereotype.Struct) {
|
|
@@ -5,7 +5,9 @@ export declare const convertStorages2Dot: (storageSections: readonly StorageSect
|
|
|
5
5
|
shapeColor: string;
|
|
6
6
|
fillColor: string;
|
|
7
7
|
textColor: string;
|
|
8
|
+
hideValues?: boolean;
|
|
8
9
|
}) => string;
|
|
9
10
|
export declare function convertStorage2Dot(storageSection: StorageSection, dotString: string, options: {
|
|
10
11
|
data: boolean;
|
|
12
|
+
hideValues?: boolean;
|
|
11
13
|
}): string;
|
|
@@ -54,7 +54,7 @@ function convertStorage2Dot(storageSection, dotString, options) {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
// write slot values if available
|
|
57
|
-
if (options.data) {
|
|
57
|
+
if (options.data && !options.hideValues) {
|
|
58
58
|
dotString += `} | {value${dataLine}`;
|
|
59
59
|
startingVariables.forEach((variable, i) => {
|
|
60
60
|
if (displayData[i]) {
|
package/lib/sol2uml.js
CHANGED
|
@@ -133,6 +133,7 @@ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A k
|
|
|
133
133
|
.default('http://localhost:8545'))
|
|
134
134
|
.option('-bn, --block <number>', 'Block number to get the contract storage values from.', 'latest')
|
|
135
135
|
.option('-a, --array <number>', 'Number of slots to display at the start and end of arrays.', '2')
|
|
136
|
+
.option('-hv, --hideValue', 'Hide storage slot value column.', false)
|
|
136
137
|
.action(async (fileFolderAddress, options, command) => {
|
|
137
138
|
try {
|
|
138
139
|
const combinedOptions = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sol2uml",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Solidity contract visualisation tool.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -20,28 +20,28 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@aduh95/viz.js": "^3.7.0",
|
|
23
|
-
"@solidity-parser/parser": "^0.
|
|
24
|
-
"axios": "1.
|
|
23
|
+
"@solidity-parser/parser": "^0.15.0",
|
|
24
|
+
"axios": "^1.3.4",
|
|
25
25
|
"axios-debug-log": "^1.0.0",
|
|
26
26
|
"cli-color": "^2.0.3",
|
|
27
|
-
"commander": "^
|
|
27
|
+
"commander": "^10.0.0",
|
|
28
28
|
"convert-svg-to-png": "^0.6.4",
|
|
29
29
|
"debug": "^4.3.4",
|
|
30
30
|
"diff-match-patch": "^1.0.5",
|
|
31
31
|
"ethers": "^5.7.2",
|
|
32
32
|
"js-graph-algorithms": "^1.0.18",
|
|
33
|
-
"klaw": "^4.0
|
|
33
|
+
"klaw": "^4.1.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@openzeppelin/contracts": "4.8.0",
|
|
37
37
|
"@types/diff-match-patch": "^1.0.32",
|
|
38
38
|
"@types/jest": "^29.4.0",
|
|
39
39
|
"@types/klaw": "^3.0.3",
|
|
40
|
-
"jest": "^29.4.
|
|
41
|
-
"prettier": "^2.8.
|
|
40
|
+
"jest": "^29.4.3",
|
|
41
|
+
"prettier": "^2.8.4",
|
|
42
42
|
"ts-jest": "^29.0.5",
|
|
43
43
|
"ts-node": "^10.9.1",
|
|
44
|
-
"typescript": "^4.9.
|
|
44
|
+
"typescript": "^4.9.5"
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
47
|
"lib/*.js",
|