-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
7,752 additions
and
1,487 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: ["./tsconfig.json", "./example/tsconfig.json"] | ||
}, | ||
plugins: ["@typescript-eslint"], | ||
extends: ['universe/native', 'universe/web'], | ||
ignorePatterns: ['build'], | ||
plugins: ['prettier'], | ||
globals: { | ||
__dirname: true, | ||
}, | ||
rules: { | ||
"@typescript-eslint/no-floating-promises": ["error"], | ||
}, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Typescript | ||
on: | ||
pull_request: | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v3 | ||
- run: yarn | ||
- run: yarn tsc |
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 |
---|---|---|
|
@@ -63,3 +63,4 @@ android/keystores/debug.keystore | |
|
||
# Typedocs | ||
docs/ | ||
**/.yarn/* |
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
508 changes: 489 additions & 19 deletions
508
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
29 changes: 29 additions & 0 deletions
29
...id/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ConversationContainerWrapper.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
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 ConversationContainerWrapper { | ||
|
||
companion object { | ||
fun encodeToObj(client: Client, conversation: Conversation): Map<String, Any> { | ||
when (conversation.version) { | ||
Conversation.Version.GROUP -> { | ||
val group = (conversation as Conversation.Group).group | ||
return GroupWrapper.encodeToObj(client, group) | ||
} | ||
else -> { | ||
return ConversationWrapper.encodeToObj(client, conversation) | ||
} | ||
} | ||
} | ||
|
||
fun encode(client: Client, conversation: Conversation): String { | ||
val gson = GsonBuilder().create() | ||
val obj = ConversationContainerWrapper.encodeToObj(client, conversation) | ||
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
38 changes: 38 additions & 0 deletions
38
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/GroupWrapper.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import android.util.Base64 | ||
import android.util.Base64.NO_WRAP | ||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.Client | ||
import org.xmtp.android.library.Conversation | ||
import org.xmtp.android.library.Group | ||
import org.xmtp.android.library.toHex | ||
import uniffi.xmtpv3.GroupPermissions | ||
|
||
class GroupWrapper { | ||
|
||
companion object { | ||
fun encodeToObj(client: Client, group: Group): Map<String, Any> { | ||
val permissionString = when (group.permissionLevel()) { | ||
GroupPermissions.EVERYONE_IS_ADMIN -> "everyone_admin" | ||
GroupPermissions.GROUP_CREATOR_IS_ADMIN -> "creator_admin" | ||
} | ||
return mapOf( | ||
"clientAddress" to client.address, | ||
"id" to group.id.toHex(), | ||
"createdAt" to group.createdAt.time, | ||
"peerAddresses" to Conversation.Group(group).peerAddresses, | ||
"version" to "GROUP", | ||
"topic" to group.id.toHex(), | ||
"permissionLevel" to permissionString, | ||
"adminAddress" to group.adminAddress() | ||
) | ||
} | ||
|
||
fun encode(client: Client, group: Group): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(client, group) | ||
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
Oops, something went wrong.