Skip to content

Commit 1fa88c6

Browse files
Merge pull request #61 from HORNET-Storage/feature/optional-wallet-configuration
Feature/optional wallet configuration
2 parents c845a48 + ac42353 commit 1fa88c6

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
REACT_APP_DEMO_MODE=false
66

77
# Direct wallet service access
8-
REACT_APP_WALLET_BASE_URL=http://localhost:9003
8+
REACT_APP_WALLET_BASE_URL=
99

1010
# Router configuration (empty since served from relay server root)
1111
REACT_APP_BASENAME=

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ Create `.env.production` for production builds:
175175
# Demo mode (set to false for production)
176176
REACT_APP_DEMO_MODE=false
177177
178-
# Explicit service URLs (required)
179-
REACT_APP_WALLET_BASE_URL=http://localhost:9003
180-
REACT_APP_OWN_RELAY_URL=ws://localhost:9001
178+
# Service URLs
179+
REACT_APP_WALLET_BASE_URL=http://localhost:9003 # Optional - leave empty to disable wallet features
180+
REACT_APP_OWN_RELAY_URL=ws://localhost:9001 # Required for profile fetching
181181
182182
# Router configuration (empty for direct access)
183183
REACT_APP_BASENAME=
@@ -193,7 +193,8 @@ TSC_COMPILE_ON_ERROR=true
193193

194194

195195
**🎯 Key Requirements**:
196-
-**Explicit Service URLs Required** - Wallet and relay URLs must be configured in environment variables
196+
-**Relay URL Required** - REACT_APP_OWN_RELAY_URL must be configured for profile fetching
197+
-**Wallet URL Optional** - REACT_APP_WALLET_BASE_URL can be empty to disable wallet features
197198
-**Panel Routing Auto-Detection** - Panel paths (REACT_APP_BASENAME/PUBLIC_URL) can be auto-detected
198199
-**Build-Time Configuration** - Service URLs are baked into the JavaScript bundle during build
199200
-**Simple Deployment** - No reverse proxy needed for basic functionality
@@ -262,11 +263,13 @@ Controls the React app's routing base path:
262263
**Note**: For the current working setup, leave this empty (`REACT_APP_BASENAME=`) since the panel is served from the root path.
263264

264265
### Service URLs
265-
**🎯 Explicit Configuration Required**: Service URLs must be explicitly configured:
266-
- **Wallet Service**: `REACT_APP_WALLET_BASE_URL=http://localhost:9003` (required)
267-
- **Relay WebSocket**: `REACT_APP_OWN_RELAY_URL=ws://localhost:9001` (required)
266+
**🎯 Configuration Requirements**:
267+
- **Wallet Service**: `REACT_APP_WALLET_BASE_URL=http://localhost:9003` (optional - leave empty to disable wallet features)
268+
- **Relay WebSocket**: `REACT_APP_OWN_RELAY_URL=ws://localhost:9001` (required for profile fetching)
268269
- **Panel API**: Auto-detected from current origin (no configuration needed)
269270

271+
**Note**: When wallet URL is not configured, send/receive buttons will show a helpful message about rebuilding with wallet configuration.
272+
270273
**Manual Override** (development only):
271274
- **REACT_APP_BASE_URL**: Panel API endpoint (dev mode only)
272275
- **REACT_APP_WALLET_BASE_URL**: Wallet service endpoint (dev mode only)

src/components/relay-dashboard/Balance/components/SendButton/SendButton.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import React, { useState } from 'react';
2+
import { message } from 'antd';
23
import * as S from '../TopUpBalanceButton/TopUpBalanceButton.styles';
34
import SendModal from '../SendModal/SendModal';
45
import { useAppSelector } from '@app/hooks/reduxHooks';
6+
import config from '@app/config/config';
57

68
const SendButton: React.FC = () => {
79
const { theme } = useAppSelector((state) => state.theme);
810
const [isModalOpen, setIsModalOpen] = useState(false);
911
const handleButtonClick = () => {
12+
if (!config.isWalletEnabled) {
13+
message.warning('Wallet functionality is not available. Please rebuild the panel with REACT_APP_WALLET_BASE_URL configured in your environment file.');
14+
return;
15+
}
1016
setIsModalOpen(true);
1117
};
1218
const handleModalClose = () => {

src/components/relay-dashboard/Balance/components/TopUpBalanceButton/TopUpBalanceButton.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React, { useState } from 'react';
22
import { useTranslation } from 'react-i18next';
3+
import { message } from 'antd';
34
import { useAppSelector } from '@app/hooks/reduxHooks';
45
import { TopUpBalanceModal } from '../TopUpBalanceModal/TopUpBalanceModal';
6+
import config from '@app/config/config';
57
import * as S from './TopUpBalanceButton.styles';
68

79
export const TopUpBalanceButton: React.FC = () => {
@@ -10,6 +12,10 @@ export const TopUpBalanceButton: React.FC = () => {
1012
const [isModalOpen, setIsModalOpen] = useState(false);
1113

1214
const handleButtonClick = () => {
15+
if (!config.isWalletEnabled) {
16+
message.warning('Wallet functionality is not available. Please rebuild the panel with REACT_APP_WALLET_BASE_URL configured in your environment file.');
17+
return;
18+
}
1319
setIsModalOpen(true);
1420
};
1521

src/config/config.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,21 @@ const getBaseURL = (): string => {
1212
return process.env.REACT_APP_BASE_URL || window.location.origin;
1313
};
1414

15-
const getWalletURL = (): string => {
15+
const getWalletURL = (): string | null => {
1616
// Demo mode override for testing
1717
if (process.env.REACT_APP_DEMO_MODE === 'true') {
1818
return 'http://localhost:9003';
1919
}
2020

21-
// Always require explicit wallet URL configuration
22-
if (!process.env.REACT_APP_WALLET_BASE_URL) {
23-
throw new Error('REACT_APP_WALLET_BASE_URL must be explicitly configured in environment variables');
24-
}
25-
26-
return process.env.REACT_APP_WALLET_BASE_URL;
21+
// Wallet URL is optional - return null if not configured
22+
return process.env.REACT_APP_WALLET_BASE_URL || null;
2723
};
2824

2925
const config = {
3026
baseURL: getBaseURL(),
3127
isDemoMode: process.env.REACT_APP_DEMO_MODE === 'true',
3228
walletBaseURL: getWalletURL(),
29+
isWalletEnabled: getWalletURL() !== null,
3330

3431
// Nostr relay configuration
3532
nostrRelayUrls: process.env.REACT_APP_NOSTR_RELAY_URLS?.split(',').map(url => url.trim()) || [

0 commit comments

Comments
 (0)