Skip to content

Commit

Permalink
Handle plutus related ledger events in Conway
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Oct 7, 2024
1 parent 00f025d commit 9b82418
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}

Expand Down Expand Up @@ -163,7 +164,7 @@ toLedgerEventConway evt =
ShelleyLedgerEventBBODY
(ShelleyInAlonzoEvent (LedgersEvent (Shelley.LedgerEvent conwayLedgerEvent))) ->
case conwayLedgerEvent of
Conway.UtxowEvent{} -> Nothing
Conway.UtxowEvent utxowEvent -> handleConwayUTxOWEvent utxowEvent
Conway.CertsEvent{} -> Nothing
Conway.GovEvent govEvent ->
case govEvent of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ handleShelleyLEDGEREvents
=> Shelley.ShelleyLedgerEvent ledgerera -> Maybe LedgerEvent
handleShelleyLEDGEREvents ledgerEvent =
case ledgerEvent of
Shelley.UtxowEvent e -> handleAlonzoOnwardsUTxOWEvent e
Shelley.UtxowEvent e -> handleAlonzoUTxOWEvent e
Shelley.DelegsEvent e -> handleShelleyDELEGSEvent e
19 changes: 16 additions & 3 deletions cardano-api/internal/Cardano/Api/LedgerEvents/Rule/BBODY/UTXOW.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.Api.LedgerEvents.Rule.BBODY.UTXOW
( handleAlonzoOnwardsUTxOWEvent
( handleAlonzoUTxOWEvent
, handleAllegraMaryUTxOWEvent
, handleConwayUTxOWEvent
, handlePreAlonzoUTxOWEvent
)
where
Expand All @@ -15,18 +17,29 @@ import qualified Cardano.Ledger.Allegra.Rules as Allegra
import Cardano.Ledger.Alonzo.Rules (AlonzoUtxoEvent (..), AlonzoUtxosEvent (..),
AlonzoUtxowEvent (..))
import qualified Cardano.Ledger.Alonzo.Rules as Alonzo
import Cardano.Ledger.Conway
import qualified Cardano.Ledger.Conway.Rules as Conway
import qualified Cardano.Ledger.Core as Ledger.Core
import qualified Cardano.Ledger.Crypto as Crypto
import qualified Cardano.Ledger.Shelley.Rules as Shelley

import Control.State.Transition.Extended

handleAlonzoOnwardsUTxOWEvent
handleConwayUTxOWEvent
:: AlonzoUtxowEvent (ConwayEra Crypto.StandardCrypto) -> Maybe LedgerEvent
handleConwayUTxOWEvent (Alonzo.WrappedShelleyEraEvent (Shelley.UtxoEvent (Alonzo.UtxosEvent conwayUTxOsEvent))) =
case conwayUTxOsEvent of
Conway.TotalDeposits{} -> Nothing
Conway.SuccessfulPlutusScriptsEvent e -> Just $ SuccessfulPlutusScript e
Conway.FailedPlutusScriptsEvent e -> Just $ FailedPlutusScript e
Conway.TxUTxODiff _ _ -> Nothing

handleAlonzoUTxOWEvent
:: Event (Ledger.Core.EraRule "UTXO" ledgerera) ~ AlonzoUtxoEvent ledgerera
=> Event (Ledger.Core.EraRule "UTXOS" ledgerera) ~ AlonzoUtxosEvent ledgerera
=> Ledger.Core.EraCrypto ledgerera ~ Crypto.StandardCrypto
=> AlonzoUtxowEvent ledgerera -> Maybe LedgerEvent
handleAlonzoOnwardsUTxOWEvent (WrappedShelleyEraEvent (Shelley.UtxoEvent (UtxosEvent utxoEvent))) =
handleAlonzoUTxOWEvent (WrappedShelleyEraEvent (Shelley.UtxoEvent (UtxosEvent utxoEvent))) =
case utxoEvent of
Alonzo.AlonzoPpupToUtxosEvent{} -> Nothing
Alonzo.TotalDeposits{} -> Nothing
Expand Down

0 comments on commit 9b82418

Please sign in to comment.