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

XMTP Legacy Branch #524

Draft
wants to merge 105 commits into
base: beta
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
4d9d018
bump the pod
nplasterer Oct 2, 2024
27e5aec
Merge branch 'beta' of https://github.com/xmtp/xmtp-react-native into…
nplasterer Oct 2, 2024
8c6a186
add chainId and isSmartContractWallet fields
nplasterer Sep 24, 2024
37b9271
add interface for signer
nplasterer Sep 24, 2024
268e461
pass the fields to the signer
nplasterer Sep 24, 2024
2c72d55
get the create the build
nplasterer Sep 24, 2024
6bb9427
Update signer
rygine Sep 26, 2024
1fa7b37
Update swift
rygine Sep 26, 2024
a10db52
cherry pick all the commits from the other PR
nplasterer Oct 2, 2024
f47bcc7
make this cleaner
nplasterer Oct 2, 2024
3dd9161
get on the latest version of the backend
nplasterer Oct 2, 2024
872a7ca
add ability to specify params you want returned or not
nplasterer Oct 2, 2024
fc3f75f
add last message and some sorting to the grou
nplasterer Oct 2, 2024
bdcf3dc
add the ability to specify fields and order
nplasterer Oct 2, 2024
a47011f
add a test for the perf
nplasterer Oct 3, 2024
4630be2
get the test passing
nplasterer Oct 3, 2024
5100167
Android side
nplasterer Oct 3, 2024
9249818
allow block number to be null
nplasterer Oct 3, 2024
4fd8dd1
add a limit to list groups so you only get the last n items instead o…
nplasterer Oct 4, 2024
befdbb0
Add a test for it
nplasterer Oct 4, 2024
d2def7e
add another test
nplasterer Oct 4, 2024
e0e500d
do the iOS side of it
nplasterer Oct 4, 2024
3680bda
fix up the linter
nplasterer Oct 8, 2024
07e8f93
fix: make group listing more performant
nplasterer Oct 8, 2024
39f6181
make sure working as expected
nplasterer Oct 8, 2024
044a992
fix up android
nplasterer Oct 8, 2024
334af67
Merge pull request #509 from xmtp/np/groups-lite-perf
nplasterer Oct 8, 2024
e00a62e
latest libxmtp
nplasterer Oct 11, 2024
c1ebdf2
update android and the methods
nplasterer Oct 20, 2024
f8a820c
try and get the iOS side matching
nplasterer Oct 20, 2024
1094e05
Merge branch 'main' of https://github.com/xmtp/xmtp-react-native into…
nplasterer Oct 20, 2024
3d8063d
point to the potential future gradle
nplasterer Oct 20, 2024
ed81adf
fix: optional field follows non-optional
peterferguson Oct 21, 2024
d0830c8
return last message
nplasterer Oct 21, 2024
806fbb7
fix: expose last message
nplasterer Oct 21, 2024
398b5c4
Merge pull request #514 from xmtp/np/last-message-not-loaded
nplasterer Oct 21, 2024
c843366
add test
nplasterer Oct 21, 2024
a5d7bb2
add back limit
nplasterer Oct 21, 2024
711f55f
Merge branch 'np/smart-contract-sdk-support' into sca-patch
peterferguson Oct 21, 2024
70461f4
fix chainId ternary
peterferguson Oct 21, 2024
1febd29
sig should be a string
peterferguson Oct 21, 2024
e7454f0
Merge pull request #515 from peterferguson/pf/np/smart-contract-sdk-s…
nplasterer Oct 22, 2024
4fc885c
change to wallet type and import latest libxmtp
nplasterer Oct 24, 2024
a6ca322
Merge branch 'np/smart-contract-sdk-support' of https://github.com/xm…
nplasterer Oct 24, 2024
1ccaec4
bad merge
nplasterer Oct 24, 2024
8ac19bb
do the ios side
nplasterer Oct 24, 2024
dc4de41
int instead of uint
nplasterer Oct 24, 2024
fd6e6d1
fix the signer
nplasterer Oct 24, 2024
b42a54b
get iOS compiling correctyl
nplasterer Oct 24, 2024
93bd230
Merge branch 'main' of https://github.com/xmtp/xmtp-react-native into…
nplasterer Oct 24, 2024
bf43701
add back limit
nplasterer Oct 24, 2024
230db03
fix: ios type <-> walletType field name mismatch
peterferguson Oct 24, 2024
74c82dd
Merge pull request #516 from peterferguson/pf/np/smart-contract-sdk-s…
nplasterer Oct 24, 2024
7d6d62d
feat: Smart Contract Wallet Support
nplasterer Oct 24, 2024
8199e76
Merge pull request #508 from xmtp/np/smart-contract-sdk-support
nplasterer Oct 24, 2024
2d4b4eb
major overhaul of the android bridge
nplasterer Oct 25, 2024
1d624f4
Merge branch 'main' of https://github.com/xmtp/xmtp-react-native into…
nplasterer Oct 25, 2024
7d762b6
remove double sync all
nplasterer Oct 25, 2024
2997c53
add a test for it
nplasterer Oct 25, 2024
c4f0d4e
fix: only call sync all once
nplasterer Oct 25, 2024
e1862c0
Merge pull request #518 from xmtp/np/sync-all-groups-perf
nplasterer Oct 25, 2024
97de67d
Merge branch 'main' of https://github.com/xmtp/xmtp-react-native into…
nplasterer Oct 25, 2024
0d2f13a
a few tweaks to android code
nplasterer Oct 25, 2024
50b080d
get all the methods in RN
nplasterer Oct 25, 2024
4fdbf73
do the entire swift side
nplasterer Oct 25, 2024
dec7860
implement dm and the common interface
nplasterer Oct 25, 2024
f4b10aa
add the conversations methods
nplasterer Oct 25, 2024
8aa5552
add a new test file for dms
nplasterer Oct 25, 2024
c97134e
get the tests going
nplasterer Oct 26, 2024
2cf7c0d
Conversation container
nplasterer Oct 26, 2024
bbcbf99
get tests passing for conversations
nplasterer Oct 26, 2024
b4b8a1d
feat: V3 only dms
nplasterer Oct 26, 2024
e9221c9
get all the tests passing
nplasterer Oct 26, 2024
c08ebf8
Merge pull request #517 from xmtp/np/v3-only-dms
nplasterer Oct 26, 2024
b9566a5
performance testing
nplasterer Oct 28, 2024
9ebc0bd
remove members from the wrapper because it will never be performant
nplasterer Oct 29, 2024
bbb4e60
add ability to create from key bundle with signer
nplasterer Nov 1, 2024
0624136
add the iOS method
nplasterer Nov 1, 2024
bfb492e
add tests
nplasterer Nov 1, 2024
793c523
add more tests
nplasterer Nov 1, 2024
4431d29
fix: get iOS test passing
nplasterer Nov 1, 2024
8447c73
fix up client creation
nplasterer Nov 1, 2024
99194d6
fix up the android test
nplasterer Nov 1, 2024
794fd86
Merge pull request #520 from xmtp/np/create-key-bundle-signer
nplasterer Nov 1, 2024
777a003
fix: performance
nplasterer Nov 2, 2024
fcafb22
fix up the peerInboxId
nplasterer Nov 2, 2024
5a145f6
get the test asserting
nplasterer Nov 2, 2024
ad44835
Merge branch 'np/v3-performance' of https://github.com/xmtp/xmtp-reac…
nplasterer Nov 2, 2024
787ab2d
remove creator inbox id from wrapper since its not performant
nplasterer Nov 2, 2024
d7114f4
remove extra logs
nplasterer Nov 2, 2024
507ab07
fix up lint issue
nplasterer Nov 4, 2024
fcb6e72
fix up the tests
nplasterer Nov 4, 2024
ab69ea7
another tweak to test
nplasterer Nov 4, 2024
971ea61
Merge pull request #522 from xmtp/np/performance-inbox-id
nplasterer Nov 4, 2024
f354462
update to the latest version for dual sending
nplasterer Nov 4, 2024
951f6cb
fix: dual send
nplasterer Nov 5, 2024
270c427
Merge pull request #523 from xmtp/np/dual-send-stage-1
nplasterer Nov 5, 2024
ee29258
fix: Type Updates
alexrisch Nov 6, 2024
d35b4f2
Merge pull request #525 from xmtp/ar/fix-type-updates
alexrisch Nov 6, 2024
928f914
processMessage method
nmalzieu Nov 20, 2024
1a3d4de
obj
nmalzieu Nov 20, 2024
c0c7278
we should expect the bridge to return a string
nmalzieu Nov 20, 2024
35cd477
fixing the kotlin code to return a string
nmalzieu Nov 20, 2024
bcfedeb
Bump
nmalzieu Nov 20, 2024
1df9670
Merge pull request #542 from xmtp/noe/fix-group-process-message-2.8
nmalzieu Nov 20, 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.12"
implementation "org.xmtp:android:0.16.2"
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
482 changes: 409 additions & 73 deletions android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package expo.modules.xmtpreactnativesdk.wrappers

