Cli: Return final transaction signature in solana program deploy (#34931)
This commit is contained in:
parent
e155d9c445
commit
9e09524595
|
@ -2075,6 +2075,7 @@ impl fmt::Display for CliTokenAccount {
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CliProgramId {
|
||||
pub program_id: String,
|
||||
pub signature: Option<String>,
|
||||
}
|
||||
|
||||
impl QuietDisplay for CliProgramId {}
|
||||
|
@ -2082,7 +2083,12 @@ impl VerboseDisplay for CliProgramId {}
|
|||
|
||||
impl fmt::Display for CliProgramId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln_name_value(f, "Program Id:", &self.program_id)
|
||||
writeln_name_value(f, "Program Id:", &self.program_id)?;
|
||||
if let Some(ref signature) = self.signature {
|
||||
writeln!(f)?;
|
||||
writeln_name_value(f, "Signature:", signature)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1337,11 +1337,12 @@ fn process_program_upgrade(
|
|||
let mut tx = Transaction::new_unsigned(message);
|
||||
let signers = &[fee_payer_signer, upgrade_authority_signer];
|
||||
tx.try_sign(signers, blockhash)?;
|
||||
rpc_client
|
||||
let final_tx_sig = rpc_client
|
||||
.send_and_confirm_transaction_with_spinner(&tx)
|
||||
.map_err(|e| format!("Upgrading program failed: {e}"))?;
|
||||
let program_id = CliProgramId {
|
||||
program_id: program_id.to_string(),
|
||||
signature: Some(final_tx_sig.to_string()),
|
||||
};
|
||||
Ok(config.output_format.formatted_string(&program_id))
|
||||
}
|
||||
|
@ -2263,7 +2264,7 @@ fn do_process_program_write_and_deploy(
|
|||
)?;
|
||||
}
|
||||
|
||||
send_deploy_messages(
|
||||
let final_tx_sig = send_deploy_messages(
|
||||
rpc_client,
|
||||
config,
|
||||
&initial_message,
|
||||
|
@ -2278,6 +2279,7 @@ fn do_process_program_write_and_deploy(
|
|||
if let Some(program_signers) = program_signers {
|
||||
let program_id = CliProgramId {
|
||||
program_id: program_signers[0].pubkey().to_string(),
|
||||
signature: final_tx_sig.as_ref().map(ToString::to_string),
|
||||
};
|
||||
Ok(config.output_format.formatted_string(&program_id))
|
||||
} else {
|
||||
|
@ -2396,7 +2398,7 @@ fn do_process_program_upgrade(
|
|||
)?;
|
||||
}
|
||||
|
||||
send_deploy_messages(
|
||||
let final_tx_sig = send_deploy_messages(
|
||||
rpc_client,
|
||||
config,
|
||||
&initial_message,
|
||||
|
@ -2410,6 +2412,7 @@ fn do_process_program_upgrade(
|
|||
|
||||
let program_id = CliProgramId {
|
||||
program_id: program_id.to_string(),
|
||||
signature: final_tx_sig.as_ref().map(ToString::to_string),
|
||||
};
|
||||
Ok(config.output_format.formatted_string(&program_id))
|
||||
}
|
||||
|
@ -2534,7 +2537,7 @@ fn send_deploy_messages(
|
|||
initial_signer: Option<&dyn Signer>,
|
||||
write_signer: Option<&dyn Signer>,
|
||||
final_signers: Option<&[&dyn Signer]>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
) -> Result<Option<Signature>, Box<dyn std::error::Error>> {
|
||||
if let Some(message) = initial_message {
|
||||
if let Some(initial_signer) = initial_signer {
|
||||
trace!("Preparing the required accounts");
|
||||
|
@ -2626,20 +2629,22 @@ fn send_deploy_messages(
|
|||
let mut signers = final_signers.to_vec();
|
||||
signers.push(fee_payer_signer);
|
||||
final_tx.try_sign(&signers, blockhash)?;
|
||||
rpc_client
|
||||
.send_and_confirm_transaction_with_spinner_and_config(
|
||||
&final_tx,
|
||||
config.commitment,
|
||||
RpcSendTransactionConfig {
|
||||
preflight_commitment: Some(config.commitment.commitment),
|
||||
..RpcSendTransactionConfig::default()
|
||||
},
|
||||
)
|
||||
.map_err(|e| format!("Deploying program failed: {e}"))?;
|
||||
return Ok(Some(
|
||||
rpc_client
|
||||
.send_and_confirm_transaction_with_spinner_and_config(
|
||||
&final_tx,
|
||||
config.commitment,
|
||||
RpcSendTransactionConfig {
|
||||
preflight_commitment: Some(config.commitment.commitment),
|
||||
..RpcSendTransactionConfig::default()
|
||||
},
|
||||
)
|
||||
.map_err(|e| format!("Deploying program failed: {e}"))?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn create_ephemeral_keypair(
|
||||
|
|
|
@ -636,6 +636,7 @@ pub fn process_deploy_program(
|
|||
|
||||
let program_id = CliProgramId {
|
||||
program_id: program_address.to_string(),
|
||||
signature: None,
|
||||
};
|
||||
Ok(config.output_format.formatted_string(&program_id))
|
||||
}
|
||||
|
@ -690,6 +691,7 @@ fn process_undeploy_program(
|
|||
|
||||
let program_id = CliProgramId {
|
||||
program_id: program_address.to_string(),
|
||||
signature: None,
|
||||
};
|
||||
Ok(config.output_format.formatted_string(&program_id))
|
||||
}
|
||||
|
@ -716,6 +718,7 @@ fn process_finalize_program(
|
|||
|
||||
let program_id = CliProgramId {
|
||||
program_id: program_address.to_string(),
|
||||
signature: None,
|
||||
};
|
||||
Ok(config.output_format.formatted_string(&program_id))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue