Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Support monikers in solana-tokens (#29693)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera authored Jan 13, 2023
1 parent 5eab3fb commit 055c6a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 11 additions & 5 deletions tokens/src/arg_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
},
solana_clap_utils::{
input_parsers::{pubkey_of_signer, value_of},
input_validators::{is_amount, is_valid_pubkey, is_valid_signer},
input_validators::{is_amount, is_url_or_moniker, is_valid_pubkey, is_valid_signer},
keypair::{pubkey_from_path, signer_from_path},
},
solana_cli_config::CONFIG_FILE,
Expand All @@ -28,19 +28,25 @@ where
.version(solana_version::version!())
.arg(
Arg::with_name("config_file")
.short("C")
.long("config")
.takes_value(true)
.value_name("FILEPATH")
.default_value(default_config_file)
.help("Config file"),
)
.arg(
Arg::with_name("url")
Arg::with_name("json_rpc_url")
.short("u")
.long("url")
.global(true)
.value_name("URL_OR_MONIKER")
.takes_value(true)
.value_name("URL")
.help("RPC entrypoint address. i.e. http://api.devnet.solana.com"),
.global(true)
.validator(is_url_or_moniker)
.help(
"URL for Solana's JSON RPC or moniker (or their first letter): \
[mainnet-beta, testnet, devnet, localhost]",
),
)
.subcommand(
SubCommand::with_name("distribute-tokens")
Expand Down
3 changes: 2 additions & 1 deletion tokens/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use {
solana_clap_utils::input_validators::normalize_to_url_if_moniker,
solana_cli_config::{Config, CONFIG_FILE},
solana_rpc_client::rpc_client::RpcClient,
solana_tokens::{arg_parser::parse_args, args::Command, commands, spl_token},
Expand Down Expand Up @@ -26,7 +27,7 @@ fn main() -> Result<(), Box<dyn Error>> {
}
Config::default()
};
let json_rpc_url = command_args.url.unwrap_or(config.json_rpc_url);
let json_rpc_url = normalize_to_url_if_moniker(command_args.url.unwrap_or(config.json_rpc_url));
let client = RpcClient::new(json_rpc_url);

let exit = Arc::new(AtomicBool::default());
Expand Down

0 comments on commit 055c6a5

Please sign in to comment.