Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate-payment.com instead of copy preimage #748

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions e2e/submarineSwap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,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("Show Proof of 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: "hi@bol.tz",
dnsOverHttps: "https://1.1.1.1/dns-query",
preimageValidation: "https://validate-payment.com",
};

type Asset = {
Expand Down
10 changes: 5 additions & 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: "Show Proof of Payment",
no_browser_wallet: "No browser wallet detected",
},
de: {
Expand Down Expand Up @@ -452,7 +452,7 @@ const dict = {
wallet_connect_failed:
"Verbindung zu Wallet fehlgeschlagen: {{ error }}",
ledger_open_app_prompt: "Ethereum oder RSK app öffnen",
copy_preimage: "Preimage Kopieren",
validate_payment: "Proof of Payment anzeigen",
no_browser_wallet: "Kein Browser Wallet gefunden",
},
es: {
Expand Down Expand Up @@ -683,7 +683,7 @@ 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",
validate_payment: "Mostrar justificante de pago",
no_browser_wallet: "No se detectó monedero en el navegador",
},
zh: {
Expand Down Expand Up @@ -887,7 +887,7 @@ const dict = {
timeout: "超时",
wallet_connect_failed: "钱包连接失败:{{ error }}",
ledger_open_app_prompt: "打开以太坊或 RSK 应用",
copy_preimage: "复制预图像",
validate_payment: "出示付款证明",
no_browser_wallet: "未检测到浏览器钱包",
},
ja: {
Expand Down Expand Up @@ -1115,7 +1115,7 @@ const dict = {
timeout: "タイムアウト",
wallet_connect_failed: "ウォレット接続の失敗: {{ error }}",
ledger_open_app_prompt: "イーサリアムもしくはRSKのアプリを開く",
copy_preimage: "コピー前画像",
validate_payment: "支払い証明書の提示",
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