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

Integrate with lightwalletd and librustzcash #16

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c99f9a3
Add data access layer for dataDb
gmale Dec 21, 2018
2c0966a
Create synchronizer and add layer of business logic onto the data layer
gmale Jan 3, 2019
986ee50
Switch to JUnit 5
gmale Jan 4, 2019
5915ad3
Create CompactBlockDownloader, iterate on business logic using new JU…
gmale Jan 13, 2019
9448f43
Integrate with dataDb init commands and grpc service updates.
gmale Jan 16, 2019
13642d6
Create CompactBlockProcessor and refine responsibilities of collabora…
gmale Jan 23, 2019
84b8756
Create ActiveTransactionManager to monitor active transactions
gmale Feb 3, 2019
e668946
Iterate and refine send and active transaction behavior
gmale Feb 5, 2019
bfdd093
Create mock synchronizer to help with driving the UI.
gmale Feb 14, 2019
21f09fa
Fix bugs
gmale Feb 14, 2019
1892e4d
Add conversion logic and extensions for consistency and correctness
gmale Feb 18, 2019
913ecb4
Twig: Refactor to be much more useful.
gmale Feb 19, 2019
37c9cf7
Add additional logging to mock synchronizer
gmale Feb 19, 2019
df9f020
Add address information to notes query and other cleanup
gmale Feb 19, 2019
c5e5941
Prevent change from being returned in transaction queries
gmale Feb 23, 2019
09de20c
Remove unused things and document limits of Junit 5 usage
gmale Feb 24, 2019
56fada2
Improve logic and behavior during app startup.
gmale Feb 24, 2019
ed5e9c0
Add a layer of logic for bubbling up errors
gmale Feb 24, 2019
d38c348
Update the logic for determining balance
gmale Feb 26, 2019
c7d85f2
Cleanup
gmale Mar 12, 2019
764455d
Clean up data API
gmale Mar 13, 2019
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
.cargo/
bin/
gen/
generated/
out/
target/
jniLibs/
Expand Down Expand Up @@ -67,3 +68,6 @@ fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# other
DecompileChecker.kt
136 changes: 111 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@ buildscript {
'targetSdkVersion': 28
]
ext.versions = [
'kotlin': '1.3.10',
'architectureComponents': '2.0.0'
'architectureComponents': [
'lifecycle': '2.1.0-alpha02',
'room': '2.1.0-alpha04'
],
'grpc':'1.19.0',
'kotlin': '1.3.21',
'coroutines': '1.1.1',
'junitJupiter': '5.4.0'
]
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha05'
classpath 'com.android.tools.build:gradle:3.5.0-alpha07'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath "com.github.ben-manes:gradle-versions-plugin:0.20.0"
classpath "org.jetbrains.kotlin:kotlin-allopen:${versions.kotlin}"
classpath "com.github.ben-manes:gradle-versions-plugin:0.21.0"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8"
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.6'
}
}

Expand All @@ -25,11 +34,14 @@ apply plugin: 'com.android.library'
apply plugin: "kotlin-android-extensions"
apply plugin: "kotlin-android"
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.google.protobuf'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.getkeepsafe.dexcount'

group = 'cash.z.android.wallet'
version = '1.2.0'
version = '1.7.4'

repositories {
google()
Expand All @@ -42,9 +54,11 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode = 1_02_00
versionName = "1.2.0"
versionCode = 1_07_04_00 // last digits are alpha(0X) beta(1X) rc(2X) release(3X). Ex: 1_08_04_20 is a RC build
versionName = "$version-alpha"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled false
archivesBaseName = "zcash-android-wallet-sdk-$versionName"
}

