From ff10b891f6f5b5084f62c83714e54bf0f0004f3b Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 13 Feb 2023 16:54:09 +0100 Subject: [PATCH] fix bug where flattened sol file is in wrong order --- apps/remix-ide/src/app/plugins/contractFlattener.tsx | 3 --- .../solidity-compiler/src/lib/logic/flattenerUtilities.ts | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/contractFlattener.tsx b/apps/remix-ide/src/app/plugins/contractFlattener.tsx index 307fd72f31..71c3a4a1c1 100644 --- a/apps/remix-ide/src/app/plugins/contractFlattener.tsx +++ b/apps/remix-ide/src/app/plugins/contractFlattener.tsx @@ -38,12 +38,9 @@ export class ContractFlattener extends Plugin { async flattenContract (source: any, filePath: string, data: any) { const ast = data.sources const dependencyGraph = getDependencyGraph(ast, filePath) - console.log({ dependencyGraph }) - const sortedGraph = dependencyGraph.sort().reverse() const sorted = dependencyGraph.isEmpty() ? [filePath] : dependencyGraph.sort().reverse() - console.log({ sortedGraph, sorted }) const sources = source.sources const result = concatSourceFiles(sorted, sources) await this.call('fileManager', 'writeFile', `${filePath}_flattened.sol`, result) diff --git a/libs/remix-ui/solidity-compiler/src/lib/logic/flattenerUtilities.ts b/libs/remix-ui/solidity-compiler/src/lib/logic/flattenerUtilities.ts index 3d90ab35da..ea147ba3c9 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/logic/flattenerUtilities.ts +++ b/libs/remix-ui/solidity-compiler/src/lib/logic/flattenerUtilities.ts @@ -28,7 +28,7 @@ function _traverse(graph, visited, ast, name) { for (const dependency of dependencies) { const path = resolve(name, dependency); if (path in visited) { - continue; + // continue; fixes wrong ordering of source in flattened file } visited[path] = 1; graph.add(name, path);