diff --git a/LibXMTP.podspec b/LibXMTP.podspec index edc7bf5..fe944b1 100644 --- a/LibXMTP.podspec +++ b/LibXMTP.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'LibXMTP' - s.version = '0.5.0-beta0' + s.version = '0.5.0-beta1' s.summary = 'XMTP shared Rust code that powers cross-platform SDKs' s.homepage = 'https://github.com/xmtp/libxmtp-swift' @@ -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-ca024cb/LibXMTPSwiftFFI.zip", :type => :zip } + s.source = { :http => "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-c86272d/LibXMTPSwiftFFI.zip", :type => :zip } s.vendored_frameworks = 'LibXMTPSwiftFFI.xcframework' s.source_files = 'Sources/LibXMTP/**/*' end diff --git a/Package.swift b/Package.swift index 5866c32..abe8757 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-ca024cb/LibXMTPSwiftFFI.zip", - checksum: "2e06d57a14c849e89803c2294d46c4f09ae6d7797153ebbd510194adc6c42852" + url: "https://github.com/xmtp/libxmtp/releases/download/swift-bindings-c86272d/LibXMTPSwiftFFI.zip", + checksum: "c9a5fdc8ffc936f1f3901cb3cb3aedea06782a68d962ef498696fd7e4f888c48" ), .testTarget(name: "LibXMTPTests", dependencies: ["LibXMTP"]), ] diff --git a/Sources/LibXMTP/libxmtp-version.txt b/Sources/LibXMTP/libxmtp-version.txt index 9311802..691b263 100644 --- a/Sources/LibXMTP/libxmtp-version.txt +++ b/Sources/LibXMTP/libxmtp-version.txt @@ -1,3 +1,3 @@ -Version: ca024cbb -Branch: main -Date: 2024-05-24 20:35:12 +0000 +Version: c86272d +Branch: HEAD +Date: 2024-05-28 21:11:59 +0000 diff --git a/Sources/LibXMTP/xmtpv3.swift b/Sources/LibXMTP/xmtpv3.swift index 5296dd9..9d7402d 100644 --- a/Sources/LibXMTP/xmtpv3.swift +++ b/Sources/LibXMTP/xmtpv3.swift @@ -691,12 +691,18 @@ public func FfiConverterTypeFfiConversations_lower(_ value: FfiConversations) -> } public protocol FfiGroupProtocol: AnyObject { + func addAdmin(inboxId: String) async throws + func addMembers(accountAddresses: [String]) async throws func addMembersByInboxId(inboxIds: [String]) async throws + func addSuperAdmin(inboxId: String) async throws + func addedByInboxId() throws -> String + func adminList() throws -> [String] + func createdAtNs() -> Int64 func findMessages(opts: FfiListMessagesOptions) throws -> [FfiMessage] @@ -705,22 +711,34 @@ public protocol FfiGroupProtocol: AnyObject { func groupName() throws -> String + func groupPermissions() throws -> FfiGroupPermissions + func id() -> Data func isActive() throws -> Bool + func isAdmin(inboxId: String) throws -> Bool + + func isSuperAdmin(inboxId: String) throws -> Bool + func listMembers() throws -> [FfiGroupMember] func processStreamedGroupMessage(envelopeBytes: Data) async throws -> FfiMessage + func removeAdmin(inboxId: String) async throws + func removeMembers(accountAddresses: [String]) async throws func removeMembersByInboxId(inboxIds: [String]) async throws + func removeSuperAdmin(inboxId: String) async throws + func send(contentBytes: Data) async throws -> Data func stream(messageCallback: FfiMessageCallback) async throws -> FfiStreamCloser + func superAdminList() throws -> [String] + func sync() async throws func updateGroupName(groupName: String) async throws @@ -766,6 +784,23 @@ open class FfiGroup: try! rustCall { uniffi_xmtpv3_fn_free_ffigroup(pointer, $0) } } + open func addAdmin(inboxId: String) async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_xmtpv3_fn_method_ffigroup_add_admin( + self.uniffiClonePointer(), + FfiConverterString.lower(inboxId) + ) + }, + 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 addMembers(accountAddresses: [String]) async throws { return try await uniffiRustCallAsync( @@ -800,12 +835,35 @@ open class FfiGroup: ) } + open func addSuperAdmin(inboxId: String) async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_xmtpv3_fn_method_ffigroup_add_super_admin( + self.uniffiClonePointer(), + FfiConverterString.lower(inboxId) + ) + }, + 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 addedByInboxId() throws -> String { return try FfiConverterString.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { uniffi_xmtpv3_fn_method_ffigroup_added_by_inbox_id(self.uniffiClonePointer(), $0) }) } + open func adminList() throws -> [String] { + return try FfiConverterSequenceString.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_ffigroup_admin_list(self.uniffiClonePointer(), $0) + }) + } + open func createdAtNs() -> Int64 { return try! FfiConverterInt64.lift(try! rustCall { uniffi_xmtpv3_fn_method_ffigroup_created_at_ns(self.uniffiClonePointer(), $0) @@ -831,6 +889,12 @@ open class FfiGroup: }) } + open func groupPermissions() throws -> FfiGroupPermissions { + return try FfiConverterTypeFfiGroupPermissions.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_ffigroup_group_permissions(self.uniffiClonePointer(), $0) + }) + } + open func id() -> Data { return try! FfiConverterData.lift(try! rustCall { uniffi_xmtpv3_fn_method_ffigroup_id(self.uniffiClonePointer(), $0) @@ -843,6 +907,20 @@ open class FfiGroup: }) } + open func isAdmin(inboxId: String) throws -> Bool { + return try FfiConverterBool.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_ffigroup_is_admin(self.uniffiClonePointer(), + FfiConverterString.lower(inboxId), $0) + }) + } + + open func isSuperAdmin(inboxId: String) throws -> Bool { + return try FfiConverterBool.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_ffigroup_is_super_admin(self.uniffiClonePointer(), + FfiConverterString.lower(inboxId), $0) + }) + } + open func listMembers() throws -> [FfiGroupMember] { return try FfiConverterSequenceTypeFfiGroupMember.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { uniffi_xmtpv3_fn_method_ffigroup_list_members(self.uniffiClonePointer(), $0) @@ -866,6 +944,23 @@ open class FfiGroup: ) } + open func removeAdmin(inboxId: String) async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_xmtpv3_fn_method_ffigroup_remove_admin( + self.uniffiClonePointer(), + FfiConverterString.lower(inboxId) + ) + }, + 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 removeMembers(accountAddresses: [String]) async throws { return try await uniffiRustCallAsync( @@ -900,6 +995,23 @@ open class FfiGroup: ) } + open func removeSuperAdmin(inboxId: String) async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_xmtpv3_fn_method_ffigroup_remove_super_admin( + self.uniffiClonePointer(), + FfiConverterString.lower(inboxId) + ) + }, + 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 send(contentBytes: Data) async throws -> Data { return try await uniffiRustCallAsync( @@ -934,6 +1046,12 @@ open class FfiGroup: ) } + open func superAdminList() throws -> [String] { + return try FfiConverterSequenceString.lift(rustCallWithError(FfiConverterTypeGenericError.lift) { + uniffi_xmtpv3_fn_method_ffigroup_super_admin_list(self.uniffiClonePointer(), $0) + }) + } + open func sync() async throws { return try await uniffiRustCallAsync( @@ -2929,8 +3047,8 @@ extension GenericError: Error {} // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. public enum GroupPermissions { - case everyoneIsAdmin - case groupCreatorIsAdmin + case allMembers + case adminOnly } public struct FfiConverterTypeGroupPermissions: FfiConverterRustBuffer { @@ -2939,9 +3057,9 @@ public struct FfiConverterTypeGroupPermissions: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GroupPermissions { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .everyoneIsAdmin + case 1: return .allMembers - case 2: return .groupCreatorIsAdmin + case 2: return .adminOnly default: throw UniffiInternalError.unexpectedEnumCase } @@ -2949,10 +3067,10 @@ public struct FfiConverterTypeGroupPermissions: FfiConverterRustBuffer { public static func write(_ value: GroupPermissions, into buf: inout [UInt8]) { switch value { - case .everyoneIsAdmin: + case .allMembers: writeInt(&buf, Int32(1)) - case .groupCreatorIsAdmin: + case .adminOnly: writeInt(&buf, Int32(2)) } } @@ -4037,15 +4155,24 @@ private var initializationResult: InitializationResult { if uniffi_xmtpv3_checksum_method_fficonversations_sync() != 9054 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_ffigroup_add_admin() != 4600 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_ffigroup_add_members() != 27666 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_method_ffigroup_add_members_by_inbox_id() != 23290 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_ffigroup_add_super_admin() != 40681 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_ffigroup_added_by_inbox_id() != 37220 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_ffigroup_admin_list() != 51010 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_ffigroup_created_at_ns() != 4894 { return InitializationResult.apiChecksumMismatch } @@ -4058,30 +4185,48 @@ private var initializationResult: InitializationResult { if uniffi_xmtpv3_checksum_method_ffigroup_group_name() != 61525 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_ffigroup_group_permissions() != 15980 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_ffigroup_id() != 36764 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_method_ffigroup_is_active() != 33848 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_ffigroup_is_admin() != 26672 { + return InitializationResult.apiChecksumMismatch + } + if uniffi_xmtpv3_checksum_method_ffigroup_is_super_admin() != 61614 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_ffigroup_list_members() != 61034 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_method_ffigroup_process_streamed_group_message() != 19069 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_ffigroup_remove_admin() != 57094 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_ffigroup_remove_members() != 24336 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_method_ffigroup_remove_members_by_inbox_id() != 45424 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_ffigroup_remove_super_admin() != 35336 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_ffigroup_send() != 37701 { return InitializationResult.apiChecksumMismatch } if uniffi_xmtpv3_checksum_method_ffigroup_stream() != 45558 { return InitializationResult.apiChecksumMismatch } + if uniffi_xmtpv3_checksum_method_ffigroup_super_admin_list() != 5323 { + return InitializationResult.apiChecksumMismatch + } if uniffi_xmtpv3_checksum_method_ffigroup_sync() != 24219 { return InitializationResult.apiChecksumMismatch }