From d37de5a630a0f3b5286d1f287559c4e5790656f2 Mon Sep 17 00:00:00 2001 From: michael1011 Date: Mon, 7 Oct 2024 14:43:55 +0200 Subject: [PATCH] refactor: cleanup RSK claim page (#687) * refactor: cleanup RSK claim page * chore: fix strings to match "continue" * fix: asset label --------- Co-authored-by: Kilian <19181985+kilrau@users.noreply.github.com> --- src/components/BlockExplorerLink.tsx | 13 +++---------- src/components/CreateButton.tsx | 27 +++++++++++++++++++++------ src/components/RefundButton.tsx | 4 ---- src/i18n/i18n.ts | 16 ++++++++-------- src/pages/RefundEvm.tsx | 1 - src/status/TransactionConfirmed.tsx | 18 ++++++++++++------ 6 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/components/BlockExplorerLink.tsx b/src/components/BlockExplorerLink.tsx index c58bb0fc..6a8b116a 100644 --- a/src/components/BlockExplorerLink.tsx +++ b/src/components/BlockExplorerLink.tsx @@ -2,7 +2,6 @@ import { Accessor, Show, createEffect, createSignal } from "solid-js"; import { RBTC } from "../consts/Assets"; import { SwapType } from "../consts/Enums"; -import { usePayContext } from "../context/Pay"; import { ChainSwap, ReverseSwap, @@ -24,18 +23,12 @@ const BlockExplorerLink = ({ (swap().type !== SwapType.Chain && getRelevantAssetForSwap(swap())) === RBTC ) { - const { swapStatusTransaction } = usePayContext(); - const txId = () => - swap().claimTx || swap().lockupTx || swapStatusTransaction()?.id; - return ( - + ); diff --git a/src/components/CreateButton.tsx b/src/components/CreateButton.tsx index 00dfc3dd..de7bc09a 100644 --- a/src/components/CreateButton.tsx +++ b/src/components/CreateButton.tsx @@ -158,12 +158,27 @@ export const CreateButton = () => { const fetchResults = await Promise.allSettled([ (() => { - try { - return fetchLnurl(lnurl(), Number(receiveAmount())); - } catch (e) { - log.warn("Fetching invoice from LNURL failed", e); - throw e; - } + return new Promise(async (resolve, reject) => { + const timeout = setTimeout( + () => reject("timeout"), + 5_000, + ); + + try { + const res = await fetchLnurl( + lnurl(), + Number(receiveAmount()), + ); + clearTimeout(timeout); + resolve(res); + } catch (e) { + log.warn( + "Fetching invoice from LNURL failed", + e, + ); + throw e; + } + }); })(), (() => { try { diff --git a/src/components/RefundButton.tsx b/src/components/RefundButton.tsx index 221dcbf4..d9d35a5a 100644 --- a/src/components/RefundButton.tsx +++ b/src/components/RefundButton.tsx @@ -26,7 +26,6 @@ import ContractTransaction from "./ContractTransaction"; export const RefundEvm = ({ swapId, setRefundTxHash, - asset, amount, claimAddress, preimageHash, @@ -35,7 +34,6 @@ export const RefundEvm = ({ }: { swapId?: string; setRefundTxHash?: Setter; - asset: string; amount: number; preimageHash: string; claimAddress: string; @@ -130,7 +128,6 @@ const RefundButton = ({ return ( { when={refundTxHash() !== undefined} fallback={ { const { getEtherSwap, signer } = useWeb3Signer(); const { t, getSwap, setSwapStorage } = useGlobalContext(); @@ -65,10 +67,12 @@ const ClaimRsk = ({ await setSwapStorage(currentSwap); }} address={signerAddress} - buttonText={t("claim")} - promptText={t("transaction_prompt", { button: t("claim") })} + buttonText={t("continue")} + promptText={t("transaction_prompt", { + button: t("continue"), + asset: assetReceive, + })} waitingText={t("tx_ready_to_claim")} - showHr={true} /> ); }; @@ -82,7 +86,7 @@ const TransactionConfirmed = () => { const chain = swap() as ChainSwap; return ( - { amount={chain.claimDetails.amount} refundAddress={chain.claimDetails.refundAddress} timeoutBlockHeight={chain.claimDetails.timeoutBlockHeight} + assetReceive={chain.assetReceive} /> ); } @@ -97,7 +102,7 @@ const TransactionConfirmed = () => { const reverse = swap() as ReverseSwap; return ( - { signerAddress={reverse.signer} refundAddress={reverse.refundAddress} timeoutBlockHeight={reverse.timeoutBlockHeight} + assetReceive={reverse.assetReceive} /> ); }