feat(client-utils): map ramps orders into the shared activity item shape#9650
Open
wenfix wants to merge 3 commits into
Open
feat(client-utils): map ramps orders into the shared activity item shape#9650wenfix wants to merge 3 commits into
wenfix wants to merge 3 commits into
Conversation
Add `mapRampsOrder` and `rampBuy`/`rampSell` `ActivityKind`s so ramps buy/sell orders can appear in the generic activity list and open through the same details pipeline as Send/Swap/Bridge, instead of a bespoke order-details page. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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 d042e19. Configure here.
- Fix changelog entry to link the actual PR (#9650) instead of a placeholder - Reformat ramps-order-mapper.ts import order per oxfmt (lint:misc:check) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
The V2 API returns orderType uppercased ('BUY'/'SELL'); only the client's
own locally-created stub order (RampsController.addPrecreatedOrder) uses
lowercase. The strict 'buy' comparison misclassified every real buy order
as rampSell with an outbound token direction.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Explanation
Ramps (buy/sell) orders currently have no representation in the shared, cross-client
ActivityItemmodel that Send/Swap/Bridge/etc. already use, so consumers (extension, mobile) have had to maintain bespoke, order-specific UI to show them instead of the generic activity list and details pipeline.This PR:
'rampBuy' | 'rampSell'toActivityKindand a matching arm to theActivityItemunion, covering the order's fiat/token amounts, fee, provider info (id/name/link), status description, and manual-payment details.idfield to the sharedActivityDatabase type. A pending ramp order has an emptytxHash(no on-chain tx exists yet while awaiting fiat settlement), so consumers need a stable identifier to key list rows / open details before settlement.idis populated only forrampBuy/rampSell(from the provider's order id) and leftundefinedfor every other kind — no behavior change for existing consumers.mapRampsOrder, a pure mapper (following the existingmapLocalTransaction/mapApiTransaction/mapKeyringTransactionpattern) that normalizes a ramps order into anActivityItem, mapping the 8-valueRampsOrderStatusdown to the existing 4-valueStatus.RampsOrderLike) redeclares the narrow subset ofRampsOrder(from@metamask/ramps-controller) it needs, rather than importing it —client-utilsandramps-controllerdon't depend on each other today, and this keeps it that way.formatChainIdToCaiphelper (already used elsewhere in this package for Solana/Bitcoin/Stellar-aware mappers) rather than hardcoding an EVM namespace, so it passes through an already-CAIP-formatted chain id unchanged and only assumeseip155for a bare numeric/hex reference (today's only observed format from the ramps API).References
Extension-side wiring (activity list,
TemplateLoadercase, new details template, deleting the standalone ramps order route) is a separate PR, gated on this one publishing first.Checklist
Note
Low Risk
Additive types and a pure mapper in client-utils; no auth or runtime behavior changes for existing activity kinds beyond optional
id.Overview
Adds
rampBuy/rampSellto the sharedActivityItemmodel plusmapRampsOrder, so fiat on/off-ramp orders can use the same activity list/details pipeline as sends and swaps instead of bespoke UI.The mapper normalizes provider orders (buy/sell, status, fiat/token amounts, fees, provider metadata, payment details) into that shape, maps ramps statuses to the existing four
Statusvalues, normalizes chain ids viaformatChainIdToCaip, and treats emptytxHashas no on-chain hash yet.ActivityItemgains an optionalid(provider order id) for pending orders that lack a hash; other activity kinds are unchanged.Reviewed by Cursor Bugbot for commit b2bfbe4. Bugbot is set up for automated code reviews on this repo. Configure here.