diff --git a/src/background/controller/wallet.ts b/src/background/controller/wallet.ts index 044852b3..3f7c7dcb 100644 --- a/src/background/controller/wallet.ts +++ b/src/background/controller/wallet.ts @@ -4,6 +4,7 @@ import { getAuth } from '@firebase/auth'; import * as fcl from '@onflow/fcl'; import * as t from '@onflow/types'; import BN from 'bignumber.js'; +import * as bip39 from 'bip39'; import { ethErrors } from 'eth-rpc-errors'; import * as ethUtil from 'ethereumjs-util'; import { getApp } from 'firebase/app'; @@ -3384,6 +3385,10 @@ export class WalletController extends BaseController { }; uploadMnemonicToGoogleDrive = async (mnemonic, username, password) => { + const isValidMnemonic = bip39.validateMnemonic(mnemonic); + if (!isValidMnemonic) { + throw new Error('Invalid mnemonic'); + } const app = getApp(process.env.NODE_ENV!); const user = await getAuth(app).currentUser; return googleDriveService.uploadMnemonicToGoogleDrive(mnemonic, username, user!.uid, password); diff --git a/src/ui/views/Setting/index.tsx b/src/ui/views/Setting/index.tsx index 408a5c1d..2e886efa 100644 --- a/src/ui/views/Setting/index.tsx +++ b/src/ui/views/Setting/index.tsx @@ -22,7 +22,7 @@ import IconLink from 'ui/FRWAssets/svg/Iconlink.svg'; import IconAbout from '../../../components/iconfont/IconAbout'; import IconAccount from '../../../components/iconfont/IconAccount'; -import IconAddressBook from '../../../components/iconfont/IconAddressBook'; +import IconAddressBook from '../../../components/iconfont/IconAddressbook'; import IconEnd from '../../../components/iconfont/IconAVector11Stroke'; import IconBackup from '../../../components/iconfont/IconBackup'; import IconDeveloper from '../../../components/iconfont/IconDeveloper'; @@ -79,16 +79,19 @@ const useStyles = makeStyles(() => ({ const SettingTab = () => { const classes = useStyles(); - const wallet = useWallet(); + const usewallet = useWallet(); const [isActive, setIsActive] = useState(false); + const [isKeyphrase, setIsKeyphrase] = useState(false); const checkIsActive = useCallback(async () => { // setSending(true); - const activeChild = await wallet.getActiveWallet(); + const activeChild = await usewallet.getActiveWallet(); if (activeChild) { setIsActive(activeChild); } - }, [wallet]); + const keyrings = await usewallet.checkMnemonics(); + await setIsKeyphrase(keyrings); + }, [usewallet]); useEffect(() => { checkIsActive(); @@ -184,24 +187,25 @@ const SettingTab = () => { )} {!isActive && } - - - - - - - - - - - - + {isKeyphrase && ( + + + + + + + + + + + + )}