solana-program-library
solana-program-library copied to clipboard
[toekn-cli] Replace `is_valid_pubkey` validator with signer source parser
Problem
In token-cli, there are still some deprecated functions from clap-v2 that should be removed. In particular, we still use input validators, which should be replaced with input parsers.
Summary of Changes
This is a follow-up to https://github.com/solana-labs/solana-program-library/pull/7448. In this PR, I removed all occurrences of the is_valid_pubkey validation function.
Replacing is_valid_pubkey requires two steps.
- Replace
is_valid_pubkeywith eitherSignerSource::default().allow_all().build()orSignerSource::default().allow_pubkey().build()depending on whether we are only parsing pubkey or any signer source. - In the command logic, use
SignerSource::try_get_pubkey(...)to parse the pubkey.
The main commit that applies the steps above is 8d27503. In the previous commits 76f5da8, 58e0441 (I made a mistake in this PR, which I fixed in ae6082d), dc311a7, I did some ground work to update the Config associated functions to use the SignerSource::try_get_pubkey(...).
After this PR, there are still occurrences of is_valid_signer validation function. This will be removed in another follow-up.