aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/+layout.svelte
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-14 15:46:09 -0800
committerAdam Soltys <[email protected]>2026-02-14 15:46:09 -0800
commit40fc5fe98c08357dff41539de48532d554aa73cb (patch)
tree289e6f1af7f256b1e8ddab75d74e272ead7baa2f /src/routes/(app)/+layout.svelte
parentd242a387279119cfc6e191eff3b4e2228cbb5a4e (diff)
downloadcoinos-ui-40fc5fe98c08357dff41539de48532d554aa73cb.tar.gz
coinos-ui-40fc5fe98c08357dff41539de48532d554aa73cb.zip
custodial ark sends
Diffstat (limited to 'src/routes/(app)/+layout.svelte')
-rw-r--r--src/routes/(app)/+layout.svelte21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte
index 2c96fc7c..2d252385 100644
--- a/src/routes/(app)/+layout.svelte
+++ b/src/routes/(app)/+layout.svelte
@@ -1,5 +1,5 @@
<script lang="ts">
- import { getWallet, syncTransactions, settle, arkkey, arkaid } from "$lib/ark";
+ import { getWallet, syncTransactions, settle, arkkey, arkaid, sendArk } from "$lib/ark";
import { SvelteToast } from "@zerodevx/svelte-toast";
import { onDestroy, onMount } from "svelte";
import { close, connect, send, socket } from "$lib/socket";
@@ -22,7 +22,7 @@
import AppHeader from "$comp/AppHeader.svelte";
import Nostr from "$comp/Nostr.svelte";
import Password from "$comp/Password.svelte";
- import { s, f, toFiat, success, getCookie, warning } from "$lib/utils";
+ import { s, f, toFiat, success, getCookie, warning, post } from "$lib/utils";
import { t, locale, loading } from "$lib/translations";
import { goto, invalidate, afterNavigate, preloadData } from "$app/navigation";
@@ -52,6 +52,7 @@
});
let arkSyncing = false;
+ let arkForwarding = false;
let arkSync = async () => {
if (arkSyncing) return;
@@ -61,11 +62,23 @@
const aid = $arkaid || getCookie("aid") || user.id;
const result = await syncTransactions(aid);
- if (result?.received > 0) {
+ if (result?.forward && !arkForwarding) {
+ arkForwarding = true;
+ try {
+ const { serverArkAddress, amount, iid } = result.forward;
+ const txid = await sendArk(serverArkAddress, amount);
+ await post("/post/ark/vault-send", { hash: txid, amount, aid });
+ await post("/post/ark/receive", { amount, hash: txid, iid });
+ } catch (e) {
+ console.error("Ark custodial forward failed:", e);
+ } finally {
+ arkForwarding = false;
+ }
+ } else if (result?.received > 0) {
if ($fiat && $rateStore && user?.currency) {
success(`Received ${f(toFiat(result.received, $rateStore as number), user.currency)}!`);
} else {
- success(`Received ⚡️${s(result.received)}!`);
+ success(`Received ${s(result.received)}!`);
}
}