Skip to content

Commit

Permalink
Merge pull request #28 from xmtp/np/update-latest-libxmtp
Browse files Browse the repository at this point in the history
Bump for SQL DB Functions
  • Loading branch information
nplasterer authored May 23, 2024
2 parents f2b73d1 + 2e59332 commit 11ac13b
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 18 deletions.
4 changes: 2 additions & 2 deletions LibXMTP.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'LibXMTP'
s.version = '0.4.4-beta5'
s.version = '0.4.4-beta6'
s.summary = 'XMTP shared Rust code that powers cross-platform SDKs'

s.homepage = 'https://github.com/xmtp/libxmtp-swift'
Expand All @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.platform = :ios, '13.0', :macos, '11.0'
s.swift_version = '5.3'

s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-49f945a/LibXMTPSwiftFFI.zip", :type => :zip }
s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-5b7cb6b/LibXMTPSwiftFFI.zip", :type => :zip }
s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework'
s.source_files = 'Sources/LibXMTP/**/*'
end
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ let package = Package(
),
.binaryTarget(
name: "LibXMTPSwiftFFI",
url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-49f945a/LibXMTPSwiftFFI.zip",
checksum: "fd642ca41569a04401bbe92edb8905e7997c8a06230d55b8c22117bc2864295c"
url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-5b7cb6b/LibXMTPSwiftFFI.zip",
checksum: "983c29d166fb5433b9a2c3025e624e420a05854a20946e897c76468ad92d5928"
),
.testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]),
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/LibXMTP/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 49f945a
Version: 5b7cb6bc
Branch: main
Date: 2024-04-24 17:02:27 +0000
Date: 2024-05-23 17:10:07 +0000
119 changes: 107 additions & 12 deletions Sources/LibXMTP/xmtpv3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,6 @@ public func FfiConverterTypeFfiGroup_lower(_ value: FfiGroup) -> UnsafeMutableRa
public protocol FfiGroupMetadataProtocol {
func conversationType() -> String
func creatorAccountAddress() -> String
func policyType() throws -> GroupPermissions
}

public class FfiGroupMetadata: FfiGroupMetadataProtocol {
Expand Down Expand Up @@ -861,14 +860,6 @@ public class FfiGroupMetadata: FfiGroupMetadataProtocol {
}
)
}

public func policyType() throws -> GroupPermissions {
return try FfiConverterTypeGroupPermissions.lift(
rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigroupmetadata_policy_type(self.pointer, $0)
}
)
}
}

public struct FfiConverterTypeFfiGroupMetadata: FfiConverter {
Expand Down Expand Up @@ -909,6 +900,71 @@ public func FfiConverterTypeFfiGroupMetadata_lower(_ value: FfiGroupMetadata) ->
return FfiConverterTypeFfiGroupMetadata.lower(value)
}

public protocol FfiGroupPermissionsProtocol {
func policyType() throws -> GroupPermissions
}

public class FfiGroupPermissions: FfiGroupPermissionsProtocol {
fileprivate let pointer: UnsafeMutableRawPointer

// TODO: We'd like this to be `private` but for Swifty reasons,
// we can't implement `FfiConverter` without making this `required` and we can't
// make it `required` without making it `public`.
required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
self.pointer = pointer
}

deinit {
try! rustCall { uniffi_xmtpv3_fn_free_ffigrouppermissions(pointer, $0) }
}

public func policyType() throws -> GroupPermissions {
return try FfiConverterTypeGroupPermissions.lift(
rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffigrouppermissions_policy_type(self.pointer, $0)
}
)
}
}

public struct FfiConverterTypeFfiGroupPermissions: FfiConverter {
typealias FfiType = UnsafeMutableRawPointer
typealias SwiftType = FfiGroupPermissions

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FfiGroupPermissions {
let v: UInt64 = try readInt(&buf)
// The Rust code won't compile if a pointer won't fit in a UInt64.
// We have to go via `UInt` because that's the thing that's the size of a pointer.
let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
if ptr == nil {
throw UniffiInternalError.unexpectedNullPointer
}
return try lift(ptr!)
}

public static func write(_ value: FfiGroupPermissions, into buf: inout [UInt8]) {
// This fiddling is because `Int` is the thing that's the same size as a pointer.
// The Rust code won't compile if a pointer won't fit in a `UInt64`.
writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
}

public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> FfiGroupPermissions {
return FfiGroupPermissions(unsafeFromRawPointer: pointer)
}

public static func lower(_ value: FfiGroupPermissions) -> UnsafeMutableRawPointer {
return value.pointer
}
}

