Skip to content

Commit 6030e8c

Browse files
Who Added Me Functionality (#230)
* Update LibXMTP Kotlin README * dump the xmtpv3 code * bump all the jni libs * added_by_address implementation + test * Fix test with lowercase() --------- Co-authored-by: Naomi Plasterer <naomi@xmtp.com>
1 parent 7c336e7 commit 6030e8c

File tree

8 files changed

+43
-6
lines changed

8 files changed

+43
-6
lines changed

library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt

+14
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,20 @@ class GroupTest {
256256
assert(!caroGroup.isActive())
257257
}
258258

259+
@Test
260+
fun testAddedByAddress() {
261+
val group = runBlocking {
262+
alixClient.conversations.newGroup(
263+
listOf(
264+
bo.walletAddress,
265+
)
266+
)
267+
}
268+
runBlocking { boClient.conversations.syncGroups() }
269+
val boGroup = runBlocking { boClient.conversations.listGroups().first() }
270+
assertEquals(boGroup.addedByAddress().lowercase(), alix.walletAddress.lowercase())
271+
}
272+
259273
@Test
260274
fun testCanListGroups() {
261275
runBlocking {

library/src/main/java/README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ Kotlin code emitted by the `bindings_ffi` crate in [libxmtp](https://github.com/
66

77
1. From repo [libxmtp](https://github.com/xmtp/libxmtp) checkout the branch you would like to make a release from
88
2. Navigate to the `bindings_ffi` folder
9-
3. Run `./gen_kotlin.sh`
10-
4. Run `./cross_build.sh`
11-
5. Copy the contents of `libxmtp/bindings_ffi/src/uniffi/xmtpv3/xmtpv3.kt` to `xmtp-android/library/src/main/java/xmtpv3.kt`
12-
6. All instances of `value.forEach` should be changed to `value.iterator().forEach` to be compatible with API 23
13-
7. Copy the jniLibs from `libxmtp/bindings_ffi/jniLibs` to `xmtp-android/library/src/main/jniLibs`
9+
3. Follow the instructions for "Rebuilding this crate in the `bindings_ffi` [README](https://github.com/xmtp/libxmtp/tree/main/bindings_ffi#rebuilding-this-crate)"
10+
4. Copy the contents of `libxmtp/bindings_ffi/src/uniffi/xmtpv3/xmtpv3.kt` to `xmtp-android/library/src/main/java/xmtpv3.kt`
11+
5. All instances of `value.forEach` should be changed to `value.iterator().forEach` to be compatible with API 23
12+
6. Copy the jniLibs from `libxmtp/bindings_ffi/jniLibs` to `xmtp-android/library/src/main/jniLibs`
1413

1514
You should now be on the latest libxmtp. Tests will fail if the jniLibs do not match the version of xmtpv3.

library/src/main/java/org/xmtp/android/library/Group.kt

+4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) {
134134
return libXMTPGroup.isActive()
135135
}
136136

137+
fun addedByAddress(): String {
138+
return libXMTPGroup.addedByAddress()
139+
}
140+
137141
fun permissionLevel(): GroupPermissions {
138142
return metadata.policyType()
139143
}

library/src/main/java/xmtpv3.kt

+21-1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ internal interface _UniFFILib : Library {
411411
): Unit
412412
fun uniffi_xmtpv3_fn_method_ffigroup_add_members(`ptr`: Pointer,`accountAddresses`: RustBuffer.ByValue,
413413
): Pointer
414+
fun uniffi_xmtpv3_fn_method_ffigroup_added_by_address(`ptr`: Pointer,_uniffi_out_err: RustCallStatus,
415+
): RustBuffer.ByValue
414416
fun uniffi_xmtpv3_fn_method_ffigroup_created_at_ns(`ptr`: Pointer,_uniffi_out_err: RustCallStatus,
415417
): Long
416418
fun uniffi_xmtpv3_fn_method_ffigroup_find_messages(`ptr`: Pointer,`opts`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
@@ -673,6 +675,8 @@ internal interface _UniFFILib : Library {
673675
): Short
674676
fun uniffi_xmtpv3_checksum_method_ffigroup_add_members(
675677
): Short
678+
fun uniffi_xmtpv3_checksum_method_ffigroup_added_by_address(
679+
): Short
676680
fun uniffi_xmtpv3_checksum_method_ffigroup_created_at_ns(
677681
): Short
678682
fun uniffi_xmtpv3_checksum_method_ffigroup_find_messages(
@@ -823,6 +827,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
823827
if (lib.uniffi_xmtpv3_checksum_method_ffigroup_add_members() != 24978.toShort()) {
824828
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
825829
}
830+
if (lib.uniffi_xmtpv3_checksum_method_ffigroup_added_by_address() != 5368.toShort()) {
831+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
832+
}
826833
if (lib.uniffi_xmtpv3_checksum_method_ffigroup_created_at_ns() != 58515.toShort()) {
827834
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
828835
}
@@ -1488,7 +1495,8 @@ public object FfiConverterTypeFfiConversations: FfiConverter<FfiConversations, P
14881495

14891496
public interface FfiGroupInterface {
14901497
@Throws(GenericException::class)
1491-
suspend fun `addMembers`(`accountAddresses`: List<String>)
1498+
suspend fun `addMembers`(`accountAddresses`: List<String>)@Throws(GenericException::class)
1499+
fun `addedByAddress`(): String
14921500
fun `createdAtNs`(): Long@Throws(GenericException::class)
14931501
fun `findMessages`(`opts`: FfiListMessagesOptions): List<FfiMessage>@Throws(GenericException::class)
14941502
fun `groupMetadata`(): FfiGroupMetadata
@@ -1542,6 +1550,18 @@ class FfiGroup(
15421550
GenericException.ErrorHandler,
15431551
)
15441552
}
1553+
1554+
@Throws(GenericException::class)override fun `addedByAddress`(): String =
1555+
callWithPointer {
1556+
rustCallWithError(GenericException) { _status ->
1557+
_UniFFILib.INSTANCE.uniffi_xmtpv3_fn_method_ffigroup_added_by_address(it,
1558+
1559+
_status)
1560+
}
1561+
}.let {
1562+
FfiConverterString.lift(it)
1563+
}
1564+
15451565
override fun `createdAtNs`(): Long =
15461566
callWithPointer {
15471567
rustCall() { _status ->
Binary file not shown.
Binary file not shown.
57.7 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)