feat(LocalSigner): add public_key
method to LocalSigner
#2572
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Resolve #2555, by implementing a helper providing a straightforward way to display the public key. See foundry-rs/foundry#10600.
Solution
public_key()
method inLocalSigner
that returns the signer's public key as a hex string prefixed with "0x".public_key()
method.This method is specifically implemented for
LocalSigner<SigningKey>
and leverages itsverifying_key
method to directly obtain the pubkey without the risk of triggering an error. This contrasts with foundry's "cast wallet pubkey" command implementation, which instantiates ak256::SecretKey
.https://github.com/foundry-rs/foundry/blob/365cbb43b67707fdbe594ae212bd7b718079b70f/crates/cast/src/cmd/wallet/mod.rs#L426-L440
PR Checklist