public func FfiConverterTypeFfiGroupPermissions_lift(_ pointer: UnsafeMutableRawPointer) throws -> FfiGroupPermissions {
return try FfiConverterTypeFfiGroupPermissions.lift(pointer)
}

public func FfiConverterTypeFfiGroupPermissions_lower(_ value: FfiGroupPermissions) -> UnsafeMutableRawPointer {
return FfiConverterTypeFfiGroupPermissions.lower(value)
}

public protocol FfiStreamCloserProtocol {
func end()
func isClosed() -> Bool
Expand Down Expand Up @@ -1226,8 +1282,10 @@ public protocol FfiXmtpClientProtocol {
func accountAddress() -> String
func canMessage(accountAddresses: [String]) async throws -> [String: Bool]
func conversations() -> FfiConversations
func dbReconnect() async throws
func installationId() -> Data
func registerIdentity(recoverableWalletSignature: Data?) async throws
func releaseDbConnection() throws
func textToSign() -> String?
}

Expand Down Expand Up @@ -1279,6 +1337,21 @@ public class FfiXmtpClient: FfiXmtpClientProtocol {
)
}

public func dbReconnect() async throws {
return try await uniffiRustCallAsync(
rustFutureFunc: {
uniffi_xmtpv3_fn_method_ffixmtpclient_db_reconnect(
self.pointer
)
},
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
)
}

public func installationId() -> Data {
return try! FfiConverterData.lift(
try!
Expand All @@ -1304,6 +1377,13 @@ public class FfiXmtpClient: FfiXmtpClientProtocol {
)
}

public func releaseDbConnection() throws {
try
rustCallWithError(FfiConverterTypeGenericError.lift) {
uniffi_xmtpv3_fn_method_ffixmtpclient_release_db_connection(self.pointer, $0)
}
}

public func textToSign() -> String? {
return try! FfiConverterOptionString.lift(
try!
Expand Down Expand Up @@ -2239,6 +2319,9 @@ public enum GenericError {
// Simple error enums only carry a message
case GroupMetadata(message: String)

// Simple error enums only carry a message
case GroupMutablePermissions(message: String)

// Simple error enums only carry a message
case Generic(message: String)

Expand Down Expand Up @@ -2281,7 +2364,11 @@ public struct FfiConverterTypeGenericError: FfiConverterRustBuffer {
message: FfiConverterString.read(from: &buf)
)

case 8: return try .Generic(
case 8: return try .GroupMutablePermissions(
message: FfiConverterString.read(from: &buf)
)

case 9: return try .Generic(
message: FfiConverterString.read(from: &buf)
)

Expand All @@ -2305,8 +2392,10 @@ public struct FfiConverterTypeGenericError: FfiConverterRustBuffer {
writeInt(&buf, Int32(6))
case .GroupMetadata(_ /* message is ignored*/ ):
writeInt(&buf, Int32(7))
case .Generic(_ /* message is ignored*/ ):
case .GroupMutablePermissions(_ /* message is ignored*/ ):
writeInt(&buf, Int32(8))
case .Generic(_ /* message is ignored*/ ):
writeInt(&buf, Int32(9))
}
}
}
Expand Down Expand Up @@ -3655,7 +3744,7 @@ private var initializationResult: InitializationResult {
if uniffi_xmtpv3_checksum_method_ffigroupmetadata_creator_account_address() != 1906 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffigroupmetadata_policy_type() != 22845 {
if uniffi_xmtpv3_checksum_method_ffigrouppermissions_policy_type() != 43161 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffistreamcloser_end() != 47211 {
Expand Down Expand Up @@ -3697,12 +3786,18 @@ private var initializationResult: InitializationResult {
if uniffi_xmtpv3_checksum_method_ffixmtpclient_conversations() != 31628 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffixmtpclient_db_reconnect() != 33037 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffixmtpclient_installation_id() != 62523 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffixmtpclient_register_identity() != 64634 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffixmtpclient_release_db_connection() != 12677 {
return InitializationResult.apiChecksumMismatch
}
if uniffi_xmtpv3_checksum_method_ffixmtpclient_text_to_sign() != 25727 {
return InitializationResult.apiChecksumMismatch
}
Expand Down

0 comments on commit 11ac13b

Please sign in to comment.