Skip to content

feat(client-utils): map ramps orders into the shared activity item shape#9650

Open
wenfix wants to merge 3 commits into
mainfrom
wenfix/ramps-activity
Open

feat(client-utils): map ramps orders into the shared activity item shape#9650
wenfix wants to merge 3 commits into
mainfrom
wenfix/ramps-activity

Conversation

@wenfix

@wenfix wenfix commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Explanation

Ramps (buy/sell) orders currently have no representation in the shared, cross-client ActivityItem model 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:

  • Adds 'rampBuy' | 'rampSell' to ActivityKind and a matching arm to the ActivityItem union, covering the order's fiat/token amounts, fee, provider info (id/name/link), status description, and manual-payment details.
  • Adds an optional id field to the shared ActivityData base type. A pending ramp order has an empty txHash (no on-chain tx exists yet while awaiting fiat settlement), so consumers need a stable identifier to key list rows / open details before settlement. id is populated only for rampBuy/rampSell (from the provider's order id) and left undefined for every other kind — no behavior change for existing consumers.
  • Adds mapRampsOrder, a pure mapper (following the existing mapLocalTransaction/mapApiTransaction/mapKeyringTransaction pattern) that normalizes a ramps order into an ActivityItem, mapping the 8-value RampsOrderStatus down to the existing 4-value Status.
  • The mapper's input type (RampsOrderLike) redeclares the narrow subset of RampsOrder (from @metamask/ramps-controller) it needs, rather than importing it — client-utils and ramps-controller don't depend on each other today, and this keeps it that way.
  • Chain id normalization is chain-agnostic: it reuses the existing formatChainIdToCaip helper (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 assumes eip155 for a bare numeric/hex reference (today's only observed format from the ramps API).

References

Extension-side wiring (activity list, TemplateLoader case, new details template, deleting the standalone ramps order route) is a separate PR, gated on this one publishing first.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

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 / rampSell to the shared ActivityItem model plus mapRampsOrder, 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 Status values, normalizes chain ids via formatChainIdToCaip, and treats empty txHash as no on-chain hash yet. ActivityItem gains an optional id (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.

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>
@wenfix
wenfix requested review from a team as code owners July 24, 2026 12:37
@wenfix
wenfix temporarily deployed to default-branch July 24, 2026 12:37 — with GitHub Actions Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread packages/client-utils/src/mappers/ramps-order-mapper.ts Outdated
- 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>
@wenfix

wenfix commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-previews

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@7.5.5-preview-5ae42f53d
@metamask-previews/accounts-controller@39.0.5-preview-5ae42f53d
@metamask-previews/address-book-controller@7.1.2-preview-5ae42f53d
@metamask-previews/ai-controllers@0.8.0-preview-5ae42f53d
@metamask-previews/analytics-controller@1.2.1-preview-5ae42f53d
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-5ae42f53d
@metamask-previews/announcement-controller@8.1.0-preview-5ae42f53d
@metamask-previews/app-metadata-controller@2.0.1-preview-5ae42f53d
@metamask-previews/approval-controller@9.0.2-preview-5ae42f53d
@metamask-previews/assets-controller@11.2.0-preview-5ae42f53d
@metamask-previews/assets-controllers@110.0.0-preview-5ae42f53d
@metamask-previews/authenticated-user-storage@3.0.1-preview-5ae42f53d
@metamask-previews/base-controller@9.1.0-preview-5ae42f53d
@metamask-previews/base-data-service@0.1.3-preview-5ae42f53d
@metamask-previews/bitcoin-regtest-up@1.0.0-preview-5ae42f53d
@metamask-previews/bridge-controller@78.0.0-preview-5ae42f53d
@metamask-previews/bridge-status-controller@74.5.0-preview-5ae42f53d
@metamask-previews/build-utils@3.0.4-preview-5ae42f53d
@metamask-previews/chain-agnostic-permission@1.7.0-preview-5ae42f53d
@metamask-previews/chomp-api-service@4.0.0-preview-5ae42f53d
@metamask-previews/claims-controller@0.5.3-preview-5ae42f53d
@metamask-previews/client-controller@1.0.1-preview-5ae42f53d
@metamask-previews/client-utils@1.2.1-preview-5ae42f53d
@metamask-previews/compliance-controller@2.1.0-preview-5ae42f53d
@metamask-previews/composable-controller@12.0.1-preview-5ae42f53d
@metamask-previews/config-registry-controller@0.4.1-preview-5ae42f53d
@metamask-previews/connectivity-controller@0.3.0-preview-5ae42f53d
@metamask-previews/controller-utils@12.3.0-preview-5ae42f53d
@metamask-previews/core-backend@7.0.0-preview-5ae42f53d
@metamask-previews/delegation-controller@3.0.2-preview-5ae42f53d
@metamask-previews/earn-controller@12.2.2-preview-5ae42f53d
@metamask-previews/eip-5792-middleware@3.0.5-preview-5ae42f53d
@metamask-previews/eip-7702-internal-rpc-middleware@0.1.1-preview-5ae42f53d
@metamask-previews/eip1193-permission-middleware@2.0.1-preview-5ae42f53d
@metamask-previews/ens-controller@19.1.5-preview-5ae42f53d
@metamask-previews/eth-block-tracker@15.0.1-preview-5ae42f53d
@metamask-previews/eth-json-rpc-middleware@23.1.3-preview-5ae42f53d
@metamask-previews/eth-json-rpc-provider@6.0.1-preview-5ae42f53d
@metamask-previews/foundryup@1.0.1-preview-5ae42f53d
@metamask-previews/gas-fee-controller@26.3.0-preview-5ae42f53d
@metamask-previews/gator-permissions-controller@4.2.3-preview-5ae42f53d
@metamask-previews/geolocation-controller@0.1.3-preview-5ae42f53d
@metamask-previews/java-tron-up@1.0.0-preview-5ae42f53d
@metamask-previews/json-rpc-engine@10.5.0-preview-5ae42f53d
@metamask-previews/json-rpc-middleware-stream@8.0.8-preview-5ae42f53d
@metamask-previews/keyring-controller@27.1.0-preview-5ae42f53d
@metamask-previews/local-node-utils@1.0.0-preview-5ae42f53d
@metamask-previews/logging-controller@8.0.2-preview-5ae42f53d
@metamask-previews/message-manager@14.1.2-preview-5ae42f53d
@metamask-previews/messenger@2.0.0-preview-5ae42f53d
@metamask-previews/messenger-cli@0.2.0-preview-5ae42f53d
@metamask-previews/money-account-api-data-service@0.3.0-preview-5ae42f53d
@metamask-previews/money-account-balance-service@2.3.0-preview-5ae42f53d
@metamask-previews/money-account-controller@0.3.3-preview-5ae42f53d
@metamask-previews/money-account-upgrade-controller@3.0.0-preview-5ae42f53d
@metamask-previews/multichain-account-service@13.0.0-preview-5ae42f53d
@metamask-previews/multichain-api-middleware@4.0.1-preview-5ae42f53d
@metamask-previews/multichain-network-controller@3.2.1-preview-5ae42f53d
@metamask-previews/multichain-transactions-controller@7.1.1-preview-5ae42f53d
@metamask-previews/name-controller@9.1.2-preview-5ae42f53d
@metamask-previews/network-connection-banner-controller@0.1.0-preview-5ae42f53d
@metamask-previews/network-controller@34.0.0-preview-5ae42f53d
@metamask-previews/network-enablement-controller@5.6.0-preview-5ae42f53d
@metamask-previews/notification-services-controller@26.0.0-preview-5ae42f53d
@metamask-previews/passkey-controller@3.0.0-preview-5ae42f53d
@metamask-previews/permission-controller@13.1.1-preview-5ae42f53d
@metamask-previews/permission-log-controller@5.1.0-preview-5ae42f53d
@metamask-previews/perps-controller@10.0.0-preview-5ae42f53d
@metamask-previews/phishing-controller@17.3.0-preview-5ae42f53d
@metamask-previews/platform-api-docs@0.0.0-preview-5ae42f53d
@metamask-previews/polling-controller@16.0.8-preview-5ae42f53d
@metamask-previews/preferences-controller@23.1.0-preview-5ae42f53d
@metamask-previews/profile-metrics-controller@4.0.2-preview-5ae42f53d
@metamask-previews/profile-sync-controller@28.3.0-preview-5ae42f53d
@metamask-previews/ramps-controller@17.1.0-preview-5ae42f53d
@metamask-previews/rate-limit-controller@7.0.1-preview-5ae42f53d
@metamask-previews/react-data-query@0.2.2-preview-5ae42f53d
@metamask-previews/remote-feature-flag-controller@4.2.2-preview-5ae42f53d
@metamask-previews/sample-controllers@5.0.3-preview-5ae42f53d
@metamask-previews/seedless-onboarding-controller@10.1.0-preview-5ae42f53d
@metamask-previews/selected-network-controller@26.1.5-preview-5ae42f53d
@metamask-previews/sentinel-api-service@1.0.0-preview-5ae42f53d
@metamask-previews/shield-controller@5.1.3-preview-5ae42f53d
@metamask-previews/signature-controller@39.2.7-preview-5ae42f53d
@metamask-previews/smart-transactions-controller@25.0.1-preview-5ae42f53d
@metamask-previews/snap-account-service@2.0.0-preview-5ae42f53d
@metamask-previews/social-controllers@2.6.0-preview-5ae42f53d
@metamask-previews/solana-test-validator-up@1.0.0-preview-5ae42f53d
@metamask-previews/stellar-quickstart-up@0.0.0-preview-5ae42f53d
@metamask-previews/storage-service@1.0.2-preview-5ae42f53d
@metamask-previews/subscription-controller@6.2.1-preview-5ae42f53d
@metamask-previews/transaction-controller@69.2.1-preview-5ae42f53d
@metamask-previews/transaction-pay-controller@26.0.0-preview-5ae42f53d
@metamask-previews/user-operation-controller@41.2.7-preview-5ae42f53d
@metamask-previews/wallet@8.1.0-preview-5ae42f53d
@metamask-previews/wallet-cli@0.0.0-preview-5ae42f53d

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>
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.

1 participant