sol2uml 2.5.5 → 2.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,8 +55,9 @@ Options:
55
55
  -f, --outputFormat <value> output file format. (choices: "svg", "png", "dot", "all", default: "svg")
56
56
  -o, --outputFileName <value> output file name
57
57
  -i, --ignoreFilesOrFolders <filesOrFolders> comma separated list of files or folders to ignore
58
- -n, --network <network> Ethereum network (choices: "mainnet", "goerli", "sepolia", "polygon", "arbitrum", "avalanche", "bsc", "crono", "fantom", "moonbeam",
58
+ -n, --network <network> Ethereum network which maps to a blockchain explorer (choices: "mainnet", "goerli", "sepolia", "polygon", "arbitrum", "avalanche", "bsc", "crono", "fantom", "moonbeam",
59
59
  "optimism", "gnosis", "celo", default: "mainnet", env: ETH_NETWORK)
60
+ -e, --explorerUrl <url> Override network with custom blockchain explorer API URL. eg Polygon Mumbai testnet https://api-testnet.polygonscan.com/api (env: EXPLORER_URL)
60
61
  -k, --apiKey <key> Blockchain explorer API key. eg Etherscan, Arbiscan, Optimism, BscScan, CronoScan, FTMScan, PolygonScan or SnowTrace API key (env: SCAN_API_KEY)
61
62
  -bc, --backColor <color> Canvas background color. "none" will use a transparent canvas. (default: "white")
62
63
  -sc, --shapeColor <color> Basic drawing color for graphics, not text (default: "black")
@@ -10,7 +10,7 @@ export declare class EtherscanParser {
10
10
  protected apikey: string;
11
11
  network: Network;
12
12
  readonly url: string;
13
- constructor(apikey?: string, network?: Network);
13
+ constructor(apikey?: string, network?: Network, url?: string);
14
14
  /**
15
15
  * Parses the verified source code files from Etherscan
16
16
  * @param contractAddress Ethereum contract address with a 0x prefix
@@ -28,9 +28,13 @@ exports.networks = [
28
28
  'celo',
29
29
  ];
30
30
  class EtherscanParser {
31
- constructor(apikey = 'ZAD4UI2RCXCQTP38EXS3UY2MPHFU5H9KB1', network = 'mainnet') {
31
+ constructor(apikey = 'ZAD4UI2RCXCQTP38EXS3UY2MPHFU5H9KB1', network = 'mainnet', url) {
32
32
  this.apikey = apikey;
33
33
  this.network = network;
34
+ if (url) {
35
+ this.url = url;
36
+ return;
37
+ }
34
38
  if (!exports.networks.includes(network)) {
35
39
  throw new Error(`Invalid network "${network}". Must be one of ${exports.networks}`);
36
40
  }
@@ -3,6 +3,7 @@ import { UmlClass } from './umlClass';
3
3
  export interface ParserOptions {
4
4
  apiKey?: string;
5
5
  network?: Network;
6
+ explorerUrl?: string;
6
7
  subfolders?: string;
7
8
  ignoreFilesOrFolders?: string;
8
9
  }
@@ -17,7 +17,7 @@ const parserUmlClasses = async (fileFolderAddress, options) => {
17
17
  if ((0, regEx_1.isAddress)(fileFolderAddress)) {
18
18
  debug(`argument ${fileFolderAddress} is an Ethereum address so checking Etherscan for the verified source code`);
19
19
  const etherscanApiKey = options.apiKey || 'ZAD4UI2RCXCQTP38EXS3UY2MPHFU5H9KB1';
20
- const etherscanParser = new parserEtherscan_1.EtherscanParser(etherscanApiKey, options.network);
20
+ const etherscanParser = new parserEtherscan_1.EtherscanParser(etherscanApiKey, options.network, options.explorerUrl);
21
21
  result = await etherscanParser.getUmlClasses(fileFolderAddress);
22
22
  }
23
23
  else {
package/lib/sol2uml.js CHANGED
@@ -29,10 +29,11 @@ Can also flatten or compare verified source files on Etherscan-like explorers.`)
29
29
  .default('svg'))
30
30
  .option('-o, --outputFileName <value>', 'output file name')
31
31
  .option('-i, --ignoreFilesOrFolders <filesOrFolders>', 'comma separated list of files or folders to ignore')
32
- .addOption(new commander_1.Option('-n, --network <network>', 'Ethereum network')
32
+ .addOption(new commander_1.Option('-n, --network <network>', 'Ethereum network which maps to a blockchain explorer')
33
33
  .choices(parserEtherscan_1.networks)
34
34
  .default('mainnet')
35
35
  .env('ETH_NETWORK'))
36
+ .addOption(new commander_1.Option('-e, --explorerUrl <url>', 'Override network with custom blockchain explorer API URL. eg Polygon Mumbai testnet https://api-testnet.polygonscan.com/api').env('EXPLORER_URL'))
36
37
  .addOption(new commander_1.Option('-k, --apiKey <key>', 'Blockchain explorer API key. eg Etherscan, Arbiscan, Optimism, BscScan, CronoScan, FTMScan, PolygonScan or SnowTrace API key').env('SCAN_API_KEY'))
37
38
  .option('-bc, --backColor <color>', 'Canvas background color. "none" will use a transparent canvas.', 'white')
38
39
  .option('-sc, --shapeColor <color>', 'Basic drawing color for graphics, not text', 'black')
@@ -202,7 +203,7 @@ In order for the merged code to compile, the following is done:
202
203
  ...command.parent._optionValues,
203
204
  ...options,
204
205
  };
205
- const etherscanParser = new parserEtherscan_1.EtherscanParser(combinedOptions.apiKey, combinedOptions.network);
206
+ const etherscanParser = new parserEtherscan_1.EtherscanParser(combinedOptions.apiKey, combinedOptions.network, combinedOptions.explorerUrl);
206
207
  const { solidityCode, contractName } = await etherscanParser.getSolidityCode(contractAddress);
207
208
  // Write Solidity to the contract address
208
209
  const outputFilename = combinedOptions.outputFileName || contractName;
@@ -239,7 +240,7 @@ The line numbers are from contract B. There are no line numbers for the red sect
239
240
  const lineBuffer = parseInt(options.lineBuffer);
240
241
  if (isNaN(lineBuffer))
241
242
  throw Error(`Invalid line buffer "${options.lineBuffer}". Must be a number`);
242
- const etherscanParser = new parserEtherscan_1.EtherscanParser(combinedOptions.apiKey, combinedOptions.network);
243
+ const etherscanParser = new parserEtherscan_1.EtherscanParser(combinedOptions.apiKey, combinedOptions.network, combinedOptions.explorerUrl);
243
244
  // Get verified Solidity code from Etherscan and flatten
244
245
  const { solidityCode: codeA, contractName: contractNameA } = await etherscanParser.getSolidityCode(addressA, combinedOptions.aFile);
245
246
  const { solidityCode: codeB, contractName: contractNameB } = await etherscanParser.getSolidityCode(addressB, combinedOptions.bFile || combinedOptions.aFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sol2uml",
3
- "version": "2.5.5",
3
+ "version": "2.5.6",
4
4
  "description": "Solidity contract visualisation tool.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",