();
@@ -165,6 +176,21 @@ export const AppProvider = (props: { children: JSXElement }) => {
updateStore('lnbc', () => undefined);
};
+
+ const openCashuModal = (cashu: string, onPay: () => void) => {
+ updateStore('showCashuInvoiceModal', () => true);
+ updateStore('cashu', () => ({
+ invoice: cashu,
+ onPay,
+ onCancel: () => updateStore('showCashuInvoiceModal', () => false),
+ }))
+ };
+
+ const closeCashuModal = () => {
+ updateStore('showCashuInvoiceModal', () => false);
+ updateStore('cashu', () => undefined);
+ };
+
const openConfirmModal = (confirmInfo: ConfirmInfo) => {
updateStore('showConfirmModal', () => true);
updateStore('confirmInfo', () => ({...confirmInfo }));
@@ -179,6 +205,15 @@ export const AppProvider = (props: { children: JSXElement }) => {
updateStore('showNoteContextMenu', () => false);
};
+ const getCashuMint = (url: string) => {
+ const formatted = new URL(url).toString();
+ if (!store.cashuMints.has(formatted)) {
+ const mint = new CashuMint(formatted);
+ store.cashuMints.set(formatted, mint);
+ }
+ return store.cashuMints.get(formatted);
+ };
+
// EFFECTS --------------------------------------
onMount(() => {
@@ -227,6 +262,9 @@ export const AppProvider = (props: { children: JSXElement }) => {
closeLnbcModal,
openConfirmModal,
closeConfirmModal,
+ openCashuModal,
+ closeCashuModal,
+ getCashuMint,
}
});
diff --git a/src/pages/Messages.tsx b/src/pages/Messages.tsx
index 40d5637..9b19570 100644
--- a/src/pages/Messages.tsx
+++ b/src/pages/Messages.tsx
@@ -36,6 +36,7 @@ import PageCaption from '../components/PageCaption/PageCaption';
import { useMediaContext } from '../contexts/MediaContext';
import PageTitle from '../components/PageTitle/PageTitle';
import Lnbc from '../components/Lnbc/Lnbc';
+import Cashu from '../components/Cashu/Cashu';
type AutoSizedTextArea = HTMLTextAreaElement & { _baseScrollHeight: number };
@@ -840,6 +841,13 @@ const Messages: Component = () => {
return test
};
+ const msgHasCashu = (msg: DirectMessage) => {
+ const r =/(\s+|\r\n|\r|\n|^)cashuA[a-zA-Z0-9]+/;
+ const test = r.test(msg.content);
+
+ return test
+ };
+
createEffect(() => {
if (account?.hasPublicKey()) {
profile?.actions.setProfileKey(account.publicKey)
@@ -894,7 +902,7 @@ const Messages: Component = () => {
}
const renderMessage = (msg: DirectMessage, thread: DirectMessageThread) => {
- if (!msgHasInvoice(msg)) {
+ if (!msgHasInvoice(msg) && !msgHasCashu(msg)) {
return (
{
let sectionIndex = 0;
tokens.forEach((t) => {
- if (t.startsWith('lnbc')) {
+ if (t.startsWith('lnbc') || t.startsWith('cashuA')) {
if (sections[sectionIndex]) sectionIndex++;
sections[sectionIndex] = t;
@@ -956,6 +964,15 @@ const Messages: Component = () => {
+
+
+
+
+
)}
diff --git a/src/translations.ts b/src/translations.ts
index 0f8e9c7..2c2d565 100644
--- a/src/translations.ts
+++ b/src/translations.ts
@@ -2199,3 +2199,54 @@ export const lnInvoice = {
},
};
+
+export const cashuInvoice = {
+ redeem: {
+ id: 'cashuInvoice.redeem',
+ defaultMessage: 'Reedem',
+ description: 'Reedem ecash action',
+ },
+ pending: {
+ id: 'cashuInvoice.pending',
+ defaultMessage: 'Pending',
+ description: 'Pending ecash',
+ },
+ spent: {
+ id: 'cashuInvoice.spent',
+ defaultMessage: 'Spent',
+ description: 'Spent ecash',
+ },
+ title: {
+ id: 'cashuInvoice.title',
+ defaultMessage: 'Cashu Ecash',
+ description: 'Cashu Ecash title',
+ },
+ mint: {
+ id: 'cashuInvoice.mint',
+ defaultMessage: 'Mint: {url}',
+ description: 'Mint url',
+ },
+ confirm: {
+ title: {
+ id: 'cashuInvoice.confirm.title',
+ defaultMessage: 'Are you sure?',
+ description: 'Cashu invoice pay confirmation',
+ },
+ description: {
+ id: 'cashuInvoice.confirm.description',
+ defaultMessage: 'Redeem {amount}',
+ description: 'Cashu Invoice confirm description',
+ },
+ confirmLabel: {
+ id: 'cashuInvoice.confirm.confirmLabel',
+ defaultMessage: 'Yes, redeem',
+ description: 'Cashu Invoice confirm button label',
+ },
+ abortLabel: {
+ id: 'cashuInvoice.confirm.abortLabel',
+ defaultMessage: 'Cancel',
+ description: 'Cashu Invoice confirm button label',
+ },
+ },
+
+};