Skip to content

Commit

Permalink
chore: Added support for Sonic chain
Browse files Browse the repository at this point in the history
  • Loading branch information
naddison36 committed Jan 15, 2025
1 parent 6e96d40 commit fc7aa88
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Nick Addison
Copyright (c) 2025 Nick Addison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ 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 to get contract source code from. `none` will not get any source code. `custom` will use the `explorerUrl` option. (choices: "mainnet", "custom", "none", "sepolia", "holesky", "arbitrum", "optimisim", "polygon", "avalanche", "bsc", "crono", "fantom", "gnosis", "moonbeam", "celo", "scroll", "base", 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", "sepolia", "holesky", "arbitrum", "optimisim", "polygon", "avalanche", "bsc", "crono", "fantom", "gnosis", "moonbeam", "celo", "scroll", "base", "sonic", default: "mainnet", env: ETH_NETWORK)
-k, --etherscanKey <value> Etherscan like block explorer API key
-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")
Expand Down
4 changes: 4 additions & 0 deletions lib/clients/EtherscanClient.js

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

4 changes: 2 additions & 2 deletions lib/types/tx2umlTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ export type ParamTypeInternal = {
components?: ParamTypeInternal[];
};
export declare const nodeTypes: readonly ["geth", "erigon", "nether", "openeth", "tgeth", "besu", "anvil", "reth"];
export declare const networks: readonly ["mainnet", "custom", "none", "sepolia", "holesky", "arbitrum", "optimisim", "polygon", "avalanche", "bsc", "crono", "fantom", "gnosis", "moonbeam", "celo", "scroll", "base"];
export declare const networks: readonly ["mainnet", "custom", "none", "sepolia", "holesky", "arbitrum", "optimisim", "polygon", "avalanche", "bsc", "crono", "fantom", "gnosis", "moonbeam", "celo", "scroll", "base", "sonic"];
export type Network = (typeof networks)[number];
export declare const setNetworkCurrency: (network: Network) => "AVAX" | "MATIC" | "BNB" | "CRO" | "FTM" | "xDAI" | "GLMR" | "CELO" | "ETH";
export declare const setNetworkCurrency: (network: Network) => "AVAX" | "MATIC" | "BNB" | "CRO" | "FTM" | "xDAI" | "GLMR" | "CELO" | "S" | "ETH";
export declare const outputFormats: readonly ["png", "svg", "eps", "puml"];
export type OutputFormat = (typeof outputFormats)[number];
export interface OutputOptions {
Expand Down
5 changes: 4 additions & 1 deletion lib/types/tx2umlTypes.js

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

3 changes: 3 additions & 0 deletions src/ts/clients/EtherscanClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export default class EtherscanClient {
} else if (network === "base") {
this.url = "https://api.basescan.org/api"
this.apiKey = apiKey || "9I5HUJHPD4ZNXJ4M8TZJ1HD2QBVP1U3M3J"
} else if (network === "sonic") {
this.url = "https://api.sonicscan.org/api"
this.apiKey = apiKey || "STCM7CPYP341C66C4IVV1IFMWDYRUTI1QY"
} else {
if (!apiKey) {
throw new Error(
Expand Down
5 changes: 4 additions & 1 deletion src/ts/types/tx2umlTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export const networks = <const>[
"celo",
"scroll",
"base",
"sonic",
]
export type Network = (typeof networks)[number]

Expand All @@ -207,7 +208,9 @@ export const setNetworkCurrency = (network: Network) =>
? "GLMR"
: network === "celo"
? "CELO"
: "ETH"
: network === "sonic"
? "S"
: "ETH"

export const outputFormats = <const>["png", "svg", "eps", "puml"]
export type OutputFormat = (typeof outputFormats)[number]
Expand Down
7 changes: 7 additions & 0 deletions tests/holesky.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"0x4242424242424242424242424242424242424242": {
"protocolName": "Beacon",
"contractName": "DepositContract",
"abi": [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubkey","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"amount","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"signature","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"index","type":"bytes"}],"name":"DepositEvent","type":"event"},{"inputs":[{"internalType":"bytes","name":"pubkey","type":"bytes"},{"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes32","name":"deposit_data_root","type":"bytes32"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"get_deposit_count","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"get_deposit_root","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
}
}
3 changes: 3 additions & 0 deletions tests/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ tx2uml value 0x4d2d405d380274c7a2afba7e4881be0f6ae99033597a96b237ceb83cc377615a,
tx2uml value --hideFooter --hideBalances 0x4d2d405d380274c7a2afba7e4881be0f6ae99033597a96b237ceb83cc377615a,0x459b469609e613d95865fd08369d6f92fb4ce8ce168efd9764d75524d9711777 -v
tx2uml value --chain none 0x4d2d405d380274c7a2afba7e4881be0f6ae99033597a96b237ceb83cc377615a,0x459b469609e613d95865fd08369d6f92fb4ce8ce168efd9764d75524d9711777 -v

# Prime No delegate calls
tx2uml call 0x3a89de87d4a039af246474e1573f4687bba402471ab83285d9aa1271edde5eda --noDelegates -v

##### Goerli
export ARCHIVE_NODE_URL=https://eth-goerli.g.alchemy.com/v2/rU87yfwzx4Xv0HSrZAENZO0Otr1x4hqo

Expand Down

0 comments on commit fc7aa88

Please sign in to comment.