From e8200be39f7b89efd5379c3c5bc24ca4533bf39c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 2 Feb 2026 23:30:20 -0800 Subject: sync and settle --- src/components/Payments.svelte | 3 +++ src/lib/ark.ts | 28 ++++++++++++++++++++++++++++ src/routes/(app)/+layout.svelte | 17 ++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/components/Payments.svelte b/src/components/Payments.svelte index 36633089..daedb036 100644 --- a/src/components/Payments.svelte +++ b/src/components/Payments.svelte @@ -101,6 +101,9 @@ alt="Liquid" /> + {:else if p.type === types.ark} + {/if}
diff --git a/src/lib/ark.ts b/src/lib/ark.ts index 487898ae..05a3963d 100644 --- a/src/lib/ark.ts +++ b/src/lib/ark.ts @@ -1,4 +1,5 @@ import { persistLocal } from "$lib/store"; +import { post } from "$lib/utils"; import { SingleKey, Wallet } from "@arkade-os/sdk"; import { get } from "svelte/store"; @@ -25,3 +26,30 @@ export const getBalance = async (): Promise<{ available: number }> => { const wallet = await getWallet(); return wallet.getBalance(); }; + +export const syncTransactions = async (aid: string) => { + const wallet = await getWallet(); + if (!wallet) return; + + const history = await wallet.getTransactionHistory(); + if (!history.length) return; + + const transactions = history.map((tx) => ({ + hash: tx.key.arkTxid || tx.key.commitmentTxid, + amount: tx.type === "RECEIVED" ? tx.amount : -tx.amount, + settled: tx.settled, + createdAt: tx.createdAt, + })); + + return post("/ark/sync", { transactions, aid }); +}; + +export const settle = async () => { + const wallet = await getWallet(); + if (!wallet) return; + + const balance = await wallet.getBalance(); + if (!balance.preconfirmed) return; + + return wallet.settle(); +}; diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 6624fff8..66596038 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -1,5 +1,5 @@