@metamask-previews/bridge-controller 72.0.4-preview-bfa94c060 → 73.0.0-preview-1275d0fda

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CHANGELOG.md +21 -2
  2. package/dist/bridge-controller-method-action-types.cjs.map +1 -1
  3. package/dist/bridge-controller-method-action-types.d.cts +5 -1
  4. package/dist/bridge-controller-method-action-types.d.cts.map +1 -1
  5. package/dist/bridge-controller-method-action-types.d.mts +5 -1
  6. package/dist/bridge-controller-method-action-types.d.mts.map +1 -1
  7. package/dist/bridge-controller-method-action-types.mjs.map +1 -1
  8. package/dist/bridge-controller.cjs +71 -2
  9. package/dist/bridge-controller.cjs.map +1 -1
  10. package/dist/bridge-controller.d.cts +8 -0
  11. package/dist/bridge-controller.d.cts.map +1 -1
  12. package/dist/bridge-controller.d.mts +8 -0
  13. package/dist/bridge-controller.d.mts.map +1 -1
  14. package/dist/bridge-controller.mjs +72 -3
  15. package/dist/bridge-controller.mjs.map +1 -1
  16. package/dist/constants/bridge.cjs +2 -0
  17. package/dist/constants/bridge.cjs.map +1 -1
  18. package/dist/constants/bridge.d.cts.map +1 -1
  19. package/dist/constants/bridge.d.mts.map +1 -1
  20. package/dist/constants/bridge.mjs +2 -0
  21. package/dist/constants/bridge.mjs.map +1 -1
  22. package/dist/index.cjs +4 -2
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +4 -4
  25. package/dist/index.d.cts.map +1 -1
  26. package/dist/index.d.mts +4 -4
  27. package/dist/index.d.mts.map +1 -1
  28. package/dist/index.mjs +2 -2
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/selectors.cjs +36 -4
  31. package/dist/selectors.cjs.map +1 -1
  32. package/dist/selectors.d.cts +3672 -3111
  33. package/dist/selectors.d.cts.map +1 -1
  34. package/dist/selectors.d.mts +3672 -3111
  35. package/dist/selectors.d.mts.map +1 -1
  36. package/dist/selectors.mjs +36 -4
  37. package/dist/selectors.mjs.map +1 -1
  38. package/dist/types.cjs.map +1 -1
  39. package/dist/types.d.cts +20 -2
  40. package/dist/types.d.cts.map +1 -1
  41. package/dist/types.d.mts +20 -2
  42. package/dist/types.d.mts.map +1 -1
  43. package/dist/types.mjs.map +1 -1
  44. package/dist/utils/bridge.cjs.map +1 -1
  45. package/dist/utils/bridge.d.cts +9 -9
  46. package/dist/utils/bridge.d.cts.map +1 -1
  47. package/dist/utils/bridge.d.mts +9 -9
  48. package/dist/utils/bridge.d.mts.map +1 -1
  49. package/dist/utils/bridge.mjs.map +1 -1
  50. package/dist/utils/fetch.cjs +55 -1
  51. package/dist/utils/fetch.cjs.map +1 -1
  52. package/dist/utils/fetch.d.cts +15 -1
  53. package/dist/utils/fetch.d.cts.map +1 -1
  54. package/dist/utils/fetch.d.mts +15 -1
  55. package/dist/utils/fetch.d.mts.map +1 -1
  56. package/dist/utils/fetch.mjs +53 -1
  57. package/dist/utils/fetch.mjs.map +1 -1
  58. package/dist/utils/metrics/constants.cjs +1 -0
  59. package/dist/utils/metrics/constants.cjs.map +1 -1
  60. package/dist/utils/metrics/constants.d.cts +2 -1
  61. package/dist/utils/metrics/constants.d.cts.map +1 -1
  62. package/dist/utils/metrics/constants.d.mts +2 -1
  63. package/dist/utils/metrics/constants.d.mts.map +1 -1
  64. package/dist/utils/metrics/constants.mjs +1 -0
  65. package/dist/utils/metrics/constants.mjs.map +1 -1
  66. package/dist/utils/quote.cjs +15 -1
  67. package/dist/utils/quote.cjs.map +1 -1
  68. package/dist/utils/quote.d.cts +15 -0
  69. package/dist/utils/quote.d.cts.map +1 -1
  70. package/dist/utils/quote.d.mts +15 -0
  71. package/dist/utils/quote.d.mts.map +1 -1
  72. package/dist/utils/quote.mjs +13 -0
  73. package/dist/utils/quote.mjs.map +1 -1
  74. package/dist/utils/slippage.d.cts +1 -1
  75. package/dist/utils/slippage.d.mts +1 -1
  76. package/dist/utils/trade-utils.d.cts +4 -4
  77. package/dist/utils/trade-utils.d.mts +4 -4
  78. package/dist/utils/validators.cjs +82 -51
  79. package/dist/utils/validators.cjs.map +1 -1
  80. package/dist/utils/validators.d.cts +317 -1451
  81. package/dist/utils/validators.d.cts.map +1 -1
  82. package/dist/utils/validators.d.mts +317 -1451
  83. package/dist/utils/validators.d.mts.map +1 -1
  84. package/dist/utils/validators.mjs +80 -50
  85. package/dist/utils/validators.mjs.map +1 -1
  86. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -7,16 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [73.0.0]
