Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clientlib-ktx web3core support #854

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading