8000 feat(explorer): display bridging data in order page by shoom3301 · Pull Request #5787 · cowprotocol/cowswap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(explorer): display bridging data in order page #5787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 73 commits into from
Jun 19, 2025

Conversation

shoom3301
Copy link
Collaborator
@shoom3301 shoom3301 commented Jun 5, 2025

Summary

Example: https://explorer-dev-git-feat-bridge-explorer-1-cowswap-dev.vercel.app/arb1/orders/0x5304214e957c583cf88d1d395d8be45b7fdd458e54ac711b59173f0c4afff969bbcf91605c18a9859c1d47abfeed5d2cca7097cf683edc4b?tab=overview

image image image image

To Test

  1. For non-bridge orders the order details page should look as before
  2. For bridge orders the page should display "Swap" and "Bridge" tabs
  3. The new tabs should look as on the pictures above

Summary by CodeRabbit

  • New Features

    • Added comprehensive cross-chain bridge order support with detailed components for bridge status, refund info, and token displays.
    • Introduced a customizable loading indicator component used across multiple tables and pages.
    • Enhanced copy button to sho 8000 w a "Copied" tooltip for better user feedback.
    • Added network logos and network name display in address and token components.
    • Modularized order details and fills tables with improved storybook coverage for various order and bridge states.
  • Improvements

    • Refactored styling into separate styled-components files for consistency and maintainability.
    • Improved handling of order and bridge statuses, including partial fills, icons, and tooltips.
    • Enhanced type safety by updating enums, types, and replacing deprecated or duplicated definitions.
    • Centralized token and price formatting utilities.
    • Unified status handling to support both order and bridge lifecycle states.
    • Updated loading states with clearer user feedback and messages.
    • Modularized tab content generation and integrated cross-chain order data in order details.
    • Replaced fixed pixel units with relative rem units for better responsiveness.
  • Bug Fixes

    • Fixed display and formatting issues related to network logos and token information.
    • Corrected styling inconsistencies by switching fixed pixel units to relative rem units and adjusting border widths.
  • Chores

    • Removed unused types and internal utility files; cleaned up imports and exports.
    • Consolidated module exports for bridge hooks and SDK providers to simplify imports.
    • Externalized styled-components to dedicated styling files for better code organization.
    • Updated imports to use centralized type definitions and removed deprecated aliases.

fairlighteth and others added 24 commits May 20, 2025 09:43
… feat/bridge-explorer-1

# Conflicts:
#	apps/cowswap-frontend/src/modules/bridge/containers/BridgeRouteBreakdown/BridgeRouteBreakdown.cosmos.tsx
#	apps/cowswap-frontend/src/modules/bridge/hooks/useBridgeProviderDetails.ts
#	apps/cowswap-frontend/src/modules/bridge/index.ts
#	apps/cowswap-frontend/src/modules/bridge/pure/BridgeStopDetails/index.tsx
#	apps/cowswap-frontend/src/modules/bridge/pure/SwapStopDetails/index.tsx
#	apps/explorer/src/components/orders/DetailsTable/index.tsx
#	apps/explorer/src/components/orders/DetailsTable/styled.ts
#	apps/explorer/src/components/orders/OrderDetails/OrderDetails.fixture.tsx
#	apps/explorer/src/utils/orderTypeGuards.ts
#	libs/bridge/src/providers.ts
Copy link
vercel bot commented Jun 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cowfi 🔄 Building (Inspect) Visit Preview Jun 19, 2025 5:32am
explorer-dev 🔄 Building (Inspect) Visit Preview Jun 19, 2025 5:32am
swap-dev 🔄 Building (Inspect) Visit Preview Jun 19, 2025 5:32am
3 Skipped Deployments
Name Status Preview Updated (UTC)
cosmos ⬜️ Ignored (Inspect) Visit Preview Jun 19, 2025 5:32am
sdk-tools ⬜️ Ignored (Inspect) Visit Preview Jun 19, 2025 5:32am
widget-configurator ⬜️ Ignored (Inspect) Visit Preview Jun 19, 2025 5:32am

Copy link
Contributor
coderabbitai bot commented Jun 5, 2025

Walkthrough

This update removes the local NetworkLogo component and its styled wrapper from the cowswap-frontend app, replacing all relative imports with imports from the @cowprotocol/ui package. A new, theme-aware NetworkLogo component is introduced in the UI library, with enhanced props and styling.

Changes

