Skip to content

Bug Fixes on Gasless#412

Merged
vignesha22 merged 2 commits intostagingfrom
PRO-3735-Gasless_Fixes
Oct 1, 2025
Merged

Bug Fixes on Gasless#412
vignesha22 merged 2 commits intostagingfrom
PRO-3735-Gasless_Fixes

Conversation

@vignesha22
Copy link
Contributor

@vignesha22 vignesha22 commented Sep 30, 2025

Description

  • When it auto refreshes, the fee token address changes to the default first option even if user has selected another option so this PR addresses the issue on keeping the user selection as it is when it auto refreshes

How Has This Been Tested?

  • Tested Locally

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • New Features

    • Fee asset picker now restores your previously selected fee token when switching assets in Gasless mode, when available.
  • Bug Fixes

    • Prevents unintended reset of the selected fee asset during asset switches.
    • Honors the current fee asset in default selections, falling back only when necessary.
    • Improved stability of fee selection persistence across payload-driven flows and related contexts.
  • Chores

    • Reduced automatic portfolio refresh: removed periodic polling and refetch-on-focus for wallet portfolio queries.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

Preserves and stabilizes selected gasless fee asset by introducing an id on fee selections, rehydrating that selection across asset switches and payload-driven flows, and updating paymaster context; also disables polling/refetch-on-focus for wallet portfolio queries.

Changes

Cohort / File(s) Summary
SendModal — gasless fee identity & preservation
src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx
- Add id to selected fee asset state and to fee option objects
- Preserve/rehydrate selected gasless fee asset by matching id when switching assets
- Fall back to first gasless option if no match; propagate paymaster address/context accordingly
- Ensure payload-driven flows store and restore option id and use it for default selection
AccountModal — portfolio query options
src/components/BottomMenuModal/AccountModal.tsx
- Change useGetWalletPortfolioQuery options: remove pollingInterval and set refetchOnFocus: false (retain skip: !accountAddress)
AssetSelect — portfolio query options
src/components/Form/AssetSelect/index.tsx
- Change useGetWalletPortfolioQuery options: remove pollingInterval and set refetchOnFocus: false

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as SendModalTokensTabView
  participant Paymaster as PaymasterContext

  User->>UI: Switch selected asset (Gasless mode)
  UI->>UI: Build fee options for new asset (each with `id`)
  alt Option with matching selectedFeeAsset.id exists
    UI->>UI: Rehydrate selectedFeeAsset (id, token, decimals, price, balance)
    UI->>Paymaster: Sync paymasterContext / address for preserved selection
    UI-->>User: Keep previous fee selection
  else No matching id
    UI->>UI: Select first gasless fee option and set its id
    UI->>Paymaster: Sync paymasterContext / address for new selection
    UI-->>User: Update fee selection to default
  end
  Note over UI,Paymaster: Payload-driven flows store/propagate option `id` to preserve identity across steps
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Fixed Send Bug #347 — Modifies fee-asset handling and paymaster balance checks in the same SendModalTokensTabView area.
  • PRO-3185-Gas_Abstraction #308 — Related adjustments to paymaster/gasless fee-asset selection flow in SendModalTokensTabView.
  • QA Gasless fix #353 — Refactors fee initialization/clearing in SendModalTokensTabView affecting similar state paths.

Suggested reviewers

  • IAmKio
  • RanaBug

Poem

I hop with an id held tight,
Across token fields in moonlight.
Switch the asset, keep the tune—
Paymaster hums, selection’s kept soon.
A rabbit’s nod: no choice undone. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The pull request title “Bug Fixes on Gasless” is related to the changeset but remains overly generic and does not clearly convey the specific issue being fixed, which is the preservation of the user’s selected gasless fee token during auto-refresh. Please revise the title to clearly summarize the primary change, for example “Preserve selected gasless fee token on auto-refresh,” so that reviewers immediately understand the specific fix being proposed.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description follows the repository’s template by providing a description of the change, a testing section, and the types of changes, and it includes the optional screenshot header even if no images are necessary, making it mostly complete.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch PRO-3735-Gasless_Fixes

📜 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 941505d and 87be59f.

📒 Files selected for processing (3)
  • src/components/BottomMenuModal/AccountModal.tsx (1 hunks)
  • src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (5 hunks)
  • src/components/Form/AssetSelect/index.tsx (1 hunks)
