-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
165 additions
and
106 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[package] | ||
name = "foundry-wallets" | ||
|
||
version.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
alloy-primitives.workspace = true | ||
|
||
ethers-core.workspace = true | ||
ethers-providers.workspace = true | ||
ethers-signers = { workspace = true, features = ["aws", "ledger", "trezor"] } | ||
|
||
rusoto_core = { version = "0.48", default-features = false } | ||
rusoto_kms = { version = "0.48", default-features = false } | ||
|
||
foundry-config.workspace = true | ||
foundry-common.workspace = true | ||
|
||
async-trait = "0.1" | ||
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } | ||
eyre.workspace = true | ||
hex = { workspace = true, features = ["serde"] } | ||
itertools.workspace = true | ||
rpassword = "7" | ||
serde.workspace = true | ||
thiserror = "1" | ||
tracing.workspace = true | ||
|
||
[features] | ||
default = ["rustls"] | ||
rustls = ["ethers-providers/rustls", "rusoto_core/rustls"] | ||
openssl = ["ethers-providers/openssl"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use ethers_signers::{AwsSignerError, LedgerError, TrezorError, WalletError}; | ||
use hex::FromHexError; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum PrivateKeyError { | ||
#[error("Failed to create wallet from private key. Private key is invalid hex: {0}")] | ||
InvalidHex(#[from] FromHexError), | ||
#[error("Failed to create wallet from private key. Invalid private key. But env var {0} exists. Is the `$` anchor missing?")] | ||
ExistsAsEnvVar(String), | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum WalletSignerError { | ||
#[error(transparent)] | ||
Local(#[from] WalletError), | ||
#[error(transparent)] | ||
Ledger(#[from] LedgerError), | ||
#[error(transparent)] | ||
Trezor(#[from] TrezorError), | ||
#[error(transparent)] | ||
Aws(#[from] AwsSignerError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#[macro_use] | ||
extern crate tracing; | ||
|
||
pub mod error; | ||
pub mod multi_wallet; | ||
pub mod raw_wallet; | ||
pub mod wallet; | ||
|
||
pub use multi_wallet::MultiWallet; | ||
pub use raw_wallet::RawWallet; | ||
pub use wallet::{Wallet, WalletSigner}; |
2 changes: 1 addition & 1 deletion
2
crates/cli/src/opts/wallet/multi_wallet.rs → crates/wallets/src/multi_wallet.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use clap::Parser; | ||
use serde::Serialize; | ||
|
||
/// A wrapper for the raw data options for `Wallet`, extracted to also be used standalone. | ||
/// The raw wallet options can either be: | ||
/// 1. Private Key (cleartext in CLI) | ||
/// 2. Private Key (interactively via secure prompt) | ||
/// 3. Mnemonic (via file path) | ||
#[derive(Clone, Debug, Default, Serialize, Parser)] | ||
#[clap(next_help_heading = "Wallet options - raw", about = None, long_about = None)] | ||
pub struct RawWallet { | ||
/// Open an interactive prompt to enter your private key. | ||
#[clap(long, short)] | ||
pub interactive: bool, | ||
|
||
/// Use the provided private key. | ||
#[clap(long, value_name = "RAW_PRIVATE_KEY")] | ||
pub private_key: Option<String>, | ||
|
||
/// Use the mnemonic phrase of mnemonic file at the specified path. | ||
#[clap(long, alias = "mnemonic-path")] | ||
pub mnemonic: Option<String>, | ||
|
||
/// Use a BIP39 passphrase for the mnemonic. | ||
#[clap(long, value_name = "PASSPHRASE")] | ||
pub mnemonic_passphrase: Option<String>, | ||
|
||
/// The wallet derivation path. | ||
/// | ||
/// Works with both --mnemonic-path and hardware wallets. | ||
#[clap(long = "mnemonic-derivation-path", alias = "hd-path", value_name = "PATH")] | ||
pub hd_path: Option<String>, | ||
|
||
/// Use the private key from the given mnemonic index. | ||
/// | ||
/// Used with --mnemonic-path. | ||
#[clap(long, conflicts_with = "hd_path", default_value_t = 0, value_name = "INDEX")] | ||
pub mnemonic_index: u32, | ||
} |
Oops, something went wrong.