Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sol2uml

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sol2uml - npm Package Compare versions

Comparing version 2.5.19 to 2.5.20

57

lib/associations.js

@@ -16,6 +16,13 @@ "use strict";

return umlClass;
// Could not find a link so now need to recursively look at imports of imports
// Could not find association so now need to recursively look at imports of imports
// add to already recursively processed files to avoid getting stuck in circular imports
searchedAbsolutePaths.push(sourceUmlClass.absolutePath);
return findChainedImport(association, sourceUmlClass, umlClasses, searchedAbsolutePaths);
const importedType = findChainedImport(association, sourceUmlClass, umlClasses, searchedAbsolutePaths);
if (importedType)
return importedType;
// Still could not find association so now need to recursively look for inherited types
const inheritedType = findInheritedType(association, sourceUmlClass, umlClasses);
if (inheritedType)
return inheritedType;
return undefined;
};

@@ -40,15 +47,14 @@ exports.findAssociatedClass = findAssociatedClass;

// If a parent contract with no import alias
(association.parentUmlClassName !== undefined &&
(association.targetUmlClassName ===
targetUmlClass.name &&
association.parentUmlClassName ===
importedClass.className &&
importedClass.className ===
targetUmlClass.name &&
importedClass.alias == undefined) ||
// If a parent contract with import alias
(association.parentUmlClassName !== undefined &&
(association.targetUmlClassName ===
targetUmlClass.name &&
association.parentUmlClassName ===
importedClass.alias &&
importedClass.className ===
targetUmlClass.name))));
importedClass.alias))));
}
// No parent class in the association
return (

@@ -75,2 +81,35 @@ // class is in the same source file

};
const findInheritedType = (association, sourceUmlClass, umlClasses) => {
// Get all realized associations.
const parentAssociations = sourceUmlClass.getParentContracts();
// For each parent association
for (const parentAssociation of parentAssociations) {
const parent = (0, exports.findAssociatedClass)(parentAssociation, sourceUmlClass, umlClasses);
if (!parent)
continue;
// For each struct on the parent
for (const structId of parent.structs) {
const structUmlClass = umlClasses.find((c) => c.id === structId);
if (!structUmlClass)
continue;
if (structUmlClass.name === association.targetUmlClassName) {
return structUmlClass;
}
}
// For each enum on the parent
for (const enumId of parent.enums) {
const enumUmlClass = umlClasses.find((c) => c.id === enumId);
if (!enumUmlClass)
continue;
if (enumUmlClass.name === association.targetUmlClassName) {
return enumUmlClass;
}
}
// Recursively look for inherited types
const targetClass = findInheritedType(association, parent, umlClasses);
if (targetClass)
return targetClass;
}
return undefined;
};
const findChainedImport = (association, sourceUmlClass, umlClasses, searchedRelativePaths) => {

@@ -77,0 +116,0 @@ // Get all valid imports. That is, imports that do not explicitly import contracts or interfaces

2

package.json
{
"name": "sol2uml",
"version": "2.5.19",
"version": "2.5.20",
"description": "Solidity contract visualisation tool.",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc