Skip to content

Commit

Permalink
Adds custom policy type, fixes invalid policy error (#263)
Browse files Browse the repository at this point in the history
* adds custom policy type, fixes invalid policy error

* format kotlin bindings file

* update libxmtp version txt

---------

Co-authored-by: cameronvoell <[email protected]>
  • Loading branch information
cameronvoell and cameronvoell authored Jun 25, 2024
1 parent 0b6f4fa commit 9e47f24
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 48 deletions.
23 changes: 11 additions & 12 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,14 @@ class GroupTest {
assertEquals(alixGroup.members().size, 3)
assertEquals(boGroup.members().size, 3)

runBlocking {
alixGroup.removeMembers(listOf(caro.walletAddress))
boGroup.sync()
// All members also defaults remove to admin only now.
assertThrows(XMTPException::class.java) {
runBlocking {
alixGroup.removeMembers(listOf(caro.walletAddress))
boGroup.sync()
}
}

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

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

Expand Down Expand Up @@ -277,7 +273,10 @@ class GroupTest {
)
)
}
runBlocking { alixClient.conversations.syncGroups() }
runBlocking {
boGroup.addAdmin(alixClient.inboxId)
alixClient.conversations.syncGroups()
}
val group = runBlocking {
alixClient.conversations.syncGroups()
alixClient.conversations.listGroups().first()
Expand Down Expand Up @@ -485,7 +484,7 @@ class GroupTest {

Thread.sleep(1000)

assertEquals(4, messageCallbacks)
assertEquals(secondMsgCheck, messageCallbacks)
}

@Test
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: 1e096906
Version: bbf05eac
Branch: main
Date: 2024-06-24 17:58:00 +0000
Date: 2024-06-25 01:50:26 +0000
73 changes: 39 additions & 34 deletions library/src/main/java/xmtpv3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ open class RustBuffer : Structure() {
// When dealing with these fields, make sure to call `toULong()`.
@JvmField
var capacity: Long = 0

@JvmField
var len: Long = 0

@JvmField
var data: Pointer? = null

Expand Down Expand Up @@ -135,6 +137,7 @@ class RustBufferByReference : ByReference(16) {
open class ForeignBytes : Structure() {
@JvmField
var len: Int = 0

@JvmField
var data: Pointer? = null

Expand Down Expand Up @@ -223,6 +226,7 @@ internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte()
internal open class UniffiRustCallStatus : Structure() {
@JvmField
var code: Byte = 0

@JvmField
var error_buf: RustBuffer.ByValue = RustBuffer.ByValue()

Expand Down Expand Up @@ -264,7 +268,7 @@ interface UniffiRustCallStatusErrorHandler<E> {
// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
private inline fun <U, E : Exception> uniffiRustCallWithError(
errorHandler: UniffiRustCallStatusErrorHandler<E>,
callback: (UniffiRustCallStatus) -> U,
callback: (UniffiRustCallStatus) -> U
): U {
var status = UniffiRustCallStatus();
val return_value = callback(status)
Expand All @@ -275,7 +279,7 @@ private inline fun <U, E : Exception> uniffiRustCallWithError(
// Check UniffiRustCallStatus and throw an error if the call wasn't successful
private fun <E : Exception> uniffiCheckCallStatus(
errorHandler: UniffiRustCallStatusErrorHandler<E>,
status: UniffiRustCallStatus,
status: UniffiRustCallStatus
) {
if (status.isSuccess()) {
return
Expand Down Expand Up @@ -325,7 +329,7 @@ internal inline fun <T, reified E : Throwable> uniffiTraitInterfaceCallWithError
callStatus: UniffiRustCallStatus,
makeCall: () -> T,
writeReturn: (T) -> Unit,
lowerError: (E) -> RustBuffer.ByValue,
lowerError: (E) -> RustBuffer.ByValue
) {
try {
writeReturn(makeCall())
Expand Down Expand Up @@ -380,7 +384,7 @@ private fun findLibraryName(componentName: String): String {
}

private inline fun <reified Lib : Library> loadIndirect(
componentName: String,
componentName: String
): Lib {
return Native.load<Lib>(findLibraryName(componentName), Lib::class.java)
}
Expand Down Expand Up @@ -2047,7 +2051,7 @@ internal suspend fun <T, F, E : Exception> uniffiRustCallAsync(
completeFunc: (Long, UniffiRustCallStatus) -> F,
freeFunc: (Long) -> Unit,
liftFunc: (F) -> T,
errorHandler: UniffiRustCallStatusErrorHandler<E>,
errorHandler: UniffiRustCallStatusErrorHandler<E>
): T {
try {
do {
Expand Down Expand Up @@ -2431,7 +2435,7 @@ private class JavaLangRefCleaner : UniffiCleaner {
}

private class JavaLangRefCleanable(
val cleanable: java.lang.ref.Cleaner.Cleanable,
val cleanable: java.lang.ref.Cleaner.Cleanable
) : UniffiCleaner.Cleanable {
override fun clean() = cleanable.clean()
}
Expand All @@ -2440,7 +2444,7 @@ public interface FfiConversationsInterface {

suspend fun `createGroup`(
`accountAddresses`: List<kotlin.String>,
`opts`: FfiCreateGroupOptions,
`opts`: FfiCreateGroupOptions
): FfiGroup

suspend fun `list`(`opts`: FfiListConversationsOptions): List<FfiGroup>
Expand Down Expand Up @@ -2542,7 +2546,7 @@ open class FfiConversations : Disposable, AutoCloseable, FfiConversationsInterfa
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `createGroup`(
`accountAddresses`: List<kotlin.String>,
`opts`: FfiCreateGroupOptions,
`opts`: FfiCreateGroupOptions
): FfiGroup {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
Expand Down Expand Up @@ -4269,7 +4273,7 @@ public interface FfiSignatureRequestInterface {
suspend fun `addScwSignature`(
`signatureBytes`: kotlin.ByteArray,
`address`: kotlin.String,
`chainRpcUrl`: kotlin.String,
`chainRpcUrl`: kotlin.String
)

suspend fun `isReady`(): kotlin.Boolean
Expand Down Expand Up @@ -4404,7 +4408,7 @@ open class FfiSignatureRequest : Disposable, AutoCloseable, FfiSignatureRequestI
override suspend fun `addScwSignature`(
`signatureBytes`: kotlin.ByteArray,
`address`: kotlin.String,
`chainRpcUrl`: kotlin.String,
`chainRpcUrl`: kotlin.String
) {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
Expand Down Expand Up @@ -5983,7 +5987,7 @@ public object FfiConverterTypeFfiXmtpClient : FfiConverter<FfiXmtpClient, Pointe
data class FfiCreateGroupOptions(
var `permissions`: GroupPermissions?,
var `groupName`: kotlin.String?,
var `groupImageUrlSquare`: kotlin.String?,
var `groupImageUrlSquare`: kotlin.String?
) {

companion object
Expand Down Expand Up @@ -6015,7 +6019,7 @@ public object FfiConverterTypeFfiCreateGroupOptions :

data class FfiCursor(
var `digest`: kotlin.ByteArray,
var `senderTimeNs`: kotlin.ULong,
var `senderTimeNs`: kotlin.ULong
) {

companion object
Expand Down Expand Up @@ -6044,7 +6048,7 @@ public object FfiConverterTypeFfiCursor : FfiConverterRustBuffer<FfiCursor> {
data class FfiEnvelope(
var `contentTopic`: kotlin.String,
var `timestampNs`: kotlin.ULong,
var `message`: kotlin.ByteArray,
var `message`: kotlin.ByteArray
) {

companion object
Expand Down Expand Up @@ -6077,7 +6081,7 @@ data class FfiGroupMember(
var `inboxId`: kotlin.String,
var `accountAddresses`: List<kotlin.String>,
var `installationIds`: List<kotlin.ByteArray>,
var `permissionLevel`: FfiPermissionLevel,
var `permissionLevel`: FfiPermissionLevel
) {

companion object
Expand Down Expand Up @@ -6112,7 +6116,7 @@ public object FfiConverterTypeFfiGroupMember : FfiConverterRustBuffer<FfiGroupMe
data class FfiListConversationsOptions(
var `createdAfterNs`: kotlin.Long?,
var `createdBeforeNs`: kotlin.Long?,
var `limit`: kotlin.Long?,
var `limit`: kotlin.Long?
) {

companion object
Expand Down Expand Up @@ -6146,7 +6150,7 @@ data class FfiListMessagesOptions(
var `sentBeforeNs`: kotlin.Long?,
var `sentAfterNs`: kotlin.Long?,
var `limit`: kotlin.Long?,
var `deliveryStatus`: FfiDeliveryStatus?,
var `deliveryStatus`: FfiDeliveryStatus?
) {

companion object
Expand Down Expand Up @@ -6186,7 +6190,7 @@ data class FfiMessage(
var `senderInboxId`: kotlin.String,
var `content`: kotlin.ByteArray,
var `kind`: FfiGroupMessageKind,
var `deliveryStatus`: FfiDeliveryStatus,
var `deliveryStatus`: FfiDeliveryStatus
) {

companion object
Expand Down Expand Up @@ -6230,7 +6234,7 @@ public object FfiConverterTypeFfiMessage : FfiConverterRustBuffer<FfiMessage> {
data class FfiPagingInfo(
var `limit`: kotlin.UInt,
var `cursor`: FfiCursor?,
var `direction`: FfiSortDirection,
var `direction`: FfiSortDirection
) {

companion object
Expand Down Expand Up @@ -6260,7 +6264,7 @@ public object FfiConverterTypeFfiPagingInfo : FfiConverterRustBuffer<FfiPagingIn


data class FfiPublishRequest(
var `envelopes`: List<FfiEnvelope>,
var `envelopes`: List<FfiEnvelope>
) {

companion object
Expand All @@ -6284,7 +6288,7 @@ public object FfiConverterTypeFfiPublishRequest : FfiConverterRustBuffer<FfiPubl


data class FfiV2BatchQueryRequest(
var `requests`: List<FfiV2QueryRequest>,
var `requests`: List<FfiV2QueryRequest>
) {

companion object
Expand All @@ -6309,7 +6313,7 @@ public object FfiConverterTypeFfiV2BatchQueryRequest :


data class FfiV2BatchQueryResponse(
var `responses`: List<FfiV2QueryResponse>,
var `responses`: List<FfiV2QueryResponse>
) {

companion object
Expand Down Expand Up @@ -6337,7 +6341,7 @@ data class FfiV2QueryRequest(
var `contentTopics`: List<kotlin.String>,
var `startTimeNs`: kotlin.ULong,
var `endTimeNs`: kotlin.ULong,
var `pagingInfo`: FfiPagingInfo?,
var `pagingInfo`: FfiPagingInfo?
) {

companion object
Expand Down Expand Up @@ -6371,7 +6375,7 @@ public object FfiConverterTypeFfiV2QueryRequest : FfiConverterRustBuffer<FfiV2Qu

data class FfiV2QueryResponse(
var `envelopes`: List<FfiEnvelope>,
var `pagingInfo`: FfiPagingInfo?,
var `pagingInfo`: FfiPagingInfo?
) {

companion object
Expand All @@ -6398,7 +6402,7 @@ public object FfiConverterTypeFfiV2QueryResponse : FfiConverterRustBuffer<FfiV2Q


data class FfiV2SubscribeRequest(
var `contentTopics`: List<kotlin.String>,
var `contentTopics`: List<kotlin.String>
) {

companion object
Expand Down Expand Up @@ -6641,7 +6645,8 @@ public object FfiConverterTypeGenericError : FfiConverterRustBuffer<GenericExcep
enum class GroupPermissions {

ALL_MEMBERS,
ADMIN_ONLY;
ADMIN_ONLY,
CUSTOM_POLICY;

companion object
}
Expand Down Expand Up @@ -7438,7 +7443,7 @@ suspend fun `createClient`(
`accountAddress`: kotlin.String,
`nonce`: kotlin.ULong,
`legacySignedPrivateKeyProto`: kotlin.ByteArray?,
`historySyncUrl`: kotlin.String?,
`historySyncUrl`: kotlin.String?
): FfiXmtpClient {
return uniffiRustCallAsync(
UniffiLib.INSTANCE.uniffi_xmtpv3_fn_func_create_client(
Expand Down Expand Up @@ -7508,7 +7513,7 @@ suspend fun `createV2Client`(`host`: kotlin.String, `isSecure`: kotlin.Boolean):
@Throws(GenericException::class)
fun `diffieHellmanK256`(
`privateKeyBytes`: kotlin.ByteArray,
`publicKeyBytes`: kotlin.ByteArray,
`publicKeyBytes`: kotlin.ByteArray
): kotlin.ByteArray {
return FfiConverterByteArray.lift(
uniffiRustCallWithError(GenericException) { _status ->
Expand Down Expand Up @@ -7552,7 +7557,7 @@ suspend fun `getInboxIdForAddress`(
`logger`: FfiLogger,
`host`: kotlin.String,
`isSecure`: kotlin.Boolean,
`accountAddress`: kotlin.String,
`accountAddress`: kotlin.String
): kotlin.String? {
return uniffiRustCallAsync(
UniffiLib.INSTANCE.uniffi_xmtpv3_fn_func_get_inbox_id_for_address(
Expand Down Expand Up @@ -7620,7 +7625,7 @@ fun `publicKeyFromPrivateKeyK256`(`privateKeyBytes`: kotlin.ByteArray): kotlin.B
@Throws(GenericException::class)
fun `recoverAddress`(
`signatureBytes`: kotlin.ByteArray,
`predigestMessage`: kotlin.String,
`predigestMessage`: kotlin.String
): kotlin.String {
return FfiConverterString.lift(
uniffiRustCallWithError(GenericException) { _status ->
Expand All @@ -7637,7 +7642,7 @@ fun `recoverAddress`(
@Throws(GenericException::class)
fun `recoverPublicKeyK256Keccak256`(
`message`: kotlin.ByteArray,
`signature`: kotlin.ByteArray,
`signature`: kotlin.ByteArray
): kotlin.ByteArray {
return FfiConverterByteArray.lift(
uniffiRustCallWithError(GenericException) { _status ->
Expand All @@ -7654,7 +7659,7 @@ fun `recoverPublicKeyK256Keccak256`(
@Throws(GenericException::class)
fun `recoverPublicKeyK256Sha256`(
`message`: kotlin.ByteArray,
`signature`: kotlin.ByteArray,
`signature`: kotlin.ByteArray
): kotlin.ByteArray {
return FfiConverterByteArray.lift(
uniffiRustCallWithError(GenericException) { _status ->
Expand Down Expand Up @@ -7682,7 +7687,7 @@ fun `sha256`(`input`: kotlin.ByteArray): kotlin.ByteArray {
fun `userPreferencesDecrypt`(
`publicKey`: kotlin.ByteArray,
`privateKey`: kotlin.ByteArray,
`message`: kotlin.ByteArray,
`message`: kotlin.ByteArray
): kotlin.ByteArray {
return FfiConverterByteArray.lift(
uniffiRustCallWithError(GenericException) { _status ->
Expand All @@ -7701,7 +7706,7 @@ fun `userPreferencesDecrypt`(
fun `userPreferencesEncrypt`(
`publicKey`: kotlin.ByteArray,
`privateKey`: kotlin.ByteArray,
`message`: kotlin.ByteArray,
`message`: kotlin.ByteArray
): kotlin.ByteArray {
return FfiConverterByteArray.lift(
uniffiRustCallWithError(GenericException) { _status ->
Expand All @@ -7721,7 +7726,7 @@ fun `verifyK256Sha256`(
`signedBy`: kotlin.ByteArray,
`message`: kotlin.ByteArray,
`signature`: kotlin.ByteArray,
`recoveryId`: kotlin.UByte,
`recoveryId`: kotlin.UByte
): kotlin.Boolean {
return FfiConverterBoolean.lift(
uniffiRustCallWithError(GenericException) { _status ->
Expand Down
Binary file modified library/src/main/jniLibs/arm64-v8a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86/libuniffi_xmtpv3.so
Binary file not shown.
Binary file modified library/src/main/jniLibs/x86_64/libuniffi_xmtpv3.so
Binary file not shown.

0 comments on commit 9e47f24

Please sign in to comment.