Skip to content

Commit

Permalink
added class diagram option to squash the inherited contracts (#118)
Browse files Browse the repository at this point in the history
* feat: added class diagram option to squash the inherited contracts
* chore: filter hidden classes before connecting to the base classes
* chore: updated examples
* chore: bumped package major version
  • Loading branch information
naddison36 authored Dec 5, 2022
1 parent 0df9c64 commit 5f7f21e
Show file tree
Hide file tree
Showing 24 changed files with 2,207 additions and 65 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Options:
-hi, --hideInterfaces hide interfaces (default: false)
-ha, --hideAbstracts hide abstract contracts (default: false)
-hn, --hideFilename hide relative path and file name (default: false)
-s, --squash squash inherited contracts to the base contract(s) (default: false)
-hsc, --hideSourceContract hide the source contract when using squash (default: false)
-h, --help display help for command
```

Expand Down
234 changes: 234 additions & 0 deletions examples/CErc20-hide.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
873 changes: 873 additions & 0 deletions examples/CErc20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 43 additions & 31 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,62 +39,74 @@ sol2uml -n bsc 0xB07c1C479b2Fdeb9f9B2d02300C13b328BF86d65
![Open Zeppelin ERC20](./OpenZeppelinAll.svg)
Generated from version [4.7.3 contracts](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/v4.7.3/contracts)

## MakerDAO's SAI Token
## Uniswap V3 Router

![MakerDAO](./MakerDAO_SAI.svg)
Generated from GitHub commit [84c682eeb4e27264503370ef5aafcb9ee3217acb](https://github.com/makerdao/sai/tree/84c682eeb4e27264503370ef5aafcb9ee3217acb/src) of makerdao/sai/src
* -hp hide private and internal variables and functions
* -hi hide interfaces
* -hl hide libraries
* -he hide enums

## Tether

![Tether](./tether.svg)
![Uniswap V3 Router](./uniswap-router.svg)
Generated from running

```
sol2uml 0xdAC17F958D2ee523a2206206994597C13D831ec7
sol2uml -hp -hi -hl -hs -he 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45
```

This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code
This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45#code

## 0x

![0x Protocol v2 Exchange](./0xv2.svg)
Generated from running
## Uniswap V3 Router Squashed

Same as the previous diagram but the inherited contracts are squashed into a single class diagram with the `-s, --squash` option.

The last stereotype is the contract the variable or function is implemented in. For example, `unwrapWETH9` is implemented in the `PeripheryPaymentsWithFeeExtended` contract.

![Uniswap V3 Router Squashed](./uniswap-router-squash.svg)

Generated from running
```
sol2uml 0x4F833a24e1f95D70F028921e27040Ca56E09AB0b
sol2uml -s -hp -hi -hl -hs -he 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45
```

This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0x4F833a24e1f95D70F028921e27040Ca56E09AB0b#code
## Uniswap V3 Router Squashed No Source

## Compound Finance's cDAI
Adding the `-hsc, --hideSourceContract` option to the previous diagram removes the stereotype with the source contract the variable or function was implemented in.

![Compound Finance cDAI](./cDAI.svg)
Generated from running
![Uniswap V3 Router Squashed no source contract](./uniswap-router-squash-no-source.svg)

Generated from running
```
sol2uml 0xf5dce57282a584d2746faf1593d3121fcac444dc
sol2uml -s -hsc -hp -hi -hl -hs -he 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45
```

This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0xf5dce57282a584d2746faf1593d3121fcac444dc#code

## Chainlink
## Tether

![Chainlink](./chainlink.svg)
![Tether](./tether.svg)
Generated from running

```bash
sol2uml 0x79fEbF6B9F76853EDBcBc913e6aAE8232cFB9De9
```
sol2uml 0xdAC17F958D2ee523a2206206994597C13D831ec7
```

This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0x79fEbF6B9F76853EDBcBc913e6aAE8232cFB9De9#code
This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0xdac17f958d2ee523a2206206994597c13d831ec7#code

## Augur
## Compound Finance's cDAI

![Augur](./augur.svg)
![Compound Finance cDAI](./CErc20.svg)
Generated from running

```bash
sol2uml 0x7F27B0598949DbF9e539BBD217f15BF3F5E97999
```
sol2uml 0xf5dce57282a584d2746faf1593d3121fcac444dc
```

This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0xf5dce57282a584d2746faf1593d3121fcac444dc#code

## Compound Finance's cDAI Hide

This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0x7F27B0598949DbF9e539BBD217f15BF3F5E97999#code
Same as the previous except enums, stucts and interfaces are hidden.
Also, only classes linked to the base `CErc20` contract are included.

![Compound Finance cDAI](./CErc20-hide.svg)
Generated from running
```
sol2uml -b CErc20 -he -hs -hi 0xf5dce57282a584d2746faf1593d3121fcac444dc
```
69 changes: 69 additions & 0 deletions examples/uniswap-router-squash-no-source.svg
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 5f7f21e

Please sign in to comment.