Skip to content

Commit

Permalink
Fix / update UsingRawBytesHex class/instances
Browse files Browse the repository at this point in the history
This should be rather taken from upstream. Created two PRs to avoid
workarounds: IntersectMBO/cardano-node#5085
and IntersectMBO/cardano-node#5086
  • Loading branch information
ch1bo committed Apr 14, 2023
1 parent 3716911 commit 6aec931
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hydra-cardano-api/src/Hydra/Cardano/Api/UsingRawBytesHex.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6aec931

Please sign in to comment.