use crate::generated::types::FeeConfig;
use solana_address::Address;
use borsh::BorshSerialize;
use borsh::BorshDeserialize;
pub const UPDATE_MARKETPLACE_CONFIG_DISCRIMINATOR: [u8; 8] = [255, 146, 152, 33, 80, 216, 160, 144];
#[derive(Debug)]
pub struct UpdateMarketplaceConfig {
pub marketplace_authority: solana_address::Address,
pub marketplace_config: solana_address::Address,
pub system_program: solana_address::Address,
pub rent: solana_address::Address,
}
impl UpdateMarketplaceConfig {
pub fn instruction(&self, args: UpdateMarketplaceConfigInstructionArgs) -> solana_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: UpdateMarketplaceConfigInstructionArgs, remaining_accounts: &[solana_instruction::AccountMeta]) -> solana_instruction::Instruction {
let mut accounts = Vec::with_capacity(4+ remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
self.marketplace_authority,
true
));
accounts.push(solana_instruction::AccountMeta::new(
self.marketplace_config,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.system_program,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
self.rent,
false
));
accounts.extend_from_slice(remaining_accounts);
let mut data = UpdateMarketplaceConfigInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
data.append(&mut args);
solana_instruction::Instruction {
program_id: crate::MALLOW_AUCTION_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
pub struct UpdateMarketplaceConfigInstructionData {
discriminator: [u8; 8],
}
impl UpdateMarketplaceConfigInstructionData {
pub fn new() -> Self {
Self {
discriminator: [255, 146, 152, 33, 80, 216, 160, 144],
}
}
pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
borsh::to_vec(self)
}
}
impl Default for UpdateMarketplaceConfigInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
pub struct UpdateMarketplaceConfigInstructionArgs {
pub fee_config: FeeConfig,
pub rewards_config: Address,
}
impl UpdateMarketplaceConfigInstructionArgs {
pub(crate) fn try_to_vec(&self) -> Result<Vec<u8>, std::io::Error> {
borsh::to_vec(self)
}
}
#[derive(Clone, Debug, Default)]
pub struct UpdateMarketplaceConfigBuilder {
marketplace_authority: Option<solana_address::Address>,
marketplace_config: Option<solana_address::Address>,
system_program: Option<solana_address::Address>,
rent: Option<solana_address::Address>,
fee_config: Option<FeeConfig>,
rewards_config: Option<Address>,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl UpdateMarketplaceConfigBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn marketplace_authority(&mut self, marketplace_authority: solana_address::Address) -> &mut Self {
self.marketplace_authority = Some(marketplace_authority);
self
}
#[inline(always)]
pub fn marketplace_config(&mut self, marketplace_config: solana_address::Address) -> &mut Self {
self.marketplace_config = Some(marketplace_config);
self
}
#[inline(always)]
pub fn system_program(&mut self, system_program: solana_address::Address) -> &mut Self {
self.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn rent(&mut self, rent: solana_address::Address) -> &mut Self {
self.rent = Some(rent);
self
}
#[inline(always)]
pub fn fee_config(&mut self, fee_config: FeeConfig) -> &mut Self {
self.fee_config = Some(fee_config);
self
}
#[inline(always)]
pub fn rewards_config(&mut self, rewards_config: Address) -> &mut Self {
self.rewards_config = Some(rewards_config);
self
}
#[inline(always)]
pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self {
self.__remaining_accounts.push(account);
self
}
#[inline(always)]
pub fn add_remaining_accounts(&mut self, accounts: &[solana_instruction::AccountMeta]) -> &mut Self {
self.__remaining_accounts.extend_from_slice(accounts);
self
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let accounts = UpdateMarketplaceConfig {
marketplace_authority: self.marketplace_authority.unwrap_or(solana_address::address!("AUTH8n3RY3JH38j19r1TrZi88zf5pUnAGh4tFkhcnptZ")),
marketplace_config: self.marketplace_config.expect("marketplace_config is not set"),
system_program: self.system_program.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
rent: self.rent.unwrap_or(solana_address::address!("SysvarRent111111111111111111111111111111111")),
};
let args = UpdateMarketplaceConfigInstructionArgs {
fee_config: self.fee_config.clone().expect("fee_config is not set"),
rewards_config: self.rewards_config.clone().expect("rewards_config is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct UpdateMarketplaceConfigCpiAccounts<'a, 'b> {
pub marketplace_authority: &'b solana_account_info::AccountInfo<'a>,
pub marketplace_config: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub rent: &'b solana_account_info::AccountInfo<'a>,
}
pub struct UpdateMarketplaceConfigCpi<'a, 'b> {
pub __program: &'b solana_account_info::AccountInfo<'a>,
pub marketplace_authority: &'b solana_account_info::AccountInfo<'a>,
pub marketplace_config: &'b solana_account_info::AccountInfo<'a>,
pub system_program: &'b solana_account_info::AccountInfo<'a>,
pub rent: &'b solana_account_info::AccountInfo<'a>,
pub __args: UpdateMarketplaceConfigInstructionArgs,
}
impl<'a, 'b> UpdateMarketplaceConfigCpi<'a, 'b> {
pub fn new(
program: &'b solana_account_info::AccountInfo<'a>,
accounts: UpdateMarketplaceConfigCpiAccounts<'a, 'b>,
args: UpdateMarketplaceConfigInstructionArgs,
) -> Self {
Self {
__program: program,
marketplace_authority: accounts.marketplace_authority,
marketplace_config: accounts.marketplace_config,
system_program: accounts.system_program,
rent: accounts.rent,
__args: args,
}
}
#[inline(always)]
pub fn invoke(&self) -> solana_program_error::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], &[])
}
#[inline(always)]
pub fn invoke_with_remaining_accounts(&self, remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)]) -> solana_program_error::ProgramResult {
self.invoke_signed_with_remaining_accounts(&[], remaining_accounts)
}
#[inline(always)]
pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::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_account_info::AccountInfo<'a>, bool, bool)]
) -> solana_program_error::ProgramResult {
let mut accounts = Vec::with_capacity(4+ remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
*self.marketplace_authority.key,
true
));
accounts.push(solana_instruction::AccountMeta::new(
*self.marketplace_config.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.system_program.key,
false
));
accounts.push(solana_instruction::AccountMeta::new_readonly(
*self.rent.key,
false
));
remaining_accounts.iter().for_each(|remaining_account| {
accounts.push(solana_instruction::AccountMeta {
pubkey: *remaining_account.0.key,
is_signer: remaining_account.1,
is_writable: remaining_account.2,
})
});
let mut data = UpdateMarketplaceConfigInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
data.append(&mut args);
let instruction = solana_instruction::Instruction {
program_id: crate::MALLOW_AUCTION_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.marketplace_authority.clone());
account_infos.push(self.marketplace_config.clone());
account_infos.push(self.system_program.clone());
account_infos.push(self.rent.clone());
remaining_accounts.iter().for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
if signers_seeds.is_empty() {
solana_cpi::invoke(&instruction, &account_infos)
} else {
solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds)
}
}
}
#[derive(Clone, Debug)]
pub struct UpdateMarketplaceConfigCpiBuilder<'a, 'b> {
instruction: Box<UpdateMarketplaceConfigCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> UpdateMarketplaceConfigCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(UpdateMarketplaceConfigCpiBuilderInstruction {
__program: program,
marketplace_authority: None,
marketplace_config: None,
system_program: None,
rent: None,
fee_config: None,
rewards_config: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn marketplace_authority(&mut self, marketplace_authority: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.marketplace_authority = Some(marketplace_authority);
self
}
#[inline(always)]
pub fn marketplace_config(&mut self, marketplace_config: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.marketplace_config = Some(marketplace_config);
self
}
#[inline(always)]
pub fn system_program(&mut self, system_program: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.system_program = Some(system_program);
self
}
#[inline(always)]
pub fn rent(&mut self, rent: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.rent = Some(rent);
self
}
#[inline(always)]
pub fn fee_config(&mut self, fee_config: FeeConfig) -> &mut Self {
self.instruction.fee_config = Some(fee_config);
self
}
#[inline(always)]
pub fn rewards_config(&mut self, rewards_config: Address) -> &mut Self {
self.instruction.rewards_config = Some(rewards_config);
self
}
#[inline(always)]
pub fn add_remaining_account(&mut self, account: &'b solana_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_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_error::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_error::ProgramResult {
let args = UpdateMarketplaceConfigInstructionArgs {
fee_config: self.instruction.fee_config.clone().expect("fee_config is not set"),
rewards_config: self.instruction.rewards_config.clone().expect("rewards_config is not set"),
};
let instruction = UpdateMarketplaceConfigCpi {
__program: self.instruction.__program,
marketplace_authority: self.instruction.marketplace_authority.expect("marketplace_authority is not set"),
marketplace_config: self.instruction.marketplace_config.expect("marketplace_config is not set"),
system_program: self.instruction.system_program.expect("system_program is not set"),
rent: self.instruction.rent.expect("rent is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(signers_seeds, &self.instruction.__remaining_accounts)
}
}
#[derive(Clone, Debug)]
struct UpdateMarketplaceConfigCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_account_info::AccountInfo<'a>,
marketplace_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
marketplace_config: Option<&'b solana_account_info::AccountInfo<'a>>,
system_program: Option<&'b solana_account_info::AccountInfo<'a>>,
rent: Option<&'b solana_account_info::AccountInfo<'a>>,
fee_config: Option<FeeConfig>,
rewards_config: Option<Address>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}