Skip to content

Commit

Permalink
Add fee-payer arg to solana feature activate (#29367)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera authored Dec 22, 2022
1 parent edd5f6f commit d331291
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions cli/src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -42,6 +42,7 @@ pub enum FeatureCliCommand {
Activate {
feature: Pubkey,
force: ForceActivation,
fee_payer: SignerIndex,
},
}

Expand Down Expand Up @@ -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()),
),
)
}
Expand All @@ -453,22 +455,32 @@ 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,
1 => ForceActivation::Almost,
_ => 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)) => {
Expand Down Expand Up @@ -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),
}
}

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d331291

Please sign in to comment.