fix bug where flattened sol file is in wrong order

homebtn
Joseph Izang 2 years ago committed by Aniket
parent 8cb2cda4cf
commit ff10b891f6
  1. 3
      apps/remix-ide/src/app/plugins/contractFlattener.tsx
  2. 2
      libs/remix-ui/solidity-compiler/src/lib/logic/flattenerUtilities.ts

@ -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)

@ -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);

Loading…
Cancel
Save