use crate::generated::types::FeeOption;
use solana_program::pubkey::Pubkey;
use borsh::BorshSerialize;
use borsh::BorshDeserialize;
#[derive(Debug)]
pub struct UpdatePaymasterFeeConfig {
pub fee_config: solana_program::pubkey::Pubkey,
pub update_authority: solana_program::pubkey::Pubkey,
}
impl UpdatePaymasterFeeConfig {
pub fn instruction(&self, args: UpdatePaymasterFeeConfigInstructionArgs) -> solana_program::instruction::Instruction {
self.instruction_with_remaining_accounts(args, &[])
}
#[allow(clippy::arithmetic_side_effects)]
#[allow(clippy::vec_init_then_push)]
pub fn instruction_with_remaining_accounts(&self, args: UpdatePaymasterFeeConfigInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta]) -> solana_program::instruction::Instruction {
let mut accounts = Vec::with_capacity(2+ remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
self.fee_config,
false
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.update_authority,
true
));
accounts.extend_from_slice(remaining_accounts);
let mut data = borsh::to_vec(&UpdatePaymasterFeeConfigInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);
solana_program::instruction::Instruction {
program_id: crate::VORTEX_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct UpdatePaymasterFeeConfigInstructionData {
discriminator: [u8; 8],
}
impl UpdatePaymasterFeeConfigInstructionData {
pub fn new() -> Self {
Self {
discriminator: [195, 232, 65, 172, 230, 141, 174, 27],
}
}
}
impl Default for UpdatePaymasterFeeConfigInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct UpdatePaymasterFeeConfigInstructionArgs {
pub fee_option_index: Option<u8>,
pub fee_option: Option<FeeOption>,
pub new_update_authority: Option<Pubkey>,
}
#[derive(Clone, Debug, Default)]
pub struct UpdatePaymasterFeeConfigBuilder {
fee_config: Option<solana_program::pubkey::Pubkey>,
update_authority: Option<solana_program::pubkey::Pubkey>,
fee_option_index: Option<u8>,
fee_option: Option<FeeOption>,
new_update_authority: Option<Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}
impl UpdatePaymasterFeeConfigBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn fee_config(&mut self, fee_config: solana_program::pubkey::Pubkey) -> &mut Self {
self.fee_config = Some(fee_config);
self
}
#[inline(always)]
pub fn update_authority(&mut self, update_authority: solana_program::pubkey::Pubkey) -> &mut Self {
self.update_authority = Some(update_authority);
self
}
#[inline(always)]
pub fn fee_option_index(&mut self, fee_option_index: u8) -> &mut Self {
self.fee_option_index = Some(fee_option_index);
self
}
#[inline(always)]
pub fn fee_option(&mut self, fee_option: FeeOption) -> &mut Self {
self.fee_option = Some(fee_option);
self
}
#[inline(always)]
pub fn new_update_authority(&mut self, new_update_authority: Pubkey) -> &mut Self {
self.new_update_authority = Some(new_update_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 = UpdatePaymasterFeeConfig {
fee_config: self.fee_config.expect("fee_config is not set"),
update_authority: self.update_authority.expect("update_authority is not set"),
};
let args = UpdatePaymasterFeeConfigInstructionArgs {
fee_option_index: self.fee_option_index.clone(),
fee_option: self.fee_option.clone(),
new_update_authority: self.new_update_authority.clone(),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct UpdatePaymasterFeeConfigCpiAccounts<'a, 'b> {
pub fee_config: &'b solana_program::account_info::AccountInfo<'a>,
pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
}
pub struct UpdatePaymasterFeeConfigCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
pub fee_config: &'b solana_program::account_info::AccountInfo<'a>,
pub update_authority: &'b solana_program::account_info::AccountInfo<'a>,
pub __args: UpdatePaymasterFeeConfigInstructionArgs,
}
impl<'a, 'b> UpdatePaymasterFeeConfigCpi<'a, 'b> {
pub fn new(
program: &'b solana_program::account_info::AccountInfo<'a>,
accounts: UpdatePaymasterFeeConfigCpiAccounts<'a, 'b>,
args: UpdatePaymasterFeeConfigInstructionArgs,
) -> Self {
Self {
__program: program,
fee_config: accounts.fee_config,
update_authority: accounts.update_authority,
__args: args,
}
}
#[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::arithmetic_side_effects)]
#[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(2+ remaining_accounts.len());
accounts.push(solana_program::instruction::AccountMeta::new(
*self.fee_config.key,
false
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.update_authority.key,
true
));
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 mut data = borsh::to_vec(&UpdatePaymasterFeeConfigInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);
let instruction = solana_program::instruction::Instruction {
program_id: crate::VORTEX_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.fee_config.clone());
account_infos.push(self.update_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 UpdatePaymasterFeeConfigCpiBuilder<'a, 'b> {
instruction: Box<UpdatePaymasterFeeConfigCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> UpdatePaymasterFeeConfigCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(UpdatePaymasterFeeConfigCpiBuilderInstruction {
__program: program,
fee_config: None,
update_authority: None,
fee_option_index: None,
fee_option: None,
new_update_authority: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn fee_config(&mut self, fee_config: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.fee_config = Some(fee_config);
self
}
#[inline(always)]
pub fn update_authority(&mut self, update_authority: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.update_authority = Some(update_authority);
self
}
#[inline(always)]
pub fn fee_option_index(&mut self, fee_option_index: u8) -> &mut Self {
self.instruction.fee_option_index = Some(fee_option_index);
self
}
#[inline(always)]
pub fn fee_option(&mut self, fee_option: FeeOption) -> &mut Self {
self.instruction.fee_option = Some(fee_option);
self
}
#[inline(always)]
pub fn new_update_authority(&mut self, new_update_authority: Pubkey) -> &mut Self {
self.instruction.new_update_authority = Some(new_update_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 args = UpdatePaymasterFeeConfigInstructionArgs {
fee_option_index: self.instruction.fee_option_index.clone(),
fee_option: self.instruction.fee_option.clone(),
new_update_authority: self.instruction.new_update_authority.clone(),
};
let instruction = UpdatePaymasterFeeConfigCpi {
__program: self.instruction.__program,
fee_config: self.instruction.fee_config.expect("fee_config is not set"),
update_authority: self.instruction.update_authority.expect("update_authority is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
}
}
#[derive(Clone, Debug)]
struct UpdatePaymasterFeeConfigCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
fee_config: Option<&'b solana_program::account_info::AccountInfo<'a>>,
update_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
fee_option_index: Option<u8>,
fee_option: Option<FeeOption>,
new_update_authority: Option<Pubkey>,
__remaining_accounts: Vec<(&'b solana_program::account_info::AccountInfo<'a>, bool, bool)>,
}