From dac62a9cf3d88f9818c6a2f9488b470016d69f99 Mon Sep 17 00:00:00 2001 From: Nicholas Addison Date: Sun, 14 Aug 2022 15:17:26 +1000 Subject: [PATCH] chore: normalise contract filename for storage diagrams to help find the correct Solidity file --- lib/converterClasses2Storage.js | 2 +- src/ts/converterAST2Classes.ts | 7 ++++++- src/ts/converterClasses2Storage.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/converterClasses2Storage.js b/lib/converterClasses2Storage.js index e1502288..cf959506 100644 --- a/lib/converterClasses2Storage.js +++ b/lib/converterClasses2Storage.js @@ -41,7 +41,7 @@ const convertClasses2Storages = (contractName, umlClasses, contractFilename) => return name === contractName; } return (name === contractName && - (relativePath == contractFilename || + (relativePath == path_1.default.normalize(contractFilename) || path_1.default.basename(relativePath) === path_1.default.normalize(contractFilename))); }); diff --git a/src/ts/converterAST2Classes.ts b/src/ts/converterAST2Classes.ts index e7469ab9..60ae0a5c 100644 --- a/src/ts/converterAST2Classes.ts +++ b/src/ts/converterAST2Classes.ts @@ -145,9 +145,14 @@ export function convertAST2UmlClasses( } }) : [], - }) + } + debug( + `Added Etherscan import ${newImport.absolutePath} with class names: ${newImport.classNames}` + ) + imports.push(newImport) } } + // TODO add file level constants }) } else { throw new Error(`AST node not of type SourceUnit`) diff --git a/src/ts/converterClasses2Storage.ts b/src/ts/converterClasses2Storage.ts index 63caa56e..32d6e61c 100644 --- a/src/ts/converterClasses2Storage.ts +++ b/src/ts/converterClasses2Storage.ts @@ -76,7 +76,7 @@ export const convertClasses2Storages = ( } return ( name === contractName && - (relativePath == contractFilename || + (relativePath == path.normalize(contractFilename) || path.basename(relativePath) === path.normalize(contractFilename)) )