Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Groups to Conversations #160

Merged
merged 92 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
fcb9921
first pass at all the pieces needed for threading
nplasterer Jan 19, 2024
6326d7f
a few more places
nplasterer Jan 19, 2024
ed9ae8c
make signing key extend inboxOwner
nplasterer Jan 19, 2024
ff740e1
get it decoding messages
nplasterer Jan 19, 2024
750eb84
dump the latest v3 code
nplasterer Jan 23, 2024
15db4e8
write a test for creating a v3 client
nplasterer Jan 23, 2024
88a2c77
use created At
nplasterer Jan 23, 2024
53c5897
write test for creating libxmtp client and confirm it works
nplasterer Jan 23, 2024
8998d13
move these change to a different branch
nplasterer Jan 23, 2024
397982a
dont pass a conversation
nplasterer Jan 23, 2024
7bb1534
fix linter
nplasterer Jan 23, 2024
b35f686
point to local not dev
nplasterer Jan 23, 2024
aaecfc3
feature flag the client creating of libxmtp while in alpha
nplasterer Jan 23, 2024
9bbee43
change to local
nplasterer Jan 23, 2024
14b3870
fix up the test helper
nplasterer Jan 23, 2024
5ddf0f5
feat: fix up the example app
nplasterer Jan 23, 2024
305f483
fix up the 22 compat issue
nplasterer Jan 23, 2024
d0d8881
Revert "move these change to a different branch"
nplasterer Jan 23, 2024
296cac4
try and get some tests running
nplasterer Jan 24, 2024
2cb89b7
setup local database
nplasterer Jan 24, 2024
4892ffe
have it create correctly
nplasterer Jan 24, 2024
04abb1c
Merge branch 'np/group-spike' of https://github.com/xmtp/xmtp-android…
nplasterer Jan 24, 2024
9751afe
write tests for functionality
nplasterer Jan 24, 2024
4aedaa3
test sending
nplasterer Jan 24, 2024
bfd9e7b
send encoded content
nplasterer Jan 24, 2024
7915b0c
add updates to the v3 bindings
nplasterer Jan 24, 2024
ca663cf
add updates to the v3 bindings
nplasterer Jan 24, 2024
1e84e4c
store in a keystore
nplasterer Jan 25, 2024
4da7d38
move to preferences
nplasterer Jan 25, 2024
c05f7f8
fix lint
nplasterer Jan 25, 2024
dc42604
Merge branch 'np/group-spike' of https://github.com/xmtp/xmtp-android…
nplasterer Jan 25, 2024
4329033
Fix build issues
neekolas Jan 25, 2024
51cb81f
new libxmtp updates
nplasterer Jan 25, 2024
5e85337
Merge branch 'np/group-conversations' of https://github.com/xmtp/xmtp…
nplasterer Jan 25, 2024
ca7537f
dump the latest schema
nplasterer Jan 25, 2024
3fd9099
update to the latest client creation flow
nplasterer Jan 25, 2024
89d0e63
get the create working again
nplasterer Jan 26, 2024
845d360
use the keystore because its more secure
nplasterer Jan 26, 2024
8862d42
fix up linter compat again
nplasterer Jan 26, 2024
13b7cf9
flaky test
nplasterer Jan 26, 2024
ba3c247
Merge branch 'main' of https://github.com/xmtp/xmtp-android into np/g…
nplasterer Jan 26, 2024
88e3456
Merge branch 'np/group-spike' of https://github.com/xmtp/xmtp-android…
nplasterer Jan 26, 2024
d89f11c
get the tests all passing
nplasterer Jan 26, 2024
ac8a2d5
get the example working with groups
nplasterer Jan 26, 2024
4fc84ea
create a group with two addresses
nplasterer Jan 26, 2024
093c5e4
more tweaks to the example app to get groups working
nplasterer Jan 26, 2024
29c9e07
add streaming messages to groups
nplasterer Jan 26, 2024
e96d81a
a few example UI tweaks
nplasterer Jan 26, 2024
d83938d
fix the lowercasing issue in the example app
nplasterer Jan 26, 2024
6eaf597
dump the schema again
nplasterer Jan 26, 2024
5b676a5
Merge branch 'main' of https://github.com/xmtp/xmtp-android into np/g…
nplasterer Jan 27, 2024
b74f02f
implement all the conversation functionality
nplasterer Jan 30, 2024
33bdafa
add new codec for membership changes
nplasterer Jan 30, 2024
2c7ac43
write tests for it
nplasterer Jan 30, 2024
5c15d7b
fix up the tests a bit'
nplasterer Jan 30, 2024
816106f
add more tests and group streaming
nplasterer Jan 30, 2024
b579a65
get the new codec working as expected
nplasterer Jan 30, 2024
dec2192
add pagination to messages
nplasterer Jan 30, 2024
06e4df0
fix up the library linting issues
nplasterer Jan 30, 2024
6f5e068
fix up flaky test
nplasterer Jan 30, 2024
1cdd848
fix up min sdk version issue again
nplasterer Jan 30, 2024
58ce184
update the example app
nplasterer Jan 30, 2024
5099e29
remove the saved wallet stuff from the demo
nplasterer Jan 30, 2024
5191cc5
get groups working again with signer improvements and membership changes
nplasterer Jan 30, 2024
7641ac7
fix linter
nplasterer Jan 30, 2024
ee6b1cb
remove syncs so the client will need to manage
nplasterer Jan 30, 2024
655ad0d
add pagination to group listing
nplasterer Jan 30, 2024
eae74a3
dont return self for peers and add erroring to new group creation
nplasterer Jan 30, 2024
2f4abdc
update the syncing in the tests
nplasterer Jan 30, 2024
76bfcc7
remove all the streams work and move to another PR
nplasterer Jan 30, 2024
53c9e26
remove need to lowercase
nplasterer Jan 31, 2024
75c57c9
try some update ci stuff
nplasterer Jan 31, 2024
c56ac33
try the warp runners again
nplasterer Jan 31, 2024
e1b4c0a
add test on can message
nplasterer Jan 31, 2024
fefded1
another scenario to lowercase
nplasterer Jan 31, 2024
47f79bc
try removing mls validation
nplasterer Jan 31, 2024
b2c8e01
forgot to remove it in one place
nplasterer Jan 31, 2024
421acb8
fix path
nplasterer Jan 31, 2024
a7a36ef
add back validation
nplasterer Jan 31, 2024
1c1a804
try without warp
nplasterer Jan 31, 2024
b886003
try warp again
nplasterer Jan 31, 2024
9bb2390
why do I need colima again
nplasterer Jan 31, 2024
22bb27a
try not on mac runner
nplasterer Jan 31, 2024
052db8a
dump schema and try to fix tests
nplasterer Jan 31, 2024
b4be3cd
try ubuntu latest
nplasterer Jan 31, 2024
e01332b
no lowercasing needed
nplasterer Jan 31, 2024
d686efd
typo
nplasterer Jan 31, 2024
e9cb54c
try warp build again
nplasterer Feb 1, 2024
11cd529
try the other linux one
nplasterer Feb 1, 2024
0ce30fa
try lower version
nplasterer Feb 1, 2024
94c446c
add linus runners
nplasterer Feb 1, 2024
1ccbce1
add one last try for the jni
nplasterer Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions dev/local/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
services:
waku-node:
node:
image: xmtp/node-go:latest
platform: linux/amd64
environment:
Expand All @@ -8,14 +8,30 @@ services:
- --store.enable
- --store.db-connection-string=postgres://postgres:xmtp@db:5432/postgres?sslmode=disable
- --store.reader-db-connection-string=postgres://postgres:xmtp@db:5432/postgres?sslmode=disable
- --mls-store.db-connection-string=postgres://postgres:xmtp@mlsdb:5432/postgres?sslmode=disable
- --mls-validation.grpc-address=validation:50051
- --api.enable-mls
- --wait-for-db=30s
- --api.authn.enable
ports:
- 9001:9001
- 5555:5555
- 5556:5556
depends_on:
- db

