diff --git a/README.md b/README.md index 102a252c..1b71cecf 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ try await conversation.send("gm") // Listen for new messages in the conversation Task { for await message in try await conversation.streamMessages() { - print("\(message.senderAddress): \(message.body)") + print("\(message.senderInboxId): \(message.body)") } } ``` @@ -193,7 +193,7 @@ let nextPage = try await conversation.messages(limit: 25, before: messages.first You can listen for any new messages (incoming or outgoing) in a conversation by calling `conversation.streamMessages()`. -A successfully received message (that makes it through the decoding and decryption without throwing) can be trusted to be authentic. Authentic means that it was sent by the owner of the `message.senderAddress` account and that it wasn't modified in transit. The `message.sent` timestamp can be trusted to have been set by the sender. +A successfully received message (that makes it through the decoding and decryption without throwing) can be trusted to be authentic. Authentic means that it was sent by the owner of the `message.senderInboxId` account and that it wasn't modified in transit. The `message.sent` timestamp can be trusted to have been set by the sender. The flow returned by the `stream` methods is an asynchronous data stream that sequentially emits values and completes normally or with an exception. @@ -202,10 +202,10 @@ The flow returned by the `stream` methods is an asynchronous data stream that se Task { for await message in try await conversation.streamMessages() { - if message.senderAddress == client.address { + if message.senderInboxId == client.address { // This message was sent from me } - print("New message from \(message.senderAddress): \(message.body)") + print("New message from \(message.senderInboxId): \(message.body)") } } ``` diff --git a/Sources/XMTPiOS/DecodedMessage.swift b/Sources/XMTPiOS/DecodedMessage.swift index abe82d4b..99013cf0 100644 --- a/Sources/XMTPiOS/DecodedMessage.swift +++ b/Sources/XMTPiOS/DecodedMessage.swift @@ -9,7 +9,7 @@ public struct DecodedMessage: Sendable { public var encodedContent: EncodedContent /// The wallet address of the sender of the message - public var senderAddress: String + public var senderInboxId: String /// When the message was sent public var sent: Date @@ -24,7 +24,7 @@ public struct DecodedMessage: Sendable { client: Client, topic: String, encodedContent: EncodedContent, - senderAddress: String, + senderInboxId: String, sent: Date, sentNs: Int64, deliveryStatus: MessageDeliveryStatus = .published @@ -33,7 +33,7 @@ public struct DecodedMessage: Sendable { self.client = client self.topic = topic self.encodedContent = encodedContent - self.senderAddress = senderAddress + self.senderInboxId = senderInboxId self.sent = sent self.sentNs = sentNs self.deliveryStatus = deliveryStatus diff --git a/Sources/XMTPiOS/Libxmtp/Message.swift b/Sources/XMTPiOS/Libxmtp/Message.swift index 5ff214b3..1dd5e6d5 100644 --- a/Sources/XMTPiOS/Libxmtp/Message.swift +++ b/Sources/XMTPiOS/Libxmtp/Message.swift @@ -68,7 +68,7 @@ public struct Message: Identifiable { client: client, topic: Topic.groupMessage(convoId).description, encodedContent: encodedContent, - senderAddress: senderInboxId, + senderInboxId: senderInboxId, sent: sentAt, sentNs: sentAtNs, deliveryStatus: deliveryStatus diff --git a/XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift b/XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift index f7483ab9..dbf128ab 100644 --- a/XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift +++ b/XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift @@ -17,12 +17,12 @@ struct MessageTextView: View { var body: some View { VStack { HStack { - if message.senderAddress.lowercased() == myAddress.lowercased() { + if message.senderInboxId.lowercased() == myAddress.lowercased() { Spacer() } VStack(alignment: .leading) { - if isGroup && message.senderAddress.lowercased() != myAddress.lowercased() { - Text(message.senderAddress) + if isGroup && message.senderInboxId.lowercased() != myAddress.lowercased() { + Text(message.senderInboxId) .font(.caption) .foregroundStyle(.secondary) } @@ -32,7 +32,7 @@ struct MessageTextView: View { if isDebugging { Text("My Address \(myAddress)") .font(.caption) - Text("Sender Address \(message.senderAddress)") + Text("Sender Address \(message.senderInboxId)") .font(.caption) } } @@ -46,7 +46,7 @@ struct MessageTextView: View { isDebugging.toggle() } } - if message.senderAddress.lowercased() != myAddress.lowercased() { + if message.senderInboxId.lowercased() != myAddress.lowercased() { Spacer() } } @@ -62,7 +62,7 @@ struct MessageTextView: View { } var background: Color { - if message.senderAddress.lowercased() == myAddress.lowercased() { + if message.senderInboxId.lowercased() == myAddress.lowercased() { return .purple } else { return .secondary.opacity(0.2) @@ -70,7 +70,7 @@ struct MessageTextView: View { } var color: Color { - if message.senderAddress.lowercased() == myAddress.lowercased() { + if message.senderInboxId.lowercased() == myAddress.lowercased() { return .white } else { return .primary diff --git a/dev/local/test/script.js b/dev/local/test/script.js deleted file mode 100644 index 164a446c..00000000 --- a/dev/local/test/script.js +++ /dev/null @@ -1,35 +0,0 @@ -let Client = require("@xmtp/xmtp-js").Client; -let Wallet = require("ethers").Wallet; - -console.log("NODE VERSION", process.version); - -// 0xf4BF19Ed562651837bc11ff975472ABd239D35B5 -const keyBytes = [ - 80, 7, 53, 52, 122, 163, 75, 130, 199, 86, 216, 14, 29, 2, 255, 71, 121, 51, - 165, 3, 208, 178, 193, 207, 223, 217, 75, 247, 84, 78, 204, 3, -]; - -async function checkAll() { - const wallet = new Wallet(keyBytes); - const client = await Client.create(wallet, { - apiUrl: "http://wakunode:5555", - }); - - console.log("Listening…"); - - try { - for await (const message of await client.conversations.streamAllMessages()) { - if (message.senderAddress === wallet.address) { - continue; - } - - await message.conversation.send("HI " + message.senderAddress); - console.log(`Replied to ${message.senderAddress}`); - } - } catch (e) { - console.info(`Error:`, e); - await checkAll(); - } -} - -checkAll().then(() => console.log("Done")); \ No newline at end of file