diff --git a/src/app/router/connectorRoutes.tsx b/src/app/router/connectorRoutes.tsx index 4a61e355c8..98ce63cfa7 100644 --- a/src/app/router/connectorRoutes.tsx +++ b/src/app/router/connectorRoutes.tsx @@ -15,9 +15,11 @@ import ConnectUmbrel from "@screens/connectors/ConnectUmbrel"; import { Route } from "react-router-dom"; import i18n from "~/i18n/i18nConfig"; +import ConnectAlbyHub from "~/app/screens/connectors/ConnectAlbyHub"; import ConnectNWC from "~/app/screens/connectors/ConnectNWC"; import ConnectVoltage from "~/app/screens/connectors/ConnectVoltage"; import ConnectCommando from "../screens/connectors/ConnectCommando"; +import albyhub from "/static/assets/icons/albyhub.png"; import btcpay from "/static/assets/icons/btcpay.svg"; import citadel from "/static/assets/icons/citadel.png"; import core_ln from "/static/assets/icons/core_ln.svg"; @@ -167,6 +169,12 @@ const connectorMap: { [key: string]: ConnectorRoute } = { title: i18n.t("translation:choose_connector.nwc.title"), logo: nwc, }, + albyhub: { + path: "albyhub", + element: , + title: i18n.t("translation:choose_connector.albyhub.title"), + logo: albyhub, + }, lawallet: { path: "lawallet", element: , @@ -246,6 +254,7 @@ const distributionMap: { [key: string]: { logo: string; children: Route[] } } = function getConnectorRoutes(): ConnectorRoute[] { return [ + connectorMap["albyhub"], connectorMap["lnd"], connectorMap["lnc"], connectorMap["commando"], diff --git a/src/app/screens/connectors/ConnectAlbyHub/index.tsx b/src/app/screens/connectors/ConnectAlbyHub/index.tsx new file mode 100644 index 0000000000..b1cbe65fa5 --- /dev/null +++ b/src/app/screens/connectors/ConnectAlbyHub/index.tsx @@ -0,0 +1,125 @@ +import ConnectorForm from "@components/ConnectorForm"; +import TextField from "@components/form/TextField"; +import ConnectionErrorToast from "@components/toasts/ConnectionErrorToast"; +import { useState } from "react"; +import { Trans, useTranslation } from "react-i18next"; +import { useNavigate } from "react-router-dom"; +import toast from "~/app/components/Toast"; +import msg from "~/common/lib/msg"; + +import logo from "/static/assets/icons/albyhub.png"; + +export default function ConnectAlbyHub() { + const navigate = useNavigate(); + const { t } = useTranslation("translation", { + keyPrefix: "choose_connector.albyhub", + }); + const [formData, setFormData] = useState({ + nostrWalletConnectUrl: "", + }); + const [loading, setLoading] = useState(false); + + function handleChange(event: React.ChangeEvent) { + setFormData({ + ...formData, + [event.target.name]: event.target.value.trim(), + }); + } + + function getConnectorType() { + return "nwc"; + } + + async function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + setLoading(true); + const { nostrWalletConnectUrl } = formData; + const account = { + name: "Alby Hub", + config: { + nostrWalletConnectUrl, + }, + connector: getConnectorType(), + }; + + try { + const validation = await msg.request("validateAccount", account); + if (validation.valid) { + const addResult = await msg.request("addAccount", account); + if (addResult.accountId) { + await msg.request("selectAccount", { + id: addResult.accountId, + }); + navigate("/test-connection"); + } + } else { + console.error(validation); + toast.error( + + ); + } + } catch (e) { + console.error(e); + let message = t("page.errors.connection_failed"); + if (e instanceof Error) { + message += `\n\n${e.message}`; + } + toast.error(message); + } + setLoading(false); + } + + return ( + + + + } + description={ + , + // eslint-disable-next-line react/jsx-key + , + // eslint-disable-next-line react/jsx-key + , + ]} + /> + } + logo={logo} + submitLoading={loading} + submitDisabled={formData.nostrWalletConnectUrl === ""} + onSubmit={handleSubmit} + > +
+ +
+
+ ); +} diff --git a/src/i18n/locales/de/translation.json b/src/i18n/locales/de/translation.json index 08fbb4d12f..82ccaedd6f 100644 --- a/src/i18n/locales/de/translation.json +++ b/src/i18n/locales/de/translation.json @@ -271,13 +271,13 @@ } }, "nwc": { - "title": "Nostr-Wallet-Verbindung", + "title": "Nostr Wallet Connect", "page": { "url": { - "label": "Nostr Wallet Verbindungs-URL", + "label": "Nostr Wallet Connect-URL", "placeholder": "nostr+walletconnect://69effe..." }, - "instructions": "Füge einen NWC-Verbindungsstring von <0>Alby Nostr Wallet Connect, <1>Umbrel Nostr Wallet Connect oder <2>Mutiny Wallet", + "instructions": "Füge einen NWC-Verbindungsstring von <0>Nostr Wallet Connect, <1>Umbrel Nostr Wallet Connect oder <2>Mutiny Wallet", "errors": { "connection_failed": "Verbindung fehlgeschlagen. Ist Ihre NWC Wallet online und wurden App Verbindungen zugelassen?" } diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index f4837b27f5..7d641d970b 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -334,6 +334,19 @@ "connection_failed": "Connection failed. Are your credentials correct?" } }, + "albyhub": { + "title": "Alby Hub", + "page": { + "instructions": "Open your Alby Hub, create a new app connection and paste the connection secret to connect.", + "url": { + "label": "NWC connection secret", + "placeholder": "nostr+walletconnect://69effe..." + }, + "errors": { + "connection_failed": "Connection failed. Is your Alby Hub online and app connection enabled?" + } + } + }, "nwc": { "title": "Nostr Wallet Connect", "page": { diff --git a/static/assets/icons/albyhub.png b/static/assets/icons/albyhub.png new file mode 100644 index 0000000000..9c6d320f6e Binary files /dev/null and b/static/assets/icons/albyhub.png differ