Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into beta #507

Merged
merged 29 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
601bf7b
fix: add created at to the installation
nplasterer Sep 26, 2024
1ee838d
fix the parsing issue
nplasterer Sep 26, 2024
8600996
test is now handled in performance folder
nplasterer Sep 26, 2024
b361543
Add delay after streaming to make sure the stream is opened
nmalzieu Sep 26, 2024
e9f6246
Always stream group even if we know it
nmalzieu Sep 26, 2024
9a30400
Add a test for broken streaming between groups & messages
nmalzieu Sep 26, 2024
d703bb6
update swift side of the code
nplasterer Sep 26, 2024
2e28e90
inbox state
nplasterer Sep 26, 2024
b64e6e8
add more awaits
nplasterer Sep 26, 2024
3ccc716
get ios working
nplasterer Sep 26, 2024
4fd09a0
fix up the testing issue
nplasterer Sep 27, 2024
01aabd0
fix up the tests
nplasterer Sep 29, 2024
d2374af
Merge pull request #502 from xmtp/np/logging-installation-created
nplasterer Sep 29, 2024
510bf6b
Merge branch 'main' of https://github.com/xmtp/xmtp-react-native into…
nplasterer Sep 29, 2024
a7cd85d
get on to the latest pod
nplasterer Sep 29, 2024
7b4d5f1
delay before checking group stream
nmalzieu Sep 30, 2024
16b296d
fix: group stream error
nmalzieu Sep 30, 2024
8ff06e5
Merge pull request #503 from xmtp/noe/fix-group-streams-issues
nmalzieu Sep 30, 2024
63873c2
add the fields to android
nplasterer Sep 30, 2024
56b3fa2
add the RN side
nplasterer Sep 30, 2024
e13c47e
add the iOS side
nplasterer Sep 30, 2024
c8b3180
write v3 tests for it
nplasterer Sep 30, 2024
e13c1bf
fix: v3 consent works
nplasterer Sep 30, 2024
26a8bd3
add a few more consent tests
nplasterer Oct 1, 2024
831cae5
Merge pull request #504 from xmtp/np/v3-consent
nplasterer Oct 1, 2024
66207cf
bump to the latest sdk version
nplasterer Oct 1, 2024
2e68539
fix: stage zero v3 dms
nplasterer Oct 2, 2024
08a2da8
Merge pull request #506 from xmtp/np/stage-zero-v3-dm
nplasterer Oct 2, 2024
af4486b
Merge branch 'main' of https://github.com/xmtp/xmtp-react-native into…
nplasterer Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.15.10"
implementation "org.xmtp:android:0.15.12"
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 @@ -38,6 +38,7 @@ import kotlinx.coroutines.withContext
import org.json.JSONObject
import org.xmtp.android.library.Client
import org.xmtp.android.library.ClientOptions
import org.xmtp.android.library.ConsentState
import org.xmtp.android.library.Conversation
import org.xmtp.android.library.Group
import org.xmtp.android.library.PreEventCallback
Expand Down Expand Up @@ -372,7 +373,7 @@ class XMTPModule : Module() {
}
}

