From 866e9710c9e8f6df778ce3ab4e01f95bb3a8110e Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Fri, 20 Dec 2024 16:34:07 -0800 Subject: [PATCH] update bindings --- library/src/main/java/xmtpv3.kt | 90 +++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/library/src/main/java/xmtpv3.kt b/library/src/main/java/xmtpv3.kt index c9f103b7..b4a6f2d2 100644 --- a/library/src/main/java/xmtpv3.kt +++ b/library/src/main/java/xmtpv3.kt @@ -1227,6 +1227,10 @@ internal interface UniffiLib : Library { `ptr`: Pointer, `accountAddresses`: RustBuffer.ByValue, `opts`: RustBuffer.ByValue, ): Long + fun uniffi_xmtpv3_fn_method_fficonversations_get_hmac_keys( + `ptr`: Pointer, uniffi_out_err: UniffiRustCallStatus, + ): RustBuffer.ByValue + fun uniffi_xmtpv3_fn_method_fficonversations_get_sync_group( `ptr`: Pointer, uniffi_out_err: UniffiRustCallStatus, ): Pointer @@ -1523,10 +1527,6 @@ internal interface UniffiLib : Library { `ptr`: Pointer, `entityType`: RustBuffer.ByValue, `entity`: RustBuffer.ByValue, ): Long - fun uniffi_xmtpv3_fn_method_ffixmtpclient_get_hmac_keys( - `ptr`: Pointer, uniffi_out_err: UniffiRustCallStatus, - ): RustBuffer.ByValue - fun uniffi_xmtpv3_fn_method_ffixmtpclient_get_latest_inbox_state( `ptr`: Pointer, `inboxId`: RustBuffer.ByValue, ): Long @@ -2115,6 +2115,9 @@ internal interface UniffiLib : Library { fun uniffi_xmtpv3_checksum_method_fficonversations_create_group( ): Short + fun uniffi_xmtpv3_checksum_method_fficonversations_get_hmac_keys( + ): Short + fun uniffi_xmtpv3_checksum_method_fficonversations_get_sync_group( ): Short @@ -2271,9 +2274,6 @@ internal interface UniffiLib : Library { fun uniffi_xmtpv3_checksum_method_ffixmtpclient_get_consent_state( ): Short - fun uniffi_xmtpv3_checksum_method_ffixmtpclient_get_hmac_keys( - ): Short - fun uniffi_xmtpv3_checksum_method_ffixmtpclient_get_latest_inbox_state( ): Short @@ -2534,6 +2534,9 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_xmtpv3_checksum_method_fficonversations_create_group() != 7282.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_xmtpv3_checksum_method_fficonversations_get_hmac_keys() != 44064.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_xmtpv3_checksum_method_fficonversations_get_sync_group() != 42973.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -2690,9 +2693,6 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) { if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_get_consent_state() != 58208.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } - if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_get_hmac_keys() != 36015.toShort()) { - throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_get_latest_inbox_state() != 3165.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -5567,6 +5567,8 @@ public interface FfiConversationsInterface { `opts`: FfiCreateGroupOptions, ): FfiConversation + fun `getHmacKeys`(): Map> + fun `getSyncGroup`(): FfiConversation suspend fun `list`(`opts`: FfiListConversationsOptions): List @@ -5765,6 +5767,20 @@ open class FfiConversations : Disposable, AutoCloseable, FfiConversationsInterfa } + @Throws(GenericException::class) + override fun `getHmacKeys`(): Map> { + return FfiConverterMapByteArraySequenceTypeFfiHmacKey.lift( + callWithPointer { + uniffiRustCallWithError(GenericException) { _status -> + UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_fficonversations_get_hmac_keys( + it, _status + ) + } + } + ) + } + + @Throws(GenericException::class) override fun `getSyncGroup`(): FfiConversation { return FfiConverterTypeFfiConversation.lift( @@ -9054,8 +9070,6 @@ public interface FfiXmtpClientInterface { `entity`: kotlin.String, ): FfiConsentState - fun `getHmacKeys`(): List - suspend fun `getLatestInboxState`(`inboxId`: kotlin.String): FfiInboxState fun `inboxId`(): kotlin.String @@ -9474,20 +9488,6 @@ open class FfiXmtpClient : Disposable, AutoCloseable, FfiXmtpClientInterface { } - @Throws(GenericException::class) - override fun `getHmacKeys`(): List { - return FfiConverterSequenceTypeFfiHmacKey.lift( - callWithPointer { - uniffiRustCallWithError(GenericException) { _status -> - UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_ffixmtpclient_get_hmac_keys( - it, _status - ) - } - } - ) - } - - @Throws(GenericException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") override suspend fun `getLatestInboxState`(`inboxId`: kotlin.String): FfiInboxState { @@ -12377,6 +12377,44 @@ public object FfiConverterMapStringBoolean : } +/** + * @suppress + */ +public object FfiConverterMapByteArraySequenceTypeFfiHmacKey : + FfiConverterRustBuffer>> { + override fun read(buf: ByteBuffer): Map> { + val len = buf.getInt() + return buildMap>(len) { + repeat(len) { + val k = FfiConverterByteArray.read(buf) + val v = FfiConverterSequenceTypeFfiHmacKey.read(buf) + this[k] = v + } + } + } + + override fun allocationSize(value: Map>): ULong { + val spaceForMapSize = 4UL + val spaceForChildren = value.map { (k, v) -> + FfiConverterByteArray.allocationSize(k) + + FfiConverterSequenceTypeFfiHmacKey.allocationSize(v) + }.sum() + return spaceForMapSize + spaceForChildren + } + + override fun write(value: Map>, buf: ByteBuffer) { + buf.putInt(value.size) + // The parens on `(k, v)` here ensure we're calling the right method, + // which is important for compatibility with older android devices. + // Ref https://blog.danlew.net/2017/03/16/kotlin-puzzler-whose-line-is-it-anyways/ + value.forEach { (k, v) -> + FfiConverterByteArray.write(k, buf) + FfiConverterSequenceTypeFfiHmacKey.write(v, buf) + } + } +} + + @Throws(GenericException::class) @Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE") suspend fun `connectToBackend`(`host`: kotlin.String, `isSecure`: kotlin.Boolean): XmtpApiClient {