From 47d92fe171890f4ffba5711d0da1ba421b82a6ff Mon Sep 17 00:00:00 2001 From: Kieran Date: Thu, 4 Jan 2024 16:11:10 +0000 Subject: [PATCH] chore: formatting --- .../app/src/Pages/settings/wallet/Cashu.tsx | 15 +- packages/app/src/Pages/wallet/index.tsx | 47 +++--- packages/app/src/Pages/wallet/receive.tsx | 100 ++++++------ packages/app/src/Pages/wallet/send.tsx | 145 ++++++++++-------- packages/app/src/Wallet/AlbyWallet.ts | 2 +- packages/app/src/index.tsx | 4 +- packages/app/src/lang.json | 27 ++++ packages/app/src/translations/en.json | 9 ++ 8 files changed, 217 insertions(+), 132 deletions(-) diff --git a/packages/app/src/Pages/settings/wallet/Cashu.tsx b/packages/app/src/Pages/settings/wallet/Cashu.tsx index 30419350..eb66e5e9 100644 --- a/packages/app/src/Pages/settings/wallet/Cashu.tsx +++ b/packages/app/src/Pages/settings/wallet/Cashu.tsx @@ -20,12 +20,15 @@ const ConnectCashu = () => { } const { CashuWallet } = await import("@/Wallet/Cashu"); - const connection = new CashuWallet({ - url: config, - keys: {}, - proofs: [], - keysets: [] - }, () => { }); + const connection = new CashuWallet( + { + url: config, + keys: {}, + proofs: [], + keysets: [], + }, + () => {}, + ); await connection.login(); const info = await connection.getInfo(); const newWallet = { diff --git a/packages/app/src/Pages/wallet/index.tsx b/packages/app/src/Pages/wallet/index.tsx index b4b45b31..b26ea86c 100644 --- a/packages/app/src/Pages/wallet/index.tsx +++ b/packages/app/src/Pages/wallet/index.tsx @@ -89,16 +89,17 @@ export default function WalletPage(props: { showHistory: boolean }) { function walletList() { if (walletState.configs.length === 0) { - return (
-
- + return ( +
+
+ +
+ + +
- - - -
); } return ( @@ -129,9 +130,11 @@ export default function WalletPage(props: { showHistory: boolean }) {

- {history === undefined && - - } + {history === undefined && ( + + + + )} {history?.map(a => { const dirClassname = { "text-[--success]": a.direction === "in", @@ -231,14 +234,18 @@ export default function WalletPage(props: { showHistory: boolean }) { />
- {wallet?.canCreateInvoice() && navigate("/wallet/receive")}> - - - } - {wallet?.canPayInvoice() && navigate("/wallet/send")}> - - - } + {wallet?.canCreateInvoice() && ( + navigate("/wallet/receive")}> + + + + )} + {wallet?.canPayInvoice() && ( + navigate("/wallet/send")}> + + + + )}
{walletHistory()} diff --git a/packages/app/src/Pages/wallet/receive.tsx b/packages/app/src/Pages/wallet/receive.tsx index 71ea9ade..8394e8e9 100644 --- a/packages/app/src/Pages/wallet/receive.tsx +++ b/packages/app/src/Pages/wallet/receive.tsx @@ -6,50 +6,64 @@ import { useState } from "react"; import { FormattedMessage, useIntl } from "react-intl"; export function WalletReceivePage() { - const wallets = useWallet(); - const { formatMessage } = useIntl(); - const [invoice, setInvoice] = useState(""); - const [error, setError] = useState(""); - const [amount, setAmount] = useState(0); - const [comment, setComment] = useState(""); + const wallets = useWallet(); + const { formatMessage } = useIntl(); + const [invoice, setInvoice] = useState(""); + const [error, setError] = useState(""); + const [amount, setAmount] = useState(0); + const [comment, setComment] = useState(""); - return
-
- -
-

- "{b}", - wallet: wallets.config?.info.alias - }} /> -

- setComment(e.target.value)} /> -
- - - - setAmount(Number(e.target.value))} /> -
- { - try { - if (wallets.wallet) { - const inv = await wallets.wallet.createInvoice({ - amount: amount, - memo: comment, - expiry: 600 - }); - setInvoice(inv.pr); - } - } catch (e) { - setError((e as Error).message); + return ( +
+
+ +
+

+ "{b}", + wallet: wallets.config?.info.alias, + }} + /> +

+ setComment(e.target.value)} + /> +
+ + + + setAmount(Number(e.target.value))} /> +
+ { + try { + if (wallets.wallet) { + const inv = await wallets.wallet.createInvoice({ + amount: amount, + memo: comment, + expiry: 600, + }); + setInvoice(inv.pr); } + } catch (e) { + setError((e as Error).message); + } }}> - - - {error && {error}} - {invoice &&
- - -
} + + + {error && {error}} + {invoice && ( +
+ + +
+ )}
-} \ No newline at end of file + ); +} diff --git a/packages/app/src/Pages/wallet/send.tsx b/packages/app/src/Pages/wallet/send.tsx index 76af1901..e869e65d 100644 --- a/packages/app/src/Pages/wallet/send.tsx +++ b/packages/app/src/Pages/wallet/send.tsx @@ -1,75 +1,100 @@ import AsyncButton from "@/Components/Button/AsyncButton"; import Icon from "@/Components/Icons/Icon"; import { formatShort } from "@/Utils/Number"; -import { WalletInvoice, useWallet } from "@/Wallet" +import { WalletInvoice, useWallet } from "@/Wallet"; import { LNURL } from "@snort/shared"; import { useEffect, useState } from "react"; import { FormattedMessage, FormattedNumber, useIntl } from "react-intl"; import { useNavigate } from "react-router-dom"; export function WalletSendPage() { - const wallets = useWallet(); - const { formatMessage } = useIntl(); - const [invoice, setInvoice] = useState(""); - const [error, setError] = useState(""); - const [lnurl, isLnurl] = useState(true); - const [amount, setAmount] = useState(0); - const [comment, setComment] = useState(""); - const [result, setResult] = useState(); + const wallets = useWallet(); + const { formatMessage } = useIntl(); + const [invoice, setInvoice] = useState(""); + const [error, setError] = useState(""); + const [lnurl, isLnurl] = useState(true); + const [amount, setAmount] = useState(0); + const [comment, setComment] = useState(""); + const [result, setResult] = useState(); - useEffect(() => { - isLnurl(!invoice.startsWith("lnbc")) - }, [invoice]); + useEffect(() => { + isLnurl(!invoice.startsWith("lnbc")); + }, [invoice]); - return
-
- -
-

- "{b}", - wallet: wallets.config?.info.alias - }} /> -

