Skip to content

Commit

Permalink
Merge branch 'Krewedk0/main' (#2670)
Browse files Browse the repository at this point in the history
* Krewedk0/main:
  fix ledger test
  fix formatting
  review fix, add changelog
  add slashed bonds/unbonds info to the client
  • Loading branch information
tzemanovic committed Feb 27, 2024
2 parents 53affea + b683589 commit 3925750
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add slashed bonds/unbonds info to the client.
([\#2670](https://github.com/anoma/namada/pull/2670))
24 changes: 19 additions & 5 deletions crates/apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1846,16 +1846,17 @@ pub async fn query_bonds(
display_line!(
context.io(),
&mut w;
" Remaining active bond from epoch {}: Δ {}",
" Remaining active bond from epoch {}: Δ {} (slashed {})",
bond.start,
bond.amount.to_string_native()
bond.amount.to_string_native(),
bond.slashed_amount.unwrap_or_default().to_string_native()
)?;
}
if !details.bonds_total.is_zero() {
display_line!(
context.io(),
&mut w;
"Active (slashed) bonds total: {}",
"Active (slashable) bonds total: {}",
details.bonds_total_active().to_string_native()
)?;
}
Expand All @@ -1873,10 +1874,11 @@ pub async fn query_bonds(
display_line!(
context.io(),
&mut w;
" Withdrawable from epoch {} (active from {}): Δ {}",
" Withdrawable from epoch {} (active from {}): Δ {} (slashed {})",
unbond.withdraw,
unbond.start,
unbond.amount.to_string_native()
unbond.amount.to_string_native(),
unbond.slashed_amount.unwrap_or_default().to_string_native()
)?;
}
display_line!(
Expand Down Expand Up @@ -1908,6 +1910,12 @@ pub async fn query_bonds(
"All bonds total: {}",
bonds_and_unbonds.bonds_total.to_string_native()
)?;
display_line!(
context.io(),
&mut w;
"All bonds total slashed: {}",
bonds_and_unbonds.bonds_total_slashed.to_string_native()
)?;

if bonds_and_unbonds.unbonds_total
!= bonds_and_unbonds.unbonds_total_slashed
Expand All @@ -1931,6 +1939,12 @@ pub async fn query_bonds(
"All unbonds total withdrawable: {}",
bonds_and_unbonds.total_withdrawable.to_string_native()
)?;
display_line!(
context.io(),
&mut w;
"All unbonds total slashed: {}",
bonds_and_unbonds.unbonds_total_slashed.to_string_native()
)?;
Ok(())
}

Expand Down
4 changes: 3 additions & 1 deletion crates/tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1510,9 +1510,11 @@ fn test_bond_queries() -> Result<()> {
client.exp_string(
"All bonds total active: 100188.000000\r
All bonds total: 100188.000000\r
All bonds total slashed: 0.000000\r
All unbonds total active: 412.000000\r
All unbonds total: 412.000000\r
All unbonds total withdrawable: 412.000000\r",
All unbonds total withdrawable: 412.000000\r
All unbonds total slashed: 0.000000\r",
)?;
client.assert_success();

Expand Down

0 comments on commit 3925750

Please sign in to comment.