aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-02 23:30:20 -0800
committerAdam Soltys <[email protected]>2026-02-11 15:33:09 -0800
commite8200be39f7b89efd5379c3c5bc24ca4533bf39c (patch)
tree46360ba397abeb8f919411fb8fdee0a0cfb50f0b /src/lib
parente8105a9ad2eee8e8c3874851b245c6c755216298 (diff)
downloadcoinos-ui-e8200be39f7b89efd5379c3c5bc24ca4533bf39c.tar.gz
coinos-ui-e8200be39f7b89efd5379c3c5bc24ca4533bf39c.zip
sync and settle
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ark.ts28
1 files changed, 28 insertions, 0 deletions
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();
+};