Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit e2d57ff

Browse files
committed
hard-code signer_arg and OfflineArgs
1 parent c376044 commit e2d57ff

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

token/cli/src/clap_app.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,40 @@ pub const COMPUTE_UNIT_LIMIT_ARG: ArgConstant<'static> = ArgConstant {
7878
help: "Set compute unit limit for transaction, in compute units.",
7979
};
8080

81+
// The `signer_arg` in clap-v3-utils` specifies the argument as a `PubkeySignature` type, but
82+
// supporting `PubkeySignature` in the token-cli requires a significant re-structuring of the
83+
// code. Therefore, hard-code the `signer_arg` and `OfflineArgs` from clap-utils` here and remove
84+
// it in a subsequent PR.
85+
fn signer_arg<'a>() -> Arg<'a> {
86+
Arg::new(SIGNER_ARG.name)
87+
.long(SIGNER_ARG.long)
88+
.takes_value(true)
89+
.value_name("PUBKEY=SIGNATURE")
90+
.requires(BLOCKHASH_ARG.name)
91+
.action(clap::ArgAction::Append)
92+
.multiple_values(false)
93+
.help(SIGNER_ARG.help)
94+
}
95+
96+
pub trait OfflineArgs {
97+
fn offline_args(self) -> Self;
98+
fn offline_args_config(self, config: &dyn ArgsConfig) -> Self;
99+
}
100+
101+
impl OfflineArgs for clap::Command<'_> {
102+
fn offline_args_config(self, config: &dyn ArgsConfig) -> Self {
103+
self.arg(config.blockhash_arg(blockhash_arg()))
104+
.arg(config.sign_only_arg(sign_only_arg()))
105+
.arg(config.signer_arg(signer_arg()))
106+
.arg(config.dump_transaction_message_arg(dump_transaction_message()))
107+
}
108+
fn offline_args(self) -> Self {
109+
struct NullArgsConfig {}
110+
impl ArgsConfig for NullArgsConfig {}
111+
self.offline_args_config(&NullArgsConfig {})
112+
}
113+
}
114+
81115
pub static VALID_TOKEN_PROGRAM_IDS: [Pubkey; 2] = [spl_token_2022::ID, spl_token::ID];
82116

83117
#[derive(AsRefStr, Debug, Clone, Copy, PartialEq, EnumString, IntoStaticStr)]

0 commit comments

Comments
 (0)