Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions __tests__/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ describe('validation utilities', () => {
});

it('returns null for valid address', () => {
const valid = 'GC3S2J2C4G3D2O446IXXH2P454G4H5R3C5Y2K5J4D3O2I1H0G8F7E6D5'; // Valid format key
const valid = 'GABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC';
expect(validateAddress(valid)).toBeNull();
expect(validateAddress(` ${valid} `)).toBeNull(); // trimmed
});

it('returns error if sending to self', () => {
const ownKey = 'GC3S2J2C4G3D2O446IXXH2P454G4H5R3C5Y2K5J4D3O2I1H0G8F7E6D5';
const ownKey = 'GOWNKEYABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW';
expect(validateAddress(ownKey, ownKey)).toBe("You can't send a payment to your own wallet.");
});
});
}); // <--- Closed describe('validateAddress') here!

describe('validateAmount', () => {
it('returns error for empty input', () => {
Expand Down Expand Up @@ -91,4 +93,4 @@ describe('validation utilities', () => {
expect(validateMemo(longMemo)).toBe('Memo is too long. Please keep it under 28 bytes.');
});
});
});
});
94 changes: 51 additions & 43 deletions app/(tabs)/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../../src/utils/walletStorageErrors';
import { useAppLockStore } from '../../src/store/appLockStore';
import { ThemeMode } from '../../src/store/appStore';
import { Moon, Sun, Monitor, Shield, Info, Globe } from 'lucide-react-native';import { WalletResetConfirmModal } from '../../src/components/WalletResetConfirmModal';
import { Moon, Sun, Monitor, Shield, AlertTriangle, Activity } from 'lucide-react-native';
import { SecretKeyReveal } from '../../src/components/SecretKeyReveal';
import { WalletResetConfirmModal } from '../../src/components/WalletResetConfirmModal';
Expand All @@ -38,6 +39,9 @@ export default function SettingsScreen() {
const appVersion = Constants.expoConfig?.version ?? Constants.nativeAppVersion ?? '1.0.0';
const appName = Constants.expoConfig?.name ?? 'Stellar PocketPay';

// Read network from environment variable, with a fallback
const activeNetwork = process.env.EXPO_PUBLIC_STELLAR_NETWORK ?? 'TESTNET';

const handleExportKey = async () => {
if (!showSecret) {
const secret = await getSecretKey();
Expand Down Expand Up @@ -108,6 +112,11 @@ export default function SettingsScreen() {
Require biometrics or passcode to open
</Text>
</View>
<Switch
value={isLockEnabled}
onValueChange={handleToggleLock}
trackColor={{ false: colors.border, true: colors.primary }}
/>
</View>
</View>
<Switch
Expand Down Expand Up @@ -155,6 +164,29 @@ export default function SettingsScreen() {
<View style={styles.section}>
<Text style={styles.sectionTitle}>About</Text>
<View style={styles.card}>
<View style={styles.aboutRow}>
<Info color={colors.textSecondary} size={20} />
<View style={styles.aboutTextGroup}>
<Text style={styles.aboutLabel}>App Name</Text>
<Text style={styles.aboutValue}>{appName}</Text>
</View>
</View>
<View style={styles.aboutDivider} />
<View style={styles.aboutRow}>
<Info color={colors.textSecondary} size={20} />
<View style={styles.aboutTextGroup}>
<Text style={styles.aboutLabel}>Version</Text>
<Text style={styles.aboutValue}>{appVersion}</Text>
</View>
</View>
<View style={styles.aboutDivider} />
<View style={styles.aboutRow}>
<Info color={colors.textSecondary} size={20} />
<View style={styles.aboutTextGroup}>
<Text style={styles.aboutLabel}>Network</Text>
{/* Dynamically display active network with fallback */}
<Text style={styles.aboutValue}>{activeNetwork}</Text>
</View>
<View style={styles.row}>
<Text style={styles.aboutLabel}>App Name</Text>
<Text style={styles.rowValue}>{appName}</Text>
Expand Down Expand Up @@ -219,43 +251,23 @@ const createStyles = (colors: ThemeColors) => StyleSheet.create({
textTransform: 'uppercase',
letterSpacing: 1,
},
dangerTitleRow: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: SIZES.sm,
},
dangerSectionTitle: {
color: colors.error,
fontSize: 14,
fontWeight: '500',
marginLeft: SIZES.xs,
textTransform: 'uppercase',
letterSpacing: 1,
},
card: {
backgroundColor: colors.surface,
borderRadius: RADIUS.lg,
overflow: 'hidden',
borderWidth: 1,
borderColor: colors.border,
},
dangerCard: {
borderColor: colors.error,
},
row: {
flexDirection: 'row',
alignItems: 'center',
justifyInBetween: 'space-between',
padding: SIZES.lg,
borderBottomWidth: 1,
borderBottomColor: colors.border,
},
rowLast: {
borderBottomWidth: 0,
},
rowLeft: {
flexDirection: 'row',
alignItems: 'center',
flex: 1,
},
rowTextGroup: {
marginLeft: SIZES.md,
Expand Down Expand Up @@ -297,37 +309,33 @@ const createStyles = (colors: ThemeColors) => StyleSheet.create({
themeOptionLabelSelected: {
color: colors.primary,
},
rowValue: {
color: colors.textSecondary,
fontSize: 16,
aboutRow: {
flexDirection: 'row',
alignItems: 'center',
paddingVertical: SIZES.md,
paddingHorizontal: SIZES.lg,
},
aboutTextGroup: {
marginLeft: SIZES.md,
},
aboutLabel: {
color: colors.textMuted,
fontSize: 12,
},
aboutValue: {
color: colors.textPrimary,
fontSize: 16,
fontWeight: '500',
},
menuButton: {
borderWidth: 0,
borderBottomWidth: 1,
borderBottomColor: colors.border,
borderRadius: 0,
justifyContent: 'flex-start',
paddingHorizontal: SIZES.lg,
aboutDivider: {
height: 1,
backgroundColor: colors.border,
marginHorizontal: SIZES.lg,
},
menuButtonLast: {
borderWidth: 0,
borderRadius: 0,
justifyContent: 'flex-start',
paddingHorizontal: SIZES.lg,
},
aboutRow: {
flexDirection: 'row',
alignItems: 'center',
paddingVertical: SIZES.md,
paddingHorizontal: SIZES.lg,
},
footerText: {
color: colors.textMuted,
fontSize: 12,
marginBottom: 4,
}
});
});
4 changes: 4 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// jest.setup.js
jest.mock('@react-native-async-storage/async-storage', () =>
require('@react-native-async-storage/async-storage/jest/async-storage-mock')
);
19 changes: 5 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,12 @@
},
"jest": {
"preset": "jest-expo",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest"
},
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
"setupFiles": [
"<rootDir>/jest.setup.js"
],
"setupFilesAfterEnv": [
"@testing-library/jest-native/extend-expect"
],
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg|lucide-react-native|@stellar|@noble)"
],
"moduleNameMapper": {
"^expo-router$": "<rootDir>/__mocks__/expo-router.ts",
"^expo-secure-store$": "<rootDir>/__mocks__/expo-secure-store.ts",
Expand All @@ -41,6 +30,7 @@
},
"dependencies": {
"@react-native-async-storage/async-storage": "2.2.0",
"@stellar/stellar-sdk": "^16.0.1",
"@stellar/stellar-sdk": "^12.2.0",
"buffer": "^6.0.3",
"events": "^3.3.0",
Expand All @@ -50,6 +40,7 @@
"expo-constants": "~18.0.13",
"expo-crypto": "~15.0.9",
"expo-linking": "~8.0.12",
"expo-local-authentication": "~16.0.5",
"expo-local-authentication": "~17.0.8",
"expo-router": "~6.0.24",
"expo-secure-store": "~15.0.8",
Expand Down Expand Up @@ -85,4 +76,4 @@
"typescript": "~5.9.2"
},
"private": true
}
}
Loading