Commit 61d1bb0
authored
refactor: move Swaps QuoteReceived event publishing to bridge-controller (#7242)
## Explanation
Publishes QuotesReceived event through BridgeController when quote
polling stops on submit to ensure it happens before navigation resets
the state
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs)
- [x] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Routes QuotesReceived publishing through BridgeController when polling
stops on submit; submitTx now passes context; adds TransactionSubmitted
abort reason and improves logging.
>
> - **Bridge Controller**:
> - Update `stopPollingForQuotes(reason?, context?)` to optionally
publish `Unified SwapBridge Quotes Received` if quotes are still loading
before abort; accept `AbortReason` and metric context.
> - Add `AbortReason.TransactionSubmitted`; ignore it in fetch error
early-returns; export `AbortReason`.
> - Improve error log to include `eventName` in
`trackUnifiedSwapBridgeEvent` catch.
> - **Bridge Status Controller**:
> - Change `submitTx` signature to accept `quotesReceivedContext` and
call
`BridgeController:stopPollingForQuotes(AbortReason.TransactionSubmitted,
context)` instead of publishing `QuotesReceived` directly.
> - Narrow `#trackUnifiedSwapBridgeEvent` generic to exclude
`QuotesReceived`.
> - **Tests/Changelogs**:
> - Update snapshots and tests to reflect new stopPolling parameters and
event routing.
> - Document behavior changes in both packages’ CHANGELOGs.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
1506266. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent b2da989 commit 61d1bb0
File tree
9 files changed
+93
-35
lines changed- packages
- bridge-controller
- src
- utils/metrics
- bridge-status-controller
- src
- __snapshots__
9 files changed
+93
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2673 | 2673 | | |
2674 | 2674 | | |
2675 | 2675 | | |
2676 | | - | |
| 2676 | + | |
2677 | 2677 | | |
2678 | 2678 | | |
2679 | 2679 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
499 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
500 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
501 | 512 | | |
502 | 513 | | |
503 | 514 | | |
| |||
627 | 638 | | |
628 | 639 | | |
629 | 640 | | |
| 641 | + | |
630 | 642 | | |
631 | 643 | | |
632 | 644 | | |
| |||
972 | 984 | | |
973 | 985 | | |
974 | 986 | | |
975 | | - | |
| 987 | + | |
976 | 988 | | |
977 | 989 | | |
978 | 990 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
Lines changed: 53 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
| 535 | + | |
534 | 536 | | |
535 | 537 | | |
536 | 538 | | |
| |||
764 | 766 | | |
765 | 767 | | |
766 | 768 | | |
| 769 | + | |
| 770 | + | |
767 | 771 | | |
768 | 772 | | |
769 | 773 | | |
| |||
997 | 1001 | | |
998 | 1002 | | |
999 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
1000 | 1006 | | |
1001 | 1007 | | |
1002 | 1008 | | |
| |||
1081 | 1087 | | |
1082 | 1088 | | |
1083 | 1089 | | |
1084 | | - | |
| 1090 | + | |
1085 | 1091 | | |
1086 | 1092 | | |
1087 | 1093 | | |
| |||
1105 | 1111 | | |
1106 | 1112 | | |
1107 | 1113 | | |
1108 | | - | |
| 1114 | + | |
1109 | 1115 | | |
1110 | 1116 | | |
1111 | 1117 | | |
| |||
1227 | 1233 | | |
1228 | 1234 | | |
1229 | 1235 | | |
1230 | | - | |
| 1236 | + | |
1231 | 1237 | | |
1232 | 1238 | | |
1233 | 1239 | | |
| |||
1245 | 1251 | | |
1246 | 1252 | | |
1247 | 1253 | | |
1248 | | - | |
| 1254 | + | |
1249 | 1255 | | |
1250 | 1256 | | |
1251 | 1257 | | |
| |||
1279 | 1285 | | |
1280 | 1286 | | |
1281 | 1287 | | |
1282 | | - | |
| 1288 | + | |
1283 | 1289 | | |
1284 | 1290 | | |
1285 | | - | |
1286 | | - | |
| 1291 | + | |
| 1292 | + | |
1287 | 1293 | | |
1288 | | - | |
1289 | 1294 | | |
1290 | 1295 | | |
1291 | 1296 | | |
| |||
1300 | 1305 | | |
1301 | 1306 | | |
1302 | 1307 | | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
1306 | 1308 | | |
1307 | 1309 | | |
1308 | 1310 | | |
| |||
1496 | 1498 | | |
1497 | 1499 | | |
1498 | 1500 | | |
| 1501 | + | |
| 1502 | + | |
1499 | 1503 | | |
1500 | 1504 | | |
1501 | 1505 | | |
| |||
1729 | 1733 | | |
1730 | 1734 | | |
1731 | 1735 | | |
| 1736 | + | |
| 1737 | + | |
1732 | 1738 | | |
1733 | 1739 | | |
1734 | 1740 | | |
| |||
2077 | 2083 | | |
2078 | 2084 | | |
2079 | 2085 | | |
| 2086 | + | |
| 2087 | + | |
2080 | 2088 | | |
2081 | 2089 | | |
2082 | 2090 | | |
| |||
2349 | 2357 | | |
2350 | 2358 | | |
2351 | 2359 | | |
| 2360 | + | |
| 2361 | + | |
2352 | 2362 | | |
2353 | 2363 | | |
2354 | 2364 | | |
| |||
2602 | 2612 | | |
2603 | 2613 | | |
2604 | 2614 | | |
| 2615 | + | |
| 2616 | + | |
2605 | 2617 | | |
2606 | 2618 | | |
2607 | 2619 | | |
| |||
2676 | 2688 | | |
2677 | 2689 | | |
2678 | 2690 | | |
| 2691 | + | |
| 2692 | + | |
2679 | 2693 | | |
2680 | 2694 | | |
2681 | 2695 | | |
| |||
2747 | 2761 | | |
2748 | 2762 | | |
2749 | 2763 | | |
| 2764 | + | |
| 2765 | + | |
2750 | 2766 | | |
2751 | 2767 | | |
2752 | 2768 | | |
| |||
3015 | 3031 | | |
3016 | 3032 | | |
3017 | 3033 | | |
| 3034 | + | |
| 3035 | + | |
3018 | 3036 | | |
3019 | 3037 | | |
3020 | 3038 | | |
| |||
3105 | 3123 | | |
3106 | 3124 | | |
3107 | 3125 | | |
| 3126 | + | |
| 3127 | + | |
3108 | 3128 | | |
3109 | 3129 | | |
3110 | 3130 | | |
| |||
3286 | 3306 | | |
3287 | 3307 | | |
3288 | 3308 | | |
| 3309 | + | |
| 3310 | + | |
3289 | 3311 | | |
3290 | 3312 | | |
3291 | 3313 | | |
| |||
3335 | 3357 | | |
3336 | 3358 | | |
3337 | 3359 | | |
| 3360 | + | |
| 3361 | + | |
3338 | 3362 | | |
3339 | 3363 | | |
3340 | 3364 | | |
| |||
3412 | 3436 | | |
3413 | 3437 | | |
3414 | 3438 | | |
| 3439 | + | |
| 3440 | + | |
3415 | 3441 | | |
3416 | 3442 | | |
3417 | 3443 | | |
| |||
3603 | 3629 | | |
3604 | 3630 | | |
3605 | 3631 | | |
| 3632 | + | |
| 3633 | + | |
3606 | 3634 | | |
3607 | 3635 | | |
3608 | 3636 | | |
| |||
3662 | 3690 | | |
3663 | 3691 | | |
3664 | 3692 | | |
| 3693 | + | |
| 3694 | + | |
3665 | 3695 | | |
3666 | 3696 | | |
3667 | 3697 | | |
| |||
3739 | 3769 | | |
3740 | 3770 | | |
3741 | 3771 | | |
| 3772 | + | |
| 3773 | + | |
3742 | 3774 | | |
3743 | 3775 | | |
3744 | 3776 | | |
| |||
3929 | 3961 | | |
3930 | 3962 | | |
3931 | 3963 | | |
| 3964 | + | |
| 3965 | + | |
3932 | 3966 | | |
3933 | 3967 | | |
3934 | 3968 | | |
| |||
3941 | 3975 | | |
3942 | 3976 | | |
3943 | 3977 | | |
| 3978 | + | |
| 3979 | + | |
3944 | 3980 | | |
3945 | 3981 | | |
3946 | 3982 | | |
| |||
4000 | 4036 | | |
4001 | 4037 | | |
4002 | 4038 | | |
| 4039 | + | |
| 4040 | + | |
4003 | 4041 | | |
4004 | 4042 | | |
4005 | 4043 | | |
| |||
4081 | 4119 | | |
4082 | 4120 | | |
4083 | 4121 | | |
| 4122 | + | |
| 4123 | + | |
4084 | 4124 | | |
4085 | 4125 | | |
4086 | 4126 | | |
| |||
4296 | 4336 | | |
4297 | 4337 | | |
4298 | 4338 | | |
| 4339 | + | |
| 4340 | + | |
4299 | 4341 | | |
4300 | 4342 | | |
4301 | 4343 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
2559 | 2560 | | |
2560 | 2561 | | |
2561 | 2562 | | |
2562 | | - | |
2563 | | - | |
| 2563 | + | |
2564 | 2564 | | |
2565 | 2565 | | |
2566 | 2566 | | |
| |||
2574 | 2574 | | |
2575 | 2575 | | |
2576 | 2576 | | |
2577 | | - | |
2578 | | - | |
| 2577 | + | |
2579 | 2578 | | |
2580 | 2579 | | |
2581 | 2580 | | |
| |||
0 commit comments