refactor(gui): Swap state stepper to use Tauri events (#77)

Previously we used the data we fetched via the rpc (`GetSwapInfo` call, saved in redux in `rpc.swapInfos`) to decide what to display in the state stepper to the user. The state stepper is displayed at the bottom of the `SwapDialog`.

However, we are moving away from our depedence on periodic rpc calls and towards relying more and more on the events we receive from the Host (from Tauri). Our goal is to rely solely on the Tauri events for everything displayed about the currently running swap.

This PR includes the following changes:
- refactor the `SwapStateStepper` such that it relies only on the Tauri events
- emit two new Tauri events (`EncryptedSignatureSent`, `CancelTimelockExpired`) in the state machine
- correctly emit `BtcRefunded` Tauri event after Bitcoin refund transaction is published
- differentiate between `"Waiting for them to redeem the Bitcoin"` and `"Revealing encrypted signature to the other party"` on the `SwapStatePage` (content displayed in the center of the `SwapDialog`)
This commit is contained in:
binarybaron 2024-09-23 03:31:24 +06:00 committed by GitHub
parent f91255ff76
commit 97510a8619
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 605 additions and 203 deletions

View file

@ -3,9 +3,9 @@ use std::sync::Arc;
use swap::cli::{
api::{
request::{
BalanceArgs, BuyXmrArgs, GetHistoryArgs, GetLogsArgs, GetSwapInfosAllArgs,
ListSellersArgs, MoneroRecoveryArgs, ResumeSwapArgs, SuspendCurrentSwapArgs,
WithdrawBtcArgs,
BalanceArgs, BuyXmrArgs, CancelAndRefundArgs, GetHistoryArgs, GetLogsArgs,
GetSwapInfosAllArgs, ListSellersArgs, MoneroRecoveryArgs, ResumeSwapArgs,
SuspendCurrentSwapArgs, WithdrawBtcArgs,
},
tauri_bindings::{TauriContextStatusEvent, TauriEmitter, TauriHandle},
Context, ContextBuilder,
@ -172,6 +172,7 @@ pub fn run() {
get_logs,
list_sellers,
suspend_current_swap,
cancel_and_refund,
is_context_available,
])
.setup(setup)
@ -211,6 +212,7 @@ tauri_command!(withdraw_btc, WithdrawBtcArgs);
tauri_command!(monero_recovery, MoneroRecoveryArgs);
tauri_command!(get_logs, GetLogsArgs);
tauri_command!(list_sellers, ListSellersArgs);
tauri_command!(cancel_and_refund, CancelAndRefundArgs);
// These commands require no arguments
tauri_command!(suspend_current_swap, SuspendCurrentSwapArgs, no_args);