From d309ab34c550912b5d1b31762eed23bb69f83f82 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 8 Feb 2023 16:46:10 -0800 Subject: invoice requests and btc deposits --- src/routes/(app)/[username]/(profile)/+page.svelte | 59 ++++++++++++++-------- .../[username]/invoice/[hash]/+layout.server.js | 7 ++- .../(app)/[username]/invoice/[hash]/+page.svelte | 12 ++--- .../[username]/receive/[...param]/+page.svelte | 10 +++- src/routes/(static)/bounties/+page.svelte | 31 ++++++------ 5 files changed, 73 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/routes/(app)/[username]/(profile)/+page.svelte b/src/routes/(app)/[username]/(profile)/+page.svelte index af191a2b..baab8ba1 100644 --- a/src/routes/(app)/[username]/(profile)/+page.svelte +++ b/src/routes/(app)/[username]/(profile)/+page.svelte @@ -1,9 +1,11 @@
@@ -13,28 +15,41 @@
- - - - - - - - - - - - - - - - - - - - - - + {#each invoices as { amount, currency, rate, request: { requester, recipient }, hash }} + {@const requested = user.username === requester?.username} + +
+
+
+ {#if requested} +
+ +
+

{$t('payments.invoiceFrom')}

+

{recipient.username}

+
+
+ {:else} +
+ +
+

{$t('payments.awaiting')}

+

{requester.username}

+
+
+ {/if} +
+
+
+ {f(amount * (rate / sats), currency)} +
+ +
{sat(amount)}
+
+
+
+
+ {/each} {#each received as { id, invoice, memo, requester: r }} diff --git a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js index 0f6168e3..b5323d3f 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js +++ b/src/routes/(app)/[username]/invoice/[hash]/+layout.server.js @@ -2,11 +2,16 @@ import Qr from 'qrcode-base64'; import { get } from '$lib/utils'; import { redirect } from '@sveltejs/kit'; -export async function load({ depends, params, url }) { +export async function load({ depends, params, url, parent }) { depends('app:invoice'); + let { user } = await parent(); let { hash } = params; let invoice = await get(`/invoice/${hash}`); + + if (user && invoice.uid !== user.id && !url.pathname.includes('tip')) + throw redirect(307, `/send/invoice/${hash}`); + let { amount, received } = invoice; amount = parseInt(amount); diff --git a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte index 6d7e1dda..ad9721e7 100644 --- a/src/routes/(app)/[username]/invoice/[hash]/+page.svelte +++ b/src/routes/(app)/[username]/invoice/[hash]/+page.svelte @@ -13,8 +13,8 @@ $: refresh(data); let { invoice, id, user, sm, lg } = data; let { - address, amount, + hash, type, rate, received, @@ -34,8 +34,8 @@ let refresh = (data) => { ({ invoice, id } = data); ({ - address, amount, + hash, type, rate, received, @@ -61,8 +61,8 @@ }); }); - $: link = address ? text : `lightning:${text}`; - $: txt = address || text; + $: link = type === 'bitcoin' ? text : `lightning:${text}`; + $: txt = type === 'bitcoin' ? hash : text; let full; let toggle = () => { @@ -115,8 +115,8 @@ {/if}
-
diff --git a/src/routes/(app)/[username]/receive/[...param]/+page.svelte b/src/routes/(app)/[username]/receive/[...param]/+page.svelte index 29a0f7a5..99d95be0 100644 --- a/src/routes/(app)/[username]/receive/[...param]/+page.svelte +++ b/src/routes/(app)/[username]/receive/[...param]/+page.svelte @@ -1,5 +1,5 @@
@@ -43,5 +46,10 @@ > {amount ? $t('payments.next') : $t('payments.sendersChoice')} + +
+ {type[0].toUpperCase() + type.substring(1, type.length)} + +
diff --git a/src/routes/(static)/bounties/+page.svelte b/src/routes/(static)/bounties/+page.svelte index 22d4283e..140b9c16 100644 --- a/src/routes/(static)/bounties/+page.svelte +++ b/src/routes/(static)/bounties/+page.svelte @@ -2,9 +2,8 @@

Bounties

- We'd like to see more on-the-ground merchant adoption in our hometown of Vancouver so we're - offering ⚡️1,000,000 to the first 10 people that help us onboard businesses in the following - categories: + We're offering ⚡️1,000,000 to the first 10 people that help us onboard businesses + in the following categories to take bitcoin payments:

-

- The business owners can expect free ongoing support and promotion from us and our community. - We'll consult with them and make sure they're all trained up and ready to go then we'll help get - the word out. -

-

Terms and Conditions

-