From bad67c0b3f3193a6ba4bbdc7aad1032aa7b49916 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Sat, 21 Oct 2023 01:42:06 +0200 Subject: [PATCH 1/7] chore(dev): add dev setup info page --- docker/regtest/docker-compose.yml | 4 ++ src/components/App.tsx | 33 ++++++++++- src/components/DevSetupPage.tsx | 99 +++++++++++++++++++++++++++++++ src/components/ErrorPage.tsx | 8 --- src/components/Footer.tsx | 28 +++++---- src/constants/debugFeatures.ts | 2 + src/constants/routes.ts | 1 + src/index.css | 1 + 8 files changed, 156 insertions(+), 20 deletions(-) create mode 100644 src/components/DevSetupPage.tsx diff --git a/docker/regtest/docker-compose.yml b/docker/regtest/docker-compose.yml index 3af8e43d9..e6c634e6a 100644 --- a/docker/regtest/docker-compose.yml +++ b/docker/regtest/docker-compose.yml @@ -175,6 +175,10 @@ services: BTCEXP_BITCOIND_PORT: 43782 BTCEXP_BITCOIND_USER: regtest BTCEXP_BITCOIND_PASS: regtest + BTCEXP_BASIC_AUTH_PASSWORD: joinmarket + BTCEXP_PRIVACY_MODE: 'true' + BTCEXP_NO_RATES: 'true' + BTCEXP_RPC_ALLOWALL: 'true' ports: - "3002:3002" depends_on: diff --git a/src/components/App.tsx b/src/components/App.tsx index f3d39934c..a71aba151 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useState } from 'react' +import { Suspense, lazy, useCallback, useEffect, useMemo, useState } from 'react' import * as rb from 'react-bootstrap' import { useTranslation } from 'react-i18next' import { @@ -27,7 +27,7 @@ import { isDebugFeatureEnabled } from '../constants/debugFeatures' import CreateWallet from './CreateWallet' import ImportWallet from './ImportWallet' import Earn from './Earn' -import ErrorPage, { ErrorThrowingComponent } from './ErrorPage' +import ErrorPage from './ErrorPage' import Footer from './Footer' import Jam from './Jam' import Layout from './Layout' @@ -39,6 +39,7 @@ import Send from './Send' import RescanChain from './RescanChain' import Settings from './Settings' import Wallets from './Wallets' +const DevSetupPage = lazy(() => import('./DevSetupPage')) export default function App() { const { t } = useTranslation() @@ -168,6 +169,17 @@ export default function App() { {isDebugFeatureEnabled('errorExamplePage') && ( } /> )} + {isDebugFeatureEnabled('devSetupPage') && ( + }> + + + } + /> + )} } /> )} @@ -208,6 +220,23 @@ export default function App() { ) } +const Loading = () => { + const { t } = useTranslation() + return ( +
+
+ ) +} + +const ErrorThrowingComponent = () => { + useEffect(() => { + throw new Error('This error is thrown on purpose. Only to be used for testing.') + }, []) + return <> +} + const RELOAD_WALLET_INFO_DELAY: { AFTER_RESCAN: Milliseconds AFTER_UNLOCK: Milliseconds diff --git a/src/components/DevSetupPage.tsx b/src/components/DevSetupPage.tsx new file mode 100644 index 000000000..f8b6e3b08 --- /dev/null +++ b/src/components/DevSetupPage.tsx @@ -0,0 +1,99 @@ +import Sprite from './Sprite' +import PageTitle from './PageTitle' + +const LINK_JM_REGTEST_JOINMARKET2 = 'http://localhost:29080' +const LINK_JM_REGTEST_JOINMARKET2_AUTH = { + user: 'joinmarket', + password: 'joinmarket', +} +const LINK_JM_REGTEST_JOINMARKET3 = 'http://localhost:30080' +const LINK_JM_REGTEST_EXPLORER = 'http://localhost:3002' +const LINK_JM_REGTEST_EXPLORER_AUTH = { + user: 'joinmarket', + password: 'joinmarket', +} +const LINK_JM_REGTEST_RPC_TERMINAL = 'http://localhost:3002/rpc-terminal' + +export default function DevSetupPage() { + return ( +
+ +
+
+
Test Wallet
+
+ Name: Satoshi +
+ Password: test +
+
+
+ +
+
Jam Instances
+
+ + +
+ Basic Authentication +
+ + User: {LINK_JM_REGTEST_JOINMARKET2_AUTH.user} +
+ Password: {LINK_JM_REGTEST_JOINMARKET2_AUTH.password} +
+
+ +
+
+ +
+
Block Explorer
+
+ {' '} + +
+ Basic Authentication +
+ + User: {LINK_JM_REGTEST_EXPLORER_AUTH.user} +
+ Password: {LINK_JM_REGTEST_EXPLORER_AUTH.password} +
+
+
+
+ +
+ Mine a block, e.g.: +
generatetoaddress 1 bcrt1qrnz0thqslhxu86th069r9j6y7ldkgs2tzgf5wx
+
+
+
+
+ ) +} diff --git a/src/components/ErrorPage.tsx b/src/components/ErrorPage.tsx index 4e09c1d11..5ad9159f8 100644 --- a/src/components/ErrorPage.tsx +++ b/src/components/ErrorPage.tsx @@ -3,14 +3,6 @@ import * as rb from 'react-bootstrap' import { useRouteError } from 'react-router-dom' import PageTitle from './PageTitle' import { t } from 'i18next' -import { useEffect } from 'react' - -export function ErrorThrowingComponent() { - useEffect(() => { - throw new Error('This error is thrown on purpose. Only to be used for testing.') - }, []) - return <> -} interface ErrorViewProps { title: string diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index db77fcbb9..ab225cb59 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -8,8 +8,10 @@ import { useCurrentWallet } from '../context/WalletContext' import Sprite from './Sprite' import Cheatsheet from './Cheatsheet' import packageInfo from '../../package.json' -import { isDevMode } from '../constants/debugFeatures' +import { isDebugFeatureEnabled, isDevMode } from '../constants/debugFeatures' import { toSemVer } from '../utils' +import { Link } from 'react-router-dom' +import { routes } from '../constants/routes' const APP_DISPLAY_VERSION = (() => { const version = toSemVer(packageInfo.version) @@ -52,7 +54,7 @@ export default function Footer() { {t('footer.warning_alert_title')}

{t('footer.warning_alert_text')}

- JoinMarket: v{serviceInfo?.server?.version?.raw || 'unknown'} + JoinMarket: v{serviceInfo?.server?.version?.raw || '_unknown'}
Jam: v{APP_DISPLAY_VERSION}

@@ -103,14 +105,20 @@ export default function Footer() {
- - v{APP_DISPLAY_VERSION} - + {!isDebugFeatureEnabled('devSetupPage') ? ( + + v{APP_DISPLAY_VERSION} + + ) : ( + + v{APP_DISPLAY_VERSION} + + )}
Date: Tue, 24 Oct 2023 17:20:56 +0200 Subject: [PATCH 2/7] refactor(style): remove warning-hint css class --- src/components/Footer.tsx | 6 +++--- src/index.css | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index ab225cb59..9227cf7f3 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -71,12 +71,12 @@ export default function Footer() {
-
+
This is pre-alpha software. setShowBetaWarning(true)} > Read this before using. @@ -104,7 +104,7 @@ export default function Footer() { )}
- +
+
+
Links
+
+ + Error Example Page + +
+
+
+
Jam Instances
From f044e46c7879410509870b9e8aceedc612681e89 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Tue, 24 Oct 2023 18:14:22 +0200 Subject: [PATCH 4/7] chore(dev): distinct link to dev setup into page in Footer --- src/components/Footer.tsx | 40 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 9227cf7f3..510929f30 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -70,7 +70,7 @@ export default function Footer() { -
+
This is pre-alpha software. @@ -104,23 +104,27 @@ export default function Footer() { )}
-
- {!isDebugFeatureEnabled('devSetupPage') ? ( - - v{APP_DISPLAY_VERSION} - - ) : ( - - v{APP_DISPLAY_VERSION} - - )} + {isDebugFeatureEnabled('devSetupPage') && ( + <> +
+ + Dev Setup + +
+
|
+ + )} + -
+ -
|
+
|
Date: Tue, 24 Oct 2023 18:23:11 +0200 Subject: [PATCH 5/7] chore(navbar): add import wallet button to navbar on mobile --- src/components/Navbar.tsx | 9 +++++++++ src/i18n/locales/en/translation.json | 1 + 2 files changed, 10 insertions(+) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 5df931248..1fca90479 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -314,6 +314,15 @@ export default function Navbar() { {t('navbar.button_create_wallet')} + + isExpanded && setIsExpanded(false)} + className="nav-link" + > + {t('navbar.button_import_wallet')} + + diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index 4f50da286..852ee544a 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -37,6 +37,7 @@ "title": "Jam", "text_rescan_in_progress": "Rescanning...", "button_create_wallet": "Create Wallet", + "button_import_wallet": "Import Wallet", "tab_send": "Send", "tab_receive": "Receive", "tab_earn": "Earn", From 8fa2d73d0a33ac89e07ffe436b1c94ea40366b1a Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Tue, 24 Oct 2023 18:26:03 +0200 Subject: [PATCH 6/7] chore(navbar): display theme toggle even when no wallet is active --- src/components/Navbar.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 1fca90479..2fb27e42a 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -299,6 +299,11 @@ export default function Navbar() { {t('navbar.menu')}
+ {isDebugFeatureEnabled('fastThemeToggle') && ( + + + + )} {t('navbar.title')} From c83461f6cfa0badff7df52d1f83a307b8b16effd Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Tue, 24 Oct 2023 22:46:48 +0200 Subject: [PATCH 7/7] ui(dev): cleanup dev setup page and color link in Footer --- src/components/DevSetupPage.tsx | 29 ++++++++++++++--------------- src/components/Footer.tsx | 13 +++++-------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/components/DevSetupPage.tsx b/src/components/DevSetupPage.tsx index 8b690f437..2894de4cf 100644 --- a/src/components/DevSetupPage.tsx +++ b/src/components/DevSetupPage.tsx @@ -1,32 +1,31 @@ +import { Link } from 'react-router-dom' import Sprite from './Sprite' import PageTitle from './PageTitle' -import { Link } from 'react-router-dom' import { routes } from '../constants/routes' -const LINK_JM_REGTEST_JOINMARKET2 = 'http://localhost:29080' -const LINK_JM_REGTEST_JOINMARKET2_AUTH = { +const DEFAULT_BASIC_AUTH = { user: 'joinmarket', password: 'joinmarket', } + +const LINK_JM_REGTEST_JOINMARKET2 = 'http://localhost:29080' +const LINK_JM_REGTEST_JOINMARKET2_AUTH = DEFAULT_BASIC_AUTH const LINK_JM_REGTEST_JOINMARKET3 = 'http://localhost:30080' const LINK_JM_REGTEST_EXPLORER = 'http://localhost:3002' -const LINK_JM_REGTEST_EXPLORER_AUTH = { - user: 'joinmarket', - password: 'joinmarket', -} -const LINK_JM_REGTEST_RPC_TERMINAL = 'http://localhost:3002/rpc-terminal' +const LINK_JM_REGTEST_EXPLORER_AUTH = DEFAULT_BASIC_AUTH +const LINK_JM_REGTEST_RPC_TERMINAL = `${LINK_JM_REGTEST_EXPLORER}/rpc-terminal` export default function DevSetupPage() { return ( -
+
Test Wallet
- Name: Satoshi + Name: Satoshi
- Password: test + Password: test
@@ -57,9 +56,9 @@ export default function DevSetupPage() { Basic Authentication
- User: {LINK_JM_REGTEST_JOINMARKET2_AUTH.user} + User: {LINK_JM_REGTEST_JOINMARKET2_AUTH.user}
- Password: {LINK_JM_REGTEST_JOINMARKET2_AUTH.password} + Password: {LINK_JM_REGTEST_JOINMARKET2_AUTH.password}
@@ -87,9 +86,9 @@ export default function DevSetupPage() { Basic Authentication
- User: {LINK_JM_REGTEST_EXPLORER_AUTH.user} + User: {LINK_JM_REGTEST_EXPLORER_AUTH.user}
- Password: {LINK_JM_REGTEST_EXPLORER_AUTH.password} + Password: {LINK_JM_REGTEST_EXPLORER_AUTH.password}
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 510929f30..f54261c6b 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -105,14 +105,11 @@ export default function Footer() {
{isDebugFeatureEnabled('devSetupPage') && ( - <> -
- - Dev Setup - -
-
|
- +
+ + Dev Setup + +
)}