sol2uml 2.1.4 → 2.1.5
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 +7 -6
- package/lib/converterClasses2Storage.d.ts +1 -1
- package/lib/converterClasses2Storage.js +18 -4
- package/lib/sol2uml.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -119,12 +119,13 @@ Arguments:
|
|
|
119
119
|
fileFolderAddress file name, base folder or contract address
|
|
120
120
|
|
|
121
121
|
Options:
|
|
122
|
-
-c, --contract <name>
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
122
|
+
-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.
|
|
123
|
+
-cf, --contractFile <filename> Filename the contract is located in. This can include the relative path to the desired file.
|
|
124
|
+
-d, --data Gets the values in the storage slots from an Ethereum node. (default: false)
|
|
125
|
+
-s, --storage <address> The address of the contract with the storage values. This will be different from the contract with the code if a proxy contract is used. This is not needed if `fileFolderAddress` is an address and the contract is not proxied.
|
|
126
|
+
-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)
|
|
127
|
+
-bn, --block <number> Block number to get the contract storage values from. (default: "latest")
|
|
128
|
+
-h, --help display help for command
|
|
128
129
|
```
|
|
129
130
|
|
|
130
131
|
### Flatten usage
|
|
@@ -36,7 +36,7 @@ export interface Storage {
|
|
|
36
36
|
* @param storage is mutated with the storage values
|
|
37
37
|
*/
|
|
38
38
|
export declare const addStorageValues: (url: string, contractAddress: string, storage: Storage, blockTag: string) => Promise<void>;
|
|
39
|
-
export declare const convertClasses2Storages: (contractName: string, umlClasses: UmlClass[]) => Storage[];
|
|
39
|
+
export declare const convertClasses2Storages: (contractName: string, umlClasses: UmlClass[], contractFilename?: string) => Storage[];
|
|
40
40
|
export declare const parseReferenceStorage: (attribute: Attribute, umlClass: UmlClass, otherClasses: UmlClass[], storages: Storage[]) => Storage | undefined;
|
|
41
41
|
export declare const calcStorageByteSize: (attribute: Attribute, umlClass: UmlClass, otherClasses: UmlClass[]) => {
|
|
42
42
|
size: number;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.findDimensionLength = exports.offsetStorageSlots = exports.calcSlotKey = exports.isElementary = exports.calcStorageByteSize = exports.parseReferenceStorage = exports.convertClasses2Storages = exports.addStorageValues = exports.StorageType = void 0;
|
|
4
7
|
const umlClass_1 = require("./umlClass");
|
|
@@ -6,6 +9,8 @@ const associations_1 = require("./associations");
|
|
|
6
9
|
const slotValues_1 = require("./slotValues");
|
|
7
10
|
const utils_1 = require("ethers/lib/utils");
|
|
8
11
|
const ethers_1 = require("ethers");
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const debug = require('debug')('sol2uml');
|
|
9
14
|
var StorageType;
|
|
10
15
|
(function (StorageType) {
|
|
11
16
|
StorageType["Contract"] = "Contract";
|
|
@@ -29,14 +34,23 @@ const addStorageValues = async (url, contractAddress, storage, blockTag) => {
|
|
|
29
34
|
});
|
|
30
35
|
};
|
|
31
36
|
exports.addStorageValues = addStorageValues;
|
|
32
|
-
const convertClasses2Storages = (contractName, umlClasses) => {
|
|
37
|
+
const convertClasses2Storages = (contractName, umlClasses, contractFilename) => {
|
|
33
38
|
// Find the base UML Class from the base contract name
|
|
34
|
-
const umlClass = umlClasses.find(({ name }) => {
|
|
35
|
-
|
|
39
|
+
const umlClass = umlClasses.find(({ name, relativePath }) => {
|
|
40
|
+
if (!contractFilename) {
|
|
41
|
+
return name === contractName;
|
|
42
|
+
}
|
|
43
|
+
return (name === contractName &&
|
|
44
|
+
(relativePath == contractFilename ||
|
|
45
|
+
path_1.default.basename(relativePath) === contractFilename));
|
|
36
46
|
});
|
|
37
47
|
if (!umlClass) {
|
|
38
|
-
|
|
48
|
+
const contractFilenameError = contractFilename
|
|
49
|
+
? ` in filename "${contractFilename}"`
|
|
50
|
+
: '';
|
|
51
|
+
throw Error(`Failed to find contract with name "${contractName}"${contractFilenameError}`);
|
|
39
52
|
}
|
|
53
|
+
debug(`Found contract "${contractName}" in ${umlClass.absolutePath}`);
|
|
40
54
|
const storages = [];
|
|
41
55
|
const variables = parseVariables(umlClass, umlClasses, [], storages, []);
|
|
42
56
|
storages.unshift({
|
package/lib/sol2uml.js
CHANGED
|
@@ -95,7 +95,8 @@ program
|
|
|
95
95
|
|
|
96
96
|
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.`)
|
|
97
97
|
.argument('<fileFolderAddress>', 'file name, base folder or contract address')
|
|
98
|
-
.option('-c, --contract <name>', 'Contract name in local Solidity files. Not needed when using an address as the first argument as the contract name can be derived from Etherscan.')
|
|
98
|
+
.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.')
|
|
99
|
+
.option('-cf, --contractFile <filename>', 'Filename the contract is located in. This can include the relative path to the desired file.')
|
|
99
100
|
.option('-d, --data', 'Gets the values in the storage slots from an Ethereum node.', false)
|
|
100
101
|
.option('-s, --storage <address>', 'The address of the contract with the storage values. This will be different from the contract with the code if a proxy contract is used. This is not needed if `fileFolderAddress` is an address and the contract is not proxied.')
|
|
101
102
|
.addOption(new commander_1.Option('-u, --url <url>', 'URL of the Ethereum node to get storage values if the `data` option is used.')
|
|
@@ -110,7 +111,7 @@ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A k
|
|
|
110
111
|
};
|
|
111
112
|
let { umlClasses, contractName } = await (0, parserGeneral_1.parserUmlClasses)(fileFolderAddress, combinedOptions);
|
|
112
113
|
contractName = combinedOptions.contract || contractName;
|
|
113
|
-
const storages = (0, converterClasses2Storage_1.convertClasses2Storages)(contractName, umlClasses);
|
|
114
|
+
const storages = (0, converterClasses2Storage_1.convertClasses2Storages)(contractName, umlClasses, combinedOptions.contractFile);
|
|
114
115
|
if ((0, regEx_1.isAddress)(fileFolderAddress)) {
|
|
115
116
|
// The first storage is the contract
|
|
116
117
|
storages[0].address = fileFolderAddress;
|
|
@@ -125,7 +126,7 @@ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A k
|
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
128
|
if (!(0, regEx_1.isAddress)(fileFolderAddress)) {
|
|
128
|
-
throw Error(`Can not get storage slot values if first param is not an address and the \`
|
|
129
|
+
throw Error(`Can not get storage slot values if first param is not an address and the \`--storage\` option is not used.`);
|
|
129
130
|
}
|
|
130
131
|
storageAddress = fileFolderAddress;
|
|
131
132
|
}
|