[transfer-hook] Remove clap deprecated functions #6952
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 transfer hook 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::with_name
toArg::new
, which is functionally identicalArg::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.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 logic to parse signers directly.I also used
SignerSource::try_get_pubkey
to remove some verbose parsing code (from #6625).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 the other crates in the repo still uses some deprecated functions, so I removed this feature from clap for now.