Skip to content

Commit

Permalink
fix michael1011 review
Browse files Browse the repository at this point in the history
  • Loading branch information
dni committed Jul 24, 2024
1 parent 4b40554 commit 8d2cff7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/status/InvoiceFailedToPay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const InvoiceFailedToPay = () => {
<hr />
<BlockExplorer
asset={swap().assetSend}
address={getLockupAddress(swap() as SubmarineSwap | ChainSwap)}
address={getLockupAddress(swap() as SubmarineSwap)}
/>
</div>
);
Expand Down
12 changes: 12 additions & 0 deletions src/status/InvoicePending.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { Show } from "solid-js";

import BlockExplorer from "../components/BlockExplorer";
import LoadingSpinner from "../components/LoadingSpinner";
import { useGlobalContext } from "../context/Global";
import { usePayContext } from "../context/Pay";

const InvoicePending = () => {
const { t } = useGlobalContext();
const { swap, swapStatusTransaction } = usePayContext();
return (
<div>
<p>{t("invoice_pending")}</p>
<LoadingSpinner />
<Show when={swapStatusTransaction() !== null}>
<BlockExplorer
asset={swap().assetSend}
txId={swapStatusTransaction().id}
typeLabel="lockup_tx"
/>
</Show>
</div>
);
};
Expand Down
8 changes: 4 additions & 4 deletions src/status/SwapExpired.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import BlockExplorer from "../components/BlockExplorer";
import RefundButton from "../components/RefundButton";
import { useGlobalContext } from "../context/Global";
import { usePayContext } from "../context/Pay";
import { getLockupTransaction } from "../utils/boltzClient";
import { LockupTransaction, getLockupTransaction } from "../utils/boltzClient";
import { ChainSwap, SubmarineSwap } from "../utils/swapCreator";

const SwapExpired = () => {
Expand All @@ -15,7 +15,7 @@ const SwapExpired = () => {
const { t } = useGlobalContext();

const [transactionToRefund, setTransactionToRefund] =
createSignal<string>("");
createSignal<LockupTransaction>(null);

createEffect(async () => {
setTransactionToRefund(null);
Expand All @@ -26,7 +26,7 @@ const SwapExpired = () => {
swap().type,
);
log.debug(`got swap transaction for ${swap().id}`);
setTransactionToRefund(res.hex);
setTransactionToRefund(res);
} catch (error: any) {
log.warn(`no swap transaction for: ${swap().id}`, error);
}
Expand All @@ -45,7 +45,7 @@ const SwapExpired = () => {
<hr />
<BlockExplorer
asset={swap().assetSend}
txId={transactionToRefund()}
txId={transactionToRefund().id}
/>
</Show>
<button class="btn" onClick={() => navigate("/swap")}>
Expand Down
12 changes: 11 additions & 1 deletion src/status/TransactionConfirmed.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Show } from "solid-js";

import BlockExplorer from "../components/BlockExplorer";
import ContractTransaction from "../components/ContractTransaction";
import LoadingSpinner from "../components/LoadingSpinner";
import { RBTC } from "../consts/Assets";
Expand Down Expand Up @@ -53,7 +56,7 @@ const ClaimRsk = ({

const TransactionConfirmed = () => {
const { t } = useGlobalContext();
const { swap } = usePayContext();
const { swapStatusTransaction, swap } = usePayContext();

if (swap().assetReceive === RBTC) {
if (swap().type === SwapType.Chain) {
Expand Down Expand Up @@ -88,6 +91,13 @@ const TransactionConfirmed = () => {
<h2>{t("tx_confirmed")}</h2>
<p>{t("tx_ready_to_claim")}</p>
<LoadingSpinner />
<Show when={swapStatusTransaction() !== null}>
<BlockExplorer
asset={swap().assetSend}
txId={swapStatusTransaction().id}
typeLabel="lockup_tx"
/>
</Show>
</div>
);
};
Expand Down
14 changes: 9 additions & 5 deletions src/status/TransactionMempool.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Show } from "solid-js";

import BlockExplorer from "../components/BlockExplorer";
import LoadingSpinner from "../components/LoadingSpinner";
import { useGlobalContext } from "../context/Global";
Expand All @@ -11,11 +13,13 @@ const TransactionMempool = () => {
<h2>{t("tx_in_mempool")}</h2>
<p>{t("tx_in_mempool_subline")}</p>
<LoadingSpinner />
<BlockExplorer
asset={swap().assetSend}
txId={swapStatusTransaction()?.id}
typeLabel="lockup_tx"
/>
<Show when={swapStatusTransaction() !== null}>
<BlockExplorer
asset={swap().assetSend}
txId={swapStatusTransaction().id}
typeLabel="lockup_tx"
/>
</Show>
</div>
);
};
Expand Down
14 changes: 8 additions & 6 deletions src/utils/boltzClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ type ChainSwapCreatedResponse = {
lockupDetails: ChainSwapDetails;
};

export type LockupTransaction = {
id: string;
hex: string;
timeoutBlockHeight: number;
timeoutEta?: number;
};

type ChainSwapTransaction = {
transaction: {
id: string;
Expand Down Expand Up @@ -366,12 +373,7 @@ export const getLockupTransaction = async (
asset: string,
id: string,
type: SwapType,
): Promise<{
id: string;
hex: string;
timeoutBlockHeight: number;
timeoutEta?: number;
}> => {
): Promise<LockupTransaction> => {
switch (type) {
case SwapType.Submarine:
return fetcher<{
Expand Down

0 comments on commit 8d2cff7

Please sign in to comment.