Skip to content

Commit

Permalink
Remove unused decode functions
Browse files Browse the repository at this point in the history
  • Loading branch information
locallycompact committed Mar 22, 2024
1 parent 905a65b commit 47d8ab1
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions src/Kupo/Data/Hydra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,15 @@ import Kupo.Data.Cardano
( BinaryData
, BlockNo (..)
, Datum (..)
, DatumHash
, Input
, Output
, OutputIndex
, OutputReference
, Script
, ScriptHash
, SlotNo (..)
, Tip
, TransactionId
, Value
, binaryDataFromBytes
, datumHashFromBytes
, getOutputIndex
, getTransactionId
, mkOutput
Expand All @@ -55,7 +51,6 @@ import Kupo.Data.Cardano
, pattern BlockPoint
, pattern Tip
, scriptFromBytes
, scriptHashFromText
, transactionIdFromText
, transactionIdToBytes
, unsafeHeaderHashFromBytes
Expand Down Expand Up @@ -219,28 +214,6 @@ decodePartialTransaction = Json.withObject "PartialTransaction" $ \o -> do
TimelockScript timelock -> TimelockScript (translateTimelock timelock)
PlutusScript script -> PlutusScript script

decodeDatums :: Json.Value -> Json.Parser (Map DatumHash BinaryData)
decodeDatums = Json.withObject "Datums" $
KeyMap.foldrWithKey
(\k v accum -> Map.insert
<$> decodeDatumHash k
<*> decodeBinaryData v
<*> accum
)
(pure mempty)

decodeDatumHash
:: Json.Key
-> Json.Parser DatumHash
decodeDatumHash k = do
case datumHashFromBytes <$> decodeBase16 (encodeUtf8 (Key.toText k)) of
Right (Just hash) ->
pure hash
Right Nothing ->
fail "decodeDatumHash: datumHashFromBytes failed."
Left e ->
fail (toString e)

decodeInput
:: Json.Value
-> Json.Parser Input
Expand Down Expand Up @@ -334,24 +307,6 @@ decodeScriptInEnvelope = Json.withObject "ScriptInEnvelope" $ \o -> do
scriptFromBytes' =
maybe (fail "decodeScript: malformed script") pure . scriptFromBytes

decodeScripts :: Json.Value -> Json.Parser (Map ScriptHash Script)
decodeScripts = Json.withObject "Scripts" $
KeyMap.foldrWithKey
(\k v accum -> Map.insert
<$> decodeScriptHash k
<*> decodeScript v
<*> accum
)
(pure mempty)

decodeScriptHash
:: Json.Key
-> Json.Parser ScriptHash
decodeScriptHash k =
case scriptHashFromText (Key.toText k) of
Nothing -> fail "decodeScriptHash"
Just scriptHash -> pure scriptHash

decodeSnapshotConfirmed :: Json.Object -> Json.Parser Snapshot
decodeSnapshotConfirmed o = do
snapshot <- o .: "snapshot"
Expand Down

0 comments on commit 47d8ab1

Please sign in to comment.