From effdb23b8ff759f32205e3bdc3e65dfdbe93f6a2 Mon Sep 17 00:00:00 2001 From: tonton-sol <19677766+tonton-sol@users.noreply.github.com> Date: Sun, 31 Mar 2024 09:39:37 -0400 Subject: [PATCH 1/6] removed allow deprecated --- token/transfer-hook/cli/src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/token/transfer-hook/cli/src/main.rs b/token/transfer-hook/cli/src/main.rs index 237b47e2ac2..010bf710547 100644 --- a/token/transfer-hook/cli/src/main.rs +++ b/token/transfer-hook/cli/src/main.rs @@ -1,5 +1,3 @@ -#![allow(deprecated)] - pub mod meta; use { From 8aa347b64aaae72403459e63dea2d208cd66191f Mon Sep 17 00:00:00 2001 From: tonton-sol <19677766+tonton-sol@users.noreply.github.com> Date: Sun, 31 Mar 2024 10:43:44 -0400 Subject: [PATCH 2/6] remove deprecated validators --- token/transfer-hook/cli/src/main.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/token/transfer-hook/cli/src/main.rs b/token/transfer-hook/cli/src/main.rs index 010bf710547..b804ad28991 100644 --- a/token/transfer-hook/cli/src/main.rs +++ b/token/transfer-hook/cli/src/main.rs @@ -4,8 +4,10 @@ use { crate::meta::parse_transfer_hook_account_arg, clap::{crate_description, crate_name, crate_version, Arg, Command}, solana_clap_v3_utils::{ - input_parsers::{parse_url_or_moniker, pubkey_of_signer}, - input_validators::{is_valid_pubkey, is_valid_signer, normalize_to_url_if_moniker}, + input_parsers::{ + parse_url_or_moniker, pubkey_of_signer, signer::SignerSourceParserBuilder, + }, + input_validators::normalize_to_url_if_moniker, keypair::DefaultSigner, }, solana_client::nonblocking::rpc_client::RpcClient, @@ -26,10 +28,6 @@ use { std::{process::exit, rc::Rc}, }; -fn clap_is_valid_pubkey(arg: &str) -> Result<(), String> { - is_valid_pubkey(arg) -} - // Helper function to calculate the required lamports for rent async fn calculate_rent_lamports( rpc_client: &RpcClient, @@ -207,7 +205,7 @@ async fn main() -> Result<(), Box> { Arg::new("fee_payer") .long("fee-payer") .value_name("KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .global(true) .help("Filepath or URL to a keypair to pay transaction fee [default: client keypair]"), @@ -235,7 +233,7 @@ async fn main() -> Result<(), Box> { .about("Create the extra account metas account for a transfer hook program") .arg( Arg::with_name("program_id") - .validator(clap_is_valid_pubkey) + .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TRANSFER_HOOK_PROGRAM") .takes_value(true) .index(1) @@ -244,7 +242,7 @@ async fn main() -> Result<(), Box> { ) .arg( Arg::with_name("token") - .validator(clap_is_valid_pubkey) + .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TOKEN_MINT_ADDRESS") .takes_value(true) .index(2) @@ -308,7 +306,7 @@ extraMetas: Arg::new("mint_authority") .long("mint-authority") .value_name("KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .global(true) .help("Filepath or URL to mint-authority keypair [default: client keypair]"), @@ -319,7 +317,7 @@ extraMetas: .about("Update the extra account metas account for a transfer hook program") .arg( Arg::with_name("program_id") - .validator(clap_is_valid_pubkey) + .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TRANSFER_HOOK_PROGRAM") .takes_value(true) .index(1) @@ -328,7 +326,7 @@ extraMetas: ) .arg( Arg::with_name("token") - .validator(clap_is_valid_pubkey) + .value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build()) .value_name("TOKEN_MINT_ADDRESS") .takes_value(true) .index(2) @@ -392,7 +390,7 @@ extraMetas: Arg::new("mint_authority") .long("mint-authority") .value_name("KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .global(true) .help("Filepath or URL to mint-authority keypair [default: client keypair]"), From 03a97dbb3308f7d01734773ac8a175ecd8a5e35a Mon Sep 17 00:00:00 2001 From: tonton-sol <19677766+tonton-sol@users.noreply.github.com> Date: Sun, 31 Mar 2024 10:44:11 -0400 Subject: [PATCH 3/6] spelling --- token/transfer-hook/cli/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/token/transfer-hook/cli/src/main.rs b/token/transfer-hook/cli/src/main.rs index b804ad28991..146507abfd0 100644 --- a/token/transfer-hook/cli/src/main.rs +++ b/token/transfer-hook/cli/src/main.rs @@ -261,7 +261,7 @@ async fn main() -> Result<(), Box> { Additional accounts with known fixed addresses can be passed at the command line in the format ":". The role must be "readonly", "writable". "readonlySigner", or "writableSigner". -Additional acounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: +Additional accounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: ```json { @@ -345,7 +345,7 @@ extraMetas: Additional accounts with known fixed addresses can be passed at the command line in the format ":". The role must be "readonly", "writable". "readonlySigner", or "writableSigner". -Additional acounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: +Additional accounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows: ```json { From 7042352284e4fcbcaaa697c29593abd22db60da1 Mon Sep 17 00:00:00 2001 From: tonton-sol <19677766+tonton-sol@users.noreply.github.com> Date: Sun, 31 Mar 2024 10:54:49 -0400 Subject: [PATCH 4/6] removed dep warning --- token-upgrade/cli/src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/token-upgrade/cli/src/main.rs b/token-upgrade/cli/src/main.rs index 5d710a61f42..24527f778ba 100644 --- a/token-upgrade/cli/src/main.rs +++ b/token-upgrade/cli/src/main.rs @@ -1,5 +1,3 @@ -#![allow(deprecated)] - use { clap::{crate_description, crate_name, crate_version, Arg, Command}, solana_clap_v3_utils::{ From f87a59e4f0c9befd47bfdf3a219199efaf9b9232 Mon Sep 17 00:00:00 2001 From: tonton-sol <19677766+tonton-sol@users.noreply.github.com> Date: Sun, 31 Mar 2024 10:57:48 -0400 Subject: [PATCH 5/6] removed dep clap functions --- token-upgrade/cli/src/main.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/token-upgrade/cli/src/main.rs b/token-upgrade/cli/src/main.rs index 24527f778ba..c72f01fbc3d 100644 --- a/token-upgrade/cli/src/main.rs +++ b/token-upgrade/cli/src/main.rs @@ -1,8 +1,8 @@ use { clap::{crate_description, crate_name, crate_version, Arg, Command}, solana_clap_v3_utils::{ - input_parsers::{parse_url_or_moniker, pubkey_of}, - input_validators::{is_valid_pubkey, is_valid_signer, normalize_to_url_if_moniker}, + input_parsers::{parse_url_or_moniker, pubkey_of, signer::SignerSourceParserBuilder}, + input_validators::normalize_to_url_if_moniker, keypair::{ signer_from_path, signer_from_path_with_config, DefaultSigner, SignerFromPathConfig, }, @@ -223,7 +223,7 @@ async fn main() -> Result<(), Box> { Arg::new("payer") .long("payer") .value_name("KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .global(true) .help("Filepath or URL to a keypair [default: client keypair]"), @@ -250,7 +250,7 @@ async fn main() -> Result<(), Box> { Command::new("create-escrow").about("Create token account for the program escrow") .arg( Arg::new("original_mint") - .validator(|s| is_valid_pubkey(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .value_name("ADDRESS") .required(true) .takes_value(true) @@ -259,7 +259,7 @@ async fn main() -> Result<(), Box> { ) .arg( Arg::new("new_mint") - .validator(|s| is_valid_pubkey(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .value_name("ADDRESS") .required(true) .takes_value(true) @@ -269,7 +269,7 @@ async fn main() -> Result<(), Box> { .arg( Arg::new("account_keypair") .value_name("ACCOUNT_KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .index(3) .help("Specify the account keypair. This may be a keypair file or the ASK keyword. [default: associated token account for escrow authority]"), @@ -279,7 +279,7 @@ async fn main() -> Result<(), Box> { Command::new("exchange").about("Exchange original tokens for new tokens") .arg( Arg::new("original_mint") - .validator(|s| is_valid_pubkey(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .value_name("ADDRESS") .required(true) .takes_value(true) @@ -288,7 +288,7 @@ async fn main() -> Result<(), Box> { ) .arg( Arg::new("new_mint") - .validator(|s| is_valid_pubkey(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .value_name("ADDRESS") .required(true) .takes_value(true) @@ -299,7 +299,7 @@ async fn main() -> Result<(), Box> { Arg::new("owner") .long("owner") .value_name("OWNER_KEYPAIR") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .help("Specify the owner or delegate for the burnt account. This may be a keypair file or the ASK keyword. [default: fee payer]"), ) @@ -307,7 +307,7 @@ async fn main() -> Result<(), Box> { Arg::new("burn_from") .long("burn-from") .value_name("BURN_TOKEN_ACCOUNT_ADDRESS") - .validator(|s| is_valid_pubkey(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .help("Specify the burnt account address. [default: associated token account for owner on original mint]"), ) @@ -315,7 +315,7 @@ async fn main() -> Result<(), Box> { Arg::new("escrow") .long("escrow") .value_name("ESCROW_TOKEN_ACCOUNT_ADDRESS") - .validator(|s| is_valid_pubkey(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .help("Specify the escrow account address to transfer from. [default: associated token account for the escrow authority on new mint]"), ) @@ -323,14 +323,14 @@ async fn main() -> Result<(), Box> { Arg::new("destination") .long("destination") .value_name("DESTINATION_ACCOUNT_ADDRESS") - .validator(|s| is_valid_pubkey(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .takes_value(true) .help("Specify the destination account to receive new tokens. [default: associated token account for owner on new mint]"), ) .arg( Arg::new("multisig_signer") .long("multisig-signer") - .validator(|s| is_valid_signer(s)) + .value_parser(SignerSourceParserBuilder::default().build()) .value_name("MULTISIG_SIGNER") .takes_value(true) .multiple(true) From 39ad92e54107da581880918601c5b06a7f26622c Mon Sep 17 00:00:00 2001 From: tonton-sol <19677766+tonton-sol@users.noreply.github.com> Date: Tue, 2 Apr 2024 09:39:51 -0400 Subject: [PATCH 6/6] added allow_all() to SignerSourceParserBuilder --- token-upgrade/cli/src/main.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/token-upgrade/cli/src/main.rs b/token-upgrade/cli/src/main.rs index c72f01fbc3d..5565effa52a 100644 --- a/token-upgrade/cli/src/main.rs +++ b/token-upgrade/cli/src/main.rs @@ -223,7 +223,7 @@ async fn main() -> Result<(), Box> { Arg::new("payer") .long("payer") .value_name("KEYPAIR") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .global(true) .help("Filepath or URL to a keypair [default: client keypair]"), @@ -250,7 +250,7 @@ async fn main() -> Result<(), Box> { Command::new("create-escrow").about("Create token account for the program escrow") .arg( Arg::new("original_mint") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .value_name("ADDRESS") .required(true) .takes_value(true) @@ -259,7 +259,7 @@ async fn main() -> Result<(), Box> { ) .arg( Arg::new("new_mint") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .value_name("ADDRESS") .required(true) .takes_value(true) @@ -269,7 +269,7 @@ async fn main() -> Result<(), Box> { .arg( Arg::new("account_keypair") .value_name("ACCOUNT_KEYPAIR") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .index(3) .help("Specify the account keypair. This may be a keypair file or the ASK keyword. [default: associated token account for escrow authority]"), @@ -279,7 +279,7 @@ async fn main() -> Result<(), Box> { Command::new("exchange").about("Exchange original tokens for new tokens") .arg( Arg::new("original_mint") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .value_name("ADDRESS") .required(true) .takes_value(true) @@ -288,7 +288,7 @@ async fn main() -> Result<(), Box> { ) .arg( Arg::new("new_mint") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .value_name("ADDRESS") .required(true) .takes_value(true) @@ -299,7 +299,7 @@ async fn main() -> Result<(), Box> { Arg::new("owner") .long("owner") .value_name("OWNER_KEYPAIR") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .help("Specify the owner or delegate for the burnt account. This may be a keypair file or the ASK keyword. [default: fee payer]"), ) @@ -307,7 +307,7 @@ async fn main() -> Result<(), Box> { Arg::new("burn_from") .long("burn-from") .value_name("BURN_TOKEN_ACCOUNT_ADDRESS") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .help("Specify the burnt account address. [default: associated token account for owner on original mint]"), ) @@ -315,7 +315,7 @@ async fn main() -> Result<(), Box> { Arg::new("escrow") .long("escrow") .value_name("ESCROW_TOKEN_ACCOUNT_ADDRESS") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .help("Specify the escrow account address to transfer from. [default: associated token account for the escrow authority on new mint]"), ) @@ -323,14 +323,14 @@ async fn main() -> Result<(), Box> { Arg::new("destination") .long("destination") .value_name("DESTINATION_ACCOUNT_ADDRESS") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .takes_value(true) .help("Specify the destination account to receive new tokens. [default: associated token account for owner on new mint]"), ) .arg( Arg::new("multisig_signer") .long("multisig-signer") - .value_parser(SignerSourceParserBuilder::default().build()) + .value_parser(SignerSourceParserBuilder::default().allow_all().build()) .value_name("MULTISIG_SIGNER") .takes_value(true) .multiple(true)