AsyncFunction("createOrBuild") Coroutine { address: String, hasCreateIdentityCallback: Boolean?, hasEnableIdentityCallback: Boolean?, hasAuthInboxCallback: Boolean?, dbEncryptionKey: List<Int>?, authParams: String ->
AsyncFunction("createOrBuild") Coroutine { address: String, hasCreateIdentityCallback: Boolean?, hasEnableIdentityCallback: Boolean?, hasAuthInboxCallback: Boolean?, dbEncryptionKey: List<Int>?, authParams: String ->
withContext(Dispatchers.IO) {
logV("createOrBuild")
val reactSigner = ReactNativeSigner(module = this@XMTPModule, address = address)
Expand Down Expand Up @@ -1029,7 +1030,10 @@ class XMTPModule : Module() {
val client = clients[inboxId] ?: throw XMTPException("No client")
client.conversations.syncAllGroups()
// Expo Modules do not support UInt, so we need to convert to Int
val numGroupsSyncedInt: Int = client.conversations.syncAllGroups()?.toInt() ?: throw IllegalArgumentException("Value cannot be null")
val numGroupsSyncedInt: Int =
client.conversations.syncAllGroups()?.toInt() ?: throw IllegalArgumentException(
"Value cannot be null"
)
numGroupsSyncedInt
}
}
Expand Down Expand Up @@ -1610,7 +1614,7 @@ class XMTPModule : Module() {
withContext(Dispatchers.IO) {
val group = findGroup(inboxId, groupId)
?: throw XMTPException("no group found for $groupId")
consentStateToString(Conversation.Group(group).consentState())
consentStateToString(group.consentState())
}
}

Expand Down Expand Up @@ -1664,6 +1668,14 @@ class XMTPModule : Module() {
client.contacts.isGroupDenied(groupId)
}
}
AsyncFunction("updateGroupConsent") Coroutine { inboxId: String, groupId: String, state: String ->
withContext(Dispatchers.IO) {
logV("updateGroupConsent")
val group = findGroup(inboxId, groupId)

group?.updateConsentState(getConsentState(state))
}
}

AsyncFunction("exportNativeLogs") Coroutine { ->
withContext(Dispatchers.IO) {
Expand All @@ -1688,7 +1700,7 @@ class XMTPModule : Module() {
// Helpers
//

private suspend fun getPermissionOption(permissionString: String): PermissionOption {
private fun getPermissionOption(permissionString: String): PermissionOption {
return when (permissionString) {
"allow" -> PermissionOption.Allow
"deny" -> PermissionOption.Deny
Expand All @@ -1698,6 +1710,14 @@ class XMTPModule : Module() {
}
}

private fun getConsentState(stateString: String): ConsentState {
return when (stateString) {
"allowed" -> ConsentState.ALLOWED
"denied" -> ConsentState.DENIED
else -> ConsentState.UNKNOWN
}
}

private suspend fun findConversation(
inboxId: String,
topic: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.xmtp.android.library.Conversation
class ConversationContainerWrapper {

companion object {
fun encodeToObj(client: Client, conversation: Conversation): Map<String, Any?> {
suspend fun encodeToObj(client: Client, conversation: Conversation): Map<String, Any?> {
when (conversation.version) {
Conversation.Version.GROUP -> {
val group = (conversation as Conversation.Group).group
Expand All @@ -20,7 +20,7 @@ class ConversationContainerWrapper {
}
}

fun encode(client: Client, conversation: Conversation): String {
suspend fun encode(client: Client, conversation: Conversation): String {
val gson = GsonBuilder().create()
val obj = ConversationContainerWrapper.encodeToObj(client, conversation)
return gson.toJson(obj)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package expo.modules.xmtpreactnativesdk.wrappers

import com.google.gson.GsonBuilder
import expo.modules.xmtpreactnativesdk.wrappers.ConsentWrapper.Companion.consentStateToString
import org.xmtp.android.library.Client
import org.xmtp.android.library.Group
import org.xmtp.android.library.toHex

class GroupWrapper {

companion object {
fun encodeToObj(client: Client, group: Group): Map<String, Any> {
suspend fun encodeToObj(client: Client, group: Group): Map<String, Any> {
return mapOf(
"clientAddress" to client.address,
"id" to group.id,
Expand All @@ -21,12 +21,13 @@ class GroupWrapper {
"addedByInboxId" to group.addedByInboxId(),
"name" to group.name,
"imageUrlSquare" to group.imageUrlSquare,
"description" to group.description
"description" to group.description,
"consentState" to consentStateToString(group.consentState())
// "pinnedFrameUrl" to group.pinnedFrameUrl
)
}

fun encode(client: Client, group: Group): String {
suspend fun encode(client: Client, group: Group): String {
val gson = GsonBuilder().create()
val obj = encodeToObj(client, group)
return gson.toJson(obj)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
package expo.modules.xmtpreactnativesdk.wrappers

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.InboxState

class InboxStateWrapper {
companion object {
val gson: Gson = GsonBuilder().create()
fun encodeToObj(inboxState: InboxState): Map<String, Any> {
return mapOf(
"inboxId" to inboxState.inboxId,
"addresses" to inboxState.addresses,
"installationIds" to inboxState.installationIds,
"installations" to inboxState.installations.map {
gson.toJson(
mapOf(
"id" to it.installationId,
"createdAt" to it.createdAt?.time
)
)
},
"recoveryAddress" to inboxState.recoveryAddress
)
}

fun encode(inboxState: InboxState): String {
val gson = GsonBuilder().create()
val obj = encodeToObj(inboxState)
return gson.toJson(obj)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class MemberWrapper {
return mapOf(
"inboxId" to member.inboxId,
"addresses" to member.addresses,
"permissionLevel" to permissionString
"permissionLevel" to permissionString,
"consentState" to ConsentWrapper.consentStateToString(member.consentState)
)
}

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.8-beta6)
- LibXMTP (0.5.9-beta0)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (1.3.9):
Expand Down Expand Up @@ -449,16 +449,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.14.14):
- XMTP (0.15.0):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.5.8-beta6)
- LibXMTP (= 0.5.9-beta0)
- web3.swift
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.14.14)
- XMTP (= 0.15.0)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -711,7 +711,7 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: c7338cace222bed90f950579300725325a2c0bfd
LibXMTP: 5a38722a68a9469be2e711857a5e7d9dd3aa8a61
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: 817ba1eea17421547e01e087285606eb270a8dcb
Expand Down Expand Up @@ -763,8 +763,8 @@ SPEC CHECKSUMS:
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: 37621f1258b12629af305e6697414ccb2fbd4ea8
XMTPReactNative: 7bec275ed26997e6a73f06a678c328e6ba852cd5
XMTP: 09faa347569b092005997364f7fe787ccc33f3d5
XMTPReactNative: 6404c11e6dd11820742d4af899daeea389fc442f
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd
Expand Down
Loading
Loading