Skip to content

Commit

Permalink
Storage diagrams can parse storage slot values (#140)
Browse files Browse the repository at this point in the history
Parse storage variable values from slot values.
Get storage slot values for structs and arrays.
Added a new -a --array option to limit the displayed slots for arrays.
Added more variables and values to the TestStorage contract.
Etherscan file remappings applied to Solidity imports.
Added options backColor, shapeColor, fillColor and textColor to style class and storage diagram colors
  • Loading branch information
naddison36 authored Feb 18, 2023
1 parent 7674467 commit 249cdda
Show file tree
Hide file tree
Showing 80 changed files with 33,320 additions and 2,247 deletions.
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See more contract diagrams [here](./examples/README.md).
Storage layout diagram of USDC's [verified source code](https://etherscan.io/address/0xa2327a938febf5fec13bacfb16ae10ecbc4cbdcf#code) on Etherscan.
![USDC](./examples/storage/usdcData.svg)

See more contract storage diagram examples [here](./examples/storage/README.md).
See an explanation of how storage diagrams work with lots of examples [here](./examples/storage/README.md).

# Install

Expand Down Expand Up @@ -54,14 +54,19 @@ The three subcommands:
The Solidity code can be pulled from verified source code on Blockchain explorers like Etherscan or from local Solidity files.
Options:
-V, --version output the version number
-sf, --subfolders <value> number of subfolders that will be recursively searched for Solidity files. (default: all)
-f, --outputFormat <value> output file format. (choices: "svg", "png", "dot", "all", default: "svg")
-o, --outputFileName <value> output file name
-i, --ignoreFilesOrFolders <filesOrFolders> comma separated list of files or folders to ignore
-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", "gnosisscan", default: "mainnet", env: ETH_NETWORK)
-k, --apiKey <key> Blockchain explorer API key. eg Etherscan, Arbiscan, BscScan, CronoScan, FTMScan, PolygonScan or SnowTrace API key (env: SCAN_API_KEY)
-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", "gnosisscan", default: "mainnet", env: ETH_NETWORK)
-k, --apiKey <key> Blockchain explorer API key. eg Etherscan, Arbiscan, Optimism, BscScan, CronoScan, FTMScan, PolygonScan or SnowTrace API key (env: SCAN_API_KEY)
-bc, --backColor <color> Canvas background color. "none" will use a transparent canvas. (default: "white")
-sc, --shapeColor <color> Basic drawing color for graphics, not text (default: "black")
-fc, --fillColor <color> Color used to fill the background of a node (default: "gray95")
-tc, --textColor <color> Color used for text (default: "black")
-v, --verbose run with debugging statements (default: false)
-V, --version output the version number
-h, --help display help for command
Commands:
Expand Down Expand Up @@ -131,6 +136,7 @@ Options:
-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.
-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")
-h, --help display help for command
```

Expand Down Expand Up @@ -272,6 +278,20 @@ Heads/Tails:

See more storage slot diagrams [here](./examples/storage/README.md).

# Styling Colors

The colors use by the diagrams can be configured using the `backColor`, `shapeColor`, `fillColor` and `textColor` options.
sol2uml uses the [X11 color scheme](https://graphviz.org/doc/info/colors.html#x11) for named colors.
Other color formats like Red-Green-Blue (RGB) can also be used. For example, #ffffff for white and #000000 for black.
See [Graphviz color](https://graphviz.org/docs/attr-types/color/) documentation for more details.

Here's an example using the color options
```
sol2uml storage -sc deeppink -tc #ffffff -fc dimgrey -bc black 0xfCc00A1e250644d89AF0df661bC6f04891E21585
```

![Aave V3 Pool](./examples/storage/AaveV3PoolStorageColor.svg )

# Version 2.x changes

The biggest change with 2.x is the introduction of subcommands as sol2uml can now draw contract storage diagrams.
Expand Down
Binary file modified examples/inheritanceDiamond.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 249cdda

Please sign in to comment.