From a92477db60d54ad353b818e67a4e25120ea18641 Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Wed, 26 Oct 2022 11:03:52 +0200 Subject: [PATCH] Improve slither-flat suppport of top level objects --- slither/tools/flattening/flattening.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/slither/tools/flattening/flattening.py b/slither/tools/flattening/flattening.py index ef793f2f2..74a93ba2d 100644 --- a/slither/tools/flattening/flattening.py +++ b/slither/tools/flattening/flattening.py @@ -4,7 +4,7 @@ import uuid from collections import namedtuple from enum import Enum as PythonEnum 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.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.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: src_mapping = elem.source_mapping - content = self._compilation_unit.core.source_code[src_mapping["filename_absolute"]] - start = src_mapping["start"] - end = src_mapping["start"] + src_mapping["length"] + content = self._compilation_unit.core.source_code[src_mapping.filename.absolute] + start = src_mapping.start + end = src_mapping.start + src_mapping.length self._source_codes_top_level[elem] = content[start:end] def _check_abi_encoder_v2(self):