Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/instrumenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ class Instrumenter {

// Handle contracts which only contain import statements
contract.contractName = (root.length) ? root[0].name : null;

contract.finalParse = true;
parse[ast.type](contract, ast);

// We have to iterate through these points in descending order
const sortedPoints = Object.keys(contract.injectionPoints).sort((a, b) => b - a);

Expand Down
6 changes: 4 additions & 2 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ parse.PragmaDirective = function(contract, expression){
}

// From solc >=0.7.4, every file should have instrumentation methods
// defined at the file level which file scoped fns can use...
if (semver.lt("0.7.3", minVersion)){
// defined at the file level which file scoped fns can use. (Make sure we only do this
// once - flattened contracts have multiple pragma statements)
if (semver.lt("0.7.3", minVersion) && contract.finalParse && !contract.fileLevelFinished){
const start = expression.range[0];
const end = contract.instrumented.slice(start).indexOf(';') + 1;
const loc = start + end;
Expand All @@ -258,6 +259,7 @@ parse.PragmaDirective = function(contract, expression){
};

contract.injectionPoints[loc] = [injectionObject];
contract.fileLevelFinished = true;
}
}

Expand Down

This file was deleted.

Loading