diff --git a/android/clientlib-ktx/build.gradle b/android/clientlib-ktx/build.gradle index d3b0deb37..14ca06384 100644 --- a/android/clientlib-ktx/build.gradle +++ b/android/clientlib-ktx/build.gradle @@ -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 diff --git a/android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/AdapterOperations.kt b/android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/AdapterOperations.kt index 691dfbee4..3671f6365 100644 --- a/android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/AdapterOperations.kt +++ b/android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/AdapterOperations.kt @@ -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 { @@ -47,4 +48,21 @@ interface AdapterOperations { suspend fun signTransactions(transactions: Array): MobileWalletAdapterClient.SignPayloadsResult suspend fun signAndSendTransactions(transactions: Array, params: TransactionParams = DefaultTransactionParams): MobileWalletAdapterClient.SignAndSendTransactionsResult + suspend fun AdapterOperations.signTransactions(vararg transactions: Transaction): List = + 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) + } + ) } \ No newline at end of file diff --git a/android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/MobileWalletAdapter.kt b/android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/MobileWalletAdapter.kt index 90c72def0..d97e07949 100644 --- a/android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/MobileWalletAdapter.kt +++ b/android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/MobileWalletAdapter.kt @@ -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) } } diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index cc0e9cb97..f0eed0adf 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -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" } @@ -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" }