From bc3ebb4b4b3fdcd61be61f1e4566bd0137d904e3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 22 Dec 2023 11:27:40 -0800 Subject: percentage based maxfee --- src/locales/en.json | 1 + .../(app)/send/lightning/[payreq]/+page.svelte | 97 +++++++++++++--------- 2 files changed, 60 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/locales/en.json b/src/locales/en.json index 5d42e9fa..64b72ded 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -298,6 +298,7 @@ "details": "Transaction Details", "header": "Payments", "preimage": "Proof of payment", + "maxfee": "Max fee", "type": "Type", "time": "Time", "sent": "Sent", diff --git a/src/routes/(app)/send/lightning/[payreq]/+page.svelte b/src/routes/(app)/send/lightning/[payreq]/+page.svelte index a5b812cb..12b5c858 100644 --- a/src/routes/(app)/send/lightning/[payreq]/+page.svelte +++ b/src/routes/(app)/send/lightning/[payreq]/+page.svelte @@ -5,21 +5,43 @@ import Numpad from "$comp/Numpad.svelte"; import Spinner from "$comp/Spinner.svelte"; import { page } from "$app/stores"; - import { back, s } from "$lib/utils"; - import { pin } from "$lib/store"; + import { back, fiat, f, s } from "$lib/utils"; + import { rate, pin } from "$lib/store"; export let data; export let form; let { payreq } = $page.params; - let { alias, rates } = data; - - let { currency } = data.user; + let { + alias, + rates, + user: { currency }, + } = data; let a; - let maxfee = 10000; + + $: reload(data); + let reload = (data) => { + ({ + alias, + rates, + user: { currency }, + } = data); + if (!$rate) $rate = rates[currency]; + }; $: amount = form?.amount || data.amount; - $: rate = rates[currency]; + $: maxfee = + amount < 100 + ? amount * 5 + : amount < 1000 + ? amount + : amount < 10000 + ? amount * 0.5 + : amount < 100000 + ? amount * 0.1 + : amount < 1000000 + ? amount * 0.05 + : amount * 0.01; let loading; let submit = () => (loading = true); @@ -43,21 +65,25 @@ {/if} -
+
{#if amount} -
-

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

-

- ⚡️{s(amount)} -

-

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

-

{alias}

+

+ {$t("payments.send")} +

+ +
+

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

+

⚡️{s(amount)}

+

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

+ +

{alias}

+
- + +
+ + + +
+ ⚡️ +
+
- - {#if show} -
- - - -
- ⚡️ -
-
- {:else} -
- -
- {/if} {:else}
- +