From 3aa7c7646ced4fc56f3960ffdace5b782204f9b2 Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Mon, 13 May 2024 14:55:33 +0100 Subject: [PATCH] fix: Black screen --- src/App.tsx | 59 +++++++--------------- src/screens/Onboarding/RestoreFromSeed.tsx | 6 +-- src/store/actions/wallet.ts | 3 ++ src/utils/wallet/index.ts | 5 +- 4 files changed, 28 insertions(+), 45 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index a600a7990..6c8f95a2d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,11 +1,4 @@ -import React, { - memo, - ReactElement, - useMemo, - useEffect, - useCallback, - useState, -} from 'react'; +import React, { memo, ReactElement, useMemo, useEffect, useState } from 'react'; import { Platform, NativeModules } from 'react-native'; import Toast from 'react-native-toast-message'; import QuickActions from 'react-native-quick-actions'; @@ -60,45 +53,29 @@ const App = (): ReactElement => { checkForAppUpdate(); }, []); - const RootComponent = useCallback((): ReactElement => { - if (!isReady) { - return <>; - } - - if (showRecovery) { - return ; - } - - if (hasCriticalUpdate) { - return ; - } - - if (walletExists) { - return ( - - - {requiresRemoteRestore ? : } - - - ); - } - - return ; - }, [ - isReady, - showRecovery, - hasCriticalUpdate, - walletExists, - requiresRemoteRestore, - ]); - const currentTheme = useMemo(() => getTheme(theme), [theme]); return ( - + + {!isReady ? ( + <> + ) : showRecovery ? ( + + ) : hasCriticalUpdate ? ( + + ) : walletExists ? ( + + + {requiresRemoteRestore ? : } + + + ) : ( + + )} + diff --git a/src/screens/Onboarding/RestoreFromSeed.tsx b/src/screens/Onboarding/RestoreFromSeed.tsx index b2bed7a16..3cff2bb6c 100644 --- a/src/screens/Onboarding/RestoreFromSeed.tsx +++ b/src/screens/Onboarding/RestoreFromSeed.tsx @@ -108,6 +108,9 @@ const RestoreFromSeed = (): ReactElement => { setIsRestoringWallet(true); dispatch(verifyBackup()); + // Tells component within slashtags provider that it needs to handle restoring from remote backup + dispatch(updateUser({ requiresRemoteRestore: true })); + const res = await restoreSeed({ mnemonic: seed.join(' '), bip39Passphrase, @@ -120,9 +123,6 @@ const RestoreFromSeed = (): ReactElement => { }); return; } - - //Tells component within slashtags provider that it needs to handle restoring from remote backup - dispatch(updateUser({ requiresRemoteRestore: true })); }; const handleAdvanced = (): void => { diff --git a/src/store/actions/wallet.ts b/src/store/actions/wallet.ts index 01dc04f9d..6a568a07e 100644 --- a/src/store/actions/wallet.ts +++ b/src/store/actions/wallet.ts @@ -120,13 +120,16 @@ export const createWallet = async ({ export const createDefaultWalletStructure = async ({ walletName = 'wallet0', + seedHash, }: { walletName?: TWalletName; + seedHash: string; }): Promise> => { try { const payload: IWallets = { [walletName]: getDefaultWalletShape(), }; + payload[walletName].seedHash = seedHash; dispatch({ type: actions.CREATE_WALLET, payload, diff --git a/src/utils/wallet/index.ts b/src/utils/wallet/index.ts index 04a0744a5..c0b87aecc 100644 --- a/src/utils/wallet/index.ts +++ b/src/utils/wallet/index.ts @@ -896,7 +896,10 @@ export const createDefaultWallet = async ({ const seed = await bip39.mnemonicToSeed(mnemonic, bip39Passphrase); await setKeychainSlashtagsPrimaryKey(seed); - await createDefaultWalletStructure({ walletName }); + await createDefaultWalletStructure({ + walletName, + seedHash: seedHash(seed), + }); let gapLimitOptions = getDefaultGapLimitOptions(); if (restore) {