- setInvoice(e.target.value)} /> - {lnurl && <> - setComment(e.target.value)} /> -
- - - - setAmount(Number(e.target.value))} /> -
- } - { - try { - if (wallets.wallet) { - if (!isLnurl) { - const res = await wallets.wallet.payInvoice(invoice); - setResult(res); - } else { - const lnurl = new LNURL(invoice); - await lnurl.load(); - const pr = await lnurl.getInvoice(amount, comment); - if (pr.pr) { - const res = await wallets.wallet.payInvoice(pr.pr); - setResult(res); - } - } + return ( +
+
+ +
+

+ "{b}", + wallet: wallets.config?.info.alias, + }} + /> +

+ setInvoice(e.target.value)} + /> + {lnurl && ( + <> + setComment(e.target.value)} + /> +
+ + + + setAmount(Number(e.target.value))} /> +
+ + )} + { + try { + if (wallets.wallet) { + if (!isLnurl) { + const res = await wallets.wallet.payInvoice(invoice); + setResult(res); + } else { + const lnurl = new LNURL(invoice); + await lnurl.load(); + const pr = await lnurl.getInvoice(amount, comment); + if (pr.pr) { + const res = await wallets.wallet.payInvoice(pr.pr); + setResult(res); } - } catch (e) { - setError((e as Error).message); + } } + } catch (e) { + setError((e as Error).message); + } }}> - - - {error && {error}} - {result &&
- - , - fee: - }} /> -
} + + + {error && {error}} + {result && ( +
+ + , + fee: , + }} + /> +
+ )}
-} \ No newline at end of file + ); +} diff --git a/packages/app/src/Wallet/AlbyWallet.ts b/packages/app/src/Wallet/AlbyWallet.ts index b709a79a..7711d1ad 100644 --- a/packages/app/src/Wallet/AlbyWallet.ts +++ b/packages/app/src/Wallet/AlbyWallet.ts @@ -35,7 +35,7 @@ export default class AlbyWallet implements LNWallet { canGetBalance() { return this.#token.scope.includes("balance:read"); } - + canCreateInvoice() { return true; } diff --git a/packages/app/src/index.tsx b/packages/app/src/index.tsx index e6de1de6..21fb090a 100644 --- a/packages/app/src/index.tsx +++ b/packages/app/src/index.tsx @@ -150,11 +150,11 @@ const mainRoutes = [ }, { path: "/wallet/send", - element: + element: , }, { path: "/wallet/receive", - element: + element: , }, ...OnboardingRoutes, ...SettingsRoutes, diff --git a/packages/app/src/lang.json b/packages/app/src/lang.json index dc088f9f..2257e045 100644 --- a/packages/app/src/lang.json +++ b/packages/app/src/lang.json @@ -467,6 +467,9 @@ "E5ZIPD": { "defaultMessage": "{amount} sats" }, + "EHqHsu": { + "defaultMessage": "Invoice / Lightning Address" + }, "EJbFi7": { "defaultMessage": "Search notes" }, @@ -810,6 +813,9 @@ "defaultMessage": "Summary", "description": "Notifications summary" }, + "PXQ0z0": { + "defaultMessage": "Receiving to {wallet}" + }, "PamNxw": { "defaultMessage": "Unknown file header: {name}" }, @@ -930,6 +936,9 @@ "UJTWqI": { "defaultMessage": "Remove from my relays" }, + "ULXFfP": { + "defaultMessage": "Receive" + }, "UNjfWJ": { "defaultMessage": "Check all event signatures received from relays" }, @@ -1017,6 +1026,9 @@ "XhpBfA": { "defaultMessage": "{site} is an open source project built by passionate people in their free time, your donations are greatly appreciated" }, + "Xnimz0": { + "defaultMessage": "Sending from {wallet}" + }, "Xopqkl": { "defaultMessage": "Your default zap amount is {number} sats, example values are calculated from this." }, @@ -1033,6 +1045,9 @@ "YXA3AH": { "defaultMessage": "Enable reactions" }, + "Yf3DwC": { + "defaultMessage": "Connect a wallet to send instant payments" + }, "Z4BMCZ": { "defaultMessage": "Enter pairing phrase" }, @@ -1063,6 +1078,9 @@ "aMaLBK": { "defaultMessage": "Supported Extensions" }, + "aRex7h": { + "defaultMessage": "Paid {amount} sats, fee {fee} sats" + }, "aSGz4J": { "defaultMessage": "Connect to your own LND node with Lightning Node Connect" }, @@ -1163,6 +1181,9 @@ "deEeEI": { "defaultMessage": "Register" }, + "djLctd": { + "defaultMessage": "Amount in sats" + }, "djNL6D": { "defaultMessage": "Read-only" }, @@ -1295,6 +1316,9 @@ "i/dBAR": { "defaultMessage": "Zap Pool" }, + "i5gBFz": { + "defaultMessage": "Your sent and received payments will show up here." + }, "iCqGww": { "defaultMessage": "Reactions ({n})" }, @@ -1319,6 +1343,9 @@ "ieGrWo": { "defaultMessage": "Follow" }, + "ipHVx5": { + "defaultMessage": "Generate Invoice" + }, "itPgxd": { "defaultMessage": "Profile" }, diff --git a/packages/app/src/translations/en.json b/packages/app/src/translations/en.json index f82c7de6..fd7f0d42 100644 --- a/packages/app/src/translations/en.json +++ b/packages/app/src/translations/en.json @@ -154,6 +154,7 @@ "DtYelJ": "Transfer", "Dx4ey3": "Toggle all", "E5ZIPD": "{amount} sats", + "EHqHsu": "Invoice / Lightning Address", "EJbFi7": "Search notes", "ELbg9p": "Data Providers", "EQKRE4": "Show badges on profile pages", @@ -267,6 +268,7 @@ "P7nJT9": "Total today (UTC): {amount} sats", "PCSt5T": "Preferences", "PJeJFc": "Summary", + "PXQ0z0": "Receiving to {wallet}", "PamNxw": "Unknown file header: {name}", "Pe0ogR": "Theme", "PrsIg7": "Reactions will be shown on every page, if disabled no reactions will be shown", @@ -306,6 +308,7 @@ "U1aPPi": "Stop listening", "UDYlxu": "Pending Subscriptions", "UJTWqI": "Remove from my relays", + "ULXFfP": "Receive", "UNjfWJ": "Check all event signatures received from relays", "UT7Nkj": "New Chat", "UUPFlt": "Users must accept the content warning to show the content of your note.", @@ -335,11 +338,13 @@ "XXm7jJ": "Trending Hashtags", "XgWvGA": "Reactions", "XhpBfA": "{site} is an open source project built by passionate people in their free time, your donations are greatly appreciated", + "Xnimz0": "Sending from {wallet}", "Xopqkl": "Your default zap amount is {number} sats, example values are calculated from this.", "XrSk2j": "Redeem", "YDURw6": "Service URL", "YR2I9M": "No keys, no {app}, There is no way to reset it if you don't back up. It only takes a minute.", "YXA3AH": "Enable reactions", + "Yf3DwC": "Connect a wallet to send instant payments", "Z4BMCZ": "Enter pairing phrase", "ZKORll": "Activate Now", "ZLmyG9": "Contributors", @@ -350,6 +355,7 @@ "a7TDNm": "Notes will stream in real time into global and notes tab", "aHje0o": "Name or nym", "aMaLBK": "Supported Extensions", + "aRex7h": "Paid {amount} sats, fee {fee} sats", "aSGz4J": "Connect to your own LND node with Lightning Node Connect", "aWpBzj": "Show more", "b12Goz": "Mnemonic", @@ -383,6 +389,7 @@ "dOQCL8": "Display name", "ddd3JX": "Popular Hashtags", "deEeEI": "Register", + "djLctd": "Amount in sats", "djNL6D": "Read-only", "dmsiLv": "A default Zap Pool split of {n} has been configured for {site} developers, you can disable it at any time in {link}", "e61Jf3": "Coming soon", @@ -427,6 +434,7 @@ "hniz8Z": "here", "hvFRBo": "Interaction", "i/dBAR": "Zap Pool", + "i5gBFz": "Your sent and received payments will show up here.", "iCqGww": "Reactions ({n})", "iEoXYx": "DeepL translations", "iGT1eE": "Prevent fake accounts from imitating you", @@ -435,6 +443,7 @@ "iXPL0Z": "Can't login with private key on an insecure connection, please use a Nostr key manager extension instead", "iYc3Ld": "Payments", "ieGrWo": "Follow", + "ipHVx5": "Generate Invoice", "itPgxd": "Profile", "izWS4J": "Unfollow", "j9xbzF": "Already backed up",