fixed ethereum group message signing UI bug

This commit is contained in:
2023-10-26 16:20:46 -04:00
parent fc75eb5579
commit 82ff3502e2
3 changed files with 25 additions and 15 deletions

View File

@@ -15,7 +15,7 @@
let btnEl: HTMLElement; let btnEl: HTMLElement;
let address: string = ''; let address: string = '';
let loadingRooms: boolean = false; let loadingRooms: boolean = false;
let groups: string[] = []; let groups: { name: string }[] = [];
let isConnected = false; let isConnected = false;
const chains = [mainnet, arbitrum, optimism, base, polygon]; const chains = [mainnet, arbitrum, optimism, base, polygon];
const metadata = { const metadata = {
@@ -37,7 +37,7 @@
const result = ethereumGroupRequest(commitment, signature); const result = ethereumGroupRequest(commitment, signature);
} }
} else { } 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; loadingRooms = true;
getEthAddressRoomNames($selectedServer, address) getEthAddressRoomNames($selectedServer, address)
.then((groupNames) => { .then((groupNames) => {
console.log(groupNames);
loadingRooms = false; loadingRooms = false;
groups = groupNames; groups = groupNames;
}) })
@@ -76,7 +77,7 @@
<div class="flex flex-col gap-3 justify-between"> <div class="flex flex-col gap-3 justify-between">
<div> <div>
<h3 class="h4 mb-2">Step 1: Connect your wallet</h3> <h3 class="h4 mb-2"><span class="text-success-500">Step 1:</span> Connect your wallet</h3>
<button bind:this={btnEl} class="btn variant-outline-tertiary">Connect</button> <button bind:this={btnEl} class="btn variant-outline-tertiary">Connect</button>
</div> </div>
{#if isConnected} {#if isConnected}
@@ -87,12 +88,13 @@
<p>You are eligible for the following Ethereum Groups:</p> <p>You are eligible for the following Ethereum Groups:</p>
<ul> <ul>
{#each groups as group} {#each groups as group}
<li>{group}</li> <ins class="ins border-y border-success-800">{group.name}</ins>
{/each} {/each}
</ul> </ul>
<div> <div>
<h3 class="h4 mb-2"> <h3 class="h4 my-2">
Step 2: Sign your Identity Commitment to prove ownership of this address <span class="text-success-500">Step 2:</span> Sign your Identity Commitment to prove ownership
of this address
</h3> </h3>
<button on:click={proveOwnership} id="btn" class="btn variant-outline-success">Sign</button> <button on:click={proveOwnership} id="btn" class="btn variant-outline-success">Sign</button>
</div> </div>

View File

@@ -33,8 +33,8 @@ export async function getServerData(serverUrl: string): Promise<ServerI> {
export async function getEthAddressRoomNames( export async function getEthAddressRoomNames(
server: string, server: string,
ethAddress: string ethAddress: string
): Promise<string[]> { ): Promise<{ name: string }[]> {
return get([server, `gateway/eth/group/${ethAddress}`]) as Promise<string[]>; return get([server, `gateway/eth/group/${ethAddress}`]) as Promise<{ name: string }[]>;
} }
export async function postInviteCode( export async function postInviteCode(

View File

@@ -59,20 +59,28 @@ export function createIdentity(regenerate = false): 'created' | 'exists' | 'unsa
} }
export function getIdentity(): IdentityStoreI | null { export function getIdentity(): IdentityStoreI | null {
const decryptedIdentity = get(identityKeyStore) as unknown as IdentityStoreI; const idExists = get(identityExists);
if (idExists === 'safe') {
if (decryptedIdentity._commitment) { return get(identityKeyStore) as unknown as IdentityStoreI;
return decryptedIdentity; } else if (idExists === 'unsafe') {
} else {
const identity = get(identityStore); const identity = get(identityStore);
if (identity._commitment?.length > 0) { if (identity._commitment?.length > 0) {
alertQueue.enqueue('Identity not encrypted, set a password!', 'warning'); alertQueue.enqueue('Identity not encrypted, set a password!', 'warning');
return identity; return identity;
} else { } 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 { export function getCommitment(): string | null {