Skip to content

Conversation

@SeniorZhai
Copy link
Member

No description provided.

@SeniorZhai SeniorZhai requested a review from Copilot November 3, 2025 06:58
@SeniorZhai SeniorZhai added the testing Now testing, but you can review label Nov 3, 2025
Copy link
Contributor

Copilot AI left a 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() and formatDate() methods from Web3FilterParams
  • Created new Web3DataProvider class with custom data source implementation
  • Updated Web3Repository to use the new Web3DataProvider instead of calling buildQuery() 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 SimpleSQLiteQuery import is no longer needed after removing the buildQuery() method and should be removed.
import androidx.sqlite.db.SimpleSQLiteQuery

app/src/main/java/one/mixin/android/ui/wallet/Web3FilterParams.kt:6

  • The TransactionStatus import is no longer used after removing the buildQuery() 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
Copy link

Copilot AI Nov 3, 2025

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.

Suggested change
import one.mixin.android.db.MixinDatabase

Copilot uses AI. Check for mistakes.
Comment on lines +168 to +173
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 -> {}
Copy link

Copilot AI Nov 3, 2025

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.

Copilot uses AI. Check for mistakes.
one.mixin.android.ui.wallet.Web3TokenFilterType.ALL -> {}
}
filter.startTime?.let {
filters.add("w.transaction_at >= '${org.threeten.bp.Instant.ofEpochMilli(it)}'")
Copy link

Copilot AI Nov 3, 2025

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.

Copilot uses AI. Check for mistakes.
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)}'")
Copy link

Copilot AI Nov 3, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Now testing, but you can review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants