= T extends T ? keyof T : never
+export type Exact = P extends Builtin
+ ? P
+ : P & { [K in keyof P]: Exact
} & Record<
+ Exclude>,
+ never
+ >
+
+function longToNumber(long: Long): number {
+ if (long.gt(Number.MAX_SAFE_INTEGER)) {
+ throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER')
+ }
+ return long.toNumber()
+}
+
+if (_m0.util.Long !== Long) {
+ _m0.util.Long = Long as any
+ _m0.configure()
+}
+
+function isObject(value: any): boolean {
+ return typeof value === 'object' && value !== null
+}
+
+function isSet(value: any): boolean {
+ return value !== null && value !== undefined
+}
diff --git a/packages/status-js/src/utils/id-to-content-topic.test.ts b/packages/status-js/src/utils/id-to-content-topic.test.ts
new file mode 100644
index 00000000..10971776
--- /dev/null
+++ b/packages/status-js/src/utils/id-to-content-topic.test.ts
@@ -0,0 +1,7 @@
+import { idToContentTopic } from './id-to-content-topic'
+
+describe('idToContentTopic', () => {
+ it('should return content topic', () => {
+ expect(idToContentTopic).toBeDefined()
+ })
+})
diff --git a/packages/status-js/src/utils/id-to-content-topic.ts b/packages/status-js/src/utils/id-to-content-topic.ts
new file mode 100644
index 00000000..4fc51967
--- /dev/null
+++ b/packages/status-js/src/utils/id-to-content-topic.ts
@@ -0,0 +1,16 @@
+import { keccak256 } from 'ethereum-cryptography/keccak'
+import { bytesToHex, hexToBytes } from 'ethereum-cryptography/utils'
+
+/**
+ * waku spec: https://rfc.vac.dev/spec/23/#bridging-waku-v1-and-waku-v2
+ * status-go: https://github.com/status-im/status-go/blob/f6dc6f752a/wakuv2/common/topic.go#L66
+ */
+
+const TOPIC_LENGTH = 4
+
+export function idToContentTopic(id: string): string {
+ const hash = keccak256(hexToBytes(id))
+ const topic = hash.slice(0, TOPIC_LENGTH)
+
+ return `/waku/1/${bytesToHex(topic)}/rfc26`
+}
diff --git a/packages/status-js/src/utils/payload-to-id.ts b/packages/status-js/src/utils/payload-to-id.ts
index 9db98a21..bf721398 100644
--- a/packages/status-js/src/utils/payload-to-id.ts
+++ b/packages/status-js/src/utils/payload-to-id.ts
@@ -2,8 +2,8 @@ import { keccak256 } from 'ethereum-cryptography/keccak'
import { bytesToHex } from 'ethereum-cryptography/utils'
export function payloadToId(
- publicKey: Uint8Array,
- payload: Uint8Array
+ payload: Uint8Array,
+ publicKey: Uint8Array
): string {
const hash = keccak256(new Uint8Array([...publicKey, ...payload]))
const hex = bytesToHex(hash)
diff --git a/packages/status-js/src/wire/chat_message.spec.ts b/packages/status-js/src/wire/chat_message.spec.ts
index 123bac1c..2d97f2d6 100644
--- a/packages/status-js/src/wire/chat_message.spec.ts
+++ b/packages/status-js/src/wire/chat_message.spec.ts
@@ -8,6 +8,26 @@ import { ChatMessage, ContentType } from './chat_message'
import type { AudioContent, ImageContent, StickerContent } from './chat_message'
describe('Chat Message', () => {
+ // todo:
+ // test('Encode & decode Text message', () => {
+ // const payload = Buffer.from([1, 1])
+
+ // const imageContent: ImageContent = {
+ // image: payload,
+ // imageType: ImageType.IMAGE_TYPE_PNG,
+ // contentType: ContentType.Image,
+ // }
+
+ // const message = ChatMessage.createMessage(1, 1, 'chat-id', imageContent)
+
+ // const buf = message.encode()
+ // const dec = ChatMessage.decode(buf)
+
+ // expect(dec.contentType).toEqual(ChatMessage_ContentType.CONTENT_TYPE_IMAGE)
+ // expect(dec.image?.payload?.toString()).toEqual(payload.toString())
+ // expect(dec.image?.type).toEqual(ImageType.IMAGE_TYPE_PNG)
+ // })
+
test('Encode & decode Image message', () => {
const payload = Buffer.from([1, 1])
diff --git a/packages/status-react/package.json b/packages/status-react/package.json
index 1fbfcdeb..00a5dd9f 100644
--- a/packages/status-react/package.json
+++ b/packages/status-react/package.json
@@ -46,6 +46,7 @@
"html-entities": "^2.3.2",
"qrcode.react": "^3.0.1",
"react": "^17.0.2",
+ "react-content-loader": "^6.2.0",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"react-router-dom": "^6.3.0",
diff --git a/packages/status-react/src/components/loading/index.tsx b/packages/status-react/src/components/loading/index.tsx
new file mode 100644
index 00000000..dfd1215c
--- /dev/null
+++ b/packages/status-react/src/components/loading/index.tsx
@@ -0,0 +1,81 @@
+import React from 'react'
+import { styled } from '~/src/styles/config'
+
+import ContentLoader from 'react-content-loader'
+import { Box } from '~/src/system'
+
+const CommunityInfoLoader = () => (
+
+
+
+
+
+)
+
+const ChannelLoader = () => {
+ return (
+
+
+
+
+ )
+}
+
+export const Loading = () => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+const Wrapper = styled('div', {
+ overflow: 'hidden',
+ position: 'relative',
+ width: '100%',
+ height: '100%',
+ display: 'flex',
+ alignItems: 'stretch',
+ background: '$background',
+})
+
+const Sidebar = styled('div', {
+ display: 'none',
+ width: 304,
+ flexShrink: 0,
+ flexDirection: 'column',
+ padding: '10px 16px',
+ backgroundColor: '$gray-4',
+ overflowY: 'scroll',
+
+ '@large': {
+ display: 'flex',
+ },
+})
diff --git a/packages/status-react/src/components/main-sidebar/components/channels/index.tsx b/packages/status-react/src/components/main-sidebar/components/channels/index.tsx
index 43fe7402..21438e1c 100644
--- a/packages/status-react/src/components/main-sidebar/components/channels/index.tsx
+++ b/packages/status-react/src/components/main-sidebar/components/channels/index.tsx
@@ -1,19 +1,30 @@
import React from 'react'
import { Box } from '~/src/system'
+import { useChats } from '~/src/protocol'
import { ChannelGroup } from './channel-group'
import { ChannelItem } from './channel-item'
-const CHANNELS = {
- Public: ['welcome', 'general', 'random'],
- Internal: ['watercooler', 'pm'],
-}
export const Channels = () => {
+
+ const chats = useChats()
+
return (
-
- {Object.entries(CHANNELS).map(([group, channels]) => (
+
+ {chats.map((chat) => (
+
+ {chat.identity!.displayName}
+
+ ))}
+
+ {/* {Object.entries(community.chats).map(([group, channels]) => (
{channels.map(channel => (
{
))}
- ))}
+ ))} */}
)
}
diff --git a/packages/status-react/src/components/main-sidebar/components/community-info/community-dialog.tsx b/packages/status-react/src/components/main-sidebar/components/community-info/community-dialog.tsx
index 4f6dc2e8..e22cafd5 100644
--- a/packages/status-react/src/components/main-sidebar/components/community-info/community-dialog.tsx
+++ b/packages/status-react/src/components/main-sidebar/components/community-info/community-dialog.tsx
@@ -1,13 +1,15 @@
import React from 'react'
-import { useCommunity } from '~/src/protocol/use-community'
+import { useCommunity } from '~/src/protocol'
import { Button, CopyInput, Dialog, Flex, Grid, Text } from '~/src/system'
export const CommunityDialog = () => {
- const { name, description, publicKey } = useCommunity()
+ const { identity, publicKey='0xTODO' } = useCommunity()
+ const { displayName, description} = identity
+
return (
-