From 098d0d4eec03e8847847be2187b566fb4a5d8e9b Mon Sep 17 00:00:00 2001 From: Juan Manuel <44899916+angarita-dev@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:13:05 -0500 Subject: [PATCH 01/17] Added getPrincipalFromPem handler --- source/Background/Keyring/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/Background/Keyring/index.js b/source/Background/Keyring/index.js index 79ec8537..c9b564fa 100644 --- a/source/Background/Keyring/index.js +++ b/source/Background/Keyring/index.js @@ -110,6 +110,7 @@ export const HANDLER_TYPES = { 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', }; export const getKeyringErrorMessage = (type) => ({ @@ -484,6 +485,8 @@ export const getKeyringHandler = (type, keyring) => ({ return { error: e.message }; } }, + [HANDLER_TYPES.GET_PRINCIPAL_FROM_PEM]: async (params) => keyring.getPrincipalFromPem(params), + }[type]); export const getContacts = () => new Promise((resolve, reject) => { From 0d42a41131ea08af4ef5359e462236110849b6a2 Mon Sep 17 00:00:00 2001 From: Juan Manuel <44899916+angarita-dev@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:13:28 -0500 Subject: [PATCH 02/17] Call getPrincipalFromPem --- .../Views/ImportWallet/Steps/Step2.jsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/views/Extension/Views/ImportWallet/Steps/Step2.jsx b/source/views/Extension/Views/ImportWallet/Steps/Step2.jsx index 4691dcb6..80614fd5 100644 --- a/source/views/Extension/Views/ImportWallet/Steps/Step2.jsx +++ b/source/views/Extension/Views/ImportWallet/Steps/Step2.jsx @@ -3,7 +3,7 @@ import Grid from "@material-ui/core/Grid"; import useStyles from "../styles"; import React, { useState } from "react"; import { useRouter } from "@components/Router"; -import { HANDLER_TYPES, sendMessage } from "@background/Keyring"; +import { HANDLER_TYPES, sendMessage, asyncSendMessage } from "@background/Keyring"; import Picker from "emoji-picker-react"; import { useEffect } from "react"; import { useTranslation } from "react-i18next"; @@ -17,11 +17,27 @@ const Step2 = ({ userPemFile }) => { const [walletName, setWalletName] = useState(""); // add deafault wallet name, for example the next wallet not used number const [currentEmoji, setCurrentEmoji] = useState("😎"); // add default emoji, not used in other wallets const [openEmojiSelector, setOpenEmojiSelector] = useState(false); + const [importedPrincipal, setImportedPrincipal] = useState(); const { navigator } = useRouter(); const classes = useStyles(); + useEffect(() => { + let fileReader = new FileReader(); + fileReader.readAsText(userPemFile); + fileReader.onloadend = () => { + const content = fileReader.result; + + asyncSendMessage({ + type: HANDLER_TYPES.GET_PRINCIPAL_FROM_PEM, + params: { pem: content }, + }).then(setImportedPrincipal); + }; + }, [userPemFile]); + + console.log('imported ->', importedPrincipal); + useEffect(() => { if (walletName && walletName !== "") { setDisabled(true); From 560f44eb93c7ad363d58543c85120c683135c91e Mon Sep 17 00:00:00 2001 From: Juan Manuel <44899916+angarita-dev@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:14:48 -0500 Subject: [PATCH 03/17] Remove extra line --- source/Background/Keyring/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Background/Keyring/index.js b/source/Background/Keyring/index.js index c9b564fa..df9fdbf1 100644 --- a/source/Background/Keyring/index.js +++ b/source/Background/Keyring/index.js @@ -486,7 +486,6 @@ export const getKeyringHandler = (type, keyring) => ({ } }, [HANDLER_TYPES.GET_PRINCIPAL_FROM_PEM]: async (params) => keyring.getPrincipalFromPem(params), - }[type]); export const getContacts = () => new Promise((resolve, reject) => { From 66c1f2cacf0f778330c6dad238dbc58efb12bc5b Mon Sep 17 00:00:00 2001 From: Juan Manuel <44899916+angarita-dev@users.noreply.github.com> Date: Thu, 20 Oct 2022 15:10:56 -0500 Subject: [PATCH 04/17] controller version bump --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d1426ef9..2cea2eab 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@metamask/post-message-stream": "^4.0.0", "@psychedelic/browser-rpc": "2.1.0", "@psychedelic/dab-js": "1.5.0-beta.1", - "@psychedelic/plug-controller": "0.24.0", + "@psychedelic/plug-controller": "0.24.1", "@psychedelic/plug-inpage-provider": "^2.3.1", "@reduxjs/toolkit": "^1.6.0", "advanced-css-reset": "^1.2.2", diff --git a/yarn.lock b/yarn.lock index 8772bbc4..9989b11f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1787,10 +1787,10 @@ cross-fetch "^3.1.4" crypto-js "^4.1.1" -"@psychedelic/plug-controller@0.24.0": - version "0.24.0" - resolved "https://npm.pkg.github.com/download/@Psychedelic/plug-controller/0.24.0/30ec34c8ea70423a474a0870769b705da9c6cb6a#30ec34c8ea70423a474a0870769b705da9c6cb6a" - integrity sha512-Jn8vonbFkp9TC3vpu8p/u5VTbwF6lTZN99CkuDC/XxR5vAfoEJuANfO17odbnl46FnkycBxk2bo0zXuW5k51GA== +"@psychedelic/plug-controller@0.24.1": + version "0.24.1" + resolved "https://npm.pkg.github.com/download/@Psychedelic/plug-controller/0.24.1/577dca2ded7248d130ab2e54b3e7ab65cba72d2a#577dca2ded7248d130ab2e54b3e7ab65cba72d2a" + integrity sha512-w/k35UZM3eFxFLXrQv6iHrofCQ6qxA8RdoOVy4WDVBaglf5NRKd3gFwuM+sMxBC6kY2uTpBG+pf2M7wKYUWMAQ== dependencies: "@dfinity/agent" "0.9.3" "@dfinity/candid" "0.9.3" From 64ae4e6933cbbabac6d95f70f05feb3928e14545 Mon Sep 17 00:00:00 2001 From: Juan Manuel <44899916+angarita-dev@users.noreply.github.com> Date: Thu, 20 Oct 2022 15:11:31 -0500 Subject: [PATCH 05/17] Added InfoModal & WalletDetailItem components --- source/components/InfoModal/index.jsx | 58 +++++++++++++++++ source/components/InfoModal/styles.js | 12 ++++ source/components/WalletDetailItem/index.jsx | 66 ++++++++++++++++++++ source/components/WalletDetailItem/styles.js | 33 ++++++++++ source/components/index.js | 2 + 5 files changed, 171 insertions(+) create mode 100644 source/components/InfoModal/index.jsx create mode 100644 source/components/InfoModal/styles.js create mode 100644 source/components/WalletDetailItem/index.jsx create mode 100644 source/components/WalletDetailItem/styles.js diff --git a/source/components/InfoModal/index.jsx b/source/components/InfoModal/index.jsx new file mode 100644 index 00000000..20412330 --- /dev/null +++ b/source/components/InfoModal/index.jsx @@ -0,0 +1,58 @@ +import React from 'react'; +import extension from 'extensionizer'; +import PropTypes from 'prop-types'; +import { Typography } from '@material-ui/core'; +import { useTranslation } from 'react-i18next'; + +import { icIdsUrl } from '@shared/constants/urls'; +import { Button, Dialog, LinkButton } from '@components'; + +import useStyles from './styles'; + +const InfoModal = ({ + title, isOpen, content, onClose, buttonText, understandButtonTestId, learnMoreButtonTestId, +}) => { + const { t } = useTranslation(); + const classes = useStyles(); + return ( + + {content} +