Skip to content

Commit

Permalink
remove the contacts and rename to conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 7, 2024
1 parent 9c97e77 commit 00225dc
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 505 deletions.
26 changes: 3 additions & 23 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,8 @@ public final class Client {
public let inboxID: String
public var hasV2Client: Bool = true

/// Access ``Conversations`` for this Client.
public lazy var conversations: Conversations = .init(client: self, ffiConversations: v3Client!.conversations())

/// Access ``Contacts`` for this Client.
public lazy var contacts: Contacts = .init(client: self)
public lazy var preferences: PrivatePreferences = .init(client: self, ffiClient: v3Client!)

/// The XMTP environment which specifies which network this Client is connected to.
public lazy var environment: XMTPEnvironment =
Expand Down Expand Up @@ -363,8 +360,7 @@ public final class Client {
installationID: v3Client?.installationId().toHex ?? "",
inboxID: v3Client?.inboxId() ?? inboxId)
let conversations = client.conversations
let contacts = client.contacts
try await client.ensureUserContactPublished()
let contacts = client.preferences

for codec in (options?.codecs ?? []) {
client.register(codec: codec)
Expand Down Expand Up @@ -512,7 +508,7 @@ public final class Client {
installationID: v3Client?.installationId().toHex ?? "",
inboxID: v3Client?.inboxId() ?? inboxId)
let conversations = result.conversations
let contacts = result.contacts
let contacts = result.preferences
for codec in options.codecs {
result.register(codec: codec)
}
Expand Down Expand Up @@ -595,17 +591,6 @@ public final class Client {
.envelopes.count > 0
}

func ensureUserContactPublished() async throws {
if let contact = try await getUserContact(peerAddress: address),
case .v2 = contact.version,
try keys.getPublicKeyBundle().equals(contact.v2.keyBundle)
{
return
}

try await publishUserContact(legacy: true)
}

func publishUserContact(legacy: Bool = false) async throws {
var envelopes: [Envelope] = []

Expand Down Expand Up @@ -714,11 +699,6 @@ public final class Client {
try await client.dbReconnect()
}

func getUserContact(peerAddress: String) async throws -> ContactBundle? {
let peerAddress = EthereumAddress(peerAddress).toChecksumAddress()
return try await contacts.find(peerAddress)
}

public func inboxIdFromAddress(address: String) async throws -> String? {
guard let client = v3Client else {
throw ClientError.noV3Client("Error no V3 client initialized")
Expand Down
Loading

0 comments on commit 00225dc

Please sign in to comment.