From f246dc282fd4f47b2aea7d404d8cb247162fdf03 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 1 Jul 2024 12:50:11 -0700 Subject: [PATCH 1/5] feat: update the v2 to all be backed by rust --- android/build.gradle | 5 ++--- ios/XMTPReactNative.podspec | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 28ed1806b..b92a17266 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -98,8 +98,7 @@ repositories { dependencies { implementation project(':expo-modules-core') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" - implementation "org.xmtp:android:0.11.2" + implementation "org.xmtp:android:0.14.0" 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" -} + implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1"} diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index 22a28797f..b16799339 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -26,5 +26,5 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency 'secp256k1.swift' s.dependency "MessagePacker" - s.dependency "XMTP", "= 0.10.9" + s.dependency "XMTP", "= 0.13.0" end From 9ea3f6d3f44486d558330f5a4458dbc68938a55a Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 1 Jul 2024 12:52:12 -0700 Subject: [PATCH 2/5] fix up the coroutine --- .../modules/xmtpreactnativesdk/XMTPModule.kt | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt index b5278afbc..d43acaaf8 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -299,20 +299,24 @@ class XMTPModule : Module() { // // Client API - AsyncFunction("canMessage") { clientAddress: String, peerAddress: String -> - logV("canMessage") - val client = clients[clientAddress] ?: throw XMTPException("No client") + AsyncFunction("canMessage") Coroutine { clientAddress: String, peerAddress: String -> + withContext(Dispatchers.IO) { + logV("canMessage") + val client = clients[clientAddress] ?: throw XMTPException("No client") - client.canMessage(peerAddress) + client.canMessage(peerAddress) + } } - AsyncFunction("staticCanMessage") { peerAddress: String, environment: String, appVersion: String? -> - try { - logV("staticCanMessage") - val options = ClientOptions(api = apiEnvironments(environment, appVersion)) - Client.canMessage(peerAddress = peerAddress, options = options) - } catch (e: Exception) { - throw XMTPException("Failed to create client: ${e.message}") + AsyncFunction("staticCanMessage") Coroutine { peerAddress: String, environment: String, appVersion: String? -> + withContext(Dispatchers.IO) { + try { + logV("staticCanMessage") + val options = ClientOptions(api = apiEnvironments(environment, appVersion)) + Client.canMessage(peerAddress = peerAddress, options = options) + } catch (e: Exception) { + throw XMTPException("Failed to create client: ${e.message}") + } } } @@ -583,14 +587,15 @@ class XMTPModule : Module() { var consentProof: ConsentProofPayload? = null if (consentProofPayload.isNotEmpty()) { - val consentProofDataBytes = consentProofPayload.foldIndexed(ByteArray(consentProofPayload.size)) { i, a, v -> - a.apply { - set( - i, - v.toByte() - ) + val consentProofDataBytes = + consentProofPayload.foldIndexed(ByteArray(consentProofPayload.size)) { i, a, v -> + a.apply { + set( + i, + v.toByte() + ) + } } - } consentProof = ConsentProofPayload.parseFrom(consentProofDataBytes) } From eb3a9e2c6f688b6ea74ec47bc47d44930ff2fc6e Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 1 Jul 2024 13:01:11 -0700 Subject: [PATCH 3/5] bump the ios version --- example/ios/Podfile.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 660d9a938..a313e030e 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -56,7 +56,7 @@ PODS: - hermes-engine/Pre-built (= 0.71.14) - hermes-engine/Pre-built (0.71.14) - libevent (2.1.12) - - LibXMTP (0.4.4-beta5) + - LibXMTP (0.5.4-beta0) - Logging (1.0.0) - MessagePacker (0.4.7) - MMKV (1.3.5): @@ -322,7 +322,7 @@ PODS: - React-Core - react-native-encrypted-storage (4.0.3): - React-Core - - react-native-get-random-values (1.10.0): + - react-native-get-random-values (1.11.0): - React-Core - react-native-mmkv (2.11.0): - MMKV (>= 1.2.13) @@ -445,16 +445,16 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.10.9): + - XMTP (0.13.0): - Connect-Swift (= 0.12.0) - GzipSwift - - LibXMTP (= 0.4.4-beta5) + - LibXMTP (= 0.5.4-beta0) - web3.swift - XMTPReactNative (0.1.0): - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.10.9) + - XMTP (= 0.13.0) - Yoga (1.14.0) DEPENDENCIES: @@ -701,7 +701,7 @@ SPEC CHECKSUMS: GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - LibXMTP: e2fb601691981900099551ff3e05621bd73dccf1 + LibXMTP: 549e85c40f00957be3e114a823a2887cdcf5817a Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26 MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02 MMKV: 506311d0494023c2f7e0b62cc1f31b7370fa3cfb @@ -724,7 +724,7 @@ SPEC CHECKSUMS: react-native-blob-util: d8fa1a7f726867907a8e43163fdd8b441d4489ea react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8 react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7 - react-native-get-random-values: 384787fd76976f5aec9465aff6fa9e9129af1e74 + react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06 react-native-mmkv: e97c0c79403fb94577e5d902ab1ebd42b0715b43 react-native-netinfo: 8a7fd3f7130ef4ad2fb4276d5c9f8d3f28d2df3d react-native-quick-base64: 777057ea4286f806b00259ede65dc79c7c706320 @@ -751,8 +751,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: 5efac5f69327cc6a4ad5b1f1fb9624b9e8355efe - XMTPReactNative: 5c4baec31d5ef83e5e5a35c33c31e70524db620e + XMTP: fbcb4e36d906d220778a5a0727cab6fd912bbb1d + XMTPReactNative: 44fd251a95a87f5ced57cce617f0748f2d056940 Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2 From 90c6eae9e4101b97eae986a2a91ba140befb2d1f Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 1 Jul 2024 14:40:11 -0700 Subject: [PATCH 4/5] fix up swift --- ios/Wrappers/ConversationWrapper.swift | 2 +- ios/XMTPModule.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/Wrappers/ConversationWrapper.swift b/ios/Wrappers/ConversationWrapper.swift index 103c6c629..81a4e74e0 100644 --- a/ios/Wrappers/ConversationWrapper.swift +++ b/ios/Wrappers/ConversationWrapper.swift @@ -26,7 +26,7 @@ struct ConversationWrapper { "topic": conversation.topic, "createdAt": UInt64(conversation.createdAt.timeIntervalSince1970 * 1000), "context": context, - "peerAddress": conversation.peerAddress, + "peerAddress": try conversation.peerAddress, "version": conversation.version == .v1 ? "v1" : "v2", "conversationID": conversation.conversationID ?? "", "keyMaterial": conversation.keyMaterial?.base64EncodedString() ?? "", diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index cfb89d939..1b77fc244 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -601,7 +601,7 @@ public class XMTPModule: Module { guard let conversation = try await findConversation(clientAddress: clientAddress, topic: conversationTopic) else { throw Error.conversationNotFound(conversationTopic) } - return ConsentWrapper.consentStateToString(state: await conversation.consentState()) + return ConsentWrapper.consentStateToString(state: try await conversation.consentState()) } AsyncFunction("consentList") { (clientAddress: String) -> [String] in @@ -682,7 +682,7 @@ public class XMTPModule: Module { await subscriptionsManager.get(getConversationsKey(clientAddress: clientAddress))?.cancel() await subscriptionsManager.set(getConversationsKey(clientAddress: clientAddress), Task { do { - for try await conversation in await client.conversations.stream() { + for try await conversation in try await client.conversations.stream() { try sendEvent("conversation", [ "clientAddress": clientAddress, "conversation": ConversationWrapper.encodeToObj(conversation, client: client), From 87e0503f65cdeb43f30e6c88bca521a626ff0c93 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 1 Jul 2024 15:48:49 -0700 Subject: [PATCH 5/5] bump to a working android version --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index b92a17266..38d62dd2d 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:0.14.0" + implementation "org.xmtp:android:0.14.1" 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"}