Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to breadcrumbs #5309

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 25 additions & 16 deletions src/hooks/useInitializeWallet.ts
Original file line number Diff line number Diff line change
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