Skip to content

Commit

Permalink
fix up the lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 19, 2024
1 parent 21e1ffe commit 36c9ce0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -66,4 +67,4 @@ class FramesTest {
assertEquals(responseCode, 200)
assertEquals(connection.contentType, "image/png")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 36c9ce0

Please sign in to comment.