-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from Jimbo4350/jordan/add-mempool-endpoint
Add mempool endpoint
- Loading branch information
Showing
15 changed files
with
223 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- | Cardano Mempool endpoints | ||
|
||
{-# OPTIONS_HADDOCK hide #-} | ||
|
||
module Blockfrost.API.Cardano.Mempool | ||
where | ||
|
||
import Servant.API | ||
import Servant.API.Generic | ||
|
||
import Blockfrost.Types | ||
import Blockfrost.Util.Pagination | ||
import Blockfrost.Util.Sorting | ||
|
||
data MempoolAPI route = | ||
MempoolAPI | ||
{ | ||
_mempoolTransactions | ||
:: route | ||
:- Summary "Transactions in Mempool." | ||
:> Description "Tx hash list of all transactions that are currently stored in the mempool." | ||
:> Pagination | ||
:> Sorting | ||
:> Get '[JSON] [TxHashObject] | ||
, _specificTransaction | ||
:: route | ||
:- Summary "Transaction in mempoool." | ||
:> Description "Content of a specific transaction in the mempool." | ||
:> Capture "hash" TxHash | ||
:> Get '[JSON] MempoolTransaction | ||
, _specificAddress | ||
:: route | ||
:- Summary "Transactions involving an address in mempool." | ||
:> Description "List of transactions in the mempool that involves a specific address." | ||
:> "addresses" | ||
:> Capture "address" Address | ||
:> Pagination | ||
:> Sorting | ||
:> Get '[JSON] [TxHashObject] | ||
} deriving (Generic) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
-- | 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 | ||
{ _tx :: TransactionInMempool | ||
, _inputs :: [MempoolUTxOInput] | ||
, _outputs :: [UtxoOutput] | ||
, _redeemers :: Maybe [MempoolRedeemer] | ||
} | ||
deriving stock (Show, Eq, Generic) | ||
deriving (FromJSON, ToJSON) | ||
via CustomJSON '[FieldLabelModifier '[StripPrefix "_", CamelToSnake]] MempoolTransaction | ||
|
||
data TransactionInMempool = TransactionInMempool | ||
{ _transactionHash :: Text -- ^ Transaction hash | ||
, _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 | ||
, _transactionInvalidHereafter :: Maybe Text -- ^ Right (excluded) endpoint of the timelock validity intervals | ||
, _transactionUtxoCount :: Integer -- ^ Count of UTXOs within the transaction | ||
, _transactionWithdrawalCount :: Integer -- ^ Count of the withdrawals within the transaction | ||
, _transactionMirCertCount :: Integer -- ^ Count of the MIR certificates within the transaction | ||
, _transactionDelegationCount :: Integer -- ^ Count of the delegations within the transaction | ||
, _transactionStakeCertCount :: Integer -- ^ Count of the stake keys (de)registration and delegation certificates within the transaction | ||
, _transactionPoolUpdateCount :: Integer -- ^ Count of the stake pool registration and update certificates within the transaction | ||
, _transactionPoolRetireCount :: Integer -- ^ Count of the stake pool retirement certificates within the transaction | ||
, _transactionAssetMintOrBurnCount :: Integer -- ^ Count of asset mints and burns within the transaction | ||
, _transactionRedeemerCount :: Integer -- ^ Count of redeemers within the transaction | ||
, _transactionValidContract :: Bool -- ^ True if this is a valid transaction, False in case of contract validation failure | ||
} | ||
deriving stock (Show, Eq, Generic) | ||
deriving (FromJSON, ToJSON) | ||
via CustomJSON '[FieldLabelModifier '[StripPrefix "_transaction", CamelToSnake]] TransactionInMempool | ||
|
||
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 | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
blockfrost-client/src/Blockfrost/Client/Cardano/Mempool.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- | Mempool queries | ||
|
||
module Blockfrost.Client.Cardano.Mempool | ||
( getMempoolTransactions | ||
, getMempoolTransaction | ||
, getMempoolTransactionsByAddress | ||
) where | ||
|
||
import Blockfrost.API | ||
import Blockfrost.Client.Types | ||
import Blockfrost.Types | ||
|
||
mempoolClient :: MonadBlockfrost m => Project -> MempoolAPI (AsClientT m) | ||
mempoolClient = fromServant . _mempool . cardanoClient | ||
|
||
getMempoolTransactions :: MonadBlockfrost m => Project -> Paged -> SortOrder -> m [TxHashObject] | ||
getMempoolTransactions = _mempoolTransactions . mempoolClient | ||
|
||
getMempoolTransaction :: MonadBlockfrost m => Project -> TxHash -> m MempoolTransaction | ||
getMempoolTransaction = _specificTransaction . mempoolClient | ||
|
||
getMempoolTransactionsByAddress :: MonadBlockfrost m => Project -> Address -> Paged -> SortOrder -> m [TxHashObject] | ||
getMempoolTransactionsByAddress = _specificAddress . mempoolClient | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters