Skip to content

Commit

Permalink
feat: validate-payment.com instead of copy preimage
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Nov 27, 2024
1 parent 93464ac commit a3c0982
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
11 changes: 7 additions & 4 deletions e2e/submarineSwap.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect, test } from "@playwright/test";

import { validateResponse } from "../src/utils/validation";

Check failure on line 3 in e2e/submarineSwap.spec.ts

View workflow job for this annotation

GitHub Actions / ci

'validateResponse' is defined but never used

Check failure on line 3 in e2e/submarineSwap.spec.ts

View workflow job for this annotation

GitHub Actions / ci

'validateResponse' is defined but never used
import {
bitcoinSendToAddress,
generateBitcoinBlock,
Expand Down Expand Up @@ -51,10 +52,12 @@ test.describe("Submarine swap", () => {

await generateBitcoinBlock();

await page.getByText("Copy preimage").click();
const preimage = await page.evaluate(() => {
return navigator.clipboard.readText();
});
const validationLink = new URL(
await page.getByText("Validate payment").getAttribute("href"),
);

expect(validationLink.searchParams.get("invoice")).toEqual(invoice);
const preimage = validationLink.searchParams.get("preimage");

const lookupRes = await lookupInvoiceLnd(invoice);
expect(lookupRes.state).toEqual("SETTLED");
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const defaults = {
telegramUrl: "https://t.me/boltzhq",
email: "[email protected]",
dnsOverHttps: "https://1.1.1.1/dns-query",
preimageValidation: "https://validate-payment.com",
};

type Asset = {
Expand Down
6 changes: 1 addition & 5 deletions src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const dict = {
timeout: "Timeout",
wallet_connect_failed: "Wallet connection failed: {{ error }}",
ledger_open_app_prompt: "Open Ethereum or RSK app",
copy_preimage: "Copy preimage",
validate_payment: "Validate payment",
no_browser_wallet: "No browser wallet detected",
},
de: {
Expand Down Expand Up @@ -452,7 +452,6 @@ const dict = {
wallet_connect_failed:
"Verbindung zu Wallet fehlgeschlagen: {{ error }}",
ledger_open_app_prompt: "Ethereum oder RSK app öffnen",
copy_preimage: "Preimage Kopieren",
no_browser_wallet: "Kein Browser Wallet gefunden",
},
es: {
Expand Down Expand Up @@ -683,7 +682,6 @@ const dict = {
timeout: "timeout",
wallet_connect_failed: "Fallo en la conexión del monedero: {{ error }}",
ledger_open_app_prompt: "Abrir aplicación Ethereum o RSK",
copy_preimage: "Copiar preimagen",
no_browser_wallet: "No se detectó monedero en el navegador",
},
zh: {
Expand Down Expand Up @@ -887,7 +885,6 @@ const dict = {
timeout: "超时",
wallet_connect_failed: "钱包连接失败:{{ error }}",
ledger_open_app_prompt: "打开以太坊或 RSK 应用",
copy_preimage: "复制预图像",
no_browser_wallet: "未检测到浏览器钱包",
},
ja: {
Expand Down Expand Up @@ -1115,7 +1112,6 @@ const dict = {
timeout: "タイムアウト",
wallet_connect_failed: "ウォレット接続の失敗: {{ error }}",
ledger_open_app_prompt: "イーサリアムもしくはRSKのアプリを開く",
copy_preimage: "コピー前画像",
no_browser_wallet: "ブラウザのウォレットが検出されない",
},
};
Expand Down
19 changes: 17 additions & 2 deletions src/status/TransactionClaimed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BigNumber } from "bignumber.js";
import log from "loglevel";
import { Show, createEffect, createResource, createSignal } from "solid-js";

import CopyButton from "../components/CopyButton";
import LoadingSpinner from "../components/LoadingSpinner";
import { config } from "../config";
import { RBTC } from "../consts/Assets";
import { SwapType } from "../consts/Enums";
import { useGlobalContext } from "../context/Global";
Expand All @@ -26,6 +26,13 @@ const Broadcasting = () => {
);
};

const paymentValidationUrl = (invoice: string, preimage: string): string => {
const url = new URL(config.preimageValidation);
url.searchParams.append("invoice", invoice);
url.searchParams.append("preimage", preimage);
return url.toString();
};

const TransactionClaimed = () => {
const navigate = useNavigate();

Expand Down Expand Up @@ -94,7 +101,15 @@ const TransactionClaimed = () => {
{t("new_swap")}
</span>
<Show when={!preimage.loading && preimage() !== undefined}>
<CopyButton label={"copy_preimage"} data={preimage()} />
<a
class="btn btn-explorer"
target="_blank"
href={paymentValidationUrl(
(swap() as SubmarineSwap).invoice,
preimage(),
)}>
{t("validate_payment")}
</a>
</Show>
</Show>
</div>
Expand Down

0 comments on commit a3c0982

Please sign in to comment.