aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-23 08:03:07 -0700
committerAdam Soltys <[email protected]>2023-03-23 08:03:07 -0700
commit4bf37cacf8502d5937187788b6738b909146940c (patch)
treea0e25e0c3bb9fc3e1ab6ca7b473f9996295926aa /src
parentaa258684dd8cf953afe540abb233ab0daad09253 (diff)
downloadcoinos-ui-4bf37cacf8502d5937187788b6738b909146940c.tar.gz
coinos-ui-4bf37cacf8502d5937187788b6738b909146940c.zip
use subject currency
Diffstat (limited to 'src')
-rw-r--r--src/routes/(app)/send/user/[username]/[...amount]/+page.server.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js b/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js
index f6ffbcd5..0a9dda6e 100644
--- a/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js
+++ b/src/routes/(app)/send/user/[username]/[...amount]/+page.server.js
@@ -2,13 +2,16 @@ import { error, fail, redirect } from '@sveltejs/kit';
import { types, sats, fd, auth, get, post } from '$lib/utils';
export async function load({ cookies, params, parent }) {
+ let subject = await get(`/users/${params.username}`);
+ if (subject.username === user?.username) throw error(500, { message: 'Cannot send to self' });
+
let { rates, user } = await parent();
let { username } = params;
let [amount, currency] = params.amount.split('/');
if (amount) {
- let rate = rates[currency ? currency.toUpperCase() : user.currency];
- if (!rate) throw error(500, "Invalid currency symbol");
+ let rate = rates[currency ? currency.toUpperCase() : subject.currency];
+ if (!rate) throw error(500, 'Invalid currency symbol');
if (currency) amount = (amount * sats) / rate;
let { hash } = await post(
@@ -23,8 +26,6 @@ export async function load({ cookies, params, parent }) {
throw redirect(307, `/${username}/invoice/${hash}`);
}
- let subject = await get(`/users/${params.username}`);
- if (subject.username === user?.username) throw error(500, { message: 'Cannot send to self' });
return { amount, subject };
}