diff --git a/apps/wallet-mobile/.storybook/storybook.requires.js b/apps/wallet-mobile/.storybook/storybook.requires.js
index 49cfb0666f..1a18920e22 100644
--- a/apps/wallet-mobile/.storybook/storybook.requires.js
+++ b/apps/wallet-mobile/.storybook/storybook.requires.js
@@ -181,6 +181,7 @@ const getStories = () => {
"./src/features/SetupWallet/common/LearnMoreButton/LearnMoreButton.stories.tsx": require("../src/features/SetupWallet/common/LearnMoreButton/LearnMoreButton.stories.tsx"),
"./src/features/SetupWallet/common/LogoBanner/LogoBanner.stories.tsx": require("../src/features/SetupWallet/common/LogoBanner/LogoBanner.stories.tsx"),
"./src/features/SetupWallet/common/MnemonicInput/MnemonicInput.stories.tsx": require("../src/features/SetupWallet/common/MnemonicInput/MnemonicInput.stories.tsx"),
+ "./src/features/SetupWallet/common/PreparingWallet/PreparingWallet.stories.tsx": require("../src/features/SetupWallet/common/PreparingWallet/PreparingWallet.stories.tsx"),
"./src/features/SetupWallet/common/StepperProgress/StepperProgress.stories.tsx": require("../src/features/SetupWallet/common/StepperProgress/StepperProgress.stories.tsx"),
"./src/features/SetupWallet/common/TextInput/TextInput.stories.tsx": require("../src/features/SetupWallet/common/TextInput/TextInput.stories.tsx"),
"./src/features/SetupWallet/legacy/CheckNanoX/CheckNanoXScreen.stories.tsx": require("../src/features/SetupWallet/legacy/CheckNanoX/CheckNanoXScreen.stories.tsx"),
diff --git a/apps/wallet-mobile/src/AppNavigator.tsx b/apps/wallet-mobile/src/AppNavigator.tsx
index cfdfb3a24d..6876169c80 100644
--- a/apps/wallet-mobile/src/AppNavigator.tsx
+++ b/apps/wallet-mobile/src/AppNavigator.tsx
@@ -19,7 +19,6 @@ import {ModalScreen} from './components/Modal/ModalScreen'
import {AgreementChangedNavigator, InitializationNavigator} from './features/Initialization'
import {LegalAgreement, useLegalAgreement} from './features/Initialization/common'
import {useDeepLinkWatcher} from './features/Links/common/useDeepLinkWatcher'
-import {AddWalletNavigator} from './features/SetupWallet/SetupWalletNavigator'
import {CONFIG} from './legacy/config'
import {DeveloperScreen} from './legacy/DeveloperScreen'
import {AppRoutes} from './navigation'
@@ -143,8 +142,6 @@ export const AppNavigator = () => {
)}
-
-
diff --git a/apps/wallet-mobile/src/WalletNavigator.tsx b/apps/wallet-mobile/src/WalletNavigator.tsx
index 633e85f10d..62cc39b1bf 100644
--- a/apps/wallet-mobile/src/WalletNavigator.tsx
+++ b/apps/wallet-mobile/src/WalletNavigator.tsx
@@ -14,6 +14,7 @@ import {useLinksRequestAction} from './features/Links/common/useLinksRequestActi
import {useLinksShowActionResult} from './features/Links/common/useLinksShowActionResult'
import {MenuNavigator} from './features/Menu'
import {SettingsScreenNavigator} from './features/Settings'
+import {SetupWalletNavigator} from './features/SetupWallet/SetupWalletNavigator'
import {
ChooseBiometricLoginScreen,
useShowBiometricsScreen,
@@ -154,10 +155,10 @@ export const WalletNavigator = () => {
const isAuthOsSupported = useIsAuthOsSupported()
const {showBiometricsScreen} = useShowBiometricsScreen()
const walletManager = useWalletManager()
- const hasWallets = useHasWallets(walletManager)
+ const {hasWallets} = useHasWallets(walletManager)
const authSetting = useAuthSetting()
- const shouldAskToUseAuthWithOs = !hasWallets && showBiometricsScreen && isAuthOsSupported && authSetting !== 'os'
+ const shouldAskToUseAuthWithOs = showBiometricsScreen && isAuthOsSupported && authSetting !== 'os'
// initialRoute doesn't update the state of the navigator, only at first render
// https://reactnavigation.org/docs/auth-flow/
@@ -182,7 +183,7 @@ export const WalletNavigator = () => {
detachPreviousScreen: false /* https://github.com/react-navigation/react-navigation/issues/9883 */,
}}
>
- {shouldAskToUseAuthWithOs && (
+ {!hasWallets && shouldAskToUseAuthWithOs && (
{
/>
)}
+ {!hasWallets && !shouldAskToUseAuthWithOs && (
+
+ )}
+
{
const prefetchStakingInfo = usePrefetchStakingInfo(wallet)
return {
- allWallets: () => navigation.navigate('app-root', {screen: 'wallet-selection'}),
catalystVoting: () => {
prefetchStakingInfo()
diff --git a/apps/wallet-mobile/src/features/Settings/RemoveWallet/RemoveWalletScreen.tsx b/apps/wallet-mobile/src/features/Settings/RemoveWallet/RemoveWalletScreen.tsx
index 02adfb7833..c5a85ed95e 100644
--- a/apps/wallet-mobile/src/features/Settings/RemoveWallet/RemoveWalletScreen.tsx
+++ b/apps/wallet-mobile/src/features/Settings/RemoveWallet/RemoveWalletScreen.tsx
@@ -3,6 +3,7 @@ import React from 'react'
import {defineMessages, useIntl} from 'react-intl'
import {ScrollView, StyleSheet, View, ViewProps} from 'react-native'
import {SafeAreaView} from 'react-native-safe-area-context'
+import {useQueryClient} from 'react-query'
import {
Button,
@@ -15,7 +16,8 @@ import {
TextInputProps,
} from '../../../components'
import {useWalletNavigation} from '../../../navigation'
-import {useRemoveWallet, useWalletName} from '../../../yoroi-wallets/hooks'
+import {useWalletManager} from '../../../wallet-manager/WalletManagerContext'
+import {hasWalletsKey, useRemoveWallet, useWalletName} from '../../../yoroi-wallets/hooks'
import {useSelectedWallet} from '../../WalletManager/Context/SelectedWalletContext'
export const RemoveWalletScreen = () => {
@@ -23,16 +25,30 @@ export const RemoveWalletScreen = () => {
const styles = useStyles()
const wallet = useSelectedWallet()
const walletName = useWalletName(wallet)
+ const {resetToWalletSetup, resetToWalletSelection} = useWalletNavigation()
+ const walletManager = useWalletManager()
+ const queryClient = useQueryClient()
- const {resetToWalletSelection} = useWalletNavigation()
- const {removeWallet, isLoading} = useRemoveWallet(wallet.id, {
- onSuccess: () => resetToWalletSelection(),
+ const {removeWallet, isLoading: isRemoveWalletLoading} = useRemoveWallet(wallet.id, {
+ onSuccess: async () => {
+ queryClient.invalidateQueries({queryKey: [hasWalletsKey]})
+
+ const walletMetas = await walletManager.listWallets()
+ const hasWallets = walletMetas.length > 0
+
+ if (hasWallets) {
+ resetToWalletSelection()
+ return
+ }
+
+ resetToWalletSetup()
+ },
})
const [hasMnemonicWrittenDown, setHasMnemonicWrittenDown] = React.useState(false)
const [typedWalletName, setTypedWalletName] = React.useState('')
- const disabled = isLoading || (!wallet.isHW && !hasMnemonicWrittenDown) || walletName !== typedWalletName
+ const disabled = isRemoveWalletLoading || (!wallet.isHW && !hasMnemonicWrittenDown) || walletName !== typedWalletName
return (
diff --git a/apps/wallet-mobile/src/features/SetupWallet/SetupWalletNavigator.tsx b/apps/wallet-mobile/src/features/SetupWallet/SetupWalletNavigator.tsx
index 8bda996c4c..9b3243c0c0 100644
--- a/apps/wallet-mobile/src/features/SetupWallet/SetupWalletNavigator.tsx
+++ b/apps/wallet-mobile/src/features/SetupWallet/SetupWalletNavigator.tsx
@@ -20,7 +20,7 @@ import {RestoreWalletDetailsScreen} from './useCases/RestoreWallet/RestoreWallet
import {RestoreWalletScreen} from './useCases/RestoreWallet/RestoreWalletScreen'
const Stack = createStackNavigator()
-export const AddWalletNavigator = () => {
+export const SetupWalletNavigator = () => {
const strings = useStrings()
const {theme} = useTheme()
@@ -37,7 +37,7 @@ export const AddWalletNavigator = () => {
null}}
/>
{
const strings = useStrings()
const storage = useAsyncStorage()
const {walletImplementationIdChanged} = useSetupWallet()
+ const {resetToWalletSetup} = useWalletNavigation()
const navigate = () => {
walletImplementationIdChanged(HASKELL_SHELLEY.WALLET_IMPLEMENTATION_ID)
- navigation.navigate('new-wallet', {
- screen: 'setup-wallet-choose-setup-type',
- })
+ resetToWalletSetup()
}
const {enableAuthWithOs, isLoading} = useEnableAuthWithOs({
@@ -39,8 +38,6 @@ export const ChooseBiometricLoginScreen = () => {
storage.setItem(chooseBiometricLoginScreenShownKey, JSON.stringify(false))
}
- const navigation = useNavigation()
-
return (
diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseSetupType/ChooseSetupTypeScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseSetupType/ChooseSetupTypeScreen.tsx
index 554fffd980..99c02e95fc 100644
--- a/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseSetupType/ChooseSetupTypeScreen.tsx
+++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseSetupType/ChooseSetupTypeScreen.tsx
@@ -21,7 +21,12 @@ import {RestoreWallet} from '../../illustrations/RestoreWallet'
export const ChooseSetupTypeScreen = () => {
const {styles} = useStyles()
const strings = useStrings()
- const {networkIdChanged, setUpTypeChanged, useUSBChanged: USBChanged} = useSetupWallet()
+ const {
+ walletImplementationIdChanged,
+ networkIdChanged,
+ setUpTypeChanged,
+ useUSBChanged: USBChanged,
+ } = useSetupWallet()
const [isModalOpen, setIsModalOpen] = React.useState(false)
const {track} = useMetrics()
@@ -34,6 +39,7 @@ export const ChooseSetupTypeScreen = () => {
const navigation = useNavigation()
const handleCreate = () => {
+ walletImplementationIdChanged(HASKELL_SHELLEY.WALLET_IMPLEMENTATION_ID)
setUpTypeChanged('create')
if (isProduction()) {
@@ -47,6 +53,7 @@ export const ChooseSetupTypeScreen = () => {
}
const handleRestore = () => {
+ walletImplementationIdChanged(HASKELL_SHELLEY.WALLET_IMPLEMENTATION_ID)
setUpTypeChanged('restore')
if (isProduction()) {
@@ -65,6 +72,7 @@ export const ChooseSetupTypeScreen = () => {
const navigateHw = () => {
setIsModalOpen(false)
+ walletImplementationIdChanged(HASKELL_SHELLEY.WALLET_IMPLEMENTATION_ID)
setUpTypeChanged('hw')
if (isProduction()) {
diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/WalletDetailsScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/WalletDetailsScreen.tsx
index c0d52b12f2..3019e249af 100644
--- a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/WalletDetailsScreen.tsx
+++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/WalletDetailsScreen.tsx
@@ -69,7 +69,7 @@ export const WalletDetailsScreen = () => {
const {styles} = useStyles()
const {HEIGHT_MODAL_NAME_PASSWORD, HEIGHT_MODAL_CHECKSUM} = useSizeModal()
const {openModal, closeModal} = useModal()
- const {navigateToTxHistory} = useWalletNavigation()
+ const {resetToTxHistory} = useWalletNavigation()
const strings = useStrings()
const walletManager = useWalletManager()
const {walletNames} = useWalletNames(walletManager)
@@ -118,7 +118,7 @@ export const WalletDetailsScreen = () => {
onSuccess: ([wallet, walletMeta]) => {
selectWalletMeta(walletMeta)
selectWallet(wallet)
- navigateToTxHistory()
+ resetToTxHistory()
},
onError: (error) => {
InteractionManager.runAfterInteractions(() => {
diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletDetailsScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletDetailsScreen.tsx
index 19c0efeb5a..05d0666a41 100644
--- a/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletDetailsScreen.tsx
+++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletDetailsScreen.tsx
@@ -7,7 +7,6 @@ import * as React from 'react'
import {useIntl} from 'react-intl'
import {
InteractionManager,
- Keyboard,
Linking,
ScrollView,
StyleSheet,
@@ -71,7 +70,7 @@ export const RestoreWalletDetailsScreen = () => {
const {HEIGHT_MODAL_NAME_PASSWORD, HEIGHT_MODAL_CHECKSUM} = useSizeModal()
const {openModal, closeModal} = useModal()
const strings = useStrings()
- const {navigateToTxHistory} = useWalletNavigation()
+ const {resetToTxHistory} = useWalletNavigation()
const walletManager = useWalletManager()
const {track} = useMetrics()
const {walletNames} = useWalletNames(walletManager)
@@ -107,7 +106,7 @@ export const RestoreWalletDetailsScreen = () => {
onSuccess: ([wallet, walletMeta]) => {
selectWalletMeta(walletMeta)
selectWallet(wallet)
- navigateToTxHistory()
+ resetToTxHistory()
},
onError: (error) => {
InteractionManager.runAfterInteractions(() => {
@@ -163,7 +162,6 @@ export const RestoreWalletDetailsScreen = () => {
)
const showModalTipsPassword = () => {
- Keyboard.dismiss()
openModal(
strings.walletDetailsModalTitle,
@@ -202,7 +200,6 @@ export const RestoreWalletDetailsScreen = () => {
}
const showModalTipsPlateNumber = () => {
- Keyboard.dismiss()
openModal(
strings.walletDetailsModalTitle,
diff --git a/apps/wallet-mobile/src/features/WalletManager/SelectWalletFromList/SelectWalletFromListScreen.tsx b/apps/wallet-mobile/src/features/WalletManager/SelectWalletFromList/SelectWalletFromListScreen.tsx
index b16eeb996e..cbee877ed1 100644
--- a/apps/wallet-mobile/src/features/WalletManager/SelectWalletFromList/SelectWalletFromListScreen.tsx
+++ b/apps/wallet-mobile/src/features/WalletManager/SelectWalletFromList/SelectWalletFromListScreen.tsx
@@ -16,7 +16,6 @@ import {useMetrics} from '../../../metrics/metricsManager'
import {useWalletNavigation} from '../../../navigation'
import {WalletMeta} from '../../../wallet-manager/types'
import {useWalletManager} from '../../../wallet-manager/WalletManagerContext'
-import * as HASKELL_SHELLEY from '../../../yoroi-wallets/cardano/constants/mainnet/constants'
import {InvalidState} from '../../../yoroi-wallets/cardano/errors'
import {isJormungandr} from '../../../yoroi-wallets/cardano/networks'
import {useOpenWallet, useWalletMetas} from '../../../yoroi-wallets/hooks'
@@ -146,20 +145,16 @@ const SupportTicketLink = () => {
}
const AddWalletButton = () => {
- const navigation = useNavigation()
const strings = useStrings()
const {styles} = useStyles()
- const {walletImplementationIdChanged, reset: resetSetupWallet} = useSetupWallet()
+ const {reset: resetSetupWallet} = useSetupWallet()
+ const {resetToWalletSetup} = useWalletNavigation()
return (