Skip to content

Commit

Permalink
Added BSC and Polygon network support
Browse files Browse the repository at this point in the history
  • Loading branch information
naddison36 committed Aug 7, 2021
1 parent 50f1295 commit e76b808
Show file tree
Hide file tree
Showing 11 changed files with 2,666 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Options:
-o, --outputFileName <value> output file name
-d, --depthLimit <depth> number of sub folders that will be recursively searched for Solidity files. Default -1 is unlimited (default: -1)
-i, --ignoreFilesOrFolders <filesOrFolders> comma separated list of files or folders to ignore
-n, --network <network> mainnet, ropsten, kovan, rinkeby or goerli (default: "mainnet")
-n, --network <network> mainnet, polygon, bsc, ropsten, kovan, rinkeby or goerli (default: "mainnet")
-a, --hideAttributes hide class and interface attributes
-p, --hideOperators hide class and interface operators/functions
-e, --hideEnums hide enum types
Expand Down
21 changes: 20 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Example UML Diagrams

## Crypto Kitties

![CryptoKitties](./cryptoKitties.svg)
Generated from running
```
Expand All @@ -9,16 +10,34 @@ sol2uml 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d
This uses the verified Solidity code loaded to Etherscan https://etherscan.io/address/0x06012c8cf97BEaD5deAe237070F9587f8E7A266d#code

## Open Zeppelin ERC20 Tokens

![Open Zeppelin ERC20](./OpenZeppelinERC20.svg)
Generated from version [2.3.0 contracts/token/ERC20](https://github.com/OpenZeppelin/openzeppelin-solidity/tree/v2.3.0/contracts/token/ERC20)

## Open Zeppelin Base Contract

![Open Zeppelin Base Contract](./OzToken.svg)
Generated from version [2.5.1 contracts](https://github.com/OpenZeppelin/openzeppelin-solidity/tree/v2.5.1/contracts) with
```base
```
sol2uml -b OzToken
```

## mStable mUSD on Polygon

![Polygon mUSD](./polygonMusd.svg)
Generated from running
```
sol2uml -n polygon 0xcA9cf48aD534f1efA2B0f6923457F2953df86e0b
```

## Crypto Blades on BSC

![BSC Crypto Blades](./bscCryptoBlades.svg)
Generated from running
```
sol2uml -n bsc 0xB07c1C479b2Fdeb9f9B2d02300C13b328BF86d65
```

## Open Zeppelin All
![Open Zeppelin ERC20](./OpenZeppelinAll.svg)
Generated from version [2.5.1 contracts](https://github.com/OpenZeppelin/openzeppelin-solidity/tree/v2.5.1/contracts)
Expand Down
1,497 changes: 1,497 additions & 0 deletions examples/bscCryptoBlades.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,111 changes: 1,111 additions & 0 deletions examples/polygonMusd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/etherscanParser.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ASTNode } from '@solidity-parser/parser/dist/src/ast-types';
import { UmlClass } from './umlClass';
declare const networks: readonly ["mainnet", "ropsten", "kovan", "rinkeby", "goerli"];
declare const networks: readonly ["mainnet", "ropsten", "kovan", "rinkeby", "goerli", "polygon", "bsc"];
declare type Network = typeof networks[number];
export declare class EtherscanParser {
protected apikey: string;
Expand Down
18 changes: 17 additions & 1 deletion lib/etherscanParser.js

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

2 changes: 1 addition & 1 deletion lib/sol2uml.js

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

2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sol2uml",
"version": "1.1.28",
"version": "1.1.29",
"description": "Unified Modeling Language (UML) class diagram generator for Solidity contracts",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
16 changes: 15 additions & 1 deletion src/ts/etherscanParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ import { VError } from 'verror'
import { convertNodeToUmlClass } from './parser'
import { UmlClass } from './umlClass'

const networks = <const>['mainnet', 'ropsten', 'kovan', 'rinkeby', 'goerli']
const networks = <const>[
'mainnet',
'ropsten',
'kovan',
'rinkeby',
'goerli',
'polygon',
'bsc',
]
type Network = typeof networks[number]

export class EtherscanParser {
Expand All @@ -22,6 +30,12 @@ export class EtherscanParser {
)
} else if (network === 'mainnet') {
this.url = 'https://api.etherscan.io/api'
} else if (network === 'polygon') {
this.url = 'https://api.polygonscan.com/api'
this.apikey = 'AMHGNTV5A7XYGX2M781JB3RC1DZFVRWQEB'
} else if (network === 'bsc') {
this.url = 'https://api.bscscan.com/api'
this.apikey = 'APYH49FXVY9UA3KTDI6F4WP3KPIC86NITN'
} else {
this.url = `https://api-${network}.etherscan.io/api`
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/sol2uml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ If an Ethereum address with a 0x prefix is passed, the verified source code from
)
.option(
'-n, --network <network>',
'mainnet, ropsten, kovan, rinkeby or goerli',
'mainnet, polygon, bsc, ropsten, kovan, rinkeby or goerli',
'mainnet'
)
.option('-a, --hideAttributes', 'hide class and interface attributes')
Expand Down

0 comments on commit e76b808

Please sign in to comment.