This repository was archived by the owner on Mar 11, 2025. It is now read-only.
[token-upgrade] Remove clap deprecated functions #6951
Merged
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.
Problem
The token-upgrade cli tool still uses some deprecated functions from clap-v2.
Summary
Updated the deprecated functions from clap-v2. Most of the changes should be straightforward:
Arg::multiple
withArgAction::Append
, which should be functionally identicalis_present
withtry_contains_id
. The oldis_present
panics if the arg is not previously known/defined whiletry_contains_id
gives an error. Otherwise, the two functions are identical.try_pubkey_of
withSignerSource::try_get_pubkey
. Thetry_pubkey_of
internally tries to parsePubkey
fromSignerSource
, which unfortunately, solana-clap-v3-utils does not yet support. TheSignerSource::try_get_pubkey
parsesSignerSource
correctly and then extractsPubkey
from it.The only non-trivial change would be replacing
value_of
. This should technically be updated totry_get_one::<T>(...)
orget_one::<T>(...)
, but I replaced it with a convenience functiontry_get_signer
, which was added withsolana-clap-v3-utils 2.0
. I ended up removing the use ofDefaultSigner
and just added the logic to parse signers directly.The feature
deprecated
in clap v3 allows us to toggle warnings from the use of deprecated functions. The deprecated functions are all removed from this crate, but other crates in the repo still uses some deprecated functions, so I removed this feature from clap for now.This is an analogous PR to #6952.