Add a simple constructor for Wallet (#1530)

* Add a simple constructor for Wallet

* Update ethers-signers/src/wallet/mod.rs

Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
moh-eulith 2022-07-30 19:01:02 -04:00 committed by GitHub
parent bad81a90d6
commit 7306a3c360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -67,6 +67,14 @@ pub struct Wallet<D: DigestSigner<Sha256Proxy, RecoverableSignature>> {
pub(crate) chain_id: u64, pub(crate) chain_id: u64,
} }
impl<D: DigestSigner<Sha256Proxy, RecoverableSignature>> Wallet<D> {
/// Construct a new wallet with an external Signer
pub fn new_with_signer(signer: D, address: Address, chain_id: u64) -> Self {
Wallet { signer, address, chain_id }
}
}
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] #[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)] #[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl<D: Sync + Send + DigestSigner<Sha256Proxy, RecoverableSignature>> Signer for Wallet<D> { impl<D: Sync + Send + DigestSigner<Sha256Proxy, RecoverableSignature>> Signer for Wallet<D> {