use borsh::BorshDeserialize;
use borsh::BorshSerialize;
#[derive(Debug)]
pub struct CancelOrdersByClientIds {
pub market: solana_pubkey::Pubkey,
pub bids: solana_pubkey::Pubkey,
pub asks: solana_pubkey::Pubkey,
pub open_orders: solana_pubkey::Pubkey,
pub owner: solana_pubkey::Pubkey,
pub event_queue: solana_pubkey::Pubkey,
}
impl CancelOrdersByClientIds {
pub fn instruction(
&self,
args: CancelOrdersByClientIdsInstructionArgs,
) -> 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: CancelOrdersByClientIdsInstructionArgs,
remaining_accounts: &[solana_instruction::AccountMeta],
) -> solana_instruction::Instruction {
let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(self.market, false));
accounts.push(solana_instruction::AccountMeta::new(self.bids, false));
accounts.push(solana_instruction::AccountMeta::new(self.asks, false));
accounts.push(solana_instruction::AccountMeta::new(
self.open_orders,
false,
));
accounts.push(solana_instruction::AccountMeta::new(self.owner, true));
accounts.push(solana_instruction::AccountMeta::new(
self.event_queue,
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = borsh::to_vec(&CancelOrdersByClientIdsInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);
solana_instruction::Instruction {
program_id: crate::OPEN_BOOK_DEX_ID,
accounts,
data,
}
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CancelOrdersByClientIdsInstructionData {
discriminator: [u8; 8],
}
impl CancelOrdersByClientIdsInstructionData {
pub fn new() -> Self {
Self {
discriminator: [63, 79, 64, 1, 26, 132, 180, 168],
}
}
}
impl Default for CancelOrdersByClientIdsInstructionData {
fn default() -> Self {
Self::new()
}
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CancelOrdersByClientIdsInstructionArgs {
pub client_ids: [u64; 8],
}
#[derive(Clone, Debug, Default)]
pub struct CancelOrdersByClientIdsBuilder {
market: Option<solana_pubkey::Pubkey>,
bids: Option<solana_pubkey::Pubkey>,
asks: Option<solana_pubkey::Pubkey>,
open_orders: Option<solana_pubkey::Pubkey>,
owner: Option<solana_pubkey::Pubkey>,
event_queue: Option<solana_pubkey::Pubkey>,
client_ids: Option<[u64; 8]>,
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
}
impl CancelOrdersByClientIdsBuilder {
pub fn new() -> Self {
Self::default()
}
#[inline(always)]
pub fn market(&mut self, market: solana_pubkey::Pubkey) -> &mut Self {
self.market = Some(market);
self
}
#[inline(always)]
pub fn bids(&mut self, bids: solana_pubkey::Pubkey) -> &mut Self {
self.bids = Some(bids);
self
}
#[inline(always)]
pub fn asks(&mut self, asks: solana_pubkey::Pubkey) -> &mut Self {
self.asks = Some(asks);
self
}
#[inline(always)]
pub fn open_orders(&mut self, open_orders: solana_pubkey::Pubkey) -> &mut Self {
self.open_orders = Some(open_orders);
self
}
#[inline(always)]
pub fn owner(&mut self, owner: solana_pubkey::Pubkey) -> &mut Self {
self.owner = Some(owner);
self
}
#[inline(always)]
pub fn event_queue(&mut self, event_queue: solana_pubkey::Pubkey) -> &mut Self {
self.event_queue = Some(event_queue);
self
}
#[inline(always)]
pub fn client_ids(&mut self, client_ids: [u64; 8]) -> &mut Self {
self.client_ids = Some(client_ids);
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 = CancelOrdersByClientIds {
market: self.market.expect("market is not set"),
bids: self.bids.expect("bids is not set"),
asks: self.asks.expect("asks is not set"),
open_orders: self.open_orders.expect("open_orders is not set"),
owner: self.owner.expect("owner is not set"),
event_queue: self.event_queue.expect("event_queue is not set"),
};
let args = CancelOrdersByClientIdsInstructionArgs {
client_ids: self.client_ids.clone().expect("client_ids is not set"),
};
accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts)
}
}
pub struct CancelOrdersByClientIdsCpiAccounts<'a, 'b> {
pub market: &'b solana_account_info::AccountInfo<'a>,
pub bids: &'b solana_account_info::AccountInfo<'a>,
pub asks: &'b solana_account_info::AccountInfo<'a>,
pub open_orders: &'b solana_account_info::AccountInfo<'a>,
pub owner: &'b solana_account_info::AccountInfo<'a>,
pub event_queue: &'b solana_account_info::AccountInfo<'a>,
}
pub struct CancelOrdersByClientIdsCpi<'a, 'b> {
pub __program: &'b solana_account_info::AccountInfo<'a>,
pub market: &'b solana_account_info::AccountInfo<'a>,
pub bids: &'b solana_account_info::AccountInfo<'a>,
pub asks: &'b solana_account_info::AccountInfo<'a>,
pub open_orders: &'b solana_account_info::AccountInfo<'a>,
pub owner: &'b solana_account_info::AccountInfo<'a>,
pub event_queue: &'b solana_account_info::AccountInfo<'a>,
pub __args: CancelOrdersByClientIdsInstructionArgs,
}
impl<'a, 'b> CancelOrdersByClientIdsCpi<'a, 'b> {
pub fn new(
program: &'b solana_account_info::AccountInfo<'a>,
accounts: CancelOrdersByClientIdsCpiAccounts<'a, 'b>,
args: CancelOrdersByClientIdsInstructionArgs,
) -> Self {
Self {
__program: program,
market: accounts.market,
bids: accounts.bids,
asks: accounts.asks,
open_orders: accounts.open_orders,
owner: accounts.owner,
event_queue: accounts.event_queue,
__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_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_account_info::AccountInfo<'a>, bool, bool)],
) -> solana_program_entrypoint::ProgramResult {
let mut accounts = Vec::with_capacity(6 + remaining_accounts.len());
accounts.push(solana_instruction::AccountMeta::new(
*self.market.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(*self.bids.key, false));
accounts.push(solana_instruction::AccountMeta::new(*self.asks.key, false));
accounts.push(solana_instruction::AccountMeta::new(
*self.open_orders.key,
false,
));
accounts.push(solana_instruction::AccountMeta::new(*self.owner.key, true));
accounts.push(solana_instruction::AccountMeta::new(
*self.event_queue.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 = borsh::to_vec(&CancelOrdersByClientIdsInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);
let instruction = solana_instruction::Instruction {
program_id: crate::OPEN_BOOK_DEX_ID,
accounts,
data,
};
let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.market.clone());
account_infos.push(self.bids.clone());
account_infos.push(self.asks.clone());
account_infos.push(self.open_orders.clone());
account_infos.push(self.owner.clone());
account_infos.push(self.event_queue.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 CancelOrdersByClientIdsCpiBuilder<'a, 'b> {
instruction: Box<CancelOrdersByClientIdsCpiBuilderInstruction<'a, 'b>>,
}
impl<'a, 'b> CancelOrdersByClientIdsCpiBuilder<'a, 'b> {
pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self {
let instruction = Box::new(CancelOrdersByClientIdsCpiBuilderInstruction {
__program: program,
market: None,
bids: None,
asks: None,
open_orders: None,
owner: None,
event_queue: None,
client_ids: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
}
#[inline(always)]
pub fn market(&mut self, market: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.market = Some(market);
self
}
#[inline(always)]
pub fn bids(&mut self, bids: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.bids = Some(bids);
self
}
#[inline(always)]
pub fn asks(&mut self, asks: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.asks = Some(asks);
self
}
#[inline(always)]
pub fn open_orders(
&mut self,
open_orders: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.open_orders = Some(open_orders);
self
}
#[inline(always)]
pub fn owner(&mut self, owner: &'b solana_account_info::AccountInfo<'a>) -> &mut Self {
self.instruction.owner = Some(owner);
self
}
#[inline(always)]
pub fn event_queue(
&mut self,
event_queue: &'b solana_account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.event_queue = Some(event_queue);
self
}
#[inline(always)]
pub fn client_ids(&mut self, client_ids: [u64; 8]) -> &mut Self {
self.instruction.client_ids = Some(client_ids);
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_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 = CancelOrdersByClientIdsInstructionArgs {
client_ids: self
.instruction
.client_ids
.clone()
.expect("client_ids is not set"),
};
let instruction = CancelOrdersByClientIdsCpi {
__program: self.instruction.__program,
market: self.instruction.market.expect("market is not set"),
bids: self.instruction.bids.expect("bids is not set"),
asks: self.instruction.asks.expect("asks is not set"),
open_orders: self
.instruction
.open_orders
.expect("open_orders is not set"),
owner: self.instruction.owner.expect("owner is not set"),
event_queue: self
.instruction
.event_queue
.expect("event_queue is not set"),
__args: args,
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
&self.instruction.__remaining_accounts,
)
}
}
#[derive(Clone, Debug)]
struct CancelOrdersByClientIdsCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_account_info::AccountInfo<'a>,
market: Option<&'b solana_account_info::AccountInfo<'a>>,
bids: Option<&'b solana_account_info::AccountInfo<'a>>,
asks: Option<&'b solana_account_info::AccountInfo<'a>>,
open_orders: Option<&'b solana_account_info::AccountInfo<'a>>,
owner: Option<&'b solana_account_info::AccountInfo<'a>>,
event_queue: Option<&'b solana_account_info::AccountInfo<'a>>,
client_ids: Option<[u64; 8]>,
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,
}