Skip to content

Conversation

@shoom3301
Copy link
Collaborator

@shoom3301 shoom3301 commented Dec 26, 2025

Summary

Fixes #6748

This is a final PR in the series of 1, 2.

Changes:

  1. At some point, I realized that computeOrderSummary was not actually in use in ActivityDetails component. If was added to ! isOrder block, so I deleted it.
  2. After that, it turned out that computeOrderSummary is only used in CancellationModal. I remembered that we have OrderSummary component, which is almost the same with computeOrderSummary, so I decided to replace it in CancellationModal.
  3. Another place where <OrderSummary> is uses is <OrderNotification>. I never liked that component because of it's complexity, so I decided to refactor it. One of the goals is to use useUltimateOrder()
    in this component in order to have all necessary data to display a summary of any kind of order (Swap, Bridge, Twap, etc.). It's also a part of fixing Near: handle amounts on cancelled/expired swap and bridge orders #6748
  4. The most problematic case of <OrderNotification> is "Order submitted", because only in that case we don't have an order in store at the moment (because we just created it). To simplify that, I split WIDGET_EVENT_EMITTER and ORDER_STATUS_EVENT_EMITTER. Before we were using WIDGET_EVENT_EMITTER for several responsibilities, which is not good.
image Screenshot 2025-12-29 at 14 49 17

To Test

  1. Near: handle amounts on cancelled/expired swap and bridge orders #6748
  2. All order status notifications (Created, Presigned, Filled, Bridge filled, Canceled, Expired)
  3. Retest fix: ethflow order showing up as WETH in notification #6676

Summary by CodeRabbit

  • New Features

    • Added a typed order status event stream and a dedicated event emitter for order lifecycle events.
    • New notification components to render posted/fulfilled/bridging order toasts with richer order details.
  • Refactor

    • Reworked order notification flow to use unified status events and a consolidated notification content component.
    • Order summary and cancellation dialogs now accept richer, composable content for clearer summaries.
  • Documentation

    • Updated translation keys and removed obsolete "submitted" entry.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
cowfi Ready Ready Preview Dec 30, 2025 11:59am
explorer-dev Ready Ready Preview Dec 30, 2025 11:59am
swap-dev Ready Ready Preview Dec 30, 2025 11:59am
widget-configurator Ready Ready Preview Dec 30, 2025 11:59am
2 Skipped Deployments
Project Deployment Review Updated (UTC)
cosmos Ignored Ignored Dec 30, 2025 11:59am
sdk-tools Ignored Ignored Preview Dec 30, 2025 11:59am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

Walkthrough

Refactors order summary rendering from strings to React components, adds a typed OrderStatusEvents emitter, replaces CowWidget event wiring with ORDER_STATUS_EVENT_EMITTER, and restructures order notification components to use useUltimateOrder and OrderNotificationContent.

Changes

