From 19635576ce8d8649da5fbd3e55ea67dc9dac20f1 Mon Sep 17 00:00:00 2001 From: Evan Batsell Date: Fri, 1 Nov 2024 12:01:26 -0400 Subject: [PATCH] Cli --- cli/src/vault.rs | 2 ++ cli/src/vault_handler.rs | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/cli/src/vault.rs b/cli/src/vault.rs index bfe7b900..5fa24e37 100644 --- a/cli/src/vault.rs +++ b/cli/src/vault.rs @@ -29,6 +29,8 @@ pub enum ConfigActions { /// The new admin's pubkey new_admin: Pubkey, }, + /// Set the config program fee wallet + SetProgramFeeWallet, } /// Vault commands diff --git a/cli/src/vault_handler.rs b/cli/src/vault_handler.rs index d2070f49..7b715b94 100644 --- a/cli/src/vault_handler.rs +++ b/cli/src/vault_handler.rs @@ -9,7 +9,8 @@ use jito_vault_client::{ CooldownDelegationBuilder, CrankVaultUpdateStateTrackerBuilder, CreateTokenMetadataBuilder, EnqueueWithdrawalBuilder, InitializeConfigBuilder, InitializeVaultBuilder, InitializeVaultOperatorDelegationBuilder, InitializeVaultUpdateStateTrackerBuilder, - MintToBuilder, SetConfigAdminBuilder, SetDepositCapacityBuilder, + MintToBuilder, SetConfigAdminBuilder, SetConfigProgramFeeWalletBuilder, + SetDepositCapacityBuilder, }, types::WithdrawalAllocationMethod, }; @@ -81,6 +82,9 @@ impl VaultCliHandler { VaultCommands::Config { action: ConfigActions::SetAdmin { new_admin }, } => self.set_config_admin(new_admin).await, + VaultCommands::Config { + action: ConfigActions::SetProgramFeeWallet, + } => self.set_config_program_fee_wallet().await, VaultCommands::Vault { action: VaultActions::Initialize { @@ -1117,4 +1121,33 @@ impl VaultCliHandler { info!("Transaction confirmed: {:?}", tx.get_signature()); Ok(()) } + + async fn set_config_program_fee_wallet(&self) -> Result<()> { + let keypair = self + .cli_config + .keypair + .as_ref() + .ok_or_else(|| anyhow!("Keypair not provided"))?; + let rpc_client = self.get_rpc_client(); + + let config_address = Config::find_program_address(&self.vault_program_id).0; + let mut ix_builder = SetConfigProgramFeeWalletBuilder::new(); + ix_builder.config(config_address); + + let blockhash = rpc_client.get_latest_blockhash().await?; + let tx = Transaction::new_signed_with_payer( + &[ix_builder.instruction()], + Some(&keypair.pubkey()), + &[keypair], + blockhash, + ); + + info!( + "Setting config program fee wallet transaction: {:?}", + tx.get_signature() + ); + rpc_client.send_and_confirm_transaction(&tx).await?; + info!("Transaction confirmed: {:?}", tx.get_signature()); + Ok(()) + } }