Skip to content

Commit

Permalink
Merge pull request #500 from xmtp/np/update-beta-with-main
Browse files Browse the repository at this point in the history
Pull main into beta
  • Loading branch information
nplasterer authored Sep 24, 2024
2 parents c1a7169 + a209215 commit 54be3f3
Show file tree
Hide file tree
Showing 38 changed files with 2,569 additions and 900 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Global rule:
* @xmtp/mobile
*.md @fabriguespe
* @xmtp/protocol-sdk
*.md @xmtp/documentation
19 changes: 0 additions & 19 deletions .github/workflows/syncBeta.yml

This file was deleted.

1 change: 1 addition & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--indent tab
--elseposition same-line
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ repositories {
dependencies {
implementation project(':expo-modules-core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
implementation "org.xmtp:android:0.14.8"
implementation "org.xmtp:android:0.15.10"
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"
// xmtp-android local testing setup below (comment org.xmtp:android above)
// implementation files('<PATH TO XMTP-ANDROID>/xmtp-android/library/build/outputs/aar/library-debug.aar')
// implementation files('<PATH_TO_LIBRARY>/xmtp-android/library/build/outputs/aar/library-debug.aar')
// implementation 'com.google.crypto.tink:tink-android:1.8.0'
// implementation 'io.grpc:grpc-kotlin-stub:1.4.1'
// implementation 'io.grpc:grpc-okhttp:1.62.2'
Expand Down
446 changes: 304 additions & 142 deletions android/src/main/java/expo/modules/xmtpreactnativesdk/XMTPModule.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class ClientWrapper {
return mapOf(
"inboxId" to client.inboxId,
"address" to client.address,
"installationId" to client.installationId
"installationId" to client.installationId,
"dbPath" to client.dbPath
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ class GroupWrapper {
"clientAddress" to client.address,
"id" to group.id,
"createdAt" to group.createdAt.time,
"peerInboxIds" to group.peerInboxIds(),
"members" to group.members().map { MemberWrapper.encode(it) },
"version" to "GROUP",
"topic" to group.topic,
"creatorInboxId" to group.creatorInboxId(),
"isActive" to group.isActive(),
"addedByInboxId" to group.addedByInboxId(),
"name" to group.name,
"imageUrlSquare" to group.imageUrlSquare,
"description" to group.description
// "pinnedFrameUrl" to group.pinnedFrameUrl
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package expo.modules.xmtpreactnativesdk.wrappers

import com.google.gson.GsonBuilder
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.InboxState

class InboxStateWrapper {
companion object {
fun encodeToObj(inboxState: InboxState): Map<String, Any> {
return mapOf(
"inboxId" to inboxState.inboxId,
"addresses" to inboxState.addresses,
"installationIds" to inboxState.installationIds,
"recoveryAddress" to inboxState.recoveryAddress
)
}

fun encode(inboxState: InboxState): String {
val gson = GsonBuilder().create()
val obj = encodeToObj(inboxState)
return gson.toJson(obj)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package expo.modules.xmtpreactnativesdk.wrappers

import com.google.gson.GsonBuilder
import com.google.gson.JsonParser
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionOption
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionPolicySet

Expand All @@ -16,6 +17,16 @@ class PermissionPolicySetWrapper {
PermissionOption.Unknown -> "unknown"
}
}

fun createPermissionOptionFromString(permissionOptionString: String): PermissionOption {
return when (permissionOptionString) {
"allow" -> PermissionOption.Allow
"deny" -> PermissionOption.Deny
"admin" -> PermissionOption.Admin
"superAdmin" -> PermissionOption.SuperAdmin
else -> PermissionOption.Unknown
}
}
fun encodeToObj(policySet: PermissionPolicySet): Map<String, Any> {
return mapOf(
"addMemberPolicy" to fromPermissionOption(policySet.addMemberPolicy),
Expand All @@ -29,6 +40,20 @@ class PermissionPolicySetWrapper {
)
}

fun createPermissionPolicySetFromJson(permissionPolicySetJson: String): PermissionPolicySet {
val jsonObj = JsonParser.parseString(permissionPolicySetJson).asJsonObject
return PermissionPolicySet(
addMemberPolicy = createPermissionOptionFromString(jsonObj.get("addMemberPolicy").asString),
removeMemberPolicy = createPermissionOptionFromString(jsonObj.get("removeMemberPolicy").asString),
addAdminPolicy = createPermissionOptionFromString(jsonObj.get("addAdminPolicy").asString),
removeAdminPolicy = createPermissionOptionFromString(jsonObj.get("removeAdminPolicy").asString),
updateGroupNamePolicy = createPermissionOptionFromString(jsonObj.get("updateGroupNamePolicy").asString),
updateGroupDescriptionPolicy = createPermissionOptionFromString(jsonObj.get("updateGroupDescriptionPolicy").asString),
updateGroupImagePolicy = createPermissionOptionFromString(jsonObj.get("updateGroupImagePolicy").asString),
updateGroupPinnedFrameUrlPolicy = createPermissionOptionFromString(jsonObj.get("updateGroupPinnedFrameUrlPolicy").asString)
)
}

fun encodeToJsonString(policySet: PermissionPolicySet): String {
val gson = GsonBuilder().create()
val obj = encodeToObj(policySet)
Expand Down
4 changes: 2 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ First create a free account and download your client id from https://thirdweb.co
cd example
cp EXAMPLE.env .env
```
Finally, insert yout Thirdweb client id in specified location of `example/.env` file:
Finally, insert your Thirdweb client id in specified location of `example/.env` file:
```
THIRD_WEB_CLIENT_ID=INSERT_CLIENT_ID_HERE
```
Expand Down Expand Up @@ -53,4 +53,4 @@ Running tests locally is useful when updating GitHub actions, or locally testing
5. You can stop the XMTP server with the following command:
```bash
docker-compose -p xmtp -f dev/local/docker-compose.yml down
```
```
6 changes: 3 additions & 3 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties
ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = '1' if podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR'] == 'true'

platform :ios, '16.0'
platform :ios, '14.0'
install! 'cocoapods',
:deterministic_uuids => false

Expand Down Expand Up @@ -85,11 +85,11 @@ target 'xmtpreactnativesdkexample' do
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
end
project.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
end
end
Expand Down
26 changes: 13 additions & 13 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ PODS:
- hermes-engine/Pre-built (= 0.71.14)
- hermes-engine/Pre-built (0.71.14)
- libevent (2.1.12)
- LibXMTP (0.5.6-beta0)
- LibXMTP (0.5.8-beta6)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (1.3.7):
- MMKVCore (~> 1.3.7)
- MMKVCore (1.3.7)
- MMKV (1.3.9):
- MMKVCore (~> 1.3.9)
- MMKVCore (1.3.9)
- OpenSSL-Universal (1.1.2200)
- RCT-Folly (2021.07.22.00):
- boost
Expand Down Expand Up @@ -449,16 +449,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.13.7):
- XMTP (0.14.14):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.5.6-beta0)
- LibXMTP (= 0.5.8-beta6)
- web3.swift
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.13.7)
- XMTP (= 0.14.14)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -711,11 +711,11 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: e7682dedb10e18343c011280d494a8e4a43d9eb7
LibXMTP: c7338cace222bed90f950579300725325a2c0bfd
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: 36a22a9ec84c9bb960613a089ddf6f48be9312b0
MMKVCore: 158e61c8516401a9fac730288acb29e6fc19bbf9
MMKV: 817ba1eea17421547e01e087285606eb270a8dcb
MMKVCore: af055b00e27d88cd92fad301c5fecd1ff9b26dd9
OpenSSL-Universal: 6e1ae0555546e604dbc632a2b9a24a9c46c41ef6
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: e9df143e880d0e879e7a498dc06923d728809c79
Expand Down Expand Up @@ -763,10 +763,10 @@ SPEC CHECKSUMS:
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: 16bd630ff61081d3a325619a26ea176ed256d419
XMTPReactNative: 4716836807cb33c72bde0846ac46b3fe923a3625
XMTP: 37621f1258b12629af305e6697414ccb2fbd4ea8
XMTPReactNative: 7bec275ed26997e6a73f06a678c328e6ba852cd5
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2
PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd

COCOAPODS: 1.15.2
9 changes: 8 additions & 1 deletion example/src/LaunchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ export default function LaunchScreen(
console.log('Pre Enable Identity Callback')
}

const preAuthenticateToInboxCallback = async () => {
console.log('Pre Authenticate To Inbox Callback')
}

const networkOptions = [
{ key: 0, label: 'dev' },
{ key: 1, label: 'local' },
// { key: 2, label: 'production' },
{ key: 2, label: 'production' },
]

const groupOptions = [
Expand Down Expand Up @@ -222,8 +226,10 @@ export default function LaunchScreen(
XMTP.Client.create(signer, {
env: selectedNetwork,
appVersion,
codecs: supportedCodecs,
preCreateIdentityCallback,
preEnableIdentityCallback,
preAuthenticateToInboxCallback,
enableV3: enableGroups === 'true',
dbEncryptionKey,
})
Expand Down Expand Up @@ -258,6 +264,7 @@ export default function LaunchScreen(
codecs: supportedCodecs,
preCreateIdentityCallback,
preEnableIdentityCallback,
preAuthenticateToInboxCallback,
enableV3: enableGroups === 'true',
dbEncryptionKey,
})
Expand Down
19 changes: 13 additions & 6 deletions example/src/TestScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { useRoute } from '@react-navigation/native'
import React, { useEffect, useState } from 'react'
import { View, Text, Button, ScrollView } from 'react-native'

import { createdAtTests } from './tests/createdAtTests'
import { groupPerformanceTests } from './tests/groupPerformanceTests'
import { groupPermissionsTests } from './tests/groupPermissionsTests'
import { groupTests } from './tests/groupTests'
import { restartStreamTests } from './tests/restartStreamsTests'
import { Test } from './tests/test-utils'
import { tests } from './tests/tests'
import { v3OnlyTests } from './tests/v3OnlyTests'

type Result = 'waiting' | 'running' | 'success' | 'failure' | 'error'

Expand Down Expand Up @@ -107,9 +108,10 @@ export enum TestCategory {
all = 'all',
tests = 'tests',
group = 'group',
createdAt = 'createdAt',
v3Only = 'v3Only',
restartStreans = 'restartStreams',
groupPermissions = 'groupPermissions',
groupPerformance = 'groupPerformance',
}

export default function TestScreen(): JSX.Element {
Expand All @@ -121,9 +123,10 @@ export default function TestScreen(): JSX.Element {
const allTests = [
...tests,
...groupTests,
...createdAtTests,
...v3OnlyTests,
...restartStreamTests,
...groupPermissionsTests,
...groupPerformanceTests,
]
let activeTests, title
switch (params.testSelection) {
Expand All @@ -139,9 +142,9 @@ export default function TestScreen(): JSX.Element {
activeTests = groupTests
title = 'Group Unit Tests'
break
case TestCategory.createdAt:
activeTests = createdAtTests
title = 'Created At Unit Tests'
case TestCategory.v3Only:
activeTests = v3OnlyTests
title = 'V3 Only Tests'
break
case TestCategory.restartStreans:
activeTests = restartStreamTests
Expand All @@ -151,6 +154,10 @@ export default function TestScreen(): JSX.Element {
activeTests = groupPermissionsTests
title = 'Group Permissions Unit Tests'
break
case TestCategory.groupPerformance:
activeTests = groupPerformanceTests
title = 'Group Performance Unit Tests'
break
}

return (
Expand Down
Loading

0 comments on commit 54be3f3

Please sign in to comment.