Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve wait_for_transaction_acceptance #2177

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions sdk/src/client/api/wait_for_tx_acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ impl Client {
.unwrap_or(DEFAULT_WAIT_FOR_TX_ACCEPTANCE_INTERVAL);

for _ in 0..max_attempts.unwrap_or(DEFAULT_WAIT_FOR_TX_ACCEPTANCE_MAX_ATTEMPTS) {
let transaction_metadata = self.get_transaction_metadata(transaction_id).await?;

match transaction_metadata.transaction_state {
TransactionState::Accepted | TransactionState::Committed | TransactionState::Finalized => {
return Ok(());
match self.get_transaction_metadata(transaction_id).await {
Ok(transaction_metadata) => {
match transaction_metadata.transaction_state {
TransactionState::Accepted | TransactionState::Committed | TransactionState::Finalized => {
return Ok(());
}
TransactionState::Failed => {
return Err(ClientError::TransactionAcceptance(transaction_id.to_string()));
}
TransactionState::Pending => {} // Just need to wait longer
};
}
TransactionState::Failed => return Err(ClientError::TransactionAcceptance(transaction_id.to_string())),
TransactionState::Pending => {} // Just need to wait longer
Err(ClientError::Node(crate::client::node_api::error::Error::NotFound(_))) => {}
Err(e) => return Err(e),
};

#[cfg(target_family = "wasm")]
Expand Down
Loading