(
program_id: &Pubkey,
accounts: &[AccountInfo],
instruction_data: &[u8],
)
| 112 | } |
| 113 | |
| 114 | pub(crate) fn process( |
| 115 | program_id: &Pubkey, |
| 116 | accounts: &[AccountInfo], |
| 117 | instruction_data: &[u8], |
| 118 | ) -> ProgramResult { |
| 119 | let params = bytemuck::checked::try_from_bytes(instruction_data) |
| 120 | .map_err(|_| ProgramError::InvalidInstructionData)?; |
| 121 | let accounts = Accounts::parse(program_id, accounts)?; |
| 122 | |
| 123 | let Params { |
| 124 | mut order_id, |
| 125 | mut order_index, |
| 126 | is_client_id, |
| 127 | _padding, |
| 128 | } = params; |
| 129 | |
| 130 | let market_state = DexState::get(accounts.market)?; |
| 131 | let mut user_account_data = accounts.user.data.borrow_mut(); |
| 132 | let mut user_account = accounts.load_user_account(&mut user_account_data)?; |
| 133 | |
| 134 | check_accounts(&market_state, &accounts).unwrap(); |
| 135 | |
| 136 | if *is_client_id { |
| 137 | (order_index, order_id) = user_account |
| 138 | .find_order_id_and_index_by_client_id(order_id) |
| 139 | .unwrap(); |
| 140 | } else { |
| 141 | let order_id_from_index = user_account.read_order(order_index as usize)?.id; |
| 142 | if order_id != order_id_from_index { |
| 143 | msg!("Order id does not match with the order at the given index!"); |
| 144 | return Err(ProgramError::InvalidArgument); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | let invoke_params = asset_agnostic_orderbook::instruction::cancel_order::Params { order_id }; |
| 149 | let invoke_accounts = asset_agnostic_orderbook::instruction::cancel_order::Accounts { |
| 150 | market: accounts.orderbook, |
| 151 | event_queue: accounts.event_queue, |
| 152 | bids: accounts.bids, |
| 153 | asks: accounts.asks, |
| 154 | }; |
| 155 | |
| 156 | let mut order_summary = match asset_agnostic_orderbook::instruction::cancel_order::process::< |
| 157 | CallBackInfo, |
| 158 | >(program_id, invoke_accounts, invoke_params) |
| 159 | { |
| 160 | Err(error) => { |
| 161 | error.print::<AoError>(); |
| 162 | return Err(DexError::AOBError.into()); |
| 163 | } |
| 164 | Ok(s) => s, |
| 165 | }; |
| 166 | let side = get_side_from_order_id(order_id); |
| 167 | |
| 168 | market_state |
| 169 | .unscale_order_summary(&mut order_summary) |
| 170 | .unwrap(); |
| 171 |
nothing calls this directly
no test coverage detected