Merge pull request #1441 from crytic/dev-slither-flat-fix

Improve slither-flat suppport of top level objects
pull/1443/head
Feist Josselin 2 years ago committed by GitHub
commit 4b3d5f442b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      slither/tools/flattening/flattening.py

@ -4,7 +4,7 @@ import uuid
from collections import namedtuple from collections import namedtuple
from enum import Enum as PythonEnum from enum import Enum as PythonEnum
from pathlib import Path from pathlib import Path
from typing import List, Set, Dict, Optional from typing import List, Set, Dict, Optional, Sequence
from slither.core.compilation_unit import SlitherCompilationUnit from slither.core.compilation_unit import SlitherCompilationUnit
from slither.core.declarations import SolidityFunction, EnumContract, StructureContract from slither.core.declarations import SolidityFunction, EnumContract, StructureContract
@ -78,12 +78,12 @@ class Flattening:
self._get_source_code_top_level(compilation_unit.variables_top_level) self._get_source_code_top_level(compilation_unit.variables_top_level)
self._get_source_code_top_level(compilation_unit.functions_top_level) self._get_source_code_top_level(compilation_unit.functions_top_level)
def _get_source_code_top_level(self, elems: List[TopLevel]) -> None: def _get_source_code_top_level(self, elems: Sequence[TopLevel]) -> None:
for elem in elems: for elem in elems:
src_mapping = elem.source_mapping src_mapping = elem.source_mapping
content = self._compilation_unit.core.source_code[src_mapping["filename_absolute"]] content = self._compilation_unit.core.source_code[src_mapping.filename.absolute]
start = src_mapping["start"] start = src_mapping.start
end = src_mapping["start"] + src_mapping["length"] end = src_mapping.start + src_mapping.length
self._source_codes_top_level[elem] = content[start:end] self._source_codes_top_level[elem] = content[start:end]
def _check_abi_encoder_v2(self): def _check_abi_encoder_v2(self):

Loading…
Cancel
Save