Skip to content

feat(geo): bouncer for privacy coin blocking#3150

Merged
CharlVS merged 32 commits intodevfrom
cursor/update-bouncer-for-privacy-coin-blocking-b618
Oct 1, 2025
Merged

feat(geo): bouncer for privacy coin blocking#3150
CharlVS merged 32 commits intodevfrom
cursor/update-bouncer-for-privacy-coin-blocking-b618

Conversation

@CharlVS
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS commented Sep 16, 2025

Update the geoblocking logic to utilise disallowed_features and disallowed_assets from the bouncer endpoint, and add a toggle to include blocked assets in private key exports.

The bouncer endpoint now provides disallowed_features and disallowed_assets to explicitly control trading and asset access by region. This PR updates the application to accommodate the new response structure, ensuring trading is blocked based on TRADING in disallowed_features, and allows users to export private keys for disallowed_assets. It also maintains backward compatibility with the blocked flag and respects the GEO_BLOCK=disabled environment variable.

Testing

  1. When in the UAE, privacy coins should not be visible except for in the private key export page, where, only if there are any disallowed assets, it shows a toggle to include the disallowed assets.
  2. Confirm no regressions in the region blocking for trading - under the hood, the code is entirely changed.

Open in Cursor Open in Web

Note

Adopts new bouncer disallowed_features/assets to drive trading/asset geo-blocking via a TradingStatusService, filters blocked assets across app flows, and adds a toggle to include blocked assets in private key exports.

  • Core Geo-Blocking:
    • Add TradingStatusService, TradingStatusApiProvider, AppGeoStatus, and DisallowedFeature to consume bouncer disallowed_features/disallowed_assets with polling and backoff.
    • Update TradingStatusRepository to parse new API, support streaming watch, and honor GEO_BLOCK=disabled.
    • Revamp TradingStatusBloc with load-success state, per-asset checks, and a watch event.
  • App Integration:
    • Initialize and provide TradingStatusService in main.dart; inject into CoinsRepo, CoinsBloc, AuthBloc.
    • CoinsBloc/Repo: wait for initial status and filter blocked assets in known coins, activation, balances, price fetches.
    • AuthBloc/Trezor flows: filter default/restored coins to exclude blocked assets before adding to metadata.
  • UI/UX:
    • Gate actions by state.isEnabled or canTradeAssets(...) in DEX, Bridge, MMBot, menus, wallet pages, and clock banner; filter lists (coins, orders, tickers) accordingly.
    • Private Keys: add toggle to include blocked assets in exports; expose via new "includeBlockedAssets" string.
  • Config/Locales:
    • Update geoBlockerApiUrl to /v1/ endpoint.
    • Add includeBlockedAssets i18n key and generated code.

Written by Cursor Bugbot for commit bf9ef01. This will update automatically on new commits. Configure here.

@cursor
Copy link
Copy Markdown

cursor bot commented Sep 16, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 16, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/update-bouncer-for-privacy-coin-blocking-b618

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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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

cursoragent and others added 2 commits September 16, 2025 15:24
Co-authored-by: charl <charl@vanstaden.info>
Co-authored-by: charl <charl@vanstaden.info>
@CharlVS CharlVS changed the title Update bouncer for privacy coin blocking feat(geo): bouncer for privacy coin blocking Sep 16, 2025
cursor[bot]

This comment was marked as outdated.

cursoragent and others added 2 commits September 17, 2025 11:30
Co-authored-by: charl <charl@vanstaden.info>
…es; remove field

- Replace AppGeoStatus(tradingEnabled: ...) with disallowedFeatures-based construction
- Remove tradingEnabled from TradingStatusLoadSuccess; compute isEnabled from disallowedFeatures
- Update TradingStatusBloc emission accordingly
- Set DisallowedFeature.trading in repository failure paths
- Remove unused _computeTradingEnabled helper
cursor[bot]

This comment was marked as outdated.

…g; use DisallowedFeature.trading\n\n- Add conservative guard to treat missing disallowed_features as trading blocked\n- Return AppGeoStatus with DisallowedFeature.trading when features are absent\n- Confirm no remaining references to deprecated 'blocked' field
@CharlVS CharlVS requested a review from Copilot September 19, 2025 13:34
Copy link
Copy Markdown
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 updates the geoblocking logic to use new disallowed_features and disallowed_assets fields from the bouncer endpoint instead of the legacy blocked flag. It adds functionality to include/exclude blocked assets in private key export and maintains backward compatibility.

