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
Gianmarco Fraccaroli committed Feb 20, 2024
2 parents b448114 + 872e34f commit c862c6c
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 {})",

Check warning on line 1849 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L1849

Added line #L1849 was not covered by tests
bond.start,
bond.amount.to_string_native()
bond.amount.to_string_native(),
bond.slashed_amount.unwrap_or_default().to_string_native()

Check warning on line 1852 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L1851-L1852

Added lines #L1851 - L1852 were not covered by tests
)?;
}
if !details.bonds_total.is_zero() {
display_line!(
context.io(),
&mut w;
"Active (slashed) bonds total: {}",
"Active (slashable) bonds total: {}",

Check warning on line 1859 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L1859

Added line #L1859 was not covered by tests
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 {})",

Check warning on line 1877 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L1877

Added line #L1877 was not covered by tests
unbond.withdraw,
unbond.start,
unbond.amount.to_string_native()
unbond.amount.to_string_native(),
unbond.slashed_amount.unwrap_or_default().to_string_native()

Check warning on line 1881 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L1880-L1881

Added lines #L1880 - L1881 were not covered by tests
)?;
}
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()
)?;

Check warning on line 1918 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L1913-L1918

Added lines #L1913 - L1918 were not covered by tests

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()
)?;

Check warning on line 1947 in crates/apps/src/lib/client/rpc.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/client/rpc.rs#L1942-L1947

Added lines #L1942 - L1947 were not covered by tests
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 @@ -1512,9 +1512,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 c862c6c

Please sign in to comment.