Comparing version 2.5.4 to 2.5.5
@@ -105,3 +105,3 @@ "use strict"; | ||
}; | ||
debug(`Added filesystem import ${newImport.absolutePath} with class names ${newImport.classNames}`); | ||
debug(`Added filesystem import ${newImport.absolutePath} with class names ${newImport.classNames.map((i) => i.className)}`); | ||
imports.push(newImport); | ||
@@ -108,0 +108,0 @@ } |
@@ -90,3 +90,3 @@ "use strict"; | ||
const isTarget = umlClasses.find((u) => u.id === targetUmlClass.id); | ||
debug(`isTarget ${isTarget} Adding edge from ${sourceUmlClass.name} with id ${sourceUmlClass.id} to ${targetUmlClass.name} with id ${targetUmlClass.id} and type ${targetUmlClass.stereotype}`); | ||
debug(`isTarget ${!!isTarget}: Adding edge from ${sourceUmlClass.name} with id ${sourceUmlClass.id} to ${targetUmlClass.name} with id ${targetUmlClass.id} and type ${targetUmlClass.stereotype}`); | ||
weightedDirectedGraph.addEdge(new js_graph_algorithms_1.Edge(sourceUmlClass.id, targetUmlClass.id, 1)); | ||
@@ -93,0 +93,0 @@ } |
@@ -7,3 +7,3 @@ import { ASTNode } from '@solidity-parser/parser/dist/src/ast-types'; | ||
} | ||
export declare const networks: readonly ["mainnet", "goerli", "sepolia", "polygon", "arbitrum", "avalanche", "bsc", "crono", "fantom", "moonbeam", "optimism", "gnosis"]; | ||
export declare const networks: readonly ["mainnet", "goerli", "sepolia", "polygon", "arbitrum", "avalanche", "bsc", "crono", "fantom", "moonbeam", "optimism", "gnosis", "celo"]; | ||
export type Network = (typeof networks)[number]; | ||
@@ -30,3 +30,3 @@ export declare class EtherscanParser { | ||
*/ | ||
getSolidityCode(contractAddress: string): Promise<{ | ||
getSolidityCode(contractAddress: string, filename?: string): Promise<{ | ||
solidityCode: string; | ||
@@ -44,4 +44,5 @@ contractName: string; | ||
* @param contractAddress Ethereum contract address with a 0x prefix | ||
* @oaram filename optional, case-sensitive name of the source file without the .sol | ||
*/ | ||
getSourceCode(contractAddress: string): Promise<{ | ||
getSourceCode(contractAddress: string, filename?: string): Promise<{ | ||
files: readonly { | ||
@@ -48,0 +49,0 @@ code: string; |
@@ -12,2 +12,3 @@ "use strict"; | ||
const regEx_1 = require("./utils/regEx"); | ||
const path_1 = __importDefault(require("path")); | ||
require('axios-debug-log'); | ||
@@ -28,2 +29,3 @@ const debug = require('debug')('sol2uml'); | ||
'gnosis', | ||
'celo', | ||
]; | ||
@@ -76,2 +78,6 @@ class EtherscanParser { | ||
} | ||
else if (network === 'celo') { | ||
this.url = 'https://api.celoscan.io/api'; | ||
this.apikey = 'JBV78T5KP15W7WKKKD6KC4J8RX2F4PK8AF'; | ||
} | ||
else { | ||
@@ -106,4 +112,4 @@ this.url = `https://api-${network}.etherscan.io/api`; | ||
*/ | ||
async getSolidityCode(contractAddress) { | ||
const { files, contractName, compilerVersion, remappings } = await this.getSourceCode(contractAddress); | ||
async getSolidityCode(contractAddress, filename) { | ||
const { files, contractName, compilerVersion, remappings } = await this.getSourceCode(contractAddress, filename); | ||
// Parse the UmlClasses from the Solidity code in each file | ||
@@ -171,4 +177,5 @@ let umlClasses = []; | ||
* @param contractAddress Ethereum contract address with a 0x prefix | ||
* @oaram filename optional, case-sensitive name of the source file without the .sol | ||
*/ | ||
async getSourceCode(contractAddress) { | ||
async getSourceCode(contractAddress, filename) { | ||
const description = `get verified source code for address ${contractAddress} from Etherscan API.`; | ||
@@ -234,4 +241,12 @@ try { | ||
}); | ||
let files = results.flat(1); | ||
const filenameWithExt = filename + '.sol'; | ||
if (filename) { | ||
files = files.filter((r) => path_1.default.parse(r.filename).base == filenameWithExt); | ||
if (!files?.length) { | ||
throw new Error(`Failed to find source file "${filename}" for contract ${contractAddress}`); | ||
} | ||
} | ||
return { | ||
files: results.flat(1), | ||
files, | ||
contractName: response.data.result[0].ContractName, | ||
@@ -238,0 +253,0 @@ compilerVersion: response.data.result[0].CompilerVersion, |
@@ -228,2 +228,4 @@ #! /usr/bin/env node | ||
.addOption(new commander_1.Option('-l, --lineBuffer <value>', 'Minimum number of lines before and after changes').default('4')) | ||
.addOption(new commander_1.Option('-af --aFile <value>', 'Contract A source code filename without the .sol extension. (default: compares all source files)')) | ||
.addOption(new commander_1.Option('-bf --bFile <value>', 'Contract B source code filename without the .sol extension. (default: aFile if specified)')) | ||
.option('-s, --saveFiles', 'Save the flattened contract code to the filesystem. The file names will be the contract address with a .sol extension.', false) | ||
@@ -243,4 +245,4 @@ .action(async (addressA, addressB, options, command) => { | ||
// Get verified Solidity code from Etherscan and flatten | ||
const { solidityCode: codeA, contractName: contractNameA } = await etherscanParser.getSolidityCode(addressA); | ||
const { solidityCode: codeB, contractName: contractNameB } = await etherscanParser.getSolidityCode(addressB); | ||
const { solidityCode: codeA, contractName: contractNameA } = await etherscanParser.getSolidityCode(addressA, combinedOptions.aFile); | ||
const { solidityCode: codeB, contractName: contractNameB } = await etherscanParser.getSolidityCode(addressB, combinedOptions.bFile || combinedOptions.aFile); | ||
console.log(`Difference between`); | ||
@@ -247,0 +249,0 @@ console.log(`A. ${addressA} ${contractNameA} on ${combinedOptions.network}`); |
{ | ||
"name": "sol2uml", | ||
"version": "2.5.4", | ||
"version": "2.5.5", | ||
"description": "Solidity contract visualisation tool.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -58,3 +58,4 @@ # Solidity 2 UML | ||
-i, --ignoreFilesOrFolders <filesOrFolders> comma separated list of files or folders to ignore | ||
-n, --network <network> Ethereum network (choices: "mainnet", "goerli", "sepolia", "polygon", "arbitrum", "avalanche", "bsc", "crono", "fantom", "moonbeam", "optimism", "gnosis", default: "mainnet", env: ETH_NETWORK) | ||
-n, --network <network> Ethereum network (choices: "mainnet", "goerli", "sepolia", "polygon", "arbitrum", "avalanche", "bsc", "crono", "fantom", "moonbeam", | ||
"optimism", "gnosis", "celo", default: "mainnet", env: ETH_NETWORK) | ||
-k, --apiKey <key> Blockchain explorer API key. eg Etherscan, Arbiscan, Optimism, BscScan, CronoScan, FTMScan, PolygonScan or SnowTrace API key (env: SCAN_API_KEY) | ||
@@ -196,2 +197,4 @@ -bc, --backColor <color> Canvas background color. "none" will use a transparent canvas. (default: "white") | ||
-l, --lineBuffer <value> Minimum number of lines before and after changes (default: "4") | ||
--aFile <value> Contract A source code filename without the .sol extension. (default: compares all source files) | ||
--bFile <value> Contract B source code filename without the .sol extension. (default: aFile if specified) | ||
-s, --saveFiles Save the flattened contract code to the filesystem. The file names will be the contract address with a .sol extension. (default: false) | ||
@@ -334,2 +337,21 @@ -h, --help display help for command | ||
# Publish | ||
Commands to publish a new package version. | ||
```bash | ||
npm run prettier | ||
npm run clean | ||
npm run package-lock | ||
npm run build | ||
npm run permit | ||
# make tx2uml globally available for local testing | ||
npm link | ||
# check all the files are included in the npm package | ||
npm pack --dry-run | ||
npm publish | ||
``` | ||
Then create a new release on GitHub https://github.com/naddison36/sol2uml/releases | ||
# About | ||
@@ -336,0 +358,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
226032
4407
363