Skip to content

Commit

Permalink
feat: added support for Base and Celo
Browse files Browse the repository at this point in the history
feat: added chain options none and custom
feat: added explorerUrl option for custom chains and testnets
  • Loading branch information
naddison36 committed Aug 25, 2023
1 parent 8600557 commit e8628a2
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 156 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Options:
-f, --outputFormat <value> output file format (choices: "png", "svg", "eps", "puml", default: "svg")
-o, --outputFileName <value> output file name. Defaults to shortened tx hashes joined together with a 'v' prefix for value transfer diagrams.
-u, --url <url> URL of the archive node with trace transaction support (default: "http://localhost:8545", env: ARCHIVE_NODE_URL)
-c, --chain <value> blockchain explorer network to get source code from (choices: "mainnet", "goerli", "sepolia", "arbitrum", "optimisim", "polygon", "avalanche", "bsc", "crono", "fantom", "gnosis",
"moonbeam", default: "mainnet", env: ETH_NETWORK)
-c, --chain <value> blockchain explorer to get contract source code from. `none` will not get any source code. `custom` will use the `explorerUrl` option. (choices: "mainnet", "custom", "none", "goerli", "sepolia", "arbitrum", "optimisim", "polygon", "avalanche", "bsc", "crono", "fantom", "gnosis", "moonbeam", "celo", "base", default: "mainnet", env: ETH_NETWORK)
-e, --explorerUrl <url> required if a `custom` chain is used. eg a testnet like Polygon Mumbai https://api-testnet.polygonscan.com/api (env: EXPLORER_URL)
-cf, --configFile <value> name of the json configuration file that can override contract details like name and ABI (default: "tx.config.json")
-af, --abiFile <value> name of the json abi file that can override contract details like ABI (default: "tx.abi.json")
-m, --memory <gigabytes> max Java memory of PlantUML process in gigabytes. Java default is 1/4 of physical memory. Large txs in png format will need up to 12g. svg format is much better for large transactions.
Expand Down
2 changes: 1 addition & 1 deletion lib/callDiagram.js

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

12 changes: 10 additions & 2 deletions lib/clients/EthereumNodeClient.js

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

8 changes: 3 additions & 5 deletions lib/clients/EtherscanClient.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Contract, Network, Token } from "../types/tx2umlTypes";
import { Contract, Network } from "../types/tx2umlTypes";
export default class EtherscanClient {
readonly apiKey: string;
readonly network: Network;
readonly apiKey?: string;
readonly url: string;
constructor(apiKey?: string, network?: Network);
constructor(apiKey?: string, network?: Network, url?: string);
getContract(contractAddress: string): Promise<Contract>;
getToken(contractAddress: string): Promise<Token | null>;
}
98 changes: 41 additions & 57 deletions lib/clients/EtherscanClient.js

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

3 changes: 2 additions & 1 deletion lib/tx2uml.js

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

