Add fee-payer arg to solana feature activate (#29367)

This commit is contained in:
Tyera 2022-12-22 10:07:56 -07:00 committed by GitHub
parent edd5f6f3be
commit d33129193f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 16 deletions

View File

@ -6,7 +6,7 @@ use {
clap::{App, AppSettings, Arg, ArgMatches, SubCommand},
console::style,
serde::{Deserialize, Serialize},
solana_clap_utils::{input_parsers::*, input_validators::*, keypair::*},
solana_clap_utils::{fee_payer::*, input_parsers::*, input_validators::*, keypair::*},
solana_cli_output::{cli_version::CliVersion, QuietDisplay, VerboseDisplay},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_rpc_client::rpc_client::RpcClient,
@ -42,6 +42,7 @@ pub enum FeatureCliCommand {
Activate {
feature: Pubkey,
force: ForceActivation,
fee_payer: SignerIndex,
},
}
@ -429,7 +430,8 @@ impl FeatureSubCommands for App<'_, '_> {
.hidden(true)
.multiple(true)
.help("Override activation sanity checks. Don't use this flag"),
),
)
.arg(fee_payer_arg()),
),
)
}
@ -453,7 +455,8 @@ pub fn parse_feature_subcommand(
let response = match matches.subcommand() {
("activate", Some(matches)) => {
let (feature_signer, feature) = signer_of(matches, "feature", wallet_manager)?;
let mut signers = vec![default_signer.signer_from_path(matches, wallet_manager)?];
let (fee_payer, fee_payer_pubkey) =
signer_of(matches, FEE_PAYER_ARG.name, wallet_manager)?;
let force = match matches.occurrences_of("force") {
2 => ForceActivation::Yes,
@ -461,14 +464,23 @@ pub fn parse_feature_subcommand(
_ => ForceActivation::No,
};
signers.push(feature_signer.unwrap());
let signer_info = default_signer.generate_unique_signers(
vec![fee_payer, feature_signer],
matches,
wallet_manager,
)?;
let feature = feature.unwrap();
known_feature(&feature)?;
CliCommandInfo {
command: CliCommand::Feature(FeatureCliCommand::Activate { feature, force }),
signers,
command: CliCommand::Feature(FeatureCliCommand::Activate {
feature,
force,
fee_payer: signer_info.index_of(fee_payer_pubkey).unwrap(),
}),
signers: signer_info.signers,
}
}
("status", Some(matches)) => {
@ -506,9 +518,11 @@ pub fn process_feature_subcommand(
features,
display_all,
} => process_status(rpc_client, config, features, *display_all),
FeatureCliCommand::Activate { feature, force } => {
process_activate(rpc_client, config, *feature, *force)
}
FeatureCliCommand::Activate {
feature,
force,
fee_payer,
} => process_activate(rpc_client, config, *feature, *force, *fee_payer),
}
}
@ -843,7 +857,9 @@ fn process_activate(
config: &CliConfig,
feature_id: Pubkey,
force: ForceActivation,
fee_payer: SignerIndex,
) -> ProcessResult {
let fee_payer = config.signers[fee_payer];
let account = rpc_client
.get_multiple_accounts(&[feature_id])?
.into_iter()
@ -874,15 +890,11 @@ fn process_activate(
false,
SpendAmount::Some(rent),
&blockhash,
&config.signers[0].pubkey(),
&fee_payer.pubkey(),
|lamports| {
Message::new(
&feature::activate_with_lamports(
&feature_id,
&config.signers[0].pubkey(),
lamports,
),
Some(&config.signers[0].pubkey()),
&feature::activate_with_lamports(&feature_id, &fee_payer.pubkey(), lamports),
Some(&fee_payer.pubkey()),
)
},
config.commitment,