Skip to content

Conversation

@HashEngineering
Copy link
Collaborator

@HashEngineering HashEngineering commented Nov 28, 2025

Issue being fixed or feature implemented

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

Summary by CodeRabbit

  • New Features

    • Staging/main endpoint selection now follows wallet network settings.
    • Added user discount field and unified discount fallback for merchant pricing.
    • UI info panel resized for better content fit.
  • Bug Fixes

    • Gift card notes are preserved when updating metadata.
    • Dialog now forces expanded view reliably.
  • Chores

    • App version bumped to 11.4.2-ctx-staging.
    • Build configuration updated to use 2.0.2.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

Walkthrough

Updates to build/versioning and ExploreDash: RemoteDataSource now uses WalletDataProvider to choose BASE_URL vs DEV_BASE_URL based on network; GetMerchantResponse adds userDiscount and discount computed property; repositories, DI, constants, UI, and a layout height were adjusted accordingly.

Changes

Cohort / File(s) Summary
Build Configuration
build.gradle, wallet/build.gradle
dppVersion bumped from "2.0.2-SNAPSHOT""2.0.2"; versionCode11040210, versionName"11.4.2-ctx-staging"
Model Layer
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/dashspend/ctx/model/GetMerchantResponse.kt
savingsPercentage: IntInt? = 0; added userDiscount: Int? = 0; added computed val discount returning userDiscount ?: savingsPercentage ?: 0
Dependency Injection & Network
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/di/ExploreDashModule.kt, features/exploredash/src/main/java/org/dash/wallet/features/exploredash/network/RemoteDataSource.kt, features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/DashSpendRepositoryFactory.kt
RemoteDataSource constructor and provider gained WalletDataProvider param; URL selection now uses walletData.networkParameters.id to pick BASE_URL for MAINNET or DEV_BASE_URL otherwise
Repository Layer
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/CTXSpendRepository.kt
Replaced uses of savingsPercentage with discount when constructing merchant details and computing gift card discount
Constants
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/utils/CTXSpendConstants.kt
Added DEV_BASE_URL = "https://staging.spend.ctx.com/"
UI Layer
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt, features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/explore/dialogs/ExploreDashInfoDialog.kt
Preserved note when updating GiftCard (removed explicit note = null); added override val forceExpand = true to ExploreDashInfoDialog
UI Layout
features/exploredash/src/main/res/layout/explore_dash_main_info.xml
Root ConstraintLayout height changed from match_parentwrap_content

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller/ViewModel
    participant Remote as RemoteDataSource
    participant Wallet as WalletDataProvider
    participant Config as CTXSpendConfig
    participant API as CTX REST API

    Caller->>Remote: request buildApi/buildTokenApi()
    Remote->>Wallet: read networkParameters.id
    Wallet-->>Remote: return network id (MAINNET or other)
    alt MAINNET
        Remote->>Config: use BASE_URL
    else non-MAINNET
        Remote->>Config: use DEV_BASE_URL
    end
    Remote->>API: construct Retrofit client with selected base URL
    Remote-->>Caller: return API client
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to focus:
    • DI changes: ensure WalletDataProvider is available where RemoteDataSource is provided/constructed (ExploreDashModule, DashSpendRepositoryFactory).
    • URL selection logic: verify correct network id enum/constant and no regressions for MAINNET vs testnets.
    • Model changes: review nullable handling and places consuming savingsPercentage vs new discount to avoid NPEs or logic drift.
    • UI change: check layout height impact and GiftCard note preservation behavior.

Poem

🐰 I hopped through code with a cheerful twitch,

network paths sorted without a glitch.
Discounts now choose the friendlier tune,
notes stay safe beneath the moon.
Version bumped — onward we stitch!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title mentions 'json parsing for CTX staging environment' but the changes primarily involve dependency injection updates, nullable field modifications, and staging URL configuration—with no direct json parsing logic changes evident. Clarify the title to better reflect the actual changes: consider 'Add WalletDataProvider to RemoteDataSource and support CTX staging environment' or similar, or provide additional context on which json parsing was updated.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/update-json-parsing

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11c94f1 and b2e1195.

📒 Files selected for processing (1)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/dashspend/ctx/model/GetMerchantResponse.kt (1)

39-52: New discount accessor cleanly encapsulates discount precedence

Using discount to prefer userDiscount over savingsPercentage simplifies call sites and matches the staged JSON changes. For API clarity, consider making the backing fields Int? = null and declaring val discount: Int explicitly so the nullability and “0 means no discount” semantics are clearer, without changing runtime behavior.

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/utils/CTXSpendConstants.kt (1)

19-27: Staging URL constant is fine; name could be clearer

