Skip to content

Commit

Permalink
basic web3core support
Browse files Browse the repository at this point in the history
  • Loading branch information
Funkatronics committed May 29, 2024
1 parent 5e16732 commit 1522867
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions android/clientlib-ktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ tasks.whenTaskAdded { task ->

dependencies {
api(project(":clientlib"))
api libs.web3.solana
implementation libs.androidx.core.ktx
implementation libs.androidx.activity.ktx
implementation libs.androidx.junit.ktx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.solana.mobilewalletadapter.clientlib
import android.net.Uri
import com.solana.mobilewalletadapter.clientlib.protocol.MobileWalletAdapterClient
import com.solana.mobilewalletadapter.common.signin.SignInWithSolana
import com.solana.transaction.Transaction

interface AdapterOperations {

Expand Down Expand Up @@ -47,4 +48,21 @@ interface AdapterOperations {
suspend fun signTransactions(transactions: Array<ByteArray>): MobileWalletAdapterClient.SignPayloadsResult

suspend fun signAndSendTransactions(transactions: Array<ByteArray>, params: TransactionParams = DefaultTransactionParams): MobileWalletAdapterClient.SignAndSendTransactionsResult
suspend fun AdapterOperations.signTransactions(vararg transactions: Transaction): List<Transaction> =
signTransactions(
runCatching {
transactions.map { it.serialize() }.toTypedArray()
}.getOrElse {
throw IllegalArgumentException("Transactions could not be serialized", it)
}
).signedPayloads.map { Transaction.from(it) }
suspend fun AdapterOperations.signAndSendTransactions(vararg transactions: Transaction)
: MobileWalletAdapterClient.SignAndSendTransactionsResult =
signAndSendTransactions(
runCatching {
transactions.map { it.serialize() }.toTypedArray()
}.getOrElse {
throw IllegalArgumentException("Transactions could not be serialized", it)
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class MobileWalletAdapter(
return@coroutineScope TransactionResult.Failure("Request was interrupted", e)
} catch (e: ActivityNotFoundException) {
return@coroutineScope TransactionResult.NoWalletFound("No compatible wallet found.")
} catch (e: java.lang.IllegalStateException) {
} catch (e: java.lang.RuntimeException) {
return@coroutineScope TransactionResult.Failure(e.message.toString(), e)
}
}
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ multimult = "0.2.1"
nvWebsocketClient = "2.14"
robolectric = "4.12.2"
slf4jAndroid = "1.7.36"
web3Solana = "0.2.3"
web3Core = "0.3.0-beta2"

[libraries]
androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "androidxActivityKtx" }
Expand Down Expand Up @@ -80,7 +80,7 @@ multimult = { module = "io.github.funkatronics:multimult", version.ref = "multim
nv-websocket-client = { module = "com.neovisionaries:nv-websocket-client", version.ref = "nvWebsocketClient" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
slf4j-android = { module = "org.slf4j:slf4j-android", version.ref = "slf4jAndroid" }
web3-solana = { module = "com.solanamobile:web3-solana", version.ref = "web3Solana" }
web3-solana = { module = "com.solanamobile:web3-solana", version.ref = "web3Core" }

[plugins]
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
Expand Down

0 comments on commit 1522867

Please sign in to comment.