Skip to content

Commit

Permalink
Changes for v1.0-beta-08 (#24)
Browse files Browse the repository at this point in the history
* Update publish workflow.

* Update publish workflow(again).

* Update README and disable build on push.

* Add shields badge for maven central.

* Clarify jitpack section in README.

* Make slight adjustments to the customClient parameter.

* NIP-05 support, using the NostrUtils.getProfileInfoFromAddress() API, and with custom client support. Add url/domain verification.

* Make adjustments and add convenience functions for relay pool management.

* Add new API: clearRelayPool().

* Use hex conversion for Uuid in singleRequestFilter, until Kotlin UUID is ready(?).

* Introduce new API: getMetadataFor(profile, relays). Fix requestFromRelay().

* Move to new name: Rhodium

* Prepare new version: v1.0-beta-08. Adjust README to new version and name.
  • Loading branch information
KotlinGeekDev authored Feb 14, 2025
1 parent 2ad6068 commit 768b16e
Show file tree
Hide file tree
Showing 42 changed files with 4,752 additions and 15 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@

name: Publish
on:
# push:
# branches: ["develop"]
release:
types: [released, prereleased]
types: [released]

#concurrency:
# cancel-in-progress: true

jobs:
publish:
name: Release build and publish
runs-on: macOS-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK 21

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Publish to MavenCentral
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
run: ./gradlew publishToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Kostr
# Rhodium

[![Kotlin](https://img.shields.io/badge/Kotlin-2.0.20-blue?style=flat&logo=kotlin)](https://kotlinlang.org)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.kotlingeekdev/ballast?color=blue)](https://search.maven.org/search?q=g:io.github.kotlingeekdev)

![badge-jvm](http://img.shields.io/badge/platform-jvm-DB413D.svg?style=flat)
![badge-android](http://img.shields.io/badge/platform-android-6EDB8D.svg?style=flat)
Expand All @@ -18,6 +19,17 @@ Note: This is still in development and very incomplete.
* The Nostr protocol specs can be found [here](https://github.com/nostr-protocol/nips).

## How to include the libary
You can include the library from either Maven Central or Jitpack.

### Maven
You can include the library in the common source set like this:
```kotlin
dependencies {
implementation("io.github.kotlingeekdev:rhodium:1.0-beta-08")
}
```

### Jitpack
Inside your root-level `build.gradle(.kts)` file, you should add `jitpack`:
``` kotlin
// build.gradle.kts
Expand Down Expand Up @@ -61,7 +73,7 @@ then, in your module's `build.gradle(.kts)`, you need to add:
// build.gradle.kts
dependencies {
//...
implementation("com.github.KotlinGeekDev.kostr:kostr-core:v1.0-beta-06")
implementation("com.github.KotlinGeekDev.Rhodium:rhodium:1.0-beta-08")

}

Expand All @@ -71,15 +83,15 @@ If you're including it in an Android app, you can just add:
// app/build.gradle.kts
dependencies {
//...
implementation("com.github.KotlinGeekDev.kostr:kostr-core-android:v1.0-beta-06")
implementation("com.github.KotlinGeekDev.Rhodium:rhodium-android:1.0-beta-08")

}
```

## Usage
When publishing an event, or making a subscription/close request to a relay,
[`ClientMessage`](kostr-core/src/commonMain/kotlin/ktnostr/nostr/client/ClientMessage.kt) is used to encode the request/event,
and anything sent by a relay is encoded as a [`RelayMessage`](kostr-core/src/commonMain/kotlin/ktnostr/nostr/relay/RelayMessage.kt).</p>
[`ClientMessage`](rhodium-core/src/commonMain/kotlin/rhodium/nostr/client/ClientMessage.kt) is used to encode the request/event,
and anything sent by a relay is encoded as a [`RelayMessage`](rhodium-core/src/commonMain/kotlin/rhodium/nostr/relay/RelayMessage.kt).</p>
Relays can be configured using a `RelayPool`,
and actual communication with relays is done with the `NostrService`.</p>
You can setup the NostrService with/without a custom relay pool as follows:
Expand Down
14 changes: 9 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ allprojects {
val isJitpack = System.getenv("JITPACK") == "true"

group = "io.github.kotlingeekdev"
version = "1.0-beta-07"
version = "1.0-beta-08"


// val javadocJar = tasks.register<Jar>("javadocJar") {
// archiveClassifier.set("javadoc")
Expand All @@ -43,14 +44,16 @@ allprojects {
signAllPublications()
}

coordinates(group.toString(), "ballast", version.toString())

coordinates(group.toString(), "rhodium", version.toString())

// configure(KotlinMultiplatform(
// javadocJar = JavadocJar.Javadoc(),
// sourcesJar = true
// ))

pom {
name = "Ballast"
name = "Rhodium"
description = " A Kotlin Multiplatform library for Nostr"
url = "https://github.com/KotlinGeekDev/Ballast"

Expand All @@ -71,8 +74,9 @@ allprojects {
}

scm {
connection = "scm:git:git://github.com/KotlinGeekDev/Ballast.git"
url = "https://github.com/KotlinGeekDev/Ballast"
connection = "scm:git:git://github.com/KotlinGeekDev/Rhodium.git"
url = "https://github.com/KotlinGeekDev/Rhodium"

}
}
}
Expand Down
1 change: 1 addition & 0 deletions rhodium-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
244 changes: 244 additions & 0 deletions rhodium-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@

import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile

val kotlinVersion = "2.0.20"
val ktorVersion = "3.0.1"
val kotlinCryptoVersion = "0.4.0"

val junitJupiterVersion = "5.10.1"

plugins {
//`java-library`
kotlin("multiplatform")
id("com.android.library")

kotlin("plugin.serialization")
// `maven-publish`
}


kotlin {
//explicitApi()
jvmToolchain(17)

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
apiVersion.set(KotlinVersion.KOTLIN_1_8)
languageVersion.set(KotlinVersion.KOTLIN_1_8)
}

jvm("baseJvm") {

@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)


testRuns["test"].executionTask.configure {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
}


androidTarget {

publishAllLibraryVariants()
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}


linuxX64("linux") {
// compilations.all {
// cinterops {
// val libs by creating {
// defFile("src/linuxMain/cinterop/libs.def")
// }
// }
// }
//
// binaries {
// sharedLib {
//
// }
// }
}

//Apple targets
macosX64()
macosArm64()
iosX64()
iosArm64()
iosSimulatorArm64()


applyDefaultHierarchyTemplate()

sourceSets {
commonMain.dependencies {
//Ktor
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-websockets:$ktorVersion")
implementation("io.ktor:ktor-client-logging:$ktorVersion")

//Kotlin base
implementation("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")

//Crypto(Secp256k1-utils, SecureRandom, Hashing, etc.)
implementation("fr.acinq.secp256k1:secp256k1-kmp:0.15.0")
implementation("dev.whyoleg.cryptography:cryptography-core:$kotlinCryptoVersion")
implementation("dev.whyoleg.cryptography:cryptography-random:$kotlinCryptoVersion")

//Serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1")
//Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
//Atomics
implementation("org.jetbrains.kotlinx:atomicfu:0.25.0")
//Date-time
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1")
//UUID
implementation("com.benasher44:uuid:0.8.4")
}

commonTest.dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}

val commonJvmMain = create("commonJvmMain") {
dependsOn(commonMain.get())
}
commonJvmMain.dependencies {
implementation("dev.whyoleg.cryptography:cryptography-provider-jdk:$kotlinCryptoVersion")

implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
implementation("ch.qos.logback:logback-classic:1.4.14")
}

val commonJvmTest = create("commonJvmTest") {
dependsOn(commonTest.get())
}
commonJvmTest.dependencies {
implementation(kotlin("test-junit5"))

implementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion")
implementation("org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion")
implementation("org.assertj:assertj-core:3.23.1")
runtimeOnly("fr.acinq.secp256k1:secp256k1-kmp-jni-jvm-linux:0.15.0")
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
runtimeOnly("org.junit.vintage:junit-vintage-engine:$junitJupiterVersion")
}

val baseJvmMain by getting {
dependsOn(commonJvmMain)

dependencies {
//implementation("fr.acinq.secp256k1:secp256k1-kmp-jvm:0.6.4")
implementation("fr.acinq.secp256k1:secp256k1-kmp-jni-jvm:0.15.0")
}
}



val androidMain by getting {
dependsOn(commonJvmMain)

dependencies {
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("fr.acinq.secp256k1:secp256k1-kmp-jni-android:0.15.0")
}
}

androidInstrumentedTest.configure {
//dependsOn(commonJvmTest)
}

val androidUnitTest by getting {
dependsOn(commonJvmTest)
}



val baseJvmTest by getting {
dependsOn(commonJvmTest)
}

linuxMain.configure {
dependencies {
implementation("io.ktor:ktor-client-cio:$ktorVersion")
//implementation("io.ktor:ktor-client-curl:$ktorVersion")
implementation("dev.whyoleg.cryptography:cryptography-provider-openssl3-prebuilt:$kotlinCryptoVersion")
}
}

linuxTest.configure {
dependencies {

}

}

appleMain.configure {
dependencies {
implementation("io.ktor:ktor-client-darwin:$ktorVersion")
implementation("dev.whyoleg.cryptography:cryptography-provider-apple:$kotlinCryptoVersion")
}
}
macosMain.get().dependsOn(appleMain.get())
iosMain.get().dependsOn(appleMain.get())

}
}

android {
namespace = "io.github.kotlingeekdev.rhodium.android"
compileSdk = 34
defaultConfig {
minSdk = 21
targetSdk = 34
compileSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
aarMetadata {

}
isMinifyEnabled = false
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.3")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
}

}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>() {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}

tasks.withType<KotlinNativeCompile>().configureEach {
compilerOptions.freeCompilerArgs.add("-opt-in=kotlinx.cinterop.ExperimentalForeignApi")
}
Loading

0 comments on commit 768b16e

Please sign in to comment.