diff --git a/apps/wallet-mobile/.env b/apps/wallet-mobile/.env index 17db531d54..a1031aea55 100644 --- a/apps/wallet-mobile/.env +++ b/apps/wallet-mobile/.env @@ -3,7 +3,7 @@ COMMIT=093dec95a BUILD_VARIANT=STAGING SENTRY_DSN=https://fb3745d47d994059917e358dae581466@o1138840.ingest.sentry.io/4505319746764800 -DISABLE_LOGBOX=true +DISABLE_LOGBOX=false WALLET_1_MNEMONIC=abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon address WALLET_1_NETWORK_ID=300 @@ -20,3 +20,5 @@ FRONTEND_FEE_ADDRESS_MAINNET=addr1q9ry6jfdgm0lcrtfpgwrgxg7qfahv80jlghhrthy6w8hmy FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km UNSTOPPABLE_API_KEY=czsajliz-wxgu6tujd1zqq7hey_pclfqhdjsqolsxjfsurgh + +LOGGER_FILTER= diff --git a/apps/wallet-mobile/.storybook/storybook.requires.js b/apps/wallet-mobile/.storybook/storybook.requires.js index 3c33e85fd6..cfe07ed9ad 100644 --- a/apps/wallet-mobile/.storybook/storybook.requires.js +++ b/apps/wallet-mobile/.storybook/storybook.requires.js @@ -197,7 +197,7 @@ const getStories = () => { "./src/features/SetupWallet/common/CardAboutPhrase/CardAboutPhrase.stories.tsx": require("../src/features/SetupWallet/common/CardAboutPhrase/CardAboutPhrase.stories.tsx"), "./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/PreparingWallet/PreparingWallet.stories.tsx": require("../src/features/SetupWallet/common/PreparingWallet/PreparingWallet.stories.tsx"), + "./src/features/SetupWallet/common/PreparingWalletScreen/PreparingWalletScreen.stories.tsx": require("../src/features/SetupWallet/common/PreparingWalletScreen/PreparingWalletScreen.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/ios/Podfile.lock b/apps/wallet-mobile/ios/Podfile.lock index 7f7cdde8de..7b40ba71f8 100644 --- a/apps/wallet-mobile/ios/Podfile.lock +++ b/apps/wallet-mobile/ios/Podfile.lock @@ -1560,7 +1560,7 @@ SPEC CHECKSUMS: amplitude-react-native: 1ea3d5e1f80ccc357dd178c55c29e51c89f1cd11 boost: d3f49c53809116a5d38da093a8aa78bf551aed09 BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872 - DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953 + DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 EXApplication: d8f53a7eee90a870a75656280e8d4b85726ea903 EXBarCodeScanner: 8e23fae8d267dbef9f04817833a494200f1fce35 EXCamera: 0fbfa338a3776af2722d626a3437abe33f708aad @@ -1577,7 +1577,7 @@ SPEC CHECKSUMS: FBLazyVector: 12ea01e587c9594e7b144e1bfc86ac4d9ac28fde FBReactNativeSpec: faca7d16c37626ca5780a87adef703817722fe61 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 - glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 + glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88 libaom: 144606b1da4b5915a1054383c3a4459ccdb3c661 libavif: 84bbb62fb232c3018d6f1bab79beea87e35de7b7 diff --git a/apps/wallet-mobile/package.json b/apps/wallet-mobile/package.json index f8c2b2f1d0..96fe79580d 100644 --- a/apps/wallet-mobile/package.json +++ b/apps/wallet-mobile/package.json @@ -127,7 +127,7 @@ "@types/pbkdf2": "^3.1.2", "@yoroi/api": "1.5.1", "@yoroi/common": "1.5.2", - "@yoroi/exchange": "2.0.1", + "@yoroi/exchange": "2.1.0", "@yoroi/explorers": "1.0.0", "@yoroi/links": "1.5.4", "@yoroi/portfolio": "1.0.0", diff --git a/apps/wallet-mobile/src/YoroiApp.tsx b/apps/wallet-mobile/src/YoroiApp.tsx index 1bc359cd7d..6346417967 100644 --- a/apps/wallet-mobile/src/YoroiApp.tsx +++ b/apps/wallet-mobile/src/YoroiApp.tsx @@ -18,7 +18,7 @@ import {SelectedWalletProvider} from './features/WalletManager/context/SelectedW import {SelectedWalletMetaProvider} from './features/WalletManager/context/SelectedWalletMetaContext' import {WalletManagerProvider} from './features/WalletManager/context/WalletManagerContext' import {InitApp} from './InitApp' -import {disableLogbox} from './kernel/env' +import {disableLogbox, loggerFilter} from './kernel/env' import {LanguageProvider} from './kernel/i18n' import {useSetupLogger} from './kernel/logger/hooks/useSetupLogger' import {makeMetricsManager, MetricsProvider} from './kernel/metrics/metricsManager' @@ -29,7 +29,11 @@ import {useThemeStorageMaker} from './yoroi-wallets/hooks' enableScreens(true) enableFreeze(true) -if (disableLogbox) LogBox.ignoreAllLogs() +if (disableLogbox) { + LogBox.ignoreAllLogs() +} else { + LogBox.ignoreLogs(['Require cycle:']) +} const queryClient = new QueryClient() const metricsManager = makeMetricsManager() @@ -74,7 +78,7 @@ const Yoroi = () => { } export const YoroiApp = () => { - const isReady = useSetupLogger() + const isReady = useSetupLogger(loggerFilter) if (!isReady) return null diff --git a/apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx b/apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx index 260e3a473d..883a0d464a 100644 --- a/apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx +++ b/apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx @@ -16,7 +16,7 @@ export type AmountItemProps = { wallet: YoroiWallet amount: Balance.Amount style?: ViewProps['style'] - isPrivacyOff?: boolean + isPrivacyActive?: boolean status?: string inWallet?: boolean variant?: 'swap' @@ -25,7 +25,7 @@ export type AmountItemProps = { } export const AmountItem = ({ - isPrivacyOff, + isPrivacyActive, wallet, style, amount, @@ -84,7 +84,7 @@ export const AmountItem = ({ {priceImpactRisk === 'high' && } - {isPrivacyOff ? '**.*******' : formattedQuantity} + {isPrivacyActive ? '**.*******' : formattedQuantity} )} diff --git a/apps/wallet-mobile/src/components/Button/Button.tsx b/apps/wallet-mobile/src/components/Button/Button.tsx index ae89e9347e..9ef9100302 100644 --- a/apps/wallet-mobile/src/components/Button/Button.tsx +++ b/apps/wallet-mobile/src/components/Button/Button.tsx @@ -19,6 +19,7 @@ export type ButtonProps = TouchableOpacityProps & { textStyles?: TextStyle isCopying?: boolean copiedText?: string + testId?: string } export const Button = (props: ButtonProps) => { @@ -38,13 +39,20 @@ export const Button = (props: ButtonProps) => { textStyles, isCopying, copiedText, + testId, ...rest } = props const {styles} = useStyles() return ( - + {isCopying && ( {copiedText} diff --git a/apps/wallet-mobile/src/components/HideableText/HideableText.tsx b/apps/wallet-mobile/src/components/HideableText/HideableText.tsx index 3749ca7f48..f3f716efe6 100644 --- a/apps/wallet-mobile/src/components/HideableText/HideableText.tsx +++ b/apps/wallet-mobile/src/components/HideableText/HideableText.tsx @@ -9,8 +9,8 @@ type Props = TextProps & { } export const HideableText = ({text, ...props}: Props) => { - const {isPrivacyOn} = usePrivacyMode() - const children = isPrivacyOn ? text : text?.replaceAll(/./g, '\u25CF') + const {isPrivacyActive} = usePrivacyMode() + const children = !isPrivacyActive ? text : text?.replaceAll(/./g, '\u25CF') return {children} } diff --git a/apps/wallet-mobile/src/components/PairedBalance/PairedBalance.tsx b/apps/wallet-mobile/src/components/PairedBalance/PairedBalance.tsx index 1626cf2ed1..e82e32db23 100644 --- a/apps/wallet-mobile/src/components/PairedBalance/PairedBalance.tsx +++ b/apps/wallet-mobile/src/components/PairedBalance/PairedBalance.tsx @@ -43,17 +43,17 @@ export const PairedBalance = React.forwardRef(({amount, te const Price = ({amount, textStyle, ignorePrivacy}: Props) => { const styles = useStyles() const wallet = useSelectedWallet() - const {isPrivacyOff, privacyPlaceholder} = usePrivacyMode() + const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode() const {currency, config} = useCurrencyContext() const rate = useExchangeRate({wallet, to: currency}) const price = React.useMemo(() => { if (rate == null) return `... ${currency}` - return isPrivacyOff || ignorePrivacy + return !isPrivacyActive || ignorePrivacy === true ? `${amountBreakdown(amount).bn.times(rate).toFormat(config.decimals)} ${currency}` : `${privacyPlaceholder} ${currency}` - }, [amount, config.decimals, currency, ignorePrivacy, isPrivacyOff, privacyPlaceholder, rate]) + }, [amount, config.decimals, currency, ignorePrivacy, isPrivacyActive, privacyPlaceholder, rate]) return ( diff --git a/apps/wallet-mobile/src/features/Exchange/common/useNavigateTo.tsx b/apps/wallet-mobile/src/features/Exchange/common/useNavigateTo.tsx index d725d7c6ee..ac52b02a1a 100644 --- a/apps/wallet-mobile/src/features/Exchange/common/useNavigateTo.tsx +++ b/apps/wallet-mobile/src/features/Exchange/common/useNavigateTo.tsx @@ -9,29 +9,5 @@ export const useNavigateTo = () => { return useRef({ exchangeSelectBuyProvider: () => navigation.navigate('exchange-select-buy-provider'), exchangeSelectSellProvider: () => navigation.navigate('exchange-select-sell-provider'), - exchangeOpenOrder: () => - navigation.reset({ - index: 0, - routes: [ - { - name: 'manage-wallets', - state: { - routes: [ - {name: 'wallet-selection'}, - { - name: 'main-wallet-routes', - state: { - routes: [ - { - name: 'history-list', - }, - ], - }, - }, - ], - }, - }, - ], - }), }).current } diff --git a/apps/wallet-mobile/src/features/Exchange/useCases/CreateExchangeOrderScreen/CreateExchangeOrderScreen.tsx b/apps/wallet-mobile/src/features/Exchange/useCases/CreateExchangeOrderScreen/CreateExchangeOrderScreen.tsx index 762deb2c02..dd0dae5a17 100644 --- a/apps/wallet-mobile/src/features/Exchange/useCases/CreateExchangeOrderScreen/CreateExchangeOrderScreen.tsx +++ b/apps/wallet-mobile/src/features/Exchange/useCases/CreateExchangeOrderScreen/CreateExchangeOrderScreen.tsx @@ -12,6 +12,7 @@ import {Space} from '../../../../components/Space/Space' import {Warning} from '../../../../components/Warning' import {banxaTestWallet} from '../../../../kernel/env' import {useMetrics} from '../../../../kernel/metrics/metricsManager' +import {useWalletNavigation} from '../../../../kernel/navigation' import {useTokenInfo} from '../../../../yoroi-wallets/hooks' import {Quantities} from '../../../../yoroi-wallets/utils' import {useSelectedWallet} from '../../../WalletManager/context/SelectedWalletContext' @@ -31,6 +32,7 @@ export const CreateExchangeOrderScreen = () => { const styles = useStyles() const {track} = useMetrics() const wallet = useSelectedWallet() + const walletNavigation = useWalletNavigation() const [contentHeight, setContentHeight] = React.useState(0) const navigateTo = useNavigateTo() @@ -88,7 +90,7 @@ export const CreateExchangeOrderScreen = () => { if (referralLink.toString() !== '') { Linking.openURL(referralLink.toString()) track.exchangeSubmitted({ramp_type: orderType === 'sell' ? 'Sell' : 'Buy', ada_amount: orderAmount}) - navigateTo.exchangeOpenOrder() + walletNavigation.navigateToTxHistory() } }, }, diff --git a/apps/wallet-mobile/src/features/Portfolio/common/TokenAmountItem/TokenAmountItem.tsx b/apps/wallet-mobile/src/features/Portfolio/common/TokenAmountItem/TokenAmountItem.tsx index 8823106ff8..59c15b3336 100644 --- a/apps/wallet-mobile/src/features/Portfolio/common/TokenAmountItem/TokenAmountItem.tsx +++ b/apps/wallet-mobile/src/features/Portfolio/common/TokenAmountItem/TokenAmountItem.tsx @@ -33,7 +33,7 @@ export const TokenAmountItem = ({ orderType, }: TokenAmountItemProps) => { const {styles, colors} = useStyles() - const {privacyPlaceholder, isPrivacyOff} = usePrivacyMode() + const {privacyPlaceholder, isPrivacyActive} = usePrivacyMode() const priceImpactRiskTheme = usePriceImpactRiskTheme(priceImpactRisk ?? 'none') const {info} = amount @@ -41,7 +41,7 @@ export const TokenAmountItem = ({ const detail = isPrimary ? info.description : info.fingerprint const name = infoExtractName(info) - const formattedQuantity = isPrivacyOff || ignorePrivacy ? amountFormatter()(amount) : privacyPlaceholder + const formattedQuantity = !isPrivacyActive && ignorePrivacy == true ? amountFormatter()(amount) : privacyPlaceholder const showSwapDetails = !isPrimary && variant === 'swap' const priceImpactRiskTextColor = orderType === 'market' ? priceImpactRiskTheme.text : colors.text diff --git a/apps/wallet-mobile/src/features/Settings/ApplicationSettings/ApplicationSettingsScreen.tsx b/apps/wallet-mobile/src/features/Settings/ApplicationSettings/ApplicationSettingsScreen.tsx index 39591e6c32..26a6bd4999 100644 --- a/apps/wallet-mobile/src/features/Settings/ApplicationSettings/ApplicationSettingsScreen.tsx +++ b/apps/wallet-mobile/src/features/Settings/ApplicationSettings/ApplicationSettingsScreen.tsx @@ -26,7 +26,7 @@ export const ApplicationSettingsScreen = () => { const {languageCode, supportedLanguages} = useLanguage() const language = supportedLanguages.find((lang) => lang.code === languageCode) ?? defaultLanguage - const {isTogglePrivacyModeLoading, isPrivacyOff} = usePrivacyMode() + const {isTogglePrivacyModeLoading, isPrivacyActive} = usePrivacyMode() const {currency} = useCurrencyContext() const {enabled: crashReportEnabled} = useCrashReports() @@ -119,7 +119,7 @@ export const ApplicationSettingsScreen = () => { label={strings.privacyMode} info={strings.privacyModeInfo} > - + { } // to avoid switch jumps -const PrivacyModeSwitch = ({isPrivacyOff}: {isPrivacyOff: boolean}) => { +const PrivacyModeSwitch = ({isPrivacyActive}: {isPrivacyActive: boolean}) => { const {setPrivacyModeOn, setPrivacyModeOff, isTogglePrivacyModeLoading} = usePrivacyMode() - const [isLocalPrivacyOff, setIsLocalPrivacyOff] = React.useState(isPrivacyOff) + const [isLocalPrivacyActive, setIsLocalPrivacyOff] = React.useState(isPrivacyActive) const onTogglePrivacyMode = () => { setIsLocalPrivacyOff((prevState) => { @@ -182,7 +182,7 @@ const PrivacyModeSwitch = ({isPrivacyOff}: {isPrivacyOff: boolean}) => { return ( diff --git a/apps/wallet-mobile/src/features/Settings/ManageCollateral/ManageCollateralScreen.tsx b/apps/wallet-mobile/src/features/Settings/ManageCollateral/ManageCollateralScreen.tsx index ef56fa645c..9cbd34ee1e 100644 --- a/apps/wallet-mobile/src/features/Settings/ManageCollateral/ManageCollateralScreen.tsx +++ b/apps/wallet-mobile/src/features/Settings/ManageCollateral/ManageCollateralScreen.tsx @@ -187,14 +187,14 @@ type ActionableAmountProps = { } const ActionableAmount = ({amount, onRemove, wallet, collateralId, disabled}: ActionableAmountProps) => { const {styles} = useStyles() - const {isPrivacyOff} = usePrivacyMode() + const {isPrivacyActive} = usePrivacyMode() const handleRemove = () => onRemove() return ( - + {collateralId !== '' && ( diff --git a/apps/wallet-mobile/src/features/Settings/PrivacyMode/PrivacyMode.tsx b/apps/wallet-mobile/src/features/Settings/PrivacyMode/PrivacyMode.tsx index c951ff1cba..bc20c3631c 100644 --- a/apps/wallet-mobile/src/features/Settings/PrivacyMode/PrivacyMode.tsx +++ b/apps/wallet-mobile/src/features/Settings/PrivacyMode/PrivacyMode.tsx @@ -62,8 +62,7 @@ export const usePrivacyMode = () => { const writePrivacyMode = useWritePrivacyMode() return { - isPrivacyOff: privacyMode === 'HIDDEN', - isPrivacyOn: privacyMode === 'SHOWN', + isPrivacyActive: privacyMode === 'HIDDEN', privacyMode, togglePrivacyMode, isTogglePrivacyModeLoading, diff --git a/apps/wallet-mobile/src/features/SetupWallet/SetupWalletNavigator.tsx b/apps/wallet-mobile/src/features/SetupWallet/SetupWalletNavigator.tsx index 6afdcacef2..eab1b3538a 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/SetupWalletNavigator.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/SetupWalletNavigator.tsx @@ -4,6 +4,7 @@ import * as React from 'react' import {defineMessages, useIntl} from 'react-intl' import {defaultStackNavigationOptions, WalletInitRoutes} from '../../kernel/navigation' +import {PreparingWalletScreen} from './common/PreparingWalletScreen/PreparingWalletScreen' import {CheckNanoXScreen} from './legacy/CheckNanoX/CheckNanoXScreen' import {ConnectNanoXScreen} from './legacy/ConnectNanoX/ConnectNanoXScreen' import {ImportReadOnlyWalletScreen} from './legacy/ImportReadOnlyWallet/ImportReadOnlyWalletScreen' @@ -134,6 +135,12 @@ export const SetupWalletNavigator = () => { component={VerifyRecoveryPhraseScreen} options={{title: strings.createWalletTitle}} /> + + ) } diff --git a/apps/wallet-mobile/src/features/SetupWallet/common/ButtonCard/ButtonCard.tsx b/apps/wallet-mobile/src/features/SetupWallet/common/ButtonCard/ButtonCard.tsx index 06d1598253..97aa10ce60 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/common/ButtonCard/ButtonCard.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/common/ButtonCard/ButtonCard.tsx @@ -10,9 +10,10 @@ type ButtonCardProps = { subTitle?: string icon?: React.ReactNode onPress: () => void + testId?: string } -export const ButtonCard = ({title, subTitle, icon = null, onPress}: ButtonCardProps) => { +export const ButtonCard = ({title, subTitle, icon = null, onPress, testId}: ButtonCardProps) => { const {styles, colors} = useStyles() return ( @@ -20,6 +21,7 @@ export const ButtonCard = ({title, subTitle, icon = null, onPress}: ButtonCardPr activeOpacity={0.5} style={[styles.container, icon !== null && styles.justifySpaceBetween]} onPress={onPress} + testID={testId} > { const {styles, colors} = useStyles(includeSpacing, showBackgroundColor) @@ -38,7 +40,9 @@ export const CardAboutPhrase = ({ {title !== undefined && ( <> - {title} + + {title} + diff --git a/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWallet/PreparingWallet.tsx b/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWallet/PreparingWallet.tsx deleted file mode 100644 index 8d5b09a75f..0000000000 --- a/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWallet/PreparingWallet.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import {useTheme} from '@yoroi/theme' -import * as React from 'react' -import {StyleSheet, Text, View} from 'react-native' - -import {useStrings} from '../useStrings' - -export const PreparingWallet = () => { - const strings = useStrings() - const {styles} = useStyles() - - return ( - - {strings.preparingWallet} - - ) -} - -const useStyles = () => { - const {atoms, color} = useTheme() - const styles = StyleSheet.create({ - root: { - flex: 1, - alignItems: 'center', - justifyContent: 'center', - }, - title: { - color: color.primary_c500, - textAlign: 'center', - ...atoms.heading_2_medium, - }, - }) - - return {styles} as const -} diff --git a/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWallet/PreparingWallet.stories.tsx b/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWalletScreen/PreparingWalletScreen.stories.tsx similarity index 74% rename from apps/wallet-mobile/src/features/SetupWallet/common/PreparingWallet/PreparingWallet.stories.tsx rename to apps/wallet-mobile/src/features/SetupWallet/common/PreparingWalletScreen/PreparingWalletScreen.stories.tsx index 7f59e3acdd..93fc7f8ee3 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWallet/PreparingWallet.stories.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWalletScreen/PreparingWalletScreen.stories.tsx @@ -2,11 +2,11 @@ import {storiesOf} from '@storybook/react-native' import React from 'react' import {StyleSheet, View} from 'react-native' -import {PreparingWallet} from './PreparingWallet' +import {PreparingWalletScreen} from './PreparingWalletScreen' storiesOf('AddWallet PreparingWallet', module) .addDecorator((story) => {story()}) - .add('initial', () => ) + .add('initial', () => ) const styles = StyleSheet.create({ container: { diff --git a/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWalletScreen/PreparingWalletScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWalletScreen/PreparingWalletScreen.tsx new file mode 100644 index 0000000000..60d7808868 --- /dev/null +++ b/apps/wallet-mobile/src/features/SetupWallet/common/PreparingWalletScreen/PreparingWalletScreen.tsx @@ -0,0 +1,52 @@ +import {useSetupWallet} from '@yoroi/setup-wallet' +import {useTheme} from '@yoroi/theme' +import * as React from 'react' +import {StyleSheet, Text} from 'react-native' +import {SafeAreaView} from 'react-native-safe-area-context' + +import {logger} from '../../../../kernel/logger/logger' +import {isEmptyString} from '../../../../kernel/utils' +import {useLaunchWalletAfterSyncing} from '../../../WalletManager/common/useLaunchWalletAfterSyncing' +import {useSyncTemporarilyPaused} from '../../../WalletManager/common/useSyncTemporarilyPaused' +import {useStrings} from '../useStrings' + +/** + * It requests the global syncing to stop on mounting to favor the sync of a specific wallet + * and resume the global syncing after the wallet is sync and the screen is unmounted. + */ +export const PreparingWalletScreen = () => { + const strings = useStrings() + const {styles} = useStyles() + const {walletId} = useSetupWallet() + const isGlobalSyncPaused = useSyncTemporarilyPaused() + useLaunchWalletAfterSyncing({isGlobalSyncPaused, walletId}) + + if (isEmptyString(walletId)) { + const error = new Error('PreparingWalletScreen: walletId is empty, reached an invalid state.') + logger.error(error) + throw error + } + + return ( + + {strings.preparingWallet} + + ) +} + +const useStyles = () => { + const {atoms, color} = useTheme() + const styles = StyleSheet.create({ + root: { + ...atoms.flex_1, + ...atoms.align_center, + ...atoms.justify_center, + }, + title: { + color: color.primary_c500, + ...atoms.text_center, + ...atoms.heading_2_medium, + }, + }) + return {styles} as const +} diff --git a/apps/wallet-mobile/src/features/SetupWallet/legacy/CheckNanoX/CheckNanoXScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/legacy/CheckNanoX/CheckNanoXScreen.tsx index ded8afe055..a1826069a0 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/legacy/CheckNanoX/CheckNanoXScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/legacy/CheckNanoX/CheckNanoXScreen.tsx @@ -9,13 +9,13 @@ import {SafeAreaView} from 'react-native-safe-area-context' import image from '../../../../assets/img/ledger_1.png' import {BulletPointItem, Button, ProgressStep, Spacer, Text} from '../../../../components' import {confirmationMessages, ledgerMessages} from '../../../../kernel/i18n/global-messages' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' export const CheckNanoXScreen = () => { const strings = useStrings() const styles = useStyles() - const navigation = useNavigation() + const navigation = useNavigation() const onContinue = () => navigation.navigate('setup-wallet-connect-nano-x') const {useUSB} = useSetupWallet() diff --git a/apps/wallet-mobile/src/features/SetupWallet/legacy/ConnectNanoX/ConnectNanoXScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/legacy/ConnectNanoX/ConnectNanoXScreen.tsx index e0e9e6c134..b918b36101 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/legacy/ConnectNanoX/ConnectNanoXScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/legacy/ConnectNanoX/ConnectNanoXScreen.tsx @@ -10,7 +10,7 @@ import {ProgressStep} from '../../../../components' import {showErrorDialog} from '../../../../kernel/dialogs' import {errorMessages} from '../../../../kernel/i18n/global-messages' import LocalizableError from '../../../../kernel/i18n/LocalizableError' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {LedgerConnect} from '../../../../legacy/HW' import {getHWDeviceInfo} from '../../../../yoroi-wallets/cardano/hw' import {DeviceId, DeviceObj, HWDeviceInfo} from '../../../../yoroi-wallets/hw' @@ -30,7 +30,7 @@ export const ConnectNanoXScreen = ({defaultDevices}: Props) => { const intl = useIntl() const strings = useStrings() const styles = useStyles() - const navigation = useNavigation() + const navigation = useNavigation() const {hwDeviceInfoChanged, walletImplementationId, useUSB} = useSetupWallet() diff --git a/apps/wallet-mobile/src/features/SetupWallet/legacy/ImportReadOnlyWallet/ImportReadOnlyWalletScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/legacy/ImportReadOnlyWallet/ImportReadOnlyWalletScreen.tsx index 1c09f29db7..fefbf46dd6 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/legacy/ImportReadOnlyWallet/ImportReadOnlyWalletScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/legacy/ImportReadOnlyWallet/ImportReadOnlyWalletScreen.tsx @@ -8,13 +8,13 @@ import {BulletPointItem, CameraCodeScanner, Spacer, Text} from '../../../../comp import {showErrorDialog} from '../../../../kernel/dialogs' import {errorMessages} from '../../../../kernel/i18n/global-messages' import {logger} from '../../../../kernel/logger/logger' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {isCIP1852AccountPath, isValidPublicKey} from '../../../../yoroi-wallets/cardano/bip44Validators' export const ImportReadOnlyWalletScreen = () => { const intl = useIntl() const strings = useStrings() - const navigation = useNavigation() + const navigation = useNavigation() const {publicKeyHexChanged, pathChanged} = useSetupWallet() const onRead = async (event: {data: string}): Promise => { diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseMnemonicType/ChooseMnemonicTypeScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseMnemonicType/ChooseMnemonicTypeScreen.tsx index b976f5f30f..32871d0de8 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseMnemonicType/ChooseMnemonicTypeScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseMnemonicType/ChooseMnemonicTypeScreen.tsx @@ -7,7 +7,7 @@ import {SafeAreaView} from 'react-native-safe-area-context' import {Space} from '../../../../components/Space/Space' import {useMetrics} from '../../../../kernel/metrics/metricsManager' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {ButtonCard} from '../../common/ButtonCard/ButtonCard' import {LogoBanner} from '../../common/LogoBanner/LogoBanner' import {useStrings} from '../../common/useStrings' @@ -20,7 +20,7 @@ export const ChooseMnemonicTypeScreen = () => { const {mnemonicTypeChanged} = useSetupWallet() const {track} = useMetrics() - const navigation = useNavigation() + const navigation = useNavigation() const handle15Words = () => { mnemonicTypeChanged(15) @@ -51,6 +51,7 @@ export const ChooseMnemonicTypeScreen = () => { title={strings.choose15WordsMnemonicTitle} icon={} onPress={handle15Words} + testId="mnemonic-15-word" /> @@ -59,6 +60,7 @@ export const ChooseMnemonicTypeScreen = () => { title={strings.choose24WordsMnemonicTitle} icon={} onPress={handle24Words} + testId="mnemonic-24-word" /> diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseNetwork/ChooseNetworkScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseNetwork/ChooseNetworkScreen.tsx index bcd10eff6f..515dbce653 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseNetwork/ChooseNetworkScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseNetwork/ChooseNetworkScreen.tsx @@ -6,7 +6,7 @@ import {ScrollView, StyleSheet, View} from 'react-native' import {SafeAreaView} from 'react-native-safe-area-context' import {Space} from '../../../../components/Space/Space' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import * as HASKELL_SHELLEY from '../../../../yoroi-wallets/cardano/constants/mainnet/constants' import * as SANCHONET from '../../../../yoroi-wallets/cardano/constants/sanchonet/constants' import * as HASKELL_SHELLEY_TESTNET from '../../../../yoroi-wallets/cardano/constants/testnet/constants' @@ -49,6 +49,7 @@ export const ChooseNetworkScreen = () => { title={strings.cardanoMainnet} subTitle={strings.cardanoMainnetDescription} onPress={handleMainnet} + testId="setup-network-select-mainnet-button" /> @@ -57,6 +58,7 @@ export const ChooseNetworkScreen = () => { title={strings.cardanoTestnet} subTitle={strings.cardanoTestnetDescription} onPress={handleTestnet} + testId="setup-network-select-testnet-button" /> @@ -65,6 +67,7 @@ export const ChooseNetworkScreen = () => { title={strings.cardanoSanchonet} subTitle={strings.cardanoSanchonetDescription} onPress={handleSanchonet} + testId="setup-network-select-sanchonet-button" /> @@ -91,7 +94,7 @@ const useNavigate = () => { } export const useNavigateTo = () => { - const navigation = useNavigation() + const navigation = useNavigation() return React.useRef({ create: () => navigation.navigate('setup-wallet-about-recovery-phase'), 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 31d9f2f909..40c85ad2bb 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseSetupType/ChooseSetupTypeScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/ChooseSetupType/ChooseSetupTypeScreen.tsx @@ -8,7 +8,7 @@ import {SafeAreaView} from 'react-native-safe-area-context' import {Space} from '../../../../components/Space/Space' import {isProduction} from '../../../../kernel/env' import {useMetrics} from '../../../../kernel/metrics/metricsManager' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {LedgerTransportSwitchModal} from '../../../../legacy/HW' import * as HASKELL_SHELLEY from '../../../../yoroi-wallets/cardano/constants/mainnet/constants' import {ButtonCard} from '../../common/ButtonCard/ButtonCard' @@ -36,7 +36,7 @@ export const ChooseSetupTypeScreen = () => { }, [track]), ) - const navigation = useNavigation() + const navigation = useNavigation() const handleCreate = () => { walletImplementationIdChanged(HASKELL_SHELLEY.WALLET_IMPLEMENTATION_ID) @@ -99,6 +99,7 @@ export const ChooseSetupTypeScreen = () => { title={strings.createWalletButtonCard} icon={} onPress={handleCreate} + testId="setup-create-new-wallet-button" /> @@ -107,6 +108,7 @@ export const ChooseSetupTypeScreen = () => { title={strings.restoreWalletButtonCard} icon={} onPress={handleRestore} + testId="setup-restore-wallet-button" /> @@ -115,6 +117,7 @@ export const ChooseSetupTypeScreen = () => { title={strings.connectWalletButtonCard} icon={} onPress={handleHw} + testId="setup-connect-HW-wallet-button" /> diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/AboutRecoveryPhraseScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/AboutRecoveryPhraseScreen.tsx index 0abc4bf99d..3b7fc78643 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/AboutRecoveryPhraseScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/AboutRecoveryPhraseScreen.tsx @@ -8,7 +8,7 @@ import {ViewProps} from 'react-native-svg/lib/typescript/fabric/utils' import {Button, Spacer} from '../../../../components' import {Space} from '../../../../components/Space/Space' import {useMetrics} from '../../../../kernel/metrics/metricsManager' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {CardAboutPhrase} from '../../common/CardAboutPhrase/CardAboutPhrase' import {YoroiZendeskLink} from '../../common/constants' import {LearnMoreButton} from '../../common/LearnMoreButton/LearnMoreButton' @@ -19,7 +19,7 @@ export const AboutRecoveryPhraseScreen = () => { const bold = useBold() const {styles} = useStyles() const strings = useStrings() - const navigation = useNavigation() + const navigation = useNavigation() const {track} = useMetrics() useFocusEffect( @@ -68,6 +68,7 @@ export const AboutRecoveryPhraseScreen = () => { title={strings.next} style={styles.button} onPress={() => navigation.navigate('setup-wallet-recovery-phrase-mnemonic')} + testID="setup-step1-next-button" /> diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/RecoveryPhraseScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/RecoveryPhraseScreen.tsx index 41f82ae5d3..5d82fe49b3 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/RecoveryPhraseScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/RecoveryPhraseScreen.tsx @@ -10,7 +10,7 @@ import {SafeAreaView} from 'react-native-safe-area-context' import {Button, Spacer, useModal} from '../../../../components' import {Space} from '../../../../components/Space/Space' import {useMetrics} from '../../../../kernel/metrics/metricsManager' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {generateAdaMnemonic} from '../../../../yoroi-wallets/cardano/mnemonic' import {CardAboutPhrase} from '../../common/CardAboutPhrase/CardAboutPhrase' import {YoroiZendeskLink} from '../../common/constants' @@ -25,7 +25,7 @@ export const RecoveryPhraseScreen = () => { const {styles, colors} = useStyles() const {openModal, closeModal} = useModal() const [isBlur, setIsBlur] = React.useState(true) - const navigation = useNavigation() + const navigation = useNavigation() const strings = useStrings() const {mnemonicChanged, showCreateWalletInfoModal, showCreateWalletInfoModalChanged} = useSetupWallet() const {track} = useMetrics() @@ -71,6 +71,7 @@ export const RecoveryPhraseScreen = () => { closeModal() showCreateWalletInfoModalChanged(false) }} + testId="setup-step2-continue-button" /> @@ -106,7 +107,7 @@ export const RecoveryPhraseScreen = () => { {strings.recoveryPhraseTitle(bold)} - + @@ -134,7 +135,12 @@ export const RecoveryPhraseScreen = () => { ))} - setIsBlur(!isBlur)}> + setIsBlur(!isBlur)} + testID="step2-show_hide-recovery-phrase-button" + > {isBlur ? : } @@ -153,6 +159,7 @@ export const RecoveryPhraseScreen = () => { mnemonicChanged(mnemonic) navigation.navigate('setup-wallet-verify-recovery-phrase-mnemonic') }} + testId="setup-step2-next-button" /> @@ -160,11 +167,11 @@ export const RecoveryPhraseScreen = () => { ) } -const Info = ({onPress}: {onPress: () => void}) => { +const Info = ({onPress, testId}: {onPress: () => void; testId?: string}) => { const {styles} = useStyles() return ( - + diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/VerifyRecoveryPhraseScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/VerifyRecoveryPhraseScreen.tsx index 8ab279e42a..32a0d8c2c4 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/VerifyRecoveryPhraseScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/VerifyRecoveryPhraseScreen.tsx @@ -11,7 +11,7 @@ import {SafeAreaView} from 'react-native-safe-area-context' import {Button} from '../../../../components' import {Space} from '../../../../components/Space/Space' import {useMetrics} from '../../../../kernel/metrics/metricsManager' -import {WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {makeKeys} from '../../../../yoroi-wallets/cardano/shelley/makeKeys' import {StepperProgress} from '../../common/StepperProgress/StepperProgress' import {useStrings} from '../../common/useStrings' @@ -21,7 +21,7 @@ import {Check2 as Check2Illustration} from '../../illustrations/Check2' export const VerifyRecoveryPhraseScreen = () => { const {styles} = useStyles() const bold = useBold() - const navigation = useNavigation() + const navigation = useNavigation() const strings = useStrings() const {mnemonic, publicKeyHexChanged} = useSetupWallet() const {track} = useMetrics() @@ -122,6 +122,7 @@ export const VerifyRecoveryPhraseScreen = () => { publicKeyHexChanged(accountPubKeyHex) navigation.navigate('setup-wallet-details-form') }} + testId="setup-next-button" /> 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 8b8ec711bc..0f23c232ea 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/WalletDetailsScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/CreateWallet/WalletDetailsScreen.tsx @@ -1,4 +1,4 @@ -import {useFocusEffect} from '@react-navigation/native' +import {useFocusEffect, useNavigation} from '@react-navigation/native' import {useAsyncStorage} from '@yoroi/common' import {useSetupWallet} from '@yoroi/setup-wallet' import {useTheme} from '@yoroi/theme' @@ -23,8 +23,9 @@ import {Button, Icon, KeyboardAvoidingView, TextInput, useModal} from '../../../ import {Space} from '../../../../components/Space/Space' import {showErrorDialog} from '../../../../kernel/dialogs' import {errorMessages} from '../../../../kernel/i18n/global-messages' +import {logger} from '../../../../kernel/logger/logger' import {useMetrics} from '../../../../kernel/metrics/metricsManager' -import {useWalletNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {isEmptyString} from '../../../../kernel/utils' import {useCreateWallet, usePlate, useWalletNames} from '../../../../yoroi-wallets/hooks' import {WalletImplementationId} from '../../../../yoroi-wallets/types' @@ -41,7 +42,6 @@ import {useWalletManager} from '../../../WalletManager/context/WalletManagerCont import {CardAboutPhrase} from '../../common/CardAboutPhrase/CardAboutPhrase' import {YoroiZendeskLink} from '../../common/constants' import {LearnMoreButton} from '../../common/LearnMoreButton/LearnMoreButton' -import {PreparingWallet} from '../../common/PreparingWallet/PreparingWallet' import {StepperProgress} from '../../common/StepperProgress/StepperProgress' import {useStrings} from '../../common/useStrings' import {Info as InfoIcon} from '../../illustrations/Info' @@ -63,15 +63,15 @@ const useSizeModal = () => { // when restoring, later will be part of the onboarding const addressMode: AddressMode = 'single' export const WalletDetailsScreen = () => { - const bold = useBold() + const navigation = useNavigation() + const strings = useStrings() const {styles} = useStyles() + const {track} = useMetrics() + const bold = useBold() const {HEIGHT_MODAL_NAME_PASSWORD, HEIGHT_MODAL_CHECKSUM} = useSizeModal() const {openModal, closeModal} = useModal() - const {resetToTxHistory} = useWalletNavigation() - const strings = useStrings() const walletManager = useWalletManager() const {walletNames} = useWalletNames(walletManager) - const {track} = useMetrics() const intl = useIntl() const storage = useAsyncStorage() const { @@ -81,6 +81,7 @@ export const WalletDetailsScreen = () => { walletImplementationId, showRestoreWalletInfoModal, showRestoreWalletInfoModalChanged, + walletIdChanged, } = useSetupWallet() const plate = usePlate({networkId, publicKeyHex}) const [name, setName] = React.useState(features.prefillWalletInfo ? debugWalletInfo.WALLET_NAME : '') @@ -111,15 +112,19 @@ export const WalletDetailsScreen = () => { isSuccess: isCreateWalletSuccess, } = useCreateWallet({ onSuccess: async (wallet) => { + walletIdChanged(wallet.id) const walletStorage = storage.join('wallet/') const walletMeta = await walletStorage.getItem(wallet.id, parseWalletMeta) - if (!walletMeta) throw new Error('invalid wallet meta') + if (!walletMeta) { + const error = new Error('WalletDetailsScreen: wallet meta is invalid, reached an invalid state.') + logger.error(error) + throw error + } track.createWalletDetailsSettled() - // TODO: revisit needs to open the new wallet - should wait for done sync event from manager - resetToTxHistory() + navigation.navigate('setup-wallet-preparing-wallet') }, onError: (error) => { InteractionManager.runAfterInteractions(() => { @@ -186,6 +191,7 @@ export const WalletDetailsScreen = () => { closeModal() showRestoreWalletInfoModalChanged(false) }} + testId="setup-modal-continue-button" /> @@ -251,8 +257,6 @@ export const WalletDetailsScreen = () => { ) } - if (isLoading) return - return ( @@ -347,6 +351,7 @@ export const WalletDetailsScreen = () => { style={styles.button} onPress={() => handleCreateWallet()} disabled={isLoading || Object.keys(passwordErrors).length > 0 || Object.keys(nameErrors).length > 0} + testID="walletFormContinueButton" /> diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/MnemonicInput/MnemonicInput.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/MnemonicInput/MnemonicInput.tsx index 6504faaeff..df92eddaf3 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/MnemonicInput/MnemonicInput.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/MnemonicInput/MnemonicInput.tsx @@ -89,6 +89,7 @@ export const MnemonicInput = ({ mnenonicRefs.forEach((ref) => ref.current?.selectWord('')) mnenonicRefs[0].current?.focus() }} + testId="clearAll-button" /> )} @@ -97,11 +98,11 @@ export const MnemonicInput = ({ ) } -const ClearAllButton = ({onPress}: {onPress: () => void}) => { +const ClearAllButton = ({onPress, testId}: {onPress: () => void; testId?: string}) => { const {styles} = useStyles() const strings = useStrings() return ( - + {strings.clearAll} 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 2659c2d5ff..9ea8ab3d9d 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletDetailsScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletDetailsScreen.tsx @@ -1,4 +1,4 @@ -import {useFocusEffect} from '@react-navigation/native' +import {useFocusEffect, useNavigation} from '@react-navigation/native' import {useAsyncStorage} from '@yoroi/common' import {useSetupWallet} from '@yoroi/setup-wallet' import {useTheme} from '@yoroi/theme' @@ -22,8 +22,9 @@ import {Button, Icon, KeyboardAvoidingView, TextInput, useModal} from '../../../ import {Space} from '../../../../components/Space/Space' import {showErrorDialog} from '../../../../kernel/dialogs' import {errorMessages} from '../../../../kernel/i18n/global-messages' +import {logger} from '../../../../kernel/logger/logger' import {useMetrics} from '../../../../kernel/metrics/metricsManager' -import {useWalletNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation} from '../../../../kernel/navigation' import {isEmptyString} from '../../../../kernel/utils' import {useCreateWallet, usePlate, useWalletNames} from '../../../../yoroi-wallets/hooks' import {WalletImplementationId} from '../../../../yoroi-wallets/types' @@ -40,7 +41,6 @@ import {useWalletManager} from '../../../WalletManager/context/WalletManagerCont import {CardAboutPhrase} from '../../common/CardAboutPhrase/CardAboutPhrase' import {YoroiZendeskLink} from '../../common/constants' import {LearnMoreButton} from '../../common/LearnMoreButton/LearnMoreButton' -import {PreparingWallet} from '../../common/PreparingWallet/PreparingWallet' import {StepperProgress} from '../../common/StepperProgress/StepperProgress' import {useStrings} from '../../common/useStrings' import {Info as InfoIcon} from '../../illustrations/Info' @@ -62,18 +62,18 @@ const useSizeModal = () => { // when restoring, later will be part of the onboarding const addressMode: AddressMode = 'single' export const RestoreWalletDetailsScreen = () => { - const bold = useBold() + const navigation = useNavigation() + const strings = useStrings() const {styles} = useStyles() + const {track} = useMetrics() + const bold = useBold() const {HEIGHT_MODAL_NAME_PASSWORD, HEIGHT_MODAL_CHECKSUM} = useSizeModal() const {openModal, closeModal} = useModal() - const strings = useStrings() - const {resetToTxHistory} = useWalletNavigation() const walletManager = useWalletManager() - const {track} = useMetrics() const {walletNames} = useWalletNames(walletManager) const [name, setName] = React.useState(features.prefillWalletInfo ? debugWalletInfo.WALLET_NAME : '') const storage = useAsyncStorage() - const {mnemonic, networkId, publicKeyHex, walletImplementationId} = useSetupWallet() + const {mnemonic, networkId, publicKeyHex, walletImplementationId, walletIdChanged} = useSetupWallet() const plate = usePlate({networkId, publicKeyHex}) const passwordRef = React.useRef(null) @@ -99,14 +99,19 @@ export const RestoreWalletDetailsScreen = () => { isSuccess: isCreateWalletSuccess, } = useCreateWallet({ onSuccess: async (wallet) => { + walletIdChanged(wallet.id) const walletStorage = storage.join('wallet/') const walletMeta = await walletStorage.getItem(wallet.id, parseWalletMeta) - if (!walletMeta) throw new Error('invalid wallet meta') + if (!walletMeta) { + const error = new Error('RestoreWalletDetailsScreen: wallet meta is invalid, reached an invalid state.') + logger.error(error) + throw error + } track.restoreWalletDetailsSettled() - // TODO: revist should open the wallet and navigate to it - resetToTxHistory() + + navigation.navigate('setup-wallet-preparing-wallet') }, onError: (error) => { InteractionManager.runAfterInteractions(() => { @@ -123,8 +128,6 @@ export const RestoreWalletDetailsScreen = () => { }, [track]), ) - if (isLoading) return - const nameErrors = validateWalletName(name, null, walletNames && !isCreateWalletSuccess ? walletNames : []) const walletNameErrorText = getWalletNameError( {tooLong: strings.tooLong, nameAlreadyTaken: strings.nameAlreadyTaken, mustBeFilled: strings.mustBeFilled}, @@ -285,7 +288,9 @@ export const RestoreWalletDetailsScreen = () => { - {plate.accountPlate.TextPart} + + {plate.accountPlate.TextPart} + @@ -307,6 +312,7 @@ export const RestoreWalletDetailsScreen = () => { addressMode, }) } + testId="setup-restore-step2-next-button" disabled={isLoading || Object.keys(passwordErrors).length > 0 || Object.keys(nameErrors).length > 0} /> diff --git a/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletScreen.tsx b/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletScreen.tsx index f427d52499..797d03dbf3 100644 --- a/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletScreen.tsx +++ b/apps/wallet-mobile/src/features/SetupWallet/useCases/RestoreWallet/RestoreWalletScreen.tsx @@ -11,7 +11,7 @@ import {SafeAreaView} from 'react-native-safe-area-context' import {Button, Icon, KeyboardAvoidingView, useModal} from '../../../../components' import {Space} from '../../../../components/Space/Space' import {useMetrics} from '../../../../kernel/metrics/metricsManager' -import {useWalletNavigation, WalletInitRouteNavigation} from '../../../../kernel/navigation' +import {SetupWalletRouteNavigation, useWalletNavigation} from '../../../../kernel/navigation' import {isEmptyString} from '../../../../kernel/utils' import {makeKeys} from '../../../../yoroi-wallets/cardano/shelley/makeKeys' import {usePlate, useWalletMetas} from '../../../../yoroi-wallets/hooks' @@ -33,13 +33,13 @@ export const RestoreWalletScreen = () => { const strings = useStrings() const bold = useBold() const [mnemonic, setMnemonic] = React.useState('') - const navigation = useNavigation() + const navigation = useNavigation() const {publicKeyHexChanged, mnemonicChanged, mnemonicType} = useSetupWallet() const {track} = useMetrics() const walletManager = useWalletManager() const {walletMetas} = useWalletMetas(walletManager) const {openModal} = useModal() - const {navigateToTxHistory} = useWalletNavigation() + const {resetToTxHistory} = useWalletNavigation() const selectWalletMeta = useSetSelectedWalletMeta() const selectWallet = useSetSelectedWallet() const [focusedIndex, setFocusedIndex] = React.useState(0) @@ -120,9 +120,9 @@ export const RestoreWalletScreen = () => { const wallet = walletManager.getOpenedWalletById(walletMeta.id) selectWallet(wallet) walletManager.setSelectedWalletId(walletMeta.id) - navigateToTxHistory() + resetToTxHistory() }, - [selectWalletMeta, walletManager, selectWallet, navigateToTxHistory], + [selectWalletMeta, walletManager, selectWallet, resetToTxHistory], ) const handleOnNext = React.useCallback(async () => { @@ -212,7 +212,7 @@ const NextButton = ({onPress}: {onPress: () => void}) => { return ( -