Key changes:

  • Refactored trading status system to use structured geo status with disallowed features and assets
  • Added toggle for including blocked assets in private key export
  • Updated all trading status checks to use new state structure

Reviewed Changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/bloc/trading_status/trading_status_state.dart Replaced legacy TradingEnabled/TradingDisabled states with TradingStatusLoadSuccess containing disallowed features and assets
lib/bloc/trading_status/trading_status_repository.dart Complete rewrite to fetch structured geo status with disallowed features and assets parsing
lib/bloc/trading_status/trading_status_bloc.dart Updated to emit new state structure with disallowed features and assets
lib/bloc/trading_status/disallowed_feature.dart New enum for parsing disallowed features from API response
lib/views/settings/widgets/security_settings/private_key_settings/private_key_show.dart Added toggle and filtering logic for blocked assets in private key export
lib/views/settings/widgets/security_settings/security_settings_page.dart Integration to pass blocked asset symbols to private key export
Multiple UI files Updated trading status checks from is TradingEnabled to .isEnabled property
lib/shared/constants.dart Updated bouncer API URL to include version path
assets/translations/en.json Added translation for blocked assets toggle

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

CharlVS and others added 6 commits September 19, 2025 15:35
…cer rules

- Adjust clock warning banner behavior
- Update security settings screens for key viewing flow
- Align bridge and DEX confirmations/buttons with privacy coin restrictions
- Update market maker bot forms and wallet coin details buttons

These changes support privacy coin blocking bouncer logic and align UI flows accordingly.
…Revert formatting-only changes and resolve conflicts by keeping current branch content where conflicts occurred.
…3153)

* refactor(trading-status): split provider and repository

* feat(trading-status): add watcher service and coins repo/bloc filtering

* refactor(trading-status): improve status watch stream handling
…and resolve conflicts in coins bloc/repo; keep TradingStatusService filtering and SDK wallet coin IDs for prices/activation
@CharlVS CharlVS marked this pull request as ready for review September 23, 2025 20:20
@CharlVS CharlVS requested a review from gcharang September 23, 2025 20:20
@CharlVS CharlVS self-assigned this Sep 23, 2025
@CharlVS CharlVS added the QA Ready for QA Testing label Sep 23, 2025
@CharlVS CharlVS requested a review from smk762 September 23, 2025 20:25
@smk762
Copy link
Copy Markdown
Collaborator

smk762 commented Sep 26, 2025

Using Dubai VPN:

  • After login with prior imported wallet, FIRO/LTC not found in activation list, nor in activated coins list. ✅

  • After newly imported wallet, FIRO/LTC not found in activation list, nor in activated coins list. ✅

  • After newly created wallet, FIRO/LTC not found in activation list, nor in activated coins list. ✅

  • LTC-segwit seen in priv key export, but not regular LTC or FIRO. Assumed this may\ have been determined based on local storage / balance, but same is seen with newly created wallet with no prior activity. 🦧

  • LTC seen in coins list prior to login (but not LTC-segwit). Searching for segwit shows compatible coins, without segwit suffix. FIRO also seen in list prior to login. Geoblock filtering fails here. 🧇

@CharlVS CharlVS requested review from gcharang and smk762 and removed request for gcharang and smk762 September 30, 2025 08:45
cursor[bot]

This comment was marked as outdated.

@smk762
Copy link
Copy Markdown
Collaborator

smk762 commented Sep 30, 2025

  • LTC-segwit seen in priv key export, but not regular LTC or FIRO. Assumed this may\ have been determined based on local storage / balance, but same is seen with newly created wallet with no prior activity. 🦧
  • LTC seen in coins list prior to login (but not LTC-segwit). Searching for segwit shows compatible coins, without segwit suffix. FIRO also seen in list prior to login. Geoblock filtering fails here. 🧇

The above still applies with the following modifications:

  • LTC, LTC-segwit, and FIRO all seen in priv key export
  • LTC in coins list prior to login. FIRO no longer seen before or after login (except in privkey export)

