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

Kotlin Ethereum Wallet Plugin #26

Merged
merged 18 commits into from
Aug 14, 2023
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
35 changes: 35 additions & 0 deletions .github/workflows/kt-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ethereum-wallet-kt-cd

on:
pull_request:
types: [closed]
branches:
- main
paths:
- "implementations/kt/**"

jobs:
cd:
name: ethereum-wallet-kt-cd
if: |
github.event.pull_request.merged &&
endsWith(github.event.pull_request.title, '/workflows/cd')
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Build
run: ./gradlew assemble
working-directory: ./implementations/kt

- name: Publish
run: ./gradlew publish
env:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
working-directory: ./implementations/kt
43 changes: 43 additions & 0 deletions .github/workflows/kt-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ethereum-wallet-kt-ci

on:
push:
branches:
- main
pull_request:
paths:
- "implementations/kt/**"

jobs:
ci:
name: ethereum-wallet-kt-ci
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Install dependencies
run: yarn install --nonInteractive --frozen-lockfile --prefer-offline
working-directory: ./implementations/kt

- name: Start Ganache
run: yarn polywrap infra up --modules=eth-ens-ipfs
working-directory: ./implementations/kt

- name: Build and test
run: ./gradlew build
working-directory: ./implementations/kt

- name: Stop Ganache
run: yarn polywrap infra down --modules=eth-ens-ipfs
working-directory: ./implementations/kt
4 changes: 4 additions & 0 deletions ethereum-wallet.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"name": "javascript-plugin",
"path": "implementations/js"
},
{
"name": "kotlin-plugin",
"path": "implementations/kt"
},
],
"settings": {
"files.exclude": {
Expand Down
57 changes: 57 additions & 0 deletions implementations/kt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# include wrap
!wrap

# Project exclude paths
/.gradle/
/build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
/buildSrc/.gradle/
/buildSrc/build/
/convention-plugins/.gradle/
/convention-plugins/build/

# env
/local.properties

# generated
/clones/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store

1 change: 1 addition & 0 deletions implementations/kt/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.15
98 changes: 98 additions & 0 deletions implementations/kt/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
plugins {
id("com.android.library") version "8.2"
kotlin("multiplatform") version "1.9.0"
kotlin("plugin.serialization") version "1.9.0"
id("org.jlleitschuh.gradle.ktlint") version "11.5.0"
id("org.jetbrains.dokka") version "1.8.20"
id("convention.publication")
}

group = "io.polywrap"
version = "0.10.0-SNAPSHOT"

repositories {
google()
mavenCentral()
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
maven { url = uri("https://jitpack.io") }
}

kotlin {
jvm {
jvmToolchain(17)
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
androidTarget {
publishLibraryVariants("release")
}

// val kethereumVersion = "0.85.7"
val kethereumVersion = "PR149-SNAPSHOT"

sourceSets {
val commonMain by getting {
dependencies {
implementation("io.polywrap:polywrap-client:0.10.0-SNAPSHOT")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.5.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("com.github.walleth.kethereum:extensions_transactions:${kethereumVersion}")
implementation("com.github.walleth.kethereum:rpc:${kethereumVersion}")
implementation("com.github.walleth.kethereum:model:${kethereumVersion}")
implementation("com.github.walleth.kethereum:crypto:${kethereumVersion}")
implementation("com.github.walleth.kethereum:crypto_impl_bouncycastle:${kethereumVersion}")
implementation("com.github.walleth.kethereum:erc712:${kethereumVersion}")
implementation("com.github.walleth.kethereum:rlp:${kethereumVersion}")
implementation("com.github.walleth.kethereum:eip1559_signer:${kethereumVersion}")
implementation("com.squareup.okhttp3:okhttp:4.11.0")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
}
}
}
}

android {
namespace = "io.polywrap.ethereumWalletPlugin"
compileSdk = 32
defaultConfig.minSdk = 24
compileOptions {
targetCompatibility = JavaVersion.VERSION_17
}
testOptions {
unitTests.all {
it.enabled = false
}
}
}

// javadoc generation for Maven repository publication
tasks.register<Jar>("dokkaJavadocJar") {
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}

// print stdout during tests
tasks.withType<Test> {
this.testLogging {
this.showStandardStreams = true
}
}

// lint configuration
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
disabledRules.set(setOf("no-wildcard-imports"))
filter {
exclude("**/build/**")
exclude("**/generated/**")
exclude("**/resources/**")
exclude("**/wrap/**")
exclude("**/build.gradle.kts")
}
}
7 changes: 7 additions & 0 deletions implementations/kt/convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
`kotlin-dsl` // Is needed to turn our build logic written in Kotlin into the Gradle Plugin
}

repositories {
gradlePluginPortal() // To use 'maven-publish' and 'signing' plugins in our own plugin
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.`maven-publish`
import org.gradle.kotlin.dsl.signing
import java.util.*

plugins {
`maven-publish`
signing
}

// Stub secrets to let the project sync and build without the publication values set up
ext["signing.keyId"] = null
ext["signing.password"] = null
ext["signing.key"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null

// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
secretPropsFile.reader().use {
Properties().apply {
load(it)
}
}.onEach { (name, value) ->
ext[name.toString()] = value
}
} else {
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.key"] = System.getenv("SIGNING_KEY")
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}

fun getExtraString(name: String) = ext[name]?.toString()

afterEvaluate {
val javadocJar: TaskProvider<Jar> = rootProject.tasks.named("dokkaJavadocJar", Jar::class.java)

publishing {
// Configure maven central repository
repositories {
maven {
name = "sonatype"
if (project.version.toString().endsWith("SNAPSHOT")) {
setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots/")
} else {
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
}
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}

// Configure all publications
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(javadocJar.get())
// Provide artifacts information requited by Maven Central
pom {
name.set("ethereum-wallet-plugin")
description.set("Polywrap Ethereum Wallet Plugin for JVM and Android")
url.set("https://github.com/polywrap/ethereum-wallet/implementations/kt")

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("krisbitney")
name.set("Kristofer Bitney")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:github.com/polywrap/ethereum-wallet.git")
developerConnection.set("scm:git:ssh://github.com/polywrap/ethereum-wallet.git")
url.set("https://github.com/polywrap/ethereum-wallet.git")
}
}
}
}
}

// Signing artifacts. Signing.* extra properties values will be used
signing {
useInMemoryPgpKeys(
getExtraString("signing.keyId"),
getExtraString("signing.key"),
getExtraString("signing.password"),
)
sign(publishing.publications)
}

tasks.withType<PublishToMavenRepository> {
dependsOn(
"signJvmPublication",
"signAndroidReleasePublication",
"signKotlinMultiplatformPublication"
)
}

tasks.withType<PublishToMavenLocal> {
dependsOn(
"signJvmPublication",
"signAndroidReleasePublication",
"signKotlinMultiplatformPublication"
)
}
4 changes: 4 additions & 0 deletions implementations/kt/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kotlin.code.style=official
android.useAndroidX=true
kotlin.mpp.androidSourceSetLayoutVersion=2
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Binary file not shown.
6 changes: 6 additions & 0 deletions implementations/kt/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Thu Jul 27 10:19:10 PET 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-rc-2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading