Skip to content

Commit

Permalink
fix: cfg attr for wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Mar 11, 2024
1 parent 16b328e commit b3db0fe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions crates/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ async-trait.workspace = true
serde = { workspace = true, features = ["derive"] }
thiserror.workspace = true

[dev-dependencies]
tokio.workspace = true

[features]
k256 = ["alloy-primitives/k256", "alloy-consensus/k256"]
3 changes: 2 additions & 1 deletion crates/network/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ impl Network for Ethereum {
type HeaderResponse = alloy_rpc_types::Header;
}

#[async_trait]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl TransactionBuilder<Ethereum> for alloy_rpc_types::TransactionRequest {
fn chain_id(&self) -> Option<alloy_primitives::ChainId> {
self.chain_id
Expand Down
3 changes: 2 additions & 1 deletion crates/network/src/transaction/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ pub type BuilderResult<T, E = TransactionBuilderError> = std::result::Result<T,
///
/// Transaction builders should be able to construct all available transaction types on a given
/// network.
#[async_trait]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait TransactionBuilder<N: Network>: Default + Sized + Send + Sync + 'static {
/// Get the chain ID for the transaction.
fn chain_id(&self) -> Option<ChainId>;
Expand Down
6 changes: 4 additions & 2 deletions crates/network/src/transaction/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ use async_trait::async_trait;

// todo: move
/// A signer capable of signing any transaction for the given network.
#[async_trait]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait NetworkSigner<N: Network>: Sync {
/// Asynchronously sign an unsigned transaction.
async fn sign(&self, tx: N::UnsignedTx) -> alloy_signer::Result<N::TxEnvelope>;
}

// todo: move
/// An async signer capable of signing any [SignableTransaction] for the given [Signature] type.
#[async_trait]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
pub trait TxSigner<Signature> {
/// Asynchronously sign an unsigned transaction.
async fn sign_transaction(
Expand Down

0 comments on commit b3db0fe

Please sign in to comment.