Skip to content
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(forge): prefer --from if specified for cast call #7218

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions crates/wallets/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,18 @@ of the unlocked account you want to use, or provide the --from flag with the add
Ok(signer)
}

/// Returns the sender address of the signer or `from`.
/// This function preferes the `from` field and may return address different from the configured
klkvr marked this conversation as resolved.
Show resolved Hide resolved
/// signer
/// If from is specified, returns it
/// If from is not specified, but there is a signer configured, returns the signer's address
/// If from is not specified and there is no signer configured, returns zero address
pub async fn sender(&self) -> Address {
if let Ok(signer) = self.signer().await {
if let Some(from) = self.from {
from
} else if let Ok(signer) = self.signer().await {
signer.address().to_alloy()
} else {
self.from.unwrap_or(Address::ZERO)
Address::ZERO
}
}
}
Expand Down
Loading