From 6aec9313470cc33e3b374feecfc87671446e0db6 Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Wed, 12 Apr 2023 12:58:27 +0200 Subject: [PATCH] Fix / update UsingRawBytesHex class/instances This should be rather taken from upstream. Created two PRs to avoid workarounds: https://github.com/input-output-hk/cardano-node/pull/5085 and https://github.com/input-output-hk/cardano-node/pull/5086 --- .../src/Hydra/Cardano/Api/UsingRawBytesHex.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hydra-cardano-api/src/Hydra/Cardano/Api/UsingRawBytesHex.hs b/hydra-cardano-api/src/Hydra/Cardano/Api/UsingRawBytesHex.hs index 1ba0c800f7e..58681facdee 100644 --- a/hydra-cardano-api/src/Hydra/Cardano/Api/UsingRawBytesHex.hs +++ b/hydra-cardano-api/src/Hydra/Cardano/Api/UsingRawBytesHex.hs @@ -1,6 +1,8 @@ -- | Shamelessly stolen from cardan-api 'Cardano.Api.SerialiseUsing' module. -- -- With some minor modifications of also using encodeUtf8 in 'IsString' instance. +-- +-- XXX: Expose / contribute upstream module Hydra.Cardano.Api.UsingRawBytesHex where import Hydra.Cardano.Api.Prelude @@ -52,8 +54,10 @@ deserialiseFromRawBytesBase16 :: deserialiseFromRawBytesBase16 str = case Base16.decode str of Right raw -> case deserialiseFromRawBytes ttoken raw of - Just x -> Right (UsingRawBytesHex x) - Nothing -> Left ("cannot deserialise " ++ show str) + Right x -> Right (UsingRawBytesHex x) + -- XXX: cannot user inner value because SerialiseAsRawBytesError data + -- constructor not exposed + Left e -> Left ("cannot deserialise " ++ show str ++ ". The error was: " <> show e) Left msg -> Left ("invalid hex " ++ show str ++ ", " ++ msg) where ttoken = proxyToAsType (Proxy :: Proxy a)