Expose HexString constructor

This commit is contained in:
Rene Vergara 2024-02-05 15:31:19 -06:00
parent 268eb1cd53
commit be830be714
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -6,7 +6,7 @@
{-# LANGUAGE OverloadedStrings #-}
module Data.HexString
( HexString
( HexString(..)
, hexString
, fromBinary
, toBinary
@ -36,12 +36,12 @@ import qualified Generics.SOP as SOP
-- | Represents a Hex string. Guarantees that all characters it contains
-- are valid hex characters.
data HexString =
HexString BS.ByteString
deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct HexString
newtype HexString = HexString
{ bytes :: BS.ByteString
} deriving stock (Eq, Prelude.Show, GHC.Generic)
deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo)
deriving anyclass (Data.Structured.Show)
deriving (BorshSize, ToBorsh, FromBorsh) via AsStruct HexString
instance FromJSON HexString where
parseJSON = withText "HexString" $ pure . hexString . TE.encodeUtf8