4 changes: 3 additions & 1 deletion lib/types/tx2umlTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export type ParamTypeInternal = {
components?: ParamTypeInternal[];
};
export declare const nodeTypes: readonly ["geth", "erigon", "nether", "openeth", "tgeth", "besu", "anvil"];
export declare const networks: readonly ["mainnet", "goerli", "sepolia", "arbitrum", "optimisim", "polygon", "avalanche", "bsc", "crono", "fantom", "gnosis", "moonbeam"];
export declare const networks: readonly ["mainnet", "custom", "none", "goerli", "sepolia", "arbitrum", "optimisim", "polygon", "avalanche", "bsc", "crono", "fantom", "gnosis", "moonbeam", "celo", "base"];
export type Network = (typeof networks)[number];
export declare const setNetworkCurrency: (network: Network) => "AVAX" | "MATIC" | "BNB" | "CRO" | "FTM" | "xDAI" | "GLMR" | "ETH";
export declare const outputFormats: readonly ["png", "svg", "eps", "puml"];
Expand Down Expand Up @@ -182,6 +182,7 @@ export interface SourceMap {
}
export interface CallDiagramOptions extends TracePumlGenerationOptions {
chain?: Network;
explorerUrl?: string;
url?: string;
nodeType: string;
noAddresses?: string[];
Expand All @@ -192,6 +193,7 @@ export interface CallDiagramOptions extends TracePumlGenerationOptions {
}
export interface TransferPumlGenerationOptions extends OutputOptions {
chain?: Network;
explorerUrl?: string;
url?: string;
etherscanKey?: string;
configFile?: string;
Expand Down
4 changes: 4 additions & 0 deletions lib/types/tx2umlTypes.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/valueDiagram.js

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

6 changes: 5 additions & 1 deletion src/contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ See ENS's [Reverse records](https://github.com/ensdomains/reverse-records/#deplo
[TokenDetails](./TokenInfo.sol) takes a constructor parameter `_reverseRecords` which is the address of Ethereum Name Service's `ReverseRecords` contract. This is only used on Goerli and Mainnet.

| Chain | Address | \_reverseRecords |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|-----------| ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Mainnet | [0xEf6B7d3885f4Af1bDfcB66FE0370D6012B38a8Db](https://etherscan.io/address/0xEf6B7d3885f4Af1bDfcB66FE0370D6012B38a8Db#code) | [0x3671aE578E63FdF66ad4F3E12CC0c0d71Ac7510C](https://etherscan.io/address/0x3671aE578E63FdF66ad4F3E12CC0c0d71Ac7510C) |
| Goerli | [0x0395f995f2cecc40e2bf45d4905004313fcece6e](https://goerli.etherscan.io/address/0x0395f995f2cecc40e2bf45d4905004313fcece6e#code) | [0x333Fc8f550043f239a2CF79aEd5e9cF4A20Eb41e](https://goerli.etherscan.io/address/0x333Fc8f550043f239a2CF79aEd5e9cF4A20Eb41e) |
| Sepolia | [0xe147cb7d90b9253844130e2c4a7ef0ffb641c3ea](https://sepolia.etherscan.io/address/0xe147cb7d90b9253844130e2c4a7ef0ffb641c3ea#code) | 0x0000000000000000000000000000000000000000 |
Expand All @@ -88,7 +88,11 @@ See ENS's [Reverse records](https://github.com/ensdomains/reverse-records/#deplo
| Optimism | [0x8E2587265C68CD9EE3EcBf22DC229980b47CB960](https://optimistic.etherscan.io/address/0x8E2587265C68CD9EE3EcBf22DC229980b47CB960#code) | 0x0000000000000000000000000000000000000000 |
| Avalanche | [0x4e557a2936D3a4Ec2cA4981e6cCCfE330C1634DF](https://snowtrace.io/address/0x4e557a2936D3a4Ec2cA4981e6cCCfE330C1634DF#code) | 0x0000000000000000000000000000000000000000 |
| Gnosis | [0x04a05bE01C94d576B3eA3e824aF52668BAC606c0](https://gnosisscan.io/address/0x04a05be01c94d576b3ea3e824af52668bac606c0#code) | 0x0000000000000000000000000000000000000000 |
| Base | [0x04a05bE01C94d576B3eA3e824aF52668BAC606c0](https://basescan.org/address/0x04a05bE01C94d576B3eA3e824aF52668BAC606c0) | 0x0000000000000000000000000000000000000000 |
| BSC | | 0x0000000000000000000000000000000000000000 |
| Crono | | 0x0000000000000000000000000000000000000000 |
| Fantom | | 0x0000000000000000000000000000000000000000 |
| Moonbeam | | 0x0000000000000000000000000000000000000000 |
| Celo | | 0x0000000000000000000000000000000000000000 |

Deployments can be done using [Remix](https://remix.ethereum.org/)
3 changes: 2 additions & 1 deletion src/ts/callDiagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const generateCallDiagram = async (

const etherscanClient = new EtherscanClient(
options.etherscanKey,
options.chain
options.chain,
options.explorerUrl
)
const txManager = new TransactionManager(
ethereumNodeClient,
Expand Down
Loading

0 comments on commit e8628a2

Please sign in to comment.