-
Notifications
You must be signed in to change notification settings - Fork 36
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
cli: Fix multisig parsing #72
Conversation
#### Problem As pointed out in solana-program#58, the CLI currently fails when just running `create-account <MINT_ADDRESS>`, because a multisig argument is expected during all commands. Clap v3's version of `values_of` gives an error if the arg is not configured in the command. This was probably missed during the port over to clap v3. #### Summary of changes Do the same thing as elsewhere, and change `values_of` to `try_get_many(...).ok().flatten()`. This is the last place using `values_of` in the CLI that could fail.
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.
Thanks for the fix! I must have missed this while upgrading to clap-v3. The tests seem to fail, but with the suggestion below, it should all pass.
clients/cli/src/config.rs
Outdated
@@ -48,9 +48,9 @@ fn signers_of( | |||
name: &str, | |||
wallet_manager: &mut Option<Rc<RemoteWalletManager>>, | |||
) -> Result<Option<SignersOf>, Box<dyn std::error::Error>> { | |||
if let Some(values) = matches.values_of(name) { | |||
if let Some(values) = matches.try_get_many(name).ok().flatten() { |
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.
if let Some(values) = matches.try_get_many(name).ok().flatten() { | |
if let Some(values) = matches.try_get_many::<String>(name).ok().flatten() { |
In clap-v3, we generally always have to specify the type that we are parsing for. We should parse this to a proper type rather than a String
, but that will require update the updating the validation function is_valid_signer
, which will follow after solana-labs/solana-program-library#7447. So let's just update it to String
here for now.
clients/cli/src/config.rs
Outdated
let mut results = Vec::new(); | ||
for (i, value) in values.enumerate() { | ||
for (i, value) in values.copied().enumerate() { |
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.
for (i, value) in values.copied().enumerate() { | |
for (i, value) in values.enumerate() { |
We are parsing for an owned String
type, so we can remove the copied()
.
Ok great, thanks for the suggestions -- this should be good for another look! |
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.
Looks good to me!
Problem
As pointed out in #58, the CLI currently fails when just running
create-account <MINT_ADDRESS>
, because a multisig argument is expected during all commands. Clap v3's version ofvalues_of
gives an error if the arg is not configured in the command.This was probably missed during the port over to clap v3.
Summary of changes
Do the same thing as elsewhere, and change
values_of
totry_get_many(...).ok().flatten()
.This is the last place using
values_of
in the CLI that could fail.Closes #58