Skip to content

Commit

Permalink
update owner_address_arg to use parser instead of validator
Browse files Browse the repository at this point in the history
  • Loading branch information
samkim-crypto committed Nov 16, 2024
1 parent 4f542e3 commit c283f66
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions token/cli/src/clap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,6 @@ impl TryFrom<CliAuthorityType> for AuthorityType {
}

pub fn owner_address_arg<'a>() -> Arg<'a> {
Arg::with_name(OWNER_ADDRESS_ARG.name)
.long(OWNER_ADDRESS_ARG.long)
.takes_value(true)
.value_name("OWNER_ADDRESS")
.validator(|s| is_valid_pubkey(s))
.help(OWNER_ADDRESS_ARG.help)
}

// Temporary function that uses proper parsing to minimize commit size
// TODO: use this to replace `owner_address_arg`
pub fn owner_address_arg_temp<'a>() -> Arg<'a> {
Arg::with_name(OWNER_ADDRESS_ARG.name)
.long(OWNER_ADDRESS_ARG.long)
.takes_value(true)
Expand Down Expand Up @@ -1237,7 +1226,7 @@ pub fn app<'a>(
"Lock the owner of this token account from ever being changed"
),
)
.arg(owner_address_arg_temp())
.arg(owner_address_arg())
.nonce_args(true)
)
.subcommand(
Expand Down Expand Up @@ -1796,7 +1785,7 @@ pub fn app<'a>(
.help("Specify the token account to close \
[default: owner's associated token account]"),
)
.arg(owner_address_arg_temp())
.arg(owner_address_arg())
.arg(multisig_signer_arg())
.nonce_args(true)
.offline_args(),
Expand Down Expand Up @@ -1850,7 +1839,7 @@ pub fn app<'a>(
.required_unless("address")
.help("Token of associated account. To query a specific account, use the `--address` parameter instead"),
)
.arg(owner_address_arg_temp().conflicts_with("address"))
.arg(owner_address_arg().conflicts_with("address"))
.arg(
Arg::with_name("address")
.value_parser(SignerSourceParserBuilder::default().allow_all().build())
Expand Down Expand Up @@ -1914,7 +1903,7 @@ pub fn app<'a>(
"Print token account addresses only"
),
)
.arg(owner_address_arg_temp())
.arg(owner_address_arg())
)
.subcommand(
SubCommand::with_name(CommandName::Address.into())
Expand All @@ -1930,7 +1919,7 @@ pub fn app<'a>(
[Default: return the client keypair address]")
)
.arg(
owner_address_arg_temp()
owner_address_arg()
.requires("token")
.help("Return the associated token address for the given owner. \
[Default: return the associated token address for the client keypair]"),
Expand Down Expand Up @@ -2380,7 +2369,7 @@ pub fn app<'a>(
.required(true)
.help("Specify the address of the account to send lamports to"),
)
.arg(owner_address_arg_temp())
.arg(owner_address_arg())
.arg(multisig_signer_arg())
)
.subcommand(
Expand Down

0 comments on commit c283f66

Please sign in to comment.