feat(gui): Display state page for inflight swap setup (#158)

We now display a "Starting swap with provider to lock ... BTC" page when the Bitcoin have been deposited and the swap setup is inflight.
This commit is contained in:
binarybaron 2024-11-13 20:18:13 +01:00 committed by GitHub
parent 6b6737c056
commit eac435aba6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 28 additions and 30 deletions

View file

@ -149,7 +149,7 @@ pub enum TauriSwapProgressEvent {
min_bitcoin_lock_tx_fee: bitcoin::Amount,
quote: BidQuote,
},
Started {
SwapSetupInflight {
#[typeshare(serialized_as = "number")]
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
btc_lock_amount: bitcoin::Amount,

View file

@ -109,6 +109,16 @@ async fn next_state(
.estimate_fee(TxCancel::weight(), btc_amount)
.await?;
// Emit an event to tauri that we are negotiating with the swap provider to lock the Bitcoin
event_emitter.emit_swap_progress_event(
swap_id,
TauriSwapProgressEvent::SwapSetupInflight {
btc_lock_amount: btc_amount,
// TODO: Replace this with the actual fee
btc_tx_lock_fee: bitcoin::Amount::ZERO,
},
);
let state2 = event_loop_handle
.setup_swap(NewSwap {
swap_id,
@ -146,16 +156,6 @@ async fn next_state(
// Publish the signed Bitcoin lock transaction
let (..) = bitcoin_wallet.broadcast(signed_tx, "lock").await?;
// Emit an event to tauri that the the swap started
event_emitter.emit_swap_progress_event(
swap_id,
TauriSwapProgressEvent::Started {
btc_lock_amount: tx_lock.lock_amount(),
// TODO: Replace this with the actual fee
btc_tx_lock_fee: bitcoin::Amount::ZERO,
},
);
BobState::BtcLocked {
state3,
monero_wallet_restore_blockheight,