crytic / crytic/crytic-compile
[Bug-Candidate]: Cannot run `slither-flat` in a hardhat project.
- Dominant language
- Python
- Stars
- 197
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the issue:
With `pwd` being the hardhat project root (where `hardhat.config.ts` sits), it doesn't seem to be possible to flatten the contracts.
Running `slither-flat --compile-force hardhat . --strategy OneFile` results in:
### Code example to reproduce the issue:
It's difficult to join a code snippet, as the project is quite big.
### Version:
0.8.3
### Relevant log output:
```shell
Traceback (most recent call last):
File "/home/user/.local/bin/slither-flat", line 8, in
sys.exit(main())
File "/home/user/.local/lib/python3.9/site-packages/slither/tools/flattening/__main__.py", line 106, in main
slither = Slither(args.filename, **vars(args))
File "/home/user/.local/lib/python3.9/site-packages/slither/slither.py", line 95, in __init__
parser.parse_top_level_from_loaded_json(ast, path)
File "/home/user/.local/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 211, in parse_top_level_from_loaded_json
contract.set_offset(top_level_data["src"], self._compilation_unit)
File "/home/user/.local/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 124, in set_offset
self._source_mapping = self._convert_source_mapping(offset, compilation_unit)
File "/home/user/.local/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 101, in _convert_source_mapping
(lines, starting_column, ending_column) = self._compute_line(
File "/home/user/.local/lib/python3.9/site-packages/slither/core/source_mapping/source_mapping.py", line 43, in _compute_line
end_line, ending_column = compilation_unit.core.crytic_compile.get_line_from_offset(
File "/home/user/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 291, in get_line_from_offset
return lines_delimiters[offset]
KeyError: 6870
```
Contributor guide
Assessment
This issue has not been assessed yet.