Skip to content

Lock spending limits settings row by password #5575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- added: Multiple memo support to `SendScene2`
- added: Add os version to the "OS" line of logs
- changed: "MAX" button in `FlipInput` restyled to tertiary and moved next to the text input field
- changed: Moved spending limits settings to password-locked account settings section.
- fixed: Primary button transforming on the animation on `GettingStartedScene`
- fixed: `NotificationCenterScene` could crash if there was an undismissed new token notification and the associated wallet no longer existed
- removed: Disable Fantom transaction list
Expand Down
294 changes: 147 additions & 147 deletions src/__tests__/scenes/__snapshots__/SettingsScene.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,153 @@ exports[`SettingsScene should render SettingsScene 1`] = `
]
}
/>
<View
accessibilityState={
{
"disabled": false,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={false}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"alignItems": "center",
"backgroundColor": "rgba(255, 255, 255, 0)",
"flexDirection": "row",
"marginBottom": 1,
"minHeight": 67,
"padding": 11,
}
}
>
<Text
style={
{
"color": "#888888",
"flexGrow": 1,
"flexShrink": 1,
"fontFamily": "Quicksand-Regular",
"fontSize": 22,
"paddingHorizontal": 11,
"textAlign": "left",
}
}
>
Spending Limits
</Text>
<View>
<View
pending={false}
style={
[
{
"aspectRatio": 1,
"position": "absolute",
"width": "100%",
"zIndex": 1,
},
{
"opacity": 0,
},
]
}
>
<ActivityIndicator
color="#00f1a2"
style={
{
"height": 34,
"marginHorizontal": 11,
}
}
/>
</View>
<View
pending={false}
style={
{
"opacity": 1,
}
}
>
<Text
allowFontScaling={false}
selectable={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "rgba(255, 255, 255, .75)",
"fontSize": 22,
"marginHorizontal": 11,
},
{
"fontFamily": "FontAwesome5Free-Solid",
"fontStyle": "normal",
"fontWeight": "normal",
},
{
"fontWeight": "900",
},
]
}
>
</Text>
</View>
</View>
</View>
<BVLinearGradient
colors={
[
452984831,
452984831,
]
}
endPoint={
{
"x": 1,
"y": 0.5,
}
}
locations={null}
startPoint={
{
"x": 0,
"y": 0.5,
}
}
style={
[
{
"borderBottomColor": "rgba(255, 255, 255, .1)",
"borderBottomWidth": 1,
"height": 1,
},
{
"margin": 11,
},
]
}
/>
<View
accessibilityState={
{
Expand Down Expand Up @@ -1661,153 +1808,6 @@ exports[`SettingsScene should render SettingsScene 1`] = `
]
}
/>
<View
accessibilityState={
{
"disabled": false,
}
}
accessibilityValue={
{
"max": undefined,
"min": undefined,
"now": undefined,
"text": undefined,
}
}
accessible={false}
focusable={true}
onClick={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"alignItems": "center",
"backgroundColor": "rgba(255, 255, 255, 0)",
"flexDirection": "row",
"marginBottom": 1,
"minHeight": 67,
"padding": 11,
}
}
>
<Text
style={
{
"color": "#FFFFFF",
"flexGrow": 1,
"flexShrink": 1,
"fontFamily": "Quicksand-Regular",
"fontSize": 22,
"paddingHorizontal": 11,
"textAlign": "left",
}
}
>
Spending Limits
</Text>
<View>
<View
pending={false}
style={
[
{
"aspectRatio": 1,
"position": "absolute",
"width": "100%",
"zIndex": 1,
},
{
"opacity": 0,
},
]
}
>
<ActivityIndicator
color="#00f1a2"
style={
{
"height": 34,
"marginHorizontal": 11,
}
}
/>
</View>
<View
pending={false}
style={
{
"opacity": 1,
}
}
>
<Text
allowFontScaling={false}
selectable={false}
style={
[
{
"color": undefined,
"fontSize": 12,
},
{
"color": "#00f1a2",
"fontSize": 22,
"marginHorizontal": 11,
},
{
"fontFamily": "FontAwesome5Free-Solid",
"fontStyle": "normal",
"fontWeight": "normal",
},
{
"fontWeight": "900",
},
]
}
>
</Text>
</View>
</View>
</View>
<BVLinearGradient
colors={
[
452984831,
452984831,
]
}
endPoint={
{
"x": 1,
"y": 0.5,
}
}
locations={null}
startPoint={
{
"x": 0,
"y": 0.5,
}
}
style={
[
{
"borderBottomColor": "rgba(255, 255, 255, .1)",
"borderBottomWidth": 1,
"height": 1,
},
{
"margin": 11,
},
]
}
/>
<View
accessibilityState={
{
Expand Down
6 changes: 5 additions & 1 deletion src/components/scenes/SettingsScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ export const SettingsScene = (props: Props) => {
})

const handleSpendingLimits = useHandler((): void => {
if (isLocked) {
handleUnlock()
return
}
navigation.navigate('spendingLimits')
})

Expand Down Expand Up @@ -348,6 +352,7 @@ export const SettingsScene = (props: Props) => {
<SettingsTappableRow disabled={isLocked} label={lstrings.settings_button_pin} onPress={handleChangePin} />
<SettingsTappableRow disabled={isLocked} label={lstrings.settings_button_setup_two_factor} onPress={handleChangeOtp} />
<SettingsTappableRow disabled={isLocked} label={lstrings.settings_button_password_recovery} onPress={handleChangeRecovery} />
<SettingsTappableRow disabled={isLocked} label={lstrings.spending_limits} onPress={handleSpendingLimits} />
<SettingsTappableRow disabled={isLocked} label={lstrings.title_duress_mode} onPress={handleDuressMode} />
<SettingsTappableRow disabled={isLocked} dangerous label={lstrings.delete_account_title} onPress={handleDeleteAccount} />
</EdgeCard>
Expand All @@ -357,7 +362,6 @@ export const SettingsScene = (props: Props) => {
<SettingsHeaderRow icon={<IonIcon color={theme.icon} name="options" size={iconSize} />} label={lstrings.settings_options_title_cap} />
<EdgeCard sections>
{config.disableSwaps !== true ? <SettingsTappableRow label={lstrings.settings_exchange_settings} onPress={handleExchangeSettings} /> : null}
<SettingsTappableRow label={lstrings.spending_limits} onPress={handleSpendingLimits} />
<SettingsLabelRow right={autoLogoutRightText} label={lstrings.settings_title_auto_logoff} onPress={handleSetAutoLogoutTime} />
<SettingsLabelRow right={removeIsoPrefix(defaultFiat)} label={lstrings.settings_title_currency} onPress={handleDefaultFiat} />

Expand Down
11 changes: 2 additions & 9 deletions src/components/scenes/SpendingLimitsScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useDispatch, useSelector } from '../../types/reactRedux'
import { EdgeAppSceneProps } from '../../types/routerTypes'
import { zeroString } from '../../util/utils'
import { SceneWrapper } from '../common/SceneWrapper'
import { showError, showToast } from '../services/AirshipInstance'
import { showError } from '../services/AirshipInstance'
import { cacheStyles, Theme, useTheme } from '../services/ThemeContext'
import { SettingsSwitchRow } from '../settings/SettingsSwitchRow'
import { EdgeText } from '../themed/EdgeText'
Expand All @@ -30,7 +30,6 @@ export const SpendingLimitsScene = (props: Props) => {
const currencySymbol = useSelector(state => getFiatSymbol(state.ui.settings.defaultFiat))
const transactionSpendingLimit = useSelector(state => state.ui.settings.spendingLimits.transaction)

const [password, setPassword] = React.useState('')
const [transactionAmount, setTransactionAmount] = React.useState(
!zeroString(transactionSpendingLimit.amount?.toString()) ? transactionSpendingLimit.amount.toString() : ''
)
Expand All @@ -39,9 +38,6 @@ export const SpendingLimitsScene = (props: Props) => {
const handleTransactionIsEnabledChanged = useHandler(() => setTransactionIsEnabled(!transactionIsEnabled))

const handleSubmitAsync = async () => {
const isAuthorized = await account.checkPassword(password)
if (!isAuthorized) return showToast(lstrings.password_check_incorrect_password_title)

const spendingLimits = {
transaction: {
isEnabled: transactionIsEnabled,
Expand All @@ -61,12 +57,9 @@ export const SpendingLimitsScene = (props: Props) => {
handleSubmitAsync().catch(err => showError(err))
})

const enableSlider = password.length > 8
return (
<SceneWrapper>
<KeyboardAwareScrollView contentContainerStyle={styles.scene} scrollIndicatorInsets={SCROLL_INDICATOR_INSET_FIX} keyboardShouldPersistTaps="handled">
<FilledTextInput secureTextEntry autoFocus placeholder={lstrings.enter_your_password} value={password} onChangeText={setPassword} />

<View style={styles.switchRow}>
<View style={styles.textBlock}>
<EdgeText style={styles.bodyText}>{lstrings.spending_limits_tx_title}</EdgeText>
Expand All @@ -89,7 +82,7 @@ export const SpendingLimitsScene = (props: Props) => {

<View style={styles.spacer} />

<MainButton label={lstrings.save} disabled={!enableSlider} onPress={handleSubmit} />
<MainButton label={lstrings.save} onPress={handleSubmit} />
</KeyboardAwareScrollView>
</SceneWrapper>
)
Expand Down
Loading