Skip to content

Commit

Permalink
Merge branch 'beta' of https://github.com/xmtp/xmtp-react-native into…
Browse files Browse the repository at this point in the history
… np/require-encryption-key
  • Loading branch information
nplasterer committed Apr 25, 2024
2 parents ad148be + 21755f5 commit 443d86e
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.5"
implementation "org.xmtp:android:0.10.6"
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,12 @@ class XMTPModule : Module() {
client.canMessage(peerAddress)
}

AsyncFunction("canGroupMessage") { clientAddress: String, peerAddresses: List<String> ->
logV("canGroupMessage")
val client = clients[clientAddress] ?: throw XMTPException("No client")
client.canMessageV3(peerAddresses)
AsyncFunction("canGroupMessage") Coroutine { clientAddress: String, peerAddresses: List<String> ->
withContext(Dispatchers.IO) {
logV("canGroupMessage")
val client = clients[clientAddress] ?: throw XMTPException("No client")
client.canMessageV3(peerAddresses)
}
}

AsyncFunction("staticCanMessage") { peerAddress: String, environment: String, appVersion: String? ->
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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-beta3)
- LibXMTP (0.4.4-beta5)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (1.3.5):
Expand Down Expand Up @@ -449,16 +449,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.10.5):
- XMTP (0.10.7):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.4.4-beta3)
- LibXMTP (= 0.4.4-beta5)
- web3.swift
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.10.5)
- XMTP (= 0.10.7)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -711,7 +711,7 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: 1422d36d715fe868b5800692f3d9b8a218a41e9d
LibXMTP: e2fb601691981900099551ff3e05621bd73dccf1
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: 506311d0494023c2f7e0b62cc1f31b7370fa3cfb
Expand Down Expand Up @@ -763,8 +763,8 @@ SPEC CHECKSUMS:
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: ec7fa7f9a2bd3990a7142c2f454e04c5b83b834a
XMTPReactNative: 42d61df711ce3c094d9fac9e3f44671f5466e93e
XMTP: 881f30f685c5c6df83aa3bca6ca400e799256290
XMTPReactNative: ca2bc46e645e71ce31afbbf236bc71cffc83a0f4
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2
Expand Down
27 changes: 21 additions & 6 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,19 +734,34 @@ test('can stream all groups and conversations', async () => {
})

test('canMessage', async () => {
const [bo, alix] = await createClients(2)
const [bo, alix, caro] = await createClients(3)

const canMessage = await bo.canMessage(alix.address)
if (!canMessage) {
throw new Error('should be able to message v2 client')
}

const [caro, chux] = await createClients(2)
const canMessageV3 = await caro.canGroupMessage([
caro.address,
alix.address,
'0x0000000000000000000000000000000000000000',
])

assert(
canMessageV3['0x0000000000000000000000000000000000000000'] === false,
`should not be able to message 0x0000000000000000000000000000000000000000`
)

assert(
canMessageV3[caro.address.toLowerCase()] === true,
`should be able to message ${caro.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
})

Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public class XMTPModule: Module {
return try await client.canMessage(peerAddress)
}

AsyncFunction("canGroupMessage") { (clientAddress: String, peerAddresses: [String]) -> Bool in
AsyncFunction("canGroupMessage") { (clientAddress: String, peerAddresses: [String]) -> [String: Bool] in
guard let client = await clientsManager.getClient(key: clientAddress) else {
throw Error.noClient
}
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPReactNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.5"
s.dependency "XMTP", "= 0.10.7"
end
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export async function canMessage(
export async function canGroupMessage(
clientAddress: string,
peerAddresses: string[]
): Promise<boolean> {
): Promise<{ [key: string]: boolean }> {
return await XMTPModule.canGroupMessage(clientAddress, peerAddresses)
}

Expand Down
6 changes: 4 additions & 2 deletions src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ 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<boolean[]>} A Promise resolving to true for peers where group messaging is allowed, and false otherwise.
* @returns {Promise<{ [key: string]: boolean }>} A Promise resolving to a hash of addresses and booleans if they can message on the V3 network.
*/
async canGroupMessage(addresses: string[]): Promise<boolean> {
async canGroupMessage(
addresses: string[]
): Promise<{ [key: string]: boolean }> {
return await XMTPModule.canGroupMessage(this.address, addresses)
}

Expand Down

0 comments on commit 443d86e

Please sign in to comment.