diff options
| author | Adam Soltys <[email protected]> | 2026-02-14 15:46:09 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-14 15:46:09 -0800 |
| commit | 40fc5fe98c08357dff41539de48532d554aa73cb (patch) | |
| tree | 289e6f1af7f256b1e8ddab75d74e272ead7baa2f /src/routes | |
| parent | d242a387279119cfc6e191eff3b4e2228cbb5a4e (diff) | |
| download | coinos-ui-40fc5fe98c08357dff41539de48532d554aa73cb.tar.gz coinos-ui-40fc5fe98c08357dff41539de48532d554aa73cb.zip | |
custodial ark sends
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/+layout.svelte | 21 | ||||
| -rw-r--r-- | src/routes/(app)/[username]/(profile)/+page.svelte | 17 | ||||
| -rw-r--r-- | src/routes/(app)/account/[id]/+page.svelte | 26 | ||||
| -rw-r--r-- | src/routes/(app)/invoice/[id]/+page.svelte | 2 |
4 files changed, 36 insertions, 30 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)}!`); } } diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index 966925d5..4885189b 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -64,17 +64,12 @@ {#each accounts as account} <Account {user} {rates} {account} /> {/each} - <div class="flex justify-end"> - <a href="/account/new" class="contents" aria-label={$t("accounts.addAccount")}> - <button - class="btn btn-circle btn-accent !w-14 !h-14 !rounded-full" - aria-label={$t("accounts.addAccount")} - title={$t("accounts.addAccount")} - > - <iconify-icon noobserver icon="ph:plus-bold" width="28"></iconify-icon> - </button> - </a> - </div> + <a href="/account/new" class="contents"> + <button class="btn btn-accent w-full"> + <iconify-icon noobserver icon="ph:plus-bold" width="24"></iconify-icon> + {$t("accounts.addAccount")} + </button> + </a> </div> {#if locked} diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte index fa9d744d..157dd096 100644 --- a/src/routes/(app)/account/[id]/+page.svelte +++ b/src/routes/(app)/account/[id]/+page.svelte @@ -30,7 +30,7 @@ let currency = $state(data.account.currency || data.user.currency); let autowithdraw = $state(data.account.autowithdraw || false); let threshold = $state(data.account.threshold || data.user.threshold || 1000000); - let reserve = $state(data.account.reserve || data.user.reserve || 0); + let reserve = $state(data.account.reserve ?? 0); let destination = $state(data.account.destination || data.user.destination || ""); let rate = $derived(rates[currency]); @@ -113,21 +113,19 @@ </script> <div class="space-y-5"> - <h1 class="text-center text-3xl font-semibold">{$t("payments.accountSettings")}</h1> + <h1 class="text-center text-3xl font-semibold flex items-center justify-center gap-2"> + {#if account.type === "ark"} + <img src="/images/ark.png" class="w-8 h-8 rounded-full object-cover" alt="Ark" /> + {:else if seed} + <iconify-icon noobserver icon="cryptocurrency-color:btc" width="32"></iconify-icon> + {:else} + <img src="/images/icon.png" class="w-8 h-8" alt="Coinos" /> + {/if} + {displayType} {$t("payments.accountSettings").toLowerCase()} + </h1> <div class="container w-full mx-auto text-lg px-4 max-w-xl space-y-2"> <form class="space-y-5 pb-8" method="POST" use:enhance> - <div class="flex items-center gap-2 text-lg"> - <span class="font-bold">{$t("accounts.accountType")}:</span> - {#if account.type === "ark"} - <img src="/images/ark.png" class="w-6 h-6 rounded-full object-cover" alt="Ark" /> - {:else if seed} - <iconify-icon noobserver icon="cryptocurrency-color:btc" width="24"></iconify-icon> - {:else} - <img src="/images/icon.png" class="w-6 h-6" alt="Coinos" /> - {/if} - {displayType} - </div> <div class="space-y-1"> <label for="name" class="font-bold block">{$t("accounts.name")}</label> @@ -213,7 +211,7 @@ </button> {/if} - {#if seed} + {#if seed || account.type === "ark"} <button onclick={del} type="button" class="btn"> <iconify-icon noobserver icon="ph:trash-bold" width="32"></iconify-icon> <div class="my-auto">{$t("accounts.deleteAccount")}</div> diff --git a/src/routes/(app)/invoice/[id]/+page.svelte b/src/routes/(app)/invoice/[id]/+page.svelte index d8f30fd1..e4a5b85e 100644 --- a/src/routes/(app)/invoice/[id]/+page.svelte +++ b/src/routes/(app)/invoice/[id]/+page.svelte @@ -94,7 +94,7 @@ invoice.address_type = address_type; invoice.type = type; - if (type === "ark") { + if (type === "ark" && invoice.aid !== invoice.uid) { const wallet = await getWallet(); invoice.hash = await wallet.getAddress(); } |
