diff --git a/nym-wallet/src-tauri/src/main.rs b/nym-wallet/src-tauri/src/main.rs
index 151a13c9a1..8058728562 100644
--- a/nym-wallet/src-tauri/src/main.rs
+++ b/nym-wallet/src-tauri/src/main.rs
@@ -44,6 +44,7 @@ fn main() {
mixnet::account::get_validator_api_urls,
mixnet::account::get_validator_nymd_urls,
mixnet::account::list_accounts,
+ mixnet::account::sign_in_decrypted_account,
mixnet::account::logout,
mixnet::account::remove_account_for_password,
mixnet::account::remove_password,
diff --git a/nym-wallet/src/components/Accounts/AccountAvatar.tsx b/nym-wallet/src/components/Accounts/AccountAvatar.tsx
index fb2ba5da4b..95d1fcfd16 100644
--- a/nym-wallet/src/components/Accounts/AccountAvatar.tsx
+++ b/nym-wallet/src/components/Accounts/AccountAvatar.tsx
@@ -3,6 +3,6 @@ import { Avatar } from '@mui/material';
import stc from 'string-to-color';
import { TAccount } from 'src/types';
-export const AccountAvatar = ({ name, address }: TAccount) => (
- {name.split('')[0]}
+export const AccountAvatar = ({ name }: Pick) => (
+ {name?.split('')[0]}
);
diff --git a/nym-wallet/src/components/Accounts/AccountContainer.tsx b/nym-wallet/src/components/Accounts/AccountContainer.tsx
deleted file mode 100644
index eb61715f20..0000000000
--- a/nym-wallet/src/components/Accounts/AccountContainer.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import React, { useEffect, useState } from 'react';
-import { TAccount } from 'src/types';
-import { Accounts } from './Accounts';
-import { TDialog } from './types';
-
-export const AccountsContainer = ({ storedAccounts }: { storedAccounts: TAccount[] }) => {
- const [accounts, setAccounts] = useState(storedAccounts);
- const [selectedAccount, setSelectedAccount] = useState(accounts[0]);
- const [accountToEdit, setAccountToEdit] = useState();
- const [dialogToDisplay, setDialogToDisplay] = useState();
-
- useEffect(() => {
- const selected = accounts.find((acc) => acc.address === selectedAccount.address);
- if (selected) setSelectedAccount(selected);
- }, [accounts]);
-
- const addAccount = (account: TAccount) => setAccounts((accs) => [...accs, account]);
- const editAccount = (account: TAccount) =>
- setAccounts((accs) => accs.map((acc) => (acc.address === account.address ? account : acc)));
- const importAccount = (account: TAccount) => setAccounts((accs) => [...accs, account]);
-
- return (
-
- );
-};
diff --git a/nym-wallet/src/components/Accounts/AccountItem.tsx b/nym-wallet/src/components/Accounts/AccountItem.tsx
index b8dd61279c..8344d355a4 100644
--- a/nym-wallet/src/components/Accounts/AccountItem.tsx
+++ b/nym-wallet/src/components/Accounts/AccountItem.tsx
@@ -1,37 +1,68 @@
-import React from 'react';
-import { IconButton, ListItem, ListItemAvatar, ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
-import { Edit } from '@mui/icons-material';
+import React, { useContext } from 'react';
+import { Box, ListItem, ListItemAvatar, ListItemButton, ListItemText, Tooltip, Typography } from '@mui/material';
+import { useClipboard } from 'use-clipboard-copy';
+import { AccountsContext } from 'src/context';
import { AccountAvatar } from './AccountAvatar';
-export const AccountItem = ({
- name,
- address,
- selected,
- onSelect,
- onEdit,
-}: {
- name: string;
- address: string;
- selected: boolean;
- onSelect: () => void;
- onEdit: () => void;
-}) => (
-
-
-
-
-
-
-
- {
- e.stopPropagation();
- onEdit();
- }}
- >
-
-
-
-
-
-);
+export const AccountItem = ({ name, address }: { name: string; address: string }) => {
+ const { selectedAccount, handleSelectAccount, setDialogToDisplay, setAccountMnemonic } = useContext(AccountsContext);
+ const { copy, copied } = useClipboard({ copiedTimeout: 1000 });
+ return (
+
+ handleSelectAccount(name)}>
+
+
+
+
+
+ ) => {
+ e.stopPropagation();
+ copy(address);
+ }}
+ sx={{ '&:hover': { color: 'grey.900' } }}
+ >
+ {address}
+
+
+
+ ) => {
+ e.stopPropagation();
+ setDialogToDisplay('Mnemonic');
+ setAccountMnemonic((accountMnemonic) => ({ ...accountMnemonic, accountName: name }));
+ }}
+ >
+ Show mnemonic
+
+
+
+ }
+ />
+ {/* edit and remove accounts todo */}
+ {/*
+ {
+ e.stopPropagation();
+ handleAccountToEdit(name);
+ }}
+ >
+
+
+ */}
+
+
+ );
+};
diff --git a/nym-wallet/src/components/Accounts/AccountOverview.tsx b/nym-wallet/src/components/Accounts/AccountOverview.tsx
new file mode 100644
index 0000000000..17830ba319
--- /dev/null
+++ b/nym-wallet/src/components/Accounts/AccountOverview.tsx
@@ -0,0 +1,15 @@
+import React from 'react';
+import { Button } from '@mui/material';
+import { AccountEntry } from 'src/types';
+import { AccountAvatar } from './AccountAvatar';
+
+export const AccountOverview = ({ account, onClick }: { account: AccountEntry; onClick: () => void }) => (
+ }
+ sx={{ color: 'nym.text.dark' }}
+ onClick={onClick}
+ disableRipple
+ >
+ {account.id}
+
+);
diff --git a/nym-wallet/src/components/Accounts/Accounts.tsx b/nym-wallet/src/components/Accounts/Accounts.tsx
index 194ec48b51..a59b59c95f 100644
--- a/nym-wallet/src/components/Accounts/Accounts.tsx
+++ b/nym-wallet/src/components/Accounts/Accounts.tsx
@@ -1,89 +1,36 @@
-import React from 'react';
-import { Button } from '@mui/material';
-import { v4 as uuidv4 } from 'uuid';
-import { TAccount } from 'src/types';
+import React, { useContext, useState } from 'react';
+import { AccountsContext, AppContext } from 'src/context';
import { EditAccountModal } from './EditAccountModal';
import { AddAccountModal } from './AddAccountModal';
import { AccountsModal } from './AccountsModal';
-import { ImportAccountModal } from './ImportAccountModal';
-import { AccountAvatar } from './AccountAvatar';
-import { TDialog } from './types';
+import { MnemonicModal } from './MnemonicModal';
+import { AccountOverview } from './AccountOverview';
+import { MultiAccountHowTo } from './MultiAccountHowTo';
-export const Accounts = ({
- accounts,
- selectedAccount,
- accountToEdit,
- dialogToDisplay,
- addAccount,
- editAccount,
- setAccountToEdit,
- importAccount,
- setSelectedAccount,
- setDialogToDisplay,
-}: {
- accounts: TAccount[];
- selectedAccount: TAccount;
- accountToEdit?: TAccount;
- dialogToDisplay?: TDialog;
- addAccount: (acc: TAccount) => void;
- editAccount: (acc: TAccount) => void;
- importAccount: (acc: TAccount) => void;
- setAccountToEdit: (acc: TAccount) => void;
- setSelectedAccount: (accs: TAccount) => void;
- setDialogToDisplay: (dialog: TDialog | undefined) => void;
-}) => (
- <>
- }
- color="inherit"
- onClick={() => setDialogToDisplay('Accounts')}
- disableRipple
- >
- {selectedAccount.name}
-
- setDialogToDisplay(undefined)}
- accounts={accounts}
- onAccountSelect={(acc) => setSelectedAccount(acc)}
- selectedAccount={selectedAccount.address}
- onAdd={() => {
- setDialogToDisplay('Add');
- }}
- onEdit={(acc) => {
- setAccountToEdit(acc);
- setDialogToDisplay('Edit');
- }}
- onImport={() => setDialogToDisplay('Import')}
- />
- {
- setDialogToDisplay('Accounts');
- }}
- onAdd={(name) => {
- addAccount({ name, address: uuidv4() });
- setDialogToDisplay('Accounts');
- }}
- />
- {
- setDialogToDisplay('Accounts');
- }}
- onEdit={(account) => {
- editAccount(account);
- setDialogToDisplay('Accounts');
- }}
- />
- setDialogToDisplay('Accounts')}
- onImport={() => {
- importAccount({ name: 'New Account', address: uuidv4() });
- setDialogToDisplay('Accounts');
- }}
- />
- >
-);
+export const Accounts = () => {
+ const { accounts, selectedAccount, setDialogToDisplay } = useContext(AccountsContext);
+
+ return accounts && selectedAccount ? (
+ <>
+ setDialogToDisplay('Accounts')} />
+
+
+
+
+ >
+ ) : null;
+};
+
+export const SingleAccount = () => {
+ const [showHowToDialog, setShowHowToDialog] = useState(false);
+ const { clientDetails } = useContext(AppContext);
+ return (
+ <>
+ setShowHowToDialog(true)}
+ />
+ setShowHowToDialog(false)} />
+ >
+ );
+};
diff --git a/nym-wallet/src/components/Accounts/AccountsModal.tsx b/nym-wallet/src/components/Accounts/AccountsModal.tsx
index 4b4c9205aa..8210b3c562 100644
--- a/nym-wallet/src/components/Accounts/AccountsModal.tsx
+++ b/nym-wallet/src/components/Accounts/AccountsModal.tsx
@@ -1,62 +1,48 @@
-import React from 'react';
+import React, { useContext } from 'react';
import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Typography } from '@mui/material';
import { Add, ArrowDownwardSharp, Close } from '@mui/icons-material';
-import { TAccount } from 'src/types';
+import { AccountsContext } from 'src/context';
import { AccountItem } from './AccountItem';
-export const AccountsModal = ({
- show,
- accounts,
- selectedAccount,
- onClose,
- onAccountSelect,
- onAdd,
- onEdit,
- onImport,
-}: {
- show: boolean;
- accounts: TAccount[];
- selectedAccount: TAccount['address'];
- onClose: () => void;
- onAccountSelect: (account: TAccount) => void;
- onAdd: () => void;
- onEdit: (acc: TAccount) => void;
- onImport: () => void;
-}) => (
-
-);
+export const AccountsModal = ({ onClose }: { onClose?: () => void }) => {
+ const { accounts, dialogToDisplay, setDialogToDisplay } = useContext(AccountsContext);
+
+ const handleClose = () => {
+ setDialogToDisplay(undefined);
+ onClose?.();
+ };
+
+ return (
+
+ );
+};
diff --git a/nym-wallet/src/components/Accounts/AddAccountModal.tsx b/nym-wallet/src/components/Accounts/AddAccountModal.tsx
index 60d1963618..3ad40f9209 100644
--- a/nym-wallet/src/components/Accounts/AddAccountModal.tsx
+++ b/nym-wallet/src/components/Accounts/AddAccountModal.tsx
@@ -1,8 +1,8 @@
-import React, { useEffect, useState } from 'react';
+import React, { useContext, useEffect, useState } from 'react';
import {
- Alert,
Box,
Button,
+ CircularProgress,
Dialog,
DialogActions,
DialogContent,
@@ -12,75 +12,32 @@ import {
TextField,
Typography,
} from '@mui/material';
-import { Check, Close, ContentCopySharp } from '@mui/icons-material';
+import { ArrowBackSharp } from '@mui/icons-material';
import { useClipboard } from 'use-clipboard-copy';
+import { createMnemonic } from 'src/requests';
+import { AccountsContext } from 'src/context';
+import { Mnemonic } from '../Mnemonic';
-const createAccountSteps = ['Save and copy mnemonic for your new account', 'Name your new account'];
-
-const passwordCreationSteps = [
- 'Log out',
- 'During sign in screen click “Sign in with mnemonic” button',
- 'On next screen click “Create a password for your account”',
- 'Sign in to wallet with your new password',
- 'Now you can create multiple accounts',
+const createAccountSteps = [
+ 'Copy and save mnemonic for your new account',
+ 'Name your new account',
+ 'Confirm the password used to login to your wallet',
+];
+const importAccountSteps = [
+ 'Provide mnemonic of account you want to import',
+ 'Name your new account',
+ 'Confirm the password used to login to your wallet',
];
-const NoPassword = ({ onClose }: { onClose: () => void }) => (
-
-
-
-
-
- You can’t add new accounts if your wallet doesn’t have a password.
-
- Follow steps below to create password.
-
- How to create password to your account
- {passwordCreationSteps.map((step, i) => (
- {`${i + 1}. ${step}`}
- ))}
-
-
-
-
-
-
-);
-
-const MnemonicStep = ({ mnemonic, onSave }: { mnemonic: string; onSave: () => void }) => {
+const MnemonicStep = ({ mnemonic, onNext }: { mnemonic: string; onNext: () => void }) => {
const { copy, copied } = useClipboard({ copiedTimeout: 5000 });
return (
-
-
-
- Below is your 24 word mnemonic, make sure to store it in a safe place for accessing your wallet in the
- future
-
-
-
-
-
-
+
-
@@ -88,7 +45,44 @@ const MnemonicStep = ({ mnemonic, onSave }: { mnemonic: string; onSave: () => vo
);
};
-const NameAccount = ({ onAdd }: { onAdd: (value: string) => void }) => {
+const ImportMnemonic = ({
+ value,
+ onChange,
+ onNext,
+}: {
+ value: string;
+ onChange: (value: string) => void;
+ onNext: () => void;
+}) => (
+
+
+
+ onChange(e.target.value)}
+ fullWidth
+ type="password"
+ />
+
+
+
+
+ Next
+
+
+
+);
+
+const NameAccount = ({ onNext }: { onNext: (value: string) => void }) => {
const [value, setValue] = useState('');
return (
@@ -102,61 +96,128 @@ const NameAccount = ({ onAdd }: { onAdd: (value: string) => void }) => {
disableElevation
variant="contained"
size="large"
- onClick={() => onAdd(value)}
+ onClick={() => onNext(value)}
>
- Add
+ Next
);
};
-export const AddAccountModal = ({
- show,
- withoutPassword,
- onClose,
- onAdd,
-}: {
- show: boolean;
- withoutPassword?: boolean;
- onClose: () => void;
- onAdd: (accountName: string) => void;
-}) => {
- const [step, setStep] = useState(0);
+const ConfirmPassword = ({ onConfirm }: { onConfirm: (password: string) => void }) => {
+ const [value, setValue] = useState('');
+ const { isLoading, error } = useContext(AccountsContext);
return (
-