-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Wallet Create CLI manager integration #11331
Wallet Create CLI manager integration #11331
Conversation
* Wallet recover CLI Manager migration * bazel run //:gazelle -- fix * fix lint and build errors * add TODO to remove duplicate code Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* Wallet recover CLI Manager migration * bazel run //:gazelle -- fix * fix lint and build errors * add TODO to remove duplicate code Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
cmd/validator/wallet/create.go
Outdated
} | ||
|
||
// ExtractWalletCreationConfigFromCli prompts the user for wallet creation input. | ||
func ExtractWalletCreationConfigFromCli(cliCtx *cli.Context, keymanagerKind keymanager.Kind) ([]accounts.Option, 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.
is there a better name for this now that you have refactored it to return account options?
other code is super nice to see, not seeing the cli used in the accounts package looks great!
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.
nice, good point! I changed it to ConstructCLIManagerOpts
!
thanks!
What type of PR is this?
Refactor/code health
What does this PR do? Why is it needed?
This PR addresses the wallet create functionality and refactors it as part of #9883. It follows up on #10554, #10686, #10824, #10841, #10890, #11136, #11278 which do similar migration for the accounts list, delete, backup, exit, import and wallet edit, recover.
This is a bit of a bigger PR, but I think closes out the refactor nicely!!!
cmd/validator/accounts/{backup_test.go, delete_test.go, exit_test.go, import_test.go}
. These files all made use of theaccounts.CreateWalletWithKeymanager
function, which was in theaccounts/wallet_create.go
file. Since we are moving the wallet creation functionality to a member function on a accounts CLI manager object, we need to replace each of these function calls with constructing a new CLI manager and callingacc.WalletCreate
. We construct each of them just with the wallet directory, the keymanager type, and the password.cmd/validator/accounts/import.go
. This was a little tricky, because this file made use of theExtractWalletCreationConfigFromCli
functions which was also defined in thevalidator/accounts
package. However, we were aiming at removing all the clictx objects from that directory. Additionally, this file only used the function to extract the wallet dir and password (rather than needing all of the other logic fromExtractWalletCreationConfigFromCli
. So I created a new functionExtractWalletDirPassword
which just extracts the wallet dir and password from the CLI. This function is also used in thecmd/validator/wallet/create_test.go
.cmd/validator/wallet/create.go
. This is a new file that parses the CLI flags and constructs the CLI manager with the appropriate options. On the CLI manager, it simply calls theWalletCreate
method with thecontext.Context
(no longer a need for thecli.Context
). I refactoredExtractWalletCreationConfigFromCli
to return a slice ofOption
objects that we use to construct the CLI manager.cmd/validator/wallet/create_test.go
. This is just a moving of thevalidator/accounts/wallet_create_test.go
file into thecmd/validator/wallet
directory.validator/accounts/cli_manager.go
andvalidator/accounts/cli_options.go
. I added two new options that the wallet create function depends on:keymanagerKind, skipMnemonicConfirm
.validator/accounts/wallet_create.go
. This is where we see the benefit of this refactor. We chop out all the CLI parsing stuff from theCreateAndSaveWalletCli
function, and make it theWalletCreate
method on the AccountsCLIManager pointer receiver.Which issues(s) does this PR fix?
This is part of the keymanager refactor defined in #9883.
It is also described in #10339.