Trait alloy_network::NetworkWallet

source ·
pub trait NetworkWallet<N: Network>: Debug + Send + Sync {
    // Required methods
    fn default_signer_address(&self) -> Address;
    fn has_signer_for(&self, address: &Address) -> bool;
    fn signer_addresses(&self) -> impl Iterator<Item = Address>;
    fn sign_transaction_from<'life0, 'async_trait>(
        &'life0 self,
        sender: Address,
        tx: N::UnsignedTx,
    ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn sign_transaction(
        &self,
        tx: N::UnsignedTx,
    ) -> impl Send + Future<Output = Result<N::TxEnvelope>> { ... }
    fn sign_request<'life0, 'async_trait>(
        &'life0 self,
        request: N::TransactionRequest,
    ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

A wallet capable of signing any transaction for the given network.

Network crate authors should implement this trait on a type capable of signing any transaction (regardless of signature type) on a given network. Signer crate authors should instead implement TxSigner to signify signing capability for specific signature types.

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.

Required Methods§

source

fn default_signer_address(&self) -> Address

Get the default signer address. This address should be used in NetworkWallet::sign_transaction_from when no specific signer is specified.

source

fn has_signer_for(&self, address: &Address) -> bool

Return true if the signer contains a credential for the given address.

source

fn signer_addresses(&self) -> impl Iterator<Item = Address>

Return an iterator of all signer addresses.

source

fn sign_transaction_from<'life0, 'async_trait>( &'life0 self, sender: Address, tx: N::UnsignedTx, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Asynchronously sign an unsigned transaction, with a specified credential.

Provided Methods§

source

fn sign_transaction( &self, tx: N::UnsignedTx, ) -> impl Send + Future<Output = Result<N::TxEnvelope>>

Asynchronously sign an unsigned transaction.

source

fn sign_request<'life0, 'async_trait>( &'life0 self, request: N::TransactionRequest, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Asynchronously sign a transaction request, using the sender specified in the from field.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, N: Network, T: 'a + NetworkWallet<N> + ?Sized> NetworkWallet<N> for &'a T
where &'a T: Debug + Send + Sync,

source§

fn default_signer_address(&self) -> Address

source§

fn has_signer_for(&self, address: &Address) -> bool

source§

fn signer_addresses(&self) -> impl Iterator<Item = Address>

source§

fn sign_transaction_from<'life0, 'async_trait>( &'life0 self, sender: Address, tx: N::UnsignedTx, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn sign_transaction( &self, tx: N::UnsignedTx, ) -> impl Send + Future<Output = Result<N::TxEnvelope>>

source§

fn sign_request<'life0, 'async_trait>( &'life0 self, request: N::TransactionRequest, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

impl<'a, N: Network, T: 'a + NetworkWallet<N> + ?Sized> NetworkWallet<N> for &'a mut T
where &'a mut T: Debug + Send + Sync,

source§

fn default_signer_address(&self) -> Address

source§

fn has_signer_for(&self, address: &Address) -> bool

source§

fn signer_addresses(&self) -> impl Iterator<Item = Address>

source§

fn sign_transaction_from<'life0, 'async_trait>( &'life0 self, sender: Address, tx: N::UnsignedTx, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn sign_transaction( &self, tx: N::UnsignedTx, ) -> impl Send + Future<Output = Result<N::TxEnvelope>>

source§

fn sign_request<'life0, 'async_trait>( &'life0 self, request: N::TransactionRequest, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

impl<N: Network, T: NetworkWallet<N> + ?Sized> NetworkWallet<N> for Box<T>
where Box<T>: Debug + Send + Sync,

source§

fn default_signer_address(&self) -> Address

source§

fn has_signer_for(&self, address: &Address) -> bool

source§

fn signer_addresses(&self) -> impl Iterator<Item = Address>

source§

fn sign_transaction_from<'life0, 'async_trait>( &'life0 self, sender: Address, tx: N::UnsignedTx, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn sign_transaction( &self, tx: N::UnsignedTx, ) -> impl Send + Future<Output = Result<N::TxEnvelope>>

source§

fn sign_request<'life0, 'async_trait>( &'life0 self, request: N::TransactionRequest, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

impl<N: Network, T: NetworkWallet<N> + ?Sized> NetworkWallet<N> for Rc<T>
where Rc<T>: Debug + Send + Sync,

source§

fn default_signer_address(&self) -> Address

source§

fn has_signer_for(&self, address: &Address) -> bool

source§

fn signer_addresses(&self) -> impl Iterator<Item = Address>

source§

fn sign_transaction_from<'life0, 'async_trait>( &'life0 self, sender: Address, tx: N::UnsignedTx, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn sign_transaction( &self, tx: N::UnsignedTx, ) -> impl Send + Future<Output = Result<N::TxEnvelope>>

source§

fn sign_request<'life0, 'async_trait>( &'life0 self, request: N::TransactionRequest, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

impl<N: Network, T: NetworkWallet<N> + ?Sized> NetworkWallet<N> for Arc<T>
where Arc<T>: Debug + Send + Sync,

source§

fn default_signer_address(&self) -> Address

source§

fn has_signer_for(&self, address: &Address) -> bool

source§

fn signer_addresses(&self) -> impl Iterator<Item = Address>

source§

fn sign_transaction_from<'life0, 'async_trait>( &'life0 self, sender: Address, tx: N::UnsignedTx, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn sign_transaction( &self, tx: N::UnsignedTx, ) -> impl Send + Future<Output = Result<N::TxEnvelope>>

source§

fn sign_request<'life0, 'async_trait>( &'life0 self, request: N::TransactionRequest, ) -> Pin<Box<dyn Future<Output = Result<N::TxEnvelope>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§

source§

impl<N> NetworkWallet<N> for EthereumWallet
where N: Network<UnsignedTx = TypedTransaction, TxEnvelope = TxEnvelope>,