diff --git a/src/App.tsx b/src/App.tsx index 0d589a6a0..31c7965b5 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'; @@ -59,45 +52,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 5ba37454e..d40616019 100644 --- a/src/screens/Onboarding/RestoreFromSeed.tsx +++ b/src/screens/Onboarding/RestoreFromSeed.tsx @@ -105,6 +105,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, @@ -117,9 +120,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 0c36e693a..fd43aa2bb 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 388be385b..ebcec53a7 100644 --- a/src/utils/wallet/index.ts +++ b/src/utils/wallet/index.ts @@ -813,7 +813,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) {