feat(asset-details): add Quick Buy entry point to Token Details sticky footer#30725
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
There was a problem hiding this comment.
There was a problem hiding this comment.
Icon has been added 🎉
Can we have a followup to remove this and use the MMDS lib?
There was a problem hiding this comment.
Yes, I have the change ready in a local branch already :) Will follow-up with it
9af9d4b to
1be4ad0
Compare
40a41ff to
f8279de
Compare
| onSwapPress, | ||
| onBuyPress, | ||
| onQuickBuyPress, | ||
| quickBuyTestID, |
There was a problem hiding this comment.
Not sure why we pass down the test id, shouldnt we just hardcode it?
There was a problem hiding this comment.
It's passed down on purpose because TokenDetailsStickyFooter is a shared component rendered by multiple different screens, and each screen needs its buttons to carry a different testID so E2E tests can target the right screen.
hjetpoluru
left a comment
There was a problem hiding this comment.
e2e related file changes lgtm
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 007886a. Configure here.
…y footer Adds a third lightning-bolt button to the Token Details sticky footer that opens the existing Quick Buy bottom sheet (previously only reachable from Top Traders positions). Generalizes the Quick Buy module so `QuickBuyTarget.chain` is a canonical `CaipChainId` rather than a Social-API position chain name. Each host (Top Traders, Asset Details) now normalizes its chain id into CAIP at the boundary, decoupling the Quick Buy core from host-specific shapes. The filled lightning icon is shipped temporarily as a local SVG asset pending the upstream `IconName.FlashFilled` addition in the MetaMask Design System. Co-authored-by: Cursor <cursoragent@cursor.com>
- Updated tests for AssetDetailsQuickBuy to ensure it mounts hidden by default with the current token. - Added a test to verify that the Quick Buy button opens the AssetDetailsQuickBuy when pressed. - Changed the assertion method for checking the presence of the Quick Buy button in TokenDetailsStickyFooter to use `toBeOnTheScreen()` for better clarity.
- Added a new selector to manage the visibility of the Quick Buy feature in the TokenDetails component. - Updated the TokenDetails component to conditionally render the AssetDetailsQuickBuy based on the feature flag. - Enhanced tests to verify the behavior of the Quick Buy button when the feature is enabled or disabled, ensuring it does not mount when disabled. - Introduced unit tests for the new selector to validate its functionality against various scenarios.
…iant - Updated the TokenDetails component to use the new selector `selectSocialAiAssetDetailsQuickBuyEnabled` instead of the deprecated `selectAssetDetailsShowQuickBuyEnabled`. - Removed the old selector and its associated tests to streamline the feature flag management for Quick Buy functionality. - Adjusted tests to ensure they reflect the changes in the selector and maintain expected behavior.
…o feature flag constants - Introduced a new feature flag constant for the Social AI Asset Details Quick Buy functionality in the known feature flag constants file. - Updated the feature flag registry to include the new flag, ensuring it is set to active and configured for production use.
- Added tracking for trade submission and completion events in the Quick Buy controller, allowing analytics to capture when trades are submitted and completed. - Updated the trade properties to conditionally include the trader's address based on context, ensuring accurate analytics reporting for both trader and non-trader scenarios. - Enhanced unit tests to verify the correct behavior of trade-level analytics, ensuring that the tracking functions are called with the expected parameters.
…orts - Updated the TokenDetails component to improve Quick Buy integration, including the addition of new imports for better functionality. - Refactored the TokenDetailsStickyFooter to ensure the FlashFilledIcon is correctly imported and utilized. - Cleaned up unused imports and organized the code structure for better readability and maintainability. - Enhanced unit tests to verify the correct behavior of the Quick Buy feature in various scenarios.
- Refactored imports in the TokenDetailsStickyFooter and QuickBuy components for improved organization and readability. - Enhanced unit tests for TraderPositionQuickBuy and useQuickBuyController to ensure accurate functionality and coverage. - Updated the Quick Buy setup logic to streamline the integration with Redux and improve performance. - Cleaned up unused imports and optimized the code structure across multiple files.
Replace the local flash-filled.svg with the design system Icon (IconName.FlashFilled) in the sticky footer quick buy button and drop the now-obsolete asset and its test mock. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- Updated the target calculation in AssetDetailsQuickBuy to read only the necessary primitive fields from the token, preventing unnecessary re-fetches of quotes. - Improved dependency array in useMemo to include only relevant fields, enhancing performance and stability of the component.
…27.0" This reverts commit f8279de.
… flash" This reverts commit 2cca92e.
The asset details quick buy target required address, symbol and name to all be defined, so native assets (e.g. ETH) whose route params lack a name produced a null target and the sheet never opened. Only require chainId and address, falling back to symbol for the display name. Co-authored-by: Cursor <cursoragent@cursor.com>
…tests - Reordered imports in `QuickBuyContext.test.tsx` for consistency. - Updated the chain identifier from 'base' to 'eip155:8453' in the mock target to reflect the correct blockchain context.
007886a to
20916ce
Compare
- Added unit tests to verify that the AssetDetailsQuickBuy component correctly passes a null target when the token address is either an empty string or null. - Updated the target calculation logic to ensure it handles these cases appropriately.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #30725 +/- ##
========================================
Coverage 82.72% 82.72%
========================================
Files 5566 5575 +9
Lines 143286 143474 +188
Branches 33099 33163 +64
========================================
+ Hits 118529 118685 +156
- Misses 16870 16883 +13
- Partials 7887 7906 +19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
juanmigdr
left a comment
There was a problem hiding this comment.
LGTM, found these issues while testing (Audio ON) but @xavier-brochard has said that he will fix them all in an upcoming PR

