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

Rename senderAddress to senderInboxId #574

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ repositories {
dependencies {
implementation project(':expo-modules-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
implementation "org.xmtp:android:3.0.17"
implementation "org.xmtp:android:3.0.18"
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.facebook.react:react-native:0.71.3'
implementation "com.daveanthonythomas.moshipack:moshipack:1.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.xmtp.android.library.Conversation
class ConversationWrapper {

companion object {
fun encodeToObj(
suspend fun encodeToObj(
client: Client,
conversation: Conversation,
conversationParams: ConversationParamsWrapper = ConversationParamsWrapper(),
Expand All @@ -25,7 +25,7 @@ class ConversationWrapper {
}
}

fun encode(
suspend fun encode(
client: Client,
conversation: Conversation,
conversationParams: ConversationParamsWrapper = ConversationParamsWrapper(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DecodedMessageWrapper {
"topic" to model.topic,
"contentTypeId" to model.encodedContent.type.description,
"content" to ContentJson(model.encodedContent).toJsonMap(),
"senderAddress" to model.senderAddress,
"senderInboxId" to model.senderInboxId,
"sentNs" to model.sentNs,
"fallback" to fallback,
"deliveryStatus" to model.deliveryStatus.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.xmtp.android.library.Dm

class DmWrapper {
companion object {
fun encodeToObj(
suspend fun encodeToObj(
client: Client,
dm: Dm,
dmParams: ConversationParamsWrapper = ConversationParamsWrapper(),
Expand All @@ -30,7 +30,7 @@ class DmWrapper {
}
}

fun encode(
suspend fun encode(
client: Client,
dm: Dm,
dmParams: ConversationParamsWrapper = ConversationParamsWrapper(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.xmtp.android.library.Group
class GroupWrapper {

companion object {
fun encodeToObj(
suspend fun encodeToObj(
client: Client,
group: Group,
groupParams: ConversationParamsWrapper = ConversationParamsWrapper(),
Expand Down Expand Up @@ -37,7 +37,7 @@ class GroupWrapper {
}
}

fun encode(
suspend fun encode(
client: Client,
group: Group,
groupParams: ConversationParamsWrapper = ConversationParamsWrapper(),
Expand Down
6 changes: 3 additions & 3 deletions example/dev/local/test/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ async function checkAll() {

try {
for await (const message of await client.conversations.streamAllMessages()) {
if (message.senderAddress === wallet.address) {
if (message.senderInboxId === wallet.address) {
continue
}

await message.conversation.send({
text: 'HI ' + message.senderAddress,
text: 'HI ' + message.senderInboxId,
})
console.log(`Replied to ${message.senderAddress}`)
console.log(`Replied to ${message.senderInboxId}`)
}
} catch (e) {
console.info(`Error:`, e)
Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ PODS:
- SQLCipher/standard (4.5.7):
- SQLCipher/common
- SwiftProtobuf (1.28.2)
- XMTP (3.0.18):
- XMTP (3.0.19):
- Connect-Swift (= 1.0.0)
- CryptoSwift (= 1.8.3)
- CSecp256k1 (~> 0.2)
Expand All @@ -459,7 +459,7 @@ PODS:
- ExpoModulesCore
- MessagePacker
- SQLCipher (= 4.5.7)
- XMTP (= 3.0.18)
- XMTP (= 3.0.19)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -762,8 +762,8 @@ SPEC CHECKSUMS:
RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396
SQLCipher: 5e6bfb47323635c8b657b1b27d25c5f1baf63bf5
SwiftProtobuf: 4dbaffec76a39a8dc5da23b40af1a5dc01a4c02d
XMTP: a15bc6d07ab387b6ac70fbd3234189dc174ca024
XMTPReactNative: 8010ff326eb0cbc69ece5ac6e9f7ca4acc9f3bf8
XMTP: b5311154b2a3cda7c07ce78ae9fa6d111bac979d
XMTPReactNative: 0d7f1d9b444eaeb3ffaf0fd29c6b71a0d6b6a29a
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd
Expand Down
16 changes: 8 additions & 8 deletions example/src/ConversationScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ export default function ConversationScreen({
showSender={
index === (filteredMessages || []).length - 1 ||
(index + 1 < (filteredMessages || []).length &&
filteredMessages![index + 1].senderAddress !==
message.senderAddress)
filteredMessages![index + 1].senderInboxId !==
message.senderInboxId)
}
/>
)}
Expand Down Expand Up @@ -469,8 +469,8 @@ function ReplyInputHeader({
}}
/>
<Text style={{ fontSize: 12, fontWeight: 'bold' }}>
{message?.senderAddress.slice(0, 6)}…
{message?.senderAddress.slice(-4)}
{message?.senderInboxId.slice(0, 6)}…
{message?.senderInboxId.slice(-4)}
</Text>
</View>
</TouchableHighlight>
Expand Down Expand Up @@ -864,8 +864,8 @@ function ReplyMessageHeader({
}}
/>
<Text style={{ fontSize: 12, fontWeight: 'bold' }}>
{message.senderAddress.slice(0, 6)}…
{message.senderAddress.slice(-4)}
{message.senderInboxId.slice(0, 6)}…
{message.senderInboxId.slice(-4)}
</Text>
{typeof content !== 'string' && 'text' in content && content.text ? (
<Text
Expand Down Expand Up @@ -955,8 +955,8 @@ function MessageItem({
}}
>
<Text style={{ fontWeight: 'bold' }}>
{message.senderAddress.slice(0, 6)}…
{message.senderAddress.slice(-4)}
{message.senderInboxId.slice(0, 6)}…
{message.senderInboxId.slice(-4)}
</Text>
<Text style={{ fontWeight: '300' }}>
{moment(message.sentNs / 1000000).fromNow()}
Expand Down
16 changes: 8 additions & 8 deletions example/src/GroupScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ export default function GroupScreen({
showSender={
index === (filteredMessages || []).length - 1 ||
(index + 1 < (filteredMessages || []).length &&
filteredMessages![index + 1].senderAddress !==
message.senderAddress)
filteredMessages![index + 1].senderInboxId !==
message.senderInboxId)
}
/>
)}
Expand Down Expand Up @@ -469,8 +469,8 @@ function ReplyInputHeader({
}}
/>
<Text style={{ fontSize: 12, fontWeight: 'bold' }}>
{message?.senderAddress.slice(0, 6)}
{message?.senderAddress.slice(-4)}
{message?.senderInboxId.slice(0, 6)}
{message?.senderInboxId.slice(-4)}
</Text>
</View>
</TouchableHighlight>
Expand Down Expand Up @@ -864,8 +864,8 @@ function ReplyMessageHeader({
}}
/>
<Text style={{ fontSize: 12, fontWeight: 'bold' }}>
{message.senderAddress.slice(0, 6)}
{message.senderAddress.slice(-4)}
{message.senderInboxId.slice(0, 6)}
{message.senderInboxId.slice(-4)}
</Text>
{typeof content !== 'string' && 'text' in content && content.text ? (
<Text
Expand Down Expand Up @@ -955,8 +955,8 @@ function MessageItem({
}}
>
<Text style={{ fontWeight: 'bold' }}>
{message.senderAddress.slice(0, 6)}
{message.senderAddress.slice(-4)}
{message.senderInboxId.slice(0, 6)}
{message.senderInboxId.slice(-4)}
</Text>
<Text style={{ fontWeight: '300' }}>
{moment(message.sentNs / 1000000).fromNow()}
Expand Down
2 changes: 1 addition & 1 deletion example/src/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function ConversationItem({
<Text numberOfLines={1} ellipsizeMode="tail">
{lastMessage?.fallback}
</Text>
<Text>{lastMessage?.senderAddress}:</Text>
<Text>{lastMessage?.senderInboxId}:</Text>
<Text>{moment(lastMessage?.sentNs / 1000000).fromNow()}</Text>
</View>
</View>
Expand Down
32 changes: 16 additions & 16 deletions example/src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export function useMessage({
console.log('Error refreshing messages', err)
)
}))
const isSenderMe = message?.senderAddress === client?.address
const isSenderMe = message?.senderInboxId === client?.address
return {
message,
performReaction,
Expand Down Expand Up @@ -217,7 +217,7 @@ export function useGroupMessage({
console.log('Error refreshing messages', err)
)
}))
const isSenderMe = message?.senderAddress === client?.address
const isSenderMe = message?.senderInboxId === client?.address
return {
message,
performReaction,
Expand Down Expand Up @@ -245,7 +245,7 @@ export function useConversationReactions({ topic }: { topic: string }) {
}>(
['xmtp', 'reactions', client?.address, topic, reactions.length],
() => {
// SELECT messageId, reaction, senderAddress FROM reactions GROUP BY messageId, reaction
// SELECT messageId, reaction, senderInboxId FROM reactions GROUP BY messageId, reaction
const byId = {} as {
[messageId: string]: { [reaction: string]: string[] }
}
Expand All @@ -254,23 +254,23 @@ export function useConversationReactions({ topic }: { topic: string }) {
.slice()
.reverse()
.forEach((message) => {
const { senderAddress } = message
const { senderInboxId } = message
const reaction = message.content() as ReactionContent
const messageId = reaction!.reference
const reactionText = reaction!.content
const v = byId[messageId] || ({} as { [reaction: string]: string[] })
// DELETE FROM reactions WHERE messageId = ? AND reaction = ? AND senderAddress = ?
// DELETE FROM reactions WHERE messageId = ? AND reaction = ? AND senderInboxId = ?
let prior = (v[reactionText] || [])
// This removes any prior instances of the sender using this reaction.
.filter((address) => address !== senderAddress)
.filter((address) => address !== senderInboxId)
if (reaction!.action === 'added') {
// INSERT INTO reactions (messageId, reaction, senderAddress) VALUES (?, ?, ?)
prior = prior.concat([senderAddress])
// INSERT INTO reactions (messageId, reaction, senderInboxId) VALUES (?, ?, ?)
prior = prior.concat([senderInboxId])
}
v[reactionText] = prior
byId[messageId] = v
})
// SELECT messageId, reaction, COUNT(*) AS count, COUNT(senderAddress = ?) AS includesMe
// SELECT messageId, reaction, COUNT(*) AS count, COUNT(senderInboxId = ?) AS includesMe
// FROM reactions
// GROUP BY messageId, reaction
// ORDER BY count DESC
Expand Down Expand Up @@ -318,7 +318,7 @@ export function useGroupReactions({ groupId }: { groupId: string }) {
}>(
['xmtp', 'reactions', client?.address, groupId, reactions.length],
() => {
// SELECT messageId, reaction, senderAddress FROM reactions GROUP BY messageId, reaction
// SELECT messageId, reaction, senderInboxId FROM reactions GROUP BY messageId, reaction
const byId = {} as {
[messageId: string]: { [reaction: string]: string[] }
}
Expand All @@ -327,23 +327,23 @@ export function useGroupReactions({ groupId }: { groupId: string }) {
.slice()
.reverse()
.forEach((message) => {
const { senderAddress } = message
const { senderInboxId } = message
const reaction = message.content() as ReactionContent
const messageId = reaction!.reference
const reactionText = reaction!.content
const v = byId[messageId] || ({} as { [reaction: string]: string[] })
// DELETE FROM reactions WHERE messageId = ? AND reaction = ? AND senderAddress = ?
// DELETE FROM reactions WHERE messageId = ? AND reaction = ? AND senderInboxId = ?
let prior = (v[reactionText] || [])
// This removes any prior instances of the sender using this reaction.
.filter((address) => address !== senderAddress)
.filter((address) => address !== senderInboxId)
if (reaction!.action === 'added') {
// INSERT INTO reactions (messageId, reaction, senderAddress) VALUES (?, ?, ?)
prior = prior.concat([senderAddress])
// INSERT INTO reactions (messageId, reaction, senderInboxId) VALUES (?, ?, ?)
prior = prior.concat([senderInboxId])
}
v[reactionText] = prior
byId[messageId] = v
})
// SELECT messageId, reaction, COUNT(*) AS count, COUNT(senderAddress = ?) AS includesMe
// SELECT messageId, reaction, COUNT(*) AS count, COUNT(senderInboxId = ?) AS includesMe
// FROM reactions
// GROUP BY messageId, reaction
// ORDER BY count DESC
Expand Down
2 changes: 1 addition & 1 deletion ios/Wrappers/DecodedMessageWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct DecodedMessageWrapper {
"topic": model.topic,
"contentTypeId": model.encodedContent.type.description,
"content": try ContentJson.fromEncoded(model.encodedContent, client: client).toJsonMap() as Any,
"senderAddress": model.senderAddress,
"senderInboxId": model.senderInboxId,
"sentNs": model.sentNs,
"fallback": fallback,
"deliveryStatus": model.deliveryStatus.rawValue.uppercased(),
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPReactNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Pod::Spec.new do |s|
s.source_files = "**/*.{h,m,swift}"

s.dependency "MessagePacker"
s.dependency "XMTP", "= 3.0.18"
s.dependency "XMTP", "= 3.0.19"
s.dependency 'CSecp256k1', '~> 0.2'
s.dependency "SQLCipher", "= 4.5.7"
end
Loading
Loading