Cohort / File(s) Summary
Cancellation modal & summary types
apps/cowswap-frontend/src/common/containers/CancellationModal/index.tsx, apps/cowswap-frontend/src/common/pure/CancellationModal/index.tsx, apps/cowswap-frontend/src/common/pure/CancellationModal/types.ts
Switched summary types from string to ReactNode; CancellationModal now renders <OrderSummary /> using getUltimateOrderTradeAmounts.
OrderSummary component
apps/cowswap-frontend/src/common/pure/OrderSummary/index.tsx
Broadened props to accept `TradeAmounts
Order trade utilities
apps/cowswap-frontend/src/common/updaters/orders/utils.ts
Removed UI-formatting helpers (computeOrderSummary, getOrderSummary, stringifyAmount); added getUltimateOrderTradeAmounts(UltimateOrderData) returning TradeAmounts.
Order event system
apps/cowswap-frontend/src/modules/orders/events/events.ts, apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts
New OrderStatusEvents enum, typed payload map and ORDER_STATUS_EVENT_EMITTER singleton.
Emitters — double emission
apps/cowswap-frontend/src/modules/orders/utils/emit*.ts (posted/fulfilled/cancelled/expired/presigned/bridging)
All emitters now also emit corresponding OrderStatusEvents to ORDER_STATUS_EVENT_EMITTER; emitPostedOrderEvent refactored to include typed input/output CurrencyAmounts and orderDetails.
Notification components & types
apps/cowswap-frontend/src/modules/orders/types.ts, apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/index.tsx, apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/index.tsx, apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/utils.ts, apps/cowswap-frontend/src/modules/orders/containers/PostedOrderNotification/index.tsx
Added OrderNotificationInfo type; refactored OrderNotification to use useUltimateOrder, useTradeChainsInfo, and delegate rendering to new OrderNotificationContent. Added PostedOrderNotification to map posted payloads. Centralized toast callback util.
Handlers & updater wiring
apps/cowswap-frontend/src/modules/orders/updaters/OrdersNotificationsUpdater/handlers.tsx, apps/cowswap-frontend/src/modules/orders/updaters/OrdersNotificationsUpdater/index.tsx
Rewired handlers to OrderStatusEvents/OrderStatusEventPayloadMap, use ORDER_STATUS_EVENT_EMITTER, simplified handlers (use PostedOrderNotification), removed obsolete handlers.
Removed legacy utils/components
apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/utils.ts (deleted), apps/cowswap-frontend/src/modules/orders/pure/PendingOrderNotification/index.tsx (deleted)
Deleted legacy mapping utilities and PendingOrderNotification component.
Activity details & other UI updates
apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx, apps/cowswap-frontend/src/modules/orders/containers/BridgingSuccessNotification/index.tsx, apps/cowswap-frontend/src/modules/orders/containers/FulfilledOrderInfo/index.tsx
Simplified activity summary fallback (removed computeOrderSummary/useUltimateOrder for non-order path); removed runtime bridge-order guard in BridgingSuccessNotification; updated OrderSummary import paths.
Legacy hooks & tests
apps/cowswap-frontend/src/legacy/state/enhancedTransactions/hooks/index.ts, apps/cowswap-frontend/src/common/updaters/orders/utils.test.ts
Fixed dispatch parentheses and removed three legacy hooks; deleted the now-obsolete computeOrderSummary tests.
i18n adjustments
apps/cowswap-frontend/src/locales/en-US.po
Moved/updated translation keys to reflect new component paths and marked pending-related entries obsolete.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor EmitterUser as Producer
    participant ORDER_EMIT as ORDER_STATUS_EVENT_EMITTER
    participant HANDLER as OrdersNotificationsHandler
    participant POSTED as PostedOrderNotification
    participant NOTIF as OrderNotificationContent
    Participant UI as UserToast/UI

    EmitterUser->>ORDER_EMIT: emit OrderStatusEvents.ON_POSTED_ORDER(payload)
    ORDER_EMIT->>HANDLER: deliver OnPostedOrderPayload
    HANDLER->>POSTED: render PostedOrderNotification(payload)
    POSTED->>NOTIF: map payload → OrderNotificationInfo
    NOTIF->>UI: render title + <OrderSummary/> (ReactNode) + ReceiverInfo?
    Note right of NOTIF: getToastMessageCallback → WIDGET_EVENT_EMITTER
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

Swap unification, Bridge

Suggested reviewers

  • elena-zh

Poem

🐰
I hop on code with tiny feet,
Turning strings to components sweet,
Events now chirp with typed delight,
Summaries bloom in React light,
A little hop — notifications right!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: unify order summary' accurately describes the main objective of this PR - consolidating and unifying the order summary handling across multiple components by replacing computeOrderSummary with OrderSummary component and refactoring OrderNotification.
Description check ✅ Passed The PR description is comprehensive and well-structured. It includes a clear summary with the fixed issue (#6748), provides detailed changes explanation with context about decisions, includes visual references (screenshots), and offers specific testing instructions beyond the template.
Linked Issues check ✅ Passed The PR addresses all coding objectives from issue #6748: fixes incorrect amounts displayed in cancellation modal/pop-ups and account modal by using OrderSummary component with getUltimateOrderTradeAmounts, hides receiver on cancelled/expired modals via hideReceiver flag, and ensures displayed amounts correspond to order-submitted UI.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the PR objectives: unifying order summary handling, refactoring OrderNotification for complexity reduction and useUltimateOrder() usage, splitting event emitters for separation of concerns, and removing unused computeOrderSummary calls. No unrelated modifications found.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19c9474 and f1f7a1a.

📒 Files selected for processing (2)
  • apps/cowswap-frontend/src/common/updaters/orders/utils.test.ts
  • apps/cowswap-frontend/src/locales/en-US.po
💤 Files with no reviewable changes (1)
  • apps/cowswap-frontend/src/common/updaters/orders/utils.test.ts
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...

Applied to files:

  • apps/cowswap-frontend/src/locales/en-US.po
📚 Learning: 2025-10-06T15:15:04.913Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6338
File: apps/cowswap-frontend/src/modules/ordersTable/pure/OrdersTableContainer/ConnectWalletContent.tsx:39-41
Timestamp: 2025-10-06T15:15:04.913Z
Learning: In the OrdersTable module (apps/cowswap-frontend/src/modules/ordersTable/), ConnectWalletContent uses `<h4>` while NoOrdersContent and warning sections use `<h3>` because they represent different styled titles with different visual treatments. This heading level difference is intentional.

Applied to files:

  • apps/cowswap-frontend/src/locales/en-US.po
📚 Learning: 2025-07-24T16:42:53.154Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/HighFeeWarningTooltipContent.tsx:23-33
Timestamp: 2025-07-24T16:42:53.154Z
Learning: In apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/HighFeeWarningTooltipContent.tsx, the use of toFixed(2) for percentage formatting in tooltip content is intentional and differs from the banner message formatting that uses toSignificant(2, undefined, Rounding.ROUND_DOWN). This formatting difference serves different UX purposes and should not be flagged as inconsistent.

Applied to files:

  • apps/cowswap-frontend/src/locales/en-US.po
📚 Learning: 2025-07-24T16:43:47.639Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/highFeeWarningHelpers.ts:18-20
Timestamp: 2025-07-24T16:43:47.639Z
Learning: In apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/highFeeWarningHelpers.ts, the formatFeePercentage function uses ROUND_DOWN with toSignificant(2) for "at least X%" messaging. This ensures the displayed percentage is never higher than the actual fee, making the "at least" phrasing accurate. For example, if the actual fee is 25.4%, displaying "at least 25%" is correct, but "at least 26%" would be misleading.

Applied to files:

  • apps/cowswap-frontend/src/locales/en-US.po
📚 Learning: 2025-07-24T10:00:45.353Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/hooks/useHighFeeWarning.ts:36-36
Timestamp: 2025-07-24T10:00:45.353Z
Learning: In the CowSwap frontend, when there's a bridgeFee present in the transaction, the isSell flag is always true for business reasons. This means bridge transactions are always structured as sell operations, which ensures consistent currency handling in fee percentage calculations.

Applied to files:

  • apps/cowswap-frontend/src/locales/en-US.po
⏰ 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: Setup
  • GitHub Check: Cypress
🔇 Additional comments (6)
apps/cowswap-frontend/src/locales/en-US.po (6)

3323-3327: Order label now correctly references OrderNotificationContent

Adding apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/index.tsx as a source for "Order" matches the new notification component and keeps the shared msgid intact across legacy helpers and the progress bar. No issues here.


3696-3699: Obsoleting lowercase "submitted" is consistent with new status copy

Marking the standalone "submitted" entry from PendingOrderNotification as obsolete (#~) is appropriate now that status strings use "Submitted" / "Order Submitted" instead. This avoids dead translations without changing runtime behavior.


3832-3835: Re-pointing "for at most" to common OrderSummary templates is correct

The source relocation to common/pure/OrderSummary/summaryTemplates.tsx matches the OrderSummary centralization described in the PR. The msgid/msgstr remain unchanged, so behavior is preserved while references stay accurate.


5370-5373: Same centralization applied to "for at least"

Updating the source reference for "for at least" to common/pure/OrderSummary/summaryTemplates.tsx keeps all summary phrase fragments co-located. No translation or runtime change, just cleaner mapping for translators.


5480-5483: Shared "Buy" label now also mapped from OrderSummary

Adding common/pure/OrderSummary/summaryTemplates.tsx as an additional source for "Buy" is consistent with using the same token in TWAP details and generic order summaries. Given the generic wording in en-US, reusing the msgid across these contexts is fine.


6079-6084: Shared "Sell" label reference alignment looks good

Extending the "Sell" msgid to also reference common/pure/OrderSummary/summaryTemplates.tsx, alongside LimitOrders and BridgingSuccessNotification, matches the unified OrderSummary usage. The string is unchanged and remains appropriate across all these contexts.


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

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

@shoom3301 shoom3301 marked this pull request as ready for review December 29, 2025 10:38
* currencyAmountToTokenAmount converts native token to wrapped
* but here we don't want to convert wrapped token to native
*/
function currencyAmountToTokenAmountIfNeeded(amount: CurrencyAmount<Currency>): CurrencyAmount<Token> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should not do that, it was causing #6676.

return <BridgingSuccessNotification payload={payload} />
},
},
[CowWidgetEvents.ON_TOAST_MESSAGE]: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we split extracted ORDER_STATUS_EVENT_EMITTER, we don't need those mocks anymore


import { WIDGET_EVENT_EMITTER } from 'widgetEventEmitter'

export function getToastMessageCallback(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not a new code, just moved it from another directory

// Transaction
(activityDerivedState.summary ??
// Order
(ultimateOrder ? computeOrderSummary(ultimateOrder) : null) ??
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

computeOrderSummary was never called here, lol

)
}

function summaryTemplate({
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can improve this component or its documentation so that it's clear if srcChainData or dstChainData is ever undefined.

Copy link
Contributor

@kernelwhisperer kernelwhisperer left a comment

Choose a reason for hiding this comment

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

LGTM!

… refactor/order-summary-1

# Conflicts:
#	apps/cowswap-frontend/src/common/containers/CancellationModal/index.tsx
#	apps/cowswap-frontend/src/common/pure/CancellationModal/RequestCancellationModal.tsx
#	apps/cowswap-frontend/src/common/updaters/orders/utils.ts
#	apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx
… refactor/order-summary-2

# Conflicts:
#	apps/cowswap-frontend/src/common/containers/CancellationModal/index.tsx
#	apps/cowswap-frontend/src/common/pure/CancellationModal/types.ts
#	apps/cowswap-frontend/src/common/updaters/orders/utils.ts
#	apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx
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 (4)
apps/cowswap-frontend/src/common/pure/OrderSummary/index.tsx (1)

35-49: Consider more granular useMemo dependencies for stability.

Using the entire props object as a dependency means these memos will recompute whenever any prop changes (or if the parent passes a new object reference). Since the computation only depends on specific fields, consider destructuring the relevant props:

🔎 Suggested refinement
  const inputAmount = useMemo(() => {
    if ('inputAmount' in props) {
      return props.inputAmount
    }

    return CurrencyAmount.fromRawAmount(TokenWithLogo.fromToken(props.inputToken), props.sellAmount)
-  }, [props])
+  }, ['inputAmount' in props ? props.inputAmount : null, 'inputToken' in props ? props.inputToken : null, 'sellAmount' in props ? props.sellAmount : null])

  const outputAmount = useMemo(() => {
    if ('outputAmount' in props) {
      return props.outputAmount
    }

    return CurrencyAmount.fromRawAmount(TokenWithLogo.fromToken(props.outputToken), props.buyAmount)
-  }, [props])
+  }, ['outputAmount' in props ? props.outputAmount : null, 'outputToken' in props ? props.outputToken : null, 'buyAmount' in props ? props.buyAmount : null])

Alternatively, extract individual props at the top of the function with type narrowing, then use those specific values in dependencies.

apps/cowswap-frontend/src/modules/orders/utils/emitPostedOrderEvent.ts (1)

52-61: Type assertion on currencyToTokenInfo return.

The as TokenInfo cast on line 60 assumes that either:

  1. The native token object (with overwritten address) matches TokenInfo, or
  2. The non-native currency already conforms to TokenInfo

This works because Currency from Uniswap SDK includes all fields needed for TokenInfo, but consider adding a more explicit type guard or mapping if TokenInfo shape diverges in the future.

🔎 Alternative with explicit mapping
 function currencyToTokenInfo(currency: Currency): TokenInfo {
-  return (
-    getIsNativeToken(currency)
-      ? {
-          ...currency,
-          address: NATIVE_CURRENCY_ADDRESS,
-        }
-      : currency
-  ) as TokenInfo
+  const address = getIsNativeToken(currency) ? NATIVE_CURRENCY_ADDRESS : currency.address
+  return {
+    chainId: currency.chainId,
+    address,
+    decimals: currency.decimals,
+    symbol: currency.symbol,
+    name: currency.name,
+  } as TokenInfo
 }
apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/index.tsx (1)

50-50: Missing null in implicit return.

Line 50 has an implicit return without a value (return), which returns undefined. For consistency with React patterns and the component's implicit ReactNode return type, consider returning null explicitly.

🔎 Proposed fix
-  if (!orderInfo) return
+  if (!orderInfo) return null
apps/cowswap-frontend/src/modules/orders/containers/BridgingSuccessNotification/index.tsx (1)

43-60: Consider documenting chain data presence and fallback behavior for bridge orders.

The summaryTemplate function defensively handles missing srcChainData and dstChainData, but for a bridge success notification, the fallback rendering—showing only "Sell {inputAmount}" without output amount or destination chain—may be incomplete.

The code design shows this is intentional (OrderSummary only passes chain data when isBridgeOrder is true, requiring both srcChainData and dstChainData). However, it would be helpful to add JSDoc documenting:

  • When/why chain data might be undefined for bridge orders
  • What the fallback behavior represents (incomplete order summary)

This clarification would make it explicit whether the fallback is an expected edge case or a potential data flow issue.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d09b211 and 19c9474.

📒 Files selected for processing (27)
  • apps/cowswap-frontend/src/common/containers/CancellationModal/index.tsx
  • apps/cowswap-frontend/src/common/pure/CancellationModal/index.tsx
  • apps/cowswap-frontend/src/common/pure/CancellationModal/types.ts
  • apps/cowswap-frontend/src/common/pure/OrderSummary/index.tsx
  • apps/cowswap-frontend/src/common/pure/OrderSummary/summaryTemplates.tsx
  • apps/cowswap-frontend/src/common/updaters/orders/utils.ts
  • apps/cowswap-frontend/src/legacy/state/enhancedTransactions/hooks/index.ts
  • apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx
  • apps/cowswap-frontend/src/modules/orders/containers/BridgingSuccessNotification/index.tsx
  • apps/cowswap-frontend/src/modules/orders/containers/FulfilledOrderInfo/index.tsx
  • apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/index.tsx
  • apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/utils.ts
  • apps/cowswap-frontend/src/modules/orders/containers/PostedOrderNotification/index.tsx
  • apps/cowswap-frontend/src/modules/orders/events/events.ts
  • apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts
  • apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/index.tsx
  • apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/utils.ts
  • apps/cowswap-frontend/src/modules/orders/pure/PendingOrderNotification/index.tsx
  • apps/cowswap-frontend/src/modules/orders/types.ts
  • apps/cowswap-frontend/src/modules/orders/updaters/OrdersNotificationsUpdater/handlers.tsx
  • apps/cowswap-frontend/src/modules/orders/updaters/OrdersNotificationsUpdater/index.tsx
  • apps/cowswap-frontend/src/modules/orders/utils/emitBridgingSuccessEvent.ts
  • apps/cowswap-frontend/src/modules/orders/utils/emitCancelledOrderEvent.ts
  • apps/cowswap-frontend/src/modules/orders/utils/emitExpiredOrderEvent.ts
  • apps/cowswap-frontend/src/modules/orders/utils/emitFulfilledOrderEvent.ts
  • apps/cowswap-frontend/src/modules/orders/utils/emitPostedOrderEvent.ts
  • apps/cowswap-frontend/src/modules/orders/utils/emitPresignedOrderEvent.ts
💤 Files with no reviewable changes (2)
  • apps/cowswap-frontend/src/modules/orders/pure/PendingOrderNotification/index.tsx
  • apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/utils.ts
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...

Applied to files:

  • apps/cowswap-frontend/src/common/pure/CancellationModal/index.tsx
  • apps/cowswap-frontend/src/modules/orders/containers/PostedOrderNotification/index.tsx
  • apps/cowswap-frontend/src/legacy/state/enhancedTransactions/hooks/index.ts
  • apps/cowswap-frontend/src/modules/orders/types.ts
  • apps/cowswap-frontend/src/modules/orders/containers/FulfilledOrderInfo/index.tsx
  • apps/cowswap-frontend/src/common/pure/OrderSummary/index.tsx
  • apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx
  • apps/cowswap-frontend/src/common/pure/CancellationModal/types.ts
  • apps/cowswap-frontend/src/common/updaters/orders/utils.ts
  • apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/index.tsx
  • apps/cowswap-frontend/src/modules/orders/utils/emitPostedOrderEvent.ts
  • apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/index.tsx
  • apps/cowswap-frontend/src/modules/orders/containers/BridgingSuccessNotification/index.tsx
  • apps/cowswap-frontend/src/common/containers/CancellationModal/index.tsx
📚 Learning: 2025-10-13T19:41:31.440Z
Learnt from: limitofzero
Repo: cowprotocol/cowswap PR: 6351
File: apps/cowswap-frontend/src/modules/erc20Approve/containers/TradeApproveModal/useTradeApproveCallback.ts:87-121
Timestamp: 2025-10-13T19:41:31.440Z
Learning: In apps/cowswap-frontend/src/modules/erc20Approve, useApproveCallback returns Promise<TransactionResponse | undefined> and is distinct from useApproveCurrency, which can return Promise<TransactionReceipt | SafeMultisigTransactionResponse>. When reviewing approval flows, verify which hook is actually being used before flagging Safe wallet concerns.

Applied to files:

  • apps/cowswap-frontend/src/legacy/state/enhancedTransactions/hooks/index.ts
  • apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx
📚 Learning: 2025-08-12T05:57:08.021Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6138
File: libs/hook-dapp-lib/src/hookDappsRegistry.ts:1-1
Timestamp: 2025-08-12T05:57:08.021Z
Learning: The matchHooksToDapps function in libs/hook-dapp-lib/src/utils.ts provides backward compatibility for permit hooks through function selector detection (EIP_2612_PERMIT_SELECTOR and DAI_PERMIT_SELECTOR) rather than dappId matching, making it robust against dappId changes.

Applied to files:

  • apps/cowswap-frontend/src/legacy/state/enhancedTransactions/hooks/index.ts
📚 Learning: 2025-10-06T15:15:04.913Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6338
File: apps/cowswap-frontend/src/modules/ordersTable/pure/OrdersTableContainer/ConnectWalletContent.tsx:39-41
Timestamp: 2025-10-06T15:15:04.913Z
Learning: In the OrdersTable module (apps/cowswap-frontend/src/modules/ordersTable/), ConnectWalletContent uses `<h4>` while NoOrdersContent and warning sections use `<h3>` because they represent different styled titles with different visual treatments. This heading level difference is intentional.

Applied to files:

  • apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/index.tsx
📚 Learning: 2025-05-26T12:39:29.009Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 5715
File: libs/common-const/src/tokens.ts:539-555
Timestamp: 2025-05-26T12:39:29.009Z
Learning: The team accepts using NATIVE_CURRENCY_ADDRESS as a temporary placeholder for COW token contract addresses on new networks (Polygon, Avalanche) until actual COW contracts are deployed.

Applied to files:

  • apps/cowswap-frontend/src/modules/orders/utils/emitPostedOrderEvent.ts
📚 Learning: 2025-09-19T11:38:59.206Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6232
File: apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx:199-200
Timestamp: 2025-09-19T11:38:59.206Z
Learning: The makeBuildClickEvent function in apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx takes five parameters: defaultChainId, contextLabel, mode, isSwapMode, and chainsCount. The chainsCount parameter is used to determine the CrossChain flag in analytics events.

Applied to files:

  • apps/cowswap-frontend/src/modules/orders/utils/emitPostedOrderEvent.ts
📚 Learning: 2025-08-05T14:27:05.023Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 5992
File: libs/wallet/src/web3-react/utils/switchChain.ts:36-38
Timestamp: 2025-08-05T14:27:05.023Z
Learning: In libs/wallet/src/web3-react/utils/switchChain.ts, the team prefers using Record<SupportedChainId, string | null> over Partial<Record<SupportedChainId, string>> for WALLET_RPC_SUGGESTION to enforce that all supported chain IDs have explicit values set, even if some might be null. This ensures compile-time completeness checking.

Applied to files:

  • apps/cowswap-frontend/src/modules/orders/containers/BridgingSuccessNotification/index.tsx
🧬 Code graph analysis (17)
apps/cowswap-frontend/src/modules/orders/utils/emitPresignedOrderEvent.ts (4)
apps/cowswap-frontend/src/modules/orders/index.ts (1)
  • emitPresignedOrderEvent (19-19)
libs/events/src/types/orders.ts (1)
  • OnPresignedOrderPayload (35-37)
apps/cowswap-frontend/src/widgetEventEmitter.ts (1)
  • WIDGET_EVENT_EMITTER (4-4)
apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (1)
  • ORDER_STATUS_EVENT_EMITTER (5-5)
apps/cowswap-frontend/src/modules/orders/utils/emitBridgingSuccessEvent.ts (4)
apps/cowswap-frontend/src/modules/orders/index.ts (1)
  • emitBridgingSuccessEvent (14-14)
libs/events/src/types/orders.ts (1)
  • OnBridgingSuccessPayload (39-39)
apps/cowswap-frontend/src/widgetEventEmitter.ts (1)
  • WIDGET_EVENT_EMITTER (4-4)
apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (1)
  • ORDER_STATUS_EVENT_EMITTER (5-5)
apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (2)
libs/events/src/CowEventEmitter.ts (1)
  • SimpleCowEventEmitter (17-48)
apps/cowswap-frontend/src/modules/orders/events/events.ts (1)
  • OrderStatusEventPayloadMap (28-35)
apps/cowswap-frontend/src/modules/orders/events/events.ts (2)
libs/events/src/types/orders.ts (5)
  • OnFulfilledOrderPayload (25-27)
  • OnCancelledOrderPayload (29-31)
  • OnExpiredOrderPayload (33-33)
  • OnPresignedOrderPayload (35-37)
  • OnBridgingSuccessPayload (39-39)
libs/events/src/CowEventEmitter.ts (1)
  • CowEventListener (7-9)
apps/cowswap-frontend/src/modules/orders/containers/PostedOrderNotification/index.tsx (3)
apps/cowswap-frontend/src/modules/orders/events/events.ts (1)
  • OnPostedOrderPayload (21-25)
apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/index.tsx (1)
  • OrderNotification (21-55)
apps/cowswap-frontend/src/modules/orders/types.ts (1)
  • OrderNotificationInfo (6-13)
apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/utils.ts (2)
libs/events/src/types/toastMessages.ts (2)
  • ToastMessagePayloads (15-59)
  • OnToastMessagePayload (91-93)
apps/cowswap-frontend/src/widgetEventEmitter.ts (1)
  • WIDGET_EVENT_EMITTER (4-4)
apps/cowswap-frontend/src/modules/orders/utils/emitCancelledOrderEvent.ts (4)
apps/cowswap-frontend/src/modules/orders/index.ts (1)
  • emitCancelledOrderEvent (15-15)
libs/events/src/types/orders.ts (1)
  • OnCancelledOrderPayload (29-31)
apps/cowswap-frontend/src/widgetEventEmitter.ts (1)
  • WIDGET_EVENT_EMITTER (4-4)
apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (1)
  • ORDER_STATUS_EVENT_EMITTER (5-5)
apps/cowswap-frontend/src/modules/orders/types.ts (1)
apps/cowswap-frontend/src/common/types.ts (1)
  • TradeAmounts (33-36)
apps/cowswap-frontend/src/modules/orders/utils/emitFulfilledOrderEvent.ts (5)
apps/cowswap-frontend/src/modules/orders/index.ts (1)
  • emitFulfilledOrderEvent (17-17)
libs/widget-lib/src/types.ts (1)
  • SupportedChainId (4-4)
libs/types/src/bridge.ts (1)
  • BridgeOrderDataSerialized (33-33)
apps/cowswap-frontend/src/widgetEventEmitter.ts (1)
  • WIDGET_EVENT_EMITTER (4-4)
apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (1)
  • ORDER_STATUS_EVENT_EMITTER (5-5)
apps/cowswap-frontend/src/common/pure/OrderSummary/index.tsx (3)
apps/cowswap-frontend/src/common/pure/OrderSummary/summaryTemplates.tsx (1)
  • SellForAtLeastTemplate (15-29)
apps/cowswap-frontend/src/common/types.ts (1)
  • TradeAmounts (33-36)
libs/common-const/src/types.ts (1)
  • TokenWithLogo (6-36)
apps/cowswap-frontend/src/modules/orders/updaters/OrdersNotificationsUpdater/index.tsx (3)
apps/cowswap-frontend/src/modules/orders/updaters/OrdersNotificationsUpdater/handlers.tsx (1)
  • ORDERS_NOTIFICATION_HANDLERS (26-111)
apps/cowswap-frontend/src/modules/orders/events/events.ts (2)
  • OrderStatusEventPayloadMap (28-35)
  • OrderStatusEventListener (39-39)
apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (1)
  • ORDER_STATUS_EVENT_EMITTER (5-5)
apps/cowswap-frontend/src/modules/orders/utils/emitExpiredOrderEvent.ts (4)
apps/cowswap-frontend/src/modules/orders/index.ts (1)
  • emitExpiredOrderEvent (16-16)
libs/events/src/types/orders.ts (1)
  • OnExpiredOrderPayload (33-33)
apps/cowswap-frontend/src/widgetEventEmitter.ts (1)
  • WIDGET_EVENT_EMITTER (4-4)
apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (1)
  • ORDER_STATUS_EVENT_EMITTER (5-5)
apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/index.tsx (6)
apps/cowswap-frontend/src/modules/orders/types.ts (1)
  • OrderNotificationInfo (6-13)
apps/cowswap-frontend/src/common/pure/OrderSummary/summaryTemplates.tsx (1)
  • SellForAtLeastTemplate (15-29)
libs/common-utils/src/legacyAddressUtils.ts (1)
  • shortenOrderId (129-131)
apps/cowswap-frontend/src/common/pure/OrderSummary/index.tsx (1)
  • OrderSummary (30-76)
apps/cowswap-frontend/src/modules/orders/pure/ReceiverInfo/index.tsx (1)
  • ReceiverInfo (15-27)
apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/utils.ts (1)
  • getToastMessageCallback (5-18)
apps/cowswap-frontend/src/modules/orders/utils/emitPostedOrderEvent.ts (4)
apps/cowswap-frontend/src/widgetEventEmitter.ts (1)
  • WIDGET_EVENT_EMITTER (4-4)
apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (1)
  • ORDER_STATUS_EVENT_EMITTER (5-5)
libs/common-utils/src/getIsNativeToken.ts (1)
  • getIsNativeToken (13-33)
libs/common-const/src/nativeAndWrappedTokens.ts (1)
  • NATIVE_CURRENCY_ADDRESS (10-10)
apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/index.tsx (7)
apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/index.tsx (2)
  • OrderNotificationContentProps (19-32)
  • OrderNotificationContent (34-86)
apps/cowswap-frontend/src/modules/orders/types.ts (1)
  • OrderNotificationInfo (6-13)
apps/cowswap-frontend/src/common/hooks/useUltimateOrder.ts (1)
  • useUltimateOrder (18-34)
apps/cowswap-frontend/src/common/updaters/orders/utils.ts (1)
  • getUltimateOrderTradeAmounts (13-62)
libs/common-utils/src/getIsNativeToken.ts (1)
  • getIsNativeToken (13-33)
libs/common-const/src/chainInfo.ts (1)
  • getChainInfo (162-164)
apps/cowswap-frontend/src/entities/bridgeProvider/index.ts (1)
  • useBridgeSupportedNetwork (1-1)
apps/cowswap-frontend/src/modules/orders/containers/BridgingSuccessNotification/index.tsx (1)
apps/cowswap-frontend/src/common/pure/OrderSummary/summaryTemplates.tsx (1)
  • OrderSummaryTemplateProps (7-13)
apps/cowswap-frontend/src/common/containers/CancellationModal/index.tsx (2)
apps/cowswap-frontend/src/common/updaters/orders/utils.ts (1)
  • getUltimateOrderTradeAmounts (13-62)
apps/cowswap-frontend/src/common/pure/OrderSummary/index.tsx (1)
  • OrderSummary (30-76)
⏰ 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: Setup
  • GitHub Check: Cypress
🔇 Additional comments (27)
apps/cowswap-frontend/src/legacy/state/enhancedTransactions/hooks/index.ts (1)

41-55: LGTM!

The trailing comma additions are consistent with the codebase style and improve diff readability for future changes.

apps/cowswap-frontend/src/common/pure/OrderSummary/index.tsx (1)

14-28: LGTM!

The polymorphic props pattern with a union type is well-designed. It allows callers to provide either pre-computed CurrencyAmount values via TradeAmounts or raw token/amount data via TokensAndAmounts, giving flexibility while maintaining type safety.

apps/cowswap-frontend/src/modules/orders/containers/FulfilledOrderInfo/index.tsx (1)

13-14: LGTM!

The switch to absolute imports (common/pure/OrderSummary) is consistent with the codebase conventions and improves maintainability.

apps/cowswap-frontend/src/modules/orders/utils/emitBridgingSuccessEvent.ts (1)

5-10: LGTM!

The dual emission pattern correctly separates concerns: WIDGET_EVENT_EMITTER for external widget consumers and ORDER_STATUS_EVENT_EMITTER for internal order status notifications. This aligns with the PR objective to decouple widget events from order status handling.

apps/cowswap-frontend/src/modules/orders/utils/emitPresignedOrderEvent.ts (1)

5-10: LGTM!

Consistent with the dual emission pattern applied to other event utilities in this PR.

apps/cowswap-frontend/src/common/pure/CancellationModal/types.ts (1)

9-10: LGTM!

Expanding summary from string to ReactNode enables richer order summary content (e.g., the OrderSummary component with proper token formatting) in the cancellation modal. This aligns with the PR goal of unifying order summary rendering across the application.

apps/cowswap-frontend/src/common/pure/CancellationModal/index.tsx (1)

17-22: LGTM!

The orderSummary type expansion to ReactNode | undefined is properly propagated from the types file and correctly used in both the pending confirmation display and the RequestCancellationModal.

apps/cowswap-frontend/src/modules/orders/types.ts (1)

6-13: LGTM!

The OrderNotificationInfo interface is well-designed:

  • Extends TradeAmounts for consistent amount handling across the order notification system
  • Includes all necessary identity and type information for rendering notifications
  • Uses Nullish<string> for receiver appropriately, since the receiver may be absent or explicitly null

This type centralizes the data contract for order notifications, supporting the PR's goal of unifying order summary rendering.

apps/cowswap-frontend/src/modules/orders/containers/PostedOrderNotification/index.tsx (1)

1-42: LGTM! Clean component implementation.

The PostedOrderNotification component is well-structured:

  • Props are properly typed with ToastMessageType and OnPostedOrderPayload
  • The mapper function cleanly transforms the payload into OrderNotificationInfo
  • Safe default (?? false) for isEthFlowOrder handles optional fields correctly
  • Follows React best practices with proper typing
apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/utils.ts (1)

5-18: LGTM! Well-typed toast callback utility.

The function correctly:

  • Uses generic constraints to ensure type safety between messageType and data
  • Emits to WIDGET_EVENT_EMITTER (appropriate for toast messages, separate from order status events)
  • Returns a properly typed callback function

The type assertion on line 16 is necessary and safe given the generic constraints.

apps/cowswap-frontend/src/common/containers/CancellationModal/index.tsx (1)

24-32: LGTM! Clean refactor to component-based rendering.

The migration from computeOrderSummary to the OrderSummary component is well-executed:

  • Uses getUltimateOrderTradeAmounts to derive trade amounts from ultimate order data
  • Renders <OrderSummary /> component with proper props (inputAmount, outputAmount, kind)
  • Returns ReactNode instead of computed summary object, aligning with the Pure component's updated signature

This change centralizes order summary rendering and improves consistency across the codebase.

apps/cowswap-frontend/src/modules/orders/events/orderStatusEventEmitter.ts (1)

1-5: LGTM! Proper emitter separation.

The ORDER_STATUS_EVENT_EMITTER singleton is correctly implemented:

  • Properly typed with OrderStatusEventPayloadMap and OrderStatusEvents
  • Follows the same pattern as WIDGET_EVENT_EMITTER
  • Supports the PR objective of separating order status events from widget events for clearer responsibilities
apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx (1)

591-591: LGTM! Correct removal of unreachable code.

The simplification from activityDerivedState.summary ?? (ultimateOrder ? computeOrderSummary(ultimateOrder) : null) ?? id to activityDerivedState.summary ?? id is correct. As noted in the past review comment, computeOrderSummary was never actually called in this code path since it's in the transaction (non-order) branch.

This cleanup removes dead code and improves readability.

apps/cowswap-frontend/src/modules/orders/utils/emitExpiredOrderEvent.ts (1)

8-11: LGTM! Consistent dual-emission pattern.

The function now emits to both emitters:

  • WIDGET_EVENT_EMITTER (line 9) - maintains backward compatibility
  • ORDER_STATUS_EVENT_EMITTER (line 10) - new order status event system

This pattern is consistently applied across all emit* utilities in the PR, supporting the objective of separating widget events from order status events.

apps/cowswap-frontend/src/modules/orders/utils/emitFulfilledOrderEvent.ts (1)

15-23: LGTM! Clean dual-emission implementation.

The refactor correctly:

  • Extracts the payload to a variable (lines 15-19) for reuse
  • Emits to both WIDGET_EVENT_EMITTER and ORDER_STATUS_EVENT_EMITTER (lines 21-22)
  • Maintains the same function signature and behavior

Consistent with the dual-emission pattern applied throughout the PR.

apps/cowswap-frontend/src/modules/orders/utils/emitCancelledOrderEvent.ts (1)

8-11: LGTM! Consistent implementation.

The function follows the same dual-emission pattern as the other emit* utilities:

  • Maintains backward compatibility with WIDGET_EVENT_EMITTER (line 9)
  • Adds ORDER_STATUS_EVENT_EMITTER emission (line 10) for the new order status event system
  • Proper void return type annotation
apps/cowswap-frontend/src/modules/orders/updaters/OrdersNotificationsUpdater/index.tsx (1)

7-41: Clean migration to the new OrderStatusEvents system.

The event system migration is well-structured:

  • Properly imports from the new events module
  • Listener registration/cleanup in useEffect follows React best practices
  • Type casting is necessary due to TypeScript's handling of Object.keys()

One minor observation: using eventTyped as the snackbar id (line 26) means all notifications of the same event type share an ID. This is likely intentional to prevent duplicate toasts for the same event type.

apps/cowswap-frontend/src/common/updaters/orders/utils.ts (1)

13-62: Well-structured trade amounts derivation with clear branching logic.

The function correctly handles three distinct cases:

  1. Bridge orders (using quote amounts)
  2. Fulfilled swap orders (using executed amounts)
  3. Pending/other swap orders (using sell + fee amounts)

The logic properly includes feeAmount in the input for non-fulfilled orders (line 59), which represents the total amount the user is selling.

apps/cowswap-frontend/src/modules/orders/pure/OrderNotificationContent/index.tsx (2)

34-86: Clean separation of pure presentation component.

The component follows the container/pure pattern well:

  • Accepts fully-resolved orderInfo and chain data as props
  • Conditionally renders OrderSummary or custom children
  • Properly handles hideReceiver and skipExplorerLink flags

88-110: Consider potential timing issues with innerText extraction.

The useToastRenderRef hook extracts node.innerText when the ref callback fires. This approach depends on the DOM being fully rendered with all text content when the ref is attached.

If child components render asynchronously or use effects to populate text, innerText might be incomplete. However, given that this renders static content (title, order ID, summary), this should work reliably in practice.

Verify that toast messages display the expected content during testing of order notifications.

apps/cowswap-frontend/src/modules/orders/events/events.ts (1)

1-40: Well-designed typed event system.

The event type definitions provide strong type safety:

  • OrderStatusEventPayloadMap enables type-safe event handling
  • OnPostedOrderPayload correctly extends the generic payload with CurrencyAmount fields for the new status-event channel
  • Listener types leverage the existing CowEventListener pattern

This separation from CowWidgetEvents allows the internal status updates to carry richer type information (like CurrencyAmount) that wouldn't be appropriate for the external widget API.

apps/cowswap-frontend/src/modules/orders/utils/emitPostedOrderEvent.ts (1)

44-49: Dual emission pattern enables richer internal event handling.

Emitting to both WIDGET_EVENT_EMITTER (for external widget consumers with serializable payloads) and ORDER_STATUS_EVENT_EMITTER (for internal consumers with CurrencyAmount objects) is a clean separation of concerns.

apps/cowswap-frontend/src/modules/orders/updaters/OrdersNotificationsUpdater/handlers.tsx (2)

26-38: PostedOrderNotification receives full payload for richer rendering.

This change enables the "Order submitted" notification to access inputAmount and outputAmount as CurrencyAmount objects directly, addressing the PR objective to display consistent amounts on the order-submitted popup.


57-88: hideReceiver correctly added for cancelled/expired orders.

Per the PR objectives (issue #6748), the receiver should not be displayed on cancelled/expired modals unless it differs from the order creator. By setting hideReceiver to true, these notifications align with the expected behavior.

apps/cowswap-frontend/src/modules/orders/containers/OrderNotification/index.tsx (2)

25-43: Good fallback pattern for orderInfo derivation.

The logic correctly prioritizes deriving orderInfo from ultimateOrder when available, then falls back to the provided _orderInfo prop. This enables the component to work both:

  1. When order data is fetched (most cases)
  2. When pre-computed order info is passed directly (e.g., from PostedOrderNotification)

57-65: Asymmetric chain info retrieval may cause subtle issues.

srcChainData is retrieved via getChainInfo() (synchronous lookup), while dstChainData uses useBridgeSupportedNetwork() (likely a hook with state/async behavior). This asymmetry could cause:

  • srcChainData to always be defined for valid chains
  • dstChainData to potentially be undefined during loading states

This is likely intentional for bridge orders where the destination might be a non-supported network, but worth noting for debugging if chain info appears inconsistent.

apps/cowswap-frontend/src/modules/orders/containers/BridgingSuccessNotification/index.tsx (1)

9-9: LGTM: Type-only import is appropriate.

Using import type for OrderSummaryTemplateProps is the correct approach since it's only used for type annotations, improving tree-shaking and making the intent clear.

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.

Near: handle amounts on cancelled/expired swap and bridge orders

4 participants