buildTypes {
Expand All @@ -56,35 +70,107 @@ android {
sourceSets {
main {
java {
srcDirs "build/generated/source/wire"
srcDirs "build/generated/source/grpc"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be src/generated/source/grpc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I can tell, it is.

}
proto {
srcDir 'src/main/proto'
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE.md'
exclude 'META-INF/LICENSE-notice.md'
}
}

allOpen {
// marker for classes that we want to be able to extend in debug builds for testing purposes
annotation 'cash.z.wallet.sdk.annotation.OpenClass'
}

clean {
delete "$project.projectDir/src/generated/source/grpc"
}

protobuf {
generatedFilesBaseDir = "$projectDir/src/generated/source/grpc"
protoc { artifact = 'com.google.protobuf:protoc:3.7.0' }
plugins {
javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${versions.grpc}" }
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
grpc { // Options added to --grpc_out
option 'lite' }
}
}
}
}

dependencies {
// Square
api "com.squareup.wire:wire-runtime:2.2.0"
implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
implementation 'androidx.multidex:multidex:2.0.1'

// Architecture components
implementation "androidx.lifecycle:lifecycle-runtime:${versions.architectureComponents}"
implementation "androidx.lifecycle:lifecycle-extensions:${versions.architectureComponents}"
implementation "androidx.room:room-runtime:${versions.architectureComponents}"
kapt "androidx.lifecycle:lifecycle-compiler:${versions.architectureComponents}"
kapt "androidx.room:room-compiler:${versions.architectureComponents}"
// Architecture Components: Lifecycle
implementation "androidx.lifecycle:lifecycle-runtime:${versions.architectureComponents.lifecycle}"
implementation "androidx.lifecycle:lifecycle-extensions:${versions.architectureComponents.lifecycle}"
kapt "androidx.lifecycle:lifecycle-compiler:${versions.architectureComponents.lifecycle}"

// Other
// Architecture Components: Room
implementation "androidx.room:room-runtime:${versions.architectureComponents.room}"
implementation "androidx.room:room-common:${versions.architectureComponents.room}"
kapt "androidx.room:room-compiler:${versions.architectureComponents.room}"

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}"
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutines}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.coroutines}"

// grpc-java
implementation "io.grpc:grpc-okhttp:${versions.grpc}"
implementation "io.grpc:grpc-protobuf-lite:${versions.grpc}"
implementation "io.grpc:grpc-stub:${versions.grpc}"
implementation 'javax.annotation:javax.annotation-api:1.3.2'

// Other
implementation "com.jakewharton.timber:timber:4.7.1"

// Tests
testImplementation "junit:junit:4.12"
androidTestImplementation "androidx.test:runner:1.1.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.1.0"
androidTestImplementation "androidx.test:core:1.0.0"
androidTestImplementation "androidx.arch.core:core-testing:${versions.architectureComponents}"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:${versions.kotlin}"
testImplementation 'org.mockito:mockito-junit-jupiter:2.25.0'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
testImplementation "org.junit.jupiter:junit-jupiter-api:${versions.junitJupiter}"
testImplementation "org.junit.jupiter:junit-jupiter-engine:${versions.junitJupiter}"
testImplementation "org.junit.jupiter:junit-jupiter-migrationsupport:${versions.junitJupiter}"
testImplementation "io.grpc:grpc-testing:${versions.grpc}"

// NOTE: androidTests will use JUnit4, while src/test/java tests will leverage Junit5
// Attempting to use JUnit5 via https://github.com/mannodermaus/android-junit5 was painful. The plugin configuration
// was buggy, crashing in several places. It also would require a separate test flavor because it's minimum API 26
// because "JUnit 5 uses Java 8-specific APIs that didn't exist on Android before the Oreo release."
androidTestImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0'
androidTestImplementation 'org.mockito:mockito-android:2.25.0'
androidTestImplementation "androidx.test:runner:1.1.2-alpha02"
androidTestImplementation "androidx.test:core:1.1.1-alpha02"
androidTestImplementation "androidx.arch.core:core-testing:2.0.0"
androidTestImplementation 'androidx.test.ext:junit:1.1.1-alpha02'
}


preBuild.dependsOn generateProtobufClasses
preBuild.dependsOn copyAllJniLibs
preBuild.dependsOn includeDirBugFix
preBuild.dependsOn copyAllJniLibs
83 changes: 56 additions & 27 deletions custom-tasks.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
def protoSrcDir = "src/main/proto"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: I've put zero energy into cleaning this file because it will be deleted once #15 is merged.

def protoDestDir = "build/generated/source/wire"
//def protoSrcDir = "src/main/proto"
//def protoDestDir = "build/generated/source/grpc"
def protoIncludeDir = "build/extracted-include-protos/main"
def jniSrcDir = "src/main/rust"
def jniDestDir = "build/rust/target"

Expand All @@ -11,36 +12,64 @@ def libArm64Dir = "src/main/jniLibs/arm64-v8a"
def libArmeabiFile = "build/rust/target/armv7-linux-androideabi/release/$libFile"
def libArmeabiDir = "src/main/jniLibs/armeabi-v7a"

