Skip to content

Commit

Permalink
Use Blockfrost.Types.Shared.Amount for MempoolTransaction outputAmoun…
Browse files Browse the repository at this point in the history
…t, fix build and whitespace errors
  • Loading branch information
sorki committed Sep 19, 2024
1 parent a73ea5e commit 52db099
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
43 changes: 16 additions & 27 deletions blockfrost-api/src/Blockfrost/Types/Cardano/Mempool.hs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
-- | Transaction metadata

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

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

data MempoolTransaction = MempoolTransaction
data MempoolTransaction = MempoolTransaction
{ _tx :: TransactionInMempool
, _inputs :: [MempoolUTxOInput]
, _outputs :: [UtxoOutput]
Expand All @@ -25,8 +25,8 @@ data MempoolTransaction = MempoolTransaction

data TransactionInMempool = TransactionInMempool
{ _transactionHash :: Text -- ^ Transaction hash
, _transactionOutputAmount :: [MempoolTxAmount] -- ^ Transaction outputs
, _transactionFees :: Lovelaces -- ^ Transacction fee
, _transactionOutputAmount :: [Amount] -- ^ Transaction outputs
, _transactionFees :: Lovelaces -- ^ Transaction fee
, _transactionDeposit :: Lovelaces -- ^ Deposit within the transaction in Lovelaces
, _transactionSize :: Integer -- ^ Size of the transaction in Bytes
, _transactionInvalidBefore :: Maybe Text -- ^ Left (included) endpoint of the timelock validity intervals
Expand All @@ -46,34 +46,23 @@ data TransactionInMempool = TransactionInMempool
deriving (FromJSON, ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_transaction", CamelToSnake]] TransactionInMempool

data MempoolTxAmount
= MempoolTxAmount
{ _amountUnit :: Text -- ^ Quantity in Lovelaces
, _amountQuantity :: Text -- ^ Quantity in the unit
}
deriving stock (Show, Eq, Generic)
deriving (FromJSON, ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_amount", CamelToSnake]] MempoolTxAmount

data MempoolUTxOInput
= MempoolUTxOInput
data MempoolUTxOInput = MempoolUTxOInput
{ _address :: Text -- ^ Address
, _txHash :: Text -- ^ Transaction hash
, _outputIndex :: Integer -- ^ Output index
, _collateral :: Bool -- ^ True if the input is a collateral input
, _reference :: Bool -- ^ Is the input a reference input
}
deriving stock (Show, Eq, Generic)
deriving (FromJSON, ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_", CamelToSnake]] MempoolUTxOInput
}
deriving stock (Show, Eq, Generic)
deriving (FromJSON, ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_", CamelToSnake]] MempoolUTxOInput

data MempoolRedeemer
= MempoolRedeemer
data MempoolRedeemer = MempoolRedeemer
{ _tx_index :: Integer -- ^ Transaction index
, _purpose :: Text -- ^ Purpose of the redeemer
, _unit_mem :: Text -- ^ Memory unit
, _unit_steps :: Text -- ^ Steps unit
}
deriving stock (Show, Eq, Generic)
deriving (FromJSON, ToJSON)
via CustomJSON '[FieldLabelModifier '[StripPrefix "_", CamelToSnake]] MempoolRedeemer
via CustomJSON '[FieldLabelModifier '[StripPrefix "_", CamelToSnake]] MempoolRedeemer
1 change: 1 addition & 0 deletions blockfrost-api/test/Cardano/Transactions.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
Expand Down
4 changes: 2 additions & 2 deletions blockfrost-client/src/Blockfrost/Client/NutLink.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module Blockfrost.Client.NutLink
, nutlinkTickers'
) where

import Blockfrost.API
import Blockfrost.Client.Types
import Blockfrost.API
import Blockfrost.Client.Types
import Blockfrost.Types hiding (MempoolUTxOInput(..))
import Data.Text (Text)

Expand Down

0 comments on commit 52db099

Please sign in to comment.