Skip to content

Commit

Permalink
update the library
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Sep 26, 2024
1 parent 607a2a7 commit f508b76
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 22 deletions.
32 changes: 16 additions & 16 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class GroupTest {
alixGroup.addMembers(listOf(caro.walletAddress))
boGroup.sync()
}
assertEquals(alixGroup.members(alixClient).size, 3)
assertEquals(boGroup.members(boClient).size, 3)
assertEquals(alixGroup.members().size, 3)
assertEquals(boGroup.members().size, 3)

// All members also defaults remove to admin only now.
assertThrows(XMTPException::class.java) {
Expand All @@ -95,8 +95,8 @@ class GroupTest {
}
}

assertEquals(alixGroup.members(alixClient).size, 3)
assertEquals(boGroup.members(boClient).size, 3)
assertEquals(alixGroup.members().size, 3)
assertEquals(boGroup.members().size, 3)

assertEquals(boGroup.permissionPolicySet().addMemberPolicy, PermissionOption.Allow)
assertEquals(alixGroup.permissionPolicySet().addMemberPolicy, PermissionOption.Allow)
Expand Down Expand Up @@ -135,31 +135,31 @@ class GroupTest {
alixGroup.sync()
}

assertEquals(alixGroup.members(alixClient).size, 3)
assertEquals(boGroup.members(boClient).size, 3)
assertEquals(alixGroup.members().size, 3)
assertEquals(boGroup.members().size, 3)

assertThrows(XMTPException::class.java) {
runBlocking { alixGroup.removeMembers(listOf(caro.walletAddress)) }
}
runBlocking { boGroup.sync() }

assertEquals(alixGroup.members(alixClient).size, 3)
assertEquals(boGroup.members(boClient).size, 3)
assertEquals(alixGroup.members().size, 3)
assertEquals(boGroup.members().size, 3)
runBlocking {
boGroup.removeMembers(listOf(caro.walletAddress))
alixGroup.sync()
}

assertEquals(alixGroup.members(alixClient).size, 2)
assertEquals(boGroup.members(boClient).size, 2)
assertEquals(alixGroup.members().size, 2)
assertEquals(boGroup.members().size, 2)

assertThrows(XMTPException::class.java) {
runBlocking { alixGroup.addMembers(listOf(caro.walletAddress)) }
}
runBlocking { boGroup.sync() }

assertEquals(alixGroup.members(alixClient).size, 2)
assertEquals(boGroup.members(boClient).size, 2)
assertEquals(alixGroup.members().size, 2)
assertEquals(boGroup.members().size, 2)