import com.google.gson.JsonParser
import org.xmtp.android.library.WalletType

class AuthParamsWrapper(
val environment: String,
val appVersion: String?,
val enableV3: Boolean = false,
val dbDirectory: String?,
val historySyncUrl: String?,
val walletType: WalletType = WalletType.EOA,
val chainId: Long?,
val blockNumber: Long?,
) {
companion object {
fun authParamsFromJson(authParams: String): AuthParamsWrapper {
Expand All @@ -17,8 +21,18 @@ class AuthParamsWrapper(
if (jsonOptions.has("appVersion")) jsonOptions.get("appVersion").asString else null,
if (jsonOptions.has("enableV3")) jsonOptions.get("enableV3").asBoolean else false,
if (jsonOptions.has("dbDirectory")) jsonOptions.get("dbDirectory").asString else null,
if (jsonOptions.has("historySyncUrl")) jsonOptions.get("historySyncUrl").asString else null
)
if (jsonOptions.has("historySyncUrl")) jsonOptions.get("historySyncUrl").asString else null,
if (jsonOptions.has("walletType")) {
when (jsonOptions.get("walletType").asString) {
"SCW" -> WalletType.SCW
else -> WalletType.EOA
}
} else {
WalletType.EOA
},
if (jsonOptions.has("chainId")) jsonOptions.get("chainId").asLong else null,
if (jsonOptions.has("blockNumber")) jsonOptions.get("blockNumber").asLong else null,
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
package expo.modules.xmtpreactnativesdk.wrappers

import android.util.Base64
import com.google.gson.GsonBuilder
import org.xmtp.android.library.Client
import org.xmtp.android.library.Conversation

class ConversationContainerWrapper {

companion object {
suspend fun encodeToObj(client: Client, conversation: Conversation): Map<String, Any?> {
when (conversation.version) {
suspend fun encodeToObj(
client: Client,
conversation: Conversation,
conversationParams: ConversationParamsWrapper = ConversationParamsWrapper(),
): Map<String, Any?> {
return when (conversation.version) {
Conversation.Version.GROUP -> {
val group = (conversation as Conversation.Group).group
return GroupWrapper.encodeToObj(client, group)
GroupWrapper.encodeToObj(client, group, conversationParams)
}

Conversation.Version.DM -> {
val dm = (conversation as Conversation.Dm).dm
DmWrapper.encodeToObj(client, dm, conversationParams)
}

else -> {
return ConversationWrapper.encodeToObj(client, conversation)
ConversationWrapper.encodeToObj(client, conversation)
}
}
}

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

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

class DmWrapper {
companion object {
suspend fun encodeToObj(
client: Client,
dm: Dm,
dmParams: ConversationParamsWrapper = ConversationParamsWrapper(),
): Map<String, Any> {
return buildMap {
put("clientAddress", client.address)
put("id", dm.id)
put("createdAt", dm.createdAt.time)
put("version", "DM")
put("topic", dm.topic)
put("peerInboxId", dm.peerInboxId)
if (dmParams.consentState) {
put("consentState", consentStateToString(dm.consentState()))
}
if (dmParams.lastMessage) {
val lastMessage = dm.decryptedMessages(limit = 1).firstOrNull()
if (lastMessage != null) {
put("lastMessage", DecodedMessageWrapper.encode(lastMessage))
}
}
}
}

suspend fun encode(
client: Client,
dm: Dm,
dmParams: ConversationParamsWrapper = ConversationParamsWrapper(),
): String {
val gson = GsonBuilder().create()
val obj = encodeToObj(client, dm, dmParams)
return gson.toJson(obj)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,77 @@
package expo.modules.xmtpreactnativesdk.wrappers

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

class GroupWrapper {

companion object {
suspend fun encodeToObj(client: Client, group: Group): Map<String, Any> {
return mapOf(
"clientAddress" to client.address,
"id" to group.id,
"createdAt" to group.createdAt.time,
"members" to group.members().map { MemberWrapper.encode(it) },
"version" to "GROUP",
"topic" to group.topic,
"creatorInboxId" to group.creatorInboxId(),
"isActive" to group.isActive(),
"addedByInboxId" to group.addedByInboxId(),
"name" to group.name,
"imageUrlSquare" to group.imageUrlSquare,
"description" to group.description,
"consentState" to consentStateToString(group.consentState())
// "pinnedFrameUrl" to group.pinnedFrameUrl
)
suspend fun encodeToObj(
client: Client,
group: Group,
groupParams: ConversationParamsWrapper = ConversationParamsWrapper(),
): Map<String, Any> {
return buildMap {
put("clientAddress", client.address)
put("id", group.id)
put("createdAt", group.createdAt.time)
put("version", "GROUP")
put("topic", group.topic)
if (groupParams.isActive) put("isActive", group.isActive())
if (groupParams.addedByInboxId) put("addedByInboxId", group.addedByInboxId())
if (groupParams.name) put("name", group.name)
if (groupParams.imageUrlSquare) put("imageUrlSquare", group.imageUrlSquare)
if (groupParams.description) put("description", group.description)
if (groupParams.consentState) {
put("consentState", consentStateToString(group.consentState()))
}
if (groupParams.lastMessage) {
val lastMessage = group.decryptedMessages(limit = 1).firstOrNull()
if (lastMessage != null) {
put("lastMessage", DecodedMessageWrapper.encode(lastMessage))
}
}
}
}

suspend fun encode(client: Client, group: Group): String {
suspend fun encode(
client: Client,
group: Group,
groupParams: ConversationParamsWrapper = ConversationParamsWrapper(),
): String {
val gson = GsonBuilder().create()
val obj = encodeToObj(client, group)
val obj = encodeToObj(client, group, groupParams)
return gson.toJson(obj)
}
}
}

class ConversationParamsWrapper(
val isActive: Boolean = true,
val addedByInboxId: Boolean = true,
val name: Boolean = true,
val imageUrlSquare: Boolean = true,
val description: Boolean = true,
val consentState: Boolean = true,
val lastMessage: Boolean = false,
) {
companion object {
fun conversationParamsFromJson(conversationParams: String): ConversationParamsWrapper {
if (conversationParams.isEmpty()) return ConversationParamsWrapper()
val jsonOptions = JsonParser.parseString(conversationParams).asJsonObject
return ConversationParamsWrapper(
if (jsonOptions.has("isActive")) jsonOptions.get("isActive").asBoolean else true,
if (jsonOptions.has("addedByInboxId")) jsonOptions.get("addedByInboxId").asBoolean else true,
if (jsonOptions.has("name")) jsonOptions.get("name").asBoolean else true,
if (jsonOptions.has("imageUrlSquare")) jsonOptions.get("imageUrlSquare").asBoolean else true,
if (jsonOptions.has("description")) jsonOptions.get("description").asBoolean else true,
if (jsonOptions.has("consentState")) jsonOptions.get("consentState").asBoolean else true,
if (jsonOptions.has("lastMessage")) jsonOptions.get("lastMessage").asBoolean else false,
)
}
}
}

24 changes: 12 additions & 12 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.9-beta0)
- LibXMTP (0.6.0)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (1.3.9):
- MMKVCore (~> 1.3.9)
- MMKVCore (1.3.9)
- MMKV (2.0.0):
- MMKVCore (~> 2.0.0)
- MMKVCore (2.0.0)
- OpenSSL-Universal (1.1.2200)
- RCT-Folly (2021.07.22.00):
- boost
Expand Down Expand Up @@ -449,16 +449,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.15.0):
- XMTP (0.16.2):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.5.9-beta0)
- LibXMTP (= 0.6.0)
- web3.swift
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.15.0)
- XMTP (= 0.16.2)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -711,11 +711,11 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: 5a38722a68a9469be2e711857a5e7d9dd3aa8a61
LibXMTP: 059c6d51b2c59419941ecff600aa586bbe083673
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: 817ba1eea17421547e01e087285606eb270a8dcb
MMKVCore: af055b00e27d88cd92fad301c5fecd1ff9b26dd9
MMKV: f7d1d5945c8765f97f39c3d121f353d46735d801
MMKVCore: c04b296010fcb1d1638f2c69405096aac12f6390
OpenSSL-Universal: 6e1ae0555546e604dbc632a2b9a24a9c46c41ef6
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: e9df143e880d0e879e7a498dc06923d728809c79
Expand Down Expand Up @@ -763,8 +763,8 @@ SPEC CHECKSUMS:
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: 09faa347569b092005997364f7fe787ccc33f3d5
XMTPReactNative: 6404c11e6dd11820742d4af899daeea389fc442f
XMTP: 281c763321f3be82b3e5d91bfd79f107b1169e30
XMTPReactNative: 2428cbce29fca3ca3e7682b096765ccf3dca739f
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd
Expand Down
Loading
Loading