diff --git a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt index 7a1785ab8..c3136c74f 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt @@ -207,11 +207,19 @@ class GroupTest { } @Test - fun testNameAGroup() { - val boGroup = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress)) } + fun testGroupMetadata() { + val boGroup = runBlocking { + boClient.conversations.newGroup( + listOf(alix.walletAddress), + groupName = "Starting Name", + groupImageUrlSquare = "startingurl.com" + ) + } runBlocking { - assertEquals("", boGroup.name) + assertEquals("Starting Name", boGroup.name) + assertEquals("startingurl.com", boGroup.imageUrlSquare) boGroup.updateGroupName("This Is A Great Group") + boGroup.updateGroupImageUrlSquare("thisisanewurl.com") boGroup.sync() alixClient.conversations.syncGroups() } @@ -219,6 +227,8 @@ class GroupTest { runBlocking { alixGroup.sync() } assertEquals("This Is A Great Group", boGroup.name) assertEquals("This Is A Great Group", alixGroup.name) + assertEquals("thisisanewurl.com", boGroup.imageUrlSquare) + assertEquals("thisisanewurl.com", alixGroup.imageUrlSquare) } @Test diff --git a/library/src/main/java/libxmtp-version.txt b/library/src/main/java/libxmtp-version.txt index 830325fe7..637a2585c 100644 --- a/library/src/main/java/libxmtp-version.txt +++ b/library/src/main/java/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: 46fad302 +Version: 6d880763 Branch: main -Date: 2024-06-04 02:30:29 +0000 +Date: 2024-06-13 06:20:50 +0000 diff --git a/library/src/main/java/org/xmtp/android/library/Conversations.kt b/library/src/main/java/org/xmtp/android/library/Conversations.kt index 70ab0dba5..7733b5205 100644 --- a/library/src/main/java/org/xmtp/android/library/Conversations.kt +++ b/library/src/main/java/org/xmtp/android/library/Conversations.kt @@ -41,6 +41,7 @@ import org.xmtp.proto.message.contents.Contact import org.xmtp.proto.message.contents.Invitation import uniffi.xmtpv3.FfiConversationCallback import uniffi.xmtpv3.FfiConversations +import uniffi.xmtpv3.FfiCreateGroupOptions import uniffi.xmtpv3.FfiGroup import uniffi.xmtpv3.FfiListConversationsOptions import uniffi.xmtpv3.FfiMessage @@ -107,6 +108,8 @@ data class Conversations( suspend fun newGroup( accountAddresses: List, permissions: GroupPermissions = GroupPermissions.ALL_MEMBERS, + groupName: String = "", + groupImageUrlSquare: String = "", ): Group { if (accountAddresses.size == 1 && accountAddresses.first().lowercase() == client.address.lowercase() @@ -121,8 +124,14 @@ data class Conversations( } val group = - libXMTPConversations?.createGroup(accountAddresses, permissions = permissions) - ?: throw XMTPException("Client does not support Groups") + libXMTPConversations?.createGroup( + accountAddresses, + opts = FfiCreateGroupOptions( + permissions = permissions, + groupName = groupName, + groupImageUrlSquare = groupImageUrlSquare + ) + ) ?: throw XMTPException("Client does not support Groups") client.contacts.allowGroups(groupIds = listOf(group.id())) return Group(client, group) diff --git a/library/src/main/java/org/xmtp/android/library/Group.kt b/library/src/main/java/org/xmtp/android/library/Group.kt index 8bc7bc6aa..5de38f1aa 100644 --- a/library/src/main/java/org/xmtp/android/library/Group.kt +++ b/library/src/main/java/org/xmtp/android/library/Group.kt @@ -44,6 +44,9 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) { val name: String get() = libXMTPGroup.groupName() + val imageUrlSquare: String + get() = libXMTPGroup.groupImageUrlSquare() + suspend fun send(text: String): String { return send(prepareMessage(content = text, options = null)) } @@ -220,6 +223,10 @@ class Group(val client: Client, private val libXMTPGroup: FfiGroup) { return libXMTPGroup.updateGroupName(name) } + suspend fun updateGroupImageUrlSquare(imageUrl: String) { + return libXMTPGroup.updateGroupImageUrlSquare(imageUrl) + } + fun isAdmin(inboxId: String): Boolean { return libXMTPGroup.isAdmin(inboxId) } diff --git a/library/src/main/java/xmtpv3.kt b/library/src/main/java/xmtpv3.kt index ff09042a6..812403992 100644 --- a/library/src/main/java/xmtpv3.kt +++ b/library/src/main/java/xmtpv3.kt @@ -841,7 +841,7 @@ internal interface UniffiLib : Library { ): Unit fun uniffi_xmtpv3_fn_method_fficonversations_create_group( - `ptr`: Pointer, `accountAddresses`: RustBuffer.ByValue, `permissions`: RustBuffer.ByValue, + `ptr`: Pointer, `accountAddresses`: RustBuffer.ByValue, `opts`: RustBuffer.ByValue, ): Long fun uniffi_xmtpv3_fn_method_fficonversations_list( @@ -904,6 +904,10 @@ internal interface UniffiLib : Library { `ptr`: Pointer, `opts`: RustBuffer.ByValue, uniffi_out_err: UniffiRustCallStatus, ): RustBuffer.ByValue + fun uniffi_xmtpv3_fn_method_ffigroup_group_image_url_square( + `ptr`: Pointer, uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + fun uniffi_xmtpv3_fn_method_ffigroup_group_metadata( `ptr`: Pointer, uniffi_out_err: UniffiRustCallStatus, ): Pointer @@ -972,6 +976,10 @@ internal interface UniffiLib : Library { `ptr`: Pointer, ): Long + fun uniffi_xmtpv3_fn_method_ffigroup_update_group_image_url_square( + `ptr`: Pointer, `groupImageUrlSquare`: RustBuffer.ByValue, + ): Long + fun uniffi_xmtpv3_fn_method_ffigroup_update_group_name( `ptr`: Pointer, `groupName`: RustBuffer.ByValue, ): Long @@ -1016,7 +1024,7 @@ internal interface UniffiLib : Library { `ptr`: Pointer, `signatureBytes`: RustBuffer.ByValue, ): Long - fun uniffi_xmtpv3_fn_method_ffisignaturerequest_add_erc1271_signature( + fun uniffi_xmtpv3_fn_method_ffisignaturerequest_add_scw_signature( `ptr`: Pointer, `signatureBytes`: RustBuffer.ByValue, `address`: RustBuffer.ByValue, @@ -1562,6 +1570,9 @@ internal interface UniffiLib : Library { fun uniffi_xmtpv3_checksum_method_ffigroup_find_messages( ): Short + fun uniffi_xmtpv3_checksum_method_ffigroup_group_image_url_square( + ): Short + fun uniffi_xmtpv3_checksum_method_ffigroup_group_metadata( ): Short @@ -1613,6 +1624,9 @@ internal interface UniffiLib : Library { fun uniffi_xmtpv3_checksum_method_ffigroup_sync( ): Short + fun uniffi_xmtpv3_checksum_method_ffigroup_update_group_image_url_square( + ): Short + fun uniffi_xmtpv3_checksum_method_ffigroup_update_group_name( ): Short @@ -1628,7 +1642,7 @@ internal interface UniffiLib : Library { fun uniffi_xmtpv3_checksum_method_ffisignaturerequest_add_ecdsa_signature( ): Short - fun uniffi_xmtpv3_checksum_method_ffisignaturerequest_add_erc1271_signature( + fun uniffi_xmtpv3_checksum_method_ffisignaturerequest_add_scw_signature( ): Short fun uniffi_xmtpv3_checksum_method_ffisignaturerequest_is_ready( @@ -1774,7 +1788,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_xmtpv3_checksum_func_verify_k256_sha256() != 25521.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_xmtpv3_checksum_method_fficonversations_create_group() != 1475.toShort()) { + if (lib.uniffi_xmtpv3_checksum_method_fficonversations_create_group() != 62996.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_xmtpv3_checksum_method_fficonversations_list() != 10804.toShort()) { @@ -1816,6 +1830,9 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_xmtpv3_checksum_method_ffigroup_find_messages() != 14930.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_xmtpv3_checksum_method_ffigroup_group_image_url_square() != 16754.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_xmtpv3_checksum_method_ffigroup_group_metadata() != 13139.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -1867,6 +1884,9 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_xmtpv3_checksum_method_ffigroup_sync() != 24219.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_xmtpv3_checksum_method_ffigroup_update_group_image_url_square() != 18878.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_xmtpv3_checksum_method_ffigroup_update_group_name() != 550.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -1882,7 +1902,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_xmtpv3_checksum_method_ffisignaturerequest_add_ecdsa_signature() != 8706.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_xmtpv3_checksum_method_ffisignaturerequest_add_erc1271_signature() != 27040.toShort()) { + if (lib.uniffi_xmtpv3_checksum_method_ffisignaturerequest_add_scw_signature() != 59425.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } if (lib.uniffi_xmtpv3_checksum_method_ffisignaturerequest_is_ready() != 65051.toShort()) { @@ -2379,7 +2399,7 @@ public interface FfiConversationsInterface { suspend fun `createGroup`( `accountAddresses`: List, - `permissions`: GroupPermissions?, + `opts`: FfiCreateGroupOptions, ): FfiGroup suspend fun `list`(`opts`: FfiListConversationsOptions): List @@ -2481,14 +2501,14 @@ open class FfiConversations : Disposable, AutoCloseable, FfiConversationsInterfa @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") override suspend fun `createGroup`( `accountAddresses`: List, - `permissions`: GroupPermissions?, + `opts`: FfiCreateGroupOptions, ): FfiGroup { return uniffiRustCallAsync( callWithPointer { thisPtr -> UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_fficonversations_create_group( thisPtr, FfiConverterSequenceString.lower(`accountAddresses`), - FfiConverterOptionalTypeGroupPermissions.lower(`permissions`), + FfiConverterTypeFfiCreateGroupOptions.lower(`opts`), ) }, { future, callback, continuation -> @@ -2820,6 +2840,8 @@ public interface FfiGroupInterface { fun `findMessages`(`opts`: FfiListMessagesOptions): List + fun `groupImageUrlSquare`(): kotlin.String + fun `groupMetadata`(): FfiGroupMetadata fun `groupName`(): kotlin.String @@ -2854,6 +2876,8 @@ public interface FfiGroupInterface { suspend fun `sync`() + suspend fun `updateGroupImageUrlSquare`(`groupImageUrlSquare`: kotlin.String) + suspend fun `updateGroupName`(`groupName`: kotlin.String) companion object @@ -3128,6 +3152,20 @@ open class FfiGroup : Disposable, AutoCloseable, FfiGroupInterface { } + @Throws(GenericException::class) + override fun `groupImageUrlSquare`(): kotlin.String { + return FfiConverterString.lift( + callWithPointer { + uniffiRustCallWithError(GenericException) { _status -> + UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_ffigroup_group_image_url_square( + it, _status + ) + } + } + ) + } + + @Throws(GenericException::class) override fun `groupMetadata`(): FfiGroupMetadata { return FfiConverterTypeFfiGroupMetadata.lift( @@ -3514,6 +3552,39 @@ open class FfiGroup : Disposable, AutoCloseable, FfiGroupInterface { } + @Throws(GenericException::class) + @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") + override suspend fun `updateGroupImageUrlSquare`(`groupImageUrlSquare`: kotlin.String) { + return uniffiRustCallAsync( + callWithPointer { thisPtr -> + UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_ffigroup_update_group_image_url_square( + thisPtr, + FfiConverterString.lower(`groupImageUrlSquare`), + ) + }, + { future, callback, continuation -> + UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_poll_void( + future, + callback, + continuation + ) + }, + { future, continuation -> + UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_complete_void( + future, + continuation + ) + }, + { future -> UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_free_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + GenericException.ErrorHandler, + ) + } + + @Throws(GenericException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") override suspend fun `updateGroupName`(`groupName`: kotlin.String) { @@ -4154,7 +4225,7 @@ public interface FfiSignatureRequestInterface { suspend fun `addEcdsaSignature`(`signatureBytes`: kotlin.ByteArray) - suspend fun `addErc1271Signature`( + suspend fun `addScwSignature`( `signatureBytes`: kotlin.ByteArray, `address`: kotlin.String, `chainRpcUrl`: kotlin.String, @@ -4289,14 +4360,14 @@ open class FfiSignatureRequest : Disposable, AutoCloseable, FfiSignatureRequestI @Throws(GenericException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") - override suspend fun `addErc1271Signature`( + override suspend fun `addScwSignature`( `signatureBytes`: kotlin.ByteArray, `address`: kotlin.String, `chainRpcUrl`: kotlin.String, ) { return uniffiRustCallAsync( callWithPointer { thisPtr -> - UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_ffisignaturerequest_add_erc1271_signature( + UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_ffisignaturerequest_add_scw_signature( thisPtr, FfiConverterByteArray.lower(`signatureBytes`), FfiConverterString.lower(`address`), @@ -5767,6 +5838,39 @@ public object FfiConverterTypeFfiXmtpClient : FfiConverter { + override fun read(buf: ByteBuffer): FfiCreateGroupOptions { + return FfiCreateGroupOptions( + FfiConverterOptionalTypeGroupPermissions.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: FfiCreateGroupOptions) = ( + FfiConverterOptionalTypeGroupPermissions.allocationSize(value.`permissions`) + + FfiConverterOptionalString.allocationSize(value.`groupName`) + + FfiConverterOptionalString.allocationSize(value.`groupImageUrlSquare`) + ) + + override fun write(value: FfiCreateGroupOptions, buf: ByteBuffer) { + FfiConverterOptionalTypeGroupPermissions.write(value.`permissions`, buf) + FfiConverterOptionalString.write(value.`groupName`, buf) + FfiConverterOptionalString.write(value.`groupImageUrlSquare`, buf) + } +} + + data class FfiCursor( var `digest`: kotlin.ByteArray, var `senderTimeNs`: kotlin.ULong, diff --git a/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so b/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so index 727f6b32c..ceeedccfb 100755 Binary files a/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so and b/library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so differ diff --git a/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so b/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so index 4f9f76374..6f768e79f 100755 Binary files a/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so and b/library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so differ diff --git a/library/src/main/jniLibs/x86/libuniffi_xmtpv3.so b/library/src/main/jniLibs/x86/libuniffi_xmtpv3.so index 0c6eebc8a..befae0f4e 100755 Binary files a/library/src/main/jniLibs/x86/libuniffi_xmtpv3.so and b/library/src/main/jniLibs/x86/libuniffi_xmtpv3.so differ diff --git a/library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so b/library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so index 3f39ae8b3..f55938875 100755 Binary files a/library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so and b/library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so differ