Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rusk-wallet: Add stdout_format flag to binary #2700

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Daksh14
Copy link
Contributor

@Daksh14 Daksh14 commented Oct 18, 2024

Closes #2664

  • Add stdout_format flag to binary
  • Add to_json for RunResult
  • Remove duplicate code in main.rs

Fetch moonlight address

cargo r -- -n testnet --password '' --stdout-format json profiles  | jq '.[] | .public'

Find stake-info

cargo r -- -n testnet --password '' --stdout-format json stake-info

@Daksh14 Daksh14 requested review from HDauven, miloszm and moCello and removed request for miloszm October 18, 2024 04:00
@HDauven
Copy link
Member

HDauven commented Oct 20, 2024

What about situations where the wallet file is missing? Should the error be JSON wrapped to also be parsable?

What if there's no stake for a given key? Should it return that as an error or just have all values default to zero? Since having no stake or rewards is equivalent to not having a key that stakes.

@Daksh14
Copy link
Contributor Author

Daksh14 commented Oct 20, 2024

@HDauven I added a has_stake field in the json output. If the wallet file is missing then the wallet will not initialize no json will be emitted just an error

Copy link
Member

@herr-seppia herr-seppia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should inform the user about the invalid eligibility

rusk-wallet/src/bin/command.rs Outdated Show resolved Hide resolved
Comment on lines -722 to -723
} else {
writeln!(f, "> No active stake found for this key")?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this has been removed?

Comment on lines +324 to +325
if want_json {
stdout_res = run_res.to_json();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put an if else and avoid to "run_res.to_string()"?

impl fmt::Display for RunResult<'_> {
impl<'a> RunResult<'a> {
/// Convert the ran result into json
pub fn to_json(&self) -> String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you implement serde::Serialize for RunResult?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rusk-wallet: Add json output for non interactive
3 participants