Skip to content

Commit

Permalink
feat: deeplinks for wallets
Browse files Browse the repository at this point in the history
add links on SwapCreated and InvoiceSet on the QR code and as button

closes #299

change copy addres to copy bip21
  • Loading branch information
dni committed Jan 23, 2024
1 parent 9d5f7ea commit f5e9889
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const dict = {
scan_qr_code: "Scan QR Code",
version: "Version",
commithash: "Commit Hash",
open_in_wallet: "Open in Wallet",
},
de: {
language: "Deutsch",
Expand Down Expand Up @@ -329,6 +330,7 @@ const dict = {
scan_qr_code: "QR Code scannen",
version: "Version",
commithash: "Commit Hash",
open_in_wallet: "Im Wallet öffnen",
},
es: {
language: "Español",
Expand Down Expand Up @@ -497,6 +499,7 @@ const dict = {
scan_qr_code: "Escanear código QR",
version: "Versión",
commithash: "Commit Hash",
open_in_wallet: "Abrir en monedero",
},
zh: {
language: "中文",
Expand Down Expand Up @@ -651,6 +654,7 @@ const dict = {
scan_qr_code: "扫描 QR 码",
version: "版本",
commithash: "提交哈希",
open_in_wallet: "在钱包中打开",
},
};

Expand Down
23 changes: 16 additions & 7 deletions src/status/InvoiceSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useGlobalContext } from "../context/Global";
import { usePayContext } from "../context/Pay";
import { useWeb3Signer } from "../context/Web3";
import { denominations, formatAmount } from "../utils/denomination";
import { clipboard, cropString } from "../utils/helper";
import { clipboard, cropString, isMobile } from "../utils/helper";
import { decodeInvoice } from "../utils/invoice";
import { prefix0x, satoshiToWei } from "../utils/rootstock";

Expand Down Expand Up @@ -64,7 +64,9 @@ const InvoiceSet = () => {
})}
</h2>
<hr />
<QrCode data={swap().reverse ? swap().invoice : swap().bip21} />
<a href={swap().bip21}>
<QrCode data={swap().bip21} />
</a>
<hr />
<p
onclick={() => clipboard(swap().address)}
Expand All @@ -77,9 +79,6 @@ const InvoiceSet = () => {
<hr />
</Show>
<div class="btns">
<span class="btn" onclick={() => clipboard(swap().bip21)}>
{t("copy_bip21")}
</span>
<span
class="btn"
onclick={() =>
Expand All @@ -92,9 +91,19 @@ const InvoiceSet = () => {
}>
{t("copy_amount")}
</span>
<span class="btn" onclick={() => clipboard(swap().address)}>
{t("copy_address")}
<Show when={!isMobile}>
<span class="btn" onclick={() => clipboard(swap().address)}>
{t("copy_address")}
</span>
</Show>
<span class="btn" onclick={() => clipboard(swap().bip21)}>
{t("copy_bip21")}
</span>
<Show when={isMobile}>
<a href={swap().bip21} class="btn">
{t("open_in_wallet")}
</a>
</Show>
</div>
<hr />
</div>
Expand Down
21 changes: 16 additions & 5 deletions src/status/SwapCreated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { BTC } from "../consts";
import { useGlobalContext } from "../context/Global";
import { usePayContext } from "../context/Pay";
import { denominations, formatAmount } from "../utils/denomination";
import { clipboard, cropString } from "../utils/helper";
import { clipboard, cropString, isMobile } from "../utils/helper";
import { invoicePrefix } from "../utils/invoice";
import { enableWebln } from "../utils/webln";

const SwapCreated = () => {
Expand All @@ -33,7 +34,9 @@ const SwapCreated = () => {
})}
</h2>
<hr />
<QrCode data={swap().reverse ? swap().invoice : swap().bip21} />
<a href={invoicePrefix + swap().invoice}>
<QrCode data={swap().invoice} />
</a>
<hr />
<p
onclick={() => clipboard(swap().invoice)}
Expand All @@ -50,9 +53,17 @@ const SwapCreated = () => {
{t("pay_invoice_webln")}
</span>
</Show>
<span class="btn" onclick={() => clipboard(swap().invoice)}>
{t("copy_invoice")}
</span>
<hr class="spacer" />
<div class="btns">
<span class="btn" onclick={() => clipboard(swap().invoice)}>
{t("copy_invoice")}
</span>
<Show when={isMobile}>
<a href={invoicePrefix + swap().invoice} class="btn">
{t("open_in_wallet")}
</a>
</Show>
</div>
</div>
);
};
Expand Down

0 comments on commit f5e9889

Please sign in to comment.