File(s) Change Summary
apps/cowswap-frontend/src/modules/bridge/pure/NetworkLogo/index.tsx,
styled.ts
Deleted local NetworkLogo component and its styled wrapper.
apps/cowswap-frontend/src/modules/bridge/pure/RecipientDisplay/index.tsx,
.../RefundedBridgingContent/index.tsx
Updated imports to use NetworkLogo from @cowprotocol/ui instead of local component.
libs/ui/src/pure/NetworkLogo/index.tsx Added new NetworkLogo component with theme-aware logo selection, configurable props, and styled wrapper.
libs/ui/src/index.ts Exported NetworkLogo from the UI library barrel file.

Sequence Diagram(s)

sequenceDiagram
    participant AppComponent
    participant UI_Library
    participant Theme
    participant ChainInfo

    AppComponent->>UI_Library: import { NetworkLogo }
    AppComponent->>NetworkLogo: <NetworkLogo chainId=... size=... />
    NetworkLogo->>ChainInfo: getChainInfo(chainId)
    NetworkLogo->>Theme: useTheme()
    NetworkLogo->>AppComponent: Render logo image with correct style and theme
Loading

Possibly related PRs

  • cowprotocol/cowswap#5831: Removes the local NetworkLogo and replaces it with the UI library version, directly related to this change.
  • cowprotocol/cowswap#5725: Previously introduced bridge-related types that are now being removed or replaced in this update.
  • cowprotocol/cowswap#5588: Switches from mock to real bridge provider and integrates bridging SDK, related to bridge provider usage and hooks.

Suggested labels

preview-widget-cfg

Suggested reviewers

  • elena-zh
  • alfetopito

Poem

A bunny hopped across the code,
Swapping logos down the road.
Out with old, in with new,
Theme-aware and shiny too!
Now every chain, big or small,
Has a logo loved by all.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
(node:24101) [DEP0169] DeprecationWarning: url.parse() behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for url.parse() vulnerabilities.
(Use node --trace-deprecation ... to show where the warning was created)
[2/4] Fetching packages...
error nx@21.0.3: The engine "node" is incompatible with this module. Expected version "^20.19.0 || ^22.12.0". Got "24.2.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
socket-security bot commented Jun 5, 2025

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

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: 2

♻️ Duplicate comments (2)
apps/explorer/src/components/orders/StatusLabel/index.tsx (1)

51-53: Unsafe cast persists – same issue flagged previously

The status as OrderStatus cast is still present and unnecessary. It can admit invalid strings into canBePartiallyFilled.

-  const tagPartiallyFilled =
-    partiallyFilled && typeof status === 'string' && canBePartiallyFilled(status as OrderStatus)
+  const tagPartiallyFilled =
+    partiallyFilled && canBePartiallyFilled(_status)
apps/explorer/src/components/orders/BridgeDetailsTable/RefundStatus.tsx (1)

43-45: Redundant NOT_INITIATED case

Behaviour is identical to the default branch – remove the extra clause to silence lint and simplify the switch.

🧹 Nitpick comments (3)
apps/explorer/src/components/token/TokenAmount/index.tsx (1)

20-23: Trim trailing space when noSymbol is enabled

The unconditional space before the symbol causes a visible trailing whitespace when noSymbol is true.
Refactor the JSX so the space is rendered only when the symbol is rendered.

-    <span title={fullAmount + ' ' + displayedSymbol}>
-      {displayedAmount} {noSymbol ? '' : displayedSymbol}
+    <span title={fullAmount + (displayedSymbol ? ` ${displayedSymbol}` : '')}>
+      {displayedAmount}
+      {!noSymbol && displayedSymbol ? ` ${displayedSymbol}` : null}
     </span>
apps/explorer/src/components/orders/StatusLabel/index.tsx (2)

24-28: Hard-coded lowercase array duplicates enum values – consolidate via .map to avoid drift

-const SHIMMING_STATUSES = [
-  OrderStatus.Signing.toLowerCase(),
-  OrderStatus.Cancelling.toLowerCase(),
-  BridgeStatus.IN_PROGRESS.toLowerCase(),
-]
+const SHIMMING_STATUSES = [
+  OrderStatus.Signing,
+  OrderStatus.Cancelling,
+  BridgeStatus.IN_PROGRESS,
+].map((s) => s.toLowerCase())

Keeps the list automatically in sync if enum literals ever change or new active states are added.


56-58: Indexing bridge-status map with union type hides intent & type-safety

