-
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 branch 'beta' into np/merge-beta
- Loading branch information
Showing
79 changed files
with
11,603 additions
and
1,944 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
1,164 changes: 1,042 additions & 122 deletions
1,164
android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt
Large diffs are not rendered by default.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/AuthParamsWrapper.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,24 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.JsonParser | ||
|
||
class AuthParamsWrapper( | ||
val environment: String, | ||
val appVersion: String?, | ||
val enableV3: Boolean = false, | ||
val dbDirectory: String?, | ||
val historySyncUrl: String?, | ||
) { | ||
companion object { | ||
fun authParamsFromJson(authParams: String): AuthParamsWrapper { | ||
val jsonOptions = JsonParser.parseString(authParams).asJsonObject | ||
return AuthParamsWrapper( | ||
jsonOptions.get("environment").asString, | ||
if (jsonOptions.has("appVersion")) jsonOptions.get("appVersion").asString else null, | ||
if (jsonOptions.has("enableV3")) jsonOptions.get("enableV3").asBoolean else false, | ||
if (jsonOptions.has("dbDirectory")) jsonOptions.get("dbDirectory").asString else null, | ||
if (jsonOptions.has("historySyncUrl")) jsonOptions.get("historySyncUrl").asString else null | ||
) | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ClientWrapper.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,22 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.Client | ||
|
||
class ClientWrapper { | ||
companion object { | ||
fun encodeToObj(client: Client): Map<String, String> { | ||
return mapOf( | ||
"inboxId" to client.inboxId, | ||
"address" to client.address, | ||
"installationId" to client.installationId | ||
) | ||
} | ||
|
||
fun encode(client: Client): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(client) | ||
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
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
22 changes: 22 additions & 0 deletions
22
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/CreateGroupParamsWrapper.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,22 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.JsonParser | ||
|
||
class CreateGroupParamsWrapper( | ||
val groupName: String, | ||
val groupImageUrlSquare: String, | ||
val groupDescription: String, | ||
val groupPinnedFrameUrl: String, | ||
) { | ||
companion object { | ||
fun createGroupParamsFromJson(authParams: String): CreateGroupParamsWrapper { | ||
val jsonOptions = JsonParser.parseString(authParams).asJsonObject | ||
return CreateGroupParamsWrapper( | ||
if (jsonOptions.has("name")) jsonOptions.get("name").asString else "", | ||
if (jsonOptions.has("imageUrlSquare")) jsonOptions.get("imageUrlSquare").asString else "", | ||
if (jsonOptions.has("description")) jsonOptions.get("description").asString else "", | ||
if (jsonOptions.has("pinnedFrameUrl")) jsonOptions.get("pinnedFrameUrl").asString else "", | ||
) | ||
} | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
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,30 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.Client | ||
import org.xmtp.android.library.Group | ||
import org.xmtp.android.library.toHex | ||
|
||
class GroupWrapper { | ||
|
||
companion object { | ||
fun encodeToObj(client: Client, group: Group): Map<String, Any> { | ||
return mapOf( | ||
"clientAddress" to client.address, | ||
"id" to group.id, | ||
"createdAt" to group.createdAt.time, | ||
"peerInboxIds" to group.peerInboxIds(), | ||
"version" to "GROUP", | ||
"topic" to group.topic, | ||
"creatorInboxId" to group.creatorInboxId(), | ||
"isActive" to group.isActive(), | ||
) | ||
} | ||
|
||
fun encode(client: Client, group: Group): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(client, group) | ||
return gson.toJson(obj) | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/MemberWrapper.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,28 @@ | ||
package expo.modules.xmtpreactnativesdk.wrappers | ||
|
||
import com.google.gson.GsonBuilder | ||
import org.xmtp.android.library.libxmtp.Member | ||
import org.xmtp.android.library.libxmtp.PermissionLevel | ||
|
||
class MemberWrapper { | ||
companion object { | ||
fun encodeToObj(member: Member): Map<String, Any> { | ||
val permissionString = when (member.permissionLevel) { | ||
PermissionLevel.MEMBER -> "member" | ||
PermissionLevel.ADMIN -> "admin" | ||
PermissionLevel.SUPER_ADMIN -> "super_admin" | ||
} | ||
return mapOf( | ||
"inboxId" to member.inboxId, | ||
"addresses" to member.addresses, | ||
"permissionLevel" to permissionString | ||
) | ||
} | ||
|
||
fun encode(member: Member): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(member) | ||
return gson.toJson(obj) | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/PermissionPolicySetWrapper.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 com.google.gson.GsonBuilder | ||
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionOption | ||
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionPolicySet | ||
|
||
class PermissionPolicySetWrapper { | ||
|
||
companion object { | ||
fun fromPermissionOption(permissionOption: PermissionOption): String { | ||
return when (permissionOption) { | ||
PermissionOption.Allow -> "allow" | ||
PermissionOption.Deny -> "deny" | ||
PermissionOption.Admin -> "admin" | ||
PermissionOption.SuperAdmin -> "superAdmin" | ||
PermissionOption.Unknown -> "unknown" | ||
} | ||
} | ||
fun encodeToObj(policySet: PermissionPolicySet): Map<String, Any> { | ||
return mapOf( | ||
"addMemberPolicy" to fromPermissionOption(policySet.addMemberPolicy), | ||
"removeMemberPolicy" to fromPermissionOption(policySet.removeMemberPolicy), | ||
"addAdminPolicy" to fromPermissionOption(policySet.addAdminPolicy), | ||
"removeAdminPolicy" to fromPermissionOption(policySet.removeAdminPolicy), | ||
"updateGroupNamePolicy" to fromPermissionOption(policySet.updateGroupNamePolicy), | ||
"updateGroupDescriptionPolicy" to fromPermissionOption(policySet.updateGroupDescriptionPolicy), | ||
"updateGroupImagePolicy" to fromPermissionOption(policySet.updateGroupImagePolicy), | ||
"updateGroupPinnedFrameUrlPolicy" to fromPermissionOption(policySet.updateGroupPinnedFrameUrlPolicy), | ||
) | ||
} | ||
|
||
fun encodeToJsonString(policySet: PermissionPolicySet): String { | ||
val gson = GsonBuilder().create() | ||
val obj = encodeToObj(policySet) | ||
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
Oops, something went wrong.