From 60b24b3d5951e159d09f42ed766c404e4b1acc4e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 11 Feb 2023 00:38:55 -0800 Subject: invoice type toggle --- src/lib/utils.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/lib/utils.js') diff --git a/src/lib/utils.js b/src/lib/utils.js index 80f7fe07..b3bb29ec 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -231,3 +231,11 @@ export function ss(str1, str2) { return 0.0; } + +export const types = { + bitcoin: 'bitcoin', + lightning: 'lightning', + internal: 'internal', + pot: 'pot', + classic: 'classic' +}; -- cgit v1.2.3 From 979d9dd27a147bae13ba953a7e260412fa024f57 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 14 Feb 2023 11:19:12 -0800 Subject: handle sending to user --- src/lib/utils.js | 2 ++ src/routes/(app)/[username]/(profile)/+page.svelte | 1 - src/routes/(app)/payment/[id]/+page.svelte | 42 ++++++++++++++++------ src/routes/(app)/send/[...text]/+page.server.js | 5 +-- 4 files changed, 36 insertions(+), 14 deletions(-) (limited to 'src/lib/utils.js') diff --git a/src/lib/utils.js b/src/lib/utils.js index b3bb29ec..86f722b9 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -147,6 +147,8 @@ export const login = async (user, cookies) => { export const auth = (cookies) => ({ authorization: `Bearer ${cookies.get('token')}` }); +export const fiat = (amount, rate) => (amount * rate) / sats; + export const f = (s, currency) => new Intl.NumberFormat('en-US', { style: 'currency', diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index baab8ba1..c704c00d 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -5,7 +5,6 @@ export let data; let { events, invoices, sent, received, subject, user } = data; - console.log(invoices);
diff --git a/src/routes/(app)/payment/[id]/+page.svelte b/src/routes/(app)/payment/[id]/+page.svelte index da21400a..7b2bdb26 100644 --- a/src/routes/(app)/payment/[id]/+page.svelte +++ b/src/routes/(app)/payment/[id]/+page.svelte @@ -1,6 +1,6 @@ -
+

{$t(amount < 0 ? 'payments.sent' : 'payments.received')}

