From 82ff3502e21ac7352f1264d7b3cc77816f57f65a Mon Sep 17 00:00:00 2001 From: AtHeartEngineer Date: Thu, 26 Oct 2023 16:20:46 -0400 Subject: [PATCH] fixed ethereum group message signing UI bug --- .../components/Gateways/EthereumGroup.svelte | 14 +++++++----- src/lib/services/server.ts | 4 ++-- src/lib/utils/identity.ts | 22 +++++++++++++------ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/lib/components/Gateways/EthereumGroup.svelte b/src/lib/components/Gateways/EthereumGroup.svelte index b6364c5..4c43362 100644 --- a/src/lib/components/Gateways/EthereumGroup.svelte +++ b/src/lib/components/Gateways/EthereumGroup.svelte @@ -15,7 +15,7 @@ let btnEl: HTMLElement; let address: string = ''; let loadingRooms: boolean = false; - let groups: string[] = []; + let groups: { name: string }[] = []; let isConnected = false; const chains = [mainnet, arbitrum, optimism, base, polygon]; const metadata = { @@ -37,7 +37,7 @@ const result = ethereumGroupRequest(commitment, signature); } } else { - alertQueue.enqueue('Error getting Identity', 'error'); + alertQueue.enqueue("Unable to sign Identity Commitment, can't access identity", 'warning'); } } @@ -59,6 +59,7 @@ loadingRooms = true; getEthAddressRoomNames($selectedServer, address) .then((groupNames) => { + console.log(groupNames); loadingRooms = false; groups = groupNames; }) @@ -76,7 +77,7 @@
-

Step 1: Connect your wallet

+

Step 1: Connect your wallet

{#if isConnected} @@ -87,12 +88,13 @@

You are eligible for the following Ethereum Groups:

-

- Step 2: Sign your Identity Commitment to prove ownership of this address +

+ Step 2: Sign your Identity Commitment to prove ownership + of this address

diff --git a/src/lib/services/server.ts b/src/lib/services/server.ts index 5bd7f28..3e575e5 100644 --- a/src/lib/services/server.ts +++ b/src/lib/services/server.ts @@ -33,8 +33,8 @@ export async function getServerData(serverUrl: string): Promise { export async function getEthAddressRoomNames( server: string, ethAddress: string -): Promise { - return get([server, `gateway/eth/group/${ethAddress}`]) as Promise; +): Promise<{ name: string }[]> { + return get([server, `gateway/eth/group/${ethAddress}`]) as Promise<{ name: string }[]>; } export async function postInviteCode( diff --git a/src/lib/utils/identity.ts b/src/lib/utils/identity.ts index c372873..391c2ed 100644 --- a/src/lib/utils/identity.ts +++ b/src/lib/utils/identity.ts @@ -59,20 +59,28 @@ export function createIdentity(regenerate = false): 'created' | 'exists' | 'unsa } export function getIdentity(): IdentityStoreI | null { - const decryptedIdentity = get(identityKeyStore) as unknown as IdentityStoreI; - - if (decryptedIdentity._commitment) { - return decryptedIdentity; - } else { + const idExists = get(identityExists); + if (idExists === 'safe') { + return get(identityKeyStore) as unknown as IdentityStoreI; + } else if (idExists === 'unsafe') { const identity = get(identityStore); if (identity._commitment?.length > 0) { alertQueue.enqueue('Identity not encrypted, set a password!', 'warning'); return identity; } else { - alertQueue.enqueue('Identity not created, create an identity!', 'warning'); + alertQueue.enqueue( + 'Problem retrieving identity, please unlock and restore your identity', + 'warning' + ); + return null; } + } else if (idExists === 'encrypted') { + alertQueue.enqueue('Unlock Identity!', 'error'); + return null; + } else { + alertQueue.enqueue('Identity not created, create an identity!', 'warning'); + return null; } - return null; } export function getCommitment(): string | null {