Adding DEV_BASE_URL for https://staging.spend.ctx.com/ matches the new environment switching logic; in a future cleanup you might consider renaming it to something like STAGING_BASE_URL to better reflect the actual host.

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/CTXSpendRepository.kt (1)

246-250: getGiftCardDiscount correctly switches to cached discount (denomination still unused)

Reading giftCardMap[merchantId]?.discount keeps repository logic consistent with the new model; note that the denomination parameter is still unused (as before), so at some point it may be worth either wiring it into the calculation or dropping it to avoid confusion.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c49b296 and 11c94f1.

📒 Files selected for processing (11)
  • build.gradle (1 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/dashspend/ctx/model/GetMerchantResponse.kt (1 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/di/ExploreDashModule.kt (1 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/network/RemoteDataSource.kt (3 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/CTXSpendRepository.kt (2 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/DashSpendRepositoryFactory.kt (1 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt (2 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/explore/dialogs/ExploreDashInfoDialog.kt (1 hunks)
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/utils/CTXSpendConstants.kt (1 hunks)
  • features/exploredash/src/main/res/layout/explore_dash_main_info.xml (1 hunks)
  • wallet/build.gradle (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1423
File: wallet/src/de/schildbach/wallet/ui/EditProfileActivity.kt:418-446
Timestamp: 2025-08-25T14:48:39.247Z
Learning: HashEngineering prefers to refactor and reuse topup code for balance validation logic improvements in DashPay activities like EditProfileActivity, rather than implementing individual fixes in the current PR.
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1417
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/explore/MerchantDao.kt:0-0
Timestamp: 2025-08-08T16:48:49.964Z
Learning: In PR dashpay/dash-wallet#1417, HashEngineering chose to defer adding Room indexes for gift_card_providers (provider, denominationsType, merchantId) to a follow-up PR; do not block the current PR on this optimization. Files: features/exploredash/.../data/explore/MerchantDao.kt and features/exploredash/.../data/dashspend/GiftCardProvider.kt.
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1422
File: common/src/main/java/org/dash/wallet/common/util/Constants.kt:68-69
Timestamp: 2025-08-25T15:00:20.777Z
Learning: HashEngineering prefers to keep HTTP logging enabled in release mode (using log.info instead of gating with BuildConfig.DEBUG) to debug production errors, even though this may leak URLs in production logs. This is a deliberate trade-off for debugging purposes in the Dash wallet project.
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1410
File: wallet/src/de/schildbach/wallet/data/InvitationLinkData.kt:79-84
Timestamp: 2025-07-12T07:12:04.769Z
Learning: HashEngineering prefers to handle defensive validation improvements for URI parsing in follow-up PRs rather than including them in the current PR when the main focus is on replacing Firebase with AppsFlyer.
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1425
File: wallet/src/de/schildbach/wallet/ui/more/SettingsScreen.kt:122-151
Timestamp: 2025-09-05T06:47:44.508Z
Learning: HashEngineering prefers to defer UI edge case fixes like the CoinJoin finishing state display issue (showing "Finishing ...%" when mode is OFF but status is FINISHING) to later PRs when the main focus is on redesigning the settings screen.
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1422
File: wallet/src/de/schildbach/wallet/data/PaymentIntent.java:476-481
Timestamp: 2025-08-25T15:04:18.461Z
Learning: HashEngineering prefers to keep payeeUsername and payeeUserId in PaymentIntent.toString() logs unredacted for debugging purposes, prioritizing troubleshooting capability over PII protection concerns in the Dash wallet project.
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1425
File: common/src/main/java/org/dash/wallet/common/ui/components/DashButton.kt:94-101
Timestamp: 2025-09-05T06:00:25.088Z
Learning: HashEngineering prefers to fix the DashButton alpha dimming issue (using explicit disabled colors instead of overall alpha) in a follow-up PR rather than including it in the current settings screen redesign PR.
📚 Learning: 2025-08-08T16:48:49.964Z
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1417
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/data/explore/MerchantDao.kt:0-0
Timestamp: 2025-08-08T16:48:49.964Z
Learning: In PR dashpay/dash-wallet#1417, HashEngineering chose to defer adding Room indexes for gift_card_providers (provider, denominationsType, merchantId) to a follow-up PR; do not block the current PR on this optimization. Files: features/exploredash/.../data/explore/MerchantDao.kt and features/exploredash/.../data/dashspend/GiftCardProvider.kt.

Applied to files:

  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/di/ExploreDashModule.kt
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/DashSpendRepositoryFactory.kt
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/CTXSpendRepository.kt
📚 Learning: 2025-05-08T18:11:40.249Z
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1390
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/CTXSpendViewModel.kt:129-145
Timestamp: 2025-05-08T18:11:40.249Z
Learning: The hardcoded test data in the purchaseGiftCard() function of CTXSpendViewModel is intentionally left in place for testing the error handling for limit mismatch, and will be fixed later before release.

Applied to files:

  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/CTXSpendRepository.kt
📚 Learning: 2025-08-25T15:02:39.634Z
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1422
File: features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/ctxspend/dialogs/GiftCardDetailsViewModel.kt:154-158
Timestamp: 2025-08-25T15:02:39.634Z
Learning: The CTXSpend getGiftCardByTxid API in CTXSpendRepository guarantees a non-null GiftCardResponse payload when returning ResponseResource.Success, so using response.value!! is safe and doesn't risk NPE despite the nullable type signature.

Applied to files:

  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt
  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/CTXSpendRepository.kt
📚 Learning: 2025-04-19T07:01:17.535Z
Learnt from: HashEngineering
Repo: dashpay/dash-wallet PR: 1362
File: wallet/src/de/schildbach/wallet/ui/more/SettingsViewModel.kt:107-115
Timestamp: 2025-04-19T07:01:17.535Z
Learning: In the Dash Wallet app, DashPayConfig methods like isTransactionMetadataInfoShown() already use withContext(Dispatchers.IO) internally, so wrapping these calls with another withContext(Dispatchers.IO) in ViewModels is redundant.

Applied to files:

  • features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: check
🔇 Additional comments (11)
features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/explore/dialogs/ExploreDashInfoDialog.kt (1)

31-34: Force-expanded dialog looks appropriate for this info sheet

Setting forceExpand = true ensures the bottom sheet opens fully, which makes sense for this one-shot informational dialog and pairs well with the updated wrap_content layout height.

wallet/build.gradle (1)

218-221: Versioning change is consistent with MMmmppbb scheme

11040210 correctly encodes 11.4.2 build 10, and the 11.4.2-ctx-staging name clearly distinguishes this build as CTX staging–focused; just ensure your release/distribution channels expect this staging suffix.

features/exploredash/src/main/res/layout/explore_dash_main_info.xml (1)

21-24: Changing root to wrap_content should improve dialog sizing

Using wrap_content for the root here should prevent the info dialog from filling the whole screen with empty space, while forceExpand ensures all content is visible; please sanity-check on smaller screens and landscape so the continue button remains fully accessible.

build.gradle (1)

3-8: Switching dppVersion to a released version improves build stability

Using 2.0.2 instead of a SNAPSHOT should make builds more reproducible; just confirm this exact version is published and resolvable from your Maven repositories before merging.

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/ui/dashspend/dialogs/GiftCardDetailsViewModel.kt (1)

500-529: Preserving gift card notes on metadata updates makes sense

Stopping the explicit note = null in both updateGiftCard overloads means existing notes (or provider order IDs) will no longer be cleared when card numbers or URLs are saved, which is safer for user/context data while leaving other behavior unchanged. Based on learnings, this aligns with how notes are used for gift card metadata.

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/CTXSpendRepository.kt (1)

205-217: Using response.discount in getMerchant aligns with new JSON schema

Routing the stored savingsPercentage through response.discount ensures per-user discounts are honored when present while preserving existing behavior when only the legacy field is set; please validate this against a couple of real CTX staging responses (with and without userDiscount) to confirm the precedence matches backend expectations.

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/DashSpendRepositoryFactory.kt (1)

46-53: LGTM! Constructor parameter properly propagated.

The updated RemoteDataSource instantiation correctly passes the injected walletDataProvider, enabling network-aware URL resolution for the CTX staging environment.

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/network/RemoteDataSource.kt (3)

38-41: Constructor updated to support network-aware configuration.

The addition of WalletDataProvider enables dynamic URL resolution based on the wallet's network context.


61-74: Consistent URL resolution in token API.

Good consistency applying the same network-aware URL logic to the token API. The same verification and null safety considerations from buildApi apply here.


48-54: The original review comment's concerns about null safety are unfounded; both constants are properly defined and the code is correct.

The verification confirms:

  1. DEV_BASE_URL exists and is correct: Points to https://staging.spend.ctx.com/ in CTXSpendConstants.kt
  2. BASE_URL exists and is correct: Points to https://spend.ctx.com/ in CTXSpendConstants.kt
  3. No null safety issue: networkParameters is declared as a non-nullable property (NetworkParameters, not NetworkParameters?) in the WalletDataProvider interface

The network-aware URL selection logic at lines 48-54 is properly implemented with the correct constants and no defensive checks are needed.

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/di/ExploreDashModule.kt (1)

58-61: DI wiring correctly updated.

The provider method signature and RemoteDataSource instantiation properly reflect the constructor changes, enabling network-aware URL resolution through dependency injection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants