From 8946ea2b2349b4551754766de9a6b98fe130dab4 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 24 Apr 2024 17:27:38 -0700 Subject: [PATCH] Revert "Can message hash map" --- android/build.gradle | 2 +- .../modules/xmtpreactnativesdk/XMTPModule.kt | 10 +++----- example/ios/Podfile.lock | 24 +++++++++--------- example/src/tests/groupTests.ts | 25 +++---------------- ios/XMTPModule.swift | 2 +- ios/XMTPReactNative.podspec | 2 +- src/index.ts | 2 +- src/lib/Client.ts | 16 +++++------- 8 files changed, 30 insertions(+), 53 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index bb315920b..6dfab186e 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.10.6" + implementation "org.xmtp:android:0.10.5" 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 347ce28af..25bafdb6d 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -374,12 +374,10 @@ class XMTPModule : Module() { client.canMessage(peerAddress) } - AsyncFunction("canGroupMessage") Coroutine { clientAddress: String, peerAddresses: List -> - withContext(Dispatchers.IO) { - logV("canGroupMessage") - val client = clients[clientAddress] ?: throw XMTPException("No client") - client.canMessageV3(peerAddresses) - } + AsyncFunction("canGroupMessage") { clientAddress: String, peerAddresses: List -> + logV("canGroupMessage") + val client = clients[clientAddress] ?: throw XMTPException("No client") + client.canMessageV3(peerAddresses) } AsyncFunction("staticCanMessage") { peerAddress: String, environment: String, appVersion: String? -> diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index de66a9fb2..6d1408b5a 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -56,12 +56,12 @@ 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.4.4-beta3) - Logging (1.0.0) - MessagePacker (0.4.7) - - MMKV (1.3.5): - - MMKVCore (~> 1.3.5) - - MMKVCore (1.3.5) + - MMKV (1.3.4): + - MMKVCore (~> 1.3.4) + - MMKVCore (1.3.4) - OpenSSL-Universal (1.1.2200) - RCT-Folly (2021.07.22.00): - boost @@ -449,16 +449,16 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.10.6): + - XMTP (0.10.5): - Connect-Swift (= 0.12.0) - GzipSwift - - LibXMTP (= 0.4.4-beta5) + - LibXMTP (= 0.4.4-beta3) - web3.swift - XMTPReactNative (0.1.0): - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.10.6) + - XMTP (= 0.10.5) - Yoga (1.14.0) DEPENDENCIES: @@ -711,11 +711,11 @@ SPEC CHECKSUMS: GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - LibXMTP: e2fb601691981900099551ff3e05621bd73dccf1 + LibXMTP: 1422d36d715fe868b5800692f3d9b8a218a41e9d Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26 MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02 - MMKV: 506311d0494023c2f7e0b62cc1f31b7370fa3cfb - MMKVCore: 9e2e5fd529b64a9fe15f1a7afb3d73b2e27b4db9 + MMKV: ed58ad794b3f88c24d604a5b74f3fba17fcbaf74 + MMKVCore: a67a1cede26175c413176f404a7cedec43f96a0b OpenSSL-Universal: 6e1ae0555546e604dbc632a2b9a24a9c46c41ef6 RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: e9df143e880d0e879e7a498dc06923d728809c79 @@ -763,8 +763,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: 0e31bcf8e904389ec831cc058601553045fda477 - XMTPReactNative: 7a3f29770f0d496a00d2c6457ce63d878528360e + XMTP: ec7fa7f9a2bd3990a7142c2f454e04c5b83b834a + XMTPReactNative: 42d61df711ce3c094d9fac9e3f44671f5466e93e Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2 diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index c3d1ae5df..18f423fad 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -738,27 +738,10 @@ test('canMessage', async () => { const [caro, chux] = await createClients(2) - const canMessageV3 = await caro.canGroupMessage([ - chux.address, - alix.address, - '0x0000000000000000000000000000000000000000', - ]) - - assert( - canMessageV3['0x0000000000000000000000000000000000000000'] === false, - `should not be able to message 0x0000000000000000000000000000000000000000` - ) - - assert( - canMessageV3[chux.address.toLowerCase()] === true, - `should be able to message ${chux.address}` - ) - - assert( - canMessageV3[alix.address.toLowerCase()] === true, - `should be able to message ${alix.address}` - ) - + const canMessageV3 = await caro.canGroupMessage([chux.address]) + if (!canMessageV3) { + throw new Error('should be able to message v3 client') + } return true }) diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 778e169a5..317236d1c 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -239,7 +239,7 @@ public class XMTPModule: Module { return try await client.canMessage(peerAddress) } - AsyncFunction("canGroupMessage") { (clientAddress: String, peerAddresses: [String]) -> [String: Bool] in + AsyncFunction("canGroupMessage") { (clientAddress: String, peerAddresses: [String]) -> Bool in guard let client = await clientsManager.getClient(key: clientAddress) else { throw Error.noClient } diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index 5ae51dc6e..814453097 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.6" + s.dependency "XMTP", "= 0.10.5" end diff --git a/src/index.ts b/src/index.ts index ad722b918..f2af4656e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -288,7 +288,7 @@ export async function canMessage( export async function canGroupMessage( clientAddress: string, peerAddresses: string[] -): Promise<{ [key: string]: boolean }> { +): Promise { return await XMTPModule.canGroupMessage(clientAddress, peerAddresses) } diff --git a/src/lib/Client.ts b/src/lib/Client.ts index e7571842c..714c4886c 100644 --- a/src/lib/Client.ts +++ b/src/lib/Client.ts @@ -19,13 +19,11 @@ import { DecodedMessage } from '../index' declare const Buffer -export type GetMessageContentTypeFromClient = C extends Client - ? T - : never +export type GetMessageContentTypeFromClient = + C extends Client ? T : never -export type ExtractDecodedType = C extends XMTPModule.ContentCodec - ? T - : never +export type ExtractDecodedType = + C extends XMTPModule.ContentCodec ? T : never export class Client< ContentTypes extends DefaultContentTypes = DefaultContentTypes, @@ -212,11 +210,9 @@ export class Client< * This method checks if the specified peers are using clients that support group messaging. * * @param {string[]} addresses - The addresses of the peers to check for messaging eligibility. - * @returns {Promise<{ [key: string]: boolean }>} A Promise resolving to a hash of addresses and booleans if they can message on the V3 network. + * @returns {Promise} A Promise resolving to true for peers where group messaging is allowed, and false otherwise. */ - async canGroupMessage( - addresses: string[] - ): Promise<{ [key: string]: boolean }> { + async canGroupMessage(addresses: string[]): Promise { return await XMTPModule.canGroupMessage(this.address, addresses) }