diff --git a/README.md b/README.md index 0cbaacc4..fb62c7a9 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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" } ``` @@ -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() @@ -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) { @@ -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 @@ -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. diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 911c570e..00000000 --- a/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -buildscript { - ext.kotlin_version = '1.3.72' - ext.dokka_version = '0.10.1' - - repositories { - jcenter() - google() - } - - dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - } -} - -allprojects { - repositories { - jcenter() - google() - } - - // Dokka - apply plugin: 'org.jetbrains.dokka' - dokka { - outputFormat = 'html' - outputDirectory = "$buildDir/dokka" - - configuration { - perPackageOption { - prefix = "com.metallicus.protonsdk.api" - suppress = true - } - perPackageOption { - prefix = "com.metallicus.protonsdk.db" - suppress = true - } - perPackageOption { - prefix = "com.metallicus.protonsdk.di" - suppress = true - } - perPackageOption { - prefix = "com.metallicus.protonsdk.repository" - suppress = true - } - perPackageOption { - prefix = "com.metallicus.protonsdk.worker" - suppress = true - } - } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..2cd99e69 --- /dev/null +++ b/build.gradle.kts @@ -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") +} \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..5aa40ec4 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + `kotlin-dsl` +} + +repositories { + jcenter() +} + +kotlinDslPluginOptions { + experimentalWarning.set(false) +} \ No newline at end of file diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 00000000..b943098e --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "DSL" \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt new file mode 100644 index 00000000..8bbc7053 --- /dev/null +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -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 = "joey@metalpay.co" + const val licenseName = "MIT License" + const val licenseUrl = "https://opensource.org/licenses/MIT" + const val allLicenses = "MIT" +} \ No newline at end of file diff --git a/docs/build.gradle b/docs/build.gradle deleted file mode 100644 index 59a9ec5a..00000000 --- a/docs/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -plugins { - id "com.eden.orchidPlugin" version "0.21.0" -} - -dependencies { - orchidRuntimeOnly "io.github.javaeden.orchid:OrchidDocs:0.21.0" - orchidRuntimeOnly "io.github.javaeden.orchid:OrchidKotlindoc:0.21.0" - orchidRuntimeOnly "io.github.javaeden.orchid:OrchidPluginDocs:0.21.0" -} - -repositories { - jcenter() - maven { url = "https://kotlin.bintray.com/kotlinx/" } -} - -orchid { - theme = "Editorial" - baseUrl = "https://username.github.io/project" - version = "1.0.0" -} \ No newline at end of file diff --git a/docs/src/orchid/resources/config.yml b/docs/src/orchid/resources/config.yml deleted file mode 100644 index c8b98d70..00000000 --- a/docs/src/orchid/resources/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -site: - about: - siteName: Proton Kotlin SDK - siteDescription: Kotlin library for handling Proton Chain operations. -Editorial: - primaryColor: '#582ACB' - social: - github: 'username/project' - metaComponents: # this is the replacement for the deprecated automatic search addition - - type: 'orchidSearch' -kotlindoc: - sourceDirs: - - './../../../../protonsdk/src/main/java' \ No newline at end of file diff --git a/protonsdk/build.gradle b/protonsdk/build.gradle deleted file mode 100644 index 4d1898f0..00000000 --- a/protonsdk/build.gradle +++ /dev/null @@ -1,252 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'kotlin-kapt' -apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.bintray' -apply plugin: 'com.github.dcendents.android-maven' - -android { - compileSdkVersion 30 - buildToolsVersion "30.0.1" - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() - } - - defaultConfig { - minSdkVersion 21 - targetSdkVersion 30 - - versionCode 13 - versionName "0.5.1" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles 'consumer-rules.pro' - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - - // Unit Testing - testImplementation "junit:junit:4.13" - androidTestImplementation "androidx.test.ext:junit:1.1.1" - androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0" - - // KTX - implementation "androidx.core:core-ktx:1.5.0-alpha01" - - // Lifecycle - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha05" - - // Room - def room_version = '2.2.5' - implementation "androidx.room:room-ktx:$room_version" - kapt "androidx.room:room-compiler:$room_version" - - // WorkManager - implementation "androidx.work:work-runtime-ktx:2.3.4" - - // OkHttp - def okhttp3_version = '4.8.0' - implementation "com.squareup.okhttp3:okhttp:$okhttp3_version" - implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3_version" - - // Retrofit - def retrofit_version = '2.9.0' - implementation("com.squareup.retrofit2:retrofit:$retrofit_version") { - exclude module: 'okhttp' - } - implementation "com.squareup.retrofit2:converter-gson:$retrofit_version" - - // Dagger - def dagger_version = '2.28.1' - implementation "com.google.dagger:dagger:$dagger_version" - implementation "com.google.dagger:dagger-android-support:$dagger_version" - kapt "com.google.dagger:dagger-android-processor:$dagger_version" - kapt "com.google.dagger:dagger-compiler:$dagger_version" - - // Assisted Inject (Dagger) - def assisted_inject_version = '0.5.2' - compileOnly "com.squareup.inject:assisted-inject-annotations-dagger2:$assisted_inject_version" - kapt "com.squareup.inject:assisted-inject-processor-dagger2:$assisted_inject_version" - - // Coroutines - def coroutines_version = '1.3.4' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" - - // Timber - implementation "com.jakewharton.timber:timber:4.7.1" - - // Gson - implementation "com.google.code.gson:gson:2.8.6" - - // Guava - implementation "com.google.guava:guava:29.0-jre" - - // Greymass ESR - //implementation "com.greymass:esrsdk:1.0.1" -} - -ext { - bintrayRepo = "ProtonKotlin" - bintrayName = "com.metallicus.protonsdk" - userOrganization = "protonprotocol" - - libraryName = "protonsdk" - - publishedGroupId = "com.metallicus" - artifact = "protonsdk" - libraryVersion = android.defaultConfig.versionName - - libraryDescription = "Kotlin library for handling Proton Chain operations" - siteUrl = "https://github.com/ProtonProtocol/ProtonKotlin" - gitUrl = "https://github.com/ProtonProtocol/ProtonKotlin.git" - developerId = "joey-harward" - developerName = "Metallicus Inc." - developerEmail = "joey@metalpay.co" - licenseName = "MIT License" - licenseUrl = "https://opensource.org/licenses/MIT" - allLicenses = ["MIT"] -} - -group = publishedGroupId -version = libraryVersion - -task sourcesJar(type: Jar) { - archiveClassifier.set('sources') - from android.sourceSets.main.java.srcDirs -} - -def pomConfig = { - licenses { - license { - name licenseName - url licenseUrl - } - } - developers { - developer { - id developerId - name developerName - email developerEmail - } - } - scm { - connection gitUrl - developerConnection gitUrl - url siteUrl - } -} - -project.afterEvaluate { - publishing { - publications { - ProtonSDKDebug(MavenPublication) { - groupId = 'com.metallicus' - artifactId = "${project.getName()}-debug" - version = android.defaultConfig.versionName - - artifact bundleDebugAar - - pom.withXml { - def root = asNode() - root.appendNode('name', libraryName) - root.appendNode('description', libraryDescription) - root.appendNode('url', siteUrl) - root.children().last() + pomConfig - - def dependenciesNode = root.appendNode('dependencies') - configurations.implementation.allDependencies.each { - if (it.group != null && it.name != null && it.version != null && - it.name != 'unspecified' && it.version != 'unspecified') { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', it.group) - dependencyNode.appendNode('artifactId', it.name) - dependencyNode.appendNode('version', it.version) - } - } - } - } - - ProtonSDKRelease(MavenPublication) { - groupId = 'com.metallicus' - artifactId project.getName() - version = android.defaultConfig.versionName - - artifact bundleReleaseAar - artifact sourcesJar - - pom.withXml { - def root = asNode() - root.appendNode('name', libraryName) - root.appendNode('description', libraryDescription) - root.appendNode('url', siteUrl) - root.children().last() + pomConfig - - def dependenciesNode = root.appendNode('dependencies') - configurations.implementation.allDependencies.each { - if (it.group != null && it.name != null && it.version != null && - it.name != 'unspecified' && it.version != 'unspecified') { - def dependencyNode = dependenciesNode.appendNode('dependency') - dependencyNode.appendNode('groupId', it.group) - dependencyNode.appendNode('artifactId', it.name) - dependencyNode.appendNode('version', it.version) - } - } - } - } - } - } -} - -project.afterEvaluate { - bintray { - if (project.rootProject.file('local.properties').exists()) { - Properties properties = new Properties() - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - - user = properties.getProperty("bintray.user") - key = properties.getProperty("bintray.apikey") - - publications = ['ProtonSDKRelease'] - - pkg { - repo = bintrayRepo - name = bintrayName - userOrg = userOrganization - desc = libraryDescription - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = allLicenses - publish = true - publicDownloadNumbers = true - version { - name = libraryVersion - desc = libraryDescription - released = new Date() - -// gpg { -// sign = true //Determines whether to GPG sign the files. The default is false -// passphrase = properties.getProperty("bintray.gpg.password") -// //Optional. The passphrase for GPG signing' -// } - } - } - } - } -} diff --git a/protonsdk/build.gradle.kts b/protonsdk/build.gradle.kts new file mode 100644 index 00000000..9b288fb7 --- /dev/null +++ b/protonsdk/build.gradle.kts @@ -0,0 +1,285 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties +import org.jetbrains.dokka.gradle.DokkaTask +import com.jfrog.bintray.gradle.tasks.BintrayUploadTask + +plugins { + id(BuildPlugins.androidLibrary) + kotlin(BuildPlugins.kotlinAndroid) + kotlin(BuildPlugins.kotlinAndroidExtensions) + kotlin(BuildPlugins.kotlinKapt) + id(BuildPlugins.mavenPublish) + id(BuildPlugins.dokka) + id(BuildPlugins.bintray) +} + +android { + compileSdkVersion(Android.compileSdk) + buildToolsVersion(Android.buildTools) + + defaultConfig { + //applicationId = "com.metallicus.protonsdk" + minSdkVersion(Android.minSdk) + targetSdkVersion(Android.targetSdk) + versionCode = ProtonSdk.versionCode + versionName = ProtonSdk.versionName + testInstrumentationRunner = TestLibraries.testRunner + consumerProguardFiles(Android.Progaurd.consumeFile) + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile(Android.Progaurd.optimizeFile), Android.Progaurd.rulesFile) + } + } +} + +dependencies { + implementation(Libraries.kotlinStdLib) + + // Unit Testing + testImplementation(TestLibraries.junit) + androidTestImplementation(TestLibraries.testExt) + androidTestImplementation(TestLibraries.espresso) + + // KTX + implementation(Libraries.ktxCore) + + // Lifecycle + implementation(Libraries.lifeCycleLiveData) + + // Room + implementation(Libraries.roomKtx) + kapt(Libraries.roomCompiler) + + // WorkManager + implementation(Libraries.workManagerKtx) + + // OkHttp + implementation(Libraries.okhttp3) + implementation(Libraries.okhttp3Logging) + + // Retrofit + implementation(Libraries.retrofit) + implementation(Libraries.retrofitGsonConverter) + + // Dagger + implementation(Libraries.dagger) + implementation(Libraries.daggerAndroidSupport) + kapt(Libraries.daggerAndroidProcessor) + kapt(Libraries.daggerAndroidCompiler) + + // Assisted Inject (Dagger) + compileOnly(Libraries.daggerAssistedInjectAnnotations) + kapt(Libraries.daggerAssistedInjectProcessor) + + // Coroutines + implementation(Libraries.coroutinesCore) + implementation(Libraries.coroutinesAndroid) + + // Timber + implementation(Libraries.timber) + + // Gson + implementation(Libraries.gson) + + // Guava + implementation(Libraries.guava) + + // Greymass ESR + //implementation "com.greymass:esrsdk:1.0.1" +} + +// Dokka +tasks { + // Dokka Task + val dokka by getting(DokkaTask::class) { + outputFormat = "html" + outputDirectory = "$buildDir/dokka" + + configuration { + perPackageOption { + prefix = "com.metallicus.protonsdk.api" + suppress = true + } + perPackageOption { + prefix = "com.metallicus.protonsdk.db" + suppress = true + } + perPackageOption { + prefix = "com.metallicus.protonsdk.di" + suppress = true + } + perPackageOption { + prefix = "com.metallicus.protonsdk.repository" + suppress = true + } + perPackageOption { + prefix = "com.metallicus.protonsdk.worker" + suppress = true + } + } + } + + // publishing depends on build + withType { + dependsOn(build) + } + + // uploading to Bintray depends on publications + withType { + dependsOn(publishToMavenLocal) + } +} + +group = Publishing.publishedGroupId +version = Publishing.libraryVersion + +val sourcesJar by tasks.creating(Jar::class) { + archiveClassifier.set("sources") + from(android.sourceSets["main"].java.srcDirs) +} + +afterEvaluate { + publishing { + publications { + create(Publishing.Publications.debug) { + groupId = "com.metallicus" + artifactId = "${Publishing.libraryName}-debug" + version = Publishing.libraryVersion + + //artifact(buildOutputs["debug"].outputFile) + artifact("$buildDir/outputs/aar/protonsdk-debug.aar") + artifact(sourcesJar) + + pom { + name.set(Publishing.libraryName) + description.set(Publishing.libraryDescription) + url.set(Publishing.siteUrl) + + licenses { + license { + name.set(Publishing.licenseName) + url.set(Publishing.licenseUrl) + } + } + + developers { + developer { + id.set(Publishing.developerId) + name.set(Publishing.developerName) + email.set(Publishing.developerEmail) + } + } + + scm { + connection.set(Publishing.gitUrl) + developerConnection.set(Publishing.gitUrl) + url.set(Publishing.siteUrl) + } + + pom.withXml { + val dependenciesNode = asNode().appendNode("dependencies") + configurations.implementation.get().allDependencies.forEach { + if (it.group != null && it.version != null && + it.name != "unspecified" && it.version != "unspecified") { + dependenciesNode.appendNode("dependency").apply { + appendNode("groupId", it.group) + appendNode("artifactId", it.name) + appendNode("version", it.version) + } + } + } + } + } + } + + create(Publishing.Publications.release) { + groupId = "com.metallicus" + artifactId = Publishing.libraryName + version = Publishing.libraryVersion + + //artifact(buildOutputs["release"].outputFile) + artifact("$buildDir/outputs/aar/protonsdk-release.aar") + artifact(sourcesJar) + + pom { + name.set(Publishing.libraryName) + description.set(Publishing.libraryDescription) + url.set(Publishing.siteUrl) + + licenses { + license { + name.set(Publishing.licenseName) + url.set(Publishing.licenseUrl) + } + } + + developers { + developer { + id.set(Publishing.developerId) + name.set(Publishing.developerName) + email.set(Publishing.developerEmail) + } + } + + scm { + connection.set(Publishing.gitUrl) + developerConnection.set(Publishing.gitUrl) + url.set(Publishing.siteUrl) + } + + pom.withXml { + val dependenciesNode = asNode().appendNode("dependencies") + configurations.implementation.get().allDependencies.forEach { + if (it.group != null && it.version != null && + it.name != "unspecified" && it.version != "unspecified" + ) { + dependenciesNode.appendNode("dependency").apply { + appendNode("groupId", it.group) + appendNode("artifactId", it.name) + appendNode("version", it.version) + } + } + } + } + } + } + } + } + + bintray { + user = gradleLocalProperties(rootDir).getProperty("bintray.user") + key = gradleLocalProperties(rootDir).getProperty("bintray.apikey") + + setPublications(Publishing.Publications.release) + + pkg.apply { + repo = Publishing.bintrayRepo + name = Publishing.bintrayName + userOrg = Publishing.userOrganization + desc = Publishing.libraryDescription + websiteUrl = Publishing.siteUrl + vcsUrl = Publishing.gitUrl + setLicenses(Publishing.allLicenses) + publish = true + publicDownloadNumbers = true + + version.apply { + name = Publishing.libraryVersion + desc = Publishing.libraryDescription +// gpg.sign = true +// gpg.passphrase = gradleLocalProperties(rootDir).getProperty("bintray.gpg.password") + } + } + } +} \ No newline at end of file diff --git a/protonsdk/src/androidTest/java/com/metallicus/protonsdk/ExampleInstrumentedTest.kt b/protonsdk/src/androidTest/java/com/metallicus/protonsdk/ExampleInstrumentedTest.kt index 5a740205..650df991 100644 --- a/protonsdk/src/androidTest/java/com/metallicus/protonsdk/ExampleInstrumentedTest.kt +++ b/protonsdk/src/androidTest/java/com/metallicus/protonsdk/ExampleInstrumentedTest.kt @@ -2,7 +2,8 @@ package com.metallicus.protonsdk import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry -import org.junit.Assert.assertEquals +import org.hamcrest.CoreMatchers.containsString +import org.junit.Assert.assertThat import org.junit.Test import org.junit.runner.RunWith @@ -14,9 +15,9 @@ import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { @Test - fun useAppContext() { + fun checkPackage() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.proton.protonchain.test", appContext.packageName) + assertThat(appContext.packageName, containsString("com.metallicus.protonsdk")) } } diff --git a/protonsdk/src/main/java/com/metallicus/protonsdk/WorkersModule.kt b/protonsdk/src/main/java/com/metallicus/protonsdk/WorkersModule.kt index 9133922f..6c568e27 100644 --- a/protonsdk/src/main/java/com/metallicus/protonsdk/WorkersModule.kt +++ b/protonsdk/src/main/java/com/metallicus/protonsdk/WorkersModule.kt @@ -90,9 +90,9 @@ class WorkersModule { .enqueue() // start periodic worker to update exchange rates - val updateTokenContractRates = PeriodicWorkRequest.Builder(UpdateTokenContractRatesWorker::class.java, 15, TimeUnit.MINUTES) + val updateTokenContractRates = PeriodicWorkRequest.Builder(UpdateTokenContractRatesWorker::class.java, 15L, TimeUnit.MINUTES) .setConstraints(constraints) - .setInitialDelay(1, TimeUnit.MINUTES) + .setInitialDelay(1L, TimeUnit.MINUTES) .build() workManager.enqueueUniquePeriodicWork(UPDATE_RATES, ExistingPeriodicWorkPolicy.REPLACE, updateTokenContractRates) } diff --git a/protonsdk/src/orchid/resources/config.yml b/protonsdk/src/orchid/resources/config.yml new file mode 100644 index 00000000..42ca5a65 --- /dev/null +++ b/protonsdk/src/orchid/resources/config.yml @@ -0,0 +1,42 @@ +site: + about: + siteName: Proton Kotlin SDK + siteDescription: Kotlin library for handling Proton Chain operations. + +Editorial: + primaryColor: '#582ACB' + legacySearch: false + social: + github: 'ProtonProtocol/ProtonKotlin' + metaComponents: # this is the replacement for the deprecated automatic search addition + - type: 'orchidSearch' + menu: + - type: 'separator' + title: 'API Docs' + - type: 'sourcedocPages' + moduleType: 'kotlindoc' + node: 'classes' + asSubmenu: true + submenuTitle: 'Classes' + - type: 'sourcedocPages' + moduleType: 'kotlindoc' + node: 'packages' + asSubmenu: true + submenuTitle: 'Packages' + +kotlindoc: + sourceDirs: + - './../../../../protonsdk/src/main/java' + sourcePages: + menu: + - type: 'sourcedocPageLinks' + moduleType: 'kotlindoc' + itemTitleType: 'SIGNATURE' + includeItems: true + +services: + publications: + stages: + - type: 'githubPages' + username: 'joey-harward' + repo: 'ProtonProtocol/ProtonKotlin' \ No newline at end of file diff --git a/docs/src/orchid/resources/homepage.md b/protonsdk/src/orchid/resources/homepage.md similarity index 100% rename from docs/src/orchid/resources/homepage.md rename to protonsdk/src/orchid/resources/homepage.md diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 0b0125c4..00000000 --- a/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name = 'Proton Kotlin SDK' - -include ':protonsdk' -include ':docs' \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..6dc07d83 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,10 @@ +rootProject.name = "ProtonKotlinSDK" + +include(":protonsdk") + +pluginManagement { + repositories { + gradlePluginPortal() + maven("https://dl.bintray.com/kotlin/kotlin-eap") + } +} \ No newline at end of file