From d4c3d52fdde5fef8f72c1f572f1ce7c70da86b23 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 19 Sep 2024 15:55:38 -0700 Subject: progress on accounts --- src/components/Account.svelte | 2 +- src/components/Footer.svelte | 2 +- src/lib/invoice.ts | 4 +- src/lib/types.ts | 4 +- src/locales/en.json | 5 +- src/routes/(app)/[username]/receive/+page.svelte | 343 +++++++++++++++++++++ src/routes/(app)/account/pass/+page.svelte | 65 +++- src/routes/(app)/account/seed/+page.svelte | 5 +- src/routes/(app)/account/setup/+page.svelte | 4 +- src/routes/(app)/invoice/+page.server.ts | 7 +- src/routes/(app)/invoice/[id]/+layout.server.ts | 42 +-- src/routes/(app)/invoice/[id]/+page.svelte | 56 ++-- src/routes/(app)/invoice/[id]/tip/+page.server.ts | 2 +- src/routes/(app)/invoice/[id]/tip/+page.svelte | 3 + src/routes/(app)/logout/+page.server.ts | 2 +- src/routes/(app)/send/[...text]/+page.svelte | 6 +- src/routes/(app)/send/ecash/+page.svelte | 13 +- .../(app)/send/lightning/[payreq]/+page.svelte | 17 +- 18 files changed, 484 insertions(+), 98 deletions(-) create mode 100644 src/routes/(app)/[username]/receive/+page.svelte (limited to 'src') diff --git a/src/components/Account.svelte b/src/components/Account.svelte index 6294bc44..0baeb9a0 100644 --- a/src/components/Account.svelte +++ b/src/components/Account.svelte @@ -12,7 +12,7 @@ let refresh = (a) => ({ seed, balance, id } = a); let setAccount = () => - (document.cookie = `account=${id}; path=/; max-age=86400`); + (document.cookie = `account_id=${id}; path=/; max-age=86400`); diff --git a/src/components/Footer.svelte b/src/components/Footer.svelte index d70c013c..067e185e 100644 --- a/src/components/Footer.svelte +++ b/src/components/Footer.svelte @@ -4,7 +4,7 @@ import { t } from "$lib/translations"; const followLinks = [ - { url: "https://twitter.com/coinoswallet", titleID: "twitter" }, + { url: "nostr:nprofile1qqst4qyeqenw7zm0fwjsty68h6cnys5jre2xd8ngqpjv5a2j26s78fspz4mhxue69uhhyetvv9ujucm0d9hx7uewd9hsgwx239", titleID: "nostr" }, { url: "https://t.me/coinoswallet", titleID: "telegram" }, { url: "https://linktr.ee/coinos.io", titleID: "linktree" }, ]; diff --git a/src/lib/invoice.ts b/src/lib/invoice.ts index 9745c27b..0a50b876 100644 --- a/src/lib/invoice.ts +++ b/src/lib/invoice.ts @@ -2,14 +2,14 @@ import { auth, get, post } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; export default async ({ cookies, request }) => { - let account = cookies.get("account"); + let account_id = cookies.get("account_id"); let form = await request.formData(); let rates = await get("/rates"); let amount = parseInt(form.get("amount")); let invoice = { - account, + account_id, amount, items: JSON.parse(form.get("items")), memo: form.get("memo"), diff --git a/src/lib/types.ts b/src/lib/types.ts index 666ea1fb..67a51f62 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -14,10 +14,10 @@ export interface User { } export interface Invoice { - account: string; + account_id: string; id?: string; memoPrompt?: boolean; memo?: string; rate: number; - type: string; + type?: string; } diff --git a/src/locales/en.json b/src/locales/en.json index ba7ebc87..36357ef2 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -62,6 +62,7 @@ "support": "Support", "telegram": "Telegram", "twitter": "Twitter", + "nostr": "Nostr", "documentation": "Documentation" }, "howItWorks": { @@ -310,7 +311,7 @@ "ecash": "Ecash", "memo": "Notes", "voucherText": "Enter an ecash or lnurlw code", - "createEcash": "Create ecash", + "createEcash": "Mint e-cash", "tips": "Tips", "options": "options", "bump": "Bump fee", @@ -338,7 +339,7 @@ "openLink": "Open wallet", "setAmount": "Set amount", "moreOptions": "More options", - "redeemVoucher": "Ecash or LNURLw", + "redeemVoucher": "Ecash", "total": "Total", "gainLoss": "Gain/Loss", "presentValue": "Present Value", diff --git a/src/routes/(app)/[username]/receive/+page.svelte b/src/routes/(app)/[username]/receive/+page.svelte new file mode 100644 index 00000000..7d7958f1 --- /dev/null +++ b/src/routes/(app)/[username]/receive/+page.svelte @@ -0,0 +1,343 @@ + + +
+ {#if $showQr} +
+ + {txt} + +
+ {:else} +
+ {txt} +
+ {/if} + + {#each invoice.items as i} +
+
{i.quantity}
+
+ {i.name} +
+
+ {f(i.price * i.quantity, currency)} +
+
+ {sat(btc(i.price * i.quantity, rate))} +
+
+ {/each} + + {#if amount > 0} +
+
+ {f(amountFiat, currency)} + + {#if tip} + + +{f(tip * (rate / sats), currency)} + + {/if} +
+
+ ⚡️{`${s(amount)}`} + + {#if tip} + + +⚡️{s(tip)} + + {/if} +
+
+ {/if} + +
+ + + {#if user?.id === invoice?.user?.id} + + {:else} + + + + {/if} + +
+ +
+
+ + {#if account_id === user.id} +
+ + + + + + + {#if user?.id === invoice?.user?.id} + + + + {/if} +
+ + {#if type === types.liquid} +
+
+ {$t("payments.onlyLbtc")} + L-BTC, + {$t("payments.dontDeposit")} +
+
+ {/if} + {/if} +
+ +{#if settingAmount} +
+
+
+ +
+ + +
+ + +
+
{$t("payments.amountPrompt")}
+ +
+
+
+{/if} + + diff --git a/src/routes/(app)/account/pass/+page.svelte b/src/routes/(app)/account/pass/+page.svelte index ee29d2c3..0eb16072 100644 --- a/src/routes/(app)/account/pass/+page.svelte +++ b/src/routes/(app)/account/pass/+page.svelte @@ -18,7 +18,7 @@ let { user } = data; - let confirm, password; + let confirm, password, revealPassword, revealConfirm; onMount(() => { if (!$mnemonic) goto("/account/savings"); @@ -65,13 +65,66 @@ class="container w-full mx-auto text-lg px-4 max-w-xl space-y-5" >

- Please add a password to the account. It should be different than your - login password. We won't be able to reset it. You'll - need it to make withdrawals. + Careful! If you lose this password you won't be able to use the account. + We can't recover it for you.

- - +
+ {#if revealPassword} + + {:else} + + {/if} + +
+ +
+ {#if revealConfirm} + + {:else} + + {/if} + +
- - {/if} - {#if type === types.liquid} -
-
- {$t("payments.onlyLbtc")} - L-BTC, - {$t("payments.dontDeposit")} -
+ {#if user?.id === invoice?.user?.id} +
+ + + {/if}
- {/if} - {#if user?.id === invoice?.user?.id} - - - + {#if type === types.liquid} +
+
+ {$t("payments.onlyLbtc")} + L-BTC, + {$t("payments.dontDeposit")} +
+
+ {/if} {/if} diff --git a/src/routes/(app)/invoice/[id]/tip/+page.server.ts b/src/routes/(app)/invoice/[id]/tip/+page.server.ts index 8417de91..48ebf970 100644 --- a/src/routes/(app)/invoice/[id]/tip/+page.server.ts +++ b/src/routes/(app)/invoice/[id]/tip/+page.server.ts @@ -1,7 +1,7 @@ import invoice from "$lib/invoice"; import { redirect } from "@sveltejs/kit"; -export async function load({ parent, params }) { +export async function load({ parent }) { let { invoice } = await parent(); if (!invoice.amount) redirect(307, `/invoice/${invoice.id}`); diff --git a/src/routes/(app)/invoice/[id]/tip/+page.svelte b/src/routes/(app)/invoice/[id]/tip/+page.svelte index 35b24bf1..e4510693 100644 --- a/src/routes/(app)/invoice/[id]/tip/+page.svelte +++ b/src/routes/(app)/invoice/[id]/tip/+page.svelte @@ -59,6 +59,7 @@ $: refresh(data); let { invoice, id, user, rates } = data; let { + account_id, amount, hash, items, @@ -81,6 +82,7 @@ ({ invoice, id } = data); ({ + account_id, amount, hash, items, @@ -111,6 +113,7 @@
+ diff --git a/src/routes/(app)/logout/+page.server.ts b/src/routes/(app)/logout/+page.server.ts index 9c2a029c..03dff6a8 100644 --- a/src/routes/(app)/logout/+page.server.ts +++ b/src/routes/(app)/logout/+page.server.ts @@ -7,7 +7,7 @@ const opts = { export async function load({ cookies }) { let lang = cookies.get("lang"); - cookies.set("account", "", opts); + cookies.set("account_id", "", opts); cookies.set("lang", "", opts); cookies.set("username", "", opts); cookies.set("token", "", opts); diff --git a/src/routes/(app)/send/[...text]/+page.svelte b/src/routes/(app)/send/[...text]/+page.svelte index d1b6cc23..be7fc664 100644 --- a/src/routes/(app)/send/[...text]/+page.svelte +++ b/src/routes/(app)/send/[...text]/+page.svelte @@ -18,7 +18,7 @@ let el, text, pasted, w; - let keypress = (e) => e.key === "Enter" && (e.preventDefault() || el.click()); + let keypress = (e) => e.key === "Enter" ? (e.preventDefault() || el.click()) : (pasted = false); let paste = async () => { text = await navigator.clipboard.readText(); @@ -52,7 +52,7 @@ name="text" placeholder={$t("user.send.placeholder")} on:keypress={keypress} - class="w-full p-4 border rounded-xl h-48 text-xl" + class="w-full p-4 border rounded-xl h-32 text-xl" bind:value={text} on:paste={() => (pasted = true)} autocapitalize="none" @@ -95,7 +95,7 @@ type="button" class="flex border rounded-2xl px-6 py-5 w-full font-bold gap-2 justify-center text-xl bg-primary" > - +
{$t("payments.createEcash")}
diff --git a/src/routes/(app)/send/ecash/+page.svelte b/src/routes/(app)/send/ecash/+page.svelte index 615c068a..ef8e368c 100644 --- a/src/routes/(app)/send/ecash/+page.svelte +++ b/src/routes/(app)/send/ecash/+page.svelte @@ -30,18 +30,14 @@
-

- {$t("payments.createEcash")} -

- -
+
{#if submitting} {:else} - {$t("payments.mint")} + +
{$t("payments.mint")}
{/if}
diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/+page.svelte index 57a17e01..74c100f8 100644 --- a/src/routes/(app)/send/lightning/[payreq]/+page.svelte +++ b/src/routes/(app)/send/lightning/[payreq]/+page.svelte @@ -58,11 +58,7 @@ let toggle = () => (show = !show); - - -
+
{#if amount} {#if form?.message}
@@ -81,12 +77,9 @@

⚡️{s(amount)}

-
-
- {$t("payments.to")} -
- -

{alias}

+
+ {$t("payments.to")} + {alias}
{#if ourfee} @@ -109,7 +102,7 @@ use:enhance on:submit={submit} action="?/send" - class="space-y-5" + class="space-y-2" > -- cgit v1.2.3