diff --git a/android/build.gradle b/android/build.gradle index 4ab0b7f5d..88caf0565 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -95,7 +95,7 @@ repositories { dependencies { implementation project(':expo-modules-core') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" - implementation "org.xmtp:android:0.6.18" + implementation "org.xmtp:android:0.6.19" 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 9d4e4e6fd..fd743fd29 100644 --- a/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt +++ b/android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt @@ -552,17 +552,26 @@ class XMTPModule : Module() { AsyncFunction("conversationConsentState") { clientAddress: String, conversationTopic: String -> val conversation = findConversation(clientAddress, conversationTopic) ?: throw XMTPException("no conversation found for $conversationTopic") - when (conversation.consentState()) { - ConsentState.ALLOWED -> "allowed" - ConsentState.DENIED -> "denied" - ConsentState.UNKNOWN -> "unknown" - } + consentStateToString(conversation.consentState()) + } + + AsyncFunction("consentList") { clientAddress: String -> + val client = clients[clientAddress] ?: throw XMTPException("No client") + client.contacts.consentList.entries.map { "${it.key}: ${consentStateToString(it.value)}" } } } // // Helpers // + private fun consentStateToString(state: ConsentState): String { + return when (state) { + ConsentState.ALLOWED -> "allowed" + ConsentState.DENIED -> "denied" + ConsentState.UNKNOWN -> "unknown" + } + } + private fun findConversation( clientAddress: String, topic: String, diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index cd71435dd..428a983b3 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -411,7 +411,7 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.7.0-alpha0): + - XMTP (0.7.1-alpha0): - Connect-Swift (= 0.3.0) - GzipSwift - web3.swift @@ -419,7 +419,7 @@ PODS: - XMTPReactNative (0.1.0): - ExpoModulesCore - MessagePacker - - XMTP (= 0.7.0-alpha0) + - XMTP (= 0.7.1-alpha0) - XMTPRust (0.3.7-beta0) - Yoga (1.14.0) @@ -668,8 +668,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: b02b5075dcf60c9f5f403000b3b0c202a11b6ae1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: bf9244684e659096f6a3351e8e942ad45eeed842 - XMTPReactNative: 2b0e4a9532081c6f84f54a9377b1cda633a7b47d + XMTP: 36069f94fc0485a0e6fe7a9fd5debc7ba816002c + XMTPReactNative: 40f71f1405e0ba3fcd4311382a236e7748ce1301 XMTPRust: 8848a2ba761b2c961d666632f2ad27d1082faa93 Yoga: 065f0b74dba4832d6e328238de46eb72c5de9556 diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 39dd3c1ab..5a37197a2 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -512,19 +512,31 @@ public class XMTPModule: Module { guard let conversation = try await findConversation(clientAddress: clientAddress, topic: conversationTopic) else { throw Error.conversationNotFound(conversationTopic) } - switch await conversation.consentState() { - case .allowed: return "allowed" - case .denied: return "denied" - case .unknown: return "unknown" - } + return consentStateToString(state: await conversation.consentState()) } + + AsyncFunction("consentList") { (clientAddress: String) -> [String] in + guard let client = await clientsManager.getClient(key: clientAddress) else { + throw Error.noClient + } + let entries = await client.contacts.consentList.entries + return entries.map { "\($0.key): \(consentStateToString(state: $0.value))" } + } } // // Helpers // - func createClientConfig(env: String, appVersion: String?) -> XMTP.ClientOptions { + func consentStateToString(state: ConsentState) -> String { + switch state { + case .allowed: return "allowed" + case .denied: return "denied" + case .unknown: return "unknown" + } + } + + func createClientConfig(env: String, appVersion: String?) -> XMTP.ClientOptions { // Ensure that all codecs have been registered. switch env { case "local": diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index 56007fb4e..ea844efb4 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -25,5 +25,5 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency "MessagePacker" - s.dependency "XMTP", "= 0.7.0-alpha0" + s.dependency "XMTP", "= 0.7.1-alpha0" end