buildscript {
dependencies {
classpath("com.squareup.wire:wire-compiler:2.2.0")
}
repositories {
mavenCentral()
}
}
//buildscript {
// dependencies {
// classpath("com.squareup.wire:wire-compiler:2.2.0")
// }
// repositories {
// mavenCentral()
// }
//}

tasks.register("generateProtobufClasses") {
doFirst {
println("**** CREATING PROTOS ****")
delete(protoDestDir)
mkdir(protoDestDir)
}
description = "Generate Java classes from protocol buffer (.proto) schema files for use with Square's Wire library"
//tasks.register("generateGrpcClasses") {
// doFirst {
// println("**** CREATING PROTOS ****")
// delete(protoDestDir)
// mkdir(protoDestDir)
// }
// description = "Generate Java classes from protocol buffer (.proto) schema files for use with grpc"
//
// fileTree(dir: protoSrcDir, include: '**/*.proto').each { File file ->
// doLast {
// javaexec {
// main = "com.squareup.wire.WireCompiler"
// classpath = buildscript.configurations.classpath
// args = ["--proto_path=$protoSrcDir", "--java_out=$protoDestDir", file.path]
// }
// }
// }
// inputs.files(fileTree(dir: protoSrcDir, include: '**/*.proto'))
// outputs.files(fileTree(dir: protoDestDir, include: '**'))
//}

fileTree(dir: protoSrcDir, include: '**/*.proto').each { File file ->
doLast {
javaexec {
main = "com.squareup.wire.WireCompiler"
classpath = buildscript.configurations.classpath
args = ["--proto_path=$protoSrcDir", "--java_out=$protoDestDir", file.path]
}
}
//tasks.register("generateProtobufClasses") {
// doFirst {
// println("**** CREATING PROTOS ****")
// delete(protoDestDir)
// mkdir(protoDestDir)
// }
// description = "Generate Java classes from protocol buffer (.proto) schema files for use with Square's Wire library"
//
// fileTree(dir: protoSrcDir, include: '**/*.proto').each { File file ->
// doLast {
// javaexec {
// main = "com.squareup.wire.WireCompiler"
// classpath = buildscript.configurations.classpath
// args = ["--proto_path=$protoSrcDir", "--java_out=$protoDestDir", file.path]
// }
// }
// }
// inputs.files(fileTree(dir: protoSrcDir, include: '**/*.proto'))
// outputs.files(fileTree(dir: protoDestDir, include: '**'))
//}
tasks.register("includeDirBugFix") {
doFirst {
mkdir(protoIncludeDir)
}
inputs.files(fileTree(dir: protoSrcDir, include: '**/*.proto'))
outputs.files(fileTree(dir: protoDestDir, include: '**'))
}

// TODO: run these in paralell with the worker API: https://guides.gradle.org/using-the-worker-api/
// note: this will require modifying the build script and having 3 separate calls
tasks.register("generateJniLibs") {
doFirst {
println("**** CREATING JNI LIBS ****")
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Nov 08 13:10:14 EST 2018
#Tue Mar 12 10:04:58 EDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
55 changes: 0 additions & 55 deletions src/androidTest/java/cash/z/wallet/sdk/dao/ComplactBlockDaoTest.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.test.core.app.ApplicationProvider
import cash.z.wallet.sdk.dao.CompactBlockDao
import cash.z.wallet.sdk.vo.CompactBlock
import cash.z.wallet.sdk.entity.CompactBlock
import org.junit.*
import org.junit.Assert.*

class DbIntegrationTest {
class CacheDbIntegrationTest {
@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule()

Expand Down Expand Up @@ -39,7 +39,8 @@ class DbIntegrationTest {
fun setup() {
// TODO: put this database in the assets directory and open it from there via .openHelperFactory(new AssetSQLiteOpenHelperFactory()) seen here https://github.com/albertogiunta/sqliteAsset
db = Room
.databaseBuilder(ApplicationProvider.getApplicationContext(), CompactBlockDb::class.java, "compact-blocks.db")
.databaseBuilder(ApplicationProvider.getApplicationContext(), CompactBlockDb::class.java, "dummy-cache.db")
// .databaseBuilder(ApplicationProvider.getApplicationContext(), CompactBlockDb::class.java, "compact-blocks.db")
.setJournalMode(RoomDatabase.JournalMode.TRUNCATE)
.fallbackToDestructiveMigration()
.build()
Expand Down
Loading