From ae9106030759a88d0259a12b27a7cd0f2a422062 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 6 Dec 2023 22:56:27 -0800 Subject: disable transitions on settings and payments --- src/lib/utils.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/lib/utils.js') diff --git a/src/lib/utils.js b/src/lib/utils.js index c0df81ae..adbe8356 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -186,6 +186,7 @@ export let f = (s, currency) => export let s = (s) => new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(s); + export let sat = (s) => { s = Math.abs(s); let p = Math.floor(Math.log(s) / Math.LN10 + 0.000000001); -- cgit v1.2.3 From fdef64da149ed0ceae3778238b9882a576e562ef Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 7 Dec 2023 23:36:01 -0800 Subject: verified flow --- src/components/AppHeader.svelte | 5 +---- src/lib/utils.js | 12 ++++++------ src/locales/en.json | 5 ++++- src/routes/(app)/[username]/settings/[...tab]/+page.svelte | 10 +++++++--- .../(app)/[username]/settings/[...tab]/_account.svelte | 2 +- src/routes/(app)/[username]/verify/[code]/+page.server.js | 8 +++++--- 6 files changed, 24 insertions(+), 18 deletions(-) (limited to 'src/lib/utils.js') diff --git a/src/components/AppHeader.svelte b/src/components/AppHeader.svelte index 352dcfa7..57892b18 100644 --- a/src/components/AppHeader.svelte +++ b/src/components/AppHeader.svelte @@ -150,11 +150,8 @@ {/if} diff --git a/src/lib/utils.js b/src/lib/utils.js index adbe8356..f55b47b6 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -101,8 +101,8 @@ export function reverseFormat(val, locale) { export let protectedRoutes = [/customers/, /settings/, /payments/]; -export let success = (m) => { - toast.pop(); +export let success = (m, clear = true) => { + if (clear) toast.pop(); toast.push(m, { theme: { "--toastBarBackground": "#F5F7FA", @@ -110,16 +110,16 @@ export let success = (m) => { }); }; -export let warning = (m) => { - toast.pop(); +export let warning = (m, clear = true) => { + if (clear) toast.pop(); toast.push(m, { theme: { "--toastBarBackground": "#FFCE22", }, }); }; -export let fail = (m) => { - toast.pop(); +export let fail = (m, clear = true) => { + if (clear) toast.pop(); toast.push(m, { theme: { "--toastBarBackground": "#E93535", diff --git a/src/locales/en.json b/src/locales/en.json index cefabaa3..ac8b0075 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -207,8 +207,11 @@ "nostrKeys": "Nostr key", "nostrDescription": "Your nostr key is used to sign and decrypt messages, keep it safe or someone may be able to impersonate you.", "seedDescription": "This 12 word seed phrase is used to derive your nostr private key and your self-custodial wallet keys which determine your auto-withdrawal addresses. Back it up and don't let anyone see it.", - "emailDescription": "For password resets and notifications", + "emailDescription": "For password resets and payment notifications only", "hideNsec": "Hide nostr secret key", + "saved": "Settings saved!", + "verifying": "Verification email sent", + "verified": "Email verified!", "revealNsec": "Reveal nostr secret key", "hideSeed": "Hide seed phrase", "revealSeed": "Reveal seed phrase", diff --git a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte index b300b75d..03b68973 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte @@ -39,7 +39,7 @@ $: form?.user && ({ user } = form); - $: form?.success && success("Settings saved!"); + $: form?.success && success($t("user.settings.saved"), false); $: form?.message && fail(form.message); @@ -60,6 +60,11 @@ let { address, id, username } = user; let loading; + onMount(() => { + if ($page.url.searchParams.get("verified")) + success($t("user.settings.verified")); + }); + async function handleSubmit() { try { loading = true; @@ -146,8 +151,7 @@ auth(cookies) ); - warning("Verification email sent"); - await sleep(4000); + warning($t("user.settings.verifying"), false); } catch (e) { console.log(e); } diff --git a/src/routes/(app)/[username]/settings/[...tab]/_account.svelte b/src/routes/(app)/[username]/settings/[...tab]/_account.svelte index e96341b4..773485f0 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_account.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_account.svelte @@ -103,7 +103,7 @@ {#if user.verified} - {:else} + {:else if user.email} {/if} diff --git a/src/routes/(app)/[username]/verify/[code]/+page.server.js b/src/routes/(app)/[username]/verify/[code]/+page.server.js index fda11c9e..3ddcd412 100644 --- a/src/routes/(app)/[username]/verify/[code]/+page.server.js +++ b/src/routes/(app)/[username]/verify/[code]/+page.server.js @@ -1,12 +1,14 @@ import { get } from "$lib/utils"; -import { error } from "@sveltejs/kit"; +import { error, redirect } from "@sveltejs/kit"; export let load = async ({ params: { code } }) => { + let user; try { - let user = await get(`/verify/${code}`); - return { user }; + user = await get(`/verify/${code}`); } catch (e) { console.log(e); return { error: "Verification failed" }; } + + throw redirect(307, `/${user.username}/settings/account?verified=true`); }; -- cgit v1.2.3 From fd137d961392ebd8f6da9f86e57a1d7dfe07eef1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 20 Dec 2023 14:41:19 -0800 Subject: new on-chain send ui --- bun.lockb | Bin 0 -> 119377 bytes package.json | 26 +--- src/components/Numpad.svelte | 5 +- src/components/Toggle.svelte | 2 +- src/lib/utils.js | 5 + src/locales/en.json | 2 + src/routes/(app)/+layout.svelte | 6 +- .../[username]/payments/[...page]/+page.svelte | 2 +- src/routes/(app)/payment/[id]/+page.svelte | 27 ++-- .../(app)/send/bitcoin/[address]/+page.svelte | 56 +++++++ .../bitcoin/[address]/[...amount]/+page.server.js | 40 ----- .../bitcoin/[address]/[...amount]/+page.svelte | 162 --------------------- .../[amount]/[...feeRate]/+page.server.js | 36 +++++ .../[address]/[amount]/[...feeRate]/+page.svelte | 134 +++++++++++++++++ src/routes/+page.svelte | 2 +- 15 files changed, 269 insertions(+), 236 deletions(-) create mode 100755 bun.lockb create mode 100644 src/routes/(app)/send/bitcoin/[address]/+page.svelte delete mode 100644 src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.server.js delete mode 100644 src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.svelte create mode 100644 src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js create mode 100644 src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte (limited to 'src/lib/utils.js') diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 00000000..3216c9fd Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json index 96741f0a..1a3f9638 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,10 @@ }, "devDependencies": { "@scure/base": "^1.1.1", + "@scure/bip39": "^1.2.1", "@sveltejs/adapter-node": "^2.0.0", "@sveltejs/kit": "^2.0.0", + "@sveltejs/vite-plugin-svelte": "^3.0.0", "@tailwindcss/line-clamp": "^0.4.2", "@zerodevx/svelte-toast": "^0.7.2", "autoprefixer": "^10.4.13", @@ -24,6 +26,7 @@ "html5-qrcode": "^2.3.8", "leaflet": "^1.9.3", "leaflet.markercluster": "^1.5.3", + "maplibre-gl": "^3.3.1", "nostr-tools": "^1.14.2", "postcss": "^8.4.20", "prettier": "2", @@ -34,30 +37,17 @@ "rollup": "^2.79.1", "screenfull": "^6.0.2", "svelte": "^4.0.0", + "svelte-adapter-bun": "^0.5.1", "svelte-outclick": "^3.3.3", "svelte-preprocess": "^5.0.3", "svelte-virtual-scroll-list": "^1.1.0", "sveltekit-i18n": "^2.2.2", "tailwind-scrollbar": "^2.1.0", "tailwindcss": "^3.2.4", + "uint8array-extras": "^1.0.0", + "unique-names-generator": "^4.7.1", "uuid": "^9.0.0", - "vite": "^5.0.0", - "@sveltejs/vite-plugin-svelte": "^3.0.0" - }, - "pnpm": { - "peerDependencyRules": { - "allowedVersions": { - "vite": "4" - } - } + "vite": "^5.0.0" }, - "type": "module", - "dependencies": { - "@faker-js/faker": "^8.2.0", - "@scure/bip39": "^1.2.1", - "maplibre-gl": "^3.3.1", - "svelte-adapter-bun": "^0.5.1", - "uint8array-extras": "^0.5.0", - "unique-names-generator": "^4.7.1" - } + "type": "module" } diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte index 7006d7aa..72dad375 100644 --- a/src/components/Numpad.svelte +++ b/src/components/Numpad.svelte @@ -118,6 +118,8 @@ .replace(/\./g, "") .replace("F", "."); + if (!clean) clean = " "; + if (fiat) clean = clean.replace(",", ""); if (clean !== html) { html = clean; @@ -171,8 +173,9 @@ } }; - let keydown = (e) => + let keydown = (e) => { e.key === "Enter" && (e.preventDefault() || submit.click()); + };
diff --git a/src/components/Toggle.svelte b/src/components/Toggle.svelte index 1e4cf4c4..2f92837d 100644 --- a/src/components/Toggle.svelte +++ b/src/components/Toggle.svelte @@ -12,6 +12,6 @@ class="sr-only peer" />
diff --git a/src/lib/utils.js b/src/lib/utils.js index f55b47b6..5303ec35 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -281,3 +281,8 @@ export function shuffleArray(array) { [array[i], array[j]] = [array[j], array[i]]; } } + + export let closest = (a, n) => + a.reduce((prev, curr) => + Math.abs(curr - n) < Math.abs(prev - n) ? curr : prev + ); diff --git a/src/locales/en.json b/src/locales/en.json index ac8b0075..cb42fa78 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -272,6 +272,8 @@ } }, "payments": { + "networkFee": "Network fee", + "ourFee": "Our fee", "create": "Create", "fund": "Fund", "addFunds": "Add Funds", diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index e439d43e..0480fd79 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -18,7 +18,7 @@ import Password from "$comp/Password.svelte"; import Request from "$comp/Request.svelte"; import { warning, protectedRoutes } from "$lib/utils"; - import { t, locale } from "$lib/translations"; + import { t, locale, loading } from "$lib/translations"; import { goto, onNavigate } from "$app/navigation"; export let data; @@ -129,7 +129,9 @@
- + {#if !$loading} + + {/if}
{#if $invoice} diff --git a/src/routes/(app)/[username]/payments/[...page]/+page.svelte b/src/routes/(app)/[username]/payments/[...page]/+page.svelte index 317f776b..1f20ea5c 100644 --- a/src/routes/(app)/[username]/payments/[...page]/+page.svelte +++ b/src/routes/(app)/[username]/payments/[...page]/+page.svelte @@ -238,7 +238,7 @@ {format(new Date(p.created), "h:mm aaa")}
- {format(new Date(p.created), "MMM d")} + {format(new Date(p.created), "MMM d, yyyy")}
diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index a1c7bbed..15c17a00 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -1,5 +1,7 @@ @@ -124,8 +131,8 @@
Date
- {format(new Date(created), "MMMM d")}, - {format(new Date(created), "h:mm aaa")} + {format(new Date(created), "h:mmaaa")} + {format(new Date(created), "MMM d, yyyy")}
@@ -140,8 +147,6 @@ class="flex font-bold hover:opacity-80 mb-auto my-auto" on:click={() => copy(id)} > - - @@ -151,7 +156,8 @@
+ +
+

{$t("payments.send")}

+ +
{address}
+ + + +
+ + +
+ +
+
+
diff --git a/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.server.js b/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.server.js deleted file mode 100644 index 2998f22a..00000000 --- a/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.server.js +++ /dev/null @@ -1,40 +0,0 @@ -import { fail, redirect } from "@sveltejs/kit"; -import { auth, post, fd } from "$lib/utils"; - -let seen = {}; -export const actions = { - default: async ({ cookies, request }) => { - try { - let { - address, - amount, - confirmed, - feeRate, - subtract, - pin, - stale, - ts, - } = await await fd(request); - if (seen[ts]) return fail(400, { message: "Duplicate form submission" }); - - let estimate = await post( - "/bitcoin/fee", - { address, amount, feeRate, subtract }, - auth(cookies) - ); - - let { tx } = estimate; - - if (stale || !confirmed) return fail(400, estimate); - - seen[ts] = 1; - setTimeout(() => delete seen[ts], 30000); - - await post("/bitcoin/send", { pin, subtract, tx }, auth(cookies)); - } catch (e) { - return fail(400, { message: e.message }); - } - - redirect(307, "/sent"); - }, -}; diff --git a/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.svelte deleted file mode 100644 index a8b86718..00000000 --- a/src/routes/(app)/send/bitcoin/[address]/[...amount]/+page.svelte +++ /dev/null @@ -1,162 +0,0 @@ - - - - -{#if form?.message} -
- {form.message} -
-{/if} - -
-

{$t("payments.send")}

- -
{address}
- - {#if confirmed} -
-

- {f(toFiat(amount, rate), currency)} -

-

⚡️{s(amount)}

-
- -
-

with fee

- -
-

- {f(toFiat(fee + ourfee, rate), currency)} -

-

⚡️{s(fee + ourfee)}

- -
-
- {:else} - - {/if} - -
- - - - - - - - - - {#if confirmed && adjusting} -
-
- Slower (~40 blocks) -
-
- Faster (~1 block) -
- -
-
-
- -
- -
- {/if} - -
- {#if !confirmed} - - {/if} - - -
-
-
diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js new file mode 100644 index 00000000..08741296 --- /dev/null +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js @@ -0,0 +1,36 @@ +import { fail, redirect } from "@sveltejs/kit"; +import { auth, post, fd } from "$lib/utils"; + +let seen = {}; + +export async function load({ params: { address, amount, feeRate }, cookies }) { + try { + let fees = await fetch( + `https://mempool.space/api/v1/fees/recommended` + ).then((r) => r.json()); + + if (!feeRate) feeRate = fees.halfHourFee; + + let { fee, ourfee, hex } = await post( + "/bitcoin/fee", + { address, amount, feeRate: feeRate }, + auth(cookies) + ); + + return { amount, address, fee, fees, feeRate, ourfee, hex }; + } catch (e) { + throw redirect(307, `/send/bitcoin/${address}`); + } +} + +export const actions = { + default: async ({ cookies, request }) => { + try { + let r = await post("/bitcoin/send", await fd(request), auth(cookies)); + } catch (e) { + return fail(400, { message: e.message }); + } + + redirect(307, "/sent"); + }, +}; diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte new file mode 100644 index 00000000..d583024c --- /dev/null +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.svelte @@ -0,0 +1,134 @@ + + + + +
+ {#if form?.message} +
+
{form.message}
+
+ {/if} + +

{$t("payments.send")}

+ +
{address}
+ +
+

+ {f(toFiat(amount, $rate), currency)} +

+

⚡️{s(amount)}

+
+ +
+

{$t("payments.networkFee")}

+ +
+ +
+

+ {f(toFiat(fee, $rate), currency)} +

+

⚡️{s(fee)}

+
+
+
+ +
+

{$t("payments.ourFee")}

+ +
+
+

+ {f(toFiat(ourfee, $rate), currency)} +

+

⚡️{s(ourfee)}

+
+
+
+ +
(submitting = true)}> + + + + +
+ +
+
+
+ + diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 3cffea21..23aaacfa 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,4 +1,4 @@ - diff --git a/src/routes/(app)/[username]/receive/[...param]/+page.svelte b/src/routes/(app)/[username]/receive/[...param]/+page.svelte index 37ab57f0..6d8939a9 100644 --- a/src/routes/(app)/[username]/receive/[...param]/+page.svelte +++ b/src/routes/(app)/[username]/receive/[...param]/+page.svelte @@ -49,7 +49,8 @@ bind:this={submit} type="submit" class="bg-black text-white rounded-xl w-full h-[48px] flex justify-center items-center font-semibold - opacity-100 hover:opacity-80"> + opacity-100 hover:opacity-80" + > {$t("payments.next")}
diff --git a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte index 714ed8db..54a2d71c 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte @@ -223,7 +223,8 @@ bind:this={submit} type="submit" class="border-2 border-black rounded-xl font-semibold mx-auto py-3 w-40 hover:opacity-80" - class:bg-black={submitting}> + class:bg-black={submitting} + > {#if submitting} {:else} diff --git a/src/routes/(app)/[username]/settings/[...tab]/_account.svelte b/src/routes/(app)/[username]/settings/[...tab]/_account.svelte index 773485f0..15ee7b0c 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_account.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_account.svelte @@ -109,7 +109,6 @@ -
{$t("user.settings.profileImage")} diff --git a/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte b/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte index 0e4301c4..539cfd5e 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_pos.svelte @@ -25,7 +25,8 @@ + value={parseInt(user.locktime)} + > diff --git a/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte b/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte index 870803fb..0266fa9c 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/_shopify.svelte @@ -28,7 +28,9 @@
admin.shopify.com/store/
+ > + admin.shopify.com/store/ +
$$ @@ -94,9 +93,8 @@ CVC/CVV @@ -115,7 +113,8 @@
@@ -71,7 +72,8 @@
@@ -81,13 +83,15 @@
diff --git a/src/routes/(app)/fund/[id]/withdraw/+page.svelte b/src/routes/(app)/fund/[id]/withdraw/+page.svelte index e7c1d852..7af07e38 100644 --- a/src/routes/(app)/fund/[id]/withdraw/+page.svelte +++ b/src/routes/(app)/fund/[id]/withdraw/+page.svelte @@ -47,7 +47,8 @@
diff --git a/src/routes/(app)/launch/purchase/+page.svelte b/src/routes/(app)/launch/purchase/+page.svelte index 3af3b186..49a51973 100644 --- a/src/routes/(app)/launch/purchase/+page.svelte +++ b/src/routes/(app)/launch/purchase/+page.svelte @@ -21,7 +21,9 @@

Purchase Ticket

+ > + Purchase Ticket +
@@ -43,21 +46,25 @@ {:else}

Payment Options

+ > + Payment Options +
diff --git a/src/routes/(app)/launch/purchase/card/+page.server.js b/src/routes/(app)/launch/purchase/card/+page.server.js index 416a66e4..9fb36b71 100644 --- a/src/routes/(app)/launch/purchase/card/+page.server.js +++ b/src/routes/(app)/launch/purchase/card/+page.server.js @@ -43,8 +43,7 @@ export const actions = { method, }).then((r) => r.json()); - if (status !== "succeeded") - error(500, { message: "Card payment failed" }); + if (status !== "succeeded") error(500, { message: "Card payment failed" }); let asset = await createTicket(cookies, form.get("username")); redirect(307, `/launch/thanks/${asset}`); diff --git a/src/routes/(app)/launch/purchase/card/+page.svelte b/src/routes/(app)/launch/purchase/card/+page.svelte index d7ef830d..6d33c87f 100644 --- a/src/routes/(app)/launch/purchase/card/+page.svelte +++ b/src/routes/(app)/launch/purchase/card/+page.svelte @@ -48,9 +48,8 @@ CVC/CVV @@ -68,7 +67,8 @@ diff --git a/src/routes/(app)/launch/ticket/+page.svelte b/src/routes/(app)/launch/ticket/+page.svelte index a4888727..6b16e804 100644 --- a/src/routes/(app)/launch/ticket/+page.svelte +++ b/src/routes/(app)/launch/ticket/+page.svelte @@ -7,7 +7,9 @@

Your Ticket

+ > + Your Ticket +

We've minted your ticket as an diff --git a/src/routes/(app)/login/+page.svelte b/src/routes/(app)/login/+page.svelte index b729d70f..cebbf41c 100644 --- a/src/routes/(app)/login/+page.svelte +++ b/src/routes/(app)/login/+page.svelte @@ -145,15 +145,14 @@

@@ -162,7 +161,8 @@ type="submit" class="bg-black text-white w-full rounded-2xl p-4 font-semibold hover:opacity-80" disabled={loading} - bind:this={btn}> + bind:this={btn} + > {#if loading} {:else} @@ -175,7 +175,8 @@ {$t("login.haveAccount")} + class="block md:inline text-black underline underline-offset-4 hover:opacity-80" + > {$t("login.register")}

diff --git a/src/routes/(app)/register/+page.server.js b/src/routes/(app)/register/+page.server.js index cdb5736e..318f6b98 100644 --- a/src/routes/(app)/register/+page.server.js +++ b/src/routes/(app)/register/+page.server.js @@ -15,15 +15,8 @@ export const actions = { let ip = request.headers.get("cf-connecting-ip"); let form = await fd(request); - let { - profile, - username, - password, - cipher, - salt, - pubkey, - loginRedirect, - } = form; + let { profile, username, password, cipher, salt, pubkey, loginRedirect } = + form; let user = { profile, username, password, cipher, salt, pubkey }; let error; diff --git a/src/routes/(app)/register/+page.svelte b/src/routes/(app)/register/+page.svelte index ef057fcf..5783059a 100644 --- a/src/routes/(app)/register/+page.svelte +++ b/src/routes/(app)/register/+page.svelte @@ -175,12 +175,14 @@
@@ -236,7 +240,8 @@ type="button" on:click={refresh} class="absolute right-0 top-4" - tabindex="5"> + tabindex="5" + >
@@ -271,7 +276,8 @@ type="button" tabindex="4" on:click={() => (revealPassword = !revealPassword)} - class="absolute right-0 top-4"> + class="absolute right-0 top-4" + >
@@ -285,7 +291,8 @@ type="submit" class="bg-black text-white w-full rounded-2xl p-4 font-semibold hover:opacity-80" disabled={loading} - bind:this={btn}> + bind:this={btn} + > {#if loading} {:else} @@ -298,7 +305,8 @@ {$t("login.haveAccount")} + class="block md:inline text-black underline underline-offset-4 hover:opacity-80" + > {$t("login.signIn")}

diff --git a/src/routes/(app)/reset/[code]/+page.svelte b/src/routes/(app)/reset/[code]/+page.svelte index 83e860ae..d93e8bdf 100644 --- a/src/routes/(app)/reset/[code]/+page.svelte +++ b/src/routes/(app)/reset/[code]/+page.svelte @@ -57,17 +57,23 @@
-
A new seed phrase will be generated for your account. You'll need to import your old seed phrase if you want to use the same nostr profile and savings account as before.
+
+ A new seed phrase will be generated for your account. You'll need to + import your old seed phrase if you want to use the same nostr profile + and savings account as before. +
+ on:click={back} + > + Cancel +
+Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From c4a7b68048d389cac3c68797ce4a44bca7979d17 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 2 Jan 2024 15:18:58 -0800 Subject: liquid payments --- .env.production | 1 + src/lib/utils.js | 14 ++++++++++++++ src/routes/(app)/payment/[id]/+page.svelte | 9 +++++++-- src/routes/(app)/send/[...text]/+page.server.js | 4 ++-- .../[address]/[amount]/[...feeRate]/+page.server.js | 8 +------- 5 files changed, 25 insertions(+), 11 deletions(-) (limited to 'src/lib/utils.js') diff --git a/.env.production b/.env.production index c04aa886..3f7aff52 100644 --- a/.env.production +++ b/.env.production @@ -2,4 +2,5 @@ PUBLIC_COINOS_URL=http://app:3119 PUBLIC_BTC=6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d PUBLIC_SOCKET=wss://coinos.io/ws PUBLIC_EXPLORER=https://mempool.space +PUBLIC_LIQUID_EXPLORER=https://liquid.network PUBLIC_DOMAIN=coinos.io diff --git a/src/lib/utils.js b/src/lib/utils.js index 9dbdc2ab..738413bf 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -287,3 +287,17 @@ export let closest = (a, n) => a.reduce((prev, curr) => Math.abs(curr - n) < Math.abs(prev - n) ? curr : prev ); + +export let isLiquid = (text) => + text.startsWith("Az") || + text.startsWith("lq1") || + text.startsWith("VJL") || + text.startsWith("VT") || + text.startsWith("XR") || + text.startsWith("XC") || + ((text.startsWith("H") || text.startsWith("G") || text.startsWith("Q")) && + text.length === 34) || + (text.startsWith("ert1q") && text.length === 43) || + (text.startsWith("ex1q") && text.length === 42) || + text.startsWith("el1qq") || + text.startsWith("lq1qq"); diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index 1acd0d3d..e07d630a 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -16,7 +16,7 @@ import Avatar from "$comp/Avatar.svelte"; import Icon from "$comp/Icon.svelte"; import { format } from "date-fns"; - import { PUBLIC_EXPLORER as expl } from "$env/static/public"; + import { PUBLIC_EXPLORER, PUBLIC_LIQUID_EXPLORER } from "$env/static/public"; export let data; let { user, payment: p } = data; @@ -37,6 +37,11 @@ } = p; let a = Math.abs(amount); + let expl = { + bitcoin: PUBLIC_EXPLORER, + liquid: PUBLIC_LIQUID_EXPLORER, + }[type]; + let print = async () => { await post(`/payment/${id}/print`, { id }); success("Printing!"); @@ -157,7 +162,7 @@ Txid
- {txid} { } // bitcoin - if (validate(t)) { + if (validate(t) || isLiquid(t)) { try { ({ id, user } = await get(`/invoice/${t}`)); } catch (e) { diff --git a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js index 86f9fde8..6f735f32 100644 --- a/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js +++ b/src/routes/(app)/send/bitcoin/[address]/[amount]/[...feeRate]/+page.server.js @@ -5,13 +5,7 @@ let seen = {}; export async function load({ params: { address, amount, feeRate }, cookies }) { try { - let fees = await fetch( - `https://mempool.space/api/v1/fees/recommended` - ).then((r) => r.json()); - - if (!feeRate) feeRate = fees.halfHourFee; - - let { fee, ourfee, hex } = await post( + let { fee, fees, ourfee, hex } = await post( "/bitcoin/fee", { address, amount, feeRate }, auth(cookies) -- cgit v1.2.3