mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-07-31 02:29:03 -04:00
wip: refactor request.rs to allow type safety
This commit is contained in:
parent
757183e857
commit
472e3a57b3
16 changed files with 955 additions and 743 deletions
15
.zed/settings.json
Normal file
15
.zed/settings.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Folder-specific settings
|
||||
//
|
||||
// For a full list of overridable settings, and general information on folder-specific settings,
|
||||
// see the documentation: https://zed.dev/docs/configuring-zed#folder-specific-settings
|
||||
{
|
||||
"lsp": {
|
||||
"rust-analyzer": {
|
||||
"initialization_options": {
|
||||
"rust": {
|
||||
"analyzerTargetDir": "./src-xmr-btc-swap"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
2
src-xmr-btc-swap/Cargo.lock
generated
2
src-xmr-btc-swap/Cargo.lock
generated
|
@ -6376,6 +6376,7 @@ dependencies = [
|
|||
"directories-next",
|
||||
"ecdsa_fun",
|
||||
"ed25519-dalek",
|
||||
"erased-serde",
|
||||
"futures",
|
||||
"get-port",
|
||||
"hex",
|
||||
|
@ -7629,6 +7630,7 @@ dependencies = [
|
|||
name = "unstoppableswap-gui-rs"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
[package]
|
||||
name = "unstoppableswap-gui-rs"
|
||||
version = "0.0.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
authors = [ "you" ]
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
description = "A Tauri App"
|
||||
|
||||
[lib]
|
||||
name = "unstoppableswap_gui_rs_lib"
|
||||
crate-type = ["lib", "cdylib", "staticlib"]
|
||||
crate-type = [ "lib", "cdylib", "staticlib" ]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.0-beta", features = [] }
|
||||
tauri-build = { version = "2.0.0-beta", features = [ ] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2.0.0-beta", features = [] }
|
||||
tauri-plugin-shell = "2.0.0-beta"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
anyhow = "1"
|
||||
once_cell = "1"
|
||||
swap = { path= "../swap" }
|
||||
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
serde_json = "1"
|
||||
swap = { path = "../swap" }
|
||||
tauri = { version = "2.0.0-beta", features = [ ] }
|
||||
tauri-plugin-shell = "2.0.0-beta"
|
||||
|
|
|
@ -1,17 +1,29 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use once_cell::sync::OnceCell;
|
||||
use swap::{api::{request::{Method, Request}, Context}, cli::command::{Bitcoin, Monero}};
|
||||
use swap::{
|
||||
api::{
|
||||
request::{get_balance, BalanceArgs, BalanceResponse},
|
||||
Context,
|
||||
},
|
||||
cli::command::{Bitcoin, Monero},
|
||||
};
|
||||
|
||||
// Lazy load the Context
|
||||
static CONTEXT: OnceCell<Arc<Context>> = OnceCell::new();
|
||||
|
||||
#[tauri::command]
|
||||
async fn balance() -> String {
|
||||
async fn balance() -> Result<BalanceResponse, String> {
|
||||
let context = CONTEXT.get().unwrap();
|
||||
let request = Request::new(Method::Balance { force_refresh: true });
|
||||
let response = request.call(context.clone()).await.unwrap();
|
||||
response.to_string()
|
||||
|
||||
get_balance(
|
||||
BalanceArgs {
|
||||
force_refresh: true,
|
||||
},
|
||||
context.clone(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
fn setup<'a>(app: &'a mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -34,7 +46,9 @@ fn setup<'a>(app: &'a mut tauri::App) -> Result<(), Box<dyn std::error::Error>>
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
CONTEXT.set(Arc::new(context)).expect("Failed to initialize cli context");
|
||||
CONTEXT
|
||||
.set(Arc::new(context))
|
||||
.expect("Failed to initialize cli context");
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -27,17 +27,31 @@ data-encoding = "2.6"
|
|||
dialoguer = "0.11"
|
||||
digest = "0.10.7"
|
||||
directories-next = "2"
|
||||
ecdsa_fun = { version = "0.10", default-features = false, features = [ "libsecp_compat", "serde", "adaptor" ] }
|
||||
ecdsa_fun = { version = "0.10", default-features = false, features = [
|
||||
"libsecp_compat",
|
||||
"serde",
|
||||
"adaptor",
|
||||
] }
|
||||
ed25519-dalek = "1"
|
||||
erased-serde = "0.4.5"
|
||||
futures = { version = "0.3", default-features = false }
|
||||
hex = "0.4"
|
||||
hyper = "0.14.20"
|
||||
itertools = "0.13"
|
||||
jsonrpsee = { version = "0.16.2", features = [ "server" ] }
|
||||
tower-http = { version = "0.3.4", features = ["full"] }
|
||||
tower = { version = "0.4.13", features = ["full"] }
|
||||
hyper = "0.14.20"
|
||||
jsonrpsee-core = "0.16.2"
|
||||
libp2p = { version = "0.42.2", default-features = false, features = [ "tcp-tokio", "yamux", "mplex", "dns-tokio", "noise", "request-response", "websocket", "ping", "rendezvous", "identify" ] }
|
||||
libp2p = { version = "0.42.2", default-features = false, features = [
|
||||
"tcp-tokio",
|
||||
"yamux",
|
||||
"mplex",
|
||||
"dns-tokio",
|
||||
"noise",
|
||||
"request-response",
|
||||
"websocket",
|
||||
"ping",
|
||||
"rendezvous",
|
||||
"identify",
|
||||
] }
|
||||
monero = { version = "0.12", features = [ "serde_support" ] }
|
||||
monero-rpc = { path = "../monero-rpc" }
|
||||
pem = "3.0"
|
||||
|
@ -45,7 +59,12 @@ proptest = "1"
|
|||
qrcode = "0.14"
|
||||
rand = "0.8"
|
||||
rand_chacha = "0.3"
|
||||
reqwest = { version = "0.12", features = [ "http2", "rustls-tls", "stream", "socks" ], default-features = false }
|
||||
reqwest = { version = "0.12", features = [
|
||||
"http2",
|
||||
"rustls-tls",
|
||||
"stream",
|
||||
"socks",
|
||||
], default-features = false }
|
||||
rust_decimal = { version = "1", features = [ "serde-float" ] }
|
||||
rust_decimal_macros = "1"
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
|
@ -53,22 +72,52 @@ serde_cbor = "0.11"
|
|||
serde_json = "1"
|
||||
serde_with = { version = "1", features = [ "macros" ] }
|
||||
sha2 = "0.10"
|
||||
sigma_fun = { version = "0.7", default-features = false, features = [ "ed25519", "serde", "secp256k1", "alloc" ] }
|
||||
sqlx = { version = "0.6.3", features = [ "sqlite", "runtime-tokio-rustls", "offline" ] }
|
||||
sigma_fun = { version = "0.7", default-features = false, features = [
|
||||
"ed25519",
|
||||
"serde",
|
||||
"secp256k1",
|
||||
"alloc",
|
||||
] }
|
||||
sqlx = { version = "0.6.3", features = [
|
||||
"sqlite",
|
||||
"runtime-tokio-rustls",
|
||||
"offline",
|
||||
] }
|
||||
structopt = "0.3"
|
||||
strum = { version = "0.26", features = [ "derive" ] }
|
||||
thiserror = "1"
|
||||
time = "0.3"
|
||||
tokio = { version = "1", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net", "parking_lot" ] }
|
||||
tokio = { version = "1", features = [
|
||||
"rt-multi-thread",
|
||||
"time",
|
||||
"macros",
|
||||
"sync",
|
||||
"process",
|
||||
"fs",
|
||||
"net",
|
||||
"parking_lot",
|
||||
] }
|
||||
tokio-socks = "0.5"
|
||||
tokio-tungstenite = { version = "0.15", features = [ "rustls-tls" ] }
|
||||
tokio-util = { version = "0.7", features = [ "io", "codec" ] }
|
||||
toml = "0.8"
|
||||
torut = { version = "0.2", default-features = false, features = [ "v3", "control" ] }
|
||||
torut = { version = "0.2", default-features = false, features = [
|
||||
"v3",
|
||||
"control",
|
||||
] }
|
||||
tower = { version = "0.4.13", features = [ "full" ] }
|
||||
tower-http = { version = "0.3.4", features = [ "full" ] }
|
||||
tracing = { version = "0.1", features = [ "attributes" ] }
|
||||
tracing-appender = "0.2"
|
||||
tracing-futures = { version = "0.2", features = [ "std-future", "futures-03" ] }
|
||||
tracing-subscriber = { version = "0.3", default-features = false, features = [ "fmt", "ansi", "env-filter", "time", "tracing-log", "json" ] }
|
||||
tracing-subscriber = { version = "0.3", default-features = false, features = [
|
||||
"fmt",
|
||||
"ansi",
|
||||
"env-filter",
|
||||
"time",
|
||||
"tracing-log",
|
||||
"json",
|
||||
] }
|
||||
url = { version = "2", features = [ "serde" ] }
|
||||
uuid = { version = "1.9", features = [ "serde", "v4" ] }
|
||||
void = "1"
|
||||
|
@ -96,4 +145,8 @@ testcontainers = "0.15"
|
|||
|
||||
[build-dependencies]
|
||||
anyhow = "1"
|
||||
vergen = { version = "8.3", default-features = false, features = [ "build", "git", "git2" ] }
|
||||
vergen = { version = "8.3", default-features = false, features = [
|
||||
"build",
|
||||
"git",
|
||||
"git2",
|
||||
] }
|
||||
|
|
|
@ -375,6 +375,7 @@ pub mod api_test {
|
|||
use crate::api::request::{Method, Request};
|
||||
|
||||
use libp2p::Multiaddr;
|
||||
use request::BuyXmrArgs;
|
||||
use std::str::FromStr;
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -431,12 +432,12 @@ pub mod api_test {
|
|||
}
|
||||
};
|
||||
|
||||
Request::new(Method::BuyXmr {
|
||||
Request::new(Method::BuyXmr(BuyXmrArgs {
|
||||
seller,
|
||||
bitcoin_change_address,
|
||||
monero_receive_address,
|
||||
swap_id: Uuid::new_v4(),
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn resume() -> Request {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,9 +12,12 @@
|
|||
#![forbid(unsafe_code)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::{
|
||||
cli::command::{parse_args_and_apply_defaults, ParseResult},
|
||||
common::check_latest_version,
|
||||
};
|
||||
use anyhow::Result;
|
||||
use std::env;
|
||||
use crate::{cli::command::{parse_args_and_apply_defaults, ParseResult}, common::check_latest_version};
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn main() -> Result<()> {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
use crate::api::request::{Method, Request};
|
||||
use crate::api::request::{
|
||||
BalanceArgs, BuyXmrArgs, CancelAndRefundArgs, ListSellersArgs, Method, MoneroRecoveryArgs,
|
||||
Request, ResumeArgs, StartDaemonArgs, WithdrawBtcArgs,
|
||||
};
|
||||
use crate::api::Context;
|
||||
use crate::bitcoin::{bitcoin_address, Amount};
|
||||
use crate::monero;
|
||||
|
@ -74,12 +77,12 @@ where
|
|||
let bitcoin_change_address =
|
||||
bitcoin_address::validate_is_testnet(bitcoin_change_address, is_testnet)?;
|
||||
|
||||
let request = Request::new(Method::BuyXmr {
|
||||
let request = Request::new(Method::BuyXmr(BuyXmrArgs {
|
||||
seller,
|
||||
bitcoin_change_address,
|
||||
monero_receive_address,
|
||||
swap_id: Uuid::new_v4(),
|
||||
});
|
||||
}));
|
||||
|
||||
let context = Context::build(
|
||||
Some(bitcoin),
|
||||
|
@ -109,9 +112,9 @@ where
|
|||
(context, request)
|
||||
}
|
||||
CliCommand::Balance { bitcoin } => {
|
||||
let request = Request::new(Method::Balance {
|
||||
let request = Request::new(Method::Balance(BalanceArgs {
|
||||
force_refresh: true,
|
||||
});
|
||||
}));
|
||||
|
||||
let context = Context::build(
|
||||
Some(bitcoin),
|
||||
|
@ -132,7 +135,7 @@ where
|
|||
monero,
|
||||
tor,
|
||||
} => {
|
||||
let request = Request::new(Method::StartDaemon { server_address });
|
||||
let request = Request::new(Method::StartDaemon(StartDaemonArgs { server_address }));
|
||||
|
||||
let context = Context::build(
|
||||
Some(bitcoin),
|
||||
|
@ -153,7 +156,7 @@ where
|
|||
address,
|
||||
} => {
|
||||
let address = bitcoin_address::validate_is_testnet(address, is_testnet)?;
|
||||
let request = Request::new(Method::WithdrawBtc { amount, address });
|
||||
let request = Request::new(Method::WithdrawBtc(WithdrawBtcArgs { amount, address }));
|
||||
|
||||
let context = Context::build(
|
||||
Some(bitcoin),
|
||||
|
@ -174,7 +177,7 @@ where
|
|||
monero,
|
||||
tor,
|
||||
} => {
|
||||
let request = Request::new(Method::Resume { swap_id });
|
||||
let request = Request::new(Method::Resume(ResumeArgs { swap_id }));
|
||||
|
||||
let context = Context::build(
|
||||
Some(bitcoin),
|
||||
|
@ -194,7 +197,7 @@ where
|
|||
bitcoin,
|
||||
tor,
|
||||
} => {
|
||||
let request = Request::new(Method::CancelAndRefund { swap_id });
|
||||
let request = Request::new(Method::CancelAndRefund(CancelAndRefundArgs { swap_id }));
|
||||
|
||||
let context = Context::build(
|
||||
Some(bitcoin),
|
||||
|
@ -213,7 +216,7 @@ where
|
|||
rendezvous_point,
|
||||
tor,
|
||||
} => {
|
||||
let request = Request::new(Method::ListSellers { rendezvous_point });
|
||||
let request = Request::new(Method::ListSellers(ListSellersArgs { rendezvous_point }));
|
||||
|
||||
let context =
|
||||
Context::build(None, None, Some(tor), data, is_testnet, debug, json, None).await?;
|
||||
|
@ -239,7 +242,7 @@ where
|
|||
CliCommand::MoneroRecovery {
|
||||
swap_id: SwapId { swap_id },
|
||||
} => {
|
||||
let request = Request::new(Method::MoneroRecovery { swap_id });
|
||||
let request = Request::new(Method::MoneroRecovery(MoneroRecoveryArgs { swap_id }));
|
||||
|
||||
let context =
|
||||
Context::build(None, None, None, data, is_testnet, debug, json, None).await?;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
pub mod api;
|
||||
pub mod asb;
|
||||
pub mod bin;
|
||||
pub mod bitcoin;
|
||||
pub mod cli;
|
||||
pub mod common;
|
||||
|
@ -27,14 +28,13 @@ pub mod fs;
|
|||
pub mod kraken;
|
||||
pub mod libp2p_ext;
|
||||
pub mod monero;
|
||||
mod monero_ext;
|
||||
pub mod network;
|
||||
pub mod protocol;
|
||||
pub mod rpc;
|
||||
pub mod seed;
|
||||
pub mod tor;
|
||||
pub mod tracing_ext;
|
||||
pub mod bin;
|
||||
mod monero_ext;
|
||||
|
||||
#[cfg(test)]
|
||||
mod proptest;
|
||||
|
|
|
@ -338,12 +338,18 @@ async fn next_state(
|
|||
}
|
||||
}
|
||||
Ok(Rejected { reason, .. }) => {
|
||||
tracing::error!(?reason, "Alice rejected our request for cooperative XMR redeem");
|
||||
tracing::error!(
|
||||
?reason,
|
||||
"Alice rejected our request for cooperative XMR redeem"
|
||||
);
|
||||
return Err(reason)
|
||||
.context("Alice rejected our request for cooperative XMR redeem");
|
||||
}
|
||||
Err(error) => {
|
||||
tracing::error!(?error, "Failed to request cooperative XMR redeem from Alice");
|
||||
tracing::error!(
|
||||
?error,
|
||||
"Failed to request cooperative XMR redeem from Alice"
|
||||
);
|
||||
return Err(error)
|
||||
.context("Failed to request cooperative XMR redeem from Alice");
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::api::Context;
|
||||
use std::{net::SocketAddr, sync::Arc};
|
||||
use thiserror::Error;
|
||||
use tower_http::cors::{Any, CorsLayer};
|
||||
use tower_http::cors::CorsLayer;
|
||||
|
||||
use jsonrpsee::{
|
||||
core::server::host_filtering::AllowHosts,
|
||||
server::{RpcModule, ServerBuilder, ServerHandle},
|
||||
core::server::host_filtering::AllowHosts,
|
||||
server::{RpcModule, ServerBuilder, ServerHandle},
|
||||
};
|
||||
|
||||
pub mod methods;
|
||||
|
@ -21,10 +21,13 @@ pub async fn run_server(
|
|||
context: Arc<Context>,
|
||||
) -> anyhow::Result<(SocketAddr, ServerHandle)> {
|
||||
let cors = CorsLayer::permissive();
|
||||
let middleware = tower::ServiceBuilder::new().layer(cors);
|
||||
let middleware = tower::ServiceBuilder::new().layer(cors);
|
||||
|
||||
let server = ServerBuilder::default().set_host_filtering(AllowHosts::Any)
|
||||
.set_middleware(middleware).build(server_address).await?;
|
||||
let server = ServerBuilder::default()
|
||||
.set_host_filtering(AllowHosts::Any)
|
||||
.set_middleware(middleware)
|
||||
.build(server_address)
|
||||
.await?;
|
||||
let mut modules = RpcModule::new(());
|
||||
{
|
||||
modules
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
use crate::api::request::{Method, Request};
|
||||
use crate::api::request::{
|
||||
BalanceArgs, BuyXmrArgs, CancelAndRefundArgs, GetSwapInfoArgs, ListSellersArgs, Method,
|
||||
MoneroRecoveryArgs, Request, ResumeArgs, WithdrawBtcArgs,
|
||||
};
|
||||
use crate::api::Context;
|
||||
use crate::bitcoin::bitcoin_address;
|
||||
use crate::monero::monero_address;
|
||||
|
@ -29,7 +32,12 @@ pub fn register_modules(context: Arc<Context>) -> Result<RpcModule<Arc<Context>>
|
|||
let swap_id = as_uuid(swap_id)
|
||||
.ok_or_else(|| jsonrpsee_core::Error::Custom("Could not parse swap_id".to_string()))?;
|
||||
|
||||
execute_request(params_raw, Method::GetSwapInfo { swap_id }, &context).await
|
||||
execute_request(
|
||||
params_raw,
|
||||
Method::GetSwapInfo(GetSwapInfoArgs { swap_id }),
|
||||
&context,
|
||||
)
|
||||
.await
|
||||
})?;
|
||||
|
||||
module.register_async_method("get_bitcoin_balance", |params_raw, context| async move {
|
||||
|
@ -45,7 +53,12 @@ pub fn register_modules(context: Arc<Context>) -> Result<RpcModule<Arc<Context>>
|
|||
jsonrpsee_core::Error::Custom("force_refesh is not a boolean".to_string())
|
||||
})?;
|
||||
|
||||
execute_request(params_raw, Method::Balance { force_refresh }, &context).await
|
||||
execute_request(
|
||||
params_raw,
|
||||
Method::Balance(BalanceArgs { force_refresh }),
|
||||
&context,
|
||||
)
|
||||
.await
|
||||
})?;
|
||||
|
||||
module.register_async_method("get_history", |params, context| async move {
|
||||
|
@ -66,7 +79,7 @@ pub fn register_modules(context: Arc<Context>) -> Result<RpcModule<Arc<Context>>
|
|||
let swap_id = as_uuid(swap_id)
|
||||
.ok_or_else(|| jsonrpsee_core::Error::Custom("Could not parse swap_id".to_string()))?;
|
||||
|
||||
execute_request(params_raw, Method::Resume { swap_id }, &context).await
|
||||
execute_request(params_raw, Method::Resume(ResumeArgs { swap_id }), &context).await
|
||||
})?;
|
||||
|
||||
module.register_async_method("cancel_refund_swap", |params_raw, context| async move {
|
||||
|
@ -79,7 +92,12 @@ pub fn register_modules(context: Arc<Context>) -> Result<RpcModule<Arc<Context>>
|
|||
let swap_id = as_uuid(swap_id)
|
||||
.ok_or_else(|| jsonrpsee_core::Error::Custom("Could not parse swap_id".to_string()))?;
|
||||
|
||||
execute_request(params_raw, Method::CancelAndRefund { swap_id }, &context).await
|
||||
execute_request(
|
||||
params_raw,
|
||||
Method::CancelAndRefund(CancelAndRefundArgs { swap_id }),
|
||||
&context,
|
||||
)
|
||||
.await
|
||||
})?;
|
||||
|
||||
module.register_async_method(
|
||||
|
@ -95,7 +113,12 @@ pub fn register_modules(context: Arc<Context>) -> Result<RpcModule<Arc<Context>>
|
|||
jsonrpsee_core::Error::Custom("Could not parse swap_id".to_string())
|
||||
})?;
|
||||
|
||||
execute_request(params_raw, Method::MoneroRecovery { swap_id }, &context).await
|
||||
execute_request(
|
||||
params_raw,
|
||||
Method::MoneroRecovery(MoneroRecoveryArgs { swap_id }),
|
||||
&context,
|
||||
)
|
||||
.await
|
||||
},
|
||||
)?;
|
||||
|
||||
|
@ -123,10 +146,10 @@ pub fn register_modules(context: Arc<Context>) -> Result<RpcModule<Arc<Context>>
|
|||
|
||||
execute_request(
|
||||
params_raw,
|
||||
Method::WithdrawBtc {
|
||||
Method::WithdrawBtc(WithdrawBtcArgs {
|
||||
amount,
|
||||
address: withdraw_address,
|
||||
},
|
||||
}),
|
||||
&context,
|
||||
)
|
||||
.await
|
||||
|
@ -165,12 +188,12 @@ pub fn register_modules(context: Arc<Context>) -> Result<RpcModule<Arc<Context>>
|
|||
|
||||
execute_request(
|
||||
params_raw,
|
||||
Method::BuyXmr {
|
||||
Method::BuyXmr(BuyXmrArgs {
|
||||
bitcoin_change_address,
|
||||
monero_receive_address,
|
||||
seller,
|
||||
swap_id: Uuid::new_v4(),
|
||||
},
|
||||
}),
|
||||
&context,
|
||||
)
|
||||
.await
|
||||
|
@ -192,9 +215,9 @@ pub fn register_modules(context: Arc<Context>) -> Result<RpcModule<Arc<Context>>
|
|||
|
||||
execute_request(
|
||||
params_raw,
|
||||
Method::ListSellers {
|
||||
Method::ListSellers(ListSellersArgs {
|
||||
rendezvous_point: rendezvous_point.clone(),
|
||||
},
|
||||
}),
|
||||
&context,
|
||||
)
|
||||
.await
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { Box, DialogContentText } from '@material-ui/core';
|
||||
import { useActiveSwapInfo, useAppSelector } from 'store/hooks';
|
||||
import CliLogsBox from '../../../other/RenderedCliLog';
|
||||
import JsonTreeView from '../../../other/JSONViewTree';
|
||||
import { Box, DialogContentText } from "@material-ui/core";
|
||||
import { useActiveSwapInfo, useAppSelector } from "store/hooks";
|
||||
import CliLogsBox from "../../../other/RenderedCliLog";
|
||||
import JsonTreeView from "../../../other/JSONViewTree";
|
||||
|
||||
export default function DebugPage() {
|
||||
const torStdOut = useAppSelector((s) => s.tor.stdOut);
|
||||
const logs = useAppSelector((s) => s.swap.logs);
|
||||
const guiState = useAppSelector((s) => s.swap);
|
||||
const guiState = useAppSelector((s) => s);
|
||||
const cliState = useActiveSwapInfo();
|
||||
|
||||
return (
|
||||
|
@ -14,9 +14,9 @@ export default function DebugPage() {
|
|||
<DialogContentText>
|
||||
<Box
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '8px',
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "8px",
|
||||
}}
|
||||
>
|
||||
<CliLogsBox logs={logs} label="Logs relevant to the swap" />
|
||||
|
@ -28,7 +28,7 @@ export default function DebugPage() {
|
|||
data={cliState}
|
||||
label="Swap Daemon State (exposed via API)"
|
||||
/>
|
||||
<CliLogsBox label="Tor Daemon Logs" logs={torStdOut.split('\n')} />
|
||||
<CliLogsBox label="Tor Daemon Logs" logs={torStdOut.split("\n")} />
|
||||
</Box>
|
||||
</DialogContentText>
|
||||
</Box>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { piconerosToXmr, satsToBtc } from 'utils/conversionUtils';
|
||||
import { Tooltip } from '@material-ui/core';
|
||||
import { useAppSelector } from 'store/hooks';
|
||||
import { piconerosToXmr, satsToBtc } from "utils/conversionUtils";
|
||||
import { Tooltip } from "@material-ui/core";
|
||||
import { useAppSelector } from "store/hooks";
|
||||
|
||||
type Amount = number | null | undefined;
|
||||
|
||||
|
@ -21,13 +21,13 @@ export function AmountWithUnit({
|
|||
title={
|
||||
dollarRate != null && amount != null
|
||||
? `≈ $${(dollarRate * amount).toFixed(2)}`
|
||||
: ''
|
||||
: ""
|
||||
}
|
||||
>
|
||||
<span>
|
||||
{amount != null
|
||||
? Number.parseFloat(amount.toFixed(fixedPrecision))
|
||||
: '?'}{' '}
|
||||
: "?"}{" "}
|
||||
{unit}
|
||||
</span>
|
||||
</Tooltip>
|
||||
|
|
|
@ -4,11 +4,15 @@ import { store } from "./store/storeRenderer";
|
|||
import { rpcSetBalance } from "store/features/rpcSlice";
|
||||
|
||||
export async function checkBitcoinBalance() {
|
||||
const response = await invoke('balance') as BalanceBitcoinResponse;
|
||||
store.dispatch(rpcSetBalance(response.balance));
|
||||
// TODO: use tauri-bindgen here
|
||||
const response = (await invoke("balance")) as {
|
||||
balance: number;
|
||||
};
|
||||
|
||||
store.dispatch(rpcSetBalance(response.balance));
|
||||
}
|
||||
|
||||
export async function getRawSwapInfos() {
|
||||
const response = await invoke('swap_infos');
|
||||
console.log(response);
|
||||
}
|
||||
const response = await invoke("swap_infos");
|
||||
console.log(response);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue