From 7887f3914d0dd8c2e1857119591a7280d6a40045 Mon Sep 17 00:00:00 2001 From: Marius G <90795310+bearpebble@users.noreply.github.com> Date: Mon, 29 Nov 2021 16:00:07 +0100 Subject: [PATCH] Fix slither-flat external/private options (#964) The options --convert-external and --convert-private are currently broken from what looks like some automatic conversion according to git blame. Also fixes issue #580 --- slither/tools/flattening/flattening.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slither/tools/flattening/flattening.py b/slither/tools/flattening/flattening.py index f2c721fcd..a1dbc0a9d 100644 --- a/slither/tools/flattening/flattening.py +++ b/slither/tools/flattening/flattening.py @@ -88,7 +88,7 @@ class Flattening: :return: """ src_mapping = contract.source_mapping - content = self._slither.source_code[src_mapping["filename_absolute"]].encode("utf8") + content = self._slither.source_code[src_mapping["filename_absolute"]] start = src_mapping["start"] end = src_mapping["start"] + src_mapping["length"] @@ -171,7 +171,7 @@ class Flattening: index = index - start if patch_type == "public_to_external": content = content[:index] + "public" + content[index + len("external") :] - if patch_type == "private_to_internal": + elif patch_type == "private_to_internal": content = content[:index] + "internal" + content[index + len("private") :] elif patch_type == "calldata_to_memory": content = content[:index] + "memory" + content[index + len("calldata") :] @@ -179,7 +179,7 @@ class Flattening: assert patch_type == "line_removal" content = content[:index] + " // " + content[index:] - self._source_codes[contract] = content.decode("utf8") + self._source_codes[contract] = content def _pragmas(self) -> str: """