From d33129193f92153eadaecab50266591dfcd3c8ad Mon Sep 17 00:00:00 2001 From: Tyera Date: Thu, 22 Dec 2022 10:07:56 -0700 Subject: [PATCH] Add fee-payer arg to solana feature activate (#29367) --- cli/src/feature.rs | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/cli/src/feature.rs b/cli/src/feature.rs index c31254cf2f68f8..82d26816fb67f3 100644 --- a/cli/src/feature.rs +++ b/cli/src/feature.rs @@ -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,