solana-program-library icon indicating copy to clipboard operation
solana-program-library copied to clipboard

[toekn-cli] Replace `is_valid_pubkey` validator with signer source parser

Open samkim-crypto opened this issue 1 year ago • 1 comments

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.

  1. Replace is_valid_pubkey with either SignerSource::default().allow_all().build() or SignerSource::default().allow_pubkey().build() depending on whether we are only parsing pubkey or any signer source.
  2. 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.

samkim-crypto avatar Nov 02 '24 00:11 samkim-crypto