Skip to content
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

Improve seed restore #329

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
773 changes: 386 additions & 387 deletions assets/translations/de.json

Large diffs are not rendered by default.

771 changes: 385 additions & 386 deletions assets/translations/en.json

Large diffs are not rendered by default.

771 changes: 385 additions & 386 deletions assets/translations/es.json

Large diffs are not rendered by default.

773 changes: 386 additions & 387 deletions assets/translations/fr.json

Large diffs are not rendered by default.

771 changes: 385 additions & 386 deletions assets/translations/hu.json

Large diffs are not rendered by default.

771 changes: 385 additions & 386 deletions assets/translations/sw.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/components/TxtInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ITxtInputProps {
multiline?: boolean
numberOfLines?: number
style?: StyleProp<TextStyle>
autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters'
}

export default function TxtInput({
Expand All @@ -31,7 +32,8 @@ export default function TxtInput({
value,
multiline,
numberOfLines,
style
style,
autoCapitalize
}: ITxtInputProps) {
const { color, highlight } = useThemeContext()
const inputRef = createRef<TextInput>()
Expand All @@ -58,6 +60,7 @@ export default function TxtInput({
value={value}
multiline={multiline}
numberOfLines={numberOfLines}
autoCapitalize={autoCapitalize}
style={[globals(color).input, { marginBottom: vs(20) }, style]}
/>
)
Expand Down
136 changes: 0 additions & 136 deletions src/components/hooks/Restore.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions src/components/nav/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ import RecoverScreen from '@screens/Restore/Recover'
import RecoveringScreen from '@screens/Restore/Recovering'
import RestoreWarningScreen from '@screens/Restore/RestoreWarning'
import SeedScreen from '@screens/Restore/Seed'
import SelectKeysetScreen from '@screens/Restore/SelectKeyset'
import SelectRecoveryMintScreen from '@screens/Restore/SelectRecoveryMint'
import RestoreOverviewScreen from '@screens/Restore/Success'
import Settings from '@screens/Settings'
import AboutSettings from '@screens/Settings/About'
import ContactsSettings from '@screens/Settings/Contacts'
Expand Down Expand Up @@ -197,6 +199,8 @@ export default function Navigator({
<Stack.Screen name='Recovering' component={RecoveringScreen} />
<Stack.Screen name='Select recovery mint' component={SelectRecoveryMintScreen} />
<Stack.Screen name='Restore warning' component={RestoreWarningScreen} />
<Stack.Screen name='restoreOverview' component={RestoreOverviewScreen} />
<Stack.Screen name='selectKeyset' component={SelectKeysetScreen} />
</Stack.Navigator>
</View>
)
Expand Down
23 changes: 22 additions & 1 deletion src/model/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ export type RootStackParamList = {
isZap?: boolean
nostr?: INostrSendData
isScanned?: boolean
isRestored?: boolean
change?: number
comingFromOnboarding?: boolean
}
Expand Down Expand Up @@ -236,13 +235,33 @@ export type RootStackParamList = {
comingFromOnboarding?: boolean
}
Recovering: {
from: number
to: number
mintUrl: string
keysetId: string
mnemonic: string
comingFromOnboarding?: boolean
shouldOvershoot?: boolean
}
'Restore warning': {
comingFromOnboarding?: boolean
}
restoreOverview: {
mnemonic: string
amount: number
mint: string
keysetID: string
cycle: {
start: number
end: number
}
comingFromOnboarding?: boolean
}
selectKeyset: {
mnemonic: string
mintUrl: string
comingFromOnboarding?: boolean
}
}

export type TRouteString = 'dashboard' | 'mints' | 'Address book' | 'Settings'
Expand Down Expand Up @@ -294,6 +313,8 @@ export type IDerivingPageProps = NativeStackScreenProps<RootStackParamList, 'Der
export type IRecoveringPageProps = NativeStackScreenProps<RootStackParamList, 'Recovering'>
export type ISelectRecoveryMintPageProps = NativeStackScreenProps<RootStackParamList, 'Select recovery mint'>
export type IRestoreWarningPageProps = NativeStackScreenProps<RootStackParamList, 'Restore warning'>
export type IRestoreSuccessPageProps = NativeStackScreenProps<RootStackParamList, 'restoreOverview'>
export type ISelectKeysetPageProps = NativeStackScreenProps<RootStackParamList, 'selectKeyset'>
export type TBottomNavProps =
TNostrOnboardingPageProps |
TDashboardPageProps |
Expand Down
14 changes: 14 additions & 0 deletions src/screens/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) {
color={hi[highlight]}
onPress={() => {
setModal(prev => ({ ...prev, sendOpts: true }))
// navigation.navigate('restoreSuccess', {
// mint: 'https://testnut.cashu.space',
// keysetID: 'jkasfhgkjg',
// cycle: { start: 300, end: 350 },
// amount: 100,
// comingFromOnboarding: true,
// })
}}
/>
:
Expand All @@ -317,6 +324,13 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) {
color={hi[highlight]}
onPress={() => {
navigation.navigate('mints')
// navigation.navigate('restoreSuccess', {
// mint: 'https://testnut.cashu.space',
// keysetID: 'jkasfhgkjg',
// cycle: { start: 300, end: 350 },
// amount: 100,
// comingFromOnboarding: true,
// })
}}
/>
}
Expand Down
1 change: 1 addition & 0 deletions src/screens/Mints/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export default function Mints({ navigation }: TMintsPageProps) {
value={input}
onChangeText={setInput}
onSubmitEditing={() => void handleMintInput()}
autoCapitalize='none'
style={[{ paddingRight: s(55) }]}
/>
{/* scan icon */}
Expand Down
10 changes: 2 additions & 8 deletions src/screens/Payment/Send/Inputfield.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,11 @@ export default function InputfieldScreen({ navigation, route }: TMeltInputfieldP
keyboardType='email-address'
placeholder={t('invoiceOrLnurl')}
value={input}
onChangeText={text => {
setInput(text)
/* Handle when the continue button is pressed
if (isLnInvoice(text)) {
void handleInvoicePaste(text)
}
*/
}}
onChangeText={text => setInput(text)}
onSubmitEditing={() => void handleBtnPress()}
autoFocus
ms={200}
autoCapitalize='none'
style={{ paddingRight: s(90) }}
/>
{/* Paste / Clear Input */}
Expand Down
16 changes: 5 additions & 11 deletions src/screens/Payment/Success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { preventBack } from '@nav/utils'
import ProfilePic from '@screens/Addressbook/ProfilePic'
import { useThemeContext } from '@src/context/Theme'
import { NS } from '@src/i18n'
import { l } from '@src/logger'
import { formatSatStr, isNum, vib } from '@util'
import LottieView from 'lottie-react-native'
import { useEffect } from 'react'
Expand All @@ -29,7 +28,7 @@ export default function SuccessPage({ navigation, route }: TSuccessPageProps) {
isZap,
nostr,
isScanned,
isRestored,
comingFromOnboarding
} = route.params
const { t } = useTranslation([NS.common])
const { color } = useThemeContext()
Expand All @@ -44,8 +43,6 @@ export default function SuccessPage({ navigation, route }: TSuccessPageProps) {
return () => navigation.removeListener('beforeRemove', backHandler)
}, [navigation])

l({ amount, memo, fee, mint, isClaim, isMelt, nostr, isScanned })

return (
<View style={[styles.container, { backgroundColor: color.BACKGROUND }]}>
{nostr && nostr.contact && nostr.contact.picture ?
Expand All @@ -71,13 +68,10 @@ export default function SuccessPage({ navigation, route }: TSuccessPageProps) {
isAutoSwap ?
t('autoSwapSuccess')
:
isRestored ?
<>{formatSatStr(amount || 0)} {t('restored')}!</>
!nostr ?
<>{formatSatStr(amount || 0)} {isClaim ? t('claimed') : t('minted')}!</>
:
!nostr ?
<>{formatSatStr(amount || 0)} {isClaim ? t('claimed') : t('minted')}!</>
:
null
null
}
</Text>
{memo &&
Expand Down Expand Up @@ -123,7 +117,7 @@ export default function SuccessPage({ navigation, route }: TSuccessPageProps) {
<Button
txt={t('backToDashboard')}
onPress={() => {
if (route.params?.comingFromOnboarding) {
if (comingFromOnboarding) {
return navigation.navigate('auth', { pinHash: '' })
}
const routes = navigation.getState()?.routes
Expand Down
14 changes: 1 addition & 13 deletions src/screens/Restore/ConfirmMnemonic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ import { useTranslation } from 'react-i18next'
import { KeyboardAvoidingView, type TextInput, View } from 'react-native'
import { ScaledSheet } from 'react-native-size-matters'

/*

manual test cases:
---
[OK] * Start new seed wallet: confirm mnemonic, set pin, add mint, mint, send, receive, melt, restore
[OK] * Start new quick wallet: skip pin, add mint, activate seed, mint, send, receive, restore
[OK] * Start new recovery wallet: paste seed, restore, set pin, send, receive, melt, mint, restore
[OK] * Start new quick wallet, skip pin, skip mint, restore, send, receive, melt, mint, restore
[ ] * ...
[ ] * ...

*/

export default function ConfirmMnemonicScreen({ navigation, route }: IConfirmMnemonicPageProps) {

const { t } = useTranslation([NS.common])
Expand Down Expand Up @@ -103,6 +90,7 @@ export default function ConfirmMnemonicScreen({ navigation, route }: IConfirmMne
placeholder={`Seed (${randomInt + 1}.)`}
onChangeText={text => setInput(text)}
onSubmitEditing={() => void handleConfirm()}
autoCapitalize='none'
autoFocus
ms={200}
/>
Expand Down
Loading
Loading