From fdae3d0f0c79d1b33dc304363f28a882ab6b1441 Mon Sep 17 00:00:00 2001 From: Daksh <41485688+Daksh14@users.noreply.github.com> Date: Thu, 31 Oct 2024 23:06:08 -0400 Subject: [PATCH] rusk-wallet: Return rewards and faults even if no stake --- rusk-wallet/src/bin/command.rs | 56 ++++++++++++++++++------------ rusk-wallet/src/bin/interactive.rs | 2 +- rusk-wallet/src/wallet/address.rs | 8 ++--- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/rusk-wallet/src/bin/command.rs b/rusk-wallet/src/bin/command.rs index bbcdb8ca12..9e01cfaeb0 100644 --- a/rusk-wallet/src/bin/command.rs +++ b/rusk-wallet/src/bin/command.rs @@ -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(); @@ -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(); diff --git a/rusk-wallet/src/bin/interactive.rs b/rusk-wallet/src/bin/interactive.rs index fbcc7a4b1f..2cbe5f06da 100644 --- a/rusk-wallet/src/bin/interactive.rs +++ b/rusk-wallet/src/bin/interactive.rs @@ -18,7 +18,7 @@ use rusk_wallet::{ }; use crate::{ - io::{self, prompt}, + io::{self, prompt, GraphQL}, settings::Settings, Command, GraphQL, RunResult, WalletFile, }; diff --git a/rusk-wallet/src/wallet/address.rs b/rusk-wallet/src/wallet/address.rs index f24da362b8..231b113028 100644 --- a/rusk-wallet/src/wallet/address.rs +++ b/rusk-wallet/src/wallet/address.rs @@ -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)), }) } }