-
Notifications
You must be signed in to change notification settings - Fork 111
Replace wallet data provider #5926
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR refactors the Web3 transaction querying logic by extracting SQL query building from Web3FilterParams into a new Web3DataProvider class. This separation improves maintainability by decoupling data filtering parameters from database query logic.
- Removed
buildQuery()andformatDate()methods fromWeb3FilterParams - Created new
Web3DataProviderclass with custom data source implementation - Updated
Web3Repositoryto use the newWeb3DataProviderinstead of callingbuildQuery()directly
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Web3FilterParams.kt | Removed SQL query building logic, keeping only filter parameter definitions |
| Web3Repository.kt | Updated to use new Web3DataProvider for transaction queries |
| Web3DataProvider.kt | New class implementing custom data source with query building logic |
Comments suppressed due to low confidence (2)
app/src/main/java/one/mixin/android/ui/wallet/Web3FilterParams.kt:4
- The
SimpleSQLiteQueryimport is no longer needed after removing thebuildQuery()method and should be removed.
import androidx.sqlite.db.SimpleSQLiteQuery
app/src/main/java/one/mixin/android/ui/wallet/Web3FilterParams.kt:6
- The
TransactionStatusimport is no longer used after removing thebuildQuery()method and should be removed.
import one.mixin.android.db.web3.vo.TransactionStatus
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import androidx.paging.DataSource | ||
| import androidx.room.RoomRawQuery | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import one.mixin.android.db.MixinDatabase |
Copilot
AI
Nov 3, 2025
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.
The MixinDatabase import is unused and should be removed.
| import one.mixin.android.db.MixinDatabase |
| one.mixin.android.ui.wallet.Web3TokenFilterType.SEND -> filters.add("w.transaction_type = 'transfer_out'") | ||
| one.mixin.android.ui.wallet.Web3TokenFilterType.RECEIVE -> filters.add("w.transaction_type = 'transfer_in'") | ||
| one.mixin.android.ui.wallet.Web3TokenFilterType.APPROVAL -> filters.add("w.transaction_type = 'approval'") | ||
| one.mixin.android.ui.wallet.Web3TokenFilterType.SWAP -> filters.add("w.transaction_type = 'swap'") | ||
| one.mixin.android.ui.wallet.Web3TokenFilterType.PENDING -> filters.add("w.status = '${TransactionStatus.PENDING.value}'") | ||
| one.mixin.android.ui.wallet.Web3TokenFilterType.ALL -> {} |
Copilot
AI
Nov 3, 2025
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.
Add an import statement for Web3TokenFilterType at the top of the file instead of using fully qualified names repeatedly. This improves code readability.
| one.mixin.android.ui.wallet.Web3TokenFilterType.ALL -> {} | ||
| } | ||
| filter.startTime?.let { | ||
| filters.add("w.transaction_at >= '${org.threeten.bp.Instant.ofEpochMilli(it)}'") |
Copilot
AI
Nov 3, 2025
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.
Add an import statement for org.threeten.bp.Instant at the top of the file instead of using the fully qualified name. This improves code readability and is consistent with the rest of the codebase where org.threeten.bp classes are imported.
| filters.add("w.transaction_at >= '${org.threeten.bp.Instant.ofEpochMilli(it)}'") | ||
| } | ||
| filter.endTime?.let { | ||
| filters.add("w.transaction_at <= '${org.threeten.bp.Instant.ofEpochMilli(it + 24 * 60 * 60 * 1000)}'") |
Copilot
AI
Nov 3, 2025
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.
The magic number 24 * 60 * 60 * 1000 (milliseconds in a day) should be extracted to a named constant for better readability and maintainability. Consider defining private const val MILLIS_PER_DAY = 24 * 60 * 60 * 1000L.
No description provided.