refactor(db): rename raw transaction states (signed/spent)#6437
Closed
SeniorZhai wants to merge 10 commits into
Closed
refactor(db): rename raw transaction states (signed/spent)#6437SeniorZhai wants to merge 10 commits into
SeniorZhai wants to merge 10 commits into
Conversation
SeniorZhai
commented
Jun 4, 2026
Member
- Add RawTransactionState enum: signed (已签名待广播) / spent (已广播终态)
- Add RawTransactionStateConverter for Room
- Update RawTransaction.kt to use new enum
- Update RawTransactionDao queries (unspent → signed)
- Update BottomSheetViewModel: write signed, mark spent after broadcast
- Update RestoreTransactionJob: mark spent after restore
- Database migration: signed→spent first, then unspent→signed
- Register converter in MixinDatabase
- Bump database version
- Add RawTransactionState enum: signed (已签名待广播) / spent (已广播终态) - Add RawTransactionStateConverter for Room - Update RawTransaction.kt to use new enum - Update RawTransactionDao queries (unspent → signed) - Update BottomSheetViewModel: write signed, mark spent after broadcast - Update RestoreTransactionJob: mark spent after restore - Database migration: signed→spent first, then unspent→signed - Register converter in MixinDatabase - Bump database version
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the persisted “raw transaction” lifecycle in the Room database by replacing the previous OutputState-backed values with a dedicated RawTransactionState (signed → pending broadcast, spent → broadcast terminal), including a data migration from DB version 69 → 70.
Changes:
- Introduces
RawTransactionState+ a RoomTypeConverter, updatesRawTransactionto use the new enum, and registers the converter inMixinDatabase. - Updates write/update call sites (e.g.,
BottomSheetViewModel,RestoreTransactionJob) to storesignedon creation and markspentafter broadcast/restore. - Adds migration
MIGRATION_69_70to remap legacy stored values (signed→spent,unspent→signed) and bumps DB version/schema.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| app/src/main/java/one/mixin/android/vo/safe/RawTransactionState.kt | Adds new enum for raw-transaction lifecycle (signed/spent). |
| app/src/main/java/one/mixin/android/vo/safe/RawTransaction.kt | Switches raw transaction state type from OutputState to RawTransactionState. |
| app/src/main/java/one/mixin/android/ui/common/BottomSheetViewModel.kt | Writes signed on insert; updates to spent after broadcast flow. |
| app/src/main/java/one/mixin/android/job/RestoreTransactionJob.kt | Marks restored/broadcasted raw transactions as spent. |
| app/src/main/java/one/mixin/android/db/RawTransactionDao.kt | Changes “unspent” queries to filter state = 'signed'. |
| app/src/main/java/one/mixin/android/db/MixinDatabaseMigrations.kt | Adds 69→70 migration remapping old state strings. |
| app/src/main/java/one/mixin/android/db/MixinDatabase.kt | Registers converter + includes new migration in builder. |
| app/src/main/java/one/mixin/android/db/converter/RawTransactionStateConverter.kt | Adds Room converter for RawTransactionState. |
| app/src/main/java/one/mixin/android/Constants.kt | Bumps DB version constant to 70. |
| app/schemas/one.mixin.android.db.MixinDatabase/70.json | Adds exported Room schema for v70. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
9
to
13
| @Query("SELECT * FROM raw_transactions WHERE state = 'signed' AND (type = 0 OR type = 1) ORDER BY rowid ASC LIMIT 1") | ||
| fun findUnspentTransaction(): RawTransaction? | ||
|
|
||
| @Query("SELECT count(1) FROM raw_transactions WHERE state = 'unspent' AND (type = 0 OR type = 1)") | ||
| @Query("SELECT count(1) FROM raw_transactions WHERE state = 'signed' AND (type = 0 OR type = 1)") | ||
| suspend fun countUnspentTransaction(): Int |
…ction-state # Conflicts: # app/schemas/one.mixin.android.db.MixinDatabase/70.json # app/src/main/java/one/mixin/android/db/MixinDatabase.kt # app/src/main/java/one/mixin/android/db/MixinDatabaseMigrations.kt
Co-authored-by: AI <ai@example.com>
* fix(trade): limit amount inputs to eight decimals * fix(trade): use token precision for common wallet inputs * fix(trade): limit price input decimals --------- Co-authored-by: Crossle Song <crosslesong@gmail.com>
This was referenced Jun 10, 2026
Member
Author
|
Duplicate of #6447; both branches point to the same head commit and have the same diff. Closing the older PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.