Skip to content

Commit 2d9eb65

Browse files
sgillespiekderme
authored andcommitted
feature(cardano-db): Add support for tx.treasury_donation
1 parent 2593723 commit 2d9eb65

File tree

8 files changed

+9
-1
lines changed

8 files changed

+9
-1
lines changed

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Allegra.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ fromAllegraTx (blkIndex, tx) =
7676
, txExtraKeyWitnesses = []
7777
, txVotingProcedure = []
7878
, txProposalProcedure = []
79+
, txTreasuryDonation = mempty -- Allegra does not support treasury donations
7980
}
8081
where
8182
txBody :: Core.TxBody StandardAllegra

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Alonzo.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ fromAlonzoTx ioExtraPlutus mprices (blkIndex, tx) =
109109
, txExtraKeyWitnesses = extraKeyWits txBody
110110
, txVotingProcedure = []
111111
, txProposalProcedure = []
112+
, txTreasuryDonation = mempty -- Alonzo does not support treasury donations
112113
}
113114
where
114115
txBody :: Alonzo.AlonzoTxBody StandardAlonzo

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Babbage.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ fromBabbageTx ioExtraPlutus mprices (blkIndex, tx) =
7878
, txExtraKeyWitnesses = extraKeyWits txBody
7979
, txVotingProcedure = []
8080
, txProposalProcedure = []
81+
, txTreasuryDonation = mempty -- Babbage does not support treasury donations
8182
}
8283
where
8384
txBody :: Core.TxBody StandardBabbage

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Conway.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fromConwayTx ioExtraPlutus mprices (blkIndex, tx) =
7070
, txExtraKeyWitnesses = extraKeyWits txBody
7171
, txVotingProcedure = Map.toList $ fmap Map.toList (unVotingProcedures $ ctbVotingProcedures txBody)
7272
, txProposalProcedure = zipWith mkProposalIndex [0 ..] $ toList $ ctbProposalProcedures txBody
73+
, txTreasuryDonation = ctbTreasuryDonation txBody
7374
}
7475
where
7576
txBody :: Core.TxBody StandardConway

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Mary.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ fromMaryTx (blkIndex, tx) =
4949
, txExtraKeyWitnesses = []
5050
, txVotingProcedure = []
5151
, txProposalProcedure = []
52+
, txTreasuryDonation = mempty -- Mary does not support treasury donations
5253
}
5354
where
5455
txBody :: Core.TxBody StandardMary

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Shelley.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ fromShelleyTx (blkIndex, tx) =
8181
, txExtraKeyWitnesses = []
8282
, txVotingProcedure = []
8383
, txProposalProcedure = []
84+
, txTreasuryDonation = mempty -- Shelley does not support treasury donations
8485
}
8586
where
8687
txBody :: Core.TxBody StandardShelley

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Types.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ data Tx = Tx
7474
, txExtraKeyWitnesses :: ![ByteString]
7575
, txVotingProcedure :: ![(Voter StandardCrypto, [(GovActionId StandardCrypto, VotingProcedure StandardConway)])]
7676
, txProposalProcedure :: ![(GovActionId StandardCrypto, ProposalProcedure StandardConway)]
77+
, txTreasuryDonation :: !Coin
7778
}
7879

7980
type ShelleyCert = ShelleyTxCert StandardShelley

cardano-db-sync/src/Cardano/DbSync/Era/Universal/Insert/Tx.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
7777
let !mdeposits = if not (Generic.txValidContract tx) then Just (Coin 0) else lookupDepositsMap txHash (apDepositsMap applyResult)
7878
let !outSum = fromIntegral $ unCoin $ Generic.txOutSum tx
7979
!withdrawalSum = fromIntegral $ unCoin $ Generic.txWithdrawalSum tx
80+
!treasuryDonation = fromIntegral . unCoin $ Generic.txTreasuryDonation tx
8081
hasConsumed = getHasConsumedOrPruneTxOut syncEnv
8182
disInOut <- liftIO $ getDisableInOutState syncEnv
8283
-- In some txs and with specific configuration we may be able to find necessary data within the tx body.
@@ -117,7 +118,7 @@ insertTx syncEnv isMember blkId epochNo slotNo applyResult blockIndex tx grouped
117118
, DB.txInvalidHereafter = DbWord64 . unSlotNo <$> Generic.txInvalidHereafter tx
118119
, DB.txValidContract = Generic.txValidContract tx
119120
, DB.txScriptSize = sum $ Generic.txScriptSizes tx
120-
, DB.txTreasuryDonation = DB.DbLovelace 0
121+
, DB.txTreasuryDonation = DB.DbLovelace treasuryDonation
121122
}
122123

123124
when (ioTxCBOR iopts) $ do

0 commit comments

Comments
 (0)