Skip to content

Commit

Permalink
cli: find-program-derived-address prints bump seed in verbose display
Browse files Browse the repository at this point in the history
  • Loading branch information
syjcnss committed Sep 30, 2024
1 parent 489f483 commit 2d6d007
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
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(),
bump_seed,
};
Ok(config.output_format.formatted_string(&result))
Expand Down

0 comments on commit 2d6d007

Please sign in to comment.