Skip to content

Commit

Permalink
Merge pull request #550 from xmtp/np/sync-call-performance
Browse files Browse the repository at this point in the history
Sync all syncs all
  • Loading branch information
nplasterer authored Dec 5, 2024
2 parents d396e0b + 91c0382 commit f4e77c5
Show file tree
Hide file tree
Showing 12 changed files with 443 additions and 526 deletions.
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.10"
implementation "org.xmtp:android:3.0.13"
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 @@ -332,14 +332,14 @@ class XMTPModule : Module() {
}
}

AsyncFunction("build") Coroutine { address: String, dbEncryptionKey: List<Int>, authParams: String ->
AsyncFunction("build") Coroutine { address: String, inboxId: String?, dbEncryptionKey: List<Int>, authParams: String ->
withContext(Dispatchers.IO) {
logV("build")
val options = clientOptions(
dbEncryptionKey,
authParams,
)
val client = Client().build(address = address, options = options)
val client = Client().build(address = address, options = options, inboxId = inboxId)
ContentJson.Companion
clients[client.installationId] = client
ClientWrapper.encodeToObj(client)
Expand Down Expand Up @@ -444,6 +444,17 @@ class XMTPModule : Module() {
}
}

AsyncFunction("staticCanMessage") Coroutine { environment: String, peerAddresses: List<String> ->
withContext(Dispatchers.IO) {
logV("staticCanMessage")
Client.canMessage(
peerAddresses,
context,
apiEnvironments(environment, null)
)
}
}

AsyncFunction("getOrCreateInboxId") Coroutine { address: String, environment: String ->
withContext(Dispatchers.IO) {
try {
Expand Down
23 changes: 16 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ PODS:
- hermes-engine/Pre-built (= 0.71.14)
- hermes-engine/Pre-built (0.71.14)
- libevent (2.1.12)
- LibXMTP (3.0.7)
- LibXMTP (3.0.10)
- MessagePacker (0.4.7)
- MMKV (2.0.0):
- MMKVCore (~> 2.0.0)
Expand Down Expand Up @@ -440,17 +440,24 @@ PODS:
- React-RCTImage
- RNSVG (13.14.0):
- React-Core
- SQLCipher (4.5.7):
- SQLCipher/standard (= 4.5.7)
- SQLCipher/common (4.5.7)
- SQLCipher/standard (4.5.7):
- SQLCipher/common
- SwiftProtobuf (1.28.2)
- XMTP (3.0.10):
- XMTP (3.0.14):
- Connect-Swift (= 1.0.0)
- CryptoSwift (= 1.8.3)
- CSecp256k1 (~> 0.2)
- LibXMTP (= 3.0.7)
- LibXMTP (= 3.0.10)
- SQLCipher (= 4.5.7)
- XMTPReactNative (0.1.0):
- CSecp256k1 (~> 0.2)
- ExpoModulesCore
- MessagePacker
- XMTP (= 3.0.10)
- SQLCipher (= 4.5.7)
- XMTP (= 3.0.14)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -536,6 +543,7 @@ SPEC REPOS:
- MMKV
- MMKVCore
- OpenSSL-Universal
- SQLCipher
- SwiftProtobuf
- XMTP

Expand Down Expand Up @@ -698,7 +706,7 @@ SPEC CHECKSUMS:
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: 1d9b9514c2b6407a82d72b203288cd5af064d787
LibXMTP: e550ccb4565023eb77f5a2eddd9d5a71cfb9d2b3
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: f7d1d5945c8765f97f39c3d121f353d46735d801
MMKVCore: c04b296010fcb1d1638f2c69405096aac12f6390
Expand Down Expand Up @@ -746,9 +754,10 @@ SPEC CHECKSUMS:
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f
RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396
SQLCipher: 5e6bfb47323635c8b657b1b27d25c5f1baf63bf5
SwiftProtobuf: 4dbaffec76a39a8dc5da23b40af1a5dc01a4c02d
XMTP: 22bd60ccd58801953c1bbc7619b0046b2eef5b97
XMTPReactNative: 48e8bbbb9c1800cd507121bd9918aa4a571e8237
XMTP: 3b586fa3703640bb5fec8a64daba9e157d9e5fdc
XMTPReactNative: ab20c0030e2092fb7201c42d6ec17a7055ec6bf8
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,15 @@
"${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/EXConstants/EXConstants.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/SQLCipher/SQLCipher.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/SwiftProtobuf/SwiftProtobuf.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CryptoSwift.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/EXConstants.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SQLCipher.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SwiftProtobuf.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
28 changes: 28 additions & 0 deletions example/src/tests/clientTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,34 @@ test('can make a client', async () => {
return true
})

test('static can message', async () => {
const [alix, bo] = await createClients(2)

const addressMap = await Client.canMessage('local', [
alix.address,
'0x4E9ce36E442e55EcD9025B9a6E0D88485d628A67',
bo.address,
])

assert(
addressMap[
'0x4E9ce36E442e55EcD9025B9a6E0D88485d628A67'.toLocaleLowerCase()
] === false,
`should not be able to message 0x4E9ce36E442e55EcD9025B9a6E0D88485d628A67`
)

assert(
addressMap[alix.address.toLowerCase()] === true,
`should be able to message ${alix.address}`
)

assert(
addressMap[bo.address.toLowerCase()] === true,
`should be able to message ${bo.address}`
)
return true
})

test('can revoke all other installations', async () => {
const keyBytes = new Uint8Array([
233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64,
Expand Down
4 changes: 0 additions & 4 deletions example/src/tests/conversationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,6 @@ test('can sync consent', async () => {
// Sync conversations
await bo.conversations.sync()
if (boDm) await boDm.sync()
await alix.conversations.sync()
await alix2.conversations.sync()
await alix2.preferences.syncConsent()
await alix.conversations.syncAllConversations()
await delayToPropogate(2000)
Expand Down Expand Up @@ -667,8 +665,6 @@ test('can stream consent', async () => {
})

await alixGroup.send('Hello')
await alix.conversations.sync()
await alix2.conversations.sync()
await alix.conversations.syncAllConversations()
await alix2.conversations.syncAllConversations()

Expand Down
Loading

0 comments on commit f4e77c5

Please sign in to comment.