-
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 edit CLI Manager migration #11136
Wallet edit CLI Manager migration #11136
Conversation
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.
Changes look good and were easy to follow
cmd/validator/wallet/edit.go
Outdated
"github.com/urfave/cli/v2" | ||
) | ||
|
||
func walletEdit(c *cli.Context) 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.
can we call this remote wallet edit or something? wallet is pretty generic if the feature is only really used for the remote keymanager configs, might be kind of confusing in the future. one of the old functions is called edit remote wallet which shows more what it's meant for.
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.
renamed to remoteWalletEdit
! good call, thanks!
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.
LGTM
What type of PR is this?
Refactor/code health
What does this PR do? Why is it needed?
This PR addresses the wallet edit functionality and refactors it as part of #9883. It follows up on #10554, #10686, #10824, #10841, #10890 which do similar migration for the accounts list, delete, backup, exit, and import.
cmd/validator/wallet/edit.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 theWalletEdit
method with thecontext.Context
(no longer a need for thecli.Context
). The options specific to the import functionality are:WithWallet
andWithKeymangerOpts
.cmd/validator/wallet/edit_test.go
. This is the new location the test that was invalidator/accounts/wallet_edit_test.go
. As written, this tests are built for the CLI context interface, so if we are moving the logic for handling to thecmd/validator/wallet
directory, it makes sense to also move the test here. Note that we duplicate a few functions and a struct into this file:setupWalletAndPasswordsDir
,testWalletConfig
, andsetupWalletCtx
. These are defined in different tests in thevalidator/accounts
directory, and thus aren't importable into this package. One weird aside, these functions are actually also defined in thecmd/validator/accounts/delete_test.go
too for the same reason (the test depended on them and couldn't import from test files invalidator/acconts
. When I tried to create a shared library for bothaccounts/delete_test.go
andwallet/edit_test.go
I kept running into the following compile error: https://pastebin.com/2n2VB7Ez. I left a TODO in the code to figure this out to remove the duplication.validator/accounts/wallet_edit.go
. This is where we see the benefit of this refactor. We chop out all the CLI parsing stuff from theEditWalletConfigurationCli
function, and make it theWalletEdit
method on the AccountsCLIManager pointer receiver.validator/accounts/cli_manager.go
andvalidator/accounts/cli_options.go
. I added a new option that the wallet edit function depends on:keymanagerOpts *remote.KeymanagerOpts
.Which issues(s) does this PR fix?
This is part of the keymanager refactor defined in #9883.
It is also described in #10339.