From 837679f566a3e3d7ef0a86d752ebae19fe0fb286 Mon Sep 17 00:00:00 2001 From: Herr Seppia Date: Tue, 12 Mar 2024 19:20:05 +0100 Subject: [PATCH] rusk: add rewards in provisioners http API --- rusk/src/lib/http/rusk.rs | 8 +++++--- rusk/tests/common/wallet.rs | 7 +++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/rusk/src/lib/http/rusk.rs b/rusk/src/lib/http/rusk.rs index fc3fd4cfd2..f3ee5370e8 100644 --- a/rusk/src/lib/http/rusk.rs +++ b/rusk/src/lib/http/rusk.rs @@ -96,14 +96,15 @@ impl Rusk { let prov: Vec<_> = self .provisioners(None) .expect("Cannot query state for provisioners") - .filter_map(|(key, stake)| { + .map(|(key, stake)| { let key = bs58::encode(key.to_bytes()).into_string(); let (amount, eligibility) = stake.amount.unwrap_or_default(); - (amount > 0).then_some(Provisioner { + Provisioner { amount, eligibility, key, - }) + reward, + } }) .collect(); @@ -121,4 +122,5 @@ struct Provisioner { key: String, amount: u64, eligibility: u64, + reward: u64, } diff --git a/rusk/tests/common/wallet.rs b/rusk/tests/common/wallet.rs index ff19413c56..4ba610544d 100644 --- a/rusk/tests/common/wallet.rs +++ b/rusk/tests/common/wallet.rs @@ -113,12 +113,11 @@ impl wallet::StateClient for TestStateClient { .ok_or(Error::OpeningPositionNotFound(*note.pos())) } - fn fetch_stake(&self, _pk: &PublicKey) -> Result { + fn fetch_stake(&self, pk: &PublicKey) -> Result { let stake = self .rusk - .provisioners(None)? - .find(|(pk, _)| pk == _pk) - .map(|(_, stake)| StakeInfo { + .provisioner(pk)? + .map(|stake| StakeInfo { amount: stake.amount, counter: stake.counter, reward: stake.reward,