Skip to content

Commit

Permalink
rusk-wallet: Return rewards and faults even if no stake
Browse files Browse the repository at this point in the history
  • Loading branch information
Daksh14 committed Nov 21, 2024
1 parent d471ef7 commit fdae3d0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
56 changes: 33 additions & 23 deletions rusk-wallet/src/bin/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,28 +696,37 @@ impl<'a> RunResult<'a> {
"hash": hex
})
}
StakeInfo(data, _) => match data.amount {
Some(amt) => {
let amount = Dusk::from(amt.value).to_string();
let locked = Dusk::from(amt.locked).to_string();
let faults = data.faults.to_string();
let hard_faults = data.hard_faults.to_string();
let eligibility = amt.eligibility.to_string();
let epoch = (amt.eligibility / EPOCH).to_string();
let rewards = Dusk::from(data.reward).to_string();

json!({
"rewards": rewards,
"amount": amount,
"locked": locked,
"eligibility": eligibility,
"epoch": epoch,
"hard_faults": hard_faults,
"faults": faults,
})
StakeInfo(data, _) => {
let faults = data.faults.to_string();
let hard_faults = data.hard_faults.to_string();
let rewards = Dusk::from(data.reward).to_string();

match data.amount {
Some(amt) => {
let amount = Dusk::from(amt.value).to_string();
let locked = Dusk::from(amt.locked).to_string();
let eligibility = amt.eligibility.to_string();
let epoch = (amt.eligibility / EPOCH).to_string();

json!({
"rewards": rewards,
"amount": amount,
"locked": locked,
"eligibility": eligibility,
"epoch": epoch,
"hard_faults": hard_faults,
"faults": faults,
})
}
None => {
json!({
"rewards": rewards,
"faults": faults,
"hard_faults": hard_faults
})
}
}
None => serde_json::Value::Null,
},
}
ExportedKeys(pk, kp) => {
let pk = pk.as_os_str();
let kp = kp.as_os_str();
Expand Down Expand Up @@ -812,8 +821,9 @@ impl<'a> fmt::Display for RunResult<'a> {
writeln!(f, "> Hard Slashes: {hard_faults}")?;
write!(f, "> Accumulated rewards is: {rewards} DUSK")
}
ContractId(bytes) => {
write!(f, "> Contract ID: {}", hex::encode(bytes))
ContractId((bytes, nonce)) => {
write!(f, "> Contract ID: {}", hex::encode(bytes))?;
write!(f, "> Deploy nonce: {}", nonce)
}
ExportedKeys(pk, kp) => {
let pk = pk.display();
Expand Down
2 changes: 1 addition & 1 deletion rusk-wallet/src/bin/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rusk_wallet::{
};

use crate::{
io::{self, prompt},
io::{self, prompt, GraphQL},
settings::Settings,
Command, GraphQL, RunResult, WalletFile,
};
Expand Down
8 changes: 2 additions & 6 deletions rusk-wallet/src/wallet/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,8 @@ impl Profile {
/// format the profile into a json value
pub fn to_json(&self) -> serde_json::Value {
json!({
"shielded": String::from(&Address::Shielded {
addr: self.shielded_addr
}),
"public": String::from(&Address::Public {
addr: self.public_addr
}),
"shielded": String::from(&Address::Shielded(self.shielded_addr)),
"public": String::from(&Address::Public(self.public_addr)),
})
}
}
Expand Down

0 comments on commit fdae3d0

Please sign in to comment.