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

Release Wait for Confirmation #85

Merged
merged 2 commits into from
Oct 12, 2023
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
34 changes: 33 additions & 1 deletion consumer/src/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
backon::{ExponentialBuilder, Retryable},
bs58, clap,
prelude::*,
thiserror,
thiserror, tokio,
uuid::Uuid,
};
use mpl_bubblegum::state::metaplex_adapter::{
Expand All @@ -28,6 +28,7 @@
use solana_client::{
client_error::{ClientError, ClientErrorKind},
nonblocking::rpc_client::RpcClient as SolanaRpcClient,
rpc_client::SerializableTransaction,
rpc_config::RpcSendTransactionConfig,
rpc_request::RpcError,
};
Expand All @@ -36,6 +37,7 @@
system_instruction::create_account, system_program,
};
use solana_sdk::{
commitment_config::CommitmentConfig,
signature::Signature,
signer::{keypair::Keypair, Signer},
transaction::Transaction,
Expand Down Expand Up @@ -291,6 +293,36 @@
anyhow!(msg)
})?;

let recent_blockhash = transaction.get_recent_blockhash();

loop {
let signature_status = with_retry!(self.rpc().get_signature_status(&signature)).await?;

match signature_status {
Some(Ok(_)) => break,
None => {
let valid_blockhash = self
.rpc()
.is_blockhash_valid(recent_blockhash, CommitmentConfig::processed())
.await?;

if valid_blockhash {
tokio::time::sleep(std::time::Duration::from_millis(250)).await;
continue;
} else {
let msg = format!("blockhash is invalid: {recent_blockhash}");
error!(msg);
bail!(msg)
}
},
Some(Err(e)) => {
let msg = format!("failed to send transaction: {e}");
error!(msg);
bail!(msg)
},
}
}

Ok(signature.to_string())
}
}
Expand Down Expand Up @@ -397,7 +429,7 @@
true,
None,
None,
Some(mpl_token_metadata::state::CollectionDetails::V1 { size: 0 }),

Check warning on line 432 in consumer/src/solana.rs

View workflow job for this annotation

GitHub Actions / Cargo Test

use of deprecated variant `mpl_token_metadata::state::CollectionDetails::V1`: The collection size tracking feature is deprecated and will soon be removed.

Check warning on line 432 in consumer/src/solana.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

use of deprecated variant `mpl_token_metadata::state::CollectionDetails::V1`: The collection size tracking feature is deprecated and will soon be removed.

Check warning on line 432 in consumer/src/solana.rs

View workflow job for this annotation

GitHub Actions / Cargo Test

use of deprecated variant `mpl_token_metadata::state::CollectionDetails::V1`: The collection size tracking feature is deprecated and will soon be removed.

Check warning on line 432 in consumer/src/solana.rs

View workflow job for this annotation

GitHub Actions / clippy/check/doc

use of deprecated variant `mpl_token_metadata::state::CollectionDetails::V1`: The collection size tracking feature is deprecated and will soon be removed.
);
let create_master_edition_ins = mpl_token_metadata::instruction::create_master_edition_v3(
mpl_token_metadata::ID,
Expand Down
Loading