use borsh::BorshDeserialize;
use borsh::BorshSerialize;
pub struct SetConfigExtensionAuthority {
pub whirlpools_config: solana_program::pubkey::Pubkey,
pub whirlpools_config_extension: solana_program::pubkey::Pubkey,
pub config_extension_authority: solana_program::pubkey::Pubkey,
pub new_config_extension_authority: solana_program::pubkey::Pubkey,
}
impl SetConfigExtensionAuthority {
pub fn instruction(&self) -> solana_program::instruction::Instruction {
self.instruction_with_remaining_accounts(&[])
}
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(&self, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(4+ remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.whirlpools_config,
false
));
accounts.push(solana_program::instruction::AccountMeta::new(
self.whirlpools_config_extension,
false
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.config_extension_authority,
true
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.new_config_extension_authority,
false
));
accounts.extend_from_slice(remaining_accounts);
let data = SetConfigExtensionAuthorityInstructionData::new().try_to_vec().unwrap();
solana_program::instruction::Instruction {
program_id: crate::WHIRLPOOL_ID,
accounts,
data,
}
}
}
#[derive(BorshDeserialize, BorshSerialize)]
pub struct SetConfigExtensionAuthorityInstructionData {
discriminator: [u8; 8],
}
impl SetConfigExtensionAuthorityInstructionData {
pub fn new() -> Self {
Self {
discriminator: [44, 94, 241, 116, 24, 188, 60, 143],
}
}
}
impl Default for SetConfigExtensionAuthorityInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Debug, Default)]
pub struct SetConfigExtensionAuthorityBuilder {
whirlpools_config: Option<solana_program::pubkey::Pubkey>,
whirlpools_config_extension: Option<solana_program::pubkey::Pubkey>,
config_extension_authority: Option<solana_program::pubkey::Pubkey>,
new_config_extension_authority: Option<solana_program::pubkey::Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl SetConfigExtensionAuthorityBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn whirlpools_config(&mut self, whirlpools_config: solana_program::pubkey::Pubkey) -> &mut Self {
self.whirlpools_config = Some(whirlpools_config);
self
}
#[inline(always)]
pub fn whirlpools_config_extension(&mut self, whirlpools_config_extension: solana_program::pubkey::Pubkey) -> &mut Self {
self.whirlpools_config_extension = Some(whirlpools_config_extension);
self
}
#[inline(always)]
pub fn config_extension_authority(&mut self, config_extension_authority: solana_program::pubkey::Pubkey) -> &mut Self {
self.config_extension_authority = Some(config_extension_authority);
self
}
#[inline(always)]
pub fn new_config_extension_authority(&mut self, new_config_extension_authority: solana_program::pubkey::Pubkey) -> &mut Self {
self.new_config_extension_authority = Some(new_config_extension_authority);
self
}
#[inline(always)]
pub fn add_remaining_account(&mut self, account: solana_program::instruction::AccountMeta) -> &mut Self {
self.__remaining_accounts.push(account);
self
}
#[inline(always)]
pub fn add_remaining_accounts(&mut self, accounts: &[solana_program::instruction::AccountMeta]) -> &mut Self {
self.__remaining_accounts.extend_from_slice(accounts);
self
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_program::instruction::Instruction {
let accounts = SetConfigExtensionAuthority {
whirlpools_config: self.whirlpools_config.expect("whirlpools_config is not set"),
whirlpools_config_extension: self.whirlpools_config_extension.expect("whirlpools_config_extension is not set"),
config_extension_authority: self.config_extension_authority.expect("config_extension_authority is not set"),
new_config_extension_authority: self.new_config_extension_authority.expect("new_config_extension_authority is not set"),
};
accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
}
pub struct SetConfigExtensionAuthorityCpiAccounts<'a, 'b> {
pub whirlpools_config: &'b solana_program::account_info::AccountInfo<'a>,
pub whirlpools_config_extension: &'b solana_program::account_info::AccountInfo<'a>,
pub config_extension_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub new_config_extension_authority: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct SetConfigExtensionAuthorityCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub whirlpools_config: &'b solana_program::account_info::AccountInfo<'a>,
pub whirlpools_config_extension: &'b solana_program::account_info::AccountInfo<'a>,
pub config_extension_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub new_config_extension_authority: &'b solana_program::account_info::AccountInfo<'a>,
}
impl<'a, 'b> SetConfigExtensionAuthorityCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: SetConfigExtensionAuthorityCpiAccounts<'a, 'b>,
) -> Self {
Self {
__program: program,
whirlpools_config: accounts.whirlpools_config,
whirlpools_config_extension: accounts.whirlpools_config_extension,
config_extension_authority: accounts.config_extension_authority,
new_config_extension_authority: accounts.new_config_extension_authority,
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed_with_remaining_accounts(signers_seeds, &[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed_with_remaining_accounts(
&self,
signers_seeds: &[&[&[u8]]],
remaining_accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]
) -> solana_program::entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(4+ remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.whirlpools_config.key,
false
));
accounts.push(solana_program::instruction::AccountMeta::new(
*self.whirlpools_config_extension.key,
false
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.config_extension_authority.key,
true
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.new_config_extension_authority.key,
false
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_program::instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_signer: remaining_account.1,
is_writable: remaining_account.2,
})
});
let data = SetConfigExtensionAuthorityInstructionData::new().try_to_vec().unwrap();
let instruction = solana_program::instruction::Instruction {
program_id: crate::WHIRLPOOL_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.whirlpools_config.clone());
account_infos.push(self.whirlpools_config_extension.clone());
account_infos.push(self.config_extension_authority.clone());
account_infos.push(self.new_config_extension_authority.clone());
remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
if signers_seeds.is_empty() {
solana_program::program::invoke(&instruction, &account_infos)
} else {
solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds)
}
}
}
#[derive(Clone, Debug)]
pub struct SetConfigExtensionAuthorityCpiBuilder<'a, 'b> {
instruction: Box<SetConfigExtensionAuthorityCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> SetConfigExtensionAuthorityCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(SetConfigExtensionAuthorityCpiBuilderInstruction {
__program: program,
whirlpools_config: None,
whirlpools_config_extension: None,
config_extension_authority: None,
new_config_extension_authority: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn whirlpools_config(&mut self, whirlpools_config: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.whirlpools_config = Some(whirlpools_config);
self
}
#[inline(always)]
pub fn whirlpools_config_extension(&mut self, whirlpools_config_extension: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.whirlpools_config_extension = Some(whirlpools_config_extension);
self
}
#[inline(always)]
pub fn config_extension_authority(&mut self, config_extension_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.config_extension_authority = Some(config_extension_authority);
self
}
#[inline(always)]
pub fn new_config_extension_authority(&mut self, new_config_extension_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.new_config_extension_authority = Some(new_config_extension_authority);
self
}
#[inline(always)]
pub fn add_remaining_account(&mut self, account: &'b solana_program::account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool) -> &mut Self {
self.instruction.__remaining_accounts.push((account, is_writable, is_signer));
self
}
#[inline(always)]
pub fn add_remaining_accounts(&mut self, accounts: &[(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)]) -> &mut Self {
self.instruction.__remaining_accounts.extend_from_slice(accounts);
self
}
#[inline(always)]
pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult {
self.invoke_signed(&[])
}
#[allow(clippy::clone_on_copy)]
#[allow(clippy::vec_init_then_push)]
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program::entrypoint::ProgramResult {
let instruction = SetConfigExtensionAuthorityCpi {
__program: self.instruction.__program,
whirlpools_config: self.instruction.whirlpools_config.expect("whirlpools_config is not set"),
whirlpools_config_extension: self.instruction.whirlpools_config_extension.expect("whirlpools_config_extension is not set"),
config_extension_authority: self.instruction.config_extension_authority.expect("config_extension_authority is not set"),
new_config_extension_authority: self.instruction.new_config_extension_authority.expect("new_config_extension_authority is not set"),
};
instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
}
}
#[derive(Clone, Debug)]
struct SetConfigExtensionAuthorityCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
whirlpools_config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
whirlpools_config_extension: Option<&'b solana_program::account_info::AccountInfo<'a>>,
config_extension_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
new_config_extension_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
__remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>,
}