From 298f954462eed689590896c9eb81b78fefcefea9 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 15 Sep 2023 17:28:46 +0200 Subject: [PATCH 1/3] print bytes32 values as hex --- lib/Echidna/ABI.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Echidna/ABI.hs b/lib/Echidna/ABI.hs index 6c6d6d10e..f4b174dd2 100644 --- a/lib/Echidna/ABI.hs +++ b/lib/Echidna/ABI.hs @@ -71,6 +71,7 @@ ppAbiValue = \case AbiInt _ n -> show n AbiAddress n -> "0x" <> showHex n "" AbiBool b -> if b then "true" else "false" + AbiBytes 32 b -> "0x" <> BS.foldr showHex "" b AbiBytes _ b -> show b AbiBytesDynamic b -> show b AbiString s -> show s From 7807107bfa241f01d9ca0e841599ae661f02a340 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Mon, 18 Sep 2023 18:53:10 +0200 Subject: [PATCH 2/3] make sure hex output is padded properly --- lib/Echidna/ABI.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Echidna/ABI.hs b/lib/Echidna/ABI.hs index f4b174dd2..e3532150a 100644 --- a/lib/Echidna/ABI.hs +++ b/lib/Echidna/ABI.hs @@ -20,6 +20,7 @@ import Data.List (intercalate) import Data.List.NonEmpty (NonEmpty) import Data.List.NonEmpty qualified as NE import Data.Maybe (fromMaybe, catMaybes) +import Text.Printf (printf) import Data.Text (Text) import Data.Text qualified as T import Data.Text.Encoding (encodeUtf8) @@ -71,7 +72,7 @@ ppAbiValue = \case AbiInt _ n -> show n AbiAddress n -> "0x" <> showHex n "" AbiBool b -> if b then "true" else "false" - AbiBytes 32 b -> "0x" <> BS.foldr showHex "" b + AbiBytes 32 b -> "0x" <> (BS.foldr (\x -> (<>) (printf "%02x" x)) "" b) AbiBytes _ b -> show b AbiBytesDynamic b -> show b AbiString s -> show s From eb9493319d48fac2b2d718d87cb4c5d4a8be6fd2 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Mon, 18 Sep 2023 18:58:35 +0200 Subject: [PATCH 3/3] hlint fixes --- lib/Echidna/ABI.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Echidna/ABI.hs b/lib/Echidna/ABI.hs index e3532150a..1063e427d 100644 --- a/lib/Echidna/ABI.hs +++ b/lib/Echidna/ABI.hs @@ -72,7 +72,7 @@ ppAbiValue = \case AbiInt _ n -> show n AbiAddress n -> "0x" <> showHex n "" AbiBool b -> if b then "true" else "false" - AbiBytes 32 b -> "0x" <> (BS.foldr (\x -> (<>) (printf "%02x" x)) "" b) + AbiBytes 32 b -> "0x" <> BS.foldr ((<>) . printf "%02x") "" b AbiBytes _ b -> show b AbiBytesDynamic b -> show b AbiString s -> show s