Skip to content

Commit

Permalink
try and get it working
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 20, 2024
1 parent 375a295 commit 255788a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ dependencies {
implementation 'org.web3j:crypto:4.9.4'
implementation "net.java.dev.jna:jna:5.14.0@aar"
api 'com.google.protobuf:protobuf-kotlin-lite:3.22.3'
api 'org.xmtp:proto-kotlin:3.71.0'
api 'org.xmtp:proto-kotlin:3.72.1'

testImplementation 'junit:junit:4.13.2'
testImplementation 'androidx.test:monitor:1.7.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.xmtp.android.library.frames

import android.util.Base64
import com.google.protobuf.kotlin.toByteString
import org.xmtp.android.library.Client
import org.xmtp.android.library.XMTPException
import org.xmtp.android.library.frames.FramesConstants.PROTOCOL_VERSION
import org.xmtp.android.library.hexToByteArray
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.messages.Signature
import org.xmtp.android.library.toHex
import java.security.MessageDigest
import org.xmtp.proto.message.contents.Frames.FrameActionBody
import org.xmtp.proto.message.contents.Frames.FrameAction
Expand All @@ -24,7 +27,6 @@ class FramesClient(private val xmtpClient: Client, var proxy: OpenFramesProxy =
frame.frameUrl = frameUrl
frame.buttonIndex = buttonIndex
frame.opaqueConversationIdentifier = opaqueConversationIdentifier
frame.timestamp = now
frame.unixTimestamp = now.toInt()
if (inputText != null) {
frame.inputText = inputText
Expand All @@ -44,17 +46,17 @@ class FramesClient(private val xmtpClient: Client, var proxy: OpenFramesProxy =
}

private fun signDigest(message: String): ByteArray {
return xmtpClient.signInstallationKey(message)
return xmtpClient.signWithInstallationKey(message)
}

private suspend fun buildSignedFrameAction(actionBodyInputs: FrameActionBody): ByteArray {
val digest = sha256(actionBodyInputs.toByteArray()).toString()
private fun buildSignedFrameAction(actionBodyInputs: FrameActionBody): ByteArray {
val digest = sha256(actionBodyInputs.toByteArray()).toHex()
val signature = signDigest(digest)

val frameAction = FrameAction.newBuilder().also {
it.actionBody = actionBodyInputs.toByteString()
it.signature = signature
it.signedPublicKeyBundle = publicKeyBundle
it.installationSignature = signature.toByteString()
it.installationId = xmtpClient.installationId.hexToByteArray().toByteString()
}.build()

return frameAction.toByteArray()
Expand Down

0 comments on commit 255788a

Please sign in to comment.