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

chore: remove async_trait from NetworkWallet #1160

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
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
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
18 changes: 9 additions & 9 deletions crates/network/src/transaction/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,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 +31,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 +48,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