From a658bbd349a267b8c1c24e8207706787547beb3f Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 8 Jun 2023 14:00:02 -0700 Subject: [PATCH 1/4] bump android version --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index cceb99aea..d62d2555e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -88,6 +88,6 @@ repositories { dependencies { implementation project(':expo-modules-core') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" - implementation "org.xmtp:android:0.1.7" + implementation "org.xmtp:android:0.2.0" implementation 'com.google.code.gson:gson:2.10.1' } From 3d38525680093385cbbaff72fa8c271db02626dc Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Fri, 19 May 2023 13:55:48 -0700 Subject: [PATCH 2/4] bench marking --- .../modules/xmtpreactnativesdk/XMTPModule.kt | 16 ++++++++++++---- example/src/ConversationListView.tsx | 9 +++++++++ ios/XMTPModule.swift | 8 ++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt index 0e39441d9..acb0b2ff4 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -124,10 +124,18 @@ class XMTPModule : Module() { // Generate a random wallet and set the client to that AsyncFunction("createRandom") { environment: String -> logV("createRandom") - val privateKey = PrivateKeyBuilder() - val options = - ClientOptions(api = apiEnvironments[environment] ?: apiEnvironments["dev"]!!) - val randomClient = Client().create(account = privateKey, options = options) + // Build from [8,54,32,15,250,250,23,163,203,139,84,242,45,106,250,96,177,61,164,135,38,84,50,65,173,197,194,80,219,176,224,205] + // or in hex 0836200ffafa17a3cb8b54f22d6afa60b13da48726543241adc5c250dbb0e0cd + // aka 2k many convos test wallet + // Create a ByteArray with the 32 bytes above + val privateKeyData = listOf(0x08, 0x36, 0x20, 0x0f, 0xfa, 0xfa, 0x17, 0xa3, 0xcb, 0x8b, 0x54, 0xf2, 0x2d, 0x6a, 0xfa, 0x60, 0xb1, 0x3d, 0xa4, 0x87, 0x26, 0x54, 0x32, 0x41, 0xad, 0xc5, 0xc2, 0x50, 0xdb, 0xb0, 0xe0, 0xcd) + .map { it.toByte() } + .toByteArray() + // Use hardcoded privateKey + val privateKey = PrivateKeyBuilder.buildFromPrivateKeyData(privateKeyData) + val privateKeyBuilder = PrivateKeyBuilder(privateKey) + val options = ClientOptions(api = apiEnvironments[environment] ?: apiEnvironments["dev"]!!) + val randomClient = Client().create(account = privateKeyBuilder, options = options) clients[randomClient.address] = randomClient randomClient.address } diff --git a/example/src/ConversationListView.tsx b/example/src/ConversationListView.tsx index 51da1e031..e30d3aa16 100644 --- a/example/src/ConversationListView.tsx +++ b/example/src/ConversationListView.tsx @@ -18,11 +18,20 @@ export default function ConversationListView({ const [messageCount, setMessageCount] = useState(0); async function refreshConversations() { + // Write code to time this function and divide by number of conversations + // to get an idea of how long it takes to load a conversation. + let start = Date.now(); const conversations = await client.conversations.list(); + let end = Date.now(); + console.log( + `Loaded ${conversations.length} conversations in ${end - start}ms` + ); + const allMessages = await client.listBatchMessages( conversations.map((conversation) => conversation.topic), conversations.map((conversation) => conversation.conversationID) ); + setConversations(conversations); setMessageCount(allMessages.length); } diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 2f422cb63..941d2a48a 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -124,8 +124,12 @@ public class XMTPModule: Module { // Generate a random wallet and set the client to that AsyncFunction("createRandom") { (environment: String) -> String in - let privateKey = try PrivateKey.generate() - let options = XMTP.ClientOptions(api: apiEnvironments[environment] ?? apiEnvironments["dev"]!) + // Data from hex: 0836200ffafa17a3cb8b54f22d6afa60b13da48726543241adc5c250dbb0e0cd + // aka 2k many convo test wallet + let privateKeyData = Data([8,54,32,15,250,250,23,163,203,139,84,242,45,106,250,96,177,61,164,135,38,84,50,65,173,197,194,80,219,176,224,205]) + let privateKey = try PrivateKey(privateKeyData) + // Use hardcoded privateKey for testing + let options = XMTP.ClientOptions(api: apiEnvironments[environment] ?? apiEnvironments["dev"]!) let client = try await Client.create(account: privateKey, options: options) self.clients[client.address] = client From 6e802c7c98b96421fe37b764efa5cbc9db2b9bd8 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 8 Jun 2023 14:12:19 -0700 Subject: [PATCH 3/4] Revert "bench marking" This reverts commit 3d38525680093385cbbaff72fa8c271db02626dc. --- .../modules/xmtpreactnativesdk/XMTPModule.kt | 16 ++++------------ example/src/ConversationListView.tsx | 9 --------- ios/XMTPModule.swift | 8 ++------ 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt index acb0b2ff4..0e39441d9 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -124,18 +124,10 @@ class XMTPModule : Module() { // Generate a random wallet and set the client to that AsyncFunction("createRandom") { environment: String -> logV("createRandom") - // Build from [8,54,32,15,250,250,23,163,203,139,84,242,45,106,250,96,177,61,164,135,38,84,50,65,173,197,194,80,219,176,224,205] - // or in hex 0836200ffafa17a3cb8b54f22d6afa60b13da48726543241adc5c250dbb0e0cd - // aka 2k many convos test wallet - // Create a ByteArray with the 32 bytes above - val privateKeyData = listOf(0x08, 0x36, 0x20, 0x0f, 0xfa, 0xfa, 0x17, 0xa3, 0xcb, 0x8b, 0x54, 0xf2, 0x2d, 0x6a, 0xfa, 0x60, 0xb1, 0x3d, 0xa4, 0x87, 0x26, 0x54, 0x32, 0x41, 0xad, 0xc5, 0xc2, 0x50, 0xdb, 0xb0, 0xe0, 0xcd) - .map { it.toByte() } - .toByteArray() - // Use hardcoded privateKey - val privateKey = PrivateKeyBuilder.buildFromPrivateKeyData(privateKeyData) - val privateKeyBuilder = PrivateKeyBuilder(privateKey) - val options = ClientOptions(api = apiEnvironments[environment] ?: apiEnvironments["dev"]!!) - val randomClient = Client().create(account = privateKeyBuilder, options = options) + val privateKey = PrivateKeyBuilder() + val options = + ClientOptions(api = apiEnvironments[environment] ?: apiEnvironments["dev"]!!) + val randomClient = Client().create(account = privateKey, options = options) clients[randomClient.address] = randomClient randomClient.address } diff --git a/example/src/ConversationListView.tsx b/example/src/ConversationListView.tsx index e30d3aa16..51da1e031 100644 --- a/example/src/ConversationListView.tsx +++ b/example/src/ConversationListView.tsx @@ -18,20 +18,11 @@ export default function ConversationListView({ const [messageCount, setMessageCount] = useState(0); async function refreshConversations() { - // Write code to time this function and divide by number of conversations - // to get an idea of how long it takes to load a conversation. - let start = Date.now(); const conversations = await client.conversations.list(); - let end = Date.now(); - console.log( - `Loaded ${conversations.length} conversations in ${end - start}ms` - ); - const allMessages = await client.listBatchMessages( conversations.map((conversation) => conversation.topic), conversations.map((conversation) => conversation.conversationID) ); - setConversations(conversations); setMessageCount(allMessages.length); } diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 941d2a48a..2f422cb63 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -124,12 +124,8 @@ public class XMTPModule: Module { // Generate a random wallet and set the client to that AsyncFunction("createRandom") { (environment: String) -> String in - // Data from hex: 0836200ffafa17a3cb8b54f22d6afa60b13da48726543241adc5c250dbb0e0cd - // aka 2k many convo test wallet - let privateKeyData = Data([8,54,32,15,250,250,23,163,203,139,84,242,45,106,250,96,177,61,164,135,38,84,50,65,173,197,194,80,219,176,224,205]) - let privateKey = try PrivateKey(privateKeyData) - // Use hardcoded privateKey for testing - let options = XMTP.ClientOptions(api: apiEnvironments[environment] ?? apiEnvironments["dev"]!) + let privateKey = try PrivateKey.generate() + let options = XMTP.ClientOptions(api: apiEnvironments[environment] ?? apiEnvironments["dev"]!) let client = try await Client.create(account: privateKey, options: options) self.clients[client.address] = client From 644fefbd4cfb4dc5459289bb6fe08e2d8ff13a8b Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Thu, 8 Jun 2023 14:13:06 -0700 Subject: [PATCH 4/4] fix: second load time of conversations