Skip to content

Commit

Permalink
use static string to test signMessage easier
Browse files Browse the repository at this point in the history
  • Loading branch information
nickcruz committed Sep 9, 2022
1 parent 36b9c92 commit 5115eba
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.solana.mobilewalletadapter.clientlib.scenario.LocalAssociationIntentC
import com.solana.mobilewalletadapter.clientlib.scenario.LocalAssociationScenario
import com.solana.mobilewalletadapter.clientlib.scenario.Scenario
import com.solana.mobilewalletadapter.common.ProtocolContract
import com.solana.mobilewalletadapter.fakedapp.usecase.Base58EncodeUseCase
import com.solana.mobilewalletadapter.fakedapp.usecase.GetLatestBlockhashUseCase
import com.solana.mobilewalletadapter.fakedapp.usecase.MemoTransactionUseCase
import com.solana.mobilewalletadapter.fakedapp.usecase.RequestAirdropUseCase
Expand Down Expand Up @@ -181,10 +182,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
if (!authorized) {
return@localAssociateAndExecute null
}
val messages = Array(numMessages) {
Random.nextBytes(16384)
}
doSignMessages(client, messages, arrayOf(_uiState.value.publicKey!!))
val message = "To avoid digital dognappers, sign below to authenticate with CryptoCorgis.".toByteArray(Charsets.UTF_8)
doSignMessages(client, arrayOf(message), arrayOf(_uiState.value.publicKey!!))
}

showMessage(if (signedMessages != null) R.string.msg_request_succeeded else R.string.msg_request_failed)
Expand Down Expand Up @@ -432,7 +431,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
var signedMessages: Array<ByteArray>? = null
try {
val result = client.signMessages(messages, addresses).get()
Log.d(TAG, "Signed message(s): $result")
Log.d(TAG, "Signed message base58: ${Base58EncodeUseCase(result.signedPayloads[0])}")
signedMessages = result.signedPayloads
} catch (e: ExecutionException) {
when (val cause = e.cause) {
Expand Down

0 comments on commit 5115eba

Please sign in to comment.