Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ledger-sync/src/Spectrum/EventSource/Data/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import qualified Cardano.Ledger.TxIn as Ledger

import qualified PlutusTx.Prelude as PlutusTx

import qualified Cardano.Ledger.Babbage.TxBody as TxBody
import Cardano.Ledger.Coin (Coin (..))

import CardanoTx.Models
( FullTxOut (FullTxOut), TxOutDatum (EmptyDatum, KnownDatumHash, KnownDatum) )
import Cardano.Api.Shelley
Expand Down Expand Up @@ -68,6 +71,7 @@ data MinimalUnconfirmedTx = MinimalUnconfirmedTx
, txInputs :: Set.Set P.TxIn
, txOutputs :: [FullTxOut]
, slotNo :: SlotNo
, txFee :: Integer
} deriving (Show, Eq, Generic, FromJSON, ToJSON)

-- | A minimal sufficient representation of a confirmed transaction
Expand All @@ -77,6 +81,7 @@ data MinimalConfirmedTx = MinimalConfirmedTx
, txInputs :: Set.Set P.TxIn
, txOutputs :: [FullTxOut]
, slotNo :: SlotNo
, txFee :: Integer
} deriving (Show, Eq, Generic, FromJSON, ToJSON)

data MinimalTx ctx where
Expand Down Expand Up @@ -117,6 +122,7 @@ fromBabbageLedgerTx blockHash slotNo vtx =
txOutValue
(parseDatum txOutDatum)
txOutReferenceScript)
txFee = unCoin $ TxBody.txfee' body
parseDatum datum = case datum of
PV2.NoOutputDatum -> EmptyDatum
PV2.OutputDatumHash dh -> KnownDatumHash dh
Expand All @@ -129,6 +135,7 @@ fromBabbageLedgerTx blockHash slotNo vtx =
<&> uncurry fromCardanoTxOut
>>= either mempty pure
, slotNo = slotNo
, txFee = txFee
}

fromMempoolBabbageLedgerTx
Expand Down Expand Up @@ -156,6 +163,7 @@ fromMempoolBabbageLedgerTx vtx slotNo =
txOutValue
(parseDatum txOutDatum)
txOutReferenceScript)
txFee = unCoin $ TxBody.txfee' body
parseDatum datum = case datum of
PV2.NoOutputDatum -> EmptyDatum
PV2.OutputDatumHash dh -> KnownDatumHash dh
Expand All @@ -167,4 +175,5 @@ fromMempoolBabbageLedgerTx vtx slotNo =
<&> uncurry fromCardanoTxOut
>>= either mempty pure
, slotNo = slotNo
, txFee = txFee
}