Skip to content

Conversation

infiniteflower
Copy link
Contributor

@infiniteflower infiniteflower commented Feb 27, 2025

Explanation

This PR refactors the BridgeController and BridgeStatusController to use Superstruct for increased readability of API response validators.

References

Changelog

@metamask/bridge-controller

  • CHANGED: Using Superstruct for better readability of API response validation

@metamask/bridge-status-controller

  • CHANGED: Using Superstruct for better readability of API response validation

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 highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@infiniteflower infiniteflower marked this pull request as ready for review February 27, 2025 22:17
@infiniteflower infiniteflower requested review from a team as code owners February 27, 2025 22:17
Base automatically changed from feat/bridge-and-bridgeStatus-state-changes to main February 27, 2025 22:19
@infiniteflower infiniteflower force-pushed the chore/bridge-bridgeStatus-superstruct branch from 7a7a917 to 9bae550 Compare February 27, 2025 22:22
Copy link
Contributor

@amitabh94 amitabh94 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

const url = `${BRIDGE_STATUS_BASE_URL}?${params.toString()}`;

const rawTxStatus = await fetchFn(url, {
const rawTxStatus: unknown = await fetchFn(url, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice improvement in type safety by explicitly marking API responses as unknown before validation.

@infiniteflower infiniteflower merged commit f3636ad into main Feb 28, 2025
136 checks passed
@infiniteflower infiniteflower deleted the chore/bridge-bridgeStatus-superstruct branch February 28, 2025 18:40
@infiniteflower infiniteflower mentioned this pull request Mar 24, 2025
4 tasks
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.

2 participants