refactor(tauri, swap): move rpc api to cli/api

This commit is contained in:
binarybaron 2024-08-26 15:40:50 +02:00
parent 5425a83871
commit 349035d321
No known key found for this signature in database
GPG key ID: 99B75D3E1476A26E
15 changed files with 1231 additions and 46 deletions

View file

@ -1,7 +1,7 @@
use std::result::Result;
use std::sync::Arc;
use swap::{
api::{
cli::api::{
request::{
BalanceArgs, BuyXmrArgs, GetHistoryArgs, ResumeSwapArgs, SuspendCurrentSwapArgs,
WithdrawBtcArgs,
@ -25,7 +25,7 @@ impl<T, E: ToString> ToStringResult<T> for Result<T, E> {
/// This macro is used to create boilerplate functions as tauri commands
/// that simply delegate handling to the respective request type.
///
///
/// # Example
/// ```ignored
/// tauri_command!(get_balance, BalanceArgs);
@ -43,8 +43,8 @@ macro_rules! tauri_command {
async fn $fn_name(
context: tauri::State<'_, Arc<Context>>,
args: $request_name,
) -> Result<<$request_name as swap::api::request::Request>::Response, String> {
<$request_name as swap::api::request::Request>::request(args, context.inner().clone())
) -> Result<<$request_name as swap::cli::api::request::Request>::Response, String> {
<$request_name as swap::cli::api::request::Request>::request(args, context.inner().clone())
.await
.to_string_result()
}