Description
Adds a Quick Buy entry point to the Token (Asset) Details screen as a third icon button (a filled lightning bolt) in the sticky footer, next to the existing Buy/Sell and Swap actions. Tapping it opens the existing Quick Buy bottom sheet — the same UX that Top Traders positions launch today — pre-targeted at the token currently being viewed.
To make this reuse clean, the Quick Buy module is generalized so its core no longer depends on Social-API position shapes. Each host (Top Traders, Asset Details) becomes responsible for normalizing its chain id into a canonical
CaipChainIdat the adapter layer.Why
QuickBuyTargetshape regardless of where it was invoked from.What changed
Quick Buy core (generalization, no behavior change)
QuickBuyTarget.chainis nowCaipChainId(was a Social-API chain name string).useQuickBuyControlleranduseQuickBuySetupconsumetarget.chainas CAIP directly — no more internalchainNameToIdlookup.TraderPositionQuickBuy(the existing host adapter) does the position-name → CAIP conversion locally viapositionToQuickBuyTarget, which now returnsQuickBuyTarget | nullwhen a chain name can't be mapped.createTargetto keep type-safety around the new nullable mapper).New Asset Details entry point
TokenDetailsStickyFootergains an optional third button rendered only whenonQuickBuyPressis provided. Styled as a 48×48 circular icon-only button with the success-accent color, matching the Figma spec for Swap-Next.AssetDetailsQuickBuyadapter mapsTokenDetailsRouteParams(TokenI-shaped) →QuickBuyTarget, normalizingchainIdto CAIP viaformatChainIdToCaipwith a safenullfallback when the chain can't be parsed.TokenDetails.tsxwires the visibility state and renders the adapter as an overlay.'asset_details'added toQuickBuySheetSource; sticky footer tracking gains a'quick_buy'CTA type.Icon (temporary)
flash-filled.svgrendered throughButtonAnimatedbecause the Design System doesn't yet exposeIconName.FlashFilled.@metamask/design-system-react-nativepublishes a new minor, a follow-up PR will replace the local SVG withIconName.FlashFilled.Out of scope
Views/SocialLeaderboard/TraderPositionView/components/QuickBuy. Relocating it to a feature-neutral folder is a separate refactor.nulltarget, which keeps the sheet inert; finer gating to be added if the analytics flag a problem post-launch.Changelog
CHANGELOG entry: Added a Quick Buy lightning-bolt button to the Asset Details screen for one-tap token purchases.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Made with Cursor
Note
Medium Risk
Reuses bridge/Quick Buy submit and quote paths with a new entry surface; changes are mostly behind a remote flag but still affect trade analytics and chain targeting contracts shared with Top Traders.
Overview
Adds a version-gated remote flag (
socialAiAssetDetailsQuickBuy) and, when enabled, a lightning Quick Buy control on Token Details that opens the existing Quick Buy sheet for the asset in view (haptics,asset_detailsanalytics, sticky footerquick_buyCTA).Introduces
AssetDetailsQuickBuyto map route token →QuickBuyTarget(CAIP chain viaformatChainIdToCaip,nulltarget when mapping fails). Generalizes Quick Buy soQuickBuyTarget.chainisCaipChainIdend-to-end; leaderboard mapping moves topositionToQuickBuyTarget(nullable for unknown chains). Trade/submit analytics can run without a trader address when entered from asset details.Temporary local
flash-filled.svguntil design-systemFlashFilledships.Reviewed by Cursor Bugbot for commit 9a87cb9. Bugbot is set up for automated code reviews on this repo. Configure here.