forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: wallet import #1
Closed
Closed
Conversation
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
nopestack
reviewed
Jul 26, 2023
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.
1st pass, looks good overall, only a few minor improvements
2d7132a
to
ede2d55
Compare
7897626
to
13ed300
Compare
13ed300
to
215f6f4
Compare
Created the PR into foundry, thanks @nopestack for the guidance |
rplusq
pushed a commit
that referenced
this pull request
Oct 16, 2023
* fuzz single refactor * add struct docs * Update crates/evm/src/fuzz/mod.rs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * add docs and move types to types.rs * fmt * add docki docs * fmt --------- Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
rplusq
pushed a commit
that referenced
this pull request
Oct 16, 2023
* feat: use alloy revm branch * fuzz/mod migrated * progress * progress, fmt * fix imdb * feat: cheatcodes compile * feat: fork backend compiles * feat: trace * fuzz * anvil progress * chore: mem, fmt * chore: db.rs * chore: it lives * fix test * chore: clippy * workin * main backend stuff migrated * chore: add glue on other crates * chore: make executor use alloy types * add glue for executor migration * chore: use workspace alloy * chore: undo revm bump changes * chore: remove unneded prefix * chore: fix fork fixture * chore: uncomment tests * chore: switch to up-to-date revm * chore: clippy * (foundry-rs#2) Alloy Migration: Migrate non-cheatcode inspectors (foundry-rs#5770) * feat: migrate non-cheatcode inspectors * fix: properly create both create and create2 addresses * chore: clippy * (foundry-rs#3) Alloy Migration: migrate fork-adjacent files to alloy primitives (foundry-rs#5771) * chore: use create2_from_code * borrow it brah * chore: use from word * chore: drop to_be_bytes * fmt * chore: use from_word on both palces * chore: use address::random * chore: make failure slot b256 * chore: use address::random * chore: fix indexes * chore: use contract.hash * chore: do not collect * chore: use display on alloy nums * use + operator * chore: unwrap bytes and replace import * chore: Into:: -> ::from * chore: fix test * chore: use alloy imports * chore: switch to alloy typesd * chore: fix test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Intro
Most of the motivation comes from these issues:
Issue#1869
Issue#3818
Big shoutout to @PatrickAlphaC for the proposed API
Summary
If you want to use your own private keys, you are going to either: expose them on the terminal or type them every time through
--interactive
. A great alternative would be to use keystores, but these are limited to random ones created throughcast wallet new PATH
.It would also be good to be able to set some env vars and then forget about that, while also maintaining a high security standard.
Solution
New Features
cast wallet import
Encrypt private keys through JSON keystores into a default directory (
~/.foundry/keystores
) that can later be accessed through their assigned names when usingcast send
,forge create
orforge script
.Which then prompts the user for a password, and encrypts it locally on the default directory.
cast wallet list
Have a command to list stored keystores in the default directory
Changes to the codebase
Extraction of Wallet's Raw Opts
I had to extract the raw options from the
opts/wallet:Wallet
struct. This is cause I wanted to reduce the amount of code duplication, so now I could use that in the use ofcast wallet import
, which really only cares about the handling of mnemonics and private keys.Adding of --account option for MultiWallet and Wallet
In order to leverage the imported keystores by name, I had to create a new option:
--account
orETH_KEYSTORE_ACCOUNT
. This enables to simplify the following command:into the smaller / simpler: