Skip to content

Commit

Permalink
fix(wallet-mobile): wallet open after create/restore
Browse files Browse the repository at this point in the history
  • Loading branch information
stackchain committed May 29, 2024
1 parent 89ea130 commit f6a108d
Show file tree
Hide file tree
Showing 41 changed files with 423 additions and 233 deletions.
4 changes: 3 additions & 1 deletion apps/wallet-mobile/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ COMMIT=093dec95a
BUILD_VARIANT=STAGING
SENTRY_DSN=https://[email protected]/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
Expand All @@ -20,3 +20,5 @@ FRONTEND_FEE_ADDRESS_MAINNET=addr1q9ry6jfdgm0lcrtfpgwrgxg7qfahv80jlghhrthy6w8hmy
FRONTEND_FEE_ADDRESS_PREPROD=addr_test1qrgpjmyy8zk9nuza24a0f4e7mgp9gd6h3uayp0rqnjnkl54v4dlyj0kwfs0x4e38a7047lymzp37tx0y42glslcdtzhqzp57km

UNSTOPPABLE_API_KEY=czsajliz-wxgu6tujd1zqq7hey_pclfqhdjsqolsxjfsurgh

LOGGER_FILTER=
2 changes: 1 addition & 1 deletion apps/wallet-mobile/.storybook/storybook.requires.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions apps/wallet-mobile/src/YoroiApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down Expand Up @@ -74,7 +78,7 @@ const Yoroi = () => {
}

export const YoroiApp = () => {
const isReady = useSetupLogger()
const isReady = useSetupLogger(loggerFilter)

if (!isReady) return null

Expand Down
24 changes: 0 additions & 24 deletions apps/wallet-mobile/src/features/Exchange/common/useNavigateTo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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()
Expand Down Expand Up @@ -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()
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -134,6 +135,12 @@ export const SetupWalletNavigator = () => {
component={VerifyRecoveryPhraseScreen}
options={{title: strings.createWalletTitle}}
/>

<Stack.Screen
name="setup-wallet-preparing-wallet"
component={PreparingWalletScreen}
options={{headerShown: false}}
/>
</Stack.Navigator>
)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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) => <View style={styles.container}>{story()}</View>)
.add('initial', () => <PreparingWallet />)
.add('initial', () => <PreparingWalletScreen />)

const styles = StyleSheet.create({
container: {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<SafeAreaView edges={['left', 'right', 'bottom', 'top']} style={styles.root}>
<Text style={styles.title}>{strings.preparingWallet}</Text>
</SafeAreaView>
)
}

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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()
const onContinue = () => navigation.navigate('setup-wallet-connect-nano-x')
const {useUSB} = useSetupWallet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -30,7 +30,7 @@ export const ConnectNanoXScreen = ({defaultDevices}: Props) => {
const intl = useIntl()
const strings = useStrings()
const styles = useStyles()
const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()

const {hwDeviceInfoChanged, walletImplementationId, useUSB} = useSetupWallet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()
const {publicKeyHexChanged, pathChanged} = useSetupWallet()

const onRead = async (event: {data: string}): Promise<boolean> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -20,7 +20,7 @@ export const ChooseMnemonicTypeScreen = () => {
const {mnemonicTypeChanged} = useSetupWallet()
const {track} = useMetrics()

const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()

const handle15Words = () => {
mnemonicTypeChanged(15)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -91,7 +91,7 @@ const useNavigate = () => {
}

export const useNavigateTo = () => {
const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()

return React.useRef({
create: () => navigation.navigate('setup-wallet-about-recovery-phase'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -36,7 +36,7 @@ export const ChooseSetupTypeScreen = () => {
}, [track]),
)

const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()

const handleCreate = () => {
walletImplementationIdChanged(HASKELL_SHELLEY.WALLET_IMPLEMENTATION_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -19,7 +19,7 @@ export const AboutRecoveryPhraseScreen = () => {
const bold = useBold()
const {styles} = useStyles()
const strings = useStrings()
const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()
const {track} = useMetrics()

useFocusEffect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -25,7 +25,7 @@ export const RecoveryPhraseScreen = () => {
const {styles, colors} = useStyles()
const {openModal, closeModal} = useModal()
const [isBlur, setIsBlur] = React.useState(true)
const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()
const strings = useStrings()
const {mnemonicChanged, showCreateWalletInfoModal, showCreateWalletInfoModalChanged} = useSetupWallet()
const {track} = useMetrics()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -21,7 +21,7 @@ import {Check2 as Check2Illustration} from '../../illustrations/Check2'
export const VerifyRecoveryPhraseScreen = () => {
const {styles} = useStyles()
const bold = useBold()
const navigation = useNavigation<WalletInitRouteNavigation>()
const navigation = useNavigation<SetupWalletRouteNavigation>()
const strings = useStrings()
const {mnemonic, publicKeyHexChanged} = useSetupWallet()
const {track} = useMetrics()
Expand Down
Loading

0 comments on commit f6a108d

Please sign in to comment.