-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #526 from xmtp/np/v3
Update to a V3 only SDK
- Loading branch information
Showing
67 changed files
with
3,214 additions
and
9,095 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,616 changes: 307 additions & 1,309 deletions
1,616
android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConsentWrapper.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
...id/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConversationContainerWrapper.kt
This file was deleted.
Oops, something went wrong.
45 changes: 22 additions & 23 deletions
45
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConversationWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import android.util.Base64 | ||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.Client | ||
import org.xmtp.android.library.Conversation | ||
|
||
class ConversationWrapper { | ||
|
||
companion object { | ||
fun encodeToObj(client: Client, conversation: Conversation): Map<String, Any?> { | ||
val context = when (conversation.version) { | ||
Conversation.Version.V2 -> mapOf<String, Any>( | ||
"conversationID" to (conversation.conversationId ?: ""), | ||
// TODO: expose the context/metadata explicitly in xmtp-android | ||
"metadata" to conversation.toTopicData().invitation.context.metadataMap, | ||
) | ||
fun encodeToObj( | ||
client: Client, | ||
conversation: Conversation, | ||
conversationParams: ConversationParamsWrapper = ConversationParamsWrapper(), | ||
): Map<String, Any?> { | ||
return when (conversation.type) { | ||
Conversation.Type.GROUP -> { | ||
val group = (conversation as Conversation.Group).group | ||
GroupWrapper.encodeToObj(client, group, conversationParams) | ||
} | ||
|
||
else -> mapOf() | ||
Conversation.Type.DM -> { | ||
val dm = (conversation as Conversation.Dm).dm | ||
DmWrapper.encodeToObj(client, dm, conversationParams) | ||
} | ||
} | ||
return mapOf( | ||
"clientAddress" to client.address, | ||
"createdAt" to conversation.createdAt.time, | ||
"context" to context, | ||
"topic" to conversation.topic, | ||
"peerAddress" to conversation.peerAddress, | ||
"version" to "DIRECT", | ||
"conversationID" to (conversation.conversationId ?: ""), | ||
"keyMaterial" to (conversation.keyMaterial?.let { Base64.encodeToString(it, Base64.NO_WRAP) } ?: ""), | ||
"consentProof" to if (conversation.consentProof != null) Base64.encodeToString(conversation.consentProof?.toByteArray(), Base64.NO_WRAP) else null | ||
) | ||
} | ||
|
||
fun encode(client: Client, conversation: Conversation): String { | ||
fun encode( | ||
client: Client, | ||
conversation: Conversation, | ||
conversationParams: ConversationParamsWrapper = ConversationParamsWrapper(), | ||
): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(client, conversation) | ||
val obj = | ||
encodeToObj(client, conversation, conversationParams) | ||
return gson.toJson(obj) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.