module Hydra.Cardano.Api.TxScriptValidity where

import Hydra.Cardano.Api.Prelude

import Cardano.Ledger.Alonzo.Tx qualified as Ledger

-- | Convert a cardano-api 'TxScriptValidity' into a cardano-ledger 'IsValid'
-- boolean wrapper.
toLedgerScriptValidity :: TxScriptValidity era -> Ledger.IsValid
toLedgerScriptValidity :: forall era. TxScriptValidity era -> IsValid
toLedgerScriptValidity =
  Bool -> IsValid
Ledger.IsValid (Bool -> IsValid)
-> (TxScriptValidity era -> Bool)
-> TxScriptValidity era
-> IsValid
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
    TxScriptValidity era
TxScriptValidityNone -> Bool
True
    TxScriptValidity AlonzoEraOnwards era
_ ScriptValidity
ScriptValid -> Bool
True
    TxScriptValidity AlonzoEraOnwards era
_ ScriptValidity
ScriptInvalid -> Bool
False