diff options
| author | Adam Soltys <[email protected]> | 2026-02-05 11:13:16 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-11 15:34:32 -0800 |
| commit | ed4d86167d32503ad8813c81dda9591d1b1b8190 (patch) | |
| tree | 90121a8315e349a259289bafd3a1eea8859ad194 /src/lib | |
| parent | ec304f8bd1ffef69a85b75da033fbccbe6bfc72f (diff) | |
| download | coinos-ui-ed4d86167d32503ad8813c81dda9591d1b1b8190.tar.gz coinos-ui-ed4d86167d32503ad8813c81dda9591d1b1b8190.zip | |
fix ark handling
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ark.ts | 6 | ||||
| -rw-r--r-- | src/lib/store.ts | 29 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/lib/ark.ts b/src/lib/ark.ts index 7b289d8a..26c16a93 100644 --- a/src/lib/ark.ts +++ b/src/lib/ark.ts @@ -30,6 +30,12 @@ export const getBalance = async (): Promise<{ available: number }> => { return wallet.getBalance(); }; +export const getVtxos = async () => { + const wallet = await getWallet(); + if (!wallet) return []; + return wallet.getVtxos({ spendableOnly: false }); +}; + export const syncTransactions = async (aid: string) => { const wallet = await getWallet(); if (!wallet) return; diff --git a/src/lib/store.ts b/src/lib/store.ts index 0148f480..7cd17aec 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -44,13 +44,40 @@ export const persistLocal = (key, defaultValue: any = undefined) => { return s; }; +export const persistLocalValue = (key, defaultValue: any = undefined) => { + const s = writable( + browser && + localStorage.getItem(key) && + localStorage.getItem(key) !== "undefined" + ? JSON.parse(localStorage.getItem(key) || "") + : defaultValue, + ); + + s.subscribe((v) => { + try { + if (browser) { + if (v === undefined) { + localStorage.removeItem(key); + } else { + localStorage.setItem(key, JSON.stringify(v)); + } + } + } catch (e) { + console.log("problem setting key", v); + console.log(e); + } + }); + + return s; +}; + export const account = writable(); export const amountPrompt = persistLocal("amountPrompt"); export const avatar = writable(); export const banner = writable(); export const event = writable(); export const events = writable({}); -export const fiat = persistLocal("fiat", true); +export const fiat = persistLocalValue("fiat", true); export const installPrompt = writable(); export const invoice = writable(); export const last = writable(); |