assertEquals(boGroup.permissionPolicySet().addMemberPolicy, PermissionOption.Admin)
assertEquals(alixGroup.permissionPolicySet().addMemberPolicy, PermissionOption.Admin)
Expand All @@ -183,7 +183,7 @@ class GroupTest {
)
}
assertEquals(
group.members(boClient).map { it.inboxId }.sorted(),
group.members().map { it.inboxId }.sorted(),
listOf(
caroClient.inboxId,
alixClient.inboxId,
Expand Down Expand Up @@ -291,7 +291,7 @@ class GroupTest {
boGroup.sync()
}
assertEquals(
boGroup.members(boClient).map { it.inboxId }.sorted(),
boGroup.members().map { it.inboxId }.sorted(),
listOf(
alixClient.inboxId,
boClient.inboxId
Expand All @@ -303,7 +303,7 @@ class GroupTest {
val group = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress)) }
runBlocking { group.addMembersByInboxId(listOf(caroClient.inboxId)) }
assertEquals(
group.members(boClient).map { it.inboxId }.sorted(),
group.members().map { it.inboxId }.sorted(),
listOf(
caroClient.inboxId,
alixClient.inboxId,
Expand All @@ -324,7 +324,7 @@ class GroupTest {
}
runBlocking { group.removeMembersByInboxId(listOf(caroClient.inboxId)) }
assertEquals(
group.members(boClient).map { it.inboxId }.sorted(),
group.members().map { it.inboxId }.sorted(),
listOf(
alixClient.inboxId,
boClient.inboxId
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/libxmtp-version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: cd0fc5cb
Version: 4f529aeb
Branch: main
Date: 2024-09-20 15:05:17 +0000
Date: 2024-09-26 04:05:26 +0000
87 changes: 83 additions & 4 deletions library/src/main/java/xmtpv3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7094,7 +7094,7 @@ public object FfiConverterTypeFfiGroupMember : FfiConverterRustBuffer<FfiGroupMe
data class FfiInboxState(
var `inboxId`: kotlin.String,
var `recoveryAddress`: kotlin.String,
var `installationIds`: List<kotlin.ByteArray>,
var `installations`: List<FfiInstallation>,
var `accountAddresses`: List<kotlin.String>,
) {

Expand All @@ -7106,27 +7106,55 @@ public object FfiConverterTypeFfiInboxState : FfiConverterRustBuffer<FfiInboxSta
return FfiInboxState(
FfiConverterString.read(buf),
FfiConverterString.read(buf),
FfiConverterSequenceByteArray.read(buf),
FfiConverterSequenceTypeFfiInstallation.read(buf),
FfiConverterSequenceString.read(buf),
)
}

override fun allocationSize(value: FfiInboxState) = (
FfiConverterString.allocationSize(value.`inboxId`) +
FfiConverterString.allocationSize(value.`recoveryAddress`) +
FfiConverterSequenceByteArray.allocationSize(value.`installationIds`) +
FfiConverterSequenceTypeFfiInstallation.allocationSize(value.`installations`) +
FfiConverterSequenceString.allocationSize(value.`accountAddresses`)
)

override fun write(value: FfiInboxState, buf: ByteBuffer) {
FfiConverterString.write(value.`inboxId`, buf)
FfiConverterString.write(value.`recoveryAddress`, buf)
FfiConverterSequenceByteArray.write(value.`installationIds`, buf)
FfiConverterSequenceTypeFfiInstallation.write(value.`installations`, buf)
FfiConverterSequenceString.write(value.`accountAddresses`, buf)
}
}


data class FfiInstallation(
var `id`: kotlin.ByteArray,
var `clientTimestampNs`: kotlin.ULong?,
) {

companion object
}

public object FfiConverterTypeFfiInstallation : FfiConverterRustBuffer<FfiInstallation> {
override fun read(buf: ByteBuffer): FfiInstallation {
return FfiInstallation(
FfiConverterByteArray.read(buf),
FfiConverterOptionalULong.read(buf),
)
}

override fun allocationSize(value: FfiInstallation) = (
FfiConverterByteArray.allocationSize(value.`id`) +
FfiConverterOptionalULong.allocationSize(value.`clientTimestampNs`)
)

override fun write(value: FfiInstallation, buf: ByteBuffer) {
FfiConverterByteArray.write(value.`id`, buf)
FfiConverterOptionalULong.write(value.`clientTimestampNs`, buf)
}
}


data class FfiListConversationsOptions(
var `createdAfterNs`: kotlin.Long?,
var `createdBeforeNs`: kotlin.Long?,
Expand Down Expand Up @@ -8221,6 +8249,33 @@ public object FfiConverterTypeFfiV2SubscriptionCallback :
FfiConverterCallbackInterface<FfiV2SubscriptionCallback>()


public object FfiConverterOptionalULong : FfiConverterRustBuffer<kotlin.ULong?> {
override fun read(buf: ByteBuffer): kotlin.ULong? {
if (buf.get().toInt() == 0) {
return null
}
return FfiConverterULong.read(buf)
}

override fun allocationSize(value: kotlin.ULong?): ULong {
if (value == null) {
return 1UL
} else {
return 1UL + FfiConverterULong.allocationSize(value)
}
}

override fun write(value: kotlin.ULong?, buf: ByteBuffer) {
if (value == null) {
buf.put(0)
} else {
buf.put(1)
FfiConverterULong.write(value, buf)
}
}
}


public object FfiConverterOptionalLong : FfiConverterRustBuffer<kotlin.Long?> {
override fun read(buf: ByteBuffer): kotlin.Long? {
if (buf.get().toInt() == 0) {
Expand Down Expand Up @@ -8634,6 +8689,30 @@ public object FfiConverterSequenceTypeFfiGroupMember :
}


public object FfiConverterSequenceTypeFfiInstallation :
FfiConverterRustBuffer<List<FfiInstallation>> {
override fun read(buf: ByteBuffer): List<FfiInstallation> {
val len = buf.getInt()
return List<FfiInstallation>(len) {
FfiConverterTypeFfiInstallation.read(buf)
}
}

override fun allocationSize(value: List<FfiInstallation>): ULong {
val sizeForLength = 4UL
val sizeForItems = value.map { FfiConverterTypeFfiInstallation.allocationSize(it) }.sum()
return sizeForLength + sizeForItems
}

override fun write(value: List<FfiInstallation>, buf: ByteBuffer) {
buf.putInt(value.size)
value.iterator().forEach {
FfiConverterTypeFfiInstallation.write(it, buf)
}
}
}


public object FfiConverterSequenceTypeFfiMessage : FfiConverterRustBuffer<List<FfiMessage>> {
override fun read(buf: ByteBuffer): List<FfiMessage> {
val len = buf.getInt()
Expand Down

0 comments on commit f508b76

Please sign in to comment.