send_and_confirm_transaction() no longer needs a keypair (#9950)
This commit is contained in:
parent
84885d79d5
commit
cb50877bbf
|
@ -1343,8 +1343,7 @@ fn process_deploy(
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
trace!("Creating program account");
|
trace!("Creating program account");
|
||||||
let result =
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&create_account_tx);
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut create_account_tx, &signers);
|
|
||||||
log_instruction_custom_error::<SystemError>(result, &config).map_err(|_| {
|
log_instruction_custom_error::<SystemError>(result, &config).map_err(|_| {
|
||||||
CliError::DynamicProgramError("Program account allocation failed".to_string())
|
CliError::DynamicProgramError("Program account allocation failed".to_string())
|
||||||
})?;
|
})?;
|
||||||
|
@ -1358,7 +1357,7 @@ fn process_deploy(
|
||||||
|
|
||||||
trace!("Finalizing program account");
|
trace!("Finalizing program account");
|
||||||
rpc_client
|
rpc_client
|
||||||
.send_and_confirm_transaction_with_spinner(&mut finalize_tx, &signers)
|
.send_and_confirm_transaction_with_spinner(&finalize_tx)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
CliError::DynamicProgramError(format!("Finalizing program account failed: {}", e))
|
CliError::DynamicProgramError(format!("Finalizing program account failed: {}", e))
|
||||||
})?;
|
})?;
|
||||||
|
@ -1423,8 +1422,7 @@ fn process_pay(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result =
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
} else if *witnesses == None {
|
} else if *witnesses == None {
|
||||||
|
@ -1459,10 +1457,7 @@ fn process_pay(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
&mut tx,
|
|
||||||
&[config.signers[0], &contract_state],
|
|
||||||
);
|
|
||||||
let signature = log_instruction_custom_error::<BudgetError>(result, &config)?;
|
let signature = log_instruction_custom_error::<BudgetError>(result, &config)?;
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
"signature": signature,
|
"signature": signature,
|
||||||
|
@ -1498,10 +1493,7 @@ fn process_pay(
|
||||||
return_signers(&tx, &config)
|
return_signers(&tx, &config)
|
||||||
} else {
|
} else {
|
||||||
tx.try_sign(&[config.signers[0], &contract_state], blockhash)?;
|
tx.try_sign(&[config.signers[0], &contract_state], blockhash)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
&mut tx,
|
|
||||||
&[config.signers[0], &contract_state],
|
|
||||||
);
|
|
||||||
check_account_for_fee(
|
check_account_for_fee(
|
||||||
rpc_client,
|
rpc_client,
|
||||||
&config.signers[0].pubkey(),
|
&config.signers[0].pubkey(),
|
||||||
|
@ -1536,8 +1528,7 @@ fn process_cancel(rpc_client: &RpcClient, config: &CliConfig, pubkey: &Pubkey) -
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result =
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
|
||||||
log_instruction_custom_error::<BudgetError>(result, &config)
|
log_instruction_custom_error::<BudgetError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1560,8 +1551,7 @@ fn process_time_elapsed(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result =
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
|
||||||
log_instruction_custom_error::<BudgetError>(result, &config)
|
log_instruction_custom_error::<BudgetError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1623,7 +1613,7 @@ fn process_transfer(
|
||||||
let result = if no_wait {
|
let result = if no_wait {
|
||||||
rpc_client.send_transaction(&tx)
|
rpc_client.send_transaction(&tx)
|
||||||
} else {
|
} else {
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers)
|
rpc_client.send_and_confirm_transaction_with_spinner(&tx)
|
||||||
};
|
};
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
@ -1647,8 +1637,7 @@ fn process_witness(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result =
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
|
||||||
log_instruction_custom_error::<BudgetError>(result, &config)
|
log_instruction_custom_error::<BudgetError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2279,8 +2268,8 @@ pub fn request_and_confirm_airdrop(
|
||||||
sleep(Duration::from_secs(1));
|
sleep(Duration::from_secs(1));
|
||||||
}
|
}
|
||||||
}?;
|
}?;
|
||||||
let mut tx = keypair.airdrop_transaction();
|
let tx = keypair.airdrop_transaction();
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[&keypair]);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -446,7 +446,7 @@ pub fn process_authorize_nonce_account(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<NonceError>(result, &config)
|
log_instruction_custom_error::<NonceError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ pub fn process_create_nonce_account(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,8 +564,7 @@ pub fn process_new_nonce(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0], nonce_authority]);
|
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +623,7 @@ pub fn process_withdraw_from_nonce_account(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<NonceError>(result, &config)
|
log_instruction_custom_error::<NonceError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -869,7 +869,7 @@ pub fn process_create_stake_account(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -934,7 +934,7 @@ pub fn process_stake_authorize(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<StakeError>(result, &config)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,7 +988,7 @@ pub fn process_deactivate_stake_account(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<StakeError>(result, &config)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1051,7 +1051,7 @@ pub fn process_withdraw_stake(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,7 @@ pub fn process_split_stake(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<StakeError>(result, &config)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1242,7 +1242,7 @@ pub fn process_stake_set_lockup(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<StakeError>(result, &config)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1450,7 +1450,7 @@ pub fn process_delegate_stake(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<StakeError>(result, &config)
|
log_instruction_custom_error::<StakeError>(result, &config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ pub fn process_create_storage_account(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ pub fn process_claim_storage_reward(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let signature = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &signers)?;
|
let signature = rpc_client.send_and_confirm_transaction_with_spinner(&tx)?;
|
||||||
Ok(signature.to_string())
|
Ok(signature.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -367,7 +367,7 @@ pub fn process_set_validator_info(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let signature_str = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &signers)?;
|
let signature_str = rpc_client.send_and_confirm_transaction_with_spinner(&tx)?;
|
||||||
|
|
||||||
println!("Success! Validator info published at: {:?}", info_pubkey);
|
println!("Success! Validator info published at: {:?}", info_pubkey);
|
||||||
println!("{}", signature_str);
|
println!("{}", signature_str);
|
||||||
|
|
|
@ -437,7 +437,7 @@ pub fn process_create_vote_account(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<SystemError>(result, &config)
|
log_instruction_custom_error::<SystemError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,8 +477,7 @@ pub fn process_vote_authorize(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result =
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &[config.signers[0]]);
|
|
||||||
log_instruction_custom_error::<VoteError>(result, &config)
|
log_instruction_custom_error::<VoteError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +510,7 @@ pub fn process_vote_update_validator(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&tx.message,
|
&tx.message,
|
||||||
)?;
|
)?;
|
||||||
let result = rpc_client.send_and_confirm_transaction_with_spinner(&mut tx, &config.signers);
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
|
||||||
log_instruction_custom_error::<VoteError>(result, &config)
|
log_instruction_custom_error::<VoteError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,8 +615,7 @@ pub fn process_withdraw_from_vote_account(
|
||||||
&fee_calculator,
|
&fee_calculator,
|
||||||
&transaction.message,
|
&transaction.message,
|
||||||
)?;
|
)?;
|
||||||
let result =
|
let result = rpc_client.send_and_confirm_transaction_with_spinner(&transaction);
|
||||||
rpc_client.send_and_confirm_transaction_with_spinner(&mut transaction, &config.signers);
|
|
||||||
log_instruction_custom_error::<VoteError>(result, &config)
|
log_instruction_custom_error::<VoteError>(result, &config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use solana_sdk::{
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
signers::Signers,
|
signers::Signers,
|
||||||
transaction::{self, Transaction, TransactionError},
|
transaction::{self, Transaction},
|
||||||
};
|
};
|
||||||
use solana_transaction_status::{
|
use solana_transaction_status::{
|
||||||
ConfirmedBlock, ConfirmedTransaction, TransactionEncoding, TransactionStatus,
|
ConfirmedBlock, ConfirmedTransaction, TransactionEncoding, TransactionStatus,
|
||||||
|
@ -449,10 +449,9 @@ impl RpcClient {
|
||||||
.map_err(|err| ClientError::new_with_command(err.into(), "MinimumLedgerSlot"))
|
.map_err(|err| ClientError::new_with_command(err.into(), "MinimumLedgerSlot"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_and_confirm_transaction<T: Signers>(
|
pub fn send_and_confirm_transaction(
|
||||||
&self,
|
&self,
|
||||||
transaction: &mut Transaction,
|
transaction: &Transaction,
|
||||||
signer_keys: &T,
|
|
||||||
) -> ClientResult<Signature> {
|
) -> ClientResult<Signature> {
|
||||||
let mut send_retries = 20;
|
let mut send_retries = 20;
|
||||||
loop {
|
loop {
|
||||||
|
@ -476,11 +475,6 @@ impl RpcClient {
|
||||||
send_retries = if let Some(result) = status.clone() {
|
send_retries = if let Some(result) = status.clone() {
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => return Ok(signature),
|
Ok(_) => return Ok(signature),
|
||||||
Err(TransactionError::AccountInUse) => {
|
|
||||||
// Fetch a new blockhash and re-sign the transaction before sending it again
|
|
||||||
self.resign_transaction(transaction, signer_keys)?;
|
|
||||||
send_retries - 1
|
|
||||||
}
|
|
||||||
Err(_) => 0,
|
Err(_) => 0,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -491,7 +485,9 @@ impl RpcClient {
|
||||||
return Err(err.unwrap_err().into());
|
return Err(err.unwrap_err().into());
|
||||||
} else {
|
} else {
|
||||||
return Err(
|
return Err(
|
||||||
RpcError::ForUser("unable to confirm transaction. This can happen in situations such as transaction expiration and insufficient fee-payer funds".to_string()).into(),
|
RpcError::ForUser("unable to confirm transaction. \
|
||||||
|
This can happen in situations such as transaction expiration \
|
||||||
|
and insufficient fee-payer funds".to_string()).into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1088,10 +1084,9 @@ impl RpcClient {
|
||||||
Ok(confirmations)
|
Ok(confirmations)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_and_confirm_transaction_with_spinner<T: Signers>(
|
pub fn send_and_confirm_transaction_with_spinner(
|
||||||
&self,
|
&self,
|
||||||
transaction: &mut Transaction,
|
transaction: &Transaction,
|
||||||
signer_keys: &T,
|
|
||||||
) -> ClientResult<Signature> {
|
) -> ClientResult<Signature> {
|
||||||
let mut confirmations = 0;
|
let mut confirmations = 0;
|
||||||
|
|
||||||
|
@ -1128,11 +1123,6 @@ impl RpcClient {
|
||||||
send_retries = if let Some(result) = status.clone() {
|
send_retries = if let Some(result) = status.clone() {
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => 0,
|
Ok(_) => 0,
|
||||||
Err(TransactionError::AccountInUse) => {
|
|
||||||
// Fetch a new blockhash and re-sign the transaction before sending it again
|
|
||||||
self.resign_transaction(transaction, signer_keys)?;
|
|
||||||
send_retries - 1
|
|
||||||
}
|
|
||||||
// If transaction errors, return right away; no point in counting confirmations
|
// If transaction errors, return right away; no point in counting confirmations
|
||||||
Err(_) => 0,
|
Err(_) => 0,
|
||||||
}
|
}
|
||||||
|
@ -1150,9 +1140,13 @@ impl RpcClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(
|
return Err(RpcError::ForUser(
|
||||||
RpcError::ForUser("unable to confirm transaction. This can happen in situations such as transaction expiration and insufficient fee-payer funds".to_string()).into(),
|
"unable to confirm transaction. \
|
||||||
);
|
This can happen in situations such as transaction \
|
||||||
|
expiration and insufficient fee-payer funds"
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1177,7 +1171,9 @@ impl RpcClient {
|
||||||
.unwrap_or(confirmations);
|
.unwrap_or(confirmations);
|
||||||
if now.elapsed().as_secs() >= MAX_HASH_AGE_IN_SECONDS as u64 {
|
if now.elapsed().as_secs() >= MAX_HASH_AGE_IN_SECONDS as u64 {
|
||||||
return Err(
|
return Err(
|
||||||
RpcError::ForUser("transaction not finalized. This can happen when a transaction lands in an abandoned fork. Please retry.".to_string()).into(),
|
RpcError::ForUser("transaction not finalized. \
|
||||||
|
This can happen when a transaction lands in an abandoned fork. \
|
||||||
|
Please retry.".to_string()).into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1380,17 +1376,16 @@ mod tests {
|
||||||
let key = Keypair::new();
|
let key = Keypair::new();
|
||||||
let to = Pubkey::new_rand();
|
let to = Pubkey::new_rand();
|
||||||
let blockhash = Hash::default();
|
let blockhash = Hash::default();
|
||||||
let mut tx = system_transaction::transfer(&key, &to, 50, blockhash);
|
let tx = system_transaction::transfer(&key, &to, 50, blockhash);
|
||||||
|
let result = rpc_client.send_and_confirm_transaction(&tx);
|
||||||
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&key]);
|
|
||||||
result.unwrap();
|
result.unwrap();
|
||||||
|
|
||||||
let rpc_client = RpcClient::new_mock("account_in_use".to_string());
|
let rpc_client = RpcClient::new_mock("account_in_use".to_string());
|
||||||
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&key]);
|
let result = rpc_client.send_and_confirm_transaction(&tx);
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
|
|
||||||
let rpc_client = RpcClient::new_mock("instruction_error".to_string());
|
let rpc_client = RpcClient::new_mock("instruction_error".to_string());
|
||||||
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&key]);
|
let result = rpc_client.send_and_confirm_transaction(&tx);
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ClientErrorKind::TransactionError(TransactionError::InstructionError(
|
ClientErrorKind::TransactionError(TransactionError::InstructionError(
|
||||||
|
@ -1400,7 +1395,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let rpc_client = RpcClient::new_mock("sig_not_found".to_string());
|
let rpc_client = RpcClient::new_mock("sig_not_found".to_string());
|
||||||
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&key]);
|
let result = rpc_client.send_and_confirm_transaction(&tx);
|
||||||
if let ClientErrorKind::Io(err) = result.unwrap_err().kind() {
|
if let ClientErrorKind::Io(err) = result.unwrap_err().kind() {
|
||||||
assert_eq!(err.kind(), io::ErrorKind::Other);
|
assert_eq!(err.kind(), io::ErrorKind::Other);
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,8 +221,7 @@ fn new_update_manifest(
|
||||||
let mut transaction = Transaction::new_unsigned_instructions(&instructions);
|
let mut transaction = Transaction::new_unsigned_instructions(&instructions);
|
||||||
let signers = [from_keypair, update_manifest_keypair];
|
let signers = [from_keypair, update_manifest_keypair];
|
||||||
transaction.sign(&signers, recent_blockhash);
|
transaction.sign(&signers, recent_blockhash);
|
||||||
|
rpc_client.send_and_confirm_transaction(&transaction)?;
|
||||||
rpc_client.send_and_confirm_transaction(&mut transaction, &[from_keypair])?;
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -245,8 +244,8 @@ fn store_update_manifest(
|
||||||
);
|
);
|
||||||
|
|
||||||
let message = Message::new_with_payer(&[instruction], Some(&from_keypair.pubkey()));
|
let message = Message::new_with_payer(&[instruction], Some(&from_keypair.pubkey()));
|
||||||
let mut transaction = Transaction::new(&signers, message, recent_blockhash);
|
let transaction = Transaction::new(&signers, message, recent_blockhash);
|
||||||
rpc_client.send_and_confirm_transaction(&mut transaction, &[from_keypair])?;
|
rpc_client.send_and_confirm_transaction(&transaction)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ fn delegate_stake(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut transaction = Transaction::new_signed_instructions(
|
let transaction = Transaction::new_signed_instructions(
|
||||||
&[faucet_keypair, &stake_account_keypair],
|
&[faucet_keypair, &stake_account_keypair],
|
||||||
&stake_instruction::create_account_and_delegate_stake(
|
&stake_instruction::create_account_and_delegate_stake(
|
||||||
&faucet_keypair.pubkey(),
|
&faucet_keypair.pubkey(),
|
||||||
|
@ -160,10 +160,7 @@ fn delegate_stake(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(err) = rpc_client.send_and_confirm_transaction(
|
if let Err(err) = rpc_client.send_and_confirm_transaction(&transaction) {
|
||||||
&mut transaction,
|
|
||||||
&[faucet_keypair, &stake_account_keypair],
|
|
||||||
) {
|
|
||||||
error!(
|
error!(
|
||||||
"Failed to delegate stake (retries: {}): {}",
|
"Failed to delegate stake (retries: {}): {}",
|
||||||
retry_count, err
|
retry_count, err
|
||||||
|
|
|
@ -214,7 +214,7 @@ fn send_message<S: Signers>(
|
||||||
if no_wait {
|
if no_wait {
|
||||||
client.send_transaction(&transaction)
|
client.send_transaction(&transaction)
|
||||||
} else {
|
} else {
|
||||||
client.send_and_confirm_transaction_with_spinner(&mut transaction, signers)
|
client.send_and_confirm_transaction_with_spinner(&transaction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue