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

Bump bindings for sync work fix #345

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions library/src/main/java/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: f6f9af92
Version: 3103e7b9
Branch: main
Date: 2024-12-03 20:02:58 +0000
Date: 2024-12-05 00:24:03 +0000
7 changes: 1 addition & 6 deletions library/src/main/java/org/xmtp/android/library/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlinx.coroutines.runBlocking
import org.xmtp.android.library.codecs.ContentCodec
import org.xmtp.android.library.codecs.TextCodec
import org.xmtp.android.library.libxmtp.Message
import org.xmtp.android.library.libxmtp.XMTPLogger
import org.xmtp.android.library.messages.rawData
import uniffi.xmtpv3.FfiConversationType
import uniffi.xmtpv3.FfiDeviceSyncKind
Expand Down Expand Up @@ -47,7 +46,6 @@ class Client() {
lateinit var conversations: Conversations
lateinit var environment: XMTPEnvironment
lateinit var dbPath: String
var logger: XMTPLogger = XMTPLogger()
val libXMTPVersion: String = getVersionInfo()
private lateinit var ffiClient: FfiXmtpClient

Expand All @@ -62,7 +60,6 @@ class Client() {

suspend fun getOrCreateInboxId(environment: ClientOptions.Api, address: String): String {
var inboxId = getInboxIdForAddress(
logger = XMTPLogger(),
host = environment.env.getUrl(),
isSecure = environment.isSecure,
accountAddress = address.lowercase()
Expand Down Expand Up @@ -91,7 +88,6 @@ class Client() {
val dbPath = directoryFile.absolutePath + "/$alias.db3"

val ffiClient = createClient(
logger = XMTPLogger(),
host = api.env.getUrl(),
isSecure = api.isSecure,
db = dbPath,
Expand Down Expand Up @@ -201,7 +197,6 @@ class Client() {
dbPath = directoryFile.absolutePath + "/$alias.db3"

val ffiClient = createClient(
logger = logger,
host = options.api.env.getUrl(),
isSecure = options.api.isSecure,
db = dbPath,
Expand All @@ -210,7 +205,7 @@ class Client() {
inboxId = inboxId,
nonce = 0.toULong(),
legacySignedPrivateKeyProto = null,
historySyncUrl = options.historySyncUrl
historySyncUrl = null
)

options.preAuthenticateToInboxCallback?.let {
Expand Down

This file was deleted.

164 changes: 16 additions & 148 deletions library/src/main/java/xmtpv3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -726,17 +726,6 @@ internal interface UniffiCallbackInterfaceFfiInboxOwnerMethod1 : com.sun.jna.Cal
)
}

internal interface UniffiCallbackInterfaceFfiLoggerMethod0 : com.sun.jna.Callback {
fun callback(
`uniffiHandle`: Long,
`level`: Int,
`levelLabel`: RustBuffer.ByValue,
`message`: RustBuffer.ByValue,
`uniffiOutReturn`: Pointer,
uniffiCallStatus: UniffiRustCallStatus,
)
}

internal interface UniffiCallbackInterfaceFfiConsentCallbackMethod0 : com.sun.jna.Callback {
fun callback(
`uniffiHandle`: Long,
Expand Down Expand Up @@ -830,23 +819,6 @@ internal open class UniffiVTableCallbackInterfaceFfiInboxOwner(

}

@Structure.FieldOrder("log", "uniffiFree")
internal open class UniffiVTableCallbackInterfaceFfiLogger(
@JvmField internal var `log`: UniffiCallbackInterfaceFfiLoggerMethod0? = null,
@JvmField internal var `uniffiFree`: UniffiCallbackInterfaceFree? = null,
) : Structure() {
class UniffiByValue(
`log`: UniffiCallbackInterfaceFfiLoggerMethod0? = null,
`uniffiFree`: UniffiCallbackInterfaceFree? = null,
) : UniffiVTableCallbackInterfaceFfiLogger(`log`, `uniffiFree`), Structure.ByValue

internal fun uniffiSetValue(other: UniffiVTableCallbackInterfaceFfiLogger) {
`log` = other.`log`
`uniffiFree` = other.`uniffiFree`
}

}

@Structure.FieldOrder("onConsentUpdate", "onError", "uniffiFree")
internal open class UniffiVTableCallbackInterfaceFfiConsentCallback(
@JvmField internal var `onConsentUpdate`: UniffiCallbackInterfaceFfiConsentCallbackMethod0? = null,
Expand Down Expand Up @@ -956,7 +928,6 @@ internal interface UniffiLib : Library {
uniffiCallbackInterfaceFfiMessageCallback.register(lib)
uniffiCallbackInterfaceFfiV2SubscriptionCallback.register(lib)
uniffiCallbackInterfaceFfiInboxOwner.register(lib)
uniffiCallbackInterfaceFfiLogger.register(lib)
}
}

Expand Down Expand Up @@ -1486,8 +1457,8 @@ internal interface UniffiLib : Library {
): RustBuffer.ByValue

fun uniffi_xmtpv3_fn_method_ffixmtpclient_maybe_start_sync_worker(
`ptr`: Pointer,
): Long
`ptr`: Pointer, uniffi_out_err: UniffiRustCallStatus,
): Unit

fun uniffi_xmtpv3_fn_method_ffixmtpclient_message(
`ptr`: Pointer, `messageId`: RustBuffer.ByValue, uniffi_out_err: UniffiRustCallStatus,
Expand Down Expand Up @@ -1544,12 +1515,7 @@ internal interface UniffiLib : Library {
`vtable`: UniffiVTableCallbackInterfaceFfiInboxOwner,
): Unit

fun uniffi_xmtpv3_fn_init_callback_vtable_ffilogger(
`vtable`: UniffiVTableCallbackInterfaceFfiLogger,
): Unit

fun uniffi_xmtpv3_fn_func_create_client(
`logger`: Long,
`host`: RustBuffer.ByValue,
`isSecure`: Byte,
`db`: RustBuffer.ByValue,
Expand Down Expand Up @@ -1580,10 +1546,7 @@ internal interface UniffiLib : Library {
): RustBuffer.ByValue

fun uniffi_xmtpv3_fn_func_get_inbox_id_for_address(
`logger`: Long,
`host`: RustBuffer.ByValue,
`isSecure`: Byte,
`accountAddress`: RustBuffer.ByValue,
`host`: RustBuffer.ByValue, `isSecure`: Byte, `accountAddress`: RustBuffer.ByValue,
): Long

fun uniffi_xmtpv3_fn_func_get_version_info(
Expand Down Expand Up @@ -2250,9 +2213,6 @@ internal interface UniffiLib : Library {
fun uniffi_xmtpv3_checksum_method_ffiinboxowner_sign(
): Short

fun uniffi_xmtpv3_checksum_method_ffilogger_log(
): Short

fun ffi_xmtpv3_uniffi_contract_version(
): Int

Expand All @@ -2270,7 +2230,7 @@ private fun uniffiCheckContractApiVersion(lib: UniffiLib) {

@Suppress("UNUSED_PARAMETER")
private fun uniffiCheckApiChecksums(lib: UniffiLib) {
if (lib.uniffi_xmtpv3_checksum_func_create_client() != 6255.toShort()) {
if (lib.uniffi_xmtpv3_checksum_func_create_client() != 50509.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_func_create_v2_client() != 48060.toShort()) {
Expand All @@ -2285,7 +2245,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) {
if (lib.uniffi_xmtpv3_checksum_func_generate_private_preferences_topic_identifier() != 59124.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_func_get_inbox_id_for_address() != 36898.toShort()) {
if (lib.uniffi_xmtpv3_checksum_func_get_inbox_id_for_address() != 35414.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_func_get_version_info() != 29277.toShort()) {
Expand Down Expand Up @@ -2612,7 +2572,7 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) {
if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_installation_id() != 37173.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_maybe_start_sync_worker() != 27018.toShort()) {
if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_maybe_start_sync_worker() != 56811.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_ffixmtpclient_message() != 26932.toShort()) {
Expand Down Expand Up @@ -2654,9 +2614,6 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) {
if (lib.uniffi_xmtpv3_checksum_method_ffiinboxowner_sign() != 30268.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_ffilogger_log() != 56011.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
}

// Async support
Expand Down Expand Up @@ -8289,7 +8246,7 @@ public interface FfiXmtpClientInterface {
/**
* Starts the sync worker if the history sync url is present.
*/
suspend fun `maybeStartSyncWorker`()
fun `maybeStartSyncWorker`()

fun `message`(`messageId`: kotlin.ByteArray): FfiMessage

Expand Down Expand Up @@ -8792,37 +8749,14 @@ open class FfiXmtpClient : Disposable, AutoCloseable, FfiXmtpClientInterface {
/**
* Starts the sync worker if the history sync url is present.
*/
@Throws(GenericException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `maybeStartSyncWorker`() {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
override fun `maybeStartSyncWorker`() =
callWithPointer {
uniffiRustCall() { _status ->
UniffiLib.INSTANCE.uniffi_xmtpv3_fn_method_ffixmtpclient_maybe_start_sync_worker(
thisPtr,

)
},
{ 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
it, _status
)
},
{ future -> UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_free_void(future) },
// lift function
{ Unit },

// Error FFI converter
GenericException.ErrorHandler,
)
}
}
}


@Throws(GenericException::class)
Expand Down Expand Up @@ -10478,64 +10412,6 @@ internal object uniffiCallbackInterfaceFfiInboxOwner {
public object FfiConverterTypeFfiInboxOwner : FfiConverterCallbackInterface<FfiInboxOwner>()


public interface FfiLogger {

fun `log`(`level`: kotlin.UInt, `levelLabel`: kotlin.String, `message`: kotlin.String)

companion object
}


// Put the implementation in an object so we don't pollute the top-level namespace
internal object uniffiCallbackInterfaceFfiLogger {
internal object `log` : UniffiCallbackInterfaceFfiLoggerMethod0 {
override fun callback(
`uniffiHandle`: Long,
`level`: Int,
`levelLabel`: RustBuffer.ByValue,
`message`: RustBuffer.ByValue,
`uniffiOutReturn`: Pointer,
uniffiCallStatus: UniffiRustCallStatus,
) {
val uniffiObj = FfiConverterTypeFfiLogger.handleMap.get(uniffiHandle)
val makeCall = { ->
uniffiObj.`log`(
FfiConverterUInt.lift(`level`),
FfiConverterString.lift(`levelLabel`),
FfiConverterString.lift(`message`),
)
}
val writeReturn = { _: Unit -> Unit }
uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn)
}
}

internal object uniffiFree : UniffiCallbackInterfaceFree {
override fun callback(handle: Long) {
FfiConverterTypeFfiLogger.handleMap.remove(handle)
}
}

internal var vtable = UniffiVTableCallbackInterfaceFfiLogger.UniffiByValue(
`log`,
uniffiFree,
)

// Registers the foreign callback with the Rust side.
// This method is generated for each callback interface.
internal fun register(lib: UniffiLib) {
lib.uniffi_xmtpv3_fn_init_callback_vtable_ffilogger(vtable)
}
}

/**
* The ffiConverter which transforms the Callbacks in to handles to pass to Rust.
*
* @suppress
*/
public object FfiConverterTypeFfiLogger : FfiConverterCallbackInterface<FfiLogger>()


/**
* @suppress
*/
Expand Down Expand Up @@ -11284,7 +11160,6 @@ public object FfiConverterMapStringBoolean :
@Throws(GenericException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
suspend fun `createClient`(
`logger`: FfiLogger,
`host`: kotlin.String,
`isSecure`: kotlin.Boolean,
`db`: kotlin.String?,
Expand All @@ -11297,9 +11172,6 @@ suspend fun `createClient`(
): FfiXmtpClient {
return uniffiRustCallAsync(
UniffiLib.INSTANCE.uniffi_xmtpv3_fn_func_create_client(
FfiConverterTypeFfiLogger.lower(
`logger`
),
FfiConverterString.lower(`host`),
FfiConverterBoolean.lower(`isSecure`),
FfiConverterOptionalString.lower(`db`),
Expand Down Expand Up @@ -11406,19 +11278,15 @@ fun `generatePrivatePreferencesTopicIdentifier`(`privateKey`: kotlin.ByteArray):
@Throws(GenericException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
suspend fun `getInboxIdForAddress`(
`logger`: FfiLogger,
`host`: kotlin.String,
`isSecure`: kotlin.Boolean,
`accountAddress`: kotlin.String,
): kotlin.String? {
return uniffiRustCallAsync(
UniffiLib.INSTANCE.uniffi_xmtpv3_fn_func_get_inbox_id_for_address(
FfiConverterTypeFfiLogger.lower(
`logger`
),
FfiConverterString.lower(`host`),
FfiConverterBoolean.lower(`isSecure`),
FfiConverterString.lower(`accountAddress`),
FfiConverterString.lower(
`host`
), FfiConverterBoolean.lower(`isSecure`), FfiConverterString.lower(`accountAddress`),
),
{ future, callback, continuation ->
UniffiLib.INSTANCE.ffi_xmtpv3_rust_future_poll_rust_buffer(
Expand Down
Binary file modified library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so
Binary file not shown.
Loading