Skip to content

Commit

Permalink
refactor stepper, waiting for deposit page
Browse files Browse the repository at this point in the history
  • Loading branch information
binarybaron committed Nov 13, 2024
1 parent 1ccca84 commit 27ed4ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src-gui/src/renderer/components/modal/swap/SwapStateStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ function getActiveStep(state: SwapState | null): PathStep | null {
case "RequestingQuote":
case "ReceivedQuote":
case "WaitingForBtcDeposit":
case "Started":
case "SwapSetupInflight":
return [PathType.HAPPY_PATH, 0, isReleased];

// Step 1: Waiting for Bitcoin lock confirmation
// Bitcoin has been locked, waiting for the counterparty to lock their XMR
case "BtcLockTxInMempool":
// We only display the first step as completed if the Bitcoin lock has been confirmed
if(latestState.content.btc_lock_confirmations > 0) {
if (latestState.content.btc_lock_confirmations > 0) {
return [PathType.HAPPY_PATH, 1, isReleased];
}
return [PathType.HAPPY_PATH, 0, isReleased];
Expand All @@ -86,7 +86,7 @@ function getActiveStep(state: SwapState | null): PathStep | null {
// XMR redemption transaction is in mempool, swap is essentially complete
case "XmrRedeemInMempool":
return [PathType.HAPPY_PATH, 4, false];

// Unhappy Path States

// Step 1: Cancel timelock has expired. Waiting for cancel transaction to be published
Expand Down Expand Up @@ -117,8 +117,8 @@ function getActiveStep(state: SwapState | null): PathStep | null {
return null;
default:
return fallbackStep("No step is assigned to the current state");
// TODO: Make this guard work. It should force the compiler to check if we have covered all possible cases.
// return exhaustiveGuard(latestState.type);
// TODO: Make this guard work. It should force the compiler to check if we have covered all possible cases.
// return exhaustiveGuard(latestState.type);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ export default function WaitingForBtcDepositPage({
min_deposit_until_swap_will_start,
max_deposit_until_maximum_amount_is_reached,
min_bitcoin_lock_tx_fee,
max_giveable,
quote,
}: TauriSwapProgressEventContent<"WaitingForBtcDeposit">) {
const classes = useStyles();
const bitcoinBalance = useAppSelector((s) => s.rpc.state.balance) || 0;

// TODO: Account for BTC lock tx fees
return (
<Box>
<DepositAddressInfoBox
Expand All @@ -39,10 +38,10 @@ export default function WaitingForBtcDepositPage({
<Box className={classes.additionalContent}>
<Typography variant="subtitle2">
<ul>
{bitcoinBalance > 0 ? (
{max_giveable > 0 ? (
<li>
You have already deposited{" "}
<SatsAmount amount={bitcoinBalance} />
You have already deposited enough funds to swap
<SatsAmount amount={max_giveable} />. However, that is below the minimum amount required to start the swap.
</li>
) : null}
<li>
Expand All @@ -52,7 +51,7 @@ export default function WaitingForBtcDepositPage({
amount={max_deposit_until_maximum_amount_is_reached}
/>{" "}
to the address above
{bitcoinBalance > 0 && (
{max_giveable > 0 && (
<> (on top of the already deposited funds)</>
)}
</li>
Expand Down

0 comments on commit 27ed4ba

Please sign in to comment.