Skip to content

Commit

Permalink
feat: add hideValue option
Browse files Browse the repository at this point in the history
fix: handle types with dot splitting contract name and type
chore: add Uniswap V3 pool example with hideValue option
  • Loading branch information
naddison36 committed Feb 26, 2023
1 parent a0f35f0 commit 2244df3
Show file tree
Hide file tree
Showing 11 changed files with 419 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Options:
-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)
-bn, --block <number> Block number to get the contract storage values from. (default: "latest")
-a, --array <number> Number of slots to display at the start and end of arrays. (default: "2")
-hv, --hideValue Hide storage slot value column.
-h, --help display help for command
```

Expand Down
9 changes: 9 additions & 0 deletions examples/storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,12 @@ sol2uml storage 0xc63a48d85CCE7C3bD4d18db9c0972a4D223e4193 -bn 16000000 -d -s 0x

![Staking Tokens BPT](./StakedTokenBPTData.svg)

## Uniswap ETH/USDC Pool

The `value` column with the slot values in hexadecimal format can be hidden with the `-hv, --hideValue` option.

```
sol2uml storage -d -hv 0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8 -o ./examples/storage/UniswapV3PoolData.svg
```

![Uniswap ETH/USDC Pool Data](./UniswapV3PoolData.svg)
395 changes: 395 additions & 0 deletions examples/storage/UniswapV3PoolData.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/storage/usdcData.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion lib/converterClasses2Storage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/converterStorage2Dot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export declare const convertStorages2Dot: (storageSections: readonly StorageSect
shapeColor: string;
fillColor: string;
textColor: string;
hideValues?: boolean;
}) => string;
export declare function convertStorage2Dot(storageSection: StorageSection, dotString: string, options: {
data: boolean;
hideValues?: boolean;
}): string;
2 changes: 1 addition & 1 deletion lib/converterStorage2Dot.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/sol2uml.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/ts/converterClasses2Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,10 @@ const findTypeClass = (
otherClasses: readonly UmlClass[]
): UmlClass => {
// Find associated UserDefined type
const types = userType.split('.')
const association = {
referenceType: ReferenceType.Memory,
targetUmlClassName: userType,
targetUmlClassName: types.length === 1 ? types[0] : types[1],
}
const typeClass = findAssociatedClass(association, umlClass, otherClasses)
if (!typeClass) {
Expand Down
5 changes: 3 additions & 2 deletions src/ts/converterStorage2Dot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const convertStorages2Dot = (
shapeColor: string
fillColor: string
textColor: string
hideValues?: boolean
}
): string => {
let dotString: string = `
Expand Down Expand Up @@ -50,7 +51,7 @@ node [shape=record, style=filled, color="${options.shapeColor}", fillcolor="${op
export function convertStorage2Dot(
storageSection: StorageSection,
dotString: string,
options: { data: boolean }
options: { data: boolean; hideValues?: boolean }
): string {
// write storage header with name and optional address
dotString += `\n${storageSection.id} [label="${storageSection.name} \\<\\<${
Expand Down Expand Up @@ -88,7 +89,7 @@ export function convertStorage2Dot(
})

// write slot values if available
if (options.data) {
if (options.data && !options.hideValues) {
dotString += `} | {value${dataLine}`
startingVariables.forEach((variable, i) => {
if (displayData[i]) {
Expand Down
1 change: 1 addition & 0 deletions src/ts/sol2uml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ WARNING: sol2uml does not use the Solidity compiler so may differ with solc. A k
'Number of slots to display at the start and end of arrays.',
'2'
)
.option('-hv, --hideValue', 'Hide storage slot value column.', false)
.action(async (fileFolderAddress, options, command) => {
try {
const combinedOptions = {
Expand Down

0 comments on commit 2244df3

Please sign in to comment.