From 947a05b6fc3f7edf4568e6a122f79010a75f4c62 Mon Sep 17 00:00:00 2001 From: michael1011 Date: Mon, 4 Nov 2024 22:24:15 +0100 Subject: [PATCH] feat: show EVM lockup transactions --- src/components/BlockExplorerLink.tsx | 76 ++++++++++++++++++---------- src/components/LockupEvm.tsx | 3 ++ src/components/SwapChecker.tsx | 25 +++++++-- 3 files changed, 73 insertions(+), 31 deletions(-) diff --git a/src/components/BlockExplorerLink.tsx b/src/components/BlockExplorerLink.tsx index ed694ff6..45958068 100644 --- a/src/components/BlockExplorerLink.tsx +++ b/src/components/BlockExplorerLink.tsx @@ -1,4 +1,11 @@ -import { Accessor, Show, createEffect, createSignal } from "solid-js"; +import { + Accessor, + Match, + Show, + Switch, + createEffect, + createSignal, +} from "solid-js"; import { RBTC } from "../consts/Assets"; import { SwapType } from "../consts/Enums"; @@ -43,6 +50,8 @@ const BlockExplorerLink = (props: { swap: Accessor; swapStatus: Accessor; }) => { + const isRsk = () => getRelevantAssetForSwap(props.swap()) === RBTC; + return ( }> - {/* Showing addresses makes no sense for EVM based chains */} - + + + {/* Refund transactions are handled in SwapRefunded */} + + + + + + {/* Showing addresses makes no sense for EVM based chains */} + + + + + }> - }> - {/* Refund transactions are handled in SwapRefunded */} - - - - + + ); }; diff --git a/src/components/LockupEvm.tsx b/src/components/LockupEvm.tsx index 90c71cb3..5a7422a2 100644 --- a/src/components/LockupEvm.tsx +++ b/src/components/LockupEvm.tsx @@ -1,6 +1,7 @@ import { Show, createEffect, createSignal } from "solid-js"; import { useGlobalContext } from "../context/Global"; +import { usePayContext } from "../context/Pay"; import { customDerivationPathRdns, useWeb3Signer } from "../context/Web3"; import { HardwareSigner } from "../utils/hardware/HadwareSigner"; import { prefix0x, satoshiToWei } from "../utils/rootstock"; @@ -30,6 +31,7 @@ const LockupEvm = (props: { derivationPath?: string; timeoutBlockHeight: number; }) => { + const { setSwap } = usePayContext(); const { getEtherSwap, signer, providers } = useWeb3Signer(); const { t, getSwap, setSwapStorage } = useGlobalContext(); @@ -75,6 +77,7 @@ const LockupEvm = (props: { ).getDerivationPath(); } + setSwap(currentSwap); await setSwapStorage(currentSwap); }} children={} diff --git a/src/components/SwapChecker.tsx b/src/components/SwapChecker.tsx index 6ea70980..7fd1f94c 100644 --- a/src/components/SwapChecker.tsx +++ b/src/components/SwapChecker.tsx @@ -32,7 +32,7 @@ type SwapStatus = { status: string; failureReason?: string; - transaction: SwapStatusTransaction; + transaction?: SwapStatusTransaction; }; const reconnectInterval = 5_000; @@ -75,6 +75,10 @@ class BoltzWebSocket { }; public subscribeUpdates = (ids: string[]) => { + if (ids.every((id) => this.relevantIds.has(id))) { + return; + } + ids.forEach((id) => this.relevantIds.add(id)); if (this.ws.readyState !== WebSocket.OPEN) { return; @@ -188,10 +192,21 @@ export const SwapChecker = () => { return; } - if ( - currentSwap.version !== OutputType.Taproot || - getRelevantAssetForSwap(currentSwap) === RBTC - ) { + if (getRelevantAssetForSwap(currentSwap) === RBTC) { + if ( + data.status === swapStatusPending.TransactionMempool && + data.transaction !== undefined + ) { + currentSwap.lockupTx = data.transaction.id; + + setSwap(currentSwap); + await setSwapStorage(currentSwap); + } + + return; + } + + if (currentSwap.version !== OutputType.Taproot) { return; }