dop-stick
Version:
Source control tooling for versionable-upgradeable smart contracts
39 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LibraryDetector = void 0;
const logger_1 = require("../logsAndMetrics/core/logger");
class LibraryDetector {
constructor(factoryManager) {
this.factoryManager = factoryManager;
}
async detectLibraries(moduleName) {
var _a;
const metadata = await this.factoryManager.getContractMetadata(moduleName);
const libraries = [];
if (metadata.linkReferences) {
for (const [filePath, libs] of Object.entries(metadata.linkReferences)) {
for (const libName of Object.keys(libs)) {
// Extract just the library name from the path
const libraryFileName = ((_a = libName.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace('.sol', '')) || libName;
try {
// Use the public method to find factory path
const factoryPath = await this.factoryManager.findFactoryPath(libraryFileName);
libraries.push({
name: libraryFileName,
factoryPath,
relativePath: filePath
});
logger_1.Logger.debug(`Detected library: ${libraryFileName} at ${factoryPath}`);
}
catch (error) {
logger_1.Logger.error(`Failed to find factory for library ${libraryFileName}:`, error);
throw new Error(`Failed to find factory for library ${libraryFileName}`);
}
}
}
}
return libraries;
}
}
exports.LibraryDetector = LibraryDetector;
//# sourceMappingURL=libraryDetector.js.map