-- | Transaction metadata

module Blockfrost.Types.Cardano.Mempool
  ( MempoolTransaction(..)
  , TransactionInMempool (..)
  , MempoolUTxOInput(..)
  , MempoolRedeemer(..)
  ) where

import Data.Text
import Deriving.Aeson
import Blockfrost.Types.Cardano.Transactions
import Blockfrost.Types.Shared.Ada
import Blockfrost.Types.Shared.Amount

data MempoolTransaction = MempoolTransaction
  { MempoolTransaction -> TransactionInMempool
_tx :: TransactionInMempool
  , MempoolTransaction -> [MempoolUTxOInput]
_inputs :: [MempoolUTxOInput]
  , MempoolTransaction -> [UtxoOutput]
_outputs :: [UtxoOutput]
  , MempoolTransaction -> Maybe [MempoolRedeemer]
_redeemers :: Maybe [MempoolRedeemer]
  }
  deriving stock (Int -> MempoolTransaction -> ShowS
[MempoolTransaction] -> ShowS
MempoolTransaction -> String
(Int -> MempoolTransaction -> ShowS)
-> (MempoolTransaction -> String)
-> ([MempoolTransaction] -> ShowS)
-> Show MempoolTransaction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MempoolTransaction -> ShowS
showsPrec :: Int -> MempoolTransaction -> ShowS
$cshow :: MempoolTransaction -> String
show :: MempoolTransaction -> String
$cshowList :: [MempoolTransaction] -> ShowS
showList :: [MempoolTransaction] -> ShowS
Show, MempoolTransaction -> MempoolTransaction -> Bool
(MempoolTransaction -> MempoolTransaction -> Bool)
-> (MempoolTransaction -> MempoolTransaction -> Bool)
-> Eq MempoolTransaction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MempoolTransaction -> MempoolTransaction -> Bool
== :: MempoolTransaction -> MempoolTransaction -> Bool
$c/= :: MempoolTransaction -> MempoolTransaction -> Bool
/= :: MempoolTransaction -> MempoolTransaction -> Bool
Eq, (forall x. MempoolTransaction -> Rep MempoolTransaction x)
-> (forall x. Rep MempoolTransaction x -> MempoolTransaction)
-> Generic MempoolTransaction
forall x. Rep MempoolTransaction x -> MempoolTransaction
forall x. MempoolTransaction -> Rep MempoolTransaction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MempoolTransaction -> Rep MempoolTransaction x
from :: forall x. MempoolTransaction -> Rep MempoolTransaction x
$cto :: forall x. Rep MempoolTransaction x -> MempoolTransaction
to :: forall x. Rep MempoolTransaction x -> MempoolTransaction
Generic)
  deriving (Maybe MempoolTransaction
Value -> Parser [MempoolTransaction]
Value -> Parser MempoolTransaction
(Value -> Parser MempoolTransaction)
-> (Value -> Parser [MempoolTransaction])
-> Maybe MempoolTransaction
-> FromJSON MempoolTransaction
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser MempoolTransaction
parseJSON :: Value -> Parser MempoolTransaction
$cparseJSONList :: Value -> Parser [MempoolTransaction]
parseJSONList :: Value -> Parser [MempoolTransaction]
$comittedField :: Maybe MempoolTransaction
omittedField :: Maybe MempoolTransaction
FromJSON, [MempoolTransaction] -> Value
[MempoolTransaction] -> Encoding
MempoolTransaction -> Bool
MempoolTransaction -> Value
MempoolTransaction -> Encoding
(MempoolTransaction -> Value)
-> (MempoolTransaction -> Encoding)
-> ([MempoolTransaction] -> Value)
-> ([MempoolTransaction] -> Encoding)
-> (MempoolTransaction -> Bool)
-> ToJSON MempoolTransaction
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: MempoolTransaction -> Value
toJSON :: MempoolTransaction -> Value
$ctoEncoding :: MempoolTransaction -> Encoding
toEncoding :: MempoolTransaction -> Encoding
$ctoJSONList :: [MempoolTransaction] -> Value
toJSONList :: [MempoolTransaction] -> Value
$ctoEncodingList :: [MempoolTransaction] -> Encoding
toEncodingList :: [MempoolTransaction] -> Encoding
$comitField :: MempoolTransaction -> Bool
omitField :: MempoolTransaction -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_", CamelToSnake]] MempoolTransaction

data TransactionInMempool = TransactionInMempool
  { TransactionInMempool -> Text
_transactionHash                 :: Text -- ^ Transaction hash
  , TransactionInMempool -> [Amount]
_transactionOutputAmount         :: [Amount] -- ^ Transaction outputs
  , TransactionInMempool -> Lovelaces
_transactionFees                 :: Lovelaces -- ^ Transaction fee
  , TransactionInMempool -> Lovelaces
_transactionDeposit              :: Lovelaces -- ^ Deposit within the transaction in Lovelaces
  , TransactionInMempool -> Integer
_transactionSize                 :: Integer -- ^ Size of the transaction in Bytes
  , TransactionInMempool -> Maybe Text
_transactionInvalidBefore        :: Maybe Text -- ^ Left (included) endpoint of the timelock validity intervals
  , TransactionInMempool -> Maybe Text
_transactionInvalidHereafter     :: Maybe Text -- ^ Right (excluded) endpoint of the timelock validity intervals
  , TransactionInMempool -> Integer
_transactionUtxoCount            :: Integer -- ^ Count of UTXOs within the transaction
  , TransactionInMempool -> Integer
_transactionWithdrawalCount      :: Integer -- ^ Count of the withdrawals within the transaction
  , TransactionInMempool -> Integer
_transactionMirCertCount         :: Integer -- ^ Count of the MIR certificates within the transaction
  , TransactionInMempool -> Integer
_transactionDelegationCount      :: Integer -- ^ Count of the delegations within the transaction
  , TransactionInMempool -> Integer
_transactionStakeCertCount       :: Integer -- ^ Count of the stake keys (de)registration and delegation certificates within the transaction
  , TransactionInMempool -> Integer
_transactionPoolUpdateCount      :: Integer -- ^ Count of the stake pool registration and update certificates within the transaction
  , TransactionInMempool -> Integer
_transactionPoolRetireCount      :: Integer -- ^ Count of the stake pool retirement certificates within the transaction
  , TransactionInMempool -> Integer
_transactionAssetMintOrBurnCount :: Integer -- ^ Count of asset mints and burns within the transaction
  , TransactionInMempool -> Integer
_transactionRedeemerCount        :: Integer -- ^ Count of redeemers within the transaction
  , TransactionInMempool -> Bool
_transactionValidContract        :: Bool    -- ^ True if this is a valid transaction, False in case of contract validation failure
  }
  deriving stock (Int -> TransactionInMempool -> ShowS
[TransactionInMempool] -> ShowS
TransactionInMempool -> String
(Int -> TransactionInMempool -> ShowS)
-> (TransactionInMempool -> String)
-> ([TransactionInMempool] -> ShowS)
-> Show TransactionInMempool
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TransactionInMempool -> ShowS
showsPrec :: Int -> TransactionInMempool -> ShowS
$cshow :: TransactionInMempool -> String
show :: TransactionInMempool -> String
$cshowList :: [TransactionInMempool] -> ShowS
showList :: [TransactionInMempool] -> ShowS
Show, TransactionInMempool -> TransactionInMempool -> Bool
(TransactionInMempool -> TransactionInMempool -> Bool)
-> (TransactionInMempool -> TransactionInMempool -> Bool)
-> Eq TransactionInMempool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TransactionInMempool -> TransactionInMempool -> Bool
== :: TransactionInMempool -> TransactionInMempool -> Bool
$c/= :: TransactionInMempool -> TransactionInMempool -> Bool
/= :: TransactionInMempool -> TransactionInMempool -> Bool
Eq, (forall x. TransactionInMempool -> Rep TransactionInMempool x)
-> (forall x. Rep TransactionInMempool x -> TransactionInMempool)
-> Generic TransactionInMempool
forall x. Rep TransactionInMempool x -> TransactionInMempool
forall x. TransactionInMempool -> Rep TransactionInMempool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TransactionInMempool -> Rep TransactionInMempool x
from :: forall x. TransactionInMempool -> Rep TransactionInMempool x
$cto :: forall x. Rep TransactionInMempool x -> TransactionInMempool
to :: forall x. Rep TransactionInMempool x -> TransactionInMempool
Generic)
  deriving (Maybe TransactionInMempool
Value -> Parser [TransactionInMempool]
Value -> Parser TransactionInMempool
(Value -> Parser TransactionInMempool)
-> (Value -> Parser [TransactionInMempool])
-> Maybe TransactionInMempool
-> FromJSON TransactionInMempool
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser TransactionInMempool
parseJSON :: Value -> Parser TransactionInMempool
$cparseJSONList :: Value -> Parser [TransactionInMempool]
parseJSONList :: Value -> Parser [TransactionInMempool]
$comittedField :: Maybe TransactionInMempool
omittedField :: Maybe TransactionInMempool
FromJSON, [TransactionInMempool] -> Value
[TransactionInMempool] -> Encoding
TransactionInMempool -> Bool
TransactionInMempool -> Value
TransactionInMempool -> Encoding
(TransactionInMempool -> Value)
-> (TransactionInMempool -> Encoding)
-> ([TransactionInMempool] -> Value)
-> ([TransactionInMempool] -> Encoding)
-> (TransactionInMempool -> Bool)
-> ToJSON TransactionInMempool
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: TransactionInMempool -> Value
toJSON :: TransactionInMempool -> Value
$ctoEncoding :: TransactionInMempool -> Encoding
toEncoding :: TransactionInMempool -> Encoding
$ctoJSONList :: [TransactionInMempool] -> Value
toJSONList :: [TransactionInMempool] -> Value
$ctoEncodingList :: [TransactionInMempool] -> Encoding
toEncodingList :: [TransactionInMempool] -> Encoding
$comitField :: TransactionInMempool -> Bool
omitField :: TransactionInMempool -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_transaction", CamelToSnake]] TransactionInMempool

data MempoolUTxOInput = MempoolUTxOInput
   { MempoolUTxOInput -> Text
_address :: Text -- ^ Address
   , MempoolUTxOInput -> Text
_txHash :: Text -- ^ Transaction hash
   , MempoolUTxOInput -> Integer
_outputIndex :: Integer -- ^ Output index
   , MempoolUTxOInput -> Bool
_collateral :: Bool -- ^ True if the input is a collateral input
   , MempoolUTxOInput -> Bool
_reference :: Bool -- ^ Is the input a reference input
   }
   deriving stock (Int -> MempoolUTxOInput -> ShowS
[MempoolUTxOInput] -> ShowS
MempoolUTxOInput -> String
(Int -> MempoolUTxOInput -> ShowS)
-> (MempoolUTxOInput -> String)
-> ([MempoolUTxOInput] -> ShowS)
-> Show MempoolUTxOInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MempoolUTxOInput -> ShowS
showsPrec :: Int -> MempoolUTxOInput -> ShowS
$cshow :: MempoolUTxOInput -> String
show :: MempoolUTxOInput -> String
$cshowList :: [MempoolUTxOInput] -> ShowS
showList :: [MempoolUTxOInput] -> ShowS
Show, MempoolUTxOInput -> MempoolUTxOInput -> Bool
(MempoolUTxOInput -> MempoolUTxOInput -> Bool)
-> (MempoolUTxOInput -> MempoolUTxOInput -> Bool)
-> Eq MempoolUTxOInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MempoolUTxOInput -> MempoolUTxOInput -> Bool
== :: MempoolUTxOInput -> MempoolUTxOInput -> Bool
$c/= :: MempoolUTxOInput -> MempoolUTxOInput -> Bool
/= :: MempoolUTxOInput -> MempoolUTxOInput -> Bool
Eq, (forall x. MempoolUTxOInput -> Rep MempoolUTxOInput x)
-> (forall x. Rep MempoolUTxOInput x -> MempoolUTxOInput)
-> Generic MempoolUTxOInput
forall x. Rep MempoolUTxOInput x -> MempoolUTxOInput
forall x. MempoolUTxOInput -> Rep MempoolUTxOInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MempoolUTxOInput -> Rep MempoolUTxOInput x
from :: forall x. MempoolUTxOInput -> Rep MempoolUTxOInput x
$cto :: forall x. Rep MempoolUTxOInput x -> MempoolUTxOInput
to :: forall x. Rep MempoolUTxOInput x -> MempoolUTxOInput
Generic)
   deriving (Maybe MempoolUTxOInput
Value -> Parser [MempoolUTxOInput]
Value -> Parser MempoolUTxOInput
(Value -> Parser MempoolUTxOInput)
-> (Value -> Parser [MempoolUTxOInput])
-> Maybe MempoolUTxOInput
-> FromJSON MempoolUTxOInput
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser MempoolUTxOInput
parseJSON :: Value -> Parser MempoolUTxOInput
$cparseJSONList :: Value -> Parser [MempoolUTxOInput]
parseJSONList :: Value -> Parser [MempoolUTxOInput]
$comittedField :: Maybe MempoolUTxOInput
omittedField :: Maybe MempoolUTxOInput
FromJSON, [MempoolUTxOInput] -> Value
[MempoolUTxOInput] -> Encoding
MempoolUTxOInput -> Bool
MempoolUTxOInput -> Value
MempoolUTxOInput -> Encoding
(MempoolUTxOInput -> Value)
-> (MempoolUTxOInput -> Encoding)
-> ([MempoolUTxOInput] -> Value)
-> ([MempoolUTxOInput] -> Encoding)
-> (MempoolUTxOInput -> Bool)
-> ToJSON MempoolUTxOInput
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: MempoolUTxOInput -> Value
toJSON :: MempoolUTxOInput -> Value
$ctoEncoding :: MempoolUTxOInput -> Encoding
toEncoding :: MempoolUTxOInput -> Encoding
$ctoJSONList :: [MempoolUTxOInput] -> Value
toJSONList :: [MempoolUTxOInput] -> Value
$ctoEncodingList :: [MempoolUTxOInput] -> Encoding
toEncodingList :: [MempoolUTxOInput] -> Encoding
$comitField :: MempoolUTxOInput -> Bool
omitField :: MempoolUTxOInput -> Bool
ToJSON)
   via CustomJSON '[FieldLabelModifier '[StripPrefix "_", CamelToSnake]] MempoolUTxOInput

data MempoolRedeemer = MempoolRedeemer
  { MempoolRedeemer -> Integer
_tx_index :: Integer -- ^ Transaction index
  , MempoolRedeemer -> Text
_purpose :: Text -- ^ Purpose of the redeemer
  , MempoolRedeemer -> Text
_unit_mem :: Text -- ^ Memory unit
  , MempoolRedeemer -> Text
_unit_steps :: Text -- ^ Steps unit
  }
  deriving stock (Int -> MempoolRedeemer -> ShowS
[MempoolRedeemer] -> ShowS
MempoolRedeemer -> String
(Int -> MempoolRedeemer -> ShowS)
-> (MempoolRedeemer -> String)
-> ([MempoolRedeemer] -> ShowS)
-> Show MempoolRedeemer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MempoolRedeemer -> ShowS
showsPrec :: Int -> MempoolRedeemer -> ShowS
$cshow :: MempoolRedeemer -> String
show :: MempoolRedeemer -> String
$cshowList :: [MempoolRedeemer] -> ShowS
showList :: [MempoolRedeemer] -> ShowS
Show, MempoolRedeemer -> MempoolRedeemer -> Bool
(MempoolRedeemer -> MempoolRedeemer -> Bool)
-> (MempoolRedeemer -> MempoolRedeemer -> Bool)
-> Eq MempoolRedeemer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MempoolRedeemer -> MempoolRedeemer -> Bool
== :: MempoolRedeemer -> MempoolRedeemer -> Bool
$c/= :: MempoolRedeemer -> MempoolRedeemer -> Bool
/= :: MempoolRedeemer -> MempoolRedeemer -> Bool
Eq, (forall x. MempoolRedeemer -> Rep MempoolRedeemer x)
-> (forall x. Rep MempoolRedeemer x -> MempoolRedeemer)
-> Generic MempoolRedeemer
forall x. Rep MempoolRedeemer x -> MempoolRedeemer
forall x. MempoolRedeemer -> Rep MempoolRedeemer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MempoolRedeemer -> Rep MempoolRedeemer x
from :: forall x. MempoolRedeemer -> Rep MempoolRedeemer x
$cto :: forall x. Rep MempoolRedeemer x -> MempoolRedeemer
to :: forall x. Rep MempoolRedeemer x -> MempoolRedeemer
Generic)
  deriving (Maybe MempoolRedeemer
Value -> Parser [MempoolRedeemer]
Value -> Parser MempoolRedeemer
(Value -> Parser MempoolRedeemer)
-> (Value -> Parser [MempoolRedeemer])
-> Maybe MempoolRedeemer
-> FromJSON MempoolRedeemer
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser MempoolRedeemer
parseJSON :: Value -> Parser MempoolRedeemer
$cparseJSONList :: Value -> Parser [MempoolRedeemer]
parseJSONList :: Value -> Parser [MempoolRedeemer]
$comittedField :: Maybe MempoolRedeemer
omittedField :: Maybe MempoolRedeemer
FromJSON, [MempoolRedeemer] -> Value
[MempoolRedeemer] -> Encoding
MempoolRedeemer -> Bool
MempoolRedeemer -> Value
MempoolRedeemer -> Encoding
(MempoolRedeemer -> Value)
-> (MempoolRedeemer -> Encoding)
-> ([MempoolRedeemer] -> Value)
-> ([MempoolRedeemer] -> Encoding)
-> (MempoolRedeemer -> Bool)
-> ToJSON MempoolRedeemer
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: MempoolRedeemer -> Value
toJSON :: MempoolRedeemer -> Value
$ctoEncoding :: MempoolRedeemer -> Encoding
toEncoding :: MempoolRedeemer -> Encoding
$ctoJSONList :: [MempoolRedeemer] -> Value
toJSONList :: [MempoolRedeemer] -> Value
$ctoEncodingList :: [MempoolRedeemer] -> Encoding
toEncodingList :: [MempoolRedeemer] -> Encoding
$comitField :: MempoolRedeemer -> Bool
omitField :: MempoolRedeemer -> Bool
ToJSON)
  via CustomJSON '[FieldLabelModifier '[StripPrefix "_", CamelToSnake]] MempoolRedeemer