Skip to content

Commit

Permalink
Merge pull request #4 from ProtonProtocol/develop
Browse files Browse the repository at this point in the history
Covert to Gradle Kotlin
  • Loading branch information
Joey Harward authored Jul 27, 2020
2 parents 09a5fc3 + cf1bd36 commit d04436b
Show file tree
Hide file tree
Showing 16 changed files with 588 additions and 378 deletions.
69 changes: 43 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Proton Kotlin Wallet SDK (Beta) 🚧

Kotlin library for handling Proton Chain operations. The main
purpose for this library is for account and key management, but also
handles signing and pushing transactions.
![Bintray](https://img.shields.io/bintray/v/protonprotocol/ProtonKotlin/com.metallicus.protonsdk)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/ProtonProtocol/ProtonKotlin?include_prereleases)
![GitHub](https://img.shields.io/github/license/ProtonProtocol/ProtonKotlin)

**Important:** *This library is currently under heavy development. Please be aware that all functionality is subject to change at anytime. Documentation and examples are also being worked on and will be added over time as well.*
Kotlin library for handling Proton Chain operations. The main purpose
for this library is for account and key management, but also handles
signing and pushing transactions.

**Important:** *This library is currently under heavy development.
Please be aware that all functionality is subject to change at anytime.
Documentation and examples are also being worked on and will be added
over time as well.*

# Installation

Expand All @@ -24,7 +31,7 @@ Then add the following dependency to your module's build.gradle
```gradle
dependencies {
...
implementation "com.metallicus:protonsdk:0.5.1"
implementation "com.metallicus:protonsdk:0.5.2"
}
```

Expand All @@ -38,16 +45,19 @@ encapsulates all the needed functions.
First you will need to initialize with either a MainNet or TestNet url.

MainNet:

```
https://api.protonchain.com
```

TestNet:

```
https://api-dev.protonchain.com
```

This is recommended during app startup.

```kotlin
override fun onCreate() {
super.onCreate()
Expand All @@ -69,10 +79,14 @@ Once an active account has been set you can:
- Update account name and avatar
- Transfer tokens from active account to another account

Most of these functions require network connectivity and will return a LiveData resource.
This LiveData can be observed and will emit the current state of the action.
Most of these functions require network connectivity and will return a
LiveData resource.
This LiveData can be observed and will emit the current state of the
action.

Here is an example of fetching Chain Provider info with the appropriate
observable states:

Here is an example of fetching Chain Provider info with the appropriate observable states:
```kotlin
Proton.getInstance(context).getChainProvider().observe(this, Observer { chainProviderResource ->
when (chainProviderResource?.status) {
Expand All @@ -88,7 +102,9 @@ Proton.getInstance(context).getChainProvider().observe(this, Observer { chainPro
}
})
```
You can follow this format for most of the functions called within `Proton`.

You can follow this format for most of the functions called within
`Proton`.

# Credits

Expand All @@ -101,21 +117,22 @@ Key Storage inspired by

Copyright (c) 2020 Proton Chain LLC, Delaware

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

58 changes: 0 additions & 58 deletions build.gradle

This file was deleted.

48 changes: 48 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath(BuildPlugins.androidGradlePlugin)
}
}

plugins {
kotlin("jvm") version kotlinVersion
id(BuildPlugins.dokka) version BuildPlugins.Versions.dokka
id(BuildPlugins.orchid) version orchidVersion
`maven-publish`
id(BuildPlugins.bintray) version BuildPlugins.Versions.bintray
}

allprojects {
repositories {
google()
jcenter()
}
}

dependencies {
orchidRuntimeOnly(Libraries.orchidDocs)
orchidRuntimeOnly(Libraries.orchidKotlindoc)
orchidRuntimeOnly(Libraries.orchidPluginDocs)
orchidRuntimeOnly(Libraries.orchidGithub)
}

orchid {
theme = "Editorial"
version = ProtonSdk.versionName
srcDir = "protonsdk/src/orchid/resources"
destDir = "protonsdk/build/docs/orchid"
baseUrl = "https://protonprotocol.github.io/ProtonKotlin"

githubToken = gradleLocalProperties(rootDir).getProperty("github.token")
}

tasks.register("cleanAll").configure {
delete("build", "buildSrc/build", "protonsdk/build")
}
11 changes: 11 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
`kotlin-dsl`
}

repositories {
jcenter()
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
}
1 change: 1 addition & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "DSL"
142 changes: 142 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Copyright (c) 2020 Proton Chain LLC, Delaware
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const val kotlinVersion = "1.3.72"
const val orchidVersion = "0.21.1"

object ProtonSdk {
const val versionCode = 14
const val versionName = "0.5.2"
}

object BuildPlugins {
object Versions {
const val gradle = "4.0.1"
const val dokka = "0.10.1"
const val bintray = "1.8.5"
}

const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.gradle}"
const val androidLibrary = "com.android.library"
const val kotlinAndroid = "android"
const val kotlinAndroidExtensions = "android.extensions"
const val kotlinKapt = "kapt"
const val mavenPublish = "maven-publish"
const val dokka = "org.jetbrains.dokka"
const val orchid = "com.eden.orchidPlugin"
const val bintray = "com.jfrog.bintray"
}

object Android {
const val minSdk = 21
const val compileSdk = 30
const val targetSdk = compileSdk
const val buildTools = "30.0.1"

object Progaurd {
const val consumeFile = "consumer-rules.pro"
const val optimizeFile = "proguard-android-optimize.txt"
const val rulesFile = "proguard-rules.pro"
}
}

object Libraries {
private object Versions {
const val ktx = "1.5.0-alpha01"
const val lifecycleLiveData = "2.3.0-alpha05"
const val room = "2.2.5"
const val workManager = "2.3.4"
const val okhttp3 = "4.8.0"
const val retrofit = "2.9.0"
const val dagger = "2.28.1"
const val daggerAssistedInject = "0.5.2"
const val coroutines = "1.3.4"
const val timber = "4.7.1"
const val gson = "2.8.6"
const val guava = "29.0-jre"
}

const val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
const val ktxCore = "androidx.core:core-ktx:${Versions.ktx}"
const val lifeCycleLiveData = "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.lifecycleLiveData}"
const val roomKtx = "androidx.room:room-ktx:${Versions.room}"
const val roomCompiler = "androidx.room:room-compiler:${Versions.room}"
const val workManagerKtx = "androidx.work:work-runtime-ktx:${Versions.workManager}"
const val okhttp3 = "com.squareup.okhttp3:okhttp:${Versions.okhttp3}"
const val okhttp3Logging = "com.squareup.okhttp3:logging-interceptor:${Versions.okhttp3}"
const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit}"
const val retrofitGsonConverter = "com.squareup.retrofit2:converter-gson:${Versions.retrofit}"
const val dagger = "com.google.dagger:dagger:${Versions.dagger}"
const val daggerAndroidSupport = "com.google.dagger:dagger-android-support:${Versions.dagger}"
const val daggerAndroidProcessor = "com.google.dagger:dagger-android-processor:${Versions.dagger}"
const val daggerAndroidCompiler = "com.google.dagger:dagger-compiler:${Versions.dagger}"
const val daggerAssistedInjectAnnotations = "com.squareup.inject:assisted-inject-annotations-dagger2:${Versions.daggerAssistedInject}"
const val daggerAssistedInjectProcessor = "com.squareup.inject:assisted-inject-processor-dagger2:${Versions.daggerAssistedInject}"
const val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}"
const val coroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}"
const val timber = "com.jakewharton.timber:timber:${Versions.timber}"
const val gson = "com.google.code.gson:gson:${Versions.gson}"
const val guava = "com.google.guava:guava:${Versions.guava}"
const val orchidDocs = "io.github.javaeden.orchid:OrchidDocs:$orchidVersion"
const val orchidKotlindoc = "io.github.javaeden.orchid:OrchidKotlindoc:$orchidVersion"
const val orchidPluginDocs = "io.github.javaeden.orchid:OrchidPluginDocs:$orchidVersion"
const val orchidGithub = "io.github.javaeden.orchid:OrchidGithub:$orchidVersion"

// Greymass ESR
//implementation "com.greymass:esrsdk:1.0.1"
}

object TestLibraries {
private object Versions {
const val junit = "4.13"
const val testExt = "1.1.1"
const val espresso = "3.2.0"
}
const val junit = "junit:junit:${Versions.junit}"
const val testExt = "androidx.test.ext:junit:${Versions.testExt}"
const val espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}"
const val testRunner = "androidx.test.runner.AndroidJUnitRunner"
}

object Publishing {
object Publications {
const val debug = "ProtonSDKDebug"
const val release = "ProtonSDKRelease"
}
const val bintrayRepo = "ProtonKotlin"
const val bintrayName = "com.metallicus.protonsdk"
const val userOrganization = "protonprotocol"

const val libraryName = "protonsdk"
const val libraryVersion = ProtonSdk.versionName

const val publishedGroupId = "com.metallicus"

const val libraryDescription = "Kotlin library for handling Proton Chain operations"
const val siteUrl = "https://github.com/ProtonProtocol/ProtonKotlin"
const val gitUrl = "https://github.com/ProtonProtocol/ProtonKotlin.git"
const val developerId = "joey-harward"
const val developerName = "Metallicus Inc."
const val developerEmail = "[email protected]"
const val licenseName = "MIT License"
const val licenseUrl = "https://opensource.org/licenses/MIT"
const val allLicenses = "MIT"
}
Loading

0 comments on commit d04436b

Please sign in to comment.