Skip to content

Commit

Permalink
Add transaction error and logs to TransactionFailure rpc bundle execu…
Browse files Browse the repository at this point in the history
…tion error
  • Loading branch information
Jac0xb committed Nov 19, 2023
1 parent 9d0fa43 commit 3daeae1
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions rpc-client-api/src/bundles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use {
solana_sdk::{
clock::Slot,
commitment_config::{CommitmentConfig, CommitmentLevel},
signature::Signature,
transaction::TransactionError,
},
solana_transaction_status::{UiTransactionEncoding, UiTransactionReturnData},
Expand Down Expand Up @@ -49,8 +48,15 @@ pub enum RpcBundleExecutionError {
#[error("Tip payment error: {0}")]
TipError(String),

#[error("A transaction in the bundle failed to execute: [signature={0}, error={1}]")]
TransactionFailure(Signature, String),
#[error(
"A transaction in the bundle failed to execute: [signature={0}, errormsg={1}, error={2:?}, log_messages={3:?}]"
)]
TransactionFailure(
String,
String,
Option<TransactionError>,
Option<Vec<String>>,
),
}

impl From<BundleExecutionError> for RpcBundleExecutionError {
Expand All @@ -68,22 +74,35 @@ impl From<BundleExecutionError> for RpcBundleExecutionError {
LoadAndExecuteBundleError::LockError {
signature,
transaction_error,
} => Self::TransactionFailure(signature, transaction_error.to_string()),
} => Self::TransactionFailure(
signature.to_string(),
transaction_error.to_string(),
Some(transaction_error),
None,
),
LoadAndExecuteBundleError::TransactionError {
signature,
execution_result,
} => match *execution_result {
TransactionExecutionResult::Executed { details, .. } => {
let err_msg = if let Err(e) = details.status {
e.to_string()
let (err_msg, e) = if let Err(e) = details.status {
(e.to_string(), Some(e))
} else {
"Unknown error".to_string()
("Unknown error".to_string(), None)
};
Self::TransactionFailure(signature, err_msg)
}
TransactionExecutionResult::NotExecuted(e) => {
Self::TransactionFailure(signature, e.to_string())
Self::TransactionFailure(
signature.to_string(),
err_msg,
e,
details.log_messages,
)
}
TransactionExecutionResult::NotExecuted(e) => Self::TransactionFailure(
signature.to_string(),
e.to_string(),
Some(e),
None,
),
},
LoadAndExecuteBundleError::InvalidPreOrPostAccounts => {
Self::InvalidPreOrPostAccounts
Expand Down

0 comments on commit 3daeae1

Please sign in to comment.