@@ -34,13 +32,33 @@ {/if}
-
- {f(fiat, currency)} - ⚡️{`${s(total)}`} + Amount +
+ {f(fiat(amount, rate), currency)} + ⚡️{`${s(amount)}`} +
+
+ +
+ Network fee +
+ {f(fiat(fee, rate), currency)} + ⚡️{`${s(fee)}`}
+ {#if ourfee > 0} +
+ Platform fee +
+ {f(fiat(ourfee, rate), currency)} + ⚡️{`${s(ourfee)}`} +
+
+ {/if} +
+ Date
{format(new Date(created), 'MMMM d')}, {format(new Date(created), 'h:mm aaa')} @@ -49,6 +67,7 @@ {#if type === 'lightning'}
+ Proof
{$t('payments.preimage')}
{ref} @@ -56,12 +75,13 @@
{:else if type === 'bitcoin'}
+ Txid
-
diff --git a/src/routes/(app)/send/[...text]/+page.server.js b/src/routes/(app)/send/[...text]/+page.server.js index d09b4da9..b1089a5b 100644 --- a/src/routes/(app)/send/[...text]/+page.server.js +++ b/src/routes/(app)/send/[...text]/+page.server.js @@ -45,14 +45,15 @@ let parse = async (t, host) => { // bitcoin if (validate(t)) { try { - ({ id } = await get(`/invoice/${t}`)); + ({ id, user } = await get(`/invoice/${t}`)); } catch (e) { let r = `/send/bitcoin/${t}`; if (amount) r += '/' + amount; throw redirect(307, r); } - if (id) throw redirect(307, `/send/${id}`); + if (user) throw redirect(307, `/send/${user.username}`); + else if (id) throw redirect(307, `/send/${id}`); } // user -- cgit v1.2.3 From 50b270db6fda60b5b3e39a9dbada5c27a14cbad1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 22 Feb 2023 19:38:55 -0800 Subject: fee slider wip --- doc/img/translate_github.png | Bin 78506 -> 78512 bytes src/components/Slider.svelte | 56 +++++++++++++++++ src/components/index.js | 1 + src/lib/utils.js | 5 ++ .../[username]/(profile)/request/+page.server.js | 6 +- .../[username]/invoice/[hash]/tip/+page.svelte | 57 +---------------- .../[username]/settings/[...tab]/+page.server.js | 4 +- src/routes/(app)/ln/[lnurl]/+page.server.js | 9 +-- src/routes/(app)/login/+page.server.js | 4 +- .../(app)/pot/[name]/withdraw/+page.server.js | 5 +- src/routes/(app)/register/+page.server.js | 4 +- .../bitcoin/[address]/[...amount]/+page.server.js | 18 +++--- .../bitcoin/[address]/[...amount]/+page.svelte | 70 ++++++++++++++++----- src/routes/(app)/send/invoice/[id]/+page.server.js | 4 +- .../(app)/send/lightning/[payreq]/+page.server.js | 4 +- .../send/pot/[name]/[...amount]/+page.server.js | 2 +- .../user/[username]/[...amount]/+page.server.js | 4 +- src/routes/(app)/support/+page.server.js | 5 +- static/tickets/21.png | Bin 327907 -> 327913 bytes 19 files changed, 152 insertions(+), 106 deletions(-) create mode 100644 src/components/Slider.svelte (limited to 'src/lib/utils.js') diff --git a/doc/img/translate_github.png b/doc/img/translate_github.png index 22e33174..021ad5cb 100644 Binary files a/doc/img/translate_github.png and b/doc/img/translate_github.png differ diff --git a/src/components/Slider.svelte b/src/components/Slider.svelte new file mode 100644 index 00000000..84482c9d --- /dev/null +++ b/src/components/Slider.svelte @@ -0,0 +1,56 @@ + + + + + diff --git a/src/components/index.js b/src/components/index.js index ab54e09f..0d1d8d1d 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -1,3 +1,4 @@ +export { default as Slider } from './Slider.svelte'; export { default as Pinpad } from './Pinpad.svelte'; export { default as Balance } from './Balance.svelte'; export { default as Lnurlp } from './Lnurlp.svelte'; diff --git a/src/lib/utils.js b/src/lib/utils.js index 86f722b9..1d064c9a 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -148,6 +148,11 @@ export const login = async (user, cookies) => { export const auth = (cookies) => ({ authorization: `Bearer ${cookies.get('token')}` }); export const fiat = (amount, rate) => (amount * rate) / sats; +export const fd = async (req) => { + let obj = Object.fromEntries(await req.formData()); + for (let k in obj) (obj[k] === 'undefined' && (obj[k] = undefined)) ||( obj[k] === 'false' && (obj[k] = false)); + return obj; +}; export const f = (s, currency) => new Intl.NumberFormat('en-US', { diff --git a/src/routes/(app)/[username]/(profile)/request/+page.server.js b/src/routes/(app)/[username]/(profile)/request/+page.server.js index 2c1d6bde..e7ad6a8f 100644 --- a/src/routes/(app)/[username]/(profile)/request/+page.server.js +++ b/src/routes/(app)/[username]/(profile)/request/+page.server.js @@ -1,15 +1,15 @@ import { redirect } from '@sveltejs/kit'; -import { auth, post } from '$lib/utils'; +import { fd, auth, post } from '$lib/utils'; export const actions = { create: async ({ cookies, params, request, url }) => { - let form = Object.fromEntries(await request.formData()); + let form = await fd(request); let { id, requester } = await post('/requests', form, auth(cookies)); throw redirect(307, `/${params.username}/request/${id}`); }, delete: async ({ cookies, request }) => { - let form = Object.fromEntries(await request.formData()); + let form = await fd(request); let r = await post('/requests/delete', form, auth(cookies)); } }; diff --git a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte index d033c413..296ef9c6 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[hash]/tip/+page.svelte @@ -3,7 +3,7 @@ import { browser } from '$app/environment'; import { invoice as inv, request } from '$lib/store'; import { copy, focus, f, sat, get, reverseFormat, s, sats } from '$lib/utils'; - import { Icon } from '$comp'; + import { Icon, Slider } from '$comp'; import { goto } from '$app/navigation'; import { t } from '$lib/translations'; import { enhance } from '$app/forms'; @@ -37,9 +37,6 @@ customInput.value = ''; } tipPercent = e.target.value; - - clearTimeout(timeout); - timeout = setTimeout(update, 800); }; let submitting; @@ -56,10 +53,6 @@ }; let submit; - let update = async () => { - await tick(); - //submit.click(); - }; export let data; $: refresh(data); @@ -123,16 +116,7 @@ {#if !showCustomAmount}
{Math.round(tipPercent)}%
- +
@@ -201,43 +185,6 @@