diff --git a/package.json b/package.json
index e7ef0620..8865fae7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "plug",
- "version": "0.6.0",
+ "version": "0.6.1",
"description": "Your plug into the Internet Computer",
"private": true,
"repository": "https://github.com/Psychedelic/plug",
@@ -37,8 +37,8 @@
"@material-ui/icons": "^4.11.2",
"@metamask/post-message-stream": "^4.0.0",
"@psychedelic/browser-rpc": "2.1.0",
- "@psychedelic/dab-js": "1.4.12",
- "@psychedelic/plug-controller": "0.22.6",
+ "@psychedelic/dab-js": "1.5.0-beta.1",
+ "@psychedelic/plug-controller": "0.24.4",
"@psychedelic/plug-inpage-provider": "^2.3.1",
"@reduxjs/toolkit": "^1.6.0",
"advanced-css-reset": "^1.2.2",
@@ -58,7 +58,9 @@
"random-color": "^1.0.1",
"react": "^17.0.1",
"react-collapsible": "^2.8.4",
+ "react-cool-virtual": "^0.7.0",
"react-dom": "^17.0.1",
+ "react-dropzone": "^14.2.2",
"react-feather": "^2.0.9",
"react-i18next": "^11.8.13",
"react-json-view": "^1.21.3",
diff --git a/source/Background/Keyring/index.js b/source/Background/Keyring/index.js
index 2522959a..6d5825d3 100644
--- a/source/Background/Keyring/index.js
+++ b/source/Background/Keyring/index.js
@@ -107,6 +107,11 @@ export const HANDLER_TYPES = {
REMOVE_NETWORK: 'remove-network',
SET_CURRENT_NETWORK: 'set-current-network',
GET_CURRENT_NETWORK: 'get-current-network',
+ IMPORT_PEM_ACCOUNT: 'import-pem-account',
+ REMOVE_PEM_ACCOUNT: 'remove-pem-account',
+ REMOVE_CUSTOM_TOKEN: 'remove-custom-token',
+ GET_PRINCIPAL_FROM_PEM: 'get-principal-from-pem',
+ VALIDATE_PEM: 'validate-pem',
};
export const getKeyringErrorMessage = (type) => ({
@@ -141,6 +146,8 @@ export const getKeyringErrorMessage = (type) => ({
[HANDLER_TYPES.SET_CURRENT_NETWORK]: 'setting the current network',
[HANDLER_TYPES.GET_CURRENT_NETWORK]: 'getting the current network',
[HANDLER_TYPES.REMOVE_CUSTOM_TOKEN]: 'removing custom token',
+ [HANDLER_TYPES.IMPORT_PEM_ACCOUNT]: 'importing account from pem',
+ [HANDLER_TYPES.REMOVE_PEM_ACCOUNT]: 'removing pem account',
}[type]);
export const sendMessage = (args, callback) => {
@@ -157,6 +164,15 @@ export const sendMessage = (args, callback) => {
});
};
+export const asyncSendMessage = (args, callback) => new Promise((resolve) => {
+ sendMessage(args, (response) => {
+ if (callback) {
+ callback(response);
+ }
+ resolve(response);
+ });
+});
+
export const getKeyringHandler = (type, keyring) => ({
[HANDLER_TYPES.LOCK]: async () => keyring.lock(),
[HANDLER_TYPES.UNLOCK]: async (params) => {
@@ -182,7 +198,9 @@ export const getKeyringHandler = (type, keyring) => ({
return null;
}
},
+ [HANDLER_TYPES.IMPORT_PEM_ACCOUNT]: keyring.importAccountFromPem,
[HANDLER_TYPES.CREATE_PRINCIPAL]: async (params) => keyring.createPrincipal(params),
+ [HANDLER_TYPES.REMOVE_PEM_ACCOUNT]: async (params) => keyring.deleteImportedAccount(params),
[HANDLER_TYPES.SET_CURRENT_PRINCIPAL]:
async (walletId) => {
await keyring.setCurrentPrincipal(walletId);
@@ -206,22 +224,12 @@ export const getKeyringHandler = (type, keyring) => ({
const parsed = parseTransactions(response);
return parsed;
},
- [HANDLER_TYPES.GET_ASSETS]: async ({ refresh }) => {
+ [HANDLER_TYPES.GET_ASSETS]: async () => {
try {
if (!keyring?.isUnlocked) return {};
-
- const { wallets, currentWalletId } = await keyring.getState();
- let assets = Object.values(wallets?.[currentWalletId]?.assets);
- const shouldUpdate = Object.values(assets)?.every((asset) => !Number(asset.amount))
- || Object.values(assets)?.some((asset) => asset.amount === 'Error')
- || refresh;
- if (shouldUpdate) {
- assets = await keyring.getBalances();
- } else {
- keyring.getBalances();
- }
- assets = parseAssetsAmount(assets);
- return (assets || []).map((asset) => recursiveParseBigint(asset));
+ const assets = await keyring.getBalances();
+ const parsedAssets = parseAssetsAmount(assets);
+ return (parsedAssets || []).map((asset) => recursiveParseBigint(asset));
} catch (e) {
// eslint-disable-next-line
console.log('Error while fetching the assets', e);
@@ -302,9 +310,10 @@ export const getKeyringHandler = (type, keyring) => ({
[HANDLER_TYPES.ADD_CUSTOM_NFT]:
async ({ canisterId, standard }) => {
try {
- const nfts = await keyring.registerNFT({
+ await keyring.registerNFT({
canisterId, standard,
});
+ const nfts = await keyring.getNFTs({ refresh: true });
return (nfts || []).map((nft) => recursiveParseBigint(nft));
} catch (e) {
// eslint-disable-next-line
@@ -339,18 +348,15 @@ export const getKeyringHandler = (type, keyring) => ({
return { error: e.message };
}
},
- [HANDLER_TYPES.GET_NFTS]: async ({ refresh = false }) => {
- const { wallets, currentWalletId } = await keyring.getState();
- let collections = wallets?.[currentWalletId]?.collections || [];
- if (!collections.length || refresh) {
- collections = await keyring.getNFTs({ subaccount: currentWalletId, refresh });
- }
+ [HANDLER_TYPES.GET_NFTS]: async ({ refresh } = { refresh: false }) => {
+ const collections = await keyring.getNFTs({ refresh });
return (collections || [])?.map((collection) => recursiveParseBigint(collection));
},
[HANDLER_TYPES.TRANSFER_NFT]: async ({ to, nft }) => {
try {
- const response = await keyring.transferNFT({ to, token: nft });
- return recursiveParseBigint(response);
+ await keyring.transferNFT({ to, token: nft });
+ const nfts = await keyring.getNFTs({ refresh: true });
+ return recursiveParseBigint(nfts);
} catch (e) {
// eslint-disable-next-line
console.log('Error transfering NFT', e);
@@ -480,6 +486,8 @@ export const getKeyringHandler = (type, keyring) => ({
return { error: e.message };
}
},
+ [HANDLER_TYPES.GET_PRINCIPAL_FROM_PEM]: keyring.getPrincipalFromPem,
+ [HANDLER_TYPES.VALIDATE_PEM]: keyring.validatePem,
}[type]);
export const getContacts = () => new Promise((resolve, reject) => {
diff --git a/source/assets/icons/gradient-file.svg b/source/assets/icons/gradient-file.svg
new file mode 100644
index 00000000..97a14564
--- /dev/null
+++ b/source/assets/icons/gradient-file.svg
@@ -0,0 +1,11 @@
+
diff --git a/source/assets/icons/link-emoji.png b/source/assets/icons/link-emoji.png
new file mode 100644
index 00000000..64b16ffd
Binary files /dev/null and b/source/assets/icons/link-emoji.png differ
diff --git a/source/assets/icons/question-hat.svg b/source/assets/icons/question-hat.svg
new file mode 100644
index 00000000..531dd54c
--- /dev/null
+++ b/source/assets/icons/question-hat.svg
@@ -0,0 +1,28 @@
+
diff --git a/source/assets/icons/red-warning-icon.svg b/source/assets/icons/red-warning-icon.svg
new file mode 100644
index 00000000..a1657145
--- /dev/null
+++ b/source/assets/icons/red-warning-icon.svg
@@ -0,0 +1,3 @@
+
diff --git a/source/components/AssetItem/index.jsx b/source/components/AssetItem/index.jsx
index 22ce92a4..f8c5faa6 100644
--- a/source/components/AssetItem/index.jsx
+++ b/source/components/AssetItem/index.jsx
@@ -8,7 +8,6 @@ import clsx from 'clsx';
import Skeleton from 'react-loading-skeleton';
import 'react-loading-skeleton/dist/skeleton.css';
-import { TOKENS } from '@shared/constants/currencies';
import RefreshIcon from '@assets/icons/blue-refresh.png';
import DeleteIcon from '@assets/icons/delete.svg';
import TokenIcon from '../TokenIcon';
@@ -32,7 +31,7 @@ const AssetItem = ({
const classes = useStyles();
const { t } = useTranslation();
const { currentNetwork, usingMainnet } = useSelector((state) => state.network);
- const [ shouldRemove, setShouldRemove] = useState(false);
+ const [shouldRemove, setShouldRemove] = useState(false);
const [isHovering, setIsHovering] = useState(false);
const [openDelete, setOpenDelete] = useState(false);
@@ -61,13 +60,19 @@ const AssetItem = ({
const handleRemoveAssetDisplay = () => {
setShouldRemove(true);
handleModalClose();
- }
+ };
const ledgerNotSpecified = !usingMainnet && !currentNetwork?.ledgerCanisterId;
return (
: ()}
- )}
+ )}
{ !failed && !loading && (
setOpenDelete(true)}
@@ -170,4 +181,5 @@ AssetItem.propTypes = {
failed: PropTypes.bool,
assetNameTestId: PropTypes.string,
removeAsset: PropTypes.func.isRequired,
+ protectedAsset: PropTypes.bool.isRequired,
};
diff --git a/source/components/ConnectAccountsModal/index.jsx b/source/components/ConnectAccountsModal/index.jsx
index dd4d7664..62c6fe1c 100644
--- a/source/components/ConnectAccountsModal/index.jsx
+++ b/source/components/ConnectAccountsModal/index.jsx
@@ -61,7 +61,9 @@ const ConnectAccountsModal = ({
const handleConfirm = () => {
Object.keys(walletsToUpdate).forEach((walletId) => {
- walletsToUpdate[walletId] && connectAccountToTab(walletId, tab);
+ if (walletsToUpdate[walletId]) {
+ connectAccountToTab(walletId, tab);
+ }
});
onConfirm?.();
setWalletsToUpdate({});
diff --git a/source/components/ConnectionStatus/components/ConnectionControls/index.jsx b/source/components/ConnectionStatus/components/ConnectionControls/index.jsx
index 786633f3..cbca0a58 100644
--- a/source/components/ConnectionStatus/components/ConnectionControls/index.jsx
+++ b/source/components/ConnectionStatus/components/ConnectionControls/index.jsx
@@ -12,12 +12,11 @@ import {
setAssetsLoading,
setTransactions,
setTransactionsLoading,
- setCollections,
- setCollectionsLoading,
} from '@redux/wallet';
import { getApps } from '@modules/storageManager';
import { getCurrentNetwork, getNetworks } from '@redux/network';
import { getContacts } from '@redux/contacts';
+import { getNFTs } from '@redux/nfts';
import { HANDLER_TYPES, sendMessage } from '@background/Keyring';
import { TABS, useRouter } from '@components/Router';
import RefreshAsset from '@assets/icons/refresh.svg';
@@ -29,14 +28,13 @@ const ConnectionControls = ({ disableNavigation, hidden }) => {
const classes = useStyles();
const icpPrice = useICPPrice();
const dispatch = useDispatch();
- const { tabIndex } = disableNavigation ? {} : useRouter();
+ const { tabIndex, route } = disableNavigation ? {} : useRouter();
const {
- principalId,
walletId,
assetsLoading,
transactionsLoading,
- collectionsLoading,
} = useSelector((state) => state.wallet);
+ const { collectionsLoading } = useSelector((state) => state.nfts);
const { useICNS } = useSelector((state) => state.icns);
const { currentNetwork } = useSelector((state) => state.network);
const [selectorOpen, setSelectorOpen] = useState(false);
@@ -95,21 +93,7 @@ const ConnectionControls = ({ disableNavigation, hidden }) => {
};
const loadCollections = () => {
- dispatch(setCollectionsLoading(true));
- sendMessage(
- {
- type: HANDLER_TYPES.GET_NFTS,
- params: { refresh: true },
- },
- (nftCollections) => {
- if (nftCollections?.length) {
- dispatch(
- setCollections({ collections: nftCollections, principalId }),
- );
- }
- dispatch(setCollectionsLoading(false));
- },
- );
+ dispatch(getNFTs({ refresh: route === 'home' && tabIndex === TABS.NFTS }));
};
const refreshWallet = () => {
diff --git a/source/components/ICNSDisplay/index.jsx b/source/components/ICNSDisplay/index.jsx
index b19bef03..a6058559 100644
--- a/source/components/ICNSDisplay/index.jsx
+++ b/source/components/ICNSDisplay/index.jsx
@@ -11,14 +11,13 @@ const ICNSDisplay = ({
}) => {
const classes = useStyles();
const [loading, setLoading] = useState(true);
-
return (
setLoading(false)}
- src={icns.url}
+ src="https://icns.id/Rectangle.jpg"
/>
{icns.name?.length > 12 ? shortICNSName(icns?.name) : icns?.name}
diff --git a/source/views/Extension/Views/WalletDetails/components/InfoModal/index.jsx b/source/components/InfoModal/index.jsx
similarity index 100%
rename from source/views/Extension/Views/WalletDetails/components/InfoModal/index.jsx
rename to source/components/InfoModal/index.jsx
diff --git a/source/views/Extension/Views/WalletDetails/components/InfoModal/styles.js b/source/components/InfoModal/styles.js
similarity index 100%
rename from source/views/Extension/Views/WalletDetails/components/InfoModal/styles.js
rename to source/components/InfoModal/styles.js
diff --git a/source/components/NFTs/components/NFTCollection/index.jsx b/source/components/NFTs/components/NFTCollection/index.jsx
index 868cf44e..4bb6f6a1 100644
--- a/source/components/NFTs/components/NFTCollection/index.jsx
+++ b/source/components/NFTs/components/NFTCollection/index.jsx
@@ -1,10 +1,11 @@
-import React, { useState } from 'react';
+import React, { useState, useMemo } from 'react';
import Collapsible from 'react-collapsible';
import PropTypes from 'prop-types';
import { useDispatch } from 'react-redux';
import clsx from 'clsx';
import { Typography } from '@material-ui/core';
import { ChevronDown } from 'react-feather';
+import useVirtual from 'react-cool-virtual';
import { shortICNSName } from '@shared/services/ICNS';
import { useRouter } from '@components/Router';
@@ -32,6 +33,21 @@ function NFTCollection({
const toggleExpanded = () => setExpanded(!expanded);
const nftDefaultTag = NFT_COLLECTION_DEFAULT_TYPES[collection.canisterId];
+ const rows = useMemo(() => {
+ const itemCount = collection?.tokens?.length || 0;
+ const COLUMNS = 3;
+ const rowsCount = Math.ceil(itemCount / COLUMNS);
+ // Generate an array of rows with 3 items each
+ const nftRows = Array.from(
+ Array(rowsCount), (_, i) => collection.tokens.slice(i * COLUMNS, i * COLUMNS + COLUMNS),
+ );
+ return nftRows;
+ }, [collection]);
+
+ const { outerRef, innerRef, items: itemRows } = useVirtual({
+ itemCount: rows?.length || 0, // Provide the total number for the list items
+ itemSize: 150, // The size of each row (img + title)
+ });
return (
)}
>
-
- {collection?.tokens?.map((nft) => {
- const name = nft.name || `#${nft.index}`;
- return (
-
handleNftClick(nft)}
- data-testid={`nft-id-${name}`}
- >
- {icns ? (
- handleNftClick(nft)}
- />
- ) : (
- handleNftClick(nft)}
- />
- )}
- {!icns && (
-
- {name.length > 12 ? shortICNSName(name) : name}
-
- )}
-
- );
- })}
+
+ {expanded && (
+
+ {itemRows?.map(({ index, size }) => {
+ const rowNfts = rows[index];
+ return (
+
+ {rowNfts?.map((nft) => {
+ const name = nft?.name || `#${nft?.index}`;
+ return (
+
handleNftClick(nft)}
+ data-testid={`nft-id-${name}`}
+ style={{ height: `${size}px` }}
+ >
+ {icns ? (
+ handleNftClick(nft)}
+ />
+ ) : (
+ handleNftClick(nft)}
+ />
+ )}
+ {!icns && (
+
+ {name.length > 12 ? shortICNSName(name) : name}
+
+ )}
+
+ );
+ })}
+
+ );
+ })}
+
+ )}
);
diff --git a/source/components/NFTs/components/NFTCollection/styles.js b/source/components/NFTs/components/NFTCollection/styles.js
index 6eae7495..4bdfda6c 100644
--- a/source/components/NFTs/components/NFTCollection/styles.js
+++ b/source/components/NFTs/components/NFTCollection/styles.js
@@ -11,7 +11,7 @@ export default makeStyles(() => ({
display: 'grid',
justifyContent: 'space-evenly',
gridTemplateColumns: 'repeat(auto-fill, 112px)',
- overflow: 'hidden',
+ padding: '0 5px',
},
nft: {
height: 112,
diff --git a/source/components/NFTs/index.jsx b/source/components/NFTs/index.jsx
index 5e1aabdc..8f5255e5 100644
--- a/source/components/NFTs/index.jsx
+++ b/source/components/NFTs/index.jsx
@@ -1,9 +1,9 @@
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
-import { HANDLER_TYPES, sendMessage } from '@background/Keyring';
+import { getNFTs } from '@redux/nfts';
+
import LoadingWrapper from '../LoadingWrapper';
-import { setCollections, setCollectionsLoading } from '../../redux/wallet';
import useStyles from './styles';
import EmptyState from './components/EmptyState';
import NFTCollection from './components/NFTCollection';
@@ -12,23 +12,12 @@ const NFTs = () => {
const classes = useStyles();
const dispatch = useDispatch();
- const {
- collections, collectionsLoading, principalId, optimisticNFTUpdate,
- } = useSelector((state) => state.wallet);
+ const { principalId } = useSelector((state) => state.wallet);
+ const { collections, collectionsLoading } = useSelector((state) => state.nfts);
useEffect(() => {
- // Update cache
if (!collectionsLoading) {
- dispatch(setCollectionsLoading(true));
- sendMessage({
- type: HANDLER_TYPES.GET_NFTS,
- params: {},
- }, (nftCollections) => {
- if (nftCollections?.length && !optimisticNFTUpdate) {
- dispatch(setCollections({ collections: nftCollections, principalId }));
- }
- dispatch(setCollectionsLoading(false));
- });
+ dispatch(getNFTs());
}
}, [principalId]);
diff --git a/source/components/Profile/components/AccountItem/index.jsx b/source/components/Profile/components/AccountItem/index.jsx
index c2f00b8d..4676c777 100644
--- a/source/components/Profile/components/AccountItem/index.jsx
+++ b/source/components/Profile/components/AccountItem/index.jsx
@@ -1,4 +1,5 @@
import React from 'react';
+import PropTypes from 'prop-types';
import clsx from 'clsx';
import { IconButton } from '@material-ui/core';
import { useDispatch } from 'react-redux';
@@ -7,16 +8,17 @@ import { useHiddenAccounts, toggleAccountHidden } from '@redux/profile';
import BluePencil from '@assets/icons/blue-pencil.svg';
import InvisibleIcon from '@assets/icons/invisible.svg';
import VisibleIcon from '@assets/icons/visible.svg';
+import RemoveCircleOutline from '@material-ui/icons/RemoveCircleOutline';
import UserIcon from '../../../UserIcon';
import useStyles from './styles';
const AccountItem = ({
account,
- isCurrentAccount,
isEditing,
handleChangeAccount,
handleEditAccount,
+ handleRemoveAccountModal,
}) => {
const classes = useStyles();
const hiddenAccounts = useHiddenAccounts();
@@ -34,20 +36,24 @@ const AccountItem = ({
return (
handleChangeAccount(e, account.walletId)}
>
-
-
- {account.icnsData.reverseResolvedName ? account.icnsData.reverseResolvedName : account.name }
+
+
+ {account?.icnsData?.reverseResolvedName || account?.name}
@@ -62,16 +68,40 @@ const AccountItem = ({
src={BluePencil}
/>
- { isEditing && (
-
{ toggleAccountVisibility(e, account.walletId) }}
- >
-
-
+ {!(account.type === 'MNEMONIC') && (
+
handleRemoveAccountModal(e, account)}>
+
+
+ )}
+ {isEditing && (
+
{
+ toggleAccountVisibility(e, account.walletId);
+ }}
+ >
+
+
)}
);
};
+AccountItem.propTypes = {
+ account: PropTypes.shape({
+ name: PropTypes.string,
+ walletId: PropTypes.string,
+ icon: PropTypes.string,
+ type: PropTypes.string,
+ icnsData: PropTypes.shape({
+ reverseResolvedName: PropTypes.string,
+ names: PropTypes.arrayOf(PropTypes.string),
+ }),
+ }).isRequired,
+ isEditing: PropTypes.bool.isRequired,
+ handleChangeAccount: PropTypes.func.isRequired,
+ handleRemoveAccountModal: PropTypes.func.isRequired,
+ handleEditAccount: PropTypes.func.isRequired,
+};
+
export default AccountItem;
diff --git a/source/components/Profile/components/AccountItem/styles.js b/source/components/Profile/components/AccountItem/styles.js
index 11e12e71..6f92ed0b 100644
--- a/source/components/Profile/components/AccountItem/styles.js
+++ b/source/components/Profile/components/AccountItem/styles.js
@@ -1,5 +1,5 @@
import { makeStyles } from '@material-ui/core/styles';
-import SMOOTH_TRANSITION from '@shared/styles/transitions';
+import SMOOTH_TRANSITION from '@shared/styles/transitions';
export default makeStyles(() => ({
accountItemContainer: {
diff --git a/source/components/Profile/index.jsx b/source/components/Profile/index.jsx
index 93423cbe..252f51a7 100644
--- a/source/components/Profile/index.jsx
+++ b/source/components/Profile/index.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable max-len */
import React, { useState, useEffect } from 'react';
import MenuList from '@material-ui/core/MenuList';
import Button from '@material-ui/core/Button';
@@ -12,11 +13,12 @@ import { useTranslation } from 'react-i18next';
import extensionizer from 'extensionizer';
import Plus from '@assets/icons/plus.svg';
+import LinkEmoji from '@assets/icons/link-emoji.png';
+
import {
setAccountInfo,
setAssets,
setAssetsLoading,
- setCollections,
setTransactions,
} from '@redux/wallet';
import { getRandomEmoji } from '@shared/constants/emojis';
@@ -27,6 +29,7 @@ import { setICNSData } from '@redux/icns';
import { useICPPrice } from '@redux/icp';
import { getContacts } from '@redux/contacts';
import { useMenuItems } from '@hooks';
+import { Dialog, Button as CButton } from '@components';
import ConnectAccountsModal from '../ConnectAccountsModal';
import HoverAnimation from '../HoverAnimation';
import MenuItem from '../MenuItem';
@@ -39,6 +42,8 @@ import { AccountItem } from './components';
import UserIcon from '../UserIcon';
import useStyles from './styles';
+const IMPORT_WALLET_ENABLED = process.env.TARGET_BROWSER !== 'firefox';
+
const Profile = ({ disableProfile }) => {
const classes = useStyles();
const { t } = useTranslation();
@@ -46,7 +51,7 @@ const Profile = ({ disableProfile }) => {
const { navigator } = disableProfile ? {} : useRouter();
const [isEditing, setIsEditing] = useState(false);
- const { walletId, principalId } = useSelector((state) => state.wallet);
+ const { walletId } = useSelector((state) => state.wallet);
const icpPrice = useICPPrice();
const [open, setOpen] = useState(false);
@@ -60,6 +65,8 @@ const Profile = ({ disableProfile }) => {
const [accountName, setAccountName] = useState('');
const [error, setError] = useState(null);
const [connectedWallets, setConnectedWallets] = useState([]);
+ const [selectedRemoveAccount, setSelectedRemovedAccount] = useState(null);
+ const [openRemoveModal, setOpenRemoveModal] = useState(false);
const handleToggle = () => {
setOpen((prevOpen) => !prevOpen);
@@ -75,7 +82,7 @@ const Profile = ({ disableProfile }) => {
setAccounts(walletsArray);
}
});
- }, []);
+ }, [open]);
const handleChangeAccountName = (e) => {
const name = e.target.value;
@@ -112,7 +119,6 @@ const Profile = ({ disableProfile }) => {
};
const executeAccountSwitch = (wallet) => {
- dispatch(setCollections({ collections: [], principalId }));
sendMessage({ type: HANDLER_TYPES.SET_CURRENT_PRINCIPAL, params: wallet },
(state) => {
const walletsArray = Object.values(state?.wallets);
@@ -181,8 +187,44 @@ const Profile = ({ disableProfile }) => {
setSelectedWallet(null);
};
+ const handleOpenImportWallet = () => {
+ navigator.navigate('import-wallet');
+ };
+
+ const handleRemoveAccountModal = (e, account) => {
+ e.stopPropagation();
+ setOpenRemoveModal(true);
+ setSelectedRemovedAccount(account);
+ };
+
+ const handleRemoveAccount = () => {
+ sendMessage({
+ type: HANDLER_TYPES.REMOVE_PEM_ACCOUNT,
+ params: selectedRemoveAccount.walletId,
+ }, () => executeAccountSwitch(accounts[0].walletId));
+ setOpenRemoveModal(false);
+ setOpen(false);
+ };
+
+
return (
<>
+