diff --git a/android/build.gradle b/android/build.gradle index 6fc236be..c6be409e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -98,7 +98,7 @@ repositories { dependencies { implementation project(':expo-modules-core') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" - implementation "org.xmtp:android:3.0.11" + implementation "org.xmtp:android:3.0.12" implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.facebook.react:react-native:0.71.3' implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1" diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt index a4d2db31..4dbead25 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -332,14 +332,14 @@ class XMTPModule : Module() { } } - AsyncFunction("build") Coroutine { address: String, dbEncryptionKey: List, authParams: String -> + AsyncFunction("build") Coroutine { address: String, inboxId: String?, dbEncryptionKey: List, authParams: String -> withContext(Dispatchers.IO) { logV("build") val options = clientOptions( dbEncryptionKey, authParams, ) - val client = Client().build(address = address, options = options) + val client = Client().build(address = address, options = options, inboxId = inboxId) ContentJson.Companion clients[client.installationId] = client ClientWrapper.encodeToObj(client) diff --git a/example/src/tests/groupPerformanceTests.ts b/example/src/tests/groupPerformanceTests.ts index 1be81446..958eef8a 100644 --- a/example/src/tests/groupPerformanceTests.ts +++ b/example/src/tests/groupPerformanceTests.ts @@ -2,7 +2,17 @@ import Config from 'react-native-config' import RNFS from 'react-native-fs' import { PrivateKeyAccount, privateKeyToAccount } from 'viem/accounts' -import { Client, Dm, Group, GroupUpdatedCodec, ReactionCodec, RemoteAttachmentCodec, ReplyCodec, Signer, StaticAttachmentCodec } from 'xmtp-react-native-sdk' +import { + Client, + Dm, + Group, + GroupUpdatedCodec, + ReactionCodec, + RemoteAttachmentCodec, + ReplyCodec, + Signer, + StaticAttachmentCodec, +} from 'xmtp-react-native-sdk' import { Test, assert, createClients } from './test-utils' import { Wallet } from 'ethers' @@ -108,7 +118,7 @@ test('building and creating', async () => { let start = performance.now() const alix = await Client.create(alixWallet, { - env: 'local', + env: 'dev', appVersion: 'Testing/0.0.0', dbEncryptionKey: keyBytes, dbDirectory: dbDirPath, @@ -131,7 +141,7 @@ test('building and creating', async () => { start = performance.now() const alixBuild = await Client.build(alixWallet.address, { - env: 'local', + env: 'dev', appVersion: 'Testing/0.0.0', dbEncryptionKey: keyBytes, dbDirectory: dbDirPath, @@ -152,6 +162,28 @@ test('building and creating', async () => { end = performance.now() console.log(`Alix build registered group updated codec in ${end - start}ms`) + start = performance.now() + const alixBuild2 = await Client.build( + alixWallet.address, + { + env: 'dev', + appVersion: 'Testing/0.0.0', + dbEncryptionKey: keyBytes, + dbDirectory: dbDirPath, + codecs: [ + new ReactionCodec(), + new ReplyCodec(), + new GroupUpdatedCodec(), + new StaticAttachmentCodec(), + new RemoteAttachmentCodec(), + ], + }, + alix.inboxId + ) + await alixBuild2.register(new GroupUpdatedCodec()) + end = performance.now() + console.log(`Built a client with inboxId in ${end - start}ms`) + start = performance.now() await alix.deleteLocalDatabase() end = performance.now() @@ -162,10 +194,9 @@ test('building and creating', async () => { end = performance.now() console.log(`Droped a client in ${end - start}ms`) - start = performance.now() await Client.create(alixWallet, { - env: 'local', + env: 'dev', appVersion: 'Testing/0.0.0', dbEncryptionKey: keyBytes, dbDirectory: dbDirPath, diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index 3e4b04f4..939babfa 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -26,7 +26,7 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency "MessagePacker" - s.dependency "XMTP", "= 3.0.12" + s.dependency "XMTP", "= 3.0.13" s.dependency 'CSecp256k1', '~> 0.2' s.dependency "SQLCipher", "= 4.5.7" end diff --git a/src/index.ts b/src/index.ts index 7ed81248..01219a2f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -173,7 +173,8 @@ export async function build( dbEncryptionKey: Uint8Array, appVersion?: string | undefined, dbDirectory?: string | undefined, - historySyncUrl?: string | undefined + historySyncUrl?: string | undefined, + inboxId?: InboxId | undefined ): Promise { const authParams: AuthParams = { environment, @@ -183,6 +184,7 @@ export async function build( } return await XMTPModule.build( address, + inboxId, Array.from(dbEncryptionKey), JSON.stringify(authParams) ) diff --git a/src/lib/Client.ts b/src/lib/Client.ts index 36b065e9..93a14f98 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -204,7 +204,8 @@ export class Client< ContentCodecs extends DefaultContentTypes = DefaultContentTypes, >( address: Address, - options: ClientOptions & { codecs?: ContentCodecs } + options: ClientOptions & { codecs?: ContentCodecs }, + inboxId?: InboxId | undefined ): Promise> { if (options.dbEncryptionKey.length !== 32) { throw new Error('Must pass an encryption key that is exactly 32 bytes.') @@ -215,7 +216,8 @@ export class Client< options.dbEncryptionKey, options.appVersion, options.dbDirectory, - options.historySyncUrl + options.historySyncUrl, + inboxId ) return new Client(