Skip to content

Commit

Permalink
switch to breadcrumbs (#5309)
Browse files Browse the repository at this point in the history
* switch to breadcrumbs

* change to debug calls
  • Loading branch information
walmat committed Jan 3, 2024
1 parent bdab37d commit 9b7d5b4
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/hooks/useInitializeWallet.ts
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -100,7 +100,7 @@ export default function useInitializeWallet() {
silent
);

logger.log('walletInit returned', {
logger.debug('walletInit returned', {
isNew,
walletAddress,
});
Expand All @@ -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 }));
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 9b7d5b4

Please sign in to comment.