Skip to content

Commit

Permalink
Revert "remove the inbox state and revoke installations code"
Browse files Browse the repository at this point in the history
This reverts commit 10cf325.
  • Loading branch information
cameronvoell committed Aug 22, 2024
1 parent 8ac886b commit 6157e8f
Show file tree
Hide file tree
Showing 8 changed files with 1,994 additions and 1,767 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import expo.modules.xmtpreactnativesdk.wrappers.DecodedMessageWrapper
import expo.modules.xmtpreactnativesdk.wrappers.DecryptedLocalAttachment
import expo.modules.xmtpreactnativesdk.wrappers.EncryptedLocalAttachment
import expo.modules.xmtpreactnativesdk.wrappers.GroupWrapper
import expo.modules.xmtpreactnativesdk.wrappers.InboxStateWrapper
import expo.modules.xmtpreactnativesdk.wrappers.MemberWrapper
import expo.modules.xmtpreactnativesdk.wrappers.PermissionPolicySetWrapper
import expo.modules.xmtpreactnativesdk.wrappers.PreparedLocalMessage
Expand Down Expand Up @@ -65,6 +66,7 @@ import org.xmtp.proto.message.api.v1.MessageApiOuterClass
import org.xmtp.proto.message.contents.Invitation.ConsentProofPayload
import org.xmtp.proto.message.contents.PrivateKeyOuterClass
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.GroupPermissionPreconfiguration
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.InboxState
import uniffi.xmtpv3.org.xmtp.android.library.libxmtp.PermissionOption
import java.io.BufferedReader
import java.io.File
Expand Down Expand Up @@ -274,6 +276,27 @@ class XMTPModule : Module() {
}
}

AsyncFunction("revokeAllOtherInstallations") Coroutine { inboxId: String ->
withContext(Dispatchers.IO) {
logV("revokeAllOtherInstallations")
val client = clients[inboxId] ?: throw XMTPException("No client")
val reactSigner =
ReactNativeSigner(module = this@XMTPModule, address = client.address)
signer = reactSigner

client.revokeAllOtherInstallations(reactSigner)
signer = null
}
}

AsyncFunction("getInboxState") Coroutine { inboxId: String, refreshFromNetwork: Boolean ->
withContext(Dispatchers.IO) {
val client = clients[inboxId] ?: throw XMTPException("No client")
val inboxState = client.inboxState(refreshFromNetwork)
InboxStateWrapper.encode(inboxState)
}
}

//
// Auth functions
//
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)
}
}
}
Loading

0 comments on commit 6157e8f

Please sign in to comment.