Commit Graph

26 Commits

Author SHA1 Message Date
Carter Jernigan bc19797125
[#971] Refactor Rust FFI to separate module
---------

Co-authored-by: Honza <rychnovsky.honza@gmail.com>
2023-05-18 07:36:15 -04:00
Carter Jernigan 953042e982
[#239] Remove pending transaction database 2023-05-05 17:46:07 -04:00
Honza Rychnovsky 9a816ee25f
[#674] Use suspending functions for networking
* [#674] Use suspending functions for networking

- Initial commit to set up how we transform to the coroutine version of networking client

* Enhance flow filter

* Switch to coroutine client in a few tests too

* Use StatusException

* Comment out old UI demo app cases

* Switch client in a few tests

* Switch client for download block case

* Remove the blocking networking client entirely

* Link fetch UTXOs issue

* Refactor refresh and process UTXOs

* Improve downloadBlockRange logging

* Remove CompactBlockRepository.write(sequence)

* Remove “Coroutine” prefix

Since we only have a single implementation, the designation shouldn’t matter anymore

* Fix collection bug

* Finish network client renaming

* Collect write results internally

* Write method simplification

* Blocks sync logging reduce

* Unused unsafe models remove

---------

Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2023-04-13 13:36:24 +02:00
Carter Jernigan 153072b903 [#880] Refactor Twig 2023-02-09 15:44:22 -05:00
Carter Jernigan c0a2c11418
[#615] Refactor lightwalletd client
* [#615] Refactor lightwalletd client

This moves the lightwalletd client code to a separate Gradle module, but does not yet do much clean up the public API (e.g. hiding generated GRPC objects).  That will be a followon change via #673

I’ve prototyped a safer version of the API that would be implemented for #673 for two specific calls: obtaining the current block height and obtaining the light wallet info.  These were the easiest endpoints to update and they provide a useful exploration for the future changes needed.

* Fix benchmarking for networking module

- Moved to fixture and build type check components to the new networking module, so it's accessible from all needed parts of the projects
- Changed fixture return type to fit to all needed usages

* Align with previous review comment

* Fix wrong merge

* Add basic sanity test

- To satisfy tests requirements on emulators.wtf service

* Remove grpc dependency from sdk-lib module

* Repackage cash.z.wallet.sdk.rpc to cash.z.wallet.sdk.internal.rpc

* Fix BuildConfig path

* Update demo-app paths to rpc

* Fix broken grpc services locations

- Our aim here is to change only the local services location (package name), the server location can't be changed due to backward compatibility.

* Enhance GRPC Response model

* Adopt enhanced GRPC response model

- Adopted in a few endpoints

* Enhance Connection failure type

* Add simple fixture test

* Refactor fetchTransaction() to work with Response

- Refactored this server call to adopt our new Response mechanism
- GrpsStatusResolver.resolveFailureFromStatus() now accepts Throwable input
- Added Response.Failure.toThrowable() to satisfy subsequent server calls results processing
- A few other minor refactoring changes

* Remove commented out log

* Unify return type of collection returning methods

- Switched fetchUtxos() to return Sequence instead of List
- Added a check on empty tAddress input

* fetchUtxos returns flow

- Switched fetchUtxos() to return Flow of Service.GetAddressUtxosReply
- Internally it calls getAddressUtxosStream() instead of getAddressUtxos() from GRPC layer

* Update unsafe suffix documentation

* Address several minor change requests

* Remove code parameter

- Removed from the locally triggered failures with default codes.

* Rename local variable

* Switch from empty response to exception

- Our server calls now rather throw IllegalArgumentException than return an empty response
- Removed commented out log message
- Updated javadocs

* Update proto files

- Plus related api changes adoption

* Unify new clients instances name

* AGP 7.4.0 changes

-  packagingOptions -> androidComponents in sdk-lib and lightwallet-client-lib modules

* SDK version bump

* Response resolver tests

* Release build upload timeout increase

* Release build upload timeout increase fix

* Revert timeout

- As Github has some infrastructure troubles and we need to wait

* Add migrations documentation

* Sort packaging filters

* Remove private field from public documentation

* Hide private variables

* Remove package from Android Manifest

* Throw exception instead of custom error

- This step unify our approach to validation on client side across all server calls

* Replace setAddresses index const with number

* Fix indentation in proto file

---------

Co-authored-by: Honza <rychnovsky.honza@gmail.com>
2023-02-01 11:14:55 +01:00
Carter Jernigan 3afe655737
[#631] Improve demo app compose UI for testing
* Add testnet faucet to Compose UI
* Show status on home view
* Add BlockHeight for fixture wallets
* Add balance screen
* Keep screen on while syncing
* Fix conversion of seed phrase to bytes
2023-01-09 10:42:38 -05:00
Carter Jernigan a4a6b25bfb
[#631] Initial Compose scaffolding for demo app
* [#631] Initial Compose scaffolding for demo app

* Bump Compose Compiler

- To bypass Kotlin version incompatibility

* Switch ConfigureSeed from Column to Scaffold

- To unify our screens UI components
- And to have a fullscreen content, and thus avoid another background color out of column (e.g. in system dark mode)

* Split addresses to two rows

- To reduce a risk of a user overlooks other addresses scrolled out of the screen

* Additional code migrated from Secant

- Added just missing test files, fixtures and model classes
- Fix previously broken dependencies imports

* Link issue to code

Co-authored-by: Honza <rychnovsky.honza@gmail.com>
2022-12-23 11:00:37 +01:00
Carter Jernigan b288b8cad9 Rename Synchronizer.getAddress APIs 2022-11-08 14:25:56 -05:00
Carter Jernigan 4c2807aefd
[#705] Roomoval
The Android and Rust code have previously managed joint custody of the derived data database.  With more complex migrations now required, we need to make the Android side read-only.  To achieve that, the Android side will remove Room and instead rely on more primitive SQLite APIs for read-only access.

As part of implementing this change, database management throughout the SDK is being refactored.

There will be multiple representations of the data:
 - Database representation (and some Entity representations in the places that Room hasn’t been removed yet).  These representations are not as type safe and don’t match Kotlin best practices in all cases.
 - Once #615 is implemented there will also be network representations
 - Type safe models, which often appear in the public API  The Database and Network representations will be converted to and from the type safe model representation.
2022-10-19 16:52:54 -04:00
Carter Jernigan 4c2fdeeb73 Add Account type 2022-10-06 14:49:04 -04:00
Carter Jernigan 3b826f8f6a Simplify Synchronizer instantiation
fix

synchronizer
2022-10-06 14:49:04 -04:00
Carter Jernigan 597cc43886 Replace `Synchronizer.getAddress()` with `Synchronizer.getCurrentAddress()`
The SDK now exposes UAs primarily, with additional methods for obtaining
corresponding Sapling and transparent addresses for legacy compatibility.

The `Account` DAO is also fixed to use the migrated `accounts` table format.

The demo app now shows the current UA and the legacy Sapling and transparent
addresses.

Closes zcash/zcash-android-wallet-sdk#677.
2022-10-06 14:49:04 -04:00
Honza Rychnovsky 150778f008
[#367] Fix Kotlin compiler warnings
* Fix missing room schema export directory
* Fix returned unused fields from cursor
* Fix missing db column index
* Improved TODO. Added suppress warning
* Changed parameters name to correspond to their supertype
* Changed type to Kotlin variant
* Use priority parameter
* Unified parameter names
* Suppress unchecked type warning
* Removed inline function
* Suppress obsolete coroutine warnings
* Improve previous commit
* Fix unnecessary safe call warning
* Remove unused parameter
* Unreachable code
* toLowerCase where possible
* Changed parameter name
* Suppress several "unused" warnings
* Fixed fromHtml() deprecation
* Suppress intentionally unused parameter warning
* Remove redundant initializer
* Remove inline function
* Suppress intentionally used deprecated code
* Unreachable code
* Suppress obsolete coroutine warnings
* Suppress intentionally unused parameter
* Remove unused expression
* Supertype parameter name
* Warnings of GetBlockRangeFragment.kt
* Deprecated onActivityCreated
* Suppress obsolete coroutine/flow warnings
* Unnecessary null check
* Suppress intentionally unused parameter
* Suppress intentionally unused parameters
* Deprecated onActivityCreated
* Predetermined type
* ListUtxosFragment clean code
* Suppress intentionally unused parameter
* Lint checks warnings fix
* Add data db migration
* Enable treating Kotlin compiler warnings as errors
* Solve several darkside-test-lib tests warnings
* Solve several demo-app tests warnings
* Solve several sdk-lib tests warnings
* Ktlint check result fix
* Remove parentheses now that Synchronizer is not cast
* Remove wildcard imports for java.util
* Revert "Add data db migration"
* Revert "Fix missing db column index"
* Suppress missing indexes on data db entities

Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-08-17 15:48:02 +02:00
Carter Jernigan e01a906407
[#593] Refactor ZcashNetwork
Splits the ZcashNetwork and Lightwalletd server information, making it easier to configure different servers
2022-08-02 09:29:09 -04:00
Carter Jernigan 3535ba905e [#629] Stream blocks during download
This change leverages the gRPC streaming API along with the elimination of bulk inserts to SQLite to reduce the amount of memory required to write blocks.
2022-07-28 15:49:46 -04:00
Carter Jernigan 9b666833b1
[#474] Add type safe BlockHeight API
- Replace int with type safe BlockHeight(Long) object
 - Fix down casting bug, as BlockHeight is uint32 but Java only supports int32 or int64
 - Rename WalletBirthday to Checkpoint and hide from the public API
2022-07-12 08:40:09 -04:00
Carter Jernigan 4f61a52b6e [#484] Kotlin 1.7.0 2022-06-30 09:32:04 -04:00
Carter Jernigan 3fa7a98fbf [#580] ktlint 0.46.1
Update baseline
2022-06-27 08:42:37 -04:00
Carter Jernigan 5f40d7a14e [#344] Minimize threads; reduce risk of SQLite issues
While there are a lot of changes, the most significant are:
 - Update the main entrypoint of the SDK to use a suspending function and eliminate lazy initialization.  This also resolves #310
 - Changing Dao methods to `suspend`, allowing Room to implicitly manage the threading model under the hood
 - Explicitly set the executor thread for the `CompactBlockDb` and `DerivedDataDb`, which is the same thread used when calling into the Rust native library.  Room will then use this thread for `suspend` fun calls into it
 - With the above set, remove unnecessary hops to Dispatchers.IO which is a thread pool
 - Eliminate lazy initialization in `PagedTransactionRepository` to make it easier to reason about the threading model and resolve #355 where the database was being touched from the UI thread

Note that `PendingTransactionsDb` is not opted into this single-threaded approach, because that database is not shared with the Rust code
2022-01-19 15:27:30 -05:00
Carter Jernigan dca91f2558 [#319] Fix ktlint issues 2021-11-18 07:10:30 -05:00
Carter Jernigan 079229972f [#269] Convert blocking calls to suspend functions
To quickly get this implemented, some calls in the demo-app have been wrapped in `runBlocking {}`.  This is not ideal and will be addressed in followup issues.
2021-10-21 16:52:15 -04:00
Carter Jernigan 07a00dc376
[#294] Move twig to internal package 2021-10-13 10:20:13 -04:00
Carter Jernigan 28853b5a84 [#293] Refactor non-public APIs to internal package 2021-10-04 08:45:53 -04:00
Carter Jernigan 283718de94 [#285] Apply ktlint to demo-app
In the process of refactoring the Gradle scripts, ktlint now is applied to all Gradle modules.  The demo-app hadn't been linted before, so this applies a series of minor autocorrections to this module.
2021-09-25 12:54:42 -04:00
Carter Jernigan 8b67ee1e57 Get tests running to completion
Some tests have been disabled to enable tests to actually complete; there are a number of test failures which need to be addressed.

These tests were failing prior to the refactoring.

The disabled tests can be easily found by searching for the Ignore annotation. They also appear in the Junit results window in Android Studio.
2021-08-31 14:57:23 -04:00
Carter Jernigan 2268f814f2 [#255] Refactor Gradle Modules
Move SDK from the root gradle project to its own Gradle module
Move the demo app to be a peer of the SDK

This will simplify integration with CI on Bitrise.
2021-08-31 14:53:25 -04:00