-
Notifications
You must be signed in to change notification settings - Fork 249
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
fix(provider): Prevent panic from having 0 keys when calling on_anvil_with_wallet_and_config
#1055
Conversation
crates/provider/src/builder.rs
Outdated
pub fn on_anvil_with_wallet_and_config( | ||
self, | ||
f: impl FnOnce(alloy_node_bindings::Anvil) -> alloy_node_bindings::Anvil, | ||
) -> <JoinFill<F, WalletFiller<alloy_network::EthereumWallet>> as ProviderLayer< | ||
L::Provider, | ||
alloy_transport_http::Http<reqwest::Client>, | ||
>>::Provider | ||
) -> Result< |
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.
I'd like to keep this function and not return a result, but we can add fn try_on_anvil...
for this and on_anvil calls this and unwraps
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.
fixed: bd30ae1
type JoinedEthereumWalletFiller<F> = JoinFill<F, WalletFiller<alloy_network::EthereumWallet>>; | ||
|
||
#[cfg(any(test, feature = "anvil-node"))] | ||
type AnvilProviderResult<T> = Result<T, alloy_node_bindings::anvil::AnvilError>; |
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.
Added these type aliases to avoid clippy error
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.
@mattsse By the way, should we create a type alias for Http<reqwest::Client>
? It appears so many times in this repository and it can cause clippy warnings very complex type used. Consider factoring parts into type definitions
when a type is complex, as in this case.
…l_with_wallet_and_config` (alloy-rs#1055) * node-bindings: Add AnvilError::NoKeysAvailable * prevent panic from having 0 keys * fix the error handlings for `on_anvil_with_wallet` * fix clippy * fix(clippy): Add type alias * Add `try_on_anvil_with_wallet_and_config` and call it in `on_anvil_with_wallet_and_config` * Revert test changes * Fix docs
…l_with_wallet_and_config` (alloy-rs#1055) * node-bindings: Add AnvilError::NoKeysAvailable * prevent panic from having 0 keys * fix the error handlings for `on_anvil_with_wallet` * fix clippy * fix(clippy): Add type alias * Add `try_on_anvil_with_wallet_and_config` and call it in `on_anvil_with_wallet_and_config` * Revert test changes * Fix docs
Motivation
Closes #889.
on_anvil_with_wallet_and_config
can panic if the available key in an anvil instance is 0.Solution
Adds the new error
NoKeysAvailable
toAnvilError
inalloy-node-bindings
and uses it as the error ofon_anvil_with_wallet_and_config
PR Checklist