diff --git a/src/hooks/useInitializeWallet.ts b/src/hooks/useInitializeWallet.ts index 68d8a8a7031..93b161f6265 100644 --- a/src/hooks/useInitializeWallet.ts +++ b/src/hooks/useInitializeWallet.ts @@ -24,7 +24,7 @@ import { WrappedAlert as Alert } from '@/helpers/alert'; import { PROFILES, useExperimentalFlag } from '@/config'; import { runKeychainIntegrityChecks } from '@/handlers/walletReadyEvents'; import { checkPendingTransactionsOnInitialize } from '@/redux/data'; -import { logger } from '@/logger'; +import { RainbowError, logger } from '@/logger'; export default function useInitializeWallet() { const dispatch = useDispatch(); @@ -71,17 +71,17 @@ export default function useInitializeWallet() { ); logger.log('Start wallet setup'); await resetAccountState(); - logger.log('resetAccountState ran ok'); + logger.debug('resetAccountState ran ok'); const isImporting = !!seedPhrase; - logger.log(`isImporting? ${isImporting}`); + logger.debug('isImporting? ' + isImporting); if (shouldRunMigrations && !seedPhrase) { - logger.log('shouldRunMigrations && !seedPhrase? => true'); + logger.debug('shouldRunMigrations && !seedPhrase? => true'); await dispatch(walletsLoadState(profilesEnabled)); - logger.log('walletsLoadState call #1'); + logger.debug('walletsLoadState call #1'); await runMigrations(); - logger.log('done with migrations'); + logger.debug('done with migrations'); } setIsSmallBalancesOpen(false); @@ -100,7 +100,7 @@ export default function useInitializeWallet() { silent ); - logger.log('walletInit returned', { + logger.debug('walletInit returned', { isNew, walletAddress, }); @@ -112,12 +112,12 @@ export default function useInitializeWallet() { } if (seedPhrase || isNew) { - logger.log('walletLoadState call #2'); + logger.debug('walletLoadState call #2'); await dispatch(walletsLoadState(profilesEnabled)); } if (isNil(walletAddress)) { - logger.log('walletAddress is nil'); + logger.debug('walletAddress is nil'); Alert.alert(lang.t('wallet.import_failed_invalid_private_key')); if (!isImporting) { dispatch(appStateUpdate({ walletReady: true })); @@ -127,23 +127,28 @@ export default function useInitializeWallet() { if (!(isNew || isImporting)) { await loadGlobalEarlyData(); - logger.log('loaded global data...'); + logger.debug('loaded global data...'); } await dispatch(settingsUpdateAccountAddress(walletAddress)); - logger.log('updated settings address', { walletAddress }); + logger.debug('updated settings address', { + walletAddress, + }); // Newly created / imported accounts have no data in localstorage if (!(isNew || isImporting)) { await loadAccountData(network); - logger.log('loaded account data', { network }); + logger.debug('loaded account data', { + network, + }); } try { hideSplashScreen(); - logger.log('Hide splash screen'); } catch (err) { - logger.log('Error while hiding splash screen', { error: err }); + logger.error(new RainbowError('Error while hiding splash screen'), { + error: err, + }); } initializeAccountData(); @@ -167,7 +172,9 @@ export default function useInitializeWallet() { PerformanceTracking.clearMeasure( PerformanceMetrics.useInitializeWallet ); - logger.log('Error while initializing wallet', { error }); + logger.error(new RainbowError('Error while initializing wallet'), { + error, + }); // TODO specify error states more granular if (!switching) { await runKeychainIntegrityChecks(); @@ -176,7 +183,9 @@ export default function useInitializeWallet() { try { hideSplashScreen(); } catch (err) { - logger.log('Error while hiding splash screen', { error: err }); + logger.error(new RainbowError('Error while hiding splash screen'), { + error: err, + }); } captureException(error);