validation:
image: xmtp/mls-validation-service:latest
platform: linux/amd64
build:
context: ../..
dockerfile: ./dev/validation_service/local.Dockerfile

db:
image: postgres:13
environment:
POSTGRES_PASSWORD: xmtp
POSTGRES_PASSWORD: xmtp

mlsdb:
image: postgres:13
environment:
POSTGRES_PASSWORD: xmtp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.xmtp.android.example.account
import android.net.Uri
import com.walletconnect.wcmodal.client.Modal
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import org.web3j.crypto.Keys
import org.xmtp.android.example.connect.getPersonalSignBody
import org.xmtp.android.example.extension.requestMethod
Expand All @@ -14,21 +15,39 @@ import org.xmtp.proto.message.contents.SignatureOuterClass
data class WalletConnectV2Account(
val session: Modal.Model.ApprovedSession,
val chain: String,
private val sendSessionRequestDeepLink: (Uri) -> Unit
private val sendSessionRequestDeepLink: (Uri) -> Unit,
) :
SigningKey {
override val address: String
get() = Keys.toChecksumAddress(
session.namespaces.getValue(chain).accounts[0].substringAfterLast(
":"
)
)

override suspend fun sign(data: ByteArray): SignatureOuterClass.Signature? {
return sign(String(data))
return signLegacy(String(data))
}

override fun sign(text: String): ByteArray {
val (parentChain, chainId, account) = session.namespaces.getValue(chain).accounts[0].split(":")
val requestParams = session.namespaces.getValue(chain).methods.find { method ->
method == "personal_sign"
}?.let { method ->
Modal.Params.Request(
sessionTopic = session.topic,
method = method,
params = getPersonalSignBody(text, account),
chainId = "$parentChain:$chainId"
)
}

runCatching {
runBlocking {
requestMethod(requestParams!!, sendSessionRequestDeepLink).first().getOrThrow()
}
}.onSuccess {
return it
}.onFailure {}

return byteArrayOf()
}

override suspend fun sign(message: String): SignatureOuterClass.Signature? {
override suspend fun signLegacy(message: String): SignatureOuterClass.Signature? {
val (parentChain, chainId, account) = session.namespaces.getValue(chain).accounts[0].split(":")
val requestParams = session.namespaces.getValue(chain).methods.find { method ->
method == "personal_sign"
Expand All @@ -50,4 +69,12 @@ data class WalletConnectV2Account(

return null
}

override fun getAddress(): String {
return Keys.toChecksumAddress(
session.namespaces.getValue(chain).accounts[0].substringAfterLast(
":"
)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ConnectWalletViewModel : ViewModel() {
val wallet = PrivateKeyBuilder()
val client = Client().create(wallet, ClientManager.CLIENT_OPTIONS)
_uiState.value = ConnectUiState.Success(
wallet.address,
wallet.getAddress(),
PrivateKeyBundleV1Builder.encodeData(client.privateKeyBundleV1)
)
} catch (e: XMTPException) {
Expand All @@ -110,7 +110,7 @@ class ConnectWalletViewModel : ViewModel() {
}
val client = Client().create(wallet, ClientManager.CLIENT_OPTIONS)
_uiState.value = ConnectUiState.Success(
wallet.address,
wallet.getAddress(),
PrivateKeyBundleV1Builder.encodeData(client.privateKeyBundleV1)
)
} catch (e: Exception) {
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dokkaGfmPartial {

ktlint {
filter {
exclude { it.file.path.contains("xmtp_dh") }
exclude { it.file.path.contains("xmtp") }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.xmtp.android.library

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.fail
import org.junit.Ignore
import org.junit.Test
Expand Down Expand Up @@ -39,7 +41,7 @@ class ClientTest {
val v1Copy = PrivateKeyBundleV1Builder.fromEncodedData(encodedData)
val client = Client().buildFrom(v1Copy)
assertEquals(
wallet.address,
wallet.getAddress(),
client.address,
)
}
Expand Down Expand Up @@ -78,12 +80,33 @@ class ClientTest {
)
}

@Test
fun testCreatesAV3Client() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
val fakeWallet = PrivateKeyBuilder()
val client =
Client().create(
account = fakeWallet,
options = ClientOptions(enableLibXmtpV3 = true, appContext = context)
)
val v3Client = client.libXMTPClient
assertEquals(client.address.lowercase(), v3Client?.accountAddress()?.lowercase())
}

@Test
fun testDoesNotCreateAV3Client() {
val fakeWallet = PrivateKeyBuilder()
val client = Client().create(account = fakeWallet)
val v3Client = client.libXMTPClient
assertNull(v3Client)
}

@Test
fun testCanMessage() {
val fixtures = fixtures()
val notOnNetwork = PrivateKeyBuilder()
val canMessage = fixtures.aliceClient.canMessage(fixtures.bobClient.address)
val cannotMessage = fixtures.aliceClient.canMessage(notOnNetwork.address)
val cannotMessage = fixtures.aliceClient.canMessage(notOnNetwork.getAddress())
assert(canMessage)
assert(!cannotMessage)
}
Expand All @@ -97,8 +120,8 @@ class ClientTest {
val aliceClient = Client().create(aliceWallet, opts)
aliceClient.ensureUserContactPublished()

val canMessage = Client.canMessage(aliceWallet.address, opts)
val cannotMessage = Client.canMessage(notOnNetwork.address, opts)
val canMessage = Client.canMessage(aliceWallet.getAddress(), opts)
val cannotMessage = Client.canMessage(notOnNetwork.getAddress(), opts)

assert(canMessage)
assert(!cannotMessage)
Expand Down
Loading
Loading