From 996c1205da0b8bbbe2fc6ab6292905435316dfa2 Mon Sep 17 00:00:00 2001
From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com>
Date: Tue, 12 Sep 2023 14:40:22 +0200
Subject: [PATCH] Identity key improvements (#70)
---
src/components/Modals/ImportKey/index.tsx | 16 ++++--
src/components/Modals/ShareIdentity/index.tsx | 17 +------
src/consts/index.ts | 4 +-
src/pages/transfer.tsx | 17 ++++---
src/utils/identityKey.ts | 49 +++++++++++++++++--
src/utils/keyStore.ts | 8 +++
6 files changed, 81 insertions(+), 30 deletions(-)
diff --git a/src/components/Modals/ImportKey/index.tsx b/src/components/Modals/ImportKey/index.tsx
index f9de790..4ad0a85 100644
--- a/src/components/Modals/ImportKey/index.tsx
+++ b/src/components/Modals/ImportKey/index.tsx
@@ -34,13 +34,23 @@ export const ImportKeyModal = ({
toastError("You don't have an identity yet.");
return;
}
+ let key = identityKey;
+ if (key.startsWith("identityNo:")) {
+ const indexOfSeparator = key.indexOf(';');
+ key = key.substring(indexOfSeparator + 1);
+ }
confirm({
description:
'This operation updates the identity key and you might lose access to your addresses.',
}).then(() => {
- KeyStore.updateIdentityKey(identityNo, identityKey);
- toastSuccess('Successfully imported identity key.');
- onClose();
+ try {
+ KeyStore.updateIdentityKey(identityNo, key);
+ toastSuccess('Successfully imported identity key.');
+ } catch (e) {
+ toastError("Invalid identity key");
+ } finally {
+ onClose();
+ }
});
};
diff --git a/src/components/Modals/ShareIdentity/index.tsx b/src/components/Modals/ShareIdentity/index.tsx
index 458e7b3..9517c03 100644
--- a/src/components/Modals/ShareIdentity/index.tsx
+++ b/src/components/Modals/ShareIdentity/index.tsx
@@ -47,7 +47,7 @@ export const ShareIdentityModal = ({
try {
const sharedKey = IdentityKey.getSharedKey(identityKey, selectedChains);
- setSharedKey(sharedKey);
+ setSharedKey(`identityNo:${identityNo};`.concat(sharedKey));
} catch (e: any) {
toastError(`Failed to get the identity key. Error: ${e.message}`);
}
@@ -62,17 +62,6 @@ export const ShareIdentityModal = ({
Share Identity
-
- {`Identity No: ${identityNo}`}
- toastSuccess('Identity no copied to clipboard.')}
- >
-
-
-
-
-
Specify the chains that the receiver of the identity key will be
able to access:
@@ -110,9 +99,7 @@ export const ShareIdentityModal = ({
- {'This identity key has to be sent alongside the identity no.'}
-
- {"Without it, the receiver won't have access to your addresses"}
+ {'This identity key will be sent alongside the identity no.'}