diff --git a/Sources/XMTP/ConversationV2.swift b/Sources/XMTP/ConversationV2.swift index 58da11ea..cd345d9b 100644 --- a/Sources/XMTP/ConversationV2.swift +++ b/Sources/XMTP/ConversationV2.swift @@ -15,12 +15,12 @@ public struct ConversationV2Container: Codable { var conversationID: String? var metadata: [String: String] = [:] var peerAddress: String - var createdAt: UInt64? + var createdAtNs: UInt64? var header: SealedInvitationHeaderV1 public func decode(with client: Client) -> ConversationV2 { let context = InvitationV1.Context(conversationID: conversationID ?? "", metadata: metadata) - return ConversationV2(topic: topic, keyMaterial: keyMaterial, context: context, peerAddress: peerAddress, client: client, createdAt: createdAt, header: header) + return ConversationV2(topic: topic, keyMaterial: keyMaterial, context: context, peerAddress: peerAddress, client: client, createdAtNs: createdAtNs, header: header) } } @@ -48,33 +48,33 @@ public struct ConversationV2 { context: invitation.context, peerAddress: peerAddress, client: client, - createdAt: header.createdNs, + createdAtNs: header.createdNs, header: header ) } - public init(topic: String, keyMaterial: Data, context: InvitationV1.Context, peerAddress: String, client: Client, createdAt: UInt64? = nil) { + public init(topic: String, keyMaterial: Data, context: InvitationV1.Context, peerAddress: String, client: Client, createdAtNs: UInt64? = nil) { self.topic = topic self.keyMaterial = keyMaterial self.context = context self.peerAddress = peerAddress self.client = client - self.createdAtNs = createdAt + self.createdAtNs = createdAtNs header = SealedInvitationHeaderV1() } - public init(topic: String, keyMaterial: Data, context: InvitationV1.Context, peerAddress: String, client: Client, createdAt: UInt64? = nil, header: SealedInvitationHeaderV1) { + public init(topic: String, keyMaterial: Data, context: InvitationV1.Context, peerAddress: String, client: Client, createdAtNs: UInt64? = nil, header: SealedInvitationHeaderV1) { self.topic = topic self.keyMaterial = keyMaterial self.context = context self.peerAddress = peerAddress self.client = client - self.createdAtNs = createdAt + self.createdAtNs = createdAtNs self.header = header } public var encodedContainer: ConversationV2Container { - ConversationV2Container(topic: topic, keyMaterial: keyMaterial, conversationID: context.conversationID, metadata: context.metadata, peerAddress: peerAddress, createdAt: createdAtNs, header: header) + ConversationV2Container(topic: topic, keyMaterial: keyMaterial, conversationID: context.conversationID, metadata: context.metadata, peerAddress: peerAddress, createdAtNs: createdAtNs, header: header) } func prepareMessage(encodedContent: EncodedContent, options: SendOptions?) async throws -> PreparedMessage { diff --git a/Sources/XMTP/Conversations.swift b/Sources/XMTP/Conversations.swift index d7f6dd7d..b6e2072a 100644 --- a/Sources/XMTP/Conversations.swift +++ b/Sources/XMTP/Conversations.swift @@ -27,7 +27,7 @@ public actor Conversations { context: data.invitation.context, peerAddress: data.peerAddress, client: client, - createdAt: data.createdNs + createdAtNs: data.createdNs )) } conversationsByTopic[conversation.topic] = conversation diff --git a/Tests/XMTPTests/MessageTests.swift b/Tests/XMTPTests/MessageTests.swift index 76d59c27..0f801327 100644 --- a/Tests/XMTPTests/MessageTests.swift +++ b/Tests/XMTPTests/MessageTests.swift @@ -141,7 +141,7 @@ class MessageTests: XCTestCase { return } - let conversation = ConversationV2(topic: decodedConversation.topic, keyMaterial: decodedConversation.keyMaterial, context: InvitationV1.Context(), peerAddress: decodedConversation.peerAddress, client: client, createdAt: decodedConversation.createdAt, header: SealedInvitationHeaderV1()) + let conversation = ConversationV2(topic: decodedConversation.topic, keyMaterial: decodedConversation.keyMaterial, context: InvitationV1.Context(), peerAddress: decodedConversation.peerAddress, client: client, header: SealedInvitationHeaderV1()) let decodedMessage = try conversation.decode(envelope: envelope) XCTAssertEqual(decodedMessage.id, "e42a7dd44d0e1214824eab093cb89cfe6f666298d0af2d54fe0c914c8b72eff3")