⏰ 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). (3)
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: build
🔇 Additional comments (9)
src/components/Form/AssetSelect/index.tsx (1)

51-51: LGTM! Disabling auto-refresh to preserve user selections.

The removal of pollingInterval and setting refetchOnFocus: false prevents the portfolio data from automatically refreshing, which would reset the user's selected fee token. This change directly addresses the PR objective.

src/components/BottomMenuModal/AccountModal.tsx (1)

69-69: LGTM! Consistent with asset selection refresh behavior.

This change mirrors the portfolio query configuration in AssetSelect, ensuring a consistent data-fetching cadence across the application and preventing unwanted resets of user state.

src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (7)

167-167: LGTM! Adding stable identity to fee asset state.

The addition of the id field to selectedFeeAsset enables stable identity tracking across asset switches and auto-refreshes, which is essential for preserving the user's selection.


205-205: LGTM! Consistent query configuration.

Setting refetchOnFocus: false aligns with the changes in AssetSelect and AccountModal, preventing unwanted data refreshes that could interfere with user selections.


2313-2313: LGTM! Proper default selection logic.

The default selection prioritizes the user's currently selected fee asset by id, falling back to the first option when none is selected. This correctly implements the preservation behavior.


2184-2202: LGTM! Capturing id on user selection.

The handleOnChange callback correctly captures and stores the id field (line 2196) when the user selects a fee asset, enabling the preservation logic to work across asset switches.


299-299: LGTM! Well-structured composite id.

The fee option id includes gasToken, chainId, paymasterAddress, and decimals, providing a unique and stable identifier for each fee asset option.


357-357: LGTM! Consistent id propagation in fallback.

When falling back to the first gasless option, the code correctly sets selectedFeeAsset.id, maintaining consistency with the preservation logic.


330-351: Address comparison logic is sound. selectedFeeAsset.token is consistently initialized from feeOption.asset.contract or parsed from the option’s id—both valid contract addresses—so the case-insensitive .toLowerCase() match reliably preserves the user’s selection.


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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 30, 2025

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 87be59f
Status: ✅  Deploy successful!
Preview URL: https://1570ff4e.x-e62.pages.dev
Branch Preview URL: https://pro-3735-gasless-fixes.x-e62.pages.dev

View logs

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 (1)
src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (1)

330-351: Preserves user's fee token selection correctly.

The logic successfully addresses the PR objective by:

  • Detecting when a fee asset was previously selected by the user
  • Searching for a matching option in the new asset's available fee options
  • Restoring the selection if found, otherwise falling back to the first option

The case-insensitive contract address matching is appropriate.

Optional enhancement: Consider chain-specific validation.

If assets can be switched across different chains, you might want to verify that the matched fee asset is valid for the current chain:

  const userSelectedOption = feeOptions.find(value => value.asset.contract.toLowerCase() === selectedFeeAsset.token.toLowerCase());
- if (userSelectedOption) {
+ if (userSelectedOption && userSelectedOption.chainId === selectedAsset.chainId) {
    // Keep user's selected fee asset

This prevents attempting to use a fee asset from a different chain.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5acb28e and 941505d.

📒 Files selected for processing (1)
  • src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (4 hunks)
⏰ 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: lint
  • GitHub Check: unit-tests
🔇 Additional comments (4)
src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (4)

162-168: LGTM: id field added to track fee asset identity.

The addition of the id field to selectedFeeAsset enables precise matching and restoration of user's fee token selection across asset switches.


352-358: LGTM: Consistent id propagation for default selection.

The id field is correctly populated when falling back to the first fee option, ensuring consistency across both user-driven and default selections.


2184-2197: LGTM: Captures id when user changes fee asset selection.

The id field is correctly populated when the user explicitly selects a different fee asset, enabling preservation of this choice across subsequent asset switches.


2313-2313: LGTM: Applies preserved fee asset id to UI selection.

The defaultSelectedId now correctly uses the preserved selectedFeeAsset?.id, ensuring the user's fee token choice is reflected in the dropdown after asset switches. The fallback to feeAssetOptions[0]?.id maintains safe default behavior.

@IAmKio
Copy link
Collaborator

IAmKio commented Sep 30, 2025

@vignesha22 can we also turn off portolio refresh on focus?

@vignesha22 vignesha22 merged commit 023de75 into staging Oct 1, 2025
5 of 6 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 1, 2025
3 tasks
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