@@ -13,40 +13,53 @@ use sidechain_domain::*;
1313use crate :: DataSourceError ;
1414
1515/// Mainchain block id, either a block hash or a block number
16- pub enum McBlockId {
17- /// Domain type Mainchain block hash
18- McBlockHash ( McBlockHash ) ,
19- /// Domain type Mainchain block number
20- McBlockNumber ( McBlockNumber ) ,
21- /// Mainchain block hash returned as string by Blockfrost API
22- Raw ( String ) ,
23- }
16+ pub struct McBlockId ( String ) ;
2417
2518impl From < McBlockHash > for McBlockId {
2619 fn from ( value : McBlockHash ) -> Self {
27- McBlockId :: McBlockHash ( value)
20+ McBlockId ( value. to_string ( ) )
2821 }
2922}
3023
3124impl From < McBlockNumber > for McBlockId {
3225 fn from ( value : McBlockNumber ) -> Self {
33- McBlockId :: McBlockNumber ( value)
26+ McBlockId ( value. to_string ( ) )
3427 }
3528}
3629
3730impl From < String > for McBlockId {
3831 fn from ( value : String ) -> Self {
39- McBlockId :: Raw ( value)
32+ McBlockId ( value)
4033 }
4134}
4235
4336impl std:: fmt:: Display for McBlockId {
4437 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
45- match self {
46- McBlockId :: McBlockHash ( mc_block_hash) => mc_block_hash. fmt ( f) ,
47- McBlockId :: McBlockNumber ( mc_block_number) => mc_block_number. fmt ( f) ,
48- McBlockId :: Raw ( str) => str. fmt ( f) ,
49- }
38+ self . 0 . fmt ( f)
39+ }
40+ }
41+
42+ /// Mainchain pool id as a bech32 string
43+ pub struct McPoolId ( String ) ;
44+
45+ impl From < MainchainKeyHash > for McPoolId {
46+ fn from ( value : MainchainKeyHash ) -> Self {
47+ let pool_id =
48+ bech32:: encode :: < bech32:: Bech32 > ( bech32:: Hrp :: parse_unchecked ( "pool" ) , & value. 0 )
49+ . expect ( "MainchainKeyHash is valid" ) ;
50+ McPoolId ( pool_id)
51+ }
52+ }
53+
54+ impl From < String > for McPoolId {
55+ fn from ( value : String ) -> Self {
56+ McPoolId ( value)
57+ }
58+ }
59+
60+ impl std:: fmt:: Display for McPoolId {
61+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
62+ self . 0 . fmt ( f)
5063 }
5164}
5265
@@ -64,12 +77,12 @@ pub trait MiniBFApi {
6477 address : MainchainAddress ,
6578 ) -> Result < Vec < AddressTransactionsContentInner > , DataSourceError > ;
6679
67- /// List of a specific asset transactions.
80+ /// List of specific asset transactions.
6881 async fn assets_transactions (
6982 & self ,
7083 asset_id : AssetId ,
7184 ) -> Result < Vec < AssetTransactionsInner > , DataSourceError > ;
72- /// List of a addresses containing a specific asset.
85+ /// List of addresses containing a specific asset.
7386 async fn assets_addresses (
7487 & self ,
7588 asset_id : AssetId ,
@@ -110,11 +123,14 @@ pub trait MiniBFApi {
110123 async fn epochs_stakes_by_pool (
111124 & self ,
112125 epoch_number : McEpochNumber ,
113- pool_id : & str ,
126+ pool_id : impl Into < McPoolId > + Send ,
114127 ) -> Result < Vec < EpochStakePoolContentInner > , DataSourceError > ;
115128
116129 /// History of stake pool parameters over epochs.
117- async fn pools_history ( & self , pool_id : & str ) -> Result < Vec < PoolHistoryInner > , DataSourceError > ;
130+ async fn pools_history (
131+ & self ,
132+ pool_id : impl Into < McPoolId > + Send ,
133+ ) -> Result < Vec < PoolHistoryInner > , DataSourceError > ;
118134 /// List of registered stake pools with additional information.
119135 async fn pools_extended ( & self ) -> Result < Vec < PoolListExtendedInner > , DataSourceError > ;
120136
0 commit comments