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

cli: make find-program-derived-address print bump seed in verbose display #3042

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cli-output/src/cli_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3196,11 +3196,19 @@ impl fmt::Display for CliBalance {
#[serde(rename_all = "camelCase")]
pub struct CliFindProgramDerivedAddress {
pub address: String,
pub seeds: Vec<Vec<u8>>,
pub bump_seed: u8,
}

impl QuietDisplay for CliFindProgramDerivedAddress {}
impl VerboseDisplay for CliFindProgramDerivedAddress {}
impl VerboseDisplay for CliFindProgramDerivedAddress {
fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result {
writeln!(w, "Seeds: {:?}", self.seeds)?;
writeln!(w, "Bump: {}", self.bump_seed)?;
write!(w, "{}", self.address)?;
Ok(())
}
}

impl fmt::Display for CliFindProgramDerivedAddress {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
4 changes: 1 addition & 3 deletions cli/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,11 @@ pub fn process_find_program_derived_address(
seeds: &Vec<Vec<u8>>,
program_id: &Pubkey,
) -> ProcessResult {
if config.verbose {
println!("Seeds: {seeds:?}");
}
let seeds_slice = seeds.iter().map(|x| &x[..]).collect::<Vec<_>>();
let (address, bump_seed) = Pubkey::find_program_address(&seeds_slice[..], program_id);
let result = CliFindProgramDerivedAddress {
address: address.to_string(),
seeds: seeds.clone(),

Choose a reason for hiding this comment

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

clippy is complaining about the &Vec passed in, and saying to change that to &[_] instead: https://github.com/anza-xyz/agave/actions/runs/11114470308/job/31517664360?pr=3042#step:5:1336

And then this will need to change to seeds.to_owned()

bump_seed,
};
Ok(config.output_format.formatted_string(&result))
Expand Down
Loading