diff --git a/staking/cli/src/cli.rs b/staking/cli/src/cli.rs index 174572bd..48600fc0 100644 --- a/staking/cli/src/cli.rs +++ b/staking/cli/src/cli.rs @@ -71,7 +71,7 @@ pub enum Action { )] hermes_url: String, - #[clap(long, default_value = "3u8hJUVTA4jH1wYAyUur7FFZVQ8H635K3tSHHF4ssjQ5")] + #[clap(long, default_value = "HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ")] wormhole: Pubkey, }, InitializePoolRewardCustody {}, @@ -110,6 +110,7 @@ pub enum Action { publisher_caps: Pubkey, }, SaveStakeAccountsSnapshot {}, + CloseAllPublisherCaps {}, } pub enum SignerSource { diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index e6908dfe..e2a4c822 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -250,7 +250,7 @@ pub fn process_transaction( rpc_client: &RpcClient, instructions: &[Instruction], signers: &[&dyn Signer], -) -> Result { +) -> Result> { let mut transaction = Transaction::new_with_payer(instructions, Some(&signers[0].pubkey())); transaction.sign( signers, @@ -275,7 +275,7 @@ pub fn process_transaction( } Err(err) => { println!("transaction err: {err:?}"); - Err(err.get_transaction_error().unwrap()) + Err(err.get_transaction_error()) } } } @@ -870,6 +870,29 @@ pub fn update_y(rpc_client: &RpcClient, signer: &dyn Signer, y: u64) { process_transaction(rpc_client, &[instruction], &[signer]).unwrap(); } +pub fn close_all_publisher_caps(rpc_client: &RpcClient, signer: &dyn Signer) { + rpc_client + .get_program_accounts_with_config( + &publisher_caps::ID, + RpcProgramAccountsConfig { + filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new( + 0, + MemcmpEncodedBytes::Bytes(PublisherCaps::DISCRIMINATOR.to_vec()), + ))]), + account_config: RpcAccountInfoConfig { + encoding: Some(UiAccountEncoding::Base64Zstd), + data_slice: None, + commitment: None, + min_context_slot: None, + }, + with_context: None, + }, + ) + .unwrap() + .into_iter() + .for_each(|(pubkey, _account)| close_publisher_caps(rpc_client, signer, pubkey)); +} + pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { let data: Vec<(Pubkey, DynamicPositionArrayAccount, Pubkey, Pubkey, Pubkey)> = rpc_client .get_program_accounts_with_config( diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index a06c0b9f..df3a6ba0 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -8,6 +8,7 @@ use { Cli, }, instructions::{ + close_all_publisher_caps, close_publisher_caps, create_slash_event, fetch_publisher_caps_and_advance, @@ -97,5 +98,8 @@ fn main() { Action::SaveStakeAccountsSnapshot {} => { save_stake_accounts_snapshot(&rpc_client); } + Action::CloseAllPublisherCaps {} => { + close_all_publisher_caps(&rpc_client, keypair.as_ref()); + } } }