From e4bca71eb85fde470d02a20110ac04250c5bb9e7 Mon Sep 17 00:00:00 2001 From: timofey Date: Thu, 9 Nov 2023 15:22:35 +0100 Subject: [PATCH 1/2] tx fee added --- ledger-sync/src/Spectrum/EventSource/Data/Tx.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ledger-sync/src/Spectrum/EventSource/Data/Tx.hs b/ledger-sync/src/Spectrum/EventSource/Data/Tx.hs index 3bde7d97..c7bc4c8d 100755 --- a/ledger-sync/src/Spectrum/EventSource/Data/Tx.hs +++ b/ledger-sync/src/Spectrum/EventSource/Data/Tx.hs @@ -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 @@ -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 @@ -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 @@ -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 @@ -128,7 +134,8 @@ fromBabbageLedgerTx blockHash slotNo vtx = , txOutputs = zip [0..] (toList $ Al.outputs body) <&> uncurry fromCardanoTxOut >>= either mempty pure - , slotNo = slotNo + , slotNo = slotNo, + , txFee = txFee } fromMempoolBabbageLedgerTx @@ -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 @@ -167,4 +175,5 @@ fromMempoolBabbageLedgerTx vtx slotNo = <&> uncurry fromCardanoTxOut >>= either mempty pure , slotNo = slotNo + , txFee = txFee } From 6ab90de9e6205f34116346521eead7fdd57b87f2 Mon Sep 17 00:00:00 2001 From: timofey Date: Thu, 9 Nov 2023 15:27:47 +0100 Subject: [PATCH 2/2] wip --- ledger-sync/src/Spectrum/EventSource/Data/Tx.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ledger-sync/src/Spectrum/EventSource/Data/Tx.hs b/ledger-sync/src/Spectrum/EventSource/Data/Tx.hs index c7bc4c8d..72301984 100755 --- a/ledger-sync/src/Spectrum/EventSource/Data/Tx.hs +++ b/ledger-sync/src/Spectrum/EventSource/Data/Tx.hs @@ -134,7 +134,7 @@ fromBabbageLedgerTx blockHash slotNo vtx = , txOutputs = zip [0..] (toList $ Al.outputs body) <&> uncurry fromCardanoTxOut >>= either mempty pure - , slotNo = slotNo, + , slotNo = slotNo , txFee = txFee }