Save addressNames from API during transaction sync (Android)#214
Open
Save addressNames from API during transaction sync (Android)#214
Conversation
Mirror iOS TransactionsService which calls addressStore.addAddressNames after syncing transactions. Android was dropping response.addressNames on the floor. Schema: - Add addresses table (PK chain+address, columns chain/address/name/ type/status) matching iOS AddressRecord; no wallet_id — entries are external (validators, contacts) - Bump DB version 70 -> 71 with Migration_70_71 Domain: - Add SaveAddressNames case in gemcore - Add thin AddressesRepository wrapping AddressesDao - Register DAO, migration, and Hilt bindings Wiring: - Add addressNames to TransactionsResponse (defaults to emptyList for back-compat) - Inject SaveAddressNames into SyncTransactionsImpl and call after saveTransactions, mirroring iOS call order Closes #10
…dressnames-from-api-during-transaction-sync
- Rename counterpartyAddress to participantAddressName for consistency with participantAddress - Inline Account.toAddressRecord into Wallet.toAddressRecords (single-use helper) - Remove outdated SyncTransactionsImplTest
6f45a9f to
749c374
Compare
e9673ae to
b3dca91
Compare
…dressnames-from-api-during-transaction-sync # Conflicts: # android/data/repositories/src/main/kotlin/com/gemwallet/android/data/repositories/di/WalletsModule.kt # android/data/repositories/src/main/kotlin/com/gemwallet/android/data/repositories/wallets/WalletsRepositoryImpl.kt # android/data/services/store/schemas/com.gemwallet.android.data.service.store.database.GemDatabase/71.json # android/data/services/store/src/main/kotlin/com/gemwallet/android/data/service/store/database/GemDatabase.kt # android/data/services/store/src/main/kotlin/com/gemwallet/android/data/service/store/database/di/DatabaseModule.kt # android/data/services/store/src/main/kotlin/com/gemwallet/android/data/service/store/database/di/Migration_70_71.kt # android/data/services/store/src/main/kotlin/com/gemwallet/android/data/service/store/database/entities/DbTransactionExtended.kt
b3dca91 to
e3bcb70
Compare
gemcoder21
approved these changes
May 4, 2026
| db.execSQL( | ||
| """ | ||
| CREATE TABLE IF NOT EXISTS `addresses` ( | ||
| `chain` TEXT NOT NULL, |
| `status` TEXT NOT NULL, | ||
| PRIMARY KEY(`chain`, `address`), | ||
| FOREIGN KEY(`wallet_id`) REFERENCES `wallets`(`id`) | ||
| ON UPDATE CASCADE ON DELETE CASCADE |
Contributor
There was a problem hiding this comment.
one liner, remove trimIndent
| LEFT JOIN tx_swap_metadata as swap ON tx.id = swap.tx_id | ||
| LEFT JOIN asset as from_asset ON swap.from_asset_id = from_asset.id | ||
| LEFT JOIN asset as to_asset ON swap.to_asset_id = to_asset.id | ||
| LEFT JOIN addresses as from_addr ON from_addr.chain = asset.chain AND from_addr.address = tx.owner |
Contributor
There was a problem hiding this comment.
Suggested change
| LEFT JOIN addresses as from_addr ON from_addr.chain = asset.chain AND from_addr.address = tx.owner | |
| LEFT JOIN addresses as from_addr ON from_addr.chain = asset.chain AND from_addr.address = transaction.owner |
…dressnames-from-api-during-transaction-sync # Conflicts: # android/data/coordinators/src/main/kotlin/com/gemwallet/android/data/coordinators/transaction/GetTransactionsImpl.kt
Mirrors the iOS AddressRecord FK and aligns with how master's Migration_71_72 wires accounts.chain to asset(id). Adds an index on chain so the FK doesn't trigger full-table scans.
…dressnames-from-api-during-transaction-sync # Conflicts: # android/data/coordinators/src/main/kotlin/com/gemwallet/android/data/coordinators/transaction/SyncTransactionsImpl.kt # android/data/services/store/src/main/kotlin/com/gemwallet/android/data/service/store/database/TransactionsDao.kt # android/gemcore/src/main/kotlin/com/gemwallet/android/model/Transaction.kt
- Drop seeding from Migration_72_73; addresses populate via SaveAddressNames sync and putWallet - Rename DbAddressNameProjection to DbAddressProjection to match DbAssetProjection naming - Drop redundant open/override val on Destination sealed subclasses
gemcoder21
reviewed
May 7, 2026
| `status` TEXT NOT NULL, | ||
| PRIMARY KEY(`chain`, `address`), | ||
| FOREIGN KEY(`chain`) REFERENCES `asset`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, | ||
| FOREIGN KEY(`wallet_id`) REFERENCES `wallets`(`id`) ON UPDATE CASCADE ON DELETE CASCADE |
Contributor
There was a problem hiding this comment.
Suggested change
| FOREIGN KEY(`wallet_id`) REFERENCES `wallets`(`id`) ON UPDATE CASCADE ON DELETE CASCADE | |
| FOREIGN KEY(`walletId`) REFERENCES `wallets`(`id`) ON UPDATE CASCADE ON DELETE CASCADE |
gemcoder21
reviewed
May 7, 2026
| data class DbAddress( | ||
| val chain: Chain, | ||
| val address: String, | ||
| @ColumnInfo(name = "wallet_id") val walletId: String?, |
Contributor
There was a problem hiding this comment.
Suggested change
| @ColumnInfo(name = "wallet_id") val walletId: String?, | |
| val walletId: String?, |
gemcoder21
reviewed
May 7, 2026
| val address: String, | ||
| @ColumnInfo(name = "wallet_id") val walletId: String?, | ||
| val name: String, | ||
| val type: AddressType?, |
Contributor
There was a problem hiding this comment.
Suggested change
| val type: AddressType?, | |
| val type: AddressType, |
gemcoder21
reviewed
May 7, 2026
| ) | ||
|
|
||
| data class DbAddressProjection( | ||
| val chain: Chain?, |
gemcoder21
reviewed
May 7, 2026
| package com.gemwallet.android.cases.addresses | ||
|
|
||
| interface RenameWalletAddresses { | ||
| suspend fun renameWalletAddresses(walletId: String, name: String) |
Contributor
There was a problem hiding this comment.
Suggested change
| suspend fun renameWalletAddresses(walletId: String, name: String) | |
| suspend fun rename(walletId: WalletId, name: String) |
gemcoder21
reviewed
May 7, 2026
| val address: String | ||
| val addressName: String? | ||
| get() = null | ||
| val addressType: AddressType? |
Contributor
There was a problem hiding this comment.
address: (name, type) ? maybe new struct?
gemcoder21
reviewed
May 7, 2026
| `address` TEXT NOT NULL, | ||
| `wallet_id` TEXT, | ||
| `name` TEXT NOT NULL, | ||
| `type` TEXT, |
Contributor
There was a problem hiding this comment.
Suggested change
| `type` TEXT, | |
| `type` TEXT NOT NULL, |
gemcoder21
approved these changes
May 7, 2026
…dressnames-from-api-during-transaction-sync # Conflicts: # android/data/coordinators/src/main/kotlin/com/gemwallet/android/data/coordinators/transaction/SyncTransactionsImpl.kt
- Bump core: AddressName.address_type is now AddressType (non-optional) - Regenerate AddressName bindings on Android and iOS - Android: DbAddress.type, DbAddressProjection.type, addresses.type column become non-null; bump 73.json schema - iOS: AddressRecord.type non-null with .notNull schema; add Backfill type migration so legacy NULL rows decode - Drop unused TransactionDataAggregate.addressType (no consumer reads it) - Rename RenameWalletAddresses.renameWalletAddresses(walletId: String, ...) to rename(walletId: WalletId, ...) per review
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.
Mirrors iOS address-name handling on Android: persists names from the API,
surfaces them in the transaction list and details, and keeps them in sync
when a wallet is renamed.
Schema:
addressestable (PK chain+address; columns chain/address/wallet_id/name/type/status). The optional
wallet_idlets us mark the user's ownaccounts as
InternalWallet/Verifiedand rename them along with theirwallet
Migration_72_73) — creates the table and seedsexisting accounts as internal addresses
Domain:
SaveAddressNames,GetAddressName,RenameWalletAddressescasesbacked by a thin
AddressesRepositorySync:
addressNamestoTransactionsResponse(defaults to empty forback-compat)
SyncTransactionsImplcallssaveAddressNamesafter saving transactions,matching iOS call order
WalletsRepositoryImpl.putWalletseeds the user's own accounts intoaddressesCloses #10