From ef13a426aad95c753476738b6644fc48f045225b Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 4 Dec 2024 16:49:11 -0800 Subject: [PATCH 1/2] dump the schema --- LibXMTP.podspec | 2 +- Sources/LibXMTP/libxmtp-version.txt | 4 +- Sources/LibXMTP/xmtpv3.swift | 131 +++------------------------- 3 files changed, 14 insertions(+), 123 deletions(-) diff --git a/LibXMTP.podspec b/LibXMTP.podspec index 39dc472..604824c 100644 --- a/LibXMTP.podspec +++ b/LibXMTP.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'LibXMTP' - s.version = '3.0.9' + s.version = '3.0.10' s.summary = 'XMTP shared Rust code that powers cross-platform SDKs' s.homepage = 'https://github.com/xmtp/libxmtp-swift' diff --git a/Sources/LibXMTP/libxmtp-version.txt b/Sources/LibXMTP/libxmtp-version.txt index 23f3da6..1c1f9fb 100644 --- a/Sources/LibXMTP/libxmtp-version.txt +++ b/Sources/LibXMTP/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: 4620d939 +Version: 3103e7b9 Branch: main -Date: 2024-12-04 00:01:39 +0000 +Date: 2024-12-05 00:24:03 +0000 diff --git a/Sources/LibXMTP/xmtpv3.swift b/Sources/LibXMTP/xmtpv3.swift index 7d5e2b6..7a1c11c 100644 --- a/Sources/LibXMTP/xmtpv3.swift +++ b/Sources/LibXMTP/xmtpv3.swift @@ -3302,7 +3302,7 @@ public protocol FfiXmtpClientProtocol: AnyObject { /** * Starts the sync worker if the history sync url is present. */ - func maybeStartSyncWorker() async throws + func maybeStartSyncWorker() func message(messageId: Data) throws -> FfiMessage @@ -3584,20 +3584,9 @@ open class FfiXmtpClient: /** * Starts the sync worker if the history sync url is present. */ - open func maybeStartSyncWorker() async throws { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_xmtpv3_fn_method_ffixmtpclient_maybe_start_sync_worker( - self.uniffiClonePointer() - ) - }, - pollFunc: ffi_xmtpv3_rust_future_poll_void, - completeFunc: ffi_xmtpv3_rust_future_complete_void, - freeFunc: ffi_xmtpv3_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypeGenericError.lift - ) + open func maybeStartSyncWorker() { try! rustCall { + uniffi_xmtpv3_fn_method_ffixmtpclient_maybe_start_sync_worker(self.uniffiClonePointer(), $0) + } } open func message(messageId: Data) throws -> FfiMessage { @@ -6201,100 +6190,6 @@ extension FfiConverterCallbackInterfaceFfiInboxOwner: FfiConverter { } } -public protocol FfiLogger: AnyObject { - func log(level: UInt32, levelLabel: String, message: String) -} - -// Put the implementation in a struct so we don't pollute the top-level namespace -private enum UniffiCallbackInterfaceFfiLogger { - // Create the VTable using a series of closures. - // Swift automatically converts these into C callback functions. - static var vtable: UniffiVTableCallbackInterfaceFfiLogger = .init( - log: { ( - uniffiHandle: UInt64, - level: UInt32, - levelLabel: RustBuffer, - message: RustBuffer, - _: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws in - guard let uniffiObj = try? FfiConverterCallbackInterfaceFfiLogger.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return try uniffiObj.log( - level: FfiConverterUInt32.lift(level), - levelLabel: FfiConverterString.lift(levelLabel), - message: FfiConverterString.lift(message) - ) - } - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - uniffiFree: { (uniffiHandle: UInt64) in - let result = try? FfiConverterCallbackInterfaceFfiLogger.handleMap.remove(handle: uniffiHandle) - if result == nil { - print("Uniffi callback interface FfiLogger: handle missing in uniffiFree") - } - } - ) -} - -private func uniffiCallbackInitFfiLogger() { - uniffi_xmtpv3_fn_init_callback_vtable_ffilogger(&UniffiCallbackInterfaceFfiLogger.vtable) -} - -// FfiConverter protocol for callback interfaces -#if swift(>=5.8) - @_documentation(visibility: private) -#endif -private enum FfiConverterCallbackInterfaceFfiLogger { - fileprivate static var handleMap = UniffiHandleMap() -} - -#if swift(>=5.8) - @_documentation(visibility: private) -#endif -extension FfiConverterCallbackInterfaceFfiLogger: FfiConverter { - typealias SwiftType = FfiLogger - typealias FfiType = UInt64 - - #if swift(>=5.8) - @_documentation(visibility: private) - #endif - public static func lift(_ handle: UInt64) throws -> SwiftType { - try handleMap.get(handle: handle) - } - - #if swift(>=5.8) - @_documentation(visibility: private) - #endif - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - let handle: UInt64 = try readInt(&buf) - return try lift(handle) - } - - #if swift(>=5.8) - @_documentation(visibility: private) - #endif - public static func lower(_ v: SwiftType) -> UInt64 { - return handleMap.insert(obj: v) - } - - #if swift(>=5.8) - @_documentation(visibility: private) - #endif - public static func write(_ v: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(v)) - } -} - #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -6976,11 +6871,11 @@ private func uniffiFutureContinuationCallback(handle: UInt64, pollResult: Int8) * xmtp.create_client(account_address, nonce, inbox_id, Option) * ``` */ -public func createClient(logger: FfiLogger, host: String, isSecure: Bool, db: String?, encryptionKey: Data?, inboxId: String, accountAddress: String, nonce: UInt64, legacySignedPrivateKeyProto: Data?, historySyncUrl: String?) async throws -> FfiXmtpClient { +public func createClient(host: String, isSecure: Bool, db: String?, encryptionKey: Data?, inboxId: String, accountAddress: String, nonce: UInt64, legacySignedPrivateKeyProto: Data?, historySyncUrl: String?) async throws -> FfiXmtpClient { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_xmtpv3_fn_func_create_client(FfiConverterCallbackInterfaceFfiLogger.lower(logger), FfiConverterString.lower(host), FfiConverterBool.lower(isSecure), FfiConverterOptionString.lower(db), FfiConverterOptionData.lower(encryptionKey), FfiConverterString.lower(inboxId), FfiConverterString.lower(accountAddress), FfiConverterUInt64.lower(nonce), FfiConverterOptionData.lower(legacySignedPrivateKeyProto), FfiConverterOptionString.lower(historySyncUrl)) + uniffi_xmtpv3_fn_func_create_client(FfiConverterString.lower(host), FfiConverterBool.lower(isSecure), FfiConverterOptionString.lower(db), FfiConverterOptionData.lower(encryptionKey), FfiConverterString.lower(inboxId), FfiConverterString.lower(accountAddress), FfiConverterUInt64.lower(nonce), FfiConverterOptionData.lower(legacySignedPrivateKeyProto), FfiConverterOptionString.lower(historySyncUrl)) }, pollFunc: ffi_xmtpv3_rust_future_poll_pointer, completeFunc: ffi_xmtpv3_rust_future_complete_pointer, @@ -7030,11 +6925,11 @@ public func generatePrivatePreferencesTopicIdentifier(privateKey: Data) throws - }) } -public func getInboxIdForAddress(logger: FfiLogger, host: String, isSecure: Bool, accountAddress: String) async throws -> String? { +public func getInboxIdForAddress(host: String, isSecure: Bool, accountAddress: String) async throws -> String? { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_xmtpv3_fn_func_get_inbox_id_for_address(FfiConverterCallbackInterfaceFfiLogger.lower(logger), FfiConverterString.lower(host), FfiConverterBool.lower(isSecure), FfiConverterString.lower(accountAddress)) + uniffi_xmtpv3_fn_func_get_inbox_id_for_address(FfiConverterString.lower(host), FfiConverterBool.lower(isSecure), FfiConverterString.lower(accountAddress)) }, pollFunc: ffi_xmtpv3_rust_future_poll_rust_buffer, completeFunc: ffi_xmtpv3_rust_future_complete_rust_buffer, @@ -7149,7 +7044,7 @@ private var initializationResult: InitializationResult = { if bindings_contract_version != scaffolding_contract_version { return InitializationResult.contractVersionMismatch } - if uniffi_xmtpv3_checksum_func_create_client() != 6255 { + if uniffi_xmtpv3_checksum_func_create_client() != 50509 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_func_create_v2_client() != 48060 { @@ -7164,7 +7059,7 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_func_generate_private_preferences_topic_identifier() != 59124 { return InitializationResult.apiChecksumMismatch } - if uniffi_xmtpv3_checksum_func_get_inbox_id_for_address() != 36898 { + if uniffi_xmtpv3_checksum_func_get_inbox_id_for_address() != 35414 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_func_get_version_info() != 29277 { @@ -7491,7 +7386,7 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_method_ffixmtpclient_installation_id() != 37173 { return InitializationResult.apiChecksumMismatch } - if uniffi_xmtpv3_checksum_method_ffixmtpclient_maybe_start_sync_worker() != 27018 { + if uniffi_xmtpv3_checksum_method_ffixmtpclient_maybe_start_sync_worker() != 56811 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_method_ffixmtpclient_message() != 26932 { @@ -7533,16 +7428,12 @@ private var initializationResult: InitializationResult = { if uniffi_xmtpv3_checksum_method_ffiinboxowner_sign() != 30268 { return InitializationResult.apiChecksumMismatch } - if uniffi_xmtpv3_checksum_method_ffilogger_log() != 56011 { - return InitializationResult.apiChecksumMismatch - } uniffiCallbackInitFfiConsentCallback() uniffiCallbackInitFfiConversationCallback() uniffiCallbackInitFfiMessageCallback() uniffiCallbackInitFfiV2SubscriptionCallback() uniffiCallbackInitFfiInboxOwner() - uniffiCallbackInitFfiLogger() return InitializationResult.ok }() From ff705b04aa4c8115241044cda38260a1ba15855b Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 4 Dec 2024 17:14:54 -0800 Subject: [PATCH 2/2] bump the binaries --- LibXMTP.podspec | 2 +- Package.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LibXMTP.podspec b/LibXMTP.podspec index 604824c..d967f77 100644 --- a/LibXMTP.podspec +++ b/LibXMTP.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.platform = :ios, '14.0', :macos, '11.0' s.swift_version = '5.3' - s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-3acc160/LibXMTPSwiftFFI.zip", :type => :zip } + s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-3103e7b/LibXMTPSwiftFFI.zip", :type => :zip } s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework' s.source_files = 'Sources/LibXMTP/**/*' end diff --git a/Package.swift b/Package.swift index 0738a8e..ad75a24 100644 --- a/Package.swift +++ b/Package.swift @@ -27,8 +27,8 @@ let package = Package( ), .binaryTarget( name: "LibXMTPSwiftFFI", - url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-3acc160/LibXMTPSwiftFFI.zip", - checksum: "bc6c2d2e9774157f0d45dd6944ffeb566fa5ea8dc9cf2cc5334f54c0bc7dd432" + url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-3103e7b/LibXMTPSwiftFFI.zip", + checksum: "14642542b669be898ded997aaa7ea7e7a9aaf6801dfbbc1d702c2d88858b5048" ), .testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]), ]