Skip to content

Commit c9a1e5b

Browse files
authored
Merge pull request #1882 from input-output-hk/dlachaume/1842/implement-cardano-stake-distribution-in-client
Implement Cardano stake distribution in `mithril-client` library
2 parents 62f71c6 + b333696 commit c9a1e5b

File tree

11 files changed

+483
-15
lines changed

11 files changed

+483
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ As a minor extension, we have adopted a slightly different versioning convention
1515

1616
- Implement the signable and artifact builders for the signed entity type `CardanoStakeDistribution`.
1717
- Implement the HTTP routes related to the signed entity type `CardanoStakeDistribution` on the aggregator REST API.
18+
- Added support in the `mithril-client` library for retrieving `CardanoStakeDistribution` by epoch or by hash, and for listing all available `CardanoStakeDistribution`.
1819

1920
- Crates versions:
2021

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-client"
3-
version = "0.8.11"
3+
version = "0.8.12"
44
description = "Mithril client library"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-client/src/aggregator_client.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use tokio::sync::RwLock;
2222
use mithril_common::entities::{ClientError, ServerError};
2323
use mithril_common::MITHRIL_API_VERSION_HEADER;
2424

25+
use crate::common::Epoch;
2526
use crate::{MithrilError, MithrilResult};
2627

2728
/// Error tied with the Aggregator client
@@ -92,6 +93,24 @@ pub enum AggregatorRequest {
9293
/// Lists the aggregator [Cardano transaction snapshot][crate::CardanoTransactionSnapshot]
9394
#[cfg(feature = "unstable")]
9495
ListCardanoTransactionSnapshots,
96+
97+
/// Get a specific [Cardano stake distribution][crate::CardanoStakeDistribution] from the aggregator by hash
98+
#[cfg(feature = "unstable")]
99+
GetCardanoStakeDistribution {
100+
/// Hash of the Cardano stake distribution to retrieve
101+
hash: String,
102+
},
103+
104+
/// Get a specific [Cardano stake distribution][crate::CardanoStakeDistribution] from the aggregator by epoch
105+
#[cfg(feature = "unstable")]
106+
GetCardanoStakeDistributionByEpoch {
107+
/// Epoch at the end of which the Cardano stake distribution is computed by the Cardano node
108+
epoch: Epoch,
109+
},
110+
111+
/// Lists the aggregator [Cardano stake distribution][crate::CardanoStakeDistribution]
112+
#[cfg(feature = "unstable")]
113+
ListCardanoStakeDistributions,
95114
}
96115

97116
impl AggregatorRequest {
@@ -130,6 +149,18 @@ impl AggregatorRequest {
130149
AggregatorRequest::ListCardanoTransactionSnapshots => {
131150
"artifact/cardano-transactions".to_string()
132151
}
152+
#[cfg(feature = "unstable")]
153+
AggregatorRequest::GetCardanoStakeDistribution { hash } => {
154+
format!("artifact/cardano-stake-distribution/{hash}")
155+
}
156+
#[cfg(feature = "unstable")]
157+
AggregatorRequest::GetCardanoStakeDistributionByEpoch { epoch } => {
158+
format!("artifact/cardano-stake-distribution/epoch/{epoch}")
159+
}
160+
#[cfg(feature = "unstable")]
161+
AggregatorRequest::ListCardanoStakeDistributions => {
162+
"artifact/cardano-stake-distributions".to_string()
163+
}
133164
}
134165
}
135166

@@ -542,6 +573,24 @@ mod tests {
542573
"artifact/cardano-transactions".to_string(),
543574
AggregatorRequest::ListCardanoTransactionSnapshots.route()
544575
);
576+
577+
assert_eq!(
578+
"artifact/cardano-stake-distribution/abc".to_string(),
579+
AggregatorRequest::GetCardanoStakeDistribution {
580+
hash: "abc".to_string()
581+
}
582+
.route()
583+
);
584+
585+
assert_eq!(
586+
"artifact/cardano-stake-distribution/epoch/123".to_string(),
587+
AggregatorRequest::GetCardanoStakeDistributionByEpoch { epoch: Epoch(123) }.route()
588+
);
589+
590+
assert_eq!(
591+
"artifact/cardano-stake-distributions".to_string(),
592+
AggregatorRequest::ListCardanoStakeDistributions.route()
593+
);
545594
}
546595
}
547596

0 commit comments

Comments
 (0)