move to impl display

This commit is contained in:
Sergio Chouhy 2026-03-26 15:21:29 -03:00
parent acf609ecc8
commit 57b83f4e1a
2 changed files with 12 additions and 7 deletions

View File

@ -183,12 +183,6 @@ pub fn TransactionPage() -> impl IntoView {
signatures_and_public_keys: _,
proof,
} = witness_set;
let validity_window_formatted = match validity_window.0 {
(Some(start), Some(end)) => format!("Blocks {start} (included) {end} (excluded)"),
(Some(start), None) => format!("Block {start} onwards"),
(None, Some(end)) => format!("Before block {end}"),
(None, None) => "Unbounded".to_owned(),
};
let proof_len = proof.map_or(0, |p| p.0.len());
view! {
@ -221,7 +215,7 @@ pub fn TransactionPage() -> impl IntoView {
</div>
<div class="info-row">
<span class="info-label">"Validity Window:"</span>
<span class="info-value">{validity_window_formatted}</span>
<span class="info-value">{validity_window.to_string()}</span>
</div>
</div>

View File

@ -304,6 +304,17 @@ pub struct Nullifier(
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
pub struct ValidityWindow(pub (Option<BlockId>, Option<BlockId>));
impl Display for ValidityWindow {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.0 {
(Some(start), Some(end)) => write!(f, "[{start}, {end})"),
(Some(start), None) => write!(f, "[{start}, ∞)"),
(None, Some(end)) => write!(f, "(-∞, {end})"),
(None, None) => write!(f, "(-∞, ∞)"),
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
pub struct CommitmentSetDigest(
#[serde(with = "base64::arr")]