From 8080b054fb6ff0d0540ffad1a6db731a2f5f6b51 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:09:19 +0200 Subject: [PATCH] chore: remove async_trait from NetworkWallet --- crates/network/src/ethereum/wallet.rs | 3 --- crates/network/src/transaction/signer.rs | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/crates/network/src/ethereum/wallet.rs b/crates/network/src/ethereum/wallet.rs index 85df1e9e8b0c..afe22c8440e6 100644 --- a/crates/network/src/ethereum/wallet.rs +++ b/crates/network/src/ethereum/wallet.rs @@ -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. @@ -95,8 +94,6 @@ impl EthereumWallet { } } -#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] -#[cfg_attr(not(target_arch = "wasm32"), async_trait)] impl NetworkWallet for EthereumWallet where N: Network, diff --git a/crates/network/src/transaction/signer.rs b/crates/network/src/transaction/signer.rs index 0c0b960a974e..3d9e14c73348 100644 --- a/crates/network/src/transaction/signer.rs +++ b/crates/network/src/transaction/signer.rs @@ -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; @@ -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: std::fmt::Debug + Send + Sync { /// Get the default signer address. This address should be used @@ -33,11 +32,11 @@ pub trait NetworkWallet: 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; + ) -> impl_future!(>); /// Asynchronously sign an unsigned transaction. #[doc(alias = "sign_tx")] @@ -50,13 +49,15 @@ pub trait NetworkWallet: 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 { - 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!(>) { + 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 + } } }