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

Commit 07450df

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

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

token/cli/src/clap_app.rs

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

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

0 commit comments

Comments
 (0)