aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-09-13 19:31:25 -0700
committerAdam Soltys <[email protected]>2022-09-13 19:31:25 -0700
commit8631c7f3e09b76db0540e1519b0c13dcb9558110 (patch)
tree378690891b12a5e1ec55ff7b455da1c366cad62a /src
parent41560c73f63f1438eee3602ccb1b2093c51c5e56 (diff)
downloadcoinos-ui-8631c7f3e09b76db0540e1519b0c13dcb9558110.tar.gz
coinos-ui-8631c7f3e09b76db0540e1519b0c13dcb9558110.zip
use integer for sats amount
Diffstat (limited to 'src')
-rw-r--r--src/routes/[username]/receive/+page.svelte16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/routes/[username]/receive/+page.svelte b/src/routes/[username]/receive/+page.svelte
index 05ee5758..dd7b3d25 100644
--- a/src/routes/[username]/receive/+page.svelte
+++ b/src/routes/[username]/receive/+page.svelte
@@ -11,10 +11,10 @@
let amountFiat = 0;
let amountSats = 0;
- $: amount = useFiat ? Math.round(amountFiat / ($selectedRate / 100000000)) : amountSats;
+ $: amount = parseInt(useFiat ? Math.round(amountFiat / ($selectedRate / 100000000)) : amountSats);
$: $invoiceAmount = parseInt(
- amountSats === 0 || amountSats === '0' ? amountFiat / ($selectedRate / 100000000) : amountSats
+ !amountSats ? amountFiat / ($selectedRate / 100000000) : amountSats
);
$: $invoiceAmountFiat = parseInt(
@@ -64,11 +64,11 @@
} else {
if (value === '.') {
return;
- } else if (amountSats === '0' && value !== '<' && value !== '0') {
- amountSats = value;
+ } else if (!amountSats && value !== '<' && value !== '0') {
+ amountSats = parseInt(value);
} else if (value === '<') {
if (amountSats !== 0) {
- amountSats = amountSats.slice(0, amountSats.length - 1);
+ amountSats = Math.floor(amountSats / 10);
if (amountSats.length === 0) {
amountSats = 0;
amountFiat = 0;
@@ -77,7 +77,7 @@
} else if (value !== '<' && parseInt(amountSats + value) > 100000000) {
warning($t('user.receive.lessThan1BTCWarning'));
} else {
- amountSats = amountSats + value;
+ amountSats = parseInt(amountSats + value);
}
}
};
@@ -132,11 +132,11 @@
<button
on:click={() => {
if (useFiat) {
- amountSats = (amountFiat / ($selectedRate / 100000000)).toFixed(0).toString();
+ amountSats = parseInt((amountFiat / ($selectedRate / 100000000)).toFixed(0));
} else {
amountFiat =
(amountSats * ($selectedRate / 100000000)).toFixed(2) > 0.0
- ? (amountSats * ($selectedRate / 100000000)).toFixed(2).toString()
+ ? (amountSats * ($selectedRate / 100000000)).toFixed(2)
: 0;
}
useFiat = !useFiat;