Comparing version 2.0.4 to 2.0.5
@@ -175,2 +175,12 @@ "use strict"; | ||
}); | ||
// Is the variable a constant that could be used in declaring fixed sized arrays | ||
if (variable.isDeclaredConst) { | ||
if (variable?.expression.type === 'NumberLiteral') { | ||
umlClass.constants.push({ | ||
name: variable.name, | ||
value: parseInt(variable.expression.number), | ||
}); | ||
} | ||
// TODO handle expressions. eg N_COINS * 2 | ||
} | ||
}); | ||
@@ -177,0 +187,0 @@ // Recursively parse variables for associations |
@@ -173,3 +173,3 @@ "use strict"; | ||
// All array dimensions must be fixed. eg [2][3][8]. | ||
const result = attribute.type.match(/(\w+)(\[([1-9][0-9]*)\])+$/); | ||
const result = attribute.type.match(/(\w+)(\[([\w][\w]*)\])+$/); | ||
// The above will not match any dynamic array dimensions, eg [], | ||
@@ -184,5 +184,15 @@ // as there needs to be one or more [0-9]+ in the square brackets | ||
// to get a total number of array elements | ||
const arrayDimensions = attribute.type.match(/\[\d+/g); | ||
const arrayDimensions = attribute.type.match(/\[\w+/g); | ||
const dimensionsStr = arrayDimensions.map((d) => d.slice(1)); | ||
const dimensions = dimensionsStr.map((d) => parseInt(d)); | ||
const dimensions = dimensionsStr.map((dimension) => { | ||
const dimensionNum = parseInt(dimension); | ||
if (!isNaN(dimensionNum)) | ||
return dimensionNum; | ||
// Try and size array dimension from declared constants | ||
const constant = umlClass.constants.find((constant) => constant.name === dimension); | ||
if (constant) { | ||
return constant.value; | ||
} | ||
throw Error(`Could not size fixed sized array with dimension "${dimension}"`); | ||
}); | ||
let elementSize; | ||
@@ -189,0 +199,0 @@ // If a fixed sized array |
@@ -94,3 +94,3 @@ #! /usr/bin/env node | ||
.command('storage') | ||
.description("Visually display a contract's storage slots.\n\nWARNING: sol2uml does not use the Solidity compiler so may differ with solc. A known example is storage arrays declared with a constant, immutable or expression will show as only taking one slot but it could be more. Storage arrays declared with an integer work.") | ||
.description("Visually display a contract's storage slots.\n\nWARNING: 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.") | ||
.argument('<fileFolderAddress>', 'file name, base folder or contract address') | ||
@@ -97,0 +97,0 @@ .option('-c, --contractName <value>', 'Contract name in local Solidity files. Not needed when using an address as the first argument.') |
@@ -66,2 +66,6 @@ export declare enum Visibility { | ||
} | ||
export interface Constants { | ||
name: string; | ||
value: number; | ||
} | ||
export interface ClassProperties { | ||
@@ -80,2 +84,3 @@ name: string; | ||
}; | ||
constants?: Constants[]; | ||
} | ||
@@ -90,2 +95,3 @@ export declare class UmlClass implements ClassProperties { | ||
stereotype?: ClassStereotype; | ||
constants: Constants[]; | ||
attributes: Attribute[]; | ||
@@ -92,0 +98,0 @@ operators: Operator[]; |
@@ -46,2 +46,3 @@ "use strict"; | ||
constructor(properties) { | ||
this.constants = []; | ||
this.attributes = []; | ||
@@ -48,0 +49,0 @@ this.operators = []; |
{ | ||
"name": "sol2uml", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Unified Modeling Language (UML) class diagram generator for Solidity contracts", | ||
@@ -28,3 +28,2 @@ "main": "./lib/index.js", | ||
"debug": "^4.3.4", | ||
"ethers": "^5.6.9", | ||
"js-graph-algorithms": "^1.0.18", | ||
@@ -31,0 +30,0 @@ "klaw": "^4.0.1" |
@@ -115,3 +115,3 @@ # Solidity 2 UML | ||
WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A known example is storage arrays declared with a constant, immutable or expression will show as only taking one slot but it could be more. Storage arrays declared with an integer work. | ||
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. | ||
@@ -118,0 +118,0 @@ Arguments: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118955
8
37
2416
- Removedethers@^5.6.9
- Removed@ethersproject/abi@5.7.0(transitive)
- Removed@ethersproject/abstract-provider@5.7.0(transitive)
- Removed@ethersproject/abstract-signer@5.7.0(transitive)
- Removed@ethersproject/address@5.7.0(transitive)
- Removed@ethersproject/base64@5.7.0(transitive)
- Removed@ethersproject/basex@5.7.0(transitive)
- Removed@ethersproject/bignumber@5.7.0(transitive)
- Removed@ethersproject/bytes@5.7.0(transitive)
- Removed@ethersproject/constants@5.7.0(transitive)
- Removed@ethersproject/contracts@5.7.0(transitive)
- Removed@ethersproject/hash@5.7.0(transitive)
- Removed@ethersproject/hdnode@5.7.0(transitive)
- Removed@ethersproject/json-wallets@5.7.0(transitive)
- Removed@ethersproject/keccak256@5.7.0(transitive)
- Removed@ethersproject/logger@5.7.0(transitive)
- Removed@ethersproject/networks@5.7.1(transitive)
- Removed@ethersproject/pbkdf2@5.7.0(transitive)
- Removed@ethersproject/properties@5.7.0(transitive)
- Removed@ethersproject/providers@5.7.2(transitive)
- Removed@ethersproject/random@5.7.0(transitive)
- Removed@ethersproject/rlp@5.7.0(transitive)
- Removed@ethersproject/sha2@5.7.0(transitive)
- Removed@ethersproject/signing-key@5.7.0(transitive)
- Removed@ethersproject/solidity@5.7.0(transitive)
- Removed@ethersproject/strings@5.7.0(transitive)
- Removed@ethersproject/transactions@5.7.0(transitive)
- Removed@ethersproject/units@5.7.0(transitive)
- Removed@ethersproject/wallet@5.7.0(transitive)
- Removed@ethersproject/web@5.7.1(transitive)
- Removed@ethersproject/wordlists@5.7.0(transitive)
- Removedaes-js@3.0.0(transitive)
- Removedbech32@1.1.4(transitive)
- Removedbn.js@4.12.15.2.1(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedelliptic@6.5.4(transitive)
- Removedethers@5.7.2(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedjs-sha3@0.8.0(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removedscrypt-js@3.0.1(transitive)
- Removedws@7.4.6(transitive)