11
+
12
+ ### Added
13
+
14
+ - Implement transaction batch and fee fetching for BatchSell quotes ([#8805](https://github.com/MetaMask/core/pull/8805))
15
+ - add new states `batchSellTrades` and `batchSellTradesLoadingStatus` to contain transaction data and its fetch status
16
+ - support transaction batch data fetching with the new `updateBatchSellTrades` handler. Clients will need to call this whenever the recommended quotes update
17
+ - implement `selectBatchSellTrades` selector which returns whether a batch is submittable, and the `totalNetworkFee` provided by the `obtainGaslessBatch` endpoint and its converted values
18
+
10
19
  ### Changed
11
20
 
21
+ - **BREAKING**: Narrow TxData validation from generic string to Hex ([#8805](https://github.com/MetaMask/core/pull/
12
22
  - Bump `@metamask/assets-controller` from `^7.1.1` to `^7.1.2` ([#8783](https://github.com/MetaMask/core/pull/8783))
13
23
  - Bump `@metamask/assets-controllers` from `^108.0.0` to `^108.1.0` ([#8783](https://github.com/MetaMask/core/pull/8783))
14
24
  - Bump `@metamask/profile-sync-controller` from `^28.0.2` to `^28.1.0` ([#8783](https://github.com/MetaMask/core/pull/8783))
15
- - Bump `@metamask/transaction-controller` from `^65.3.0` to `^65.4.0` ([#8796](https://github.com/MetaMask/core/pull/8796))
25
+ - Bump `@metamask/transaction-controller` from `^65.3.0` to `^66.0.0` ([#8796](https://github.com/MetaMask/core/pull/8796), [#8848](https://github.com/MetaMask/core/pull/8848))
16
26
  - Bump `@metamask/gas-fee-controller` from `^26.2.1` to `^26.2.2` ([#8834](https://github.com/MetaMask/core/pull/8834))
17
27
  - Bump `@metamask/multichain-network-controller` from `^3.1.1` to `^3.1.2` ([#8834](https://github.com/MetaMask/core/pull/8834))
18
28
  - Bump `@metamask/polling-controller` from `^16.0.5` to `^16.0.6` ([#8834](https://github.com/MetaMask/core/pull/8834))
19
29
 
30
+ ### Removed
31
+
32
+ - **BREAKING**: Remove `totalNetworkFee` from the `selectBatchSellQuotes`'s results. Clients should use `selectBatchSellTrades` instead ([#8805](https://github.com/MetaMask/core/pull/8805))
33
+
34
+ ### Fixed
35
+
36
+ - fix non-evm token type detection ([#8811](https://github.com/MetaMask/core/pull/8811))
37
+
20
38
  ## [72.0.4]
21
39
 
22
40
  ### Changed
@@ -1482,7 +1500,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1482
1500
 
1483
1501
  - Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
1484
1502
 
1485
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@72.0.4...HEAD
1503
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@73.0.0...HEAD
1504
+ [73.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@72.0.4...@metamask/bridge-controller@73.0.0
1486
1505
  [72.0.4]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@72.0.3...@metamask/bridge-controller@72.0.4
1487
1506
  [72.0.3]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@72.0.2...@metamask/bridge-controller@72.0.3
1488
1507
  [72.0.2]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@72.0.1...@metamask/bridge-controller@72.0.2
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-controller-method-action-types.cjs","sourceRoot":"","sources":["../src/bridge-controller-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { BridgeController } from './bridge-controller';\n\nexport type BridgeControllerUpdateBridgeQuoteRequestParamsAction = {\n type: `BridgeController:updateBridgeQuoteRequestParams`;\n handler: BridgeController['updateBridgeQuoteRequestParams'];\n};\n\nexport type BridgeControllerFetchQuotesAction = {\n type: `BridgeController:fetchQuotes`;\n handler: BridgeController['fetchQuotes'];\n};\n\nexport type BridgeControllerStopPollingForQuotesAction = {\n type: `BridgeController:stopPollingForQuotes`;\n handler: BridgeController['stopPollingForQuotes'];\n};\n\nexport type BridgeControllerSetLocationAction = {\n type: `BridgeController:setLocation`;\n handler: BridgeController['setLocation'];\n};\n\nexport type BridgeControllerResetStateAction = {\n type: `BridgeController:resetState`;\n handler: BridgeController['resetState'];\n};\n\nexport type BridgeControllerSetChainIntervalLengthAction = {\n type: `BridgeController:setChainIntervalLength`;\n handler: BridgeController['setChainIntervalLength'];\n};\n\nexport type BridgeControllerTrackUnifiedSwapBridgeEventAction = {\n type: `BridgeController:trackUnifiedSwapBridgeEvent`;\n handler: BridgeController['trackUnifiedSwapBridgeEvent'];\n};\n\n/**\n * Union of all BridgeController action types.\n */\nexport type BridgeControllerMethodActions =\n | BridgeControllerUpdateBridgeQuoteRequestParamsAction\n | BridgeControllerFetchQuotesAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerSetLocationAction\n | BridgeControllerResetStateAction\n | BridgeControllerSetChainIntervalLengthAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction;\n"]}
1
+ {"version":3,"file":"bridge-controller-method-action-types.cjs","sourceRoot":"","sources":["../src/bridge-controller-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { BridgeController } from './bridge-controller';\n\nexport type BridgeControllerUpdateBridgeQuoteRequestParamsAction = {\n type: `BridgeController:updateBridgeQuoteRequestParams`;\n handler: BridgeController['updateBridgeQuoteRequestParams'];\n};\n\nexport type BridgeControllerFetchQuotesAction = {\n type: `BridgeController:fetchQuotes`;\n handler: BridgeController['fetchQuotes'];\n};\n\nexport type BridgeControllerStopPollingForQuotesAction = {\n type: `BridgeController:stopPollingForQuotes`;\n handler: BridgeController['stopPollingForQuotes'];\n};\n\nexport type BridgeControllerSetLocationAction = {\n type: `BridgeController:setLocation`;\n handler: BridgeController['setLocation'];\n};\n\nexport type BridgeControllerResetStateAction = {\n type: `BridgeController:resetState`;\n handler: BridgeController['resetState'];\n};\n\nexport type BridgeControllerSetChainIntervalLengthAction = {\n type: `BridgeController:setChainIntervalLength`;\n handler: BridgeController['setChainIntervalLength'];\n};\n\nexport type BridgeControllerTrackUnifiedSwapBridgeEventAction = {\n type: `BridgeController:trackUnifiedSwapBridgeEvent`;\n handler: BridgeController['trackUnifiedSwapBridgeEvent'];\n};\n\nexport type BridgeControllerUpdateBatchSellTradesAction = {\n type: `BridgeController:updateBatchSellTrades`;\n handler: BridgeController['updateBatchSellTrades'];\n};\n\n/**\n * Union of all BridgeController action types.\n */\nexport type BridgeControllerMethodActions =\n | BridgeControllerUpdateBridgeQuoteRequestParamsAction\n | BridgeControllerFetchQuotesAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerSetLocationAction\n | BridgeControllerResetStateAction\n | BridgeControllerSetChainIntervalLengthAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction\n | BridgeControllerUpdateBatchSellTradesAction;\n"]}
@@ -31,8 +31,12 @@ export type BridgeControllerTrackUnifiedSwapBridgeEventAction = {
31
31
  type: `BridgeController:trackUnifiedSwapBridgeEvent`;
32
32
  handler: BridgeController['trackUnifiedSwapBridgeEvent'];
33
33
  };
34
+ export type BridgeControllerUpdateBatchSellTradesAction = {
35
+ type: `BridgeController:updateBatchSellTrades`;
36
+ handler: BridgeController['updateBatchSellTrades'];
37
+ };
34
38
  /**
35
39
  * Union of all BridgeController action types.
36
40
  */
37
- export type BridgeControllerMethodActions = BridgeControllerUpdateBridgeQuoteRequestParamsAction | BridgeControllerFetchQuotesAction | BridgeControllerStopPollingForQuotesAction | BridgeControllerSetLocationAction | BridgeControllerResetStateAction | BridgeControllerSetChainIntervalLengthAction | BridgeControllerTrackUnifiedSwapBridgeEventAction;
41
+ export type BridgeControllerMethodActions = BridgeControllerUpdateBridgeQuoteRequestParamsAction | BridgeControllerFetchQuotesAction | BridgeControllerStopPollingForQuotesAction | BridgeControllerSetLocationAction | BridgeControllerResetStateAction | BridgeControllerSetChainIntervalLengthAction | BridgeControllerTrackUnifiedSwapBridgeEventAction | BridgeControllerUpdateBatchSellTradesAction;
38
42
  //# sourceMappingURL=bridge-controller-method-action-types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-controller-method-action-types.d.cts","sourceRoot":"","sources":["../src/bridge-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAE5D,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,gBAAgB,CAAC,6BAA6B,CAAC,CAAC;CAC1D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,oDAAoD,GACpD,iCAAiC,GACjC,0CAA0C,GAC1C,iCAAiC,GACjC,gCAAgC,GAChC,4CAA4C,GAC5C,iDAAiD,CAAC"}
1
+ {"version":3,"file":"bridge-controller-method-action-types.d.cts","sourceRoot":"","sources":["../src/bridge-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAE5D,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,gBAAgB,CAAC,6BAA6B,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,oDAAoD,GACpD,iCAAiC,GACjC,0CAA0C,GAC1C,iCAAiC,GACjC,gCAAgC,GAChC,4CAA4C,GAC5C,iDAAiD,GACjD,2CAA2C,CAAC"}
@@ -31,8 +31,12 @@ export type BridgeControllerTrackUnifiedSwapBridgeEventAction = {
31
31
  type: `BridgeController:trackUnifiedSwapBridgeEvent`;
32
32
  handler: BridgeController['trackUnifiedSwapBridgeEvent'];
33
33
  };
34
+ export type BridgeControllerUpdateBatchSellTradesAction = {
35
+ type: `BridgeController:updateBatchSellTrades`;
36
+ handler: BridgeController['updateBatchSellTrades'];
37
+ };
34
38
  /**
35
39
  * Union of all BridgeController action types.
36
40
  */
37
- export type BridgeControllerMethodActions = BridgeControllerUpdateBridgeQuoteRequestParamsAction | BridgeControllerFetchQuotesAction | BridgeControllerStopPollingForQuotesAction | BridgeControllerSetLocationAction | BridgeControllerResetStateAction | BridgeControllerSetChainIntervalLengthAction | BridgeControllerTrackUnifiedSwapBridgeEventAction;
41
+ export type BridgeControllerMethodActions = BridgeControllerUpdateBridgeQuoteRequestParamsAction | BridgeControllerFetchQuotesAction | BridgeControllerStopPollingForQuotesAction | BridgeControllerSetLocationAction | BridgeControllerResetStateAction | BridgeControllerSetChainIntervalLengthAction | BridgeControllerTrackUnifiedSwapBridgeEventAction | BridgeControllerUpdateBatchSellTradesAction;
38
42
  //# sourceMappingURL=bridge-controller-method-action-types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-controller-method-action-types.d.mts","sourceRoot":"","sources":["../src/bridge-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAE5D,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,gBAAgB,CAAC,6BAA6B,CAAC,CAAC;CAC1D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,oDAAoD,GACpD,iCAAiC,GACjC,0CAA0C,GAC1C,iCAAiC,GACjC,gCAAgC,GAChC,4CAA4C,GAC5C,iDAAiD,CAAC"}
1
+ {"version":3,"file":"bridge-controller-method-action-types.d.mts","sourceRoot":"","sources":["../src/bridge-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAE5D,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,6BAA6B,CAAC;IACpC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,gBAAgB,CAAC,6BAA6B,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,oDAAoD,GACpD,iCAAiC,GACjC,0CAA0C,GAC1C,iCAAiC,GACjC,gCAAgC,GAChC,4CAA4C,GAC5C,iDAAiD,GACjD,2CAA2C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-controller-method-action-types.mjs","sourceRoot":"","sources":["../src/bridge-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { BridgeController } from './bridge-controller';\n\nexport type BridgeControllerUpdateBridgeQuoteRequestParamsAction = {\n type: `BridgeController:updateBridgeQuoteRequestParams`;\n handler: BridgeController['updateBridgeQuoteRequestParams'];\n};\n\nexport type BridgeControllerFetchQuotesAction = {\n type: `BridgeController:fetchQuotes`;\n handler: BridgeController['fetchQuotes'];\n};\n\nexport type BridgeControllerStopPollingForQuotesAction = {\n type: `BridgeController:stopPollingForQuotes`;\n handler: BridgeController['stopPollingForQuotes'];\n};\n\nexport type BridgeControllerSetLocationAction = {\n type: `BridgeController:setLocation`;\n handler: BridgeController['setLocation'];\n};\n\nexport type BridgeControllerResetStateAction = {\n type: `BridgeController:resetState`;\n handler: BridgeController['resetState'];\n};\n\nexport type BridgeControllerSetChainIntervalLengthAction = {\n type: `BridgeController:setChainIntervalLength`;\n handler: BridgeController['setChainIntervalLength'];\n};\n\nexport type BridgeControllerTrackUnifiedSwapBridgeEventAction = {\n type: `BridgeController:trackUnifiedSwapBridgeEvent`;\n handler: BridgeController['trackUnifiedSwapBridgeEvent'];\n};\n\n/**\n * Union of all BridgeController action types.\n */\nexport type BridgeControllerMethodActions =\n | BridgeControllerUpdateBridgeQuoteRequestParamsAction\n | BridgeControllerFetchQuotesAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerSetLocationAction\n | BridgeControllerResetStateAction\n | BridgeControllerSetChainIntervalLengthAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction;\n"]}
1
+ {"version":3,"file":"bridge-controller-method-action-types.mjs","sourceRoot":"","sources":["../src/bridge-controller-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { BridgeController } from './bridge-controller';\n\nexport type BridgeControllerUpdateBridgeQuoteRequestParamsAction = {\n type: `BridgeController:updateBridgeQuoteRequestParams`;\n handler: BridgeController['updateBridgeQuoteRequestParams'];\n};\n\nexport type BridgeControllerFetchQuotesAction = {\n type: `BridgeController:fetchQuotes`;\n handler: BridgeController['fetchQuotes'];\n};\n\nexport type BridgeControllerStopPollingForQuotesAction = {\n type: `BridgeController:stopPollingForQuotes`;\n handler: BridgeController['stopPollingForQuotes'];\n};\n\nexport type BridgeControllerSetLocationAction = {\n type: `BridgeController:setLocation`;\n handler: BridgeController['setLocation'];\n};\n\nexport type BridgeControllerResetStateAction = {\n type: `BridgeController:resetState`;\n handler: BridgeController['resetState'];\n};\n\nexport type BridgeControllerSetChainIntervalLengthAction = {\n type: `BridgeController:setChainIntervalLength`;\n handler: BridgeController['setChainIntervalLength'];\n};\n\nexport type BridgeControllerTrackUnifiedSwapBridgeEventAction = {\n type: `BridgeController:trackUnifiedSwapBridgeEvent`;\n handler: BridgeController['trackUnifiedSwapBridgeEvent'];\n};\n\nexport type BridgeControllerUpdateBatchSellTradesAction = {\n type: `BridgeController:updateBatchSellTrades`;\n handler: BridgeController['updateBatchSellTrades'];\n};\n\n/**\n * Union of all BridgeController action types.\n */\nexport type BridgeControllerMethodActions =\n | BridgeControllerUpdateBridgeQuoteRequestParamsAction\n | BridgeControllerFetchQuotesAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerSetLocationAction\n | BridgeControllerResetStateAction\n | BridgeControllerSetChainIntervalLengthAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction\n | BridgeControllerUpdateBatchSellTradesAction;\n"]}
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _BridgeController_instances, _BridgeController_abortController, _BridgeController_quotesFirstFetched, _BridgeController_location, _BridgeController_clientId, _BridgeController_clientVersion, _BridgeController_getLayer1GasFee, _BridgeController_fetchFn, _BridgeController_trackMetaMetricsFn, _BridgeController_trace, _BridgeController_config, _BridgeController_getUseAssetsControllerForRates, _BridgeController_trackQuoteValidationFailures, _BridgeController_getExchangeRateSources, _BridgeController_fetchAssetExchangeRates, _BridgeController_hasInsufficientBalance, _BridgeController_appendInsufficientBalAndResetApproval, _BridgeController_shouldResetApproval, _BridgeController_fetchBridgeQuotes, _BridgeController_handleQuoteStreaming, _BridgeController_setMinimumBalanceForRentExemptionInLamports, _BridgeController_getMultichainSelectedAccount, _BridgeController_getNetworkClientByChainId, _BridgeController_getJwt, _BridgeController_getRequestMetadata, _BridgeController_getQuoteFetchData, _BridgeController_getEventProperties, _BridgeController_trackInputChangedEvents, _BridgeController_getUSDTMainnetAllowance;
13
+ var _BridgeController_instances, _BridgeController_abortController, _BridgeController_batchSellTradesAbortController, _BridgeController_quotesFirstFetched, _BridgeController_location, _BridgeController_clientId, _BridgeController_clientVersion, _BridgeController_getLayer1GasFee, _BridgeController_fetchFn, _BridgeController_trackMetaMetricsFn, _BridgeController_trace, _BridgeController_config, _BridgeController_getUseAssetsControllerForRates, _BridgeController_trackQuoteValidationFailures, _BridgeController_getExchangeRateSources, _BridgeController_fetchAssetExchangeRates, _BridgeController_hasInsufficientBalance, _BridgeController_appendInsufficientBalAndResetApproval, _BridgeController_shouldResetApproval, _BridgeController_fetchBridgeQuotes, _BridgeController_handleQuoteStreaming, _BridgeController_setMinimumBalanceForRentExemptionInLamports, _BridgeController_getMultichainSelectedAccount, _BridgeController_getNetworkClientByChainId, _BridgeController_getJwt, _BridgeController_getRequestMetadata, _BridgeController_getQuoteFetchData, _BridgeController_getEventProperties, _BridgeController_trackInputChangedEvents, _BridgeController_getUSDTMainnetAllowance;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.BridgeController = void 0;
16
16
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
@@ -109,10 +109,23 @@ const metadata = {
109
109
  includeInDebugSnapshot: false,
110
110
  usedInUi: true,
111
111
  },
112
+ batchSellTrades: {
113
+ includeInStateLogs: true,
114
+ persist: false,
115
+ includeInDebugSnapshot: false,
116
+ usedInUi: true,
117
+ },
118
+ batchSellTradesLoadingStatus: {
119
+ includeInStateLogs: true,
120
+ persist: false,
121
+ includeInDebugSnapshot: false,
122
+ usedInUi: true,
123
+ },
112
124
  };
113
125
  const MESSENGER_EXPOSED_METHODS = [
114
126
  'updateBridgeQuoteRequestParams',
115
127
  'fetchQuotes',
128
+ 'updateBatchSellTrades',
116
129
  'stopPollingForQuotes',
117
130
  'setLocation',
118
131
  'resetState',
@@ -132,6 +145,7 @@ class BridgeController extends (0, polling_controller_1.StaticIntervalPollingCon
132
145
  });
133
146
  _BridgeController_instances.add(this);
134
147
  _BridgeController_abortController.set(this, void 0);
148
+ _BridgeController_batchSellTradesAbortController.set(this, void 0);
135
149
  _BridgeController_quotesFirstFetched.set(this, void 0);
136
150
  /**
137
151
  * Stores the location/entry point from which the user initiated the swap or bridge flow.
@@ -227,6 +241,51 @@ class BridgeController extends (0, polling_controller_1.StaticIntervalPollingCon
227
241
  const quotesWithFees = await (0, quote_fees_1.appendFeesToQuotes)(baseQuotes, this.messenger, __classPrivateFieldGet(this, _BridgeController_getLayer1GasFee, "f"), __classPrivateFieldGet(this, _BridgeController_instances, "m", _BridgeController_getMultichainSelectedAccount).call(this, quoteRequest.walletAddress));
228
242
  return (0, quote_1.sortQuotes)(quotesWithFees, featureId);
229
243
  };
244
+ /**
245
+ * Fetches gasless transaction data and fees for BatchSell quotes.
246
+ * To use this in the clients, add a listener for the recommendedQuotes and call
247
+ * this handler whenever they change.
248
+ *
249
+ * @param quotes - The quotes to fetch the gasless transaction data and fees for
250
+ */
251
+ this.updateBatchSellTrades = async (quotes) => {
252
+ __classPrivateFieldGet(this, _BridgeController_batchSellTradesAbortController, "f")?.abort(constants_1.AbortReason.GaslessTxBatchFetched);
253
+ __classPrivateFieldSet(this, _BridgeController_batchSellTradesAbortController, new AbortController(), "f");
254
+ this.update((state) => {
255
+ // Set loading status again if recommended quotes are re-ordered
256
+ state.batchSellTradesLoadingStatus = types_1.RequestStatus.LOADING;
257
+ });
258
+ try {
259
+ const batchSellTradesResponse = await (0, fetch_1.fetchBatchSellTrades)(quotes, __classPrivateFieldGet(this, _BridgeController_batchSellTradesAbortController, "f").signal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), await __classPrivateFieldGet(this, _BridgeController_getJwt, "f").call(this), __classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? bridge_1.BRIDGE_PROD_API_BASE_URL, __classPrivateFieldGet(this, _BridgeController_clientVersion, "f"));
260
+ this.update((state) => {
261
+ state.batchSellTrades = batchSellTradesResponse;
262
+ state.batchSellTradesLoadingStatus = types_1.RequestStatus.FETCHED;
263
+ });
264
+ // TODO if fee.asset.assetId is not in exchange rates, fetch the exchange rate and update the state
265
+ }
266
+ catch (error) {
267
+ // Ignore abort errors
268
+ if (error.toString().includes('AbortError') ||
269
+ error.toString().includes('FetchRequestCanceledException') ||
270
+ [
271
+ constants_1.AbortReason.ResetState,
272
+ constants_1.AbortReason.NewQuoteRequest,
273
+ constants_1.AbortReason.QuoteRequestUpdated,
274
+ constants_1.AbortReason.TransactionSubmitted,
275
+ constants_1.AbortReason.GaslessTxBatchFetched,
276
+ ].includes(error)) {
277
+ // Exit the function early to prevent other state updates
278
+ return;
279
+ }
280
+ this.update((state) => {
281
+ // Reset the batch sell trades if the fetch fails to avoid showing stale data
282
+ state.batchSellTrades = bridge_1.DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;
283
+ // Update loading status
284
+ state.batchSellTradesLoadingStatus = types_1.RequestStatus.ERROR;
285
+ });
286
+ console.log(`Failed to fetch batch sell trades`, error);
287
+ }
288
+ };
230
289
  _BridgeController_trackQuoteValidationFailures.set(this, (validationFailures) => {
231
290
  if (validationFailures.length === 0) {
232
291
  return;
@@ -369,6 +428,7 @@ class BridgeController extends (0, polling_controller_1.StaticIntervalPollingCon
369
428
  }
370
429
  // Clears quotes list in state
371
430
  __classPrivateFieldGet(this, _BridgeController_abortController, "f")?.abort(reason);
431
+ __classPrivateFieldGet(this, _BridgeController_batchSellTradesAbortController, "f")?.abort(reason);
372
432
  };
373
433
  /**
374
434
  * Sets the location/entry point for the current swap or bridge flow.
@@ -414,6 +474,9 @@ class BridgeController extends (0, polling_controller_1.StaticIntervalPollingCon
414
474
  bridge_1.DEFAULT_BRIDGE_CONTROLLER_STATE.tokenSecurityTypeDestination;
415
475
  state.quoteStreamComplete =
416
476
  bridge_1.DEFAULT_BRIDGE_CONTROLLER_STATE.quoteStreamComplete;
477
+ state.batchSellTrades = bridge_1.DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;
478
+ state.batchSellTradesLoadingStatus =
479
+ bridge_1.DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTradesLoadingStatus;
417
480
  });
418
481
  };
419
482
  /**
@@ -433,6 +496,7 @@ class BridgeController extends (0, polling_controller_1.StaticIntervalPollingCon
433
496
  };
434
497
  _BridgeController_fetchBridgeQuotes.set(this, async ({ quoteRequests, context, }) => {
435
498
  __classPrivateFieldGet(this, _BridgeController_abortController, "f")?.abort(constants_1.AbortReason.NewQuoteRequest);
499
+ __classPrivateFieldGet(this, _BridgeController_batchSellTradesAbortController, "f")?.abort(constants_1.AbortReason.NewQuoteRequest);
436
500
  __classPrivateFieldSet(this, _BridgeController_abortController, new AbortController(), "f");
437
501
  __classPrivateFieldGet(this, _BridgeController_fetchAssetExchangeRates, "f").call(this, quoteRequests).catch((error) => console.warn('Failed to fetch asset exchange rates', error));
438
502
  this.trackUnifiedSwapBridgeEvent(constants_1.UnifiedSwapBridgeEventName.QuotesRequested, context);
@@ -447,6 +511,11 @@ class BridgeController extends (0, polling_controller_1.StaticIntervalPollingCon
447
511
  bridge_1.DEFAULT_BRIDGE_CONTROLLER_STATE.quoteStreamComplete;
448
512
  state.quotesLastFetched = Date.now();
449
513
  state.quotesLoadingStatus = types_1.RequestStatus.LOADING;
514
+ // Prevent clients from displaying stale batch sell fees
515
+ if (quoteRequests.length > 1) {
516
+ state.batchSellTradesLoadingStatus = types_1.RequestStatus.LOADING;
517
+ state.batchSellTrades = bridge_1.DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;
518
+ }
450
519
  });
451
520
  const jwt = await __classPrivateFieldGet(this, _BridgeController_getJwt, "f").call(this);
452
521
  try {
@@ -820,7 +889,7 @@ class BridgeController extends (0, polling_controller_1.StaticIntervalPollingCon
820
889
  }
821
890
  }
822
891
  exports.BridgeController = BridgeController;
823
- _BridgeController_abortController = new WeakMap(), _BridgeController_quotesFirstFetched = new WeakMap(), _BridgeController_location = new WeakMap(), _BridgeController_clientId = new WeakMap(), _BridgeController_clientVersion = new WeakMap(), _BridgeController_getLayer1GasFee = new WeakMap(), _BridgeController_fetchFn = new WeakMap(), _BridgeController_trackMetaMetricsFn = new WeakMap(), _BridgeController_trace = new WeakMap(), _BridgeController_config = new WeakMap(), _BridgeController_getUseAssetsControllerForRates = new WeakMap(), _BridgeController_trackQuoteValidationFailures = new WeakMap(), _BridgeController_getExchangeRateSources = new WeakMap(), _BridgeController_fetchAssetExchangeRates = new WeakMap(), _BridgeController_hasInsufficientBalance = new WeakMap(), _BridgeController_appendInsufficientBalAndResetApproval = new WeakMap(), _BridgeController_shouldResetApproval = new WeakMap(), _BridgeController_fetchBridgeQuotes = new WeakMap(), _BridgeController_handleQuoteStreaming = new WeakMap(), _BridgeController_setMinimumBalanceForRentExemptionInLamports = new WeakMap(), _BridgeController_getJwt = new WeakMap(), _BridgeController_getRequestMetadata = new WeakMap(), _BridgeController_getQuoteFetchData = new WeakMap(), _BridgeController_getEventProperties = new WeakMap(), _BridgeController_trackInputChangedEvents = new WeakMap(), _BridgeController_getUSDTMainnetAllowance = new WeakMap(), _BridgeController_instances = new WeakSet(), _BridgeController_getMultichainSelectedAccount = function _BridgeController_getMultichainSelectedAccount(walletAddress) {
892
+ _BridgeController_abortController = new WeakMap(), _BridgeController_batchSellTradesAbortController = new WeakMap(), _BridgeController_quotesFirstFetched = new WeakMap(), _BridgeController_location = new WeakMap(), _BridgeController_clientId = new WeakMap(), _BridgeController_clientVersion = new WeakMap(), _BridgeController_getLayer1GasFee = new WeakMap(), _BridgeController_fetchFn = new WeakMap(), _BridgeController_trackMetaMetricsFn = new WeakMap(), _BridgeController_trace = new WeakMap(), _BridgeController_config = new WeakMap(), _BridgeController_getUseAssetsControllerForRates = new WeakMap(), _BridgeController_trackQuoteValidationFailures = new WeakMap(), _BridgeController_getExchangeRateSources = new WeakMap(), _BridgeController_fetchAssetExchangeRates = new WeakMap(), _BridgeController_hasInsufficientBalance = new WeakMap(), _BridgeController_appendInsufficientBalAndResetApproval = new WeakMap(), _BridgeController_shouldResetApproval = new WeakMap(), _BridgeController_fetchBridgeQuotes = new WeakMap(), _BridgeController_handleQuoteStreaming = new WeakMap(), _BridgeController_setMinimumBalanceForRentExemptionInLamports = new WeakMap(), _BridgeController_getJwt = new WeakMap(), _BridgeController_getRequestMetadata = new WeakMap(), _BridgeController_getQuoteFetchData = new WeakMap(), _BridgeController_getEventProperties = new WeakMap(), _BridgeController_trackInputChangedEvents = new WeakMap(), _BridgeController_getUSDTMainnetAllowance = new WeakMap(), _BridgeController_instances = new WeakSet(), _BridgeController_getMultichainSelectedAccount = function _BridgeController_getMultichainSelectedAccount(walletAddress) {
824
893
  // Assume that all quotes in a batch are for the same account
825
894
  const addressToUse = walletAddress ?? this.state.quoteRequest[0].walletAddress;
826
895
  if (!addressToUse) {