@@ -4,15 +4,13 @@ module Hydra.Cardano.Api.ScriptData where
4
4
5
5
import Hydra.Cardano.Api.Prelude hiding (left )
6
6
7
- import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
8
7
import Cardano.Ledger.Era qualified as Ledger
9
8
import Cardano.Ledger.Plutus.Data qualified as Ledger
10
9
import Codec.Serialise (deserialiseOrFail , serialise )
11
10
import Control.Arrow (left )
12
11
import Data.Aeson (Value (String ), withText )
13
12
import Data.ByteString qualified as BS
14
13
import Data.ByteString.Base16 qualified as Base16
15
- import Data.Map qualified as Map
16
14
import PlutusLedgerApi.V3 qualified as Plutus
17
15
import Test.QuickCheck (arbitrarySizedNatural , choose , oneof , scale , sized , vector )
18
16
@@ -36,39 +34,14 @@ fromScriptData =
36
34
Plutus. fromData . toPlutusData . getScriptData
37
35
38
36
-- | Get the 'HashableScriptData' associated to the a 'TxOut'. Note that this
39
- -- requires the 'CtxTx' context. To get script data in a 'CtxUTxO' context, see
40
- -- 'lookupScriptData'.
37
+ -- requires the 'CtxTx' context.
41
38
txOutScriptData :: TxOut CtxTx era -> Maybe HashableScriptData
42
39
txOutScriptData (TxOut _ _ d _) =
43
40
case d of
44
41
TxOutDatumInTx _ sd -> Just sd
45
42
TxOutDatumInline _ sd -> Just sd
46
43
_ -> Nothing
47
44
48
- -- | Lookup included datum of given 'TxOut'.
49
- lookupScriptData ::
50
- forall era .
51
- ( UsesStandardCrypto era
52
- , Ledger. Era (ShelleyLedgerEra era )
53
- ) =>
54
- Tx era ->
55
- TxOut CtxUTxO era ->
56
- Maybe HashableScriptData
57
- lookupScriptData (Tx (ShelleyTxBody _ _ _ scriptsData _ _) _) (TxOut _ _ datum _) =
58
- case datum of
59
- TxOutDatumNone ->
60
- Nothing
61
- (TxOutDatumHash _ (ScriptDataHash h)) ->
62
- fromLedgerData <$> Map. lookup h datums
63
- (TxOutDatumInline _ dat) ->
64
- Just dat
65
- where
66
- datums :: Map (Ledger. DataHash StandardCrypto ) (Ledger. Data (ShelleyLedgerEra era ))
67
- datums =
68
- case (scriptsData :: TxBodyScriptData era ) of
69
- TxBodyNoScriptData -> mempty
70
- TxBodyScriptData _ (Ledger. TxDats m) _ -> m
71
-
72
45
-- * Type Conversions
73
46
74
47
-- | Convert a cardano-ledger script 'Data' into a cardano-api 'ScriptDatum'.
0 commit comments