-  const displayStatus: StyledGenericStatus =
-    customizeStatus && partiallyFilled ? OrderStatus.PartiallyFilled : bridgeStatusTitleMap[_status] || status
+  const displayStatus: StyledGenericStatus =
+    customizeStatus && partiallyFilled
+      ? OrderStatus.PartiallyFilled
+      : _status in bridgeStatusTitleMap
+      ? bridgeStatusTitleMap[_status as BridgeStatus]
+      : status

Makes it explicit that only BridgeStatus values should hit the map, removing the silent undefined fallback and easing TypeScript’s control-flow analysis.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7402396 and b3dcb97.

📒 Files selected for processing (11)
  • apps/explorer/src/components/orders/BridgeDetailsTable/BridgeAmountDisplay.tsx (1 hunks)
  • apps/explorer/src/components/orders/BridgeDetailsTable/BridgeDetailsContent/index.tsx (1 hunks)
  • apps/explorer/src/components/orders/BridgeDetailsTable/BridgeReceiveAmount.tsx (1 hunks)
  • apps/explorer/src/components/orders/BridgeDetailsTable/BridgeTxOverview.tsx (1 hunks)
  • apps/explorer/src/components/orders/BridgeDetailsTable/RefundStatus.tsx (1 hunks)
  • apps/explorer/src/components/orders/BridgeDetailsTable/index.tsx (1 hunks)
  • apps/explorer/src/components/orders/BridgeDetailsTable/styled.ts (1 hunks)
  • apps/explorer/src/components/orders/OrderDetails/index.tsx (5 hunks)
  • apps/explorer/src/components/orders/OrderDetails/tabs.tsx (1 hunks)
  • apps/explorer/src/components/orders/StatusLabel/index.tsx (1 hunks)
  • apps/explorer/src/components/token/TokenAmount/index.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • apps/explorer/src/components/orders/BridgeDetailsTable/BridgeAmountDisplay.tsx
  • apps/explorer/src/components/orders/BridgeDetailsTable/BridgeReceiveAmount.tsx
  • apps/explorer/src/components/orders/BridgeDetailsTable/index.tsx
  • apps/explorer/src/components/orders/BridgeDetailsTable/BridgeDetailsContent/index.tsx
  • apps/explorer/src/components/orders/BridgeDetailsTable/BridgeTxOverview.tsx
  • apps/explorer/src/components/orders/OrderDetails/index.tsx
  • apps/explorer/src/components/orders/OrderDetails/tabs.tsx
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/explorer/src/components/token/TokenAmount/index.tsx (1)
apps/explorer/src/utils/format.ts (2)
  • formatSmartMaxPrecision (211-218)
  • formattingAmountPrecision (277-292)
apps/explorer/src/components/orders/StatusLabel/index.tsx (5)
apps/explorer/src/components/orders/StatusLabel/styled.ts (3)
  • PartiallyTagPosition (8-8)
  • Wrapper (101-109)
  • Label (117-149)
apps/explorer/src/api/operator/types.ts (1)
  • ORDER_FINAL_FAILED_STATUSES (27-27)
apps/explorer/src/utils/statusHelpers.ts (1)
  • canBePartiallyFilled (20-22)
apps/explorer/src/utils/format.ts (1)
  • formatPercentage (114-133)
apps/explorer/src/components/orders/StatusLabel/StatusIcon.tsx (1)
  • StatusIcon (14-21)
🪛 Biome (1.9.4)
apps/explorer/src/components/orders/BridgeDetailsTable/RefundStatus.tsx

[error] 43-43: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)

apps/explorer/src/components/orders/BridgeDetailsTable/styled.ts

[error] 75-75: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)


[error] 76-76: Useless case clause.

because the default clause is present:

Unsafe fix: Remove the useless case.

(lint/complexity/noUselessSwitchCase)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Setup
  • GitHub Check: Cypress
🔇 Additional comments (2)
apps/explorer/src/components/token/TokenAmount/index.tsx (1)

21-22: Confirm tooltip behaviour aligns with noSymbol intent

Even when noSymbol is true, the tooltip (title attribute) still includes the symbol.
If the goal of noSymbol is purely visual, this is fine; if the intent is to hide the symbol everywhere, the tooltip should omit it as well. Please verify the desired UX.

apps/explorer/src/components/orders/BridgeDetailsTable/styled.ts (1)

57-62: Provider logo style looks good

Border-radius tied to the custom property guarantees a perfect circle and respects any future size change.

