Skip to content

Commit

Permalink
chore: remove async_trait from NetworkWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Aug 20, 2024
1 parent 68c8bfc commit 8080b05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 0 additions & 3 deletions crates/network/src/ethereum/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{Network, NetworkWallet, TxSigner};
use alloy_consensus::{SignableTransaction, TxEnvelope, TypedTransaction};
use alloy_primitives::Address;
use alloy_signer::Signature;
use async_trait::async_trait;
use std::{collections::BTreeMap, sync::Arc};

/// A wallet capable of signing any transaction for the Ethereum network.
Expand Down Expand Up @@ -95,8 +94,6 @@ impl EthereumWallet {
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl<N> NetworkWallet<N> for EthereumWallet
where
N: Network<UnsignedTx = TypedTransaction, TxEnvelope = TxEnvelope>,
Expand Down
19 changes: 10 additions & 9 deletions crates/network/src/transaction/signer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{Network, TransactionBuilder};
use alloy_consensus::SignableTransaction;
use alloy_primitives::Address;
use alloy_signer::{Signer, SignerSync};
use async_trait::async_trait;
use auto_impl::auto_impl;
use futures_utils_wasm::impl_future;
Expand All @@ -15,8 +16,6 @@ use futures_utils_wasm::impl_future;
/// Network wallets are expected to contain one or more signing credentials,
/// keyed by signing address. The default signer address should be used when
/// no specific signer address is specified.
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[auto_impl(&, &mut, Box, Rc, Arc)]
pub trait NetworkWallet<N: Network>: std::fmt::Debug + Send + Sync {
/// Get the default signer address. This address should be used
Expand All @@ -33,11 +32,11 @@ pub trait NetworkWallet<N: Network>: std::fmt::Debug + Send + Sync {
/// Asynchronously sign an unsigned transaction, with a specified
/// credential.
#[doc(alias = "sign_tx_from")]
async fn sign_transaction_from(
fn sign_transaction_from(
&self,
sender: Address,
tx: N::UnsignedTx,
) -> alloy_signer::Result<N::TxEnvelope>;
) -> impl_future!(<Output = alloy_signer::Result<N::TxEnvelope>>);

/// Asynchronously sign an unsigned transaction.
#[doc(alias = "sign_tx")]
Expand All @@ -50,13 +49,15 @@ pub trait NetworkWallet<N: Network>: std::fmt::Debug + Send + Sync {

/// Asynchronously sign a transaction request, using the sender specified
/// in the `from` field.
async fn sign_request(
fn sign_request(
&self,
request: N::TransactionRequest,
) -> alloy_signer::Result<N::TxEnvelope> {
let sender = request.from().unwrap_or_else(|| self.default_signer_address());
let tx = request.build_unsigned().map_err(alloy_signer::Error::other)?;
self.sign_transaction_from(sender, tx).await
) -> impl_future!(<Output = alloy_signer::Result<N::TxEnvelope>>) {
async move {
let sender = request.from().unwrap_or_else(|| self.default_signer_address());
let tx = request.build_unsigned().map_err(alloy_signer::Error::other)?;
self.sign_transaction_from(sender, tx).await
}
}
}

Expand Down

0 comments on commit 8080b05

Please sign in to comment.