-
-
-
-
+
{#if $profile.signer !== undefined}
-
goto('/post/new')}>
- Share freely...
-
+
+
(showChat = false)}>Personas
+
(showChat = true)}>
+ Chats
+ {#if $chats.unread > 0}
+
{$chats.unread}
+ {/if}
+
- {:else}
-
{/if}
- {#if $posts.loading}
-
Loading posts...
- {:else if $posts.posts.length == 0}
-
There are no posts yet
+ {#if showChat}
+
Chat not implemented yet
+ {:else if $personas.loading}
+
Loading personas...
{:else}
-
- {#each $posts.posts as post}
-
+ {#if $personas.draft.length !== 0 && $profile.signer !== undefined}
+ Draft personas
+
diff --git a/packages/ui/src/routes/persona/[id]/+page.svelte b/packages/ui/src/routes/persona/[id]/+page.svelte
new file mode 100644
index 0000000..ba8a452
--- /dev/null
+++ b/packages/ui/src/routes/persona/[id]/+page.svelte
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
goto(ROUTES.HOME)} />
+
+
+ {#if $profile.signer !== undefined}
+
+
goto(ROUTES.POST_NEW($page.params.id))}>
+ Share freely...
+
+
+ {/if}
+
+ {#if $posts.loading}
+
Loading posts...
+ {:else if $posts.posts.length == 0}
+
There are no posts yet
+ {:else}
+
+ {#each $posts.posts as post}
+
+ {/each}
+
+ {/if}
+
+
+
+
diff --git a/packages/ui/src/routes/post/new/+page.svelte b/packages/ui/src/routes/persona/[id]/post/new/+page.svelte
similarity index 87%
rename from packages/ui/src/routes/post/new/+page.svelte
rename to packages/ui/src/routes/persona/[id]/post/new/+page.svelte
index fd1bd4d..f5611bf 100644
--- a/packages/ui/src/routes/post/new/+page.svelte
+++ b/packages/ui/src/routes/persona/[id]/post/new/+page.svelte
@@ -7,10 +7,13 @@
import { goto } from '$app/navigation'
import { ROUTES } from '$lib/routes'
import {
+ createIdentity,
generateGroupProof,
getContractGroup,
getGlobalAnonymousFeed,
getRandomExternalNullifier,
+ joinGroupOffChain,
+ joinGroupOnChain,
} from '$lib/services/index'
import { posts } from '$lib/stores/post'
import { hashPost, createPost } from '$lib/services/posts'
@@ -27,12 +30,21 @@
const signer = $profile.signer
if (!signer) throw new Error('no signer')
- const identity = $profile.identities.anonymous
- if (!identity) throw new Error('no identity')
+ const defaultIdentity = 'anonymous'
+
+ const identity = await createIdentity(signer, defaultIdentity)
const globalAnonymousFeed = getGlobalAnonymousFeed(signer)
const group = await getContractGroup(globalAnonymousFeed)
+ const commitment = identity.commitment
+
+ if (!group.members.includes(commitment)) {
+ joinGroupOffChain(group, commitment)
+ const txres = await joinGroupOnChain(globalAnonymousFeed, commitment)
+ console.log(txres)
+ }
+
const post = { text: postText }
const signal = hashPost(post)
@@ -45,7 +57,6 @@
posts.add({
timestamp: Date.now(),
text: postText,
- tx: '',
})
goto(ROUTES.HOME)
} catch (error) {
diff --git a/packages/ui/src/routes/persona/new/+page.svelte b/packages/ui/src/routes/persona/new/+page.svelte
new file mode 100644
index 0000000..70940b3
--- /dev/null
+++ b/packages/ui/src/routes/persona/new/+page.svelte
@@ -0,0 +1,35 @@
+
+
+
history.back()} />
+Create persona
+
+
+
+
+
+
+
+ history.back()} />
+ {
+ $personas.draft
+ }}
+/>
diff --git a/packages/ui/src/routes/profile/+page.svelte b/packages/ui/src/routes/profile/+page.svelte
index d897bd1..103c4bf 100644
--- a/packages/ui/src/routes/profile/+page.svelte
+++ b/packages/ui/src/routes/profile/+page.svelte
@@ -6,15 +6,7 @@
import Wallet from '$lib/components/icons/wallet.svelte'
import WalletInfo from '$lib/components/wallet-info.svelte'
import { formatAddress } from '$lib/utils'
- import {
- connectWallet,
- canConnectWallet,
- createIdentity,
- getGlobalAnonymousFeed,
- getContractGroup,
- joinGroupOffChain,
- joinGroupOnChain,
- } from '$lib/services'
+ import { connectWallet, canConnectWallet } from '$lib/services'
import { profile } from '$lib/stores/profile'
let y: number
@@ -25,24 +17,9 @@
const handleConnect = async () => {
try {
const signer = await connectWallet()
- $profile.signer = signer
+ const address = await signer.getAddress()
- const defaultIdentity = 'anonymous'
-
- const identity = await createIdentity(signer, defaultIdentity)
-
- $profile.identities = { ...$profile.identities, [defaultIdentity]: identity }
-
- const globalAnonymousFeed = getGlobalAnonymousFeed(signer)
- const group = await getContractGroup(globalAnonymousFeed)
-
- const commitment = identity.commitment
-
- if (!group.members.includes(commitment)) {
- joinGroupOffChain(group, commitment)
- const txres = await joinGroupOnChain(globalAnonymousFeed, commitment)
- console.log(txres)
- }
+ $profile = { signer, address }
} catch (err) {
error = err as Error
}
@@ -98,20 +75,11 @@
variant="primary"
icon={Logout}
label="Logout"
- on:click={() => ($profile.signer = undefined)}
+ on:click={() => ($profile = {})}
disabled={!$profile.signer}
/>
{/if}
-
-
- {#each Object.entries($profile.identities) as [name, identity]}
-
{name}
-
commitment: {identity.getCommitment().toString(16)}
-
nullifier: {identity.getNullifier().toString(16)}
-
trapdoor: {identity.getTrapdoor().toString(16)}
- {/each}
-
diff --git a/packages/ui/tests/test.ts b/packages/ui/tests/test.ts
index 1433959..14d9855 100644
--- a/packages/ui/tests/test.ts
+++ b/packages/ui/tests/test.ts
@@ -3,5 +3,5 @@ import { expect, test } from '@playwright/test'
test('index page has expected header', async ({ page }) => {
await page.goto(ROUTES.HOME)
- expect(await page.textContent('span')).toBe('The Outlet')
+ expect(await page.textContent('span')).toBe('Kurate')
})