From a5faa64ba470f935ea3e7932feece3cd9fbadb90 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 26 Feb 2026 13:36:28 -0800 Subject: ark tests --- src/routes/(app)/+layout.svelte | 31 +++++++++++++++++++-- src/routes/(app)/account/[id]/+page.svelte | 5 +++- .../pay/[username]/[...amount]/+page.server.ts | 21 +++++++++++++- src/routes/(app)/payment/[id]/+page.svelte | 2 +- .../[amount]/[...feeRate]/+page.server.ts | 6 ++++ .../[address]/[amount]/[...feeRate]/+page.svelte | 32 +++++++++++++++------- .../[address]/[amount]/[...feeRate]/+page.svelte | 9 +++--- 7 files changed, 87 insertions(+), 19 deletions(-) (limited to 'src/routes') diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 0c88ff19..3fc8f9cf 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -1,5 +1,5 @@ diff --git a/src/routes/(app)/account/[id]/+page.svelte b/src/routes/(app)/account/[id]/+page.svelte index 065b85c6..62c4beea 100644 --- a/src/routes/(app)/account/[id]/+page.svelte +++ b/src/routes/(app)/account/[id]/+page.svelte @@ -5,7 +5,7 @@ import Toggle from "$comp/Toggle.svelte"; import WalletPass from "$comp/WalletPass.svelte"; import { goto } from "$app/navigation"; - import { copy, fail, focus, post } from "$lib/utils"; + import { copy, fail, focus, loc, post } from "$lib/utils"; import { importing } from "$lib/store"; import { enhance } from "$app/forms"; import { t } from "$lib/translations"; @@ -33,6 +33,7 @@ let name = $state(data.account.name || displayType); let currency = $state(data.account.currency || data.user.currency); let userCurrency = $derived(data.user.currency); + let locale = $derived(loc(data.user)); let currencyChanged = $derived(currency !== userCurrency); let updateUserCurrency = $state(false); @@ -325,6 +326,7 @@ {$t("payments.date")}
- {format(new Date(created), "MMM d, yyyy", { locale })}{format(new Date(created), "h:mmaaa", { locale })} + {format(new Date(created), "MMM d, yyyy", { locale })} {format(new Date(created), "h:mmaaa", { locale })}
diff --git a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.server.ts b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.server.ts index 10a6a737..9fa754d6 100644 --- a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.server.ts +++ b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.server.ts @@ -26,12 +26,18 @@ export async function load({ params: { address, amount }, cookies, parent }) { } const rate = rates[user.currency]; + const serverArkAddress = account.type === "ark" ? await get("/ark/address") : null; + + // Check if destination is the user's own vault address (custodial ark invoice) + const isCustodialForward = account.type === "ark" && address === account.arkAddress; return { account, amount, address, rate, + serverArkAddress, + isCustodialForward, }; } diff --git a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte index 02f1c4fb..744886ae 100644 --- a/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte +++ b/src/routes/(app)/send/ark/[address]/[amount]/[...feeRate]/+page.svelte @@ -2,12 +2,12 @@ import { t } from "$lib/translations"; import { enhance } from "$app/forms"; import Spinner from "$comp/Spinner.svelte"; - import { focus, s, post } from "$lib/utils"; + import { focus, loc, s, post } from "$lib/utils"; import { pin } from "$lib/store"; import { goto, invalidate } from "$app/navigation"; import { rate } from "$lib/store"; import { applyAction } from "$app/forms"; - import { sendArk } from "$lib/ark"; + import { sendArk, sendArkViaForward } from "$lib/ark"; import Amount from "$comp/Amount.svelte"; @@ -23,13 +23,24 @@ submitting = true; error = ""; try { - const txid = await sendArk(address, parseInt(amount)); - - const p = await post("/post/ark/vault-send", { - hash: txid, - amount: parseInt(amount), - aid: account.id, - }); + let p; + + if (data.serverArkAddress && (address === data.serverArkAddress || data.isCustodialForward)) { + // Vault→custodial: send to server and credit custodial account + p = await sendArkViaForward({ + serverArkAddress: data.serverArkAddress, + amount: parseInt(amount), + aid: account.id, + user: data.user, + }); + } else { + const txid = await sendArk(address, parseInt(amount)); + p = await post("/post/ark/vault-send", { + hash: txid, + amount: parseInt(amount), + aid: account.id, + }); + } goto(`/sent/${p.id}`, { invalidateAll: true }); } catch (e: any) { @@ -65,6 +76,7 @@ let balance = $derived(data.user.balance); let currency = $derived(data.user.currency); + let locale = $derived(loc(data.user)); let submitting = $state(false), submit = $state(); @@ -81,7 +93,7 @@ {#if !error}
{address}
- +
diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte index 967c47af..4cb22155 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte @@ -6,7 +6,7 @@ import Spinner from "$comp/Spinner.svelte"; import WalletPass from "$comp/WalletPass.svelte"; import { page } from "$app/stores"; - import { toFiat, f, focus, s, sat, closest, network } from "$lib/utils"; + import { toFiat, f, focus, loc, s, sat, closest, network } from "$lib/utils"; import { pin } from "$lib/store"; import { goto, invalidate } from "$app/navigation"; import { rate } from "$lib/store"; @@ -198,6 +198,7 @@ let balance = $derived(data.user.balance); let currency = $derived(data.user.currency); + let locale = $derived(loc(data.user)); let submitting = $state(), submit: any = $state(), showSettings = $state(); @@ -231,7 +232,7 @@
{address}
{/if} - + {#if fees}
@@ -245,7 +246,7 @@ {/each} - +
@@ -253,7 +254,7 @@

{$t("payments.platformFee")}

- +
{/if} {/if} -- cgit v1.2.3