-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose RPC objects and add arrow extensions
- Loading branch information
Showing
25 changed files
with
314 additions
and
181 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version=0.1.15 | ||
version=0.2.0 | ||
# Kotlin | ||
#kotlin.code.style=official | ||
kotlin.js.compiler=ir | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
plugins { | ||
alias(libs.plugins.kotlinMultiplatform) | ||
alias(libs.plugins.kotlinSerialization) | ||
alias(libs.plugins.mavenPublish) | ||
alias(libs.plugins.dokka) | ||
signing | ||
} | ||
|
||
group = "net.avianlabs.solana" | ||
version = properties["version"] as String | ||
|
||
|
||
kotlin { | ||
applyDefaultHierarchyTemplate() | ||
explicitApi() | ||
|
||
jvm { | ||
// set the target JVM version | ||
compilations.all { | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
} | ||
|
||
mingwX64() | ||
linuxX64() | ||
|
||
sourceSets { | ||
val jvmMain by getting | ||
|
||
val jvmTest by getting | ||
|
||
val commonMain by getting { | ||
dependencies { | ||
api(project(":solana-kotlin")) | ||
implementation(libs.coroutinesCore) | ||
implementation(libs.kermit) | ||
implementation(libs.arrow.core) | ||
} | ||
} | ||
val commonTest by getting { | ||
dependencies { | ||
implementation(libs.kotlinTest) | ||
implementation(libs.coroutinesTest) | ||
} | ||
} | ||
|
||
val nativeMain by getting | ||
|
||
val linuxMain by getting | ||
|
||
val mingwMain by getting | ||
} | ||
} | ||
|
||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
|
||
signing { | ||
useGpgCmd() | ||
} | ||
|
||
publishing { | ||
repositories { | ||
mavenLocal() | ||
repositories { | ||
maven { | ||
name = "GitHubPackages" | ||
url = uri("https://maven.pkg.github.com/avianlabs/solana-kotlin") | ||
credentials { | ||
username = System.getenv("GITHUB_ACTOR") | ||
password = System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
} | ||
} | ||
publications { | ||
withType<MavenPublication> { | ||
pom { | ||
name = "Solana Kotlin Arrow Extensions" | ||
description = "Arrow extensions for Solana Kotlin" | ||
licenses { | ||
license { | ||
name = "MIT" | ||
url = "https://opensource.org/licenses/MIT" | ||
} | ||
} | ||
url = "https://github.com/avianlabs/solana-kotlin" | ||
issueManagement { | ||
system = "GitHub" | ||
url = "https://github.com/avianlabs/solana-kotlin" | ||
} | ||
scm { | ||
connection = "https://github.com/avianlabs/solana-kotlin.git" | ||
url = "https://github.com/avianlabs/solana-kotlin" | ||
} | ||
developers { | ||
developer { | ||
name = "Avian Labs Engineers" | ||
email = "[email protected]" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
mavenPublishing { | ||
if (rootProject.findProperty("signPublications") != "false") { | ||
signAllPublications() | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
solana-kotlin-arrow-extensions/src/commonMain/kotlin/net/avianlabs/solana/arrow/Either.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.avianlabs.solana.arrow | ||
|
||
import arrow.core.Either | ||
import arrow.core.left | ||
import arrow.core.right | ||
import net.avianlabs.solana.arrow.SolanaKotlinError.RpcError.* | ||
import net.avianlabs.solana.client.Response | ||
import net.avianlabs.solana.client.RpcError | ||
|
||
public fun <T> Response<T>.toEither(): Either<SolanaKotlinError, T> = | ||
if (error != null) { | ||
error!!.toRpcError().left() | ||
} else if (result != null) { | ||
result!!.right() | ||
} else { | ||
SolanaKotlinError.MalformedResponse("both error and result are null").left() | ||
} | ||
|
||
private fun RpcError.toRpcError(): SolanaKotlinError = when (code) { | ||
-32700 -> ParseError(message) | ||
-32600 -> InvalidRequest(message) | ||
-32601 -> MethodNotFound(message) | ||
-32602 -> InvalidParams(message) | ||
-32603 -> InternalError(message) | ||
in -32000 downTo -32099 -> ServerError(message) | ||
else -> SolanaKotlinError.UnknownError(message) | ||
} |
15 changes: 15 additions & 0 deletions
15
...in-arrow-extensions/src/commonMain/kotlin/net/avianlabs/solana/arrow/SolanaKotlinError.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package net.avianlabs.solana.arrow | ||
|
||
public sealed interface SolanaKotlinError { | ||
public sealed interface RpcError : SolanaKotlinError { | ||
public data class ParseError(val message: String) : RpcError | ||
public data class InvalidRequest(val message: String) : RpcError | ||
public data class MethodNotFound(val message: String) : RpcError | ||
public data class InvalidParams(val message: String) : RpcError | ||
public data class InternalError(val message: String) : RpcError | ||
public data class ServerError(val message: String) : RpcError | ||
} | ||
|
||
public data class MalformedResponse(val message: String) : SolanaKotlinError | ||
public data class UnknownError(val message: String) : SolanaKotlinError | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
solana-kotlin/src/commonMain/kotlin/net/avianlabs/solana/client/ExecuteException.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.