From 36c9ce04106bd1634b420c0dd27191871242ef71 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 18 Dec 2024 16:55:55 -0800 Subject: [PATCH] fix up the lint --- .../org/xmtp/android/library/FramesTest.kt | 5 ++-- .../android/library/frames/FramesClient.kt | 27 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/library/src/androidTest/java/org/xmtp/android/library/FramesTest.kt b/library/src/androidTest/java/org/xmtp/android/library/FramesTest.kt index 994d9dad..665e1f38 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/FramesTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/FramesTest.kt @@ -19,7 +19,8 @@ import java.net.URL class FramesTest { @Test fun testFramesClient() { - val frameUrl = "https://fc-polls-five.vercel.app/polls/03710836-bc1d-4921-9e24-89d82015c53b?env=dev" + val frameUrl = + "https://fc-polls-five.vercel.app/polls/03710836-bc1d-4921-9e24-89d82015c53b?env=dev" val fixtures = fixtures(ClientOptions.Api(XMTPEnvironment.DEV, isSecure = true)) val framesClient = FramesClient(xmtpClient = fixtures.alixClient) val conversationTopic = "foo" @@ -66,4 +67,4 @@ class FramesTest { assertEquals(responseCode, 200) assertEquals(connection.contentType, "image/png") } -} \ No newline at end of file +} diff --git a/library/src/main/java/org/xmtp/android/library/frames/FramesClient.kt b/library/src/main/java/org/xmtp/android/library/frames/FramesClient.kt index 0f5c1fc8..257f61ff 100644 --- a/library/src/main/java/org/xmtp/android/library/frames/FramesClient.kt +++ b/library/src/main/java/org/xmtp/android/library/frames/FramesClient.kt @@ -6,12 +6,10 @@ 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 +import org.xmtp.proto.message.contents.Frames.FrameActionBody +import java.security.MessageDigest import java.util.Date class FramesClient(private val xmtpClient: Client, var proxy: OpenFramesProxy = OpenFramesProxy()) { @@ -39,7 +37,16 @@ class FramesClient(private val xmtpClient: Client, var proxy: OpenFramesProxy = val toSign = frameActionBuilder.build() val signedAction = Base64.encodeToString(buildSignedFrameAction(toSign), Base64.NO_WRAP) - val untrustedData = FramePostUntrustedData(frameUrl, now, buttonIndex, inputText, state, xmtpClient.address, opaqueConversationIdentifier, now.toInt()) + val untrustedData = FramePostUntrustedData( + frameUrl, + now, + buttonIndex, + inputText, + state, + xmtpClient.address, + opaqueConversationIdentifier, + now.toInt() + ) val trustedData = FramePostTrustedData(signedAction) return FramePostPayload("xmtp@$PROTOCOL_VERSION", untrustedData, trustedData) @@ -71,11 +78,15 @@ class FramesClient(private val xmtpClient: Client, var proxy: OpenFramesProxy = val digest = sha256(combined) Base64.encodeToString(digest, Base64.NO_WRAP) } + is ConversationActionInputs.Dm -> { val dmInputs = inputs.conversationInputs.inputs - val conversationTopic = dmInputs.conversationTopic ?: throw XMTPException("No conversation topic") - val combined = (conversationTopic.lowercase() + dmInputs.participantAccountAddresses.map { it.lowercase() }.sorted().joinToString("")).toByteArray() - val digest = sha256(combined) + val conversationTopic = + dmInputs.conversationTopic ?: throw XMTPException("No conversation topic") + val combined = + conversationTopic.lowercase() + dmInputs.participantAccountAddresses.map { it.lowercase() } + .sorted().joinToString("") + val digest = sha256(combined.toByteArray()) Base64.encodeToString(digest, Base64.NO_WRAP) } }