- Fix private key export to filter blocked assets before fetching keys
- Fix race condition in CoinsBloc by waiting for initial trading status
- Filter blocked assets from default coins during wallet creation/restoration
- Prevent blocked assets from being added to wallet metadata
- Apply filtering in Trezor wallet setup flow

This ensures geo-blocked privacy coins (LTC, LTC-segwit, FIRO) are
completely excluded from:
- Wallet metadata and config
- Coin activation on login
- Private key export
- Pre-login coins display
- All user-facing features

Fixes issues reported in PR #3150
Document potential future improvements to reduce startup time:
- Start with unrestricted state, apply filters when API responds
- Populate coins immediately, filter reactively on status updates
- Add all coins to metadata, remove blocked ones post-confirmation

Trade-off: Faster startup (~100-500ms improvement) vs. brief exposure
of potentially blocked assets during initial API call.

These optimizations would require:
- Reactive UI updates to handle dynamic asset removal
- Coordinated metadata cleanup when trading status changes
- Handling edge cases for manually re-added blocked coins
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 30, 2025

Visit the preview URL for this PR (updated for commit bf9ef01):

https://walletrc--pull-3150-merge-v1zqkz4f.web.app

(expires Tue, 07 Oct 2025 15:11:53 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc

cursor[bot]

This comment was marked as outdated.

The private key fetch operation was filtering out geo-blocked assets before
they reached the PrivateKeyShow component, making the 'Include blocked assets'
toggle ineffective. Now only NFT assets are filtered during fetch, allowing
the UI component to control blocked asset visibility through the toggle.
cursor[bot]

This comment was marked as outdated.

Replace context.read with context.watch for TradingStatusBloc state access
to enable automatic UI rebuilds when geo-blocking or other trading status
restrictions change. This allows filtered asset and protocol lists to update
dynamically without manual intervention.
- Wrapped build methods with BlocBuilder<TradingStatusBloc> in coins_table_content, orders_table_content, and coin_selection_and_amount_input
- Fixed bug where filtered coin/order lists didn't update when geo-blocking status changed
- Added comprehensive documentation of BLoC anti-patterns in table_utils
- Documented tech debt: utility functions using context.read in build methods
- Recommended refactor: move filtering logic into respective Blocs following SOLID principles

The issue was caused by using context.read<TradingStatusBloc>() which doesn't establish a subscription to state changes. Now widgets properly rebuild when trading status updates.
@GLEECBTC GLEECBTC deleted a comment from github-actions bot Sep 30, 2025
The FEEDBACK_API_KEY was only being passed to builds when both Trello
credentials and Cloudflare credentials were present. This caused CI
builds to disable trading when Trello credentials were missing, even
if the FEEDBACK_API_KEY was available.

Changed the condition to only require FEEDBACK_API_KEY and
FEEDBACK_PRODUCTION_URL to be present, independent of Trello
configuration. This allows CI builds to properly enable trading
based on geo-status checks when the feedback API credentials are
configured.

Updated both the GitHub Actions workflow and Docker build script
to use the corrected logic.
Previously, canTradeAssets treated null asset IDs as blocked, causing
trading to incorrectly show as disabled when coins weren't selected
yet in forms (taker, maker, bridge, market maker bot).

The fix filters out null values using whereType<AssetId>() before
checking if assets are blocked, so trading status is only determined
by the general trading feature flag and actually selected assets.

Also fixed props getter to include isEnabled for proper state comparison.
Copy link
Copy Markdown
Collaborator

@smk762 smk762 left a comment

Choose a reason for hiding this comment

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

Filtering applied as expected in blocked region.
Unable to test in desktop due to login issue reported in internal chat, but as that issue affects all current PRs, it is not isolated to this one and outside scope..

@CharlVS CharlVS merged commit d33ba24 into dev Oct 1, 2025
7 of 14 checks passed
@CharlVS CharlVS deleted the cursor/update-bouncer-for-privacy-coin-blocking-b618 branch October 1, 2025 12:04
@CharlVS CharlVS mentioned this pull request Oct 5, 2025
@smk762 smk762 mentioned this pull request Nov 23, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA Ready for QA Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants