Skip to content

Commit

Permalink
pull in the latest main
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Jul 1, 2024
2 parents 86652bc + ac0e0ad commit 5028c42
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 31 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.13.9"
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"
Expand Down
27 changes: 15 additions & 12 deletions android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,12 @@ class XMTPModule : Module() {

//
// Client API
AsyncFunction("canMessage") { inboxId: String, peerAddress: String ->
logV("canMessage")
val client = clients[inboxId] ?: throw XMTPException("No client")

client.canMessage(peerAddress)
AsyncFunction("canMessage") Coroutine { clientAddress: String, peerAddress: String ->
withContext(Dispatchers.IO) {
logV("canMessage")
val client = clients[inboxId] ?: throw XMTPException("No client")
client.canMessage(peerAddress)
}
}

AsyncFunction("canGroupMessage") Coroutine { inboxId: String, peerAddresses: List<String> ->
Expand All @@ -426,13 +427,15 @@ class XMTPModule : Module() {
}
}

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}")
}
}
}

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.5.3-beta2)
- LibXMTP (0.5.4-beta0)
- 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.12.4):
- XMTP (0.13.0):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.5.3-beta2)
- LibXMTP (= 0.5.4-beta0)
- web3.swift
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.12.4)
- XMTP (= 0.13.0)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -711,7 +711,7 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: c0f992e33c4ac95bdf2652f9429b3999890b6ab3
LibXMTP: 549e85c40f00957be3e114a823a2887cdcf5817a
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: 7d69afe403538056efb6caf01db7248b01221c48
XMTPReactNative: 938a95995dcd9ddf7db3872ee69c59e59105cfaa
XMTP: fbcb4e36d906d220778a5a0727cab6fd912bbb1d
XMTPReactNative: 44fd251a95a87f5ced57cce617f0748f2d056940
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2
Expand Down
33 changes: 25 additions & 8 deletions example/src/tests/tests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FramesClient } from '@xmtp/frames-client'
import { content, invitation } from '@xmtp/proto'
import { createHmac } from 'crypto'
import { ethers } from 'ethers'
import ReactNativeBlobUtil from 'react-native-blob-util'
import Config from 'react-native-config'
import { TextEncoder, TextDecoder } from 'text-encoding'
Expand Down Expand Up @@ -1792,13 +1791,31 @@ test('can handle complex streaming setup with messages from self', async () => {
return true
})

class ViemSigner {
account: PrivateKeyAccount

constructor(account: PrivateKeyAccount) {
this.account = account
}

async getAddress() {
return this.account.address
}

async signMessage(message: string) {
return this.account.signMessage({ message })
}
}

test('can send and receive consent proofs', async () => {
const alixWallet = await ethers.Wallet.createRandom()
const boWallet = await ethers.Wallet.createRandom()
const bo = await Client.create(boWallet, { env: 'local' })
await delayToPropogate()
const alix = await Client.create(alixWallet, { env: 'local' })
await delayToPropogate()
const alixPrivateKey = generatePrivateKey()
const alixAccount = privateKeyToAccount(alixPrivateKey)
const boPrivateKey = generatePrivateKey()
const boAccount = privateKeyToAccount(boPrivateKey)
const alixSigner = new ViemSigner(alixAccount)
const boSigner = new ViemSigner(boAccount)
const alix = await Client.create(alixSigner, { env: 'local' })
const bo = await Client.create(boSigner, { env: 'local' })

const timestamp = Date.now()
const consentMessage =
Expand All @@ -1808,7 +1825,7 @@ test('can send and receive consent proofs', async () => {
`From Address: ${bo.address}\n` +
'\n' +
'For more info: https://xmtp.org/signatures/'
const sig = await alixWallet.signMessage(consentMessage)
const sig = await alixSigner.signMessage(consentMessage)
const consentProof = invitation.ConsentProofPayload.fromPartial({
payloadVersion:
invitation.ConsentProofPayloadVersion.CONSENT_PROOF_PAYLOAD_VERSION_1,
Expand Down
4 changes: 2 additions & 2 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ public class XMTPModule: Module {
guard let conversation = try await findConversation(inboxId: inboxId, topic: conversationTopic) else {
throw Error.conversationNotFound(conversationTopic)
}
return try ConsentWrapper.consentStateToString(state: await conversation.consentState())
return try ConsentWrapper.consentStateToString(state: try await conversation.consentState())
}

AsyncFunction("groupConsentState") { (inboxId: String, groupId: String) -> String in
Expand Down Expand Up @@ -1317,7 +1317,7 @@ public class XMTPModule: Module {
await subscriptionsManager.get(getConversationsKey(inboxId: inboxId))?.cancel()
await subscriptionsManager.set(getConversationsKey(inboxId: inboxId), Task {
do {
for try await conversation in await client.conversations.stream() {
for try await conversation in try await client.conversations.stream() {
try sendEvent("conversation", [
"inboxId": inboxId,
"conversation": ConversationWrapper.encodeToObj(conversation, client: client),
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.12.4"
s.dependency "XMTP", "= 0.13.0"
end

0 comments on commit 5028c42

Please sign in to comment.