diff --git a/example/src/tests/conversationTests.ts b/example/src/tests/conversationTests.ts index c9fdf552c..4864a2a23 100644 --- a/example/src/tests/conversationTests.ts +++ b/example/src/tests/conversationTests.ts @@ -68,7 +68,7 @@ test('can find a dm by address', async () => { const alixDm = await alixClient.conversations.findOrCreateDm(boClient.address) await boClient.conversations.sync() - const boDm = await boClient.conversations.findDm(alixClient.address) + const boDm = await boClient.conversations.findDmByAddress(alixClient.address) assert( boDm?.id === alixDm.id, diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index 340677c7a..3799b21b1 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -1482,16 +1482,16 @@ test('only streams groups that can be decrypted', async () => { await alixClient.conversations.stream(async (group: Conversation) => { alixGroups.push(group) - }, 'groups') + }) await boClient.conversations.stream(async (group: Conversation) => { boGroups.push(group) - }, 'groups') + }) await caroClient.conversations.stream(async (group: Conversation) => { caroGroups.push(group) - }, 'groups') + }) await alixClient.conversations.newGroup([boClient.address]) - + await delayToPropogate() assert( alixGroups.length === 1, `alix group length should be 1 but was ${alixGroups.length}` diff --git a/example/src/types/typeTests.ts b/example/src/types/typeTests.ts index 935412bfc..226b7d49d 100644 --- a/example/src/types/typeTests.ts +++ b/example/src/types/typeTests.ts @@ -2,10 +2,12 @@ import { Client, ContentTypeId, ConversationVersion, + Dm, EncodedContent, JSContentCodec, ReactionCodec, ReplyCodec, + sendMessage, TextCodec, } from 'xmtp-react-native-sdk' @@ -52,7 +54,14 @@ class NumberCodec implements JSContentCodec { } export const typeTests = async () => { - const textClient = await Client.createRandom<[TextCodec]>({ env: 'local' }) + const keyBytes = new Uint8Array([ + 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, + 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, + ]) + const textClient = await Client.createRandom<[TextCodec]>({ + env: 'local', + dbEncryptionKey: keyBytes, + }) const textConvo = (await textClient.conversations.list())[0] await textConvo.send({ text: 'hello' }) await textConvo.send('hello') @@ -63,6 +72,7 @@ export const typeTests = async () => { const textConvo2 = new Dm(textClient, { createdAt: 123, + // @ts-expect-error topic: 'sdf', peerAddress: 'sdf', version: 'sdf', @@ -73,8 +83,6 @@ export const typeTests = async () => { await textConvo2.send(12312312) // @ts-expect-error await textConvo2.send({ wrong: 'hello' }) - await sendMessage<[TextCodec]>('0x1234', 'topic', { text: 'hello' }) - await sendMessage<[TextCodec]>('0x1234', 'topic', 'hello') // @ts-expect-error await sendMessage<[TextCodec]>('0x1234', 'topic', 12314) @@ -82,6 +90,7 @@ export const typeTests = async () => { const reactionClient = await Client.createRandom({ codecs: supportedCodecs, env: 'local', + dbEncryptionKey: keyBytes, }) const reactionConvo = (await reactionClient.conversations.list())[0] await reactionConvo.send({ @@ -111,13 +120,14 @@ export const typeTests = async () => { await reactionConvo.send({ text: 'text', }) - const keyBundle = await reactionClient.exportKeyBundle() - const keyBundleReactionClient = await Client.createFromKeyBundle< - typeof supportedCodecs - >(keyBundle, { - codecs: supportedCodecs, - env: 'local', - }) + const keyBundleReactionClient = await Client.build( + reactionClient.address, + { + codecs: supportedCodecs, + env: 'local', + dbEncryptionKey: keyBytes, + } + ) const reactionKeyBundleConvo = ( await keyBundleReactionClient.conversations.list() )[0] @@ -150,6 +160,7 @@ export const typeTests = async () => { const customContentClient = await Client.createRandom({ env: 'local', codecs: [new NumberCodec()], + dbEncryptionKey: keyBytes, }) const customContentConvo = (await customContentClient.conversations.list())[0] @@ -183,6 +194,7 @@ export const typeTests = async () => { const replyClient = await Client.createRandom({ codecs: supportedReplyCodecs, env: 'local', + dbEncryptionKey: keyBytes, }) const replyConvo = (await replyClient.conversations.list())[0] @@ -240,8 +252,9 @@ export const typeTests = async () => { const convoClient = await Client.createRandom({ env: 'local', codecs: [new NumberCodec()], + dbEncryptionKey: keyBytes, }) - const convos = await convoClient.conversations.listConversations() + const convos = await convoClient.conversations.list() const firstConvo = convos[0] if (firstConvo.version === ConversationVersion.GROUP) { const groupName = firstConvo.name @@ -252,7 +265,6 @@ export const typeTests = async () => { // @ts-expect-error const groupName = firstConvo.name } else { - const peerAddress = firstConvo.peerAddress // @ts-expect-error const peerAddress2 = firstConvo.peerInboxId() } diff --git a/src/lib/Conversations.ts b/src/lib/Conversations.ts index bd0873056..a3b808fca 100644 --- a/src/lib/Conversations.ts +++ b/src/lib/Conversations.ts @@ -111,8 +111,10 @@ export default class Conversations< * * @returns {Promise} A Promise that resolves to a Dm or undefined if not found. */ - async findDm(address: Address): Promise | undefined> { - return await XMTPModule.findDm(this.client, address) + async findDmByAddress( + address: Address + ): Promise | undefined> { + return await XMTPModule.findDmByAddress(this.client, address) } /** diff --git a/src/lib/Dm.ts b/src/lib/Dm.ts index 9a54216d7..f78daf860 100644 --- a/src/lib/Dm.ts +++ b/src/lib/Dm.ts @@ -47,7 +47,7 @@ export class Dm * @returns {Promise} A Promise that resolves to a InboxId. */ async peerInboxId(): Promise { - return XMTP.listPeerInboxId(this.client, this.id) + return XMTP.dmPeerInboxId(this.client, this.id) } /** diff --git a/src/lib/Group.ts b/src/lib/Group.ts index 38861c938..1e74f5dc7 100644 --- a/src/lib/Group.ts +++ b/src/lib/Group.ts @@ -98,11 +98,7 @@ export class Group< content = { text: content } } - return await XMTP.sendMessage( - this.client.inboxId, - this.id, - content - ) + return await XMTP.sendMessage(this.client.inboxId, this.id, content) } catch (e) { console.info('ERROR in send()', e.message) throw e diff --git a/src/lib/Signer.ts b/src/lib/Signer.ts index 97946beba..efc994d27 100644 --- a/src/lib/Signer.ts +++ b/src/lib/Signer.ts @@ -14,8 +14,6 @@ export function getSigner(wallet: Signer | WalletClient | null): Signer | null { if (!wallet) { return null } - console.log("Lopi444") - if (isWalletClient(wallet)) { return convertWalletClientToSigner(wallet) }