Skip to content

Commit

Permalink
Merge branch 'master' into nwc-transaction-states
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanjoshi914 authored Jan 23, 2025
2 parents 1784673 + 4c4bd74 commit aa8504b
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 88 deletions.
41 changes: 35 additions & 6 deletions src/app/components/Alert/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
import { PopiconsXLine } from "@popicons/react";
import { useState } from "react";
import { classNames } from "~/app/utils";

type Props = {
type: "warn" | "info";
children: React.ReactNode;
showClose?: boolean;
onClose?: () => void;
};

export default function Alert({ type, children }: Props) {
export default function Alert({
type,
children,
showClose = false,
onClose,
}: Props) {
const [isVisible, setIsVisible] = useState(true);

const handleClose = () => {
setIsVisible(false);
if (onClose) {
onClose();
}
};

if (!isVisible) return null;

return (
<div
className={classNames(
"border rounded-md p-3",
type == "warn" &&
"text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900 border-orange-100 dark:border-orange-900",
type == "info" &&
"border rounded-md p-3 flex justify-between relative",
type === "warn" &&
"text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900 border-orange-100 dark:border-orange-900",
type === "info" &&
"text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900 border-blue-100 dark:border-blue-900"
)}
>
{children}
{showClose && (
<button
onClick={handleClose}
className="absolute right-2 top-2 text-gray-600 dark:text-neutral-400 hover:text-gray-700 dark:hover:text-neutral-300"
aria-label="Close alert"
>
<PopiconsXLine className="w-5 h-5" />
</button>
)}
<div className="pr-8">{children}</div>
</div>
);
}
80 changes: 18 additions & 62 deletions src/app/screens/Home/DefaultView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const DefaultView: FC<Props> = (props) => {
const [isBlockedUrl, setIsBlockedUrl] = useState<boolean>(false);
const [currentAccount, setCurrentAccount] = useState<GetAccountRes>();
const [nostrPublicKey, setNostrPublicKey] = useState("");
const [hasSeenInfoBanner, setHasSeenInfoBanner] = useState<boolean>(true);

const { transactions, isLoadingTransactions, loadTransactions } =
useTransactions();
Expand Down Expand Up @@ -85,6 +86,8 @@ const DefaultView: FC<Props> = (props) => {
const userAccount = await api.getAccount();
const nostrPrivateKey = await api.nostr.getPrivateKey(userAccount.id);

setHasSeenInfoBanner(userAccount.hasSeenInfoBanner);

setNostrPublicKey(
nostrPrivateKey ? await nostr.derivePublicKey(nostrPrivateKey) : ""
);
Expand Down Expand Up @@ -176,41 +179,26 @@ const DefaultView: FC<Props> = (props) => {
</Alert>
)}

{account?.sharedNode && (
<Alert type="info">
<div className="flex items-center gap-2">
<div className="shrink-0">
<PopiconsCircleExclamationLine className="w-5 h-5" />
</div>
<span className="text-sm">
<Trans
i18nKey={"default_view.using_shared_node"}
t={t}
components={[
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/node/embrace_albyhub"
target="_blank"
rel="noopener nofollow"
/>,
]}
/>
</span>
</div>
</Alert>
)}

{account?.usingFeeCredits && (
<Alert type="info">
{(account?.usingFeeCredits || account?.nodeRequired) &&
!hasSeenInfoBanner ? (
<Alert
type="info"
showClose
onClose={async () => {
await api.editAccount(account.id, {
hasSeenInfoBanner: true,
});
setHasSeenInfoBanner(true);
}}
>
<div className="flex items-center gap-2">
<div className="shrink-0">
<PopiconsCircleExclamationLine className="w-5 h-5" />
</div>
<span className="text-sm">
<Trans
i18nKey={"default_view.using_fee_credits"}
t={t}
i18nKey={"setup_wallet"}
t={tCommon}
values={{
max_account_balance: getFormattedSats(
account?.limits?.max_account_balance || 0
Expand All @@ -220,39 +208,7 @@ const DefaultView: FC<Props> = (props) => {
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/onboarding/node/new"
target="_blank"
rel="noopener nofollow"
/>,
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://guides.getalby.com/user-guide/alby-account-and-browser-extension/alby-account/faqs-alby-account/what-are-fee-credits-in-my-alby-account"
target="_blank"
rel="noopener nofollow"
/>,
]}
/>
</span>
</div>
</Alert>
)}

{account?.nodeRequired ? (
<Alert type="info">
<div className="flex items-center gap-2">
<div className="shrink-0">
<PopiconsCircleExclamationLine className="w-5 h-5" />
</div>
<span className="text-sm">
<Trans
i18nKey={"node_required"}
t={tCommon}
components={[
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/onboarding/node/new"
href="https://getalby.com/node/embrace_albyhub"
target="_blank"
rel="noopener nofollow"
/>,
Expand Down
11 changes: 9 additions & 2 deletions src/app/screens/Options/TestConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useSettings } from "~/app/context/SettingsContext";
import TestConnectionResultCard from "~/app/screens/Options/TestConnection/card";
import api from "~/common/lib/api";
import msg from "~/common/lib/msg";

import type { AccountInfo } from "~/types";

export default function TestConnection() {
Expand All @@ -30,6 +31,7 @@ export default function TestConnection() {
}>();
const [errorMessage, setErrorMessage] = useState("");
const [loading, setLoading] = useState(false);
const { getFormattedSats } = useSettings();

const navigate = useNavigate();
const { t } = useTranslation("translation", {
Expand Down Expand Up @@ -127,13 +129,18 @@ export default function TestConnection() {
</div>
<span className="text-sm">
<Trans
i18nKey={"node_required"}
i18nKey={"setup_wallet"}
t={tCommon}
values={{
max_account_balance: getFormattedSats(
account?.limits?.max_account_balance || 0
),
}}
components={[
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/onboarding/node/new"
href="https://getalby.com/node/embrace_albyhub"
target="_blank"
rel="noopener nofollow"
/>,
Expand Down
1 change: 1 addition & 0 deletions src/common/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface GetAccountRes extends Pick<Account, "id" | "name"> {
hasMnemonic: boolean;
isMnemonicBackupDone: boolean;
hasImportedNostrKey: boolean;
hasSeenInfoBanner: boolean;
bitcoinNetwork: BitcoinNetworkType;
useMnemonicForLnurlAuth: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ describe("account info", () => {
nostrEnabled: false,
liquidEnabled: false,
hasMnemonic: false,
hasSeenInfoBanner: false,
hasImportedNostrKey: true,
bitcoinNetwork: "bitcoin",
useMnemonicForLnurlAuth: false,
Expand Down Expand Up @@ -91,6 +92,7 @@ describe("account info", () => {
nostrEnabled: true,
liquidEnabled: true,
hasMnemonic: true,
hasSeenInfoBanner: false,
hasImportedNostrKey: true,
bitcoinNetwork: "regtest",
useMnemonicForLnurlAuth: true,
Expand Down
4 changes: 4 additions & 0 deletions src/extension/background-script/actions/accounts/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const edit = async (message: MessageAccountEdit) => {
message.args.isMnemonicBackupDone;
}

if (message.args.hasSeenInfoBanner !== undefined) {
accounts[accountId].hasSeenInfoBanner = message.args.hasSeenInfoBanner;
}

state.setState({ accounts });
// make sure we immediately persist the updated accounts
await state.getState().saveToStorage();
Expand Down
1 change: 1 addition & 0 deletions src/extension/background-script/actions/accounts/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const get = async (message: MessageAccountGet) => {
// Note: undefined (default for new accounts) it is also considered imported
hasImportedNostrKey: account.hasImportedNostrKey !== false,
bitcoinNetwork: account.bitcoinNetwork || "bitcoin",
hasSeenInfoBanner: account.hasSeenInfoBanner || false,
useMnemonicForLnurlAuth: account.useMnemonicForLnurlAuth || false,
};

Expand Down
7 changes: 2 additions & 5 deletions src/i18n/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,7 @@
"description": "Erstelle einen Master Key für Bitcoin, Nostr und Liquid oder importiere ein bestehendes Nostr-Konto."
}
},
"upgrade_account": "Du verwendest die alte LNDHub-Einstellung. <0>Bitte verbinde dich erneut</0> mit deinem Alby-Konto, um Zugang zu den neuesten Funktionen zu erhalten.",
"using_fee_credits": "Schließe deine Einrichtung ab und verbinde deine Geldbörse mit deinem <0>Alby-Konto</0> für unbegrenzte Zahlungen. Bis deine Einrichtung abgeschlossen ist, kannst du bis zu {{max_account_balance}} sats als <1>Gebührenguthaben</1> erhalten",
"using_shared_node": "Die von dir genutzte gemeinsame Wallet wird zugunsten der Alby Hub Wallet veraltet sein. Um weiterhin Zahlungen zu senden und zu empfangen, <0>richte deine Geldbörse</0> bis zum 3. Januar 2025 ein."
"upgrade_account": "Du verwendest die alte LNDHub-Einstellung. <0>Bitte verbinde dich erneut</0> mit deinem Alby-Konto, um Zugang zu den neuesten Funktionen zu erhalten."
},
"allowance_view": {
"sats": "sats",
Expand Down Expand Up @@ -1312,8 +1310,7 @@
"advanced": "Erweiterte Einstellungen anzeigen",
"details": "Einzelheiten",
"general": "Allgemein",
"wallet_settings": "Wallet-Einstellungen",
"node_required": "Schließe deine Einrichtung von deiner Geldbörse ab, damit du <0>hier</0> unbegrenzt Zahlungen senden und empfangen kannst. Bis dahin kannst du nur bis zu 50.000 Sats als <1>Gebührenguthaben</1> empfangen."
"wallet_settings": "Wallet-Einstellungen"
},
"permissions": {
"commando": {
Expand Down
6 changes: 2 additions & 4 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,7 @@
"description": "Fund your account and receive via your lightning address or an invoice"
}
},
"upgrade_account": "You are using the old LNDHub setup. <0>Please re-connect</0> your Alby account to get access to the latest features.",
"using_fee_credits": "Finish your setup and connect your wallet to your <0>Alby account</0> for unlimited payments. Until your setup is complete, you can receive up to {{max_account_balance}} sats as <1>fee credits</1>",
"using_shared_node": "The shared wallet that you use is being deprecated in favor of the Alby Hub wallet. To continue sending and receiving payments <0>setup your wallet</0> by January 3, 2025."
"upgrade_account": "You are using the old LNDHub setup. <0>Please re-connect</0> your Alby account to get access to the latest features."
}
},
"accounts": {
Expand Down Expand Up @@ -1142,7 +1140,7 @@
"website": "Website",
"wallet_settings": "Wallet Settings",
"apps": "Apps",
"node_required": "Finish setting up your wallet to start sending and receiving unlimited payments <0>here</0>. Until then, you can receive up to 50,000 sats as <1>fee credits</1> only.",
"setup_wallet": "Finish your <0>Alby account setup</0> for unlimited payments. Until your setup is complete, you can receive up to {{max_account_balance}} as <1>fee credits</1>",
"actions": {
"back": "Back",
"delete": "Delete",
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,7 @@
},
"using_shared_node": "Используемый вами общий кошелек устаревает в пользу кошелька Alby Hub. Чтобы продолжать отправлять и получать платежи <0>настройте свой кошелек</0> до 3 января 2025 года.",
"no_transactions": "Для этого аккаунта пока нет транзакций.",
"upgrade_account": "Вы используете старую настройку LNDHub. <0>Пожалуйста, переподключите</0> свою учетную запись Alby, чтобы получить доступ к новейшим функциям.",
"using_fee_credits": "Завершите настройку и подключите кошелек к своему <0>аккаунту Alby</0> для неограниченных платежей. Пока настройка не завершена, вы можете получать до {{max_account_balance}} сатов в качестве <1>бесплатных кредитов</1>"
"upgrade_account": "Вы используете старую настройку LNDHub. <0>Пожалуйста, переподключите</0> свою учетную запись Alby, чтобы получить доступ к новейшим функциям."
},
"allowance_view": {
"permissions": "Разрешения",
Expand Down
3 changes: 0 additions & 3 deletions src/i18n/locales/si/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,6 @@
},
"home": {
"default_view": {
"using_fee_credits": "අසීමිත ගෙවීම් සඳහා ඔබගේ පිහිටුවීම අවසන් කර ඔබගේ පසුම්බිය ඔබගේ <0>Alby ගිණුමට</0> සම්බන්ධ කරන්න. ඔබගේ පිහිටුවීම සම්පූර්ණ වන තුරු, ඔබට {{max_account_balance}} සැට්(sats) දක්වා <1>ගාස්තු බැර(fee credits)</1> ලෙස ලැබිය හැක",
"using_shared_node": "ඔබ භාවිතා කරන හවුල් මුදල් පසුම්බිය ඇල්බි හබ්(Alby Hub) පසුම්බියට පක්ෂව අත් හරිනු ලැබේ. ගෙවීම් යැවීම සහ ලැබීම දිගටම කරගෙන යාමට 2025 ජනවාරි 3 වන විට <0>ඔබේ මුදල් පසුම්බිය සකසන්න</0>.",
"is_blocked_hint": "ඇල්බි(Alby) දැනට {{host}} හි අබල කර ඇත",
"block_removed": "{{host}} සබල කර ඇත. කරුණාකර වෙබ් අඩවිය නැවත පූරණය කරන්න.",
"no_transactions": "මෙම ගිණුම සඳහා තවමත් ගනුදෙනු නොමැත.",
Expand Down Expand Up @@ -1136,7 +1134,6 @@
"copy_invoice": "ඉන්වොයිසිය පිටපත් කරන්න",
"log_in": "ඇතුල් වන්න"
},
"node_required": "අසීමිත ගෙවීම් යැවීම සහ ලැබීම ආරම්භ කිරීමට<0>මෙතනින්</0> ඔබේ මුදල් පසුම්බිය පිහිටුවීම අවසන් කරන්න. එතෙක්, ඔබට <1>ගාස්තු බැර</1> ලෙස පමණක් සැට් 50,000ක් ලබා ගත හැක.",
"connectors": {
"lnd": "LND",
"nativelnd": "LND (ටෝර් හරහා)",
Expand Down
5 changes: 1 addition & 4 deletions src/i18n/locales/ta/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,7 @@
"block_removed": "இயக்கப்பட்டது {{host}}. வலைத்தளத்தை மீண்டும் ஏற்றவும்.",
"no_transactions": "இந்த கணக்கிற்கான பரிவர்த்தனைகள் இதுவரை இல்லை.",
"see_all": "அனைத்தையும் காண்க",
"upgrade_account": "நீங்கள் பழைய lndhub அமைப்பைப் பயன்படுத்துகிறீர்கள். <0> தயவுசெய்து மீண்டும் இணைக்கவும் </0> அண்மைக் கால அம்சங்களை அணுக உங்கள் ஆல்பி கணக்கு.",
"using_shared_node": "நீங்கள் பயன்படுத்தும் பகிரப்பட்ட பணப்பையை ஆல்பி அப் வாலட்டுக்கு ஆதரவாக நீக்கப்படுகிறது. தொடர்ந்து கொடுப்பனவுகளை அனுப்புவதற்கும் பெறுவதற்கும் <0> உங்கள் பணப்பையை அமைக்கவும் </0> சனவரி 3, 2025 க்குள்.",
"using_fee_credits": "உங்கள் அமைப்பை முடித்துவிட்டு, வரம்பற்ற கொடுப்பனவுகளுக்கு உங்கள் பணப்பையை <0> ஆல்பி கணக்கு </0> உடன் இணைக்கவும். உங்கள் அமைப்பு முடியும் வரை, நீங்கள் {{max_account_balance}} sats <1> கட்டண வரவு </1> வரை பெறலாம்"
"upgrade_account": "நீங்கள் பழைய lndhub அமைப்பைப் பயன்படுத்துகிறீர்கள். <0> தயவுசெய்து மீண்டும் இணைக்கவும் </0> அண்மைக் கால அம்சங்களை அணுக உங்கள் ஆல்பி கணக்கு."
}
},
"accounts": {
Expand Down Expand Up @@ -1171,7 +1169,6 @@
"website": "வலைத்தளம்",
"wallet_settings": "பணப்பையை அமைப்புகள்",
"apps": "பயன்பாடுகள்",
"node_required": "வரம்பற்ற கொடுப்பனவுகளை அனுப்பவும் பெறவும் உங்கள் பணப்பையை அமைப்பதை முடிக்கவும் <0> இங்கே </0>. அதுவரை, நீங்கள் 50,000 SAT களை <1> கட்டண வரவு </1> என மட்டுமே பெறலாம்.",
"enable": {
"allow": "இந்த வலைத்தளத்தை இதற்கு அனுமதிக்கவும்:",
"block_added": "பிளாக்லிச்ட்டில் {{host}} சேர்க்கப்பட்டது, தயவுசெய்து வலைத்தளத்தை மீண்டும் ஏற்றவும்.",
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface Account {
nostrPrivateKey?: string | null;
mnemonic?: string | null;
hasImportedNostrKey?: boolean;
hasSeenInfoBanner?: boolean;
bitcoinNetwork?: BitcoinNetworkType;
isMnemonicBackupDone?: boolean;
useMnemonicForLnurlAuth?: boolean;
Expand Down Expand Up @@ -269,6 +270,7 @@ export interface MessageAccountEdit extends MessageDefault {
bitcoinNetwork?: BitcoinNetworkType;
useMnemonicForLnurlAuth?: boolean;
isMnemonicBackupDone?: boolean;
hasSeenInfoBanner?: boolean;
};
action: "editAccount";
}
Expand Down

0 comments on commit aa8504b

Please sign in to comment.