-
Notifications
You must be signed in to change notification settings - Fork 11
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
[#1632] Refactor Account.DEFAULT
#1645
Conversation
ae3796b
to
f3f98c3
Compare
The failing tests need to resolve this comment in the underlying PR first #1640 (review) |
crash - DerivationTool.getInstance().deriveUnifiedSpendingKey when deriving spending key feature request - getAccounts is fine as a function but please also add a flow |
Thank you. I'll test both crashes.
This one might be related to my comment above
No quick thought about this one. I'll come back once reproduced.
Yes, we'll need it when adopting in Zashi. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed db49a63. I did not review (most of) the changes to the test files.
This PR should be split into the changes that fix #1632 (which all LGTM), and the changes that finish #1640. Whether or not this happens outside of #1640 or by merging the PR into #1640 and then rebasing the branch to fix its commit history, I don't particularly mind; but the #1632 fixes need to merge before #1640 can be merged, because the latter blocks on the former.
sdk-lib/src/test/java/cash/z/ecc/android/sdk/model/AccountTest.kt
Outdated
Show resolved
Hide resolved
sdk-lib/src/androidTest/java/cash/z/ecc/fixture/AccountFixture.kt
Outdated
Show resolved
Hide resolved
sdk-lib/src/androidTest/java/cash/z/ecc/fixture/FakeRustBackend.kt
Outdated
Show resolved
Hide resolved
sdk-lib/src/main/java/cash/z/ecc/android/sdk/internal/db/derived/TxOutputsView.kt
Show resolved
Hide resolved
@@ -31,7 +31,7 @@ sealed class TransactionRecipient { | |||
override fun toString() = "TransactionRecipient.Address" | |||
} | |||
|
|||
data class Account(val accountValue: cash.z.ecc.android.sdk.model.Account) : TransactionRecipient() { | |||
data class Account(val accountZip32Index: Int) : TransactionRecipient() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is incorrect. The value currently returned from the SQL view is the internal account ID, not the ZIP 32 account index. (This is where the SDKs were conflating internal account IDs with ZIP 32 account indices previously; we should not persist with this conflation.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backend-lib/src/test/java/cash/z/ecc/android/sdk/internal/fixture/JniAccountBalanceFixture.kt
Show resolved
Hide resolved
3dedb0c
to
4409e65
Compare
@Milan-Cerovsky, we're ready for review here. I moved the #1640 related changes into the PR and left only #1632 related changes in this PR. Please take a look. |
We have deprecated the old Fragment-based Demo app. See #973. So, the purpose of these changes is purely the buildability of the new Compose-based Demo app.
This part of the Demo app will be removed as part of #973
+ necessary fixtures changes
As it was, as making it public could bring more requirements on our multi-account support in version 1
- We deduplicated the fixture across the related modules and their tests - It works with UUID instead of String converted to ByteArray - Documentation added
5d8cd90
to
426f9d2
Compare
The rest of the changes (tests changes) will be used by 1640 though
426f9d2
to
2f4ac4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 2f4ac4c. I did not closely review the changes to the demo app.
PR should be squash-merged to get rid of the added-then-removed UUID changes from the history.
demo-app/src/main/java/cash/z/ecc/android/sdk/demoapp/demos/getaddress/GetAddressFragment.kt
Show resolved
Hide resolved
demo-app/src/main/java/cash/z/ecc/android/sdk/demoapp/demos/getbalance/GetBalanceFragment.kt
Show resolved
Hide resolved
demo-app/src/main/java/cash/z/ecc/android/sdk/demoapp/demos/getbalance/GetBalanceFragment.kt
Show resolved
Hide resolved
* [#1632] Refactor `Account.DEFAULT` (#1645) * [#1632] Remove `Account.DEFAULT` * Update Account related APIs * Refactor balances APIs * Adopt `getAccounts` in fragment-based Demo app We have deprecated the old Fragment-based Demo app. See #973. So, the purpose of these changes is purely the buildability of the new Compose-based Demo app. * Add init to `JniUnifiedSpendingKey.kt` * Update deprecated Fragment-based Demo app This part of the Demo app will be removed as part of #973 * Remove deprecated functions from Synchronizer * Update WalletSnapshot and WalletVM APIs in Demo + necessary fixtures changes * Update newer Compose-based Demo app * Hide `Synchronizer.createAccount` form public API As it was, as making it public could bring more requirements on our multi-account support in version 1 * Add all accounts flow API * Refactor AccountFixture - We deduplicated the fixture across the related modules and their tests - Documentation added * Fix `fetchUtxos` error (code 14) - Closes #1648 - This also impacts SDK’s ability to recover from loss of internet connection - Changelog updated * Switch from ZIP 32 account indices to UUID account identifiers (#1640) * Switch from ZIP 32 account indices to UUID account identifiers * Rename TransactionRecipient.Account To emphasize the distinction between Account and TransactionRecipient.Account * Fix `Backend.createAccount` API parameters * Add `importAccountUfvk` to the Rust backend. * Propagate accountName and keySource across SDK * Propagate new importAccount across SDK * Wrap createAccount setup information * Wrap importAccount setup information * Add `Zip32AccountIndex` wrapper * Update key source parameter * Remove account from `UnifiedSpendingKey` * Fix `importAccountByUfvk` API * Refactor Account.accountUuid to wrapper class So we can easily keep it typesafe and compare it to each other * Add `JniAccountUsk` * Add `seedFingerprint` and `zip32AccountIndex` To public API `importAccountUfvk` * Transactions by account UUID * Refactor default account creation * Migrate to Rust crate revision with bugfixes to account UUID migration * Refactor inputs of `importAccountUfvk` * Use `FirsClassByteArray` for `seed` parameter --------- Co-authored-by: Honza <[email protected]> Co-authored-by: Kris Nuttycombe <[email protected]> Co-authored-by: Honza Rychnovský <[email protected]> Co-authored-by: Daira-Emma Hopwood <[email protected]> * Remove unused `TransactionEncoder` functions (#1660) * Resolve [#1640] review comments * `Account` documentation fix * Make `AccountPurpose.Spending` args not null As they now live under `AccountPurpose.Spending` where we need them not null + `AccountImportSetup` doc fix * Replace `bytes` with `usk` in `AccountUsk` * Change test name * Feature/proposal to pczt (#1647) * Migrate to latest revision of Zcash crates * Integrate PCZT APIs into the Android SDK * Fix `Backend.createPcztFromProposal` parameter * Add Synchronizer side of PCZT logic * Add `getAccountForUfvk` method to Rust backend & fix key derivation null issue. (#1656) * Add `getAccountForUfvk` method to the FFI. * Only decode key derivation metadata when creating a count with `Spending` purpose. Also, ensure that a spending account can still be created without providing key derivation metadata. * Update to `librustzcash` revision `205d4c930319b7b6d24aeb4efde69e9b4d1b6f7b` * Add the new `getAccountForUfvk` to `TypesafeBackend` * Update `FakeRustBackend` --------- Co-authored-by: Honza <[email protected]> * Remove unused `TransactionEncoder` functions (#1660) * Resolve [#1640] review comments * `Account` documentation fix * Make `AccountPurpose.Spending` args not null As they now live under `AccountPurpose.Spending` where we need them not null + `AccountImportSetup` doc fix * Replace `bytes` with `usk` in `AccountUsk` * Change test name * Testnet Synchronizer test fix * Detekt warning * Changelog update --------- Co-authored-by: Jack Grigg <[email protected]> Co-authored-by: Honza <[email protected]> Co-authored-by: Honza Rychnovský <[email protected]> * Peformance optimizations * Revert "Peformance optimizations" This reverts commit 68de6ae. * PCZT support follow-ups (#1663) * Rename exception * Add sapling param fetching to new KS-related fun * Add dedicated clone PZCT function * Add `Synchronizer.Status.INITIALIZING` For wallets to know that accounts and other APIs are not ready yet * [#1665] Checkpoints update Closes #1665 * Bump lib version to 2.2.7 * Migrate to the published Zcash crate releases including PCZT v1 (#1664) Co-authored-by: Honza <[email protected]> --------- Co-authored-by: Jack Grigg <[email protected]> Co-authored-by: Kris Nuttycombe <[email protected]> Co-authored-by: Daira-Emma Hopwood <[email protected]> Co-authored-by: Kris Nuttycombe <[email protected]> Co-authored-by: Milan Cerovsky <[email protected]>
Account
type to the new multi-seed-compatible account identifier #1633Account
logic refactoring addSynchronizer.getAllAccounts
to the public API.Synchronizer.sendToAddress
andSynchronizer.shieldFunds
to simplify refactoringAuthor
Reviewer
Footnotes
Code often looks different when reviewing the diff in a browser, making it easier to spot potential bugs. ↩
While we aim for automated testing of the SDK, some aspects require manual testing. If you had to manually test
something during development of this pull request, write those steps down. ↩
While we are not looking for perfect coverage, the tool can point out potential cases that have been missed. Code coverage can be generated with:
./gradlew check
for Kotlin modules and./gradlew connectedCheck -PIS_ANDROID_INSTRUMENTATION_TEST_COVERAGE_ENABLED=true
for Android modules. ↩Having your code up to date and squashed will make it easier for others to review. Use best judgement when squashing commits, as some changes (such as refactoring) might be easier to review as a separate commit. ↩
In addition to a first pass using the code review guidelines, do a second pass using your best judgement and experience which may identify additional questions or comments. Research shows that code review is most effective when done in multiple passes, where reviewers look for different things through each pass. ↩
While the CI server runs the demo app to look for build failures or crashes, humans running the demo app are
more likely to notice unexpected log messages, UI inconsistencies, or bad output data. Perform this step last, after verifying the code changes are safe to run locally. ↩