(
&mut self,
matches: &ArgMatches,
destination_network: DestinationNetwork,
)
| 302 | } |
| 303 | |
| 304 | pub async fn handle_history( |
| 305 | &mut self, |
| 306 | matches: &ArgMatches, |
| 307 | destination_network: DestinationNetwork, |
| 308 | ) -> Response { |
| 309 | let args = vec![ |
| 310 | "DEPOSITOR_PUBLIC_KEY".to_string(), |
| 311 | "WITHDRAWER_CHAIN_ADDRESS".into(), |
| 312 | ]; |
| 313 | let validate_result = match validate(matches, args, destination_network) { |
| 314 | Ok(result) => result, |
| 315 | Err(err) => return err, |
| 316 | }; |
| 317 | let (pubkey, chain_address) = match &validate_result[..] { |
| 318 | [arg1, arg2, ..] => match (arg1, arg2) { |
| 319 | (ArgType::DepositorPublicKey(pubkey), ArgType::ChainAddress(chain_address)) => { |
| 320 | (pubkey, chain_address) |
| 321 | } |
| 322 | _ => unreachable!(), |
| 323 | }, |
| 324 | _ => unreachable!(), |
| 325 | }; |
| 326 | |
| 327 | self.sync().await; |
| 328 | let mut result_depositor = self.client.get_depositor_status(pubkey).await; |
| 329 | let mut result_withdrawer = self |
| 330 | .client |
| 331 | .get_withdrawer_status(chain_address.to_string().as_str()) |
| 332 | .await; |
| 333 | |
| 334 | let result = match (result_depositor.len(), result_withdrawer.len()) { |
| 335 | (0, 0) => vec![], |
| 336 | (0, _) => result_withdrawer, |
| 337 | (_, 0) => result_depositor, |
| 338 | _ => { |
| 339 | result_depositor.append(&mut result_withdrawer); |
| 340 | result_depositor |
| 341 | } |
| 342 | }; |
| 343 | |
| 344 | match result.len() { |
| 345 | len if len > 0 => { |
| 346 | let data = |
| 347 | Some(serde_json::to_value(result).expect("Failed to merge value vector")); |
| 348 | Response::new(ResponseStatus::OK, data) |
| 349 | } |
| 350 | _ => Response::new( |
| 351 | ResponseStatus::NOK("Depositor / Withdrawer not found.".to_string()), |
| 352 | None, |
| 353 | ), |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | pub fn transactions_command() -> Command { |
| 358 | Command::new("transactions") |
no test coverage detected