|
1 | 1 | use async_trait::async_trait; |
2 | 2 | use blockfrost_openapi::models::{ |
3 | | - address_transactions_content_inner::AddressTransactionsContentInner, address_utxo_content_inner::AddressUtxoContentInner, asset_addresses_inner::AssetAddressesInner, asset_transactions_inner::AssetTransactionsInner, block_content::BlockContent, epoch_param_content::EpochParamContent, epoch_stake_pool_content_inner::EpochStakePoolContentInner, genesis_content::GenesisContent, pool_history_inner::PoolHistoryInner, pool_list_extended_inner::PoolListExtendedInner, tx_content::TxContent, tx_content_utxo::TxContentUtxo |
| 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, genesis_content::GenesisContent, |
| 8 | + pool_history_inner::PoolHistoryInner, pool_list_extended_inner::PoolListExtendedInner, |
| 9 | + tx_content::TxContent, tx_content_utxo::TxContentUtxo, |
4 | 10 | }; |
5 | 11 | use sidechain_domain::*; |
6 | 12 |
|
| 13 | +use crate::DataSourceError; |
| 14 | + |
7 | 15 | /// Mainchain block id, either a block hash or a block number |
8 | 16 | pub enum McBlockId { |
9 | 17 | /// Domain type Mainchain block hash |
@@ -49,63 +57,79 @@ pub trait MiniBFApi { |
49 | 57 | async fn addresses_utxos( |
50 | 58 | &self, |
51 | 59 | address: MainchainAddress, |
52 | | - ) -> Result<Vec<AddressUtxoContentInner>, String>; |
| 60 | + ) -> Result<Vec<AddressUtxoContentInner>, DataSourceError>; |
53 | 61 | /// Transactions on the address. |
54 | 62 | async fn addresses_transactions( |
55 | 63 | &self, |
56 | 64 | address: MainchainAddress, |
57 | | - ) -> Result<Vec<AddressTransactionsContentInner>, String>; |
| 65 | + ) -> Result<Vec<AddressTransactionsContentInner>, DataSourceError>; |
58 | 66 |
|
59 | 67 | /// List of a specific asset transactions. |
60 | 68 | async fn assets_transactions( |
61 | 69 | &self, |
62 | 70 | asset_id: AssetId, |
63 | | - ) -> Result<Vec<AssetTransactionsInner>, String>; |
| 71 | + ) -> Result<Vec<AssetTransactionsInner>, DataSourceError>; |
64 | 72 | /// List of a addresses containing a specific asset. |
65 | | - async fn assets_addresses(&self, asset_id: AssetId) |
66 | | - -> Result<Vec<AssetAddressesInner>, String>; |
| 73 | + async fn assets_addresses( |
| 74 | + &self, |
| 75 | + asset_id: AssetId, |
| 76 | + ) -> Result<Vec<AssetAddressesInner>, DataSourceError>; |
67 | 77 |
|
68 | 78 | /// Return the latest block available to the backends, also known as the tip of the blockchain. |
69 | | - async fn blocks_latest(&self) -> Result<BlockContent, String>; |
| 79 | + async fn blocks_latest(&self) -> Result<BlockContent, DataSourceError>; |
70 | 80 | /// Return the content of a requested block. |
71 | | - async fn blocks_by_id(&self, id: impl Into<McBlockId> + Send) -> Result<BlockContent, String>; |
| 81 | + async fn blocks_by_id( |
| 82 | + &self, |
| 83 | + id: impl Into<McBlockId> + Send, |
| 84 | + ) -> Result<BlockContent, DataSourceError>; |
72 | 85 | /// Return the content of a requested block for a specific slot. |
73 | | - async fn blocks_slot(&self, slot_number: McSlotNumber) -> Result<BlockContent, String>; |
| 86 | + async fn blocks_slot(&self, slot_number: McSlotNumber) |
| 87 | + -> Result<BlockContent, DataSourceError>; |
74 | 88 | /// Return the list of blocks following a specific block. |
75 | 89 | async fn blocks_next( |
76 | 90 | &self, |
77 | 91 | hash: impl Into<McBlockId> + Send, |
78 | | - ) -> Result<Vec<BlockContent>, String>; |
| 92 | + ) -> Result<Vec<BlockContent>, DataSourceError>; |
79 | 93 | /// Return the transactions within the block. |
80 | | - async fn blocks_txs(&self, id: impl Into<McBlockId> + Send) -> Result<Vec<String>, String>; |
| 94 | + async fn blocks_txs( |
| 95 | + &self, |
| 96 | + id: impl Into<McBlockId> + Send, |
| 97 | + ) -> Result<Vec<String>, DataSourceError>; |
81 | 98 |
|
82 | 99 | /// Return the blocks minted for the epoch specified. |
83 | | - async fn epochs_blocks(&self, epoch_number: McEpochNumber) -> Result<Vec<String>, String>; |
| 100 | + async fn epochs_blocks( |
| 101 | + &self, |
| 102 | + epoch_number: McEpochNumber, |
| 103 | + ) -> Result<Vec<String>, DataSourceError>; |
84 | 104 | /// Return the protocol parameters for the epoch specified. |
85 | 105 | async fn epochs_parameters( |
86 | 106 | &self, |
87 | 107 | epoch_number: McEpochNumber, |
88 | | - ) -> Result<EpochParamContent, String>; |
| 108 | + ) -> Result<EpochParamContent, DataSourceError>; |
89 | 109 | /// Return the active stake distribution for the epoch specified by stake pool. |
90 | 110 | async fn epochs_stakes_by_pool( |
91 | 111 | &self, |
92 | 112 | epoch_number: McEpochNumber, |
93 | 113 | pool_id: &str, |
94 | | - ) -> Result<Vec<EpochStakePoolContentInner>, String>; |
| 114 | + ) -> Result<Vec<EpochStakePoolContentInner>, DataSourceError>; |
95 | 115 |
|
96 | 116 | /// History of stake pool parameters over epochs. |
97 | | - async fn pools_history(&self, pool_id: &str) -> Result<Vec<PoolHistoryInner>, String>; |
| 117 | + async fn pools_history(&self, pool_id: &str) -> Result<Vec<PoolHistoryInner>, DataSourceError>; |
98 | 118 | /// List of registered stake pools with additional information. |
99 | | - async fn pools_extended(&self) -> Result<Vec<PoolListExtendedInner>, String>; |
| 119 | + async fn pools_extended(&self) -> Result<Vec<PoolListExtendedInner>, DataSourceError>; |
100 | 120 |
|
101 | 121 | /// Query JSON value of a datum by its hash. |
102 | | - async fn scripts_datum_hash(&self, datum_hash: &str) -> Result<Vec<serde_json::Value>, String>; |
| 122 | + async fn scripts_datum_hash( |
| 123 | + &self, |
| 124 | + datum_hash: &str, |
| 125 | + ) -> Result<Vec<serde_json::Value>, DataSourceError>; |
103 | 126 |
|
104 | 127 | /// Return content of the requested transaction. |
105 | | - async fn transaction_by_hash(&self, tx_hash: McTxHash) -> Result<TxContent, String>; |
| 128 | + async fn transaction_by_hash(&self, tx_hash: McTxHash) -> Result<TxContent, DataSourceError>; |
106 | 129 | /// Return the inputs and UTXOs of the specific transaction. |
107 | | - async fn transactions_utxos(&self, tx_hash: McTxHash) -> Result<TxContentUtxo, String>; |
| 130 | + async fn transactions_utxos(&self, tx_hash: McTxHash) |
| 131 | + -> Result<TxContentUtxo, DataSourceError>; |
108 | 132 |
|
109 | 133 | /// Return the information about blockchain genesis. |
110 | | - async fn genesis(&self) -> Result<GenesisContent, String>; |
| 134 | + async fn genesis(&self) -> Result<GenesisContent, DataSourceError>; |
111 | 135 | } |
0 commit comments