|
| 1 | +use async_trait::async_trait; |
| 2 | +use blockfrost_openapi::models::{ |
| 3 | + address_transactions_content_inner::AddressTransactionsContentInner, |
| 4 | + address_utxo_content_inner::AddressUtxoContentInner, |
| 5 | + asset_addresses_inner::AssetAddressesInner, asset_transactions_inner::AssetTransactionsInner, |
| 6 | + block_content::BlockContent, epoch_param_content::EpochParamContent, |
| 7 | + epoch_stake_pool_content_inner::EpochStakePoolContentInner, |
| 8 | + pool_history_inner::PoolHistoryInner, pool_list_extended_inner::PoolListExtendedInner, |
| 9 | + tx_content::TxContent, tx_content_utxo::TxContentUtxo, |
| 10 | +}; |
| 11 | +use sidechain_domain::*; |
| 12 | + |
| 13 | +pub enum McBlockId { |
| 14 | + McBlockHash(McBlockHash), |
| 15 | + McBlockNumber(McBlockNumber), |
| 16 | + Raw(String), // makes you think |
| 17 | +} |
| 18 | + |
| 19 | +impl From<McBlockHash> for McBlockId { |
| 20 | + fn from(value: McBlockHash) -> Self { |
| 21 | + McBlockId::McBlockHash(value) |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +impl From<McBlockNumber> for McBlockId { |
| 26 | + fn from(value: McBlockNumber) -> Self { |
| 27 | + McBlockId::McBlockNumber(value) |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +impl From<String> for McBlockId { |
| 32 | + fn from(value: String) -> Self { |
| 33 | + McBlockId::Raw(value) |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +impl std::fmt::Display for McBlockId { |
| 38 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 39 | + match self { |
| 40 | + McBlockId::McBlockHash(mc_block_hash) => mc_block_hash.fmt(f), |
| 41 | + McBlockId::McBlockNumber(mc_block_number) => mc_block_number.fmt(f), |
| 42 | + McBlockId::Raw(str) => str.fmt(f), |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +#[async_trait] |
| 48 | +pub trait MiniBFApi { |
| 49 | + async fn addresses_utxos( |
| 50 | + &self, |
| 51 | + address: MainchainAddress, |
| 52 | + ) -> Result<Vec<AddressUtxoContentInner>, String>; |
| 53 | + async fn addresses_transactions( |
| 54 | + &self, |
| 55 | + address: MainchainAddress, |
| 56 | + ) -> Result<Vec<AddressTransactionsContentInner>, String>; |
| 57 | + |
| 58 | + async fn assets_transactions( |
| 59 | + &self, |
| 60 | + asset_id: AssetId, |
| 61 | + ) -> Result<Vec<AssetTransactionsInner>, String>; |
| 62 | + async fn assets_addresses(&self, asset_id: AssetId) |
| 63 | + -> Result<Vec<AssetAddressesInner>, String>; |
| 64 | + |
| 65 | + async fn blocks_latest(&self) -> Result<BlockContent, String>; |
| 66 | + async fn blocks_by_id(&self, id: impl Into<McBlockId> + Send) -> Result<BlockContent, String>; |
| 67 | + async fn blocks_slot(&self, slot_number: McSlotNumber) -> Result<BlockContent, String>; |
| 68 | + async fn blocks_next( |
| 69 | + &self, |
| 70 | + hash: impl Into<McBlockId> + Send, |
| 71 | + ) -> Result<Vec<BlockContent>, String>; |
| 72 | + async fn blocks_txs(&self, id: impl Into<McBlockId> + Send) -> Result<Vec<String>, String>; |
| 73 | + |
| 74 | + async fn epochs_blocks(&self, epoch_number: McEpochNumber) -> Result<Vec<String>, String>; |
| 75 | + async fn epochs_parameters( |
| 76 | + &self, |
| 77 | + epoch_number: McEpochNumber, |
| 78 | + ) -> Result<EpochParamContent, String>; |
| 79 | + async fn epochs_stakes_by_pool( |
| 80 | + &self, |
| 81 | + epoch_number: McEpochNumber, |
| 82 | + pool_id: &str, |
| 83 | + ) -> Result<Vec<EpochStakePoolContentInner>, String>; |
| 84 | + |
| 85 | + async fn pools_history(&self, pool_id: &str) -> Result<Vec<PoolHistoryInner>, String>; |
| 86 | + async fn pools_extended(&self) -> Result<Vec<PoolListExtendedInner>, String>; |
| 87 | + |
| 88 | + async fn scripts_datum_hash(&self, datum_hash: &str) -> Result<Vec<serde_json::Value>, String>; |
| 89 | + |
| 90 | + async fn transaction_by_hash(&self, tx_hash: McTxHash) -> Result<TxContent, String>; |
| 91 | + async fn transactions_utxos(&self, tx_hash: McTxHash) -> Result<TxContentUtxo, String>; |
| 92 | +} |
0 commit comments