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

fixed: hide backup page if login with privatekey #228

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/background/controller/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
48 changes: 26 additions & 22 deletions src/ui/views/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -184,24 +187,25 @@ const SettingTab = () => {
)}

{!isActive && <Divider sx={{ width: '90%' }} variant="middle" />}

<ListItem
button
component={Link}
to="/dashboard/setting/backups"
disablePadding
className={classes.listItem}
>
<ListItemButton className={classes.itemButton}>
<ListItemIcon sx={{ minWidth: '25px' }}>
<IconBackup className={classes.iconOthers} color="#59A1DB" />
</ListItemIcon>
<ListItemText primary={chrome.i18n.getMessage('Backup')} />
<ListItemIcon aria-label="end" sx={{ minWidth: '15px' }}>
<IconEnd size={12} />
</ListItemIcon>
</ListItemButton>
</ListItem>
{isKeyphrase && (
<ListItem
button
component={Link}
to="/dashboard/setting/backups"
disablePadding
className={classes.listItem}
>
<ListItemButton className={classes.itemButton}>
<ListItemIcon sx={{ minWidth: '25px' }}>
<IconBackup className={classes.iconOthers} color="#59A1DB" />
</ListItemIcon>
<ListItemText primary={chrome.i18n.getMessage('Backup')} />
<ListItemIcon aria-label="end" sx={{ minWidth: '15px' }}>
<IconEnd size={12} />
</ListItemIcon>
</ListItemButton>
</ListItem>
)}
</List>

<List className={classes.list} sx={{ margin: '8px auto 18px auto', pt: 0, pb: 0 }}>
Expand Down