@elena-zh
Copy link
Contributor

@shoom3301 , the build has failed

@shoom3301
Copy link
Collaborator Author

@elena-zh sorry, fixed

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: 1

♻️ Duplicate comments (1)
apps/explorer/src/components/orders/StatusLabel/index.tsx (1)

47-53: Unsafe cast & redundant type check remain unfixed
status is always a string (_status.toLowerCase()); the typeof guard is therefore pointless.
Casting to OrderStatus is still unsafe and was already flagged in a previous review.

-const tagPartiallyFilled =
-  partiallyFilled && typeof status === 'string' && canBePartiallyFilled(status as OrderStatus)
+const tagPartiallyFilled =
+  partiallyFilled && canBePartiallyFilled(_status as OrderStatus)

Even better: overload canBePartiallyFilled to accept string | OrderStatus, eliminating the cast entirely.

Failure to address this will surface at runtime if an unknown status is passed.

🧹 Nitpick comments (1)
apps/explorer/src/components/orders/StatusLabel/index.tsx (1)

24-28: Rename constant and centralize spinner-state logic

The constant name is misspelled (SHIMMINGSHIMMERING) and doesn’t convey intent clearly.
Additionally, hard-coding the list risks missing future “in-progress” bridge statuses (e.g. WAITING_FOR_REFUND, etc.).
Consider renaming and deriving the list from a single source of truth in statusHelpers.ts.

-const SHIMMING_STATUSES = [
+const SHIMMERING_STATUSES: string[] = [
   OrderStatus.Signing.toLowerCase(),
   OrderStatus.Cancelling.toLowerCase(),
   BridgeStatus.IN_PROGRESS.toLowerCase(),
 ]

Moving this array next to canBePartiallyFilled keeps status logic co-located, reducing future drift.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e1496f and 7318065.

📒 Files selected for processing (1)
  • apps/explorer/src/components/orders/StatusLabel/index.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Socket Security: Pull Request Alerts

Comment on lines +56 to 58
const displayStatus: StyledGenericStatus =
customizeStatus && partiallyFilled ? OrderStatus.PartiallyFilled : bridgeStatusTitleMap[_status] || status

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Display logic mixes bridge & order status paths — extract for clarity

bridgeStatusTitleMap[_status] || status works but:

  1. bridgeStatusTitleMap is typed Record<BridgeStatus, string>; indexing with an OrderStatus violates the contract and defeats TypeScript safety.
  2. Falling back to status yields the lowercase value, relying on toUpperCase() later for presentation. This double handling lowers readability.

Suggested refactor:

-const displayStatus: StyledGenericStatus =
-  customizeStatus && partiallyFilled ? OrderStatus.PartiallyFilled : bridgeStatusTitleMap[_status] || status
+const normalizedStatus =
+  (_status in bridgeStatusTitleMap
+    ? bridgeStatusTitleMap[_status as BridgeStatus]
+    : _status) as StyledGenericStatus
+
+const displayStatus: StyledGenericStatus =
+  isFinalStatus && partiallyFilled ? OrderStatus.PartiallyFilled : normalizedStatus

This keeps typing strict and separates “mapping” from “final display decision.”

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In apps/explorer/src/components/orders/StatusLabel/index.tsx around lines 56 to
58, the current displayStatus logic mixes bridge and order status handling,
causing TypeScript type safety issues by indexing bridgeStatusTitleMap with an
OrderStatus and relying on fallback to lowercase status with later toUpperCase
calls. To fix this, separate the mapping of bridge statuses from order statuses
explicitly by first checking if _status is a BridgeStatus and mapping it via
bridgeStatusTitleMap, otherwise use the order status directly. This preserves
strict typing and improves readability by avoiding fallback and double case
transformations.

Copy link
Contributor
@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

Thank you!

… feat/bridge-explorer-1

# Conflicts:
#	apps/explorer/src/components/orders/DetailsTable/BaseDetailsTable.tsx
#	apps/explorer/src/components/orders/DetailsTable/FullDetailsTable.tsx
#	apps/explorer/src/components/orders/DetailsTable/index.tsx
@shoom3301 shoom3301 merged commit cd398f0 into develop Jun 19, 2025
6 of 12 checks passed
@shoom3301 shoom3301 deleted the feat/bridge-explorer-1 branch June 19, 2025 05:32
@github-actions github-actions bot locked and limited conversation to collaborators Jun 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0