From 87eea924685238f37da45f3a2a7e96e02a0563ff Mon Sep 17 00:00:00 2001 From: luciotato Date: Fri, 23 Dec 2022 19:49:44 -0300 Subject: [PATCH] show set-owners only instruction --- cli/src/main.rs | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index 470825f..765581b 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -567,14 +567,17 @@ impl fmt::Display for ShowTransactionOutput { ParsedInstruction::MultisigChange { threshold, owners } => { writeln!( f, - " This is a multisig::set_owners_and_change_threshold instruction." - )?; - writeln!( - f, - " New threshold: {} out of {}", - threshold, - owners.len() + " This is a multisig::set_owners{} instruction.", + if *threshold != u64::MAX {"_and_change_threshold"} else {""} )?; + if *threshold != u64::MAX { + writeln!( + f, + " New threshold: {} out of {}", + threshold, + owners.len() + )?; + } writeln!(f, " New owners:")?; for owner_pubkey in owners { writeln!(f, " {}", owner_pubkey)?; @@ -661,14 +664,28 @@ fn show_transaction(program: Program, opts: ShowTransactionOpts) -> ShowTransact // hard-code the tag here (it is stable as long as the namespace and // function name do not change). if instr.program_id == program.id() - && &instr.data[..8] == &[122, 49, 168, 177, 231, 28, 167, 204] { - if let Ok(instr) = - multisig_instruction::SetOwnersAndChangeThreshold::try_from_slice(&instr.data[8..]) - { - ParsedInstruction::MultisigChange { - threshold: instr.threshold, - owners: instr.owners.iter().map(PubkeyBase58::from).collect(), + if &instr.data[..8] == &[122, 49, 168, 177, 231, 28, 167, 204] { + if let Ok(instr) = + multisig_instruction::SetOwnersAndChangeThreshold::try_from_slice(&instr.data[8..]) + { + ParsedInstruction::MultisigChange { + threshold: instr.threshold, + owners: instr.owners.iter().map(PubkeyBase58::from).collect(), + } + } else { + ParsedInstruction::Unrecognized(transaction.instruction.try_to_vec().unwrap()) + } + } else if &instr.data[..8] == &[134, 145, 42, 122, 94, 64, 76, 218] { + if let Ok(instr) = + multisig_instruction::SetOwners::try_from_slice(&instr.data[8..]) + { + ParsedInstruction::MultisigChange { + threshold: u64::MAX, + owners: instr.owners.iter().map(PubkeyBase58::from).collect(), + } + } else { + ParsedInstruction::Unrecognized(transaction.instruction.try_to_vec().unwrap()) } } else { ParsedInstruction::Unrecognized(transaction.instruction.try_to_vec().unwrap()) @@ -704,14 +721,11 @@ pub(crate) fn propose_instruction( transaction_account: Arc, instruction: Instruction, ) -> ProposeInstructionOutput { - - // get multisig_instance data let multisig_data: multisig::Multisig = program .account(multisig_address) .expect("Failed to read multisig state from account."); - // The Multisig program expects `multisig::TransactionAccount` instead of // `solana_sdk::AccountMeta`. The types are structurally identical, // but not nominally, so we need to convert these.