cargo_tangle/
lib.rs

1pub mod command;
2pub mod foundry;
3pub mod utils;
4
5#[cfg(test)]
6mod tests;
7
8pub use blueprint_chain_setup::anvil;
9use blueprint_tangle_extra::util::TxProgressExt;
10use tangle_subxt::subxt::{Config, blocks::ExtrinsicEvents, client::OnlineClientT, tx::TxProgress};
11use tangle_subxt::tangle_testnet_runtime::api::runtime_types::tangle_primitives::services::field::BoundedString;
12
13pub(crate) async fn wait_for_in_block_success<T: Config>(
14    res: TxProgress<T, impl OnlineClientT<T>>,
15) -> ExtrinsicEvents<T> {
16    res.wait_for_in_block()
17        .await
18        .unwrap()
19        .fetch_events()
20        .await
21        .unwrap()
22}
23
24/// Helper function to decode a `BoundedString` to a regular String
25pub(crate) fn decode_bounded_string(bounded_string: &BoundedString) -> String {
26    String::from_utf8_lossy(&bounded_string.0.0).to_string()
27}
28
29/// This force installs the default crypto provider.
30///
31/// This is necessary in case there are more than one available backends enabled in rustls (ring,
32/// aws-lc-rs).
33///
34/// This should be called high in the main fn.
35///
36/// See also:
37///   <https://github.com/snapview/tokio-tungstenite/issues/353#issuecomment-2455100010>
38///   <https://github.com/awslabs/aws-sdk-rust/discussions/1257>
39///
40/// # Panics
41/// If the default crypto provider cannot be installed, this function will panic.
42pub fn install_crypto_provider() {
43    // https://github.com/snapview/tokio-tungstenite/issues/353
44    rustls::crypto::ring::default_provider()
45        .install_default()
46        .expect("Failed to install default rustls crypto provider");
47}