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

feat: V3 only dms #411

Merged
merged 54 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ede8122
update package
nplasterer Sep 13, 2024
70c3a41
Merge branch 'main' of https://github.com/xmtp/xmtp-ios
nplasterer Sep 13, 2024
c72c33c
Merge branch 'main' of https://github.com/xmtp/xmtp-ios
nplasterer Sep 20, 2024
2f9cca8
add chain id and SCW check
nplasterer Sep 20, 2024
4e43786
add implementation
nplasterer Sep 20, 2024
ede8c29
fix a little formatting
nplasterer Sep 21, 2024
fd8ddc1
change defaults
nplasterer Sep 21, 2024
bc9fb62
Merge branch 'main' of https://github.com/xmtp/xmtp-ios
nplasterer Sep 22, 2024
65a4aaa
make a test release pod
nplasterer Sep 24, 2024
a366503
bump the latest libxmtp
nplasterer Sep 24, 2024
a46302b
fix up all the async tests
nplasterer Sep 24, 2024
16e2e6d
add installation timestamps and async members
nplasterer Sep 26, 2024
35f8053
Merge branch 'main' of https://github.com/xmtp/xmtp-ios into np/smart…
nplasterer Sep 26, 2024
f02d489
fix up the tests and bump the pod
nplasterer Sep 26, 2024
0e8ab5b
Merge branch 'np/stream-groups-logging' of https://github.com/xmtp/xm…
nplasterer Sep 26, 2024
e246103
bump to the next version
nplasterer Sep 26, 2024
f19b9b7
Merge branch 'main' of https://github.com/xmtp/xmtp-ios into np/smart…
nplasterer Sep 26, 2024
ef8dea9
bad merge
nplasterer Sep 26, 2024
03d4215
Merge branch 'main' of https://github.com/xmtp/xmtp-ios into np/smart…
nplasterer Oct 2, 2024
67a88fc
update the package
nplasterer Oct 2, 2024
929ac84
fix up bad merge
nplasterer Oct 2, 2024
a2d472a
Merge branch 'main' of https://github.com/xmtp/xmtp-ios into np/smart…
nplasterer Oct 9, 2024
63b79e1
make block number optional
nplasterer Oct 9, 2024
402ee51
add a test to reproduce the scw error
nplasterer Oct 9, 2024
d1f509d
update to latest libxmtp
nplasterer Oct 11, 2024
abe6af8
update the signers
nplasterer Oct 18, 2024
2cd20ce
update to the latest libxmtp functions
nplasterer Oct 18, 2024
2812b8a
fix the linter
nplasterer Oct 18, 2024
b03101f
get on a working version
nplasterer Oct 19, 2024
263bf64
check the chain id
nplasterer Oct 19, 2024
14b0cff
chain id is optional
nplasterer Oct 19, 2024
b986370
fix the lint issue
nplasterer Oct 20, 2024
87b8b42
tag
nplasterer Oct 20, 2024
4f36f8c
remove chain id from inbox id creation
nplasterer Oct 23, 2024
e704cea
update the SCW functionality and message listing
nplasterer Oct 23, 2024
39e52ef
small tweak to message listing
nplasterer Oct 23, 2024
b1678a9
get closer
nplasterer Oct 23, 2024
b169c71
small test clean up
nplasterer Oct 23, 2024
6c6a2f5
add the basic functionality to conversation and client
nplasterer Oct 23, 2024
c7564b9
put V2 stuff below the line
nplasterer Oct 23, 2024
0087142
more common functions
nplasterer Oct 23, 2024
f7bbd96
Merge branch 'main' of https://github.com/xmtp/xmtp-ios into np/v3-on…
nplasterer Oct 23, 2024
6e7abe7
reorder the conversations class and add additional functionality
nplasterer Oct 23, 2024
e445e13
get everything compiling
nplasterer Oct 24, 2024
e8f2d8c
write a bunch of dm tests
nplasterer Oct 24, 2024
b8be6d2
more tests
nplasterer Oct 24, 2024
585010d
beefing up all the tests
nplasterer Oct 24, 2024
4f84a16
fix up some tests
nplasterer Oct 24, 2024
f0948ba
Update Sources/XMTPiOS/Conversations.swift
nplasterer Oct 24, 2024
307c5a4
Update Tests/XMTPTests/V3ClientTests.swift
nplasterer Oct 24, 2024
ae5adf6
Update Sources/XMTPiOS/Conversation.swift
nplasterer Oct 24, 2024
1d00582
Update Tests/XMTPTests/GroupTests.swift
nplasterer Oct 24, 2024
d1d70d6
add return statements
nplasterer Oct 24, 2024
ca81bb6
get all the tests passing
nplasterer Oct 24, 2024
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
38 changes: 38 additions & 0 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum ClientError: Error, CustomStringConvertible, LocalizedError {
case creationError(String)
case noV3Client(String)
case noV2Client(String)
case missingInboxId

public var description: String {
switch self {
Expand All @@ -24,6 +25,8 @@ public enum ClientError: Error, CustomStringConvertible, LocalizedError {
return "ClientError.noV3Client: \(err)"
case .noV2Client(let err):
return "ClientError.noV2Client: \(err)"
case .missingInboxId:
return "ClientError.missingInboxId"
}
}

Expand Down Expand Up @@ -693,6 +696,41 @@ public final class Client {
return nil
}
}

public func findConversation(conversationId: String) throws -> Conversation? {
guard let client = v3Client else {
throw ClientError.noV3Client("Error no V3 client initialized")
}
let conversation = try client.conversation(conversationId: conversationId.hexToData)
return try conversation.toConversation(client: self)
}

public func findConversationByTopic(topic: String) throws -> Conversation? {
guard let client = v3Client else {
throw ClientError.noV3Client("Error no V3 client initialized")
}
let regexPattern = #"/xmtp/mls/1/g-(.*?)/proto"#
if let regex = try? NSRegularExpression(pattern: regexPattern) {
let range = NSRange(location: 0, length: topic.utf16.count)
if let match = regex.firstMatch(in: topic, options: [], range: range) {
let conversationId = (topic as NSString).substring(with: match.range(at: 1))
let conversation = try client.conversation(conversationId: conversationId.hexToData)
return try conversation.toConversation(client: self)
}
}
return nil
}
nplasterer marked this conversation as resolved.
Show resolved Hide resolved

public func findDm(address: String) async throws -> Dm? {
guard let client = v3Client else {
throw ClientError.noV3Client("Error no V3 client initialized")
}
guard let inboxId = try await inboxIdFromAddress(address: address) else {
throw ClientError.creationError("No inboxId present")
}
let conversation = try client.dmConversation(targetInboxId: inboxId)
return Dm(ffiConversation: conversation, client: self)
}

public func findMessage(messageId: String) throws -> MessageV3? {
guard let client = v3Client else {
Expand Down
Loading
Loading