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

Solana RPC Client #14

Merged
merged 8 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
39 changes: 39 additions & 0 deletions .github/actions/install-solana/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Install Solana

inputs:
solana_version:
description: Version of Solana to install
required: true

runs:
using: "composite"
steps:
- name: Cache Solana Install
if: ${{ !env.ACT }}
id: cache-solana-install
uses: actions/cache@v2
with:
path: "$HOME/.local/share/solana/install/releases/${{ inputs.solana_version }}"
key: ${{ runner.os }}-Solana-v${{ inputs.solana_version }}

- name: Install Solana
if: ${{ !env.ACT }} && steps.cache-solana-install.cache-hit != 'true'
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${{ inputs.solana_version }}/install)"
shell: bash

- name: Set Active Solana Version
run: |
rm -f "$HOME/.local/share/solana/install/active_release"
ln -s "$HOME/.local/share/solana/install/releases/${{ inputs.solana_version }}/solana-release" "$HOME/.local/share/solana/install/active_release"
shell: bash

- name: Add Solana bin to Path
run: |
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
shell: bash

- name: Verify Solana install
run: |
solana --version
shell: bash
13 changes: 12 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
jobs:
build:
runs-on: macos-latest
strategy:
matrix:
solana: ["1.18.14"]

steps:
- name: Checkout
Expand All @@ -26,11 +29,19 @@ jobs:
distribution: 'temurin'
cache: gradle

- name: Install Solana
uses: ./.github/actions/install-solana
with:
solana_version: ${{ matrix.solana }}

- name: Start local validator
run: solana-test-validator > /dev/null 2>&1 &

# Build
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Test
run: ./gradlew build
run: ./gradlew build -PlocalValidator=true

- name: Save Test Reports
if: failure()
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/solana-mobile/rpc-core.git
POM_DEVELOPER_NAME=Solana Mobile Engineering
POM_DEVELOPER_URL=https://solanamobile.com
[email protected]

# RPC URLs used for testing
testing.rpc.defaultUrl=https://api.devnet.solana.com
testing.rpc.localUrl=http://127.0.0.1:8899
localValidator=false
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref =
ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" }
ktor-client-mock = { group = "io.ktor", name = "ktor-client-mock", version.ref = "ktor" }
multimult = { group = "io.github.funkatronics", name = "multimult", version = "0.2.1" }
web3-solana = { group = "com.solanamobile", name = "web3-solana", version = "0.3.0-beta3" }

[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
Expand Down
4 changes: 2 additions & 2 deletions ktordriver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ kotlin {
dependencies {
implementation(project(mapOf("path" to ":rpccore")))
implementation(libs.kotlinx.coroutines.core)
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.cio)
api(libs.ktor.client.core)
api(libs.ktor.client.cio)
}
}
val commonTest by getting {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ rootProject.name = "Rpc Core"
include(":rpccore")
include(":okiodriver")
include(":ktordriver")
include(":solanaclient")

76 changes: 76 additions & 0 deletions solanaclient/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.publish)
}

val artifactIdPrefix: String by project
val moduleArtifactId = "$artifactIdPrefix-solana"

kotlin {
jvm {
jvmToolchain(11)
withJava()
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
macosX64(),
macosArm64()
).forEach {
it.binaries.framework {
baseName = moduleArtifactId
}
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(project(mapOf("path" to ":rpccore")))
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.web3.solana)
implementation(libs.multimult)
}
}
val commonTest by getting {
kotlin.srcDir(File("${buildDir}/generated/src/commonTest/kotlin"))
dependencies {
implementation(project(mapOf("path" to ":ktordriver")))
implementation(libs.kotlin.test)
implementation(libs.kotlinx.coroutines.test)
implementation(libs.kotlinx.serialization.json)
implementation(libs.crypto)
}
}
}
}

mavenPublishing {
coordinates(group as String, moduleArtifactId, version as String)
}

afterEvaluate {
val defaultRpcUrl = properties["testing.rpc.defaultUrl"]
var rpcUrl = properties["rpcUrl"] ?: defaultRpcUrl

val useLocalValidator = project.properties["localValidator"] == "true"
val localRpcUrl = project.properties["testing.rpc.localUrl"]
if (useLocalValidator && localRpcUrl != null) rpcUrl = localRpcUrl

val dir = "${buildDir}/generated/src/commonTest/kotlin/com/solana/config"
mkdir(dir)
File(dir, "TestConfig.kt").writeText(
"""
package com.solana.config

internal object TestConfig {
const val RPC_URL = "$rpcUrl"
}
""".trimIndent()
)
}
Loading
Loading