Skip to main content

cow_sdk_alloy/
lib.rs

1#![cfg_attr(doctest, doc = include_str!("../README.md"))]
2
3//! Native composed Alloy adapter for the `CoW` Protocol Rust SDK.
4//!
5//! [`AlloyClient`] combines an Alloy HTTP provider with an Alloy local private
6//! key signer through Alloy's wallet-filler stack. It implements
7//! [`cow_sdk_core::Provider`], [`cow_sdk_core::LogProvider`], and
8//! [`cow_sdk_core::SigningProvider`], while the handle returned by
9//! `create_signer` implements [`cow_sdk_core::Signer`].
10//!
11//! ```rust,no_run
12//! use cow_sdk_alloy::AlloyClient;
13//! use cow_sdk_core::SupportedChainId;
14//!
15//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
16//! let client = AlloyClient::builder()
17//!     .http("https://example.invalid/rpc")?
18//!     .private_key("0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d")?
19//!     .chain_id(SupportedChainId::Sepolia)
20//!     .build_checked()
21//!     .await?;
22//! # let _ = client;
23//! # Ok(())
24//! # }
25//! ```
26//!
27//! `send_transaction` submits through the wallet-filler provider and returns
28//! [`cow_sdk_core::TransactionBroadcast`] with the broadcast transaction hash
29//! from Alloy's pending transaction handle. It does not wait for receipt
30//! observation. Use [`cow_sdk_core::Provider::get_transaction_receipt`]
31//! on the client when mined status, block, gas, sender, or recipient fields are
32//! needed. Raw `sign_transaction` is intentionally not exposed by this release
33//! because Alloy's provider method routes to the remote JSON-RPC peer rather
34//! than producing a local signed payload.
35
36#![warn(missing_docs)]
37#![allow(
38    clippy::redundant_pub_crate,
39    reason = "helper modules keep crate-private visibility explicit"
40)]
41
42#[cfg(not(target_arch = "wasm32"))]
43mod builder;
44#[cfg(not(target_arch = "wasm32"))]
45mod client;
46#[cfg(not(target_arch = "wasm32"))]
47mod conversion;
48#[cfg(not(target_arch = "wasm32"))]
49mod error;
50#[cfg(not(target_arch = "wasm32"))]
51mod handle;
52
53#[cfg(not(target_arch = "wasm32"))]
54pub use builder::{
55    AlloyClientBuilder, AlloyClientBuilderError, ChainSet, ChainState, ChainUnset, HttpTransport,
56    KeySourceState, KeySourceUnset, PrivateKeySource, TransportState, TransportUnset,
57};
58#[cfg(not(target_arch = "wasm32"))]
59pub use client::AlloyClient;
60#[cfg(not(target_arch = "wasm32"))]
61pub use cow_sdk_alloy_provider::RetryConfig;
62#[cfg(not(target_arch = "wasm32"))]
63pub use error::AlloyClientError;
64#[cfg(not(target_arch = "wasm32"))]
65pub use handle::AlloyClientSignerHandle;
66
67/// Native Alloy provider leaf namespace.
68#[cfg(not(target_arch = "wasm32"))]
69pub use cow_sdk_alloy_provider as provider;
70/// Native Alloy signer leaf namespace.
71#[cfg(not(target_arch = "wasm32"))]
72pub use cow_sdk_alloy_signer as signer;