Skip to content

Commit

Permalink
Merge pull request #3193 from dusk-network/stake_funds_owner
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia authored Dec 17, 2024
2 parents 0297c6e + 584414a commit ccc8bd4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions rusk/src/lib/http/rusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use super::event::Event;
use super::*;

use dusk_bytes::Serializable;
use execution_core::stake::StakeFundOwner;
use node::vm::VMExecution;
use rusk_profile::CRS_17_HASH;
use serde::Serialize;
Expand Down Expand Up @@ -131,6 +132,7 @@ impl Rusk {
.provisioners(None)
.expect("Cannot query state for provisioners")
.map(|(key, stake)| {
let owner = StakeOwner::from(&key.owner);
let key = bs58::encode(key.account.to_bytes()).into_string();
let amount = stake.amount.unwrap_or_default();

Expand All @@ -142,6 +144,7 @@ impl Rusk {
reward: stake.reward,
faults: stake.faults,
hard_faults: stake.hard_faults,
owner,
}
})
.collect();
Expand All @@ -164,4 +167,24 @@ struct Provisioner {
reward: u64,
faults: u8,
hard_faults: u8,
owner: StakeOwner,
}

#[derive(Serialize)]
enum StakeOwner {
Account(String),
Contract(String),
}

impl From<&StakeFundOwner> for StakeOwner {
fn from(value: &StakeFundOwner) -> Self {
match value {
StakeFundOwner::Account(account) => StakeOwner::Account(
bs58::encode(account.to_bytes()).into_string(),
),
StakeFundOwner::Contract(contract) => {
StakeOwner::Contract(hex::encode(contract.as_bytes()))
}
}
}
}

0 comments on commit ccc8bd4

Please sign in to comment.