diff --git a/apps/wallet-mobile/src/AppNavigator.tsx b/apps/wallet-mobile/src/AppNavigator.tsx index 8e5d688132..cfdfb3a24d 100644 --- a/apps/wallet-mobile/src/AppNavigator.tsx +++ b/apps/wallet-mobile/src/AppNavigator.tsx @@ -25,7 +25,7 @@ import {DeveloperScreen} from './legacy/DeveloperScreen' import {AppRoutes} from './navigation' import {SearchProvider} from './Search/SearchContext' import {WalletNavigator} from './WalletNavigator' -import {AuthSetting, useAuthOsEnabled, useAuthSetting, useAuthWithOs} from './yoroi-wallets/auth' +import {AuthSetting, useAuthSetting, useAuthWithOs, useIsAuthOsSupported} from './yoroi-wallets/auth' const Stack = createStackNavigator() const navRef = React.createRef>() @@ -208,8 +208,8 @@ const useAutoLogout = () => { const authSetting = useAuthSetting() const strings = useStrings() const {logout} = useAuth() - const authOsEnabled = useAuthOsEnabled() - const osAuthDisabled = !authOsEnabled && authSetting === 'os' + const isAuthOsSupported = useIsAuthOsSupported() + const osAuthDisabled = !isAuthOsSupported && authSetting === 'os' useBackgroundTimeout({ onTimeout: logout, @@ -246,7 +246,7 @@ const useHideScreenInAppSwitcher = () => { type FirstAction = 'auth-with-pin' | 'auth-with-os' | 'request-new-pin' | 'first-run' | 'show-agreement-changed-notice' const getFirstAction = ( - authOsEnabled: boolean, + isAuthOsSupported: boolean, authSetting: AuthSetting, agreement: LegalAgreement | undefined, ): FirstAction => { @@ -255,16 +255,16 @@ const getFirstAction = ( if (isString(authSetting) && !hasAccepted) return 'show-agreement-changed-notice' if (authSetting === 'pin') return 'auth-with-pin' - if (authSetting === 'os' && authOsEnabled) return 'auth-with-os' - if (authSetting === 'os' && !authOsEnabled) return 'request-new-pin' + if (authSetting === 'os' && isAuthOsSupported) return 'auth-with-os' + if (authSetting === 'os' && !isAuthOsSupported) return 'request-new-pin' return 'first-run' // setup not completed } const useFirstAction = () => { const authSetting = useAuthSetting() - const authOsEnabled = useAuthOsEnabled() + const isAuthOsSupported = useIsAuthOsSupported() const terms = useLegalAgreement() - return getFirstAction(authOsEnabled, authSetting, terms) + return getFirstAction(isAuthOsSupported, authSetting, terms) } diff --git a/apps/wallet-mobile/src/WalletNavigator.tsx b/apps/wallet-mobile/src/WalletNavigator.tsx index f58c96167d..63a5c7cebb 100644 --- a/apps/wallet-mobile/src/WalletNavigator.tsx +++ b/apps/wallet-mobile/src/WalletNavigator.tsx @@ -29,8 +29,10 @@ import {NftDetailsNavigator} from './NftDetails/NftDetailsNavigator' import {NftsNavigator} from './Nfts/NftsNavigator' import {SearchProvider} from './Search/SearchContext' import {TxHistoryNavigator} from './TxHistory' -import {useAuthOsEnabled} from './yoroi-wallets/auth' +import {useWalletManager} from './wallet-manager/WalletManagerContext' +import {useAuthSetting, useIsAuthOsSupported} from './yoroi-wallets/auth' import {isHaskellShelley} from './yoroi-wallets/cardano/utils' +import {useHasWallets} from './yoroi-wallets/hooks' const Tab = createBottomTabNavigator() const WalletTabNavigator = () => { @@ -149,8 +151,13 @@ export const WalletNavigator = () => { const strings = useStrings() const {theme} = useTheme() useLinksRequestAction() - const authOsEnabled = useAuthOsEnabled() + const isAuthOsSupported = useIsAuthOsSupported() const {showBiometricsScreen} = useShowBiometricsScreen() + const walletManager = useWalletManager() + const hasWallets = useHasWallets(walletManager) + const authSetting = useAuthSetting() + + const shouldAskToUseAuthWithOs = !hasWallets && showBiometricsScreen && isAuthOsSupported && authSetting !== 'os' // initialRoute doesn't update the state of the navigator, only at first render // https://reactnavigation.org/docs/auth-flow/ @@ -175,7 +182,7 @@ export const WalletNavigator = () => { detachPreviousScreen: false /* https://github.com/react-navigation/react-navigation/issues/9883 */, }} > - {showBiometricsScreen && authOsEnabled && ( + {shouldAskToUseAuthWithOs && ( { const {enabled: crashReportEnabled} = useCrashReports() const authSetting = useAuthSetting() - const authOsEnabled = useAuthOsEnabled() + const isAuthOsSupported = useIsAuthOsSupported() const navigateTo = useNavigateTo() const {authWithOs} = useAuthWithOs({onSuccess: navigateTo.enableLoginWithPin}) @@ -126,12 +126,12 @@ export const ApplicationSettingsScreen = () => { icon={} label={strings.biometricsSignIn} info={strings.biometricsSignInInfo} - disabled={!authOsEnabled} + disabled={!isAuthOsSupported} > 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 7ac3b8ce8f..613953ef2a 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/WalletDetailsScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/WalletDetailsScreen.tsx @@ -57,7 +57,7 @@ const useSizeModal = () => { } // when restoring, later will be part of the onboarding -const addressMode: AddressMode = 'multiple' +const addressMode: AddressMode = 'single' export const WalletDetailsScreen = () => { const bold = useBold() const {styles} = useStyles() 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 90d73e6200..bfab406ea2 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletDetailsScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletDetailsScreen.tsx @@ -58,7 +58,7 @@ const useSizeModal = () => { } // when restoring, later will be part of the onboarding -const addressMode: AddressMode = 'multiple' +const addressMode: AddressMode = 'single' export const RestoreWalletDetailsScreen = () => { const bold = useBold() const {styles} = useStyles() diff --git a/apps/wallet-mobile/src/yoroi-wallets/auth/auth.ts b/apps/wallet-mobile/src/yoroi-wallets/auth/auth.ts index 4b130890c2..cf6a1ac38c 100644 --- a/apps/wallet-mobile/src/yoroi-wallets/auth/auth.ts +++ b/apps/wallet-mobile/src/yoroi-wallets/auth/auth.ts @@ -14,11 +14,11 @@ import {YoroiWallet} from '../cardano/types' import {decryptData, encryptData} from '../encryption' import {AuthenticationPrompt, Keychain} from '../storage' -export const useAuthOsEnabled = (options?: UseQueryOptions) => { +export const useIsAuthOsSupported = (options?: UseQueryOptions) => { const queryClient = useQueryClient() const query = useQuery({ - queryKey: ['authOsEnabled'], - queryFn: authOsEnabled, + queryKey: ['isAuthOsSupported'], + queryFn: isAuthOsSupported, suspense: true, ...options, }) @@ -269,7 +269,7 @@ export type AuthSetting = 'pin' | 'os' | undefined export const AUTH_WITH_OS: AuthSetting = 'os' export const AUTH_WITH_PIN: AuthSetting = 'pin' -export const authOsEnabled = () => { +export const isAuthOsSupported = () => { return Platform.select({ android: async () => canAuthWithOS({ diff --git a/apps/wallet-mobile/src/yoroi-wallets/storage/KeychainStorage.test.ts b/apps/wallet-mobile/src/yoroi-wallets/storage/KeychainStorage.test.ts index 0081b445b9..b3a352a9ad 100644 --- a/apps/wallet-mobile/src/yoroi-wallets/storage/KeychainStorage.test.ts +++ b/apps/wallet-mobile/src/yoroi-wallets/storage/KeychainStorage.test.ts @@ -1,6 +1,6 @@ import {canAuthWithOS} from '../auth/auth' -describe('authOsEnabled', () => { +describe('isAuthOsSupported', () => { describe('android', () => { describe('with fingerprint', () => { it('can auth', () => { diff --git a/apps/wallet-mobile/translations/messages/src/WalletNavigator.json b/apps/wallet-mobile/translations/messages/src/WalletNavigator.json index 5444c4691b..b897a5e8a5 100644 --- a/apps/wallet-mobile/translations/messages/src/WalletNavigator.json +++ b/apps/wallet-mobile/translations/messages/src/WalletNavigator.json @@ -4,14 +4,14 @@ "defaultMessage": "!!!Transactions", "file": "src/WalletNavigator.tsx", "start": { - "line": 223, + "line": 227, "column": 22, - "index": 7793 + "index": 8024 }, "end": { - "line": 226, + "line": 230, "column": 3, - "index": 7896 + "index": 8127 } }, { @@ -19,14 +19,14 @@ "defaultMessage": "!!!Send", "file": "src/WalletNavigator.tsx", "start": { - "line": 227, + "line": 231, "column": 14, - "index": 7912 + "index": 8143 }, "end": { - "line": 230, + "line": 234, "column": 3, - "index": 8011 + "index": 8242 } }, { @@ -34,14 +34,14 @@ "defaultMessage": "!!!Receive", "file": "src/WalletNavigator.tsx", "start": { - "line": 231, + "line": 235, "column": 17, - "index": 8030 + "index": 8261 }, "end": { - "line": 234, + "line": 238, "column": 3, - "index": 8135 + "index": 8366 } }, { @@ -49,14 +49,14 @@ "defaultMessage": "!!!Dashboard", "file": "src/WalletNavigator.tsx", "start": { - "line": 235, + "line": 239, "column": 19, - "index": 8156 + "index": 8387 }, "end": { - "line": 238, + "line": 242, "column": 3, - "index": 8253 + "index": 8484 } }, { @@ -64,14 +64,14 @@ "defaultMessage": "!!!Delegate", "file": "src/WalletNavigator.tsx", "start": { - "line": 239, + "line": 243, "column": 18, - "index": 8273 + "index": 8504 }, "end": { - "line": 242, + "line": 246, "column": 3, - "index": 8368 + "index": 8599 } }, { @@ -79,14 +79,14 @@ "defaultMessage": "!!!Wallet", "file": "src/WalletNavigator.tsx", "start": { - "line": 243, + "line": 247, "column": 16, - "index": 8386 + "index": 8617 }, "end": { - "line": 246, + "line": 250, "column": 3, - "index": 8484 + "index": 8715 } }, { @@ -94,14 +94,14 @@ "defaultMessage": "!!!Staking", "file": "src/WalletNavigator.tsx", "start": { - "line": 247, + "line": 251, "column": 17, - "index": 8503 + "index": 8734 }, "end": { - "line": 250, + "line": 254, "column": 3, - "index": 8568 + "index": 8799 } }, { @@ -109,14 +109,14 @@ "defaultMessage": "!!!NFT Gallery", "file": "src/WalletNavigator.tsx", "start": { - "line": 251, + "line": 255, "column": 14, - "index": 8584 + "index": 8815 }, "end": { - "line": 254, + "line": 258, "column": 3, - "index": 8678 + "index": 8909 } }, { @@ -124,14 +124,14 @@ "defaultMessage": "!!!Menu", "file": "src/WalletNavigator.tsx", "start": { - "line": 255, + "line": 259, "column": 14, - "index": 8694 + "index": 8925 }, "end": { - "line": 258, + "line": 262, "column": 3, - "index": 8746 + "index": 8977 } }, { @@ -139,14 +139,14 @@ "defaultMessage": "!!!My wallets", "file": "src/WalletNavigator.tsx", "start": { - "line": 259, + "line": 263, "column": 31, - "index": 8779 + "index": 9010 }, "end": { - "line": 262, + "line": 266, "column": 3, - "index": 8888 + "index": 9119 } } ] \ No newline at end of file