-
Notifications
You must be signed in to change notification settings - Fork 245
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
refactor(signers): use signer
for single credentials and wallet
for credential stores
#883
Conversation
…r -> LedgerWallet, GcpSigner -> GcpWallet, AwsSigner stays because it is a single credential mapping to a single public key - not a keyring like Gcp
…unsatisfied trait bounds
signer
for single credentials and wallet
for credential stores
crates/signer-local/src/lib.rs
Outdated
/// A signer instantiated with a locally stored private key. | ||
pub type FilledLocalSigner = LocalSigner<SigningKey>; | ||
|
||
/// A wallet instantiated with a YubiHSM | ||
/// A signer instantiated with a YubiHSM. | ||
#[cfg(feature = "yubihsm")] | ||
pub type YubiWallet = Wallet<yubihsm::ecdsa::Signer<k256::Secp256k1>>; | ||
pub type FilledYubiSigner = LocalSigner<yubihsm::ecdsa::Signer<k256::Secp256k1>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of the Filled*
name, any suggestions @prestwich?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went with PrivateKeySigner
(prev. LocalSigner
) and YubiSigner
for now
hold off on moving the |
/// The wallet's address. | ||
pub struct LocalSigner<C> { | ||
/// The signers' credential. | ||
pub(crate) credential: C, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to inner private_key
as credential
for flexibility, open to changing it
Co-authored-by: DaniPopes <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Co-authored-by: DaniPopes <[email protected]>
Co-authored-by: DaniPopes <[email protected]>
Co-authored-by: DaniPopes <[email protected]>
…r-wallet for backwards compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few things now called wallets that should not have been changed
…sSigner, LedgerWallet -> LedgerSigner
@@ -437,11 +439,17 @@ impl<L, F> ProviderBuilder<L, F, Ethereum> { | |||
let anvil_layer = crate::layers::AnvilLayer::from(f(Default::default())); | |||
let url = anvil_layer.endpoint_url(); | |||
|
|||
let wallet = alloy_signer_wallet::Wallet::from(anvil_layer.instance().keys()[0].clone()); | |||
let default_keys = anvil_layer.instance().keys().to_vec(); | |||
let (default_key, remaining_keys) = default_keys.split_first().expect("no keys available"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prevent panic from having 0 keys when calling on_anvil_with_wallet_and_config
This can panic if the f
function sets accounts to 0. This is not concerning (and is the pre-existing behavior) but we should probably fix it
followup work (not this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests are broken because they iterate over the hashmap in the |
…not retain the insertion order
Will do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* update according to proposed changes alloy-rs/alloy#883 * Trezor|Ledger|Aws wallet -> signer * bump to latest alloy version incl. signer -> wallet commit
…or credential stores (alloy-rs#883) * NetworkSigner -> NetworkWallet * LocalWallet -> LocalSigner, TrezorSigner -> TrezorWallet, LedgerSigner -> LedgerWallet, GcpSigner -> GcpWallet, AwsSigner stays because it is a single credential mapping to a single public key - not a keyring like Gcp * EthereumSigner -> EthereumWallet, SignerFiller -> WalletFiller * start major refactor * signer -> credential * minor fixes, still issue with on_http method cannot be called due to unsatisfied trait bounds * fix tests * signer-(aws|gcp|ledger|trezor) -> wallet-(aws|gcp|ledger|trezor) * update docs * more doc fixes * move wallet implementations into its own block * wallet -> signer, come up with better name than FilledLocalSigner * default MnemonicBuilder to English * fix docs * fix doctests * revert signer -> wallet crate renaming * pull in main fix for rust-tls, fix flag * FilledLocalSigner -> PrivateKeySigner * minor fixes * minor fixes * fix clippy * Update README.md Co-authored-by: DaniPopes <[email protected]> * add private key signer to list * Update crates/signer-local/src/lib.rs Co-authored-by: DaniPopes <[email protected]> * Update crates/signer-local/src/lib.rs Co-authored-by: DaniPopes <[email protected]> * Update crates/signer/README.md Co-authored-by: DaniPopes <[email protected]> * add deprecation notice on LocalWallet and YubiWallet * fix my broken english * TrezorWallet -> TrezorSigner, GcpWallet -> GcpSigner, AwsWallet -> AwsSigner, LedgerWallet -> LedgerSigner * populate wallet with all known default anvil keys * revert, due to the way BTreeMap backing the signer_addresses it does not retain the insertion order * add back multi-key insertion * fix build issues --------- Co-authored-by: DaniPopes <[email protected]>
Motivation
Closes: #575
Related downstream PR: alloy-rs/examples#92
Solution
Current naming of signer types is somewhat confusing. Move to standardize naming by reviewing usage of the words "signer" and "wallet":
Changes:
NetworkSigner
->NetworkWallet
LocalWallet
->LocalSigner
signer-wallet
->signer-local
(note: updated crate name!)LocalSigner<SigningKey>
previously exported asLocalSigner
->PrivateKeySigner
Expected change in syntax:
Major breaking / invasive changes, in the context of @prestwich's request
Renaming of
signer-*
towallet-*
crates is not handled in this PR per comment: #883 (comment)Included deprecation notices where I thought it made sense (and was possible)
Note: @yash-atreya / @zerosnacks / @gakonst requires changes in
alloy-rs/book
/alloy-rs/examples
and examples in public relationsPR Checklist