diff options
| author | Adam Soltys <[email protected]> | 2025-11-26 10:56:00 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-11 15:33:08 -0800 |
| commit | 5f1c31b6618f0b895fb98c8f2a841989625eaf16 (patch) | |
| tree | 668a3cddaacbb03a1f3b5fdcf8700e49674dada0 /src/routes/(app)/+layout.svelte | |
| parent | 21023052918c0b787916ef78937e0be41f46142a (diff) | |
| download | coinos-ui-5f1c31b6618f0b895fb98c8f2a841989625eaf16.tar.gz coinos-ui-5f1c31b6618f0b895fb98c8f2a841989625eaf16.zip | |
ark
Diffstat (limited to 'src/routes/(app)/+layout.svelte')
| -rw-r--r-- | src/routes/(app)/+layout.svelte | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 830e5291..cf29ad7c 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -1,4 +1,5 @@ <script> + import { getWallet } from "$lib/ark"; import { SvelteToast } from "@zerodevx/svelte-toast"; import { onDestroy, onMount } from "svelte"; import { close, connect, send, socket } from "$lib/socket"; @@ -19,7 +20,7 @@ import AppHeader from "$comp/AppHeader.svelte"; import Nostr from "$comp/Nostr.svelte"; import Password from "$comp/Password.svelte"; - import { getCookie, warning } from "$lib/utils"; + import { s, success, post, getCookie, warning } from "$lib/utils"; import { t, locale, loading } from "$lib/translations"; import { goto, afterNavigate, preloadData } from "$app/navigation"; @@ -41,11 +42,40 @@ } }); + let handleArkPayment = async (notification) => { + console.log("NOTIF", notification); + let amount = notification.newVtxos.reduce((a, b) => a + b.value, 0); + console.log("AMOUNT", amount); + success(`Received ⚡️${s(amount)}!`); + const wallet = await getWallet(); + const address = await wallet.getAddress(); + + let invoice = await post(`/invoice`, { + invoice: { aid, type: "ark", amount }, + user, + }); + + let p = await post(`/post/ark/receive`, { + amount: vtxo.value, + iid: invoice.id, + }); + + goto(`/invoice/${p.iid}`, { + invalidateAll: true, + noScroll: true, + }); + }; + onMount(async () => { if (browser) { checkSocket(); $pin = getCookie("pin"); + if (user) { + const wallet = await getWallet(); + wallet.notifyIncomingFunds(handleArkPayment); + } + // if (window.NDEFReader) { // try { // $ndef = new NDEFReader(); |
