@metamask-previews/bridge-status-controller 75.4.0-preview-3866c0ff1 → 75.4.0-preview-e3275932a

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 (408) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/bridge-status-controller-method-action-types.cjs +7 -0
  3. package/dist/bridge-status-controller-method-action-types.cjs.map +1 -0
  4. package/dist/{bridge-status-controller-method-action-types.d.ts → bridge-status-controller-method-action-types.d.cts} +2 -2
  5. package/dist/bridge-status-controller-method-action-types.d.cts.map +1 -0
  6. package/dist/bridge-status-controller-method-action-types.d.mts +42 -0
  7. package/dist/bridge-status-controller-method-action-types.d.mts.map +1 -0
  8. package/dist/{bridge-status-controller-method-action-types.js → bridge-status-controller-method-action-types.mjs} +1 -1
  9. package/dist/bridge-status-controller-method-action-types.mjs.map +1 -0
  10. package/dist/bridge-status-controller.cjs +1144 -0
  11. package/dist/bridge-status-controller.cjs.map +1 -0
  12. package/dist/{bridge-status-controller.d.ts → bridge-status-controller.d.cts} +20 -20
  13. package/dist/bridge-status-controller.d.cts.map +1 -0
  14. package/dist/bridge-status-controller.d.mts +155 -0
  15. package/dist/bridge-status-controller.d.mts.map +1 -0
  16. package/dist/bridge-status-controller.intent.cjs +116 -0
  17. package/dist/bridge-status-controller.intent.cjs.map +1 -0
  18. package/dist/{bridge-status-controller.intent.d.ts → bridge-status-controller.intent.d.cts} +6 -6
  19. package/dist/bridge-status-controller.intent.d.cts.map +1 -0
  20. package/dist/bridge-status-controller.intent.d.mts +36 -0
  21. package/dist/bridge-status-controller.intent.d.mts.map +1 -0
  22. package/dist/bridge-status-controller.intent.mjs +112 -0
  23. package/dist/bridge-status-controller.intent.mjs.map +1 -0
  24. package/dist/bridge-status-controller.mjs +1137 -0
  25. package/dist/bridge-status-controller.mjs.map +1 -0
  26. package/dist/constants.cjs +31 -0
  27. package/dist/constants.cjs.map +1 -0
  28. package/dist/{constants.d.ts → constants.d.cts} +3 -3
  29. package/dist/constants.d.cts.map +1 -0
  30. package/dist/constants.d.mts +18 -0
  31. package/dist/constants.d.mts.map +1 -0
  32. package/dist/{constants.js → constants.mjs} +2 -2
  33. package/dist/constants.mjs.map +1 -0
  34. package/dist/index.cjs +24 -0
  35. package/dist/index.cjs.map +1 -0
  36. package/dist/{index.d.ts → index.d.cts} +9 -9
  37. package/dist/index.d.cts.map +1 -0
  38. package/dist/index.d.mts +9 -0
  39. package/dist/index.d.mts.map +1 -0
  40. package/dist/index.mjs +9 -0
  41. package/dist/index.mjs.map +1 -0
  42. package/dist/quote-status-manager/constants.cjs +196 -0
  43. package/dist/quote-status-manager/constants.cjs.map +1 -0
  44. package/dist/quote-status-manager/{constants.d.ts → constants.d.cts} +1 -1
  45. package/dist/quote-status-manager/constants.d.cts.map +1 -0
  46. package/dist/quote-status-manager/constants.d.mts +152 -0
  47. package/dist/quote-status-manager/constants.d.mts.map +1 -0
  48. package/dist/quote-status-manager/{constants.js → constants.mjs} +1 -1
  49. package/dist/quote-status-manager/constants.mjs.map +1 -0
  50. package/dist/quote-status-manager/errors.cjs +57 -0
  51. package/dist/quote-status-manager/errors.cjs.map +1 -0
  52. package/dist/quote-status-manager/{errors.d.ts → errors.d.cts} +2 -2
  53. package/dist/quote-status-manager/errors.d.cts.map +1 -0
  54. package/dist/quote-status-manager/errors.d.mts +51 -0
  55. package/dist/quote-status-manager/errors.d.mts.map +1 -0
  56. package/dist/quote-status-manager/{errors.js → errors.mjs} +1 -10
  57. package/dist/quote-status-manager/errors.mjs.map +1 -0
  58. package/dist/quote-status-manager/quote-status-api-service.cjs +241 -0
  59. package/dist/quote-status-manager/quote-status-api-service.cjs.map +1 -0
  60. package/dist/quote-status-manager/{quote-status-api-service.d.ts → quote-status-api-service.d.cts} +5 -5
  61. package/dist/quote-status-manager/quote-status-api-service.d.cts.map +1 -0
  62. package/dist/quote-status-manager/quote-status-api-service.d.mts +93 -0
  63. package/dist/quote-status-manager/quote-status-api-service.d.mts.map +1 -0
  64. package/dist/quote-status-manager/{quote-status-api-service.js → quote-status-api-service.mjs} +51 -37
  65. package/dist/quote-status-manager/quote-status-api-service.mjs.map +1 -0
  66. package/dist/quote-status-manager/quote-status-entry-store.cjs +293 -0
  67. package/dist/quote-status-manager/quote-status-entry-store.cjs.map +1 -0
  68. package/dist/quote-status-manager/{quote-status-entry-store.d.ts → quote-status-entry-store.d.cts} +2 -2
  69. package/dist/quote-status-manager/quote-status-entry-store.d.cts.map +1 -0
  70. package/dist/quote-status-manager/quote-status-entry-store.d.mts +157 -0
  71. package/dist/quote-status-manager/quote-status-entry-store.d.mts.map +1 -0
  72. package/dist/quote-status-manager/{quote-status-entry-store.js → quote-status-entry-store.mjs} +51 -53
  73. package/dist/quote-status-manager/quote-status-entry-store.mjs.map +1 -0
  74. package/dist/quote-status-manager/quote-status-get-with-retry-outcome.cjs +29 -0
  75. package/dist/quote-status-manager/quote-status-get-with-retry-outcome.cjs.map +1 -0
  76. package/dist/quote-status-manager/{quote-status-get-with-retry-outcome.d.ts → quote-status-get-with-retry-outcome.d.cts} +4 -4
  77. package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.cts.map +1 -0
  78. package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.mts +32 -0
  79. package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.mts.map +1 -0
  80. package/dist/quote-status-manager/{quote-status-get-with-retry-outcome.js → quote-status-get-with-retry-outcome.mjs} +3 -11
  81. package/dist/quote-status-manager/quote-status-get-with-retry-outcome.mjs.map +1 -0
  82. package/dist/quote-status-manager/quote-status-state-fsm.cjs +107 -0
  83. package/dist/quote-status-manager/quote-status-state-fsm.cjs.map +1 -0
  84. package/dist/quote-status-manager/{quote-status-state-fsm.d.ts → quote-status-state-fsm.d.cts} +3 -3
  85. package/dist/quote-status-manager/quote-status-state-fsm.d.cts.map +1 -0
  86. package/dist/quote-status-manager/quote-status-state-fsm.d.mts +57 -0
  87. package/dist/quote-status-manager/quote-status-state-fsm.d.mts.map +1 -0
  88. package/dist/quote-status-manager/quote-status-state-fsm.mjs +103 -0
  89. package/dist/quote-status-manager/quote-status-state-fsm.mjs.map +1 -0
  90. package/dist/quote-status-manager/quote-status-update-with-retry-outcome.cjs +27 -0
  91. package/dist/quote-status-manager/quote-status-update-with-retry-outcome.cjs.map +1 -0
  92. package/dist/quote-status-manager/{quote-status-update-with-retry-outcome.d.ts → quote-status-update-with-retry-outcome.d.cts} +3 -3
  93. package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.cts.map +1 -0
  94. package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.mts +30 -0
  95. package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.mts.map +1 -0
  96. package/dist/quote-status-manager/{quote-status-update-with-retry-outcome.js → quote-status-update-with-retry-outcome.mjs} +2 -10
  97. package/dist/quote-status-manager/quote-status-update-with-retry-outcome.mjs.map +1 -0
  98. package/dist/quote-status-manager/quotes-status-manager.cjs +506 -0
  99. package/dist/quote-status-manager/quotes-status-manager.cjs.map +1 -0
  100. package/dist/quote-status-manager/{quotes-status-manager.d.ts → quotes-status-manager.d.cts} +5 -5
  101. package/dist/quote-status-manager/quotes-status-manager.d.cts.map +1 -0
  102. package/dist/quote-status-manager/quotes-status-manager.d.mts +135 -0
  103. package/dist/quote-status-manager/quotes-status-manager.d.mts.map +1 -0
  104. package/dist/quote-status-manager/quotes-status-manager.mjs +502 -0
  105. package/dist/quote-status-manager/quotes-status-manager.mjs.map +1 -0
  106. package/dist/quote-status-manager/types.cjs +8 -0
  107. package/dist/quote-status-manager/types.cjs.map +1 -0
  108. package/dist/quote-status-manager/{types.d.ts → types.d.cts} +8 -8
  109. package/dist/quote-status-manager/types.d.cts.map +1 -0
  110. package/dist/quote-status-manager/types.d.mts +164 -0
  111. package/dist/quote-status-manager/types.d.mts.map +1 -0
  112. package/dist/quote-status-manager/types.mjs +6 -0
  113. package/dist/quote-status-manager/types.mjs.map +1 -0
  114. package/dist/quote-status-manager/utils.cjs +11 -0
  115. package/dist/quote-status-manager/utils.cjs.map +1 -0
  116. package/dist/quote-status-manager/{utils.d.ts → utils.d.cts} +1 -1
  117. package/dist/quote-status-manager/utils.d.cts.map +1 -0
  118. package/dist/quote-status-manager/utils.d.mts +7 -0
  119. package/dist/quote-status-manager/utils.d.mts.map +1 -0
  120. package/dist/quote-status-manager/{utils.js → utils.mjs} +1 -1
  121. package/dist/quote-status-manager/utils.mjs.map +1 -0
  122. package/dist/quote-status-manager/validators.cjs +44 -0
  123. package/dist/quote-status-manager/validators.cjs.map +1 -0
  124. package/dist/quote-status-manager/{validators.d.ts → validators.d.cts} +43 -43
  125. package/dist/quote-status-manager/validators.d.cts.map +1 -0
  126. package/dist/quote-status-manager/validators.d.mts +172 -0
  127. package/dist/quote-status-manager/validators.d.mts.map +1 -0
  128. package/dist/quote-status-manager/{validators.js → validators.mjs} +4 -4
  129. package/dist/quote-status-manager/validators.mjs.map +1 -0
  130. package/dist/strategy/batch-sell-strategy.cjs +113 -0
  131. package/dist/strategy/batch-sell-strategy.cjs.map +1 -0
  132. package/dist/strategy/{batch-sell-strategy.d.ts → batch-sell-strategy.d.cts} +3 -3
  133. package/dist/strategy/batch-sell-strategy.d.cts.map +1 -0
  134. package/dist/strategy/batch-sell-strategy.d.mts +10 -0
  135. package/dist/strategy/batch-sell-strategy.d.mts.map +1 -0
  136. package/dist/strategy/{batch-sell-strategy.js → batch-sell-strategy.mjs} +4 -4
  137. package/dist/strategy/batch-sell-strategy.mjs.map +1 -0
  138. package/dist/strategy/batch-strategy.cjs +64 -0
  139. package/dist/strategy/batch-strategy.cjs.map +1 -0
  140. package/dist/strategy/{batch-strategy.d.ts → batch-strategy.d.cts} +3 -3
  141. package/dist/strategy/batch-strategy.d.cts.map +1 -0
  142. package/dist/strategy/batch-strategy.d.mts +10 -0
  143. package/dist/strategy/batch-strategy.d.mts.map +1 -0
  144. package/dist/strategy/{batch-strategy.js → batch-strategy.mjs} +3 -3
  145. package/dist/strategy/batch-strategy.mjs.map +1 -0
  146. package/dist/strategy/evm-strategy.cjs +149 -0
  147. package/dist/strategy/evm-strategy.cjs.map +1 -0
  148. package/dist/strategy/{evm-strategy.d.ts → evm-strategy.d.cts} +8 -8
  149. package/dist/strategy/evm-strategy.d.cts.map +1 -0
  150. package/dist/strategy/evm-strategy.d.mts +38 -0
  151. package/dist/strategy/evm-strategy.d.mts.map +1 -0
  152. package/dist/strategy/{evm-strategy.js → evm-strategy.mjs} +8 -8
  153. package/dist/strategy/evm-strategy.mjs.map +1 -0
  154. package/dist/strategy/index.cjs +72 -0
  155. package/dist/strategy/index.cjs.map +1 -0
  156. package/dist/strategy/{index.d.ts → index.d.cts} +3 -3
  157. package/dist/strategy/index.d.cts.map +1 -0
  158. package/dist/strategy/index.d.mts +12 -0
  159. package/dist/strategy/index.d.mts.map +1 -0
  160. package/dist/strategy/{index.js → index.mjs} +7 -7
  161. package/dist/strategy/index.mjs.map +1 -0
  162. package/dist/strategy/intent-strategy.cjs +160 -0
  163. package/dist/strategy/{intent-strategy.js.map → intent-strategy.cjs.map} +1 -1
  164. package/dist/strategy/{intent-strategy.d.ts → intent-strategy.d.cts} +3 -3
  165. package/dist/strategy/intent-strategy.d.cts.map +1 -0
  166. package/dist/strategy/intent-strategy.d.mts +17 -0
  167. package/dist/strategy/intent-strategy.d.mts.map +1 -0
  168. package/dist/strategy/{intent-strategy.js → intent-strategy.mjs} +10 -10
  169. package/dist/strategy/intent-strategy.mjs.map +1 -0
  170. package/dist/strategy/non-evm-strategy.cjs +80 -0
  171. package/dist/strategy/non-evm-strategy.cjs.map +1 -0
  172. package/dist/strategy/{non-evm-strategy.d.ts → non-evm-strategy.d.cts} +3 -3
  173. package/dist/strategy/non-evm-strategy.d.cts.map +1 -0
  174. package/dist/strategy/non-evm-strategy.d.mts +15 -0
  175. package/dist/strategy/non-evm-strategy.d.mts.map +1 -0
  176. package/dist/strategy/{non-evm-strategy.js → non-evm-strategy.mjs} +6 -6
  177. package/dist/strategy/non-evm-strategy.mjs.map +1 -0
  178. package/dist/strategy/types.cjs +33 -0
  179. package/dist/strategy/types.cjs.map +1 -0
  180. package/dist/strategy/{types.d.ts → types.d.cts} +7 -7
  181. package/dist/strategy/types.d.cts.map +1 -0
  182. package/dist/strategy/types.d.mts +116 -0
  183. package/dist/strategy/types.d.mts.map +1 -0
  184. package/dist/strategy/{types.js → types.mjs} +1 -1
  185. package/dist/strategy/types.mjs.map +1 -0
  186. package/dist/types.cjs +44 -0
  187. package/dist/types.cjs.map +1 -0
  188. package/dist/{types.d.ts → types.d.cts} +17 -17
  189. package/dist/types.d.cts.map +1 -0
  190. package/dist/types.d.mts +308 -0
  191. package/dist/types.d.mts.map +1 -0
  192. package/dist/{types.js → types.mjs} +4 -1
  193. package/dist/types.mjs.map +1 -0
  194. package/dist/utils/accounts.cjs +8 -0
  195. package/dist/utils/accounts.cjs.map +1 -0
  196. package/dist/utils/{accounts.d.ts → accounts.d.cts} +7 -7
  197. package/dist/utils/accounts.d.cts.map +1 -0
  198. package/dist/utils/accounts.d.mts +34 -0
  199. package/dist/utils/accounts.d.mts.map +1 -0
  200. package/dist/utils/{accounts.js → accounts.mjs} +1 -1
  201. package/dist/utils/accounts.mjs.map +1 -0
  202. package/dist/utils/authentication.cjs +15 -0
  203. package/dist/utils/authentication.cjs.map +1 -0
  204. package/dist/utils/authentication.d.cts +3 -0
  205. package/dist/utils/authentication.d.cts.map +1 -0
  206. package/dist/utils/authentication.d.mts +3 -0
  207. package/dist/utils/authentication.d.mts.map +1 -0
  208. package/dist/utils/{authentication.js → authentication.mjs} +1 -1
  209. package/dist/utils/authentication.mjs.map +1 -0
  210. package/dist/utils/bridge-status.cjs +157 -0
  211. package/dist/utils/bridge-status.cjs.map +1 -0
  212. package/dist/utils/{bridge-status.d.ts → bridge-status.d.cts} +4 -4
  213. package/dist/utils/bridge-status.d.cts.map +1 -0
  214. package/dist/utils/bridge-status.d.mts +23 -0
  215. package/dist/utils/bridge-status.d.mts.map +1 -0
  216. package/dist/utils/{bridge-status.js → bridge-status.mjs} +8 -7
  217. package/dist/utils/bridge-status.mjs.map +1 -0
  218. package/dist/utils/bridge.cjs +17 -0
  219. package/dist/utils/bridge.cjs.map +1 -0
  220. package/dist/utils/{bridge.d.ts → bridge.d.cts} +3 -3
  221. package/dist/utils/bridge.d.cts.map +1 -0
  222. package/dist/utils/bridge.d.mts +10 -0
  223. package/dist/utils/bridge.d.mts.map +1 -0
  224. package/dist/utils/{bridge.js → bridge.mjs} +2 -2
  225. package/dist/utils/bridge.mjs.map +1 -0
  226. package/dist/utils/feature-flags.cjs +12 -0
  227. package/dist/utils/feature-flags.cjs.map +1 -0
  228. package/dist/utils/{feature-flags.d.ts → feature-flags.d.cts} +2 -2
  229. package/dist/utils/feature-flags.d.cts.map +1 -0
  230. package/dist/utils/feature-flags.d.mts +3 -0
  231. package/dist/utils/feature-flags.d.mts.map +1 -0
  232. package/dist/utils/{feature-flags.js → feature-flags.mjs} +3 -3
  233. package/dist/utils/feature-flags.mjs.map +1 -0
  234. package/dist/utils/gas.cjs +35 -0
  235. package/dist/utils/gas.cjs.map +1 -0
  236. package/dist/utils/{gas.d.ts → gas.d.cts} +4 -4
  237. package/dist/utils/gas.d.cts.map +1 -0
  238. package/dist/utils/gas.d.mts +14 -0
  239. package/dist/utils/gas.d.mts.map +1 -0
  240. package/dist/utils/{gas.js → gas.mjs} +2 -2
  241. package/dist/utils/gas.mjs.map +1 -0
  242. package/dist/utils/history.cjs +200 -0
  243. package/dist/utils/history.cjs.map +1 -0
  244. package/dist/utils/{history.d.ts → history.d.cts} +3 -3
  245. package/dist/utils/history.d.cts.map +1 -0
  246. package/dist/utils/history.d.mts +54 -0
  247. package/dist/utils/history.d.mts.map +1 -0
  248. package/dist/utils/{history.js → history.mjs} +3 -3
  249. package/dist/utils/history.mjs.map +1 -0
  250. package/dist/utils/intent-api.cjs +143 -0
  251. package/dist/utils/intent-api.cjs.map +1 -0
  252. package/dist/utils/{intent-api.d.ts → intent-api.d.cts} +5 -5
  253. package/dist/utils/intent-api.d.cts.map +1 -0
  254. package/dist/utils/intent-api.d.mts +44 -0
  255. package/dist/utils/intent-api.d.mts.map +1 -0
  256. package/dist/utils/{intent-api.js → intent-api.mjs} +26 -13
  257. package/dist/utils/intent-api.mjs.map +1 -0
  258. package/dist/utils/keyring.cjs +12 -0
  259. package/dist/utils/keyring.cjs.map +1 -0
  260. package/dist/utils/{keyring.d.ts → keyring.d.cts} +3 -3
  261. package/dist/utils/keyring.d.cts.map +1 -0
  262. package/dist/utils/keyring.d.mts +8 -0
  263. package/dist/utils/keyring.d.mts.map +1 -0
  264. package/dist/utils/{keyring.js → keyring.mjs} +2 -2
  265. package/dist/utils/keyring.mjs.map +1 -0
  266. package/dist/utils/metrics.cjs +248 -0
  267. package/dist/utils/metrics.cjs.map +1 -0
  268. package/dist/utils/{metrics.d.ts → metrics.d.cts} +22 -22
  269. package/dist/utils/metrics.d.cts.map +1 -0
  270. package/dist/utils/metrics.d.mts +120 -0
  271. package/dist/utils/metrics.d.mts.map +1 -0
  272. package/dist/utils/{metrics.js → metrics.mjs} +6 -6
  273. package/dist/utils/metrics.mjs.map +1 -0
  274. package/dist/utils/network.cjs +23 -0
  275. package/dist/utils/network.cjs.map +1 -0
  276. package/dist/utils/{network.d.ts → network.d.cts} +4 -4
  277. package/dist/utils/network.d.cts.map +1 -0
  278. package/dist/utils/network.d.mts +7 -0
  279. package/dist/utils/network.d.mts.map +1 -0
  280. package/dist/utils/{network.js → network.mjs} +2 -2
  281. package/dist/utils/network.mjs.map +1 -0
  282. package/dist/utils/snaps.cjs +199 -0
  283. package/dist/utils/snaps.cjs.map +1 -0
  284. package/dist/utils/{snaps.d.ts → snaps.d.cts} +8 -8
  285. package/dist/utils/snaps.d.cts.map +1 -0
  286. package/dist/utils/snaps.d.mts +79 -0
  287. package/dist/utils/snaps.d.mts.map +1 -0
  288. package/dist/utils/{snaps.js → snaps.mjs} +5 -4
  289. package/dist/utils/snaps.mjs.map +1 -0
  290. package/dist/utils/swap-received-amount.cjs +94 -0
  291. package/dist/utils/swap-received-amount.cjs.map +1 -0
  292. package/dist/utils/{swap-received-amount.d.ts → swap-received-amount.d.cts} +5 -5
  293. package/dist/utils/swap-received-amount.d.cts.map +1 -0
  294. package/dist/utils/swap-received-amount.d.mts +25 -0
  295. package/dist/utils/swap-received-amount.d.mts.map +1 -0
  296. package/dist/utils/{swap-received-amount.js → swap-received-amount.mjs} +3 -3
  297. package/dist/utils/swap-received-amount.mjs.map +1 -0
  298. package/dist/utils/trace.cjs +58 -0
  299. package/dist/utils/trace.cjs.map +1 -0
  300. package/dist/utils/{trace.d.ts → trace.d.cts} +7 -7
  301. package/dist/utils/trace.d.cts.map +1 -0
  302. package/dist/utils/trace.d.mts +39 -0
  303. package/dist/utils/trace.d.mts.map +1 -0
  304. package/dist/utils/{trace.js → trace.mjs} +3 -3
  305. package/dist/utils/trace.mjs.map +1 -0
  306. package/dist/utils/transaction.cjs +395 -0
  307. package/dist/utils/transaction.cjs.map +1 -0
  308. package/dist/utils/{transaction.d.ts → transaction.d.cts} +17 -17
  309. package/dist/utils/transaction.d.cts.map +1 -0
  310. package/dist/utils/transaction.d.mts +122 -0
  311. package/dist/utils/transaction.d.mts.map +1 -0
  312. package/dist/utils/{transaction.js → transaction.mjs} +9 -9
  313. package/dist/utils/transaction.mjs.map +1 -0
  314. package/dist/utils/validators.cjs +67 -0
  315. package/dist/utils/validators.cjs.map +1 -0
  316. package/dist/utils/{validators.d.ts → validators.d.cts} +82 -39
  317. package/dist/utils/validators.d.cts.map +1 -0
  318. package/dist/utils/validators.d.mts +201 -0
  319. package/dist/utils/validators.d.mts.map +1 -0
  320. package/dist/utils/{validators.js → validators.mjs} +3 -3
  321. package/dist/utils/validators.mjs.map +1 -0
  322. package/package.json +17 -13
  323. package/dist/bridge-status-controller-method-action-types.d.ts.map +0 -1
  324. package/dist/bridge-status-controller-method-action-types.js.map +0 -1
  325. package/dist/bridge-status-controller.d.ts.map +0 -1
  326. package/dist/bridge-status-controller.intent.d.ts.map +0 -1
  327. package/dist/bridge-status-controller.intent.js +0 -108
  328. package/dist/bridge-status-controller.intent.js.map +0 -1
  329. package/dist/bridge-status-controller.js +0 -1123
  330. package/dist/bridge-status-controller.js.map +0 -1
  331. package/dist/constants.d.ts.map +0 -1
  332. package/dist/constants.js.map +0 -1
  333. package/dist/index.d.ts.map +0 -1
  334. package/dist/index.js +0 -9
  335. package/dist/index.js.map +0 -1
  336. package/dist/quote-status-manager/constants.d.ts.map +0 -1
  337. package/dist/quote-status-manager/constants.js.map +0 -1
  338. package/dist/quote-status-manager/errors.d.ts.map +0 -1
  339. package/dist/quote-status-manager/errors.js.map +0 -1
  340. package/dist/quote-status-manager/quote-status-api-service.d.ts.map +0 -1
  341. package/dist/quote-status-manager/quote-status-api-service.js.map +0 -1
  342. package/dist/quote-status-manager/quote-status-entry-store.d.ts.map +0 -1
  343. package/dist/quote-status-manager/quote-status-entry-store.js.map +0 -1
  344. package/dist/quote-status-manager/quote-status-get-with-retry-outcome.d.ts.map +0 -1
  345. package/dist/quote-status-manager/quote-status-get-with-retry-outcome.js.map +0 -1
  346. package/dist/quote-status-manager/quote-status-state-fsm.d.ts.map +0 -1
  347. package/dist/quote-status-manager/quote-status-state-fsm.js +0 -90
  348. package/dist/quote-status-manager/quote-status-state-fsm.js.map +0 -1
  349. package/dist/quote-status-manager/quote-status-update-with-retry-outcome.d.ts.map +0 -1
  350. package/dist/quote-status-manager/quote-status-update-with-retry-outcome.js.map +0 -1
  351. package/dist/quote-status-manager/quotes-status-manager.d.ts.map +0 -1
  352. package/dist/quote-status-manager/quotes-status-manager.js +0 -576
  353. package/dist/quote-status-manager/quotes-status-manager.js.map +0 -1
  354. package/dist/quote-status-manager/types.d.ts.map +0 -1
  355. package/dist/quote-status-manager/types.js +0 -2
  356. package/dist/quote-status-manager/types.js.map +0 -1
  357. package/dist/quote-status-manager/utils.d.ts.map +0 -1
  358. package/dist/quote-status-manager/utils.js.map +0 -1
  359. package/dist/quote-status-manager/validators.d.ts.map +0 -1
  360. package/dist/quote-status-manager/validators.js.map +0 -1
  361. package/dist/strategy/batch-sell-strategy.d.ts.map +0 -1
  362. package/dist/strategy/batch-sell-strategy.js.map +0 -1
  363. package/dist/strategy/batch-strategy.d.ts.map +0 -1
  364. package/dist/strategy/batch-strategy.js.map +0 -1
  365. package/dist/strategy/evm-strategy.d.ts.map +0 -1
  366. package/dist/strategy/evm-strategy.js.map +0 -1
  367. package/dist/strategy/index.d.ts.map +0 -1
  368. package/dist/strategy/index.js.map +0 -1
  369. package/dist/strategy/intent-strategy.d.ts.map +0 -1
  370. package/dist/strategy/non-evm-strategy.d.ts.map +0 -1
  371. package/dist/strategy/non-evm-strategy.js.map +0 -1
  372. package/dist/strategy/types.d.ts.map +0 -1
  373. package/dist/strategy/types.js.map +0 -1
  374. package/dist/types.d.ts.map +0 -1
  375. package/dist/types.js.map +0 -1
  376. package/dist/utils/accounts.d.ts.map +0 -1
  377. package/dist/utils/accounts.js.map +0 -1
  378. package/dist/utils/authentication.d.ts +0 -3
  379. package/dist/utils/authentication.d.ts.map +0 -1
  380. package/dist/utils/authentication.js.map +0 -1
  381. package/dist/utils/bridge-status.d.ts.map +0 -1
  382. package/dist/utils/bridge-status.js.map +0 -1
  383. package/dist/utils/bridge.d.ts.map +0 -1
  384. package/dist/utils/bridge.js.map +0 -1
  385. package/dist/utils/feature-flags.d.ts.map +0 -1
  386. package/dist/utils/feature-flags.js.map +0 -1
  387. package/dist/utils/gas.d.ts.map +0 -1
  388. package/dist/utils/gas.js.map +0 -1
  389. package/dist/utils/history.d.ts.map +0 -1
  390. package/dist/utils/history.js.map +0 -1
  391. package/dist/utils/intent-api.d.ts.map +0 -1
  392. package/dist/utils/intent-api.js.map +0 -1
  393. package/dist/utils/keyring.d.ts.map +0 -1
  394. package/dist/utils/keyring.js.map +0 -1
  395. package/dist/utils/metrics.d.ts.map +0 -1
  396. package/dist/utils/metrics.js.map +0 -1
  397. package/dist/utils/network.d.ts.map +0 -1
  398. package/dist/utils/network.js.map +0 -1
  399. package/dist/utils/snaps.d.ts.map +0 -1
  400. package/dist/utils/snaps.js.map +0 -1
  401. package/dist/utils/swap-received-amount.d.ts.map +0 -1
  402. package/dist/utils/swap-received-amount.js.map +0 -1
  403. package/dist/utils/trace.d.ts.map +0 -1
  404. package/dist/utils/trace.js.map +0 -1
  405. package/dist/utils/transaction.d.ts.map +0 -1
  406. package/dist/utils/transaction.js.map +0 -1
  407. package/dist/utils/validators.d.ts.map +0 -1
  408. package/dist/utils/validators.js.map +0 -1
@@ -0,0 +1,1144 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_intentManager, _BridgeStatusController_quoteStatusManager, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_trace, _BridgeStatusController_traceSwapOperationCompleted, _BridgeStatusController_onTransactionFailed, _BridgeStatusController_onTransactionConfirmed, _BridgeStatusController_reportSubmittedForNonEvmTx, _BridgeStatusController_reportSubmittedOnce, _BridgeStatusController_seedQuoteStatusEntriesFromHistory, _BridgeStatusController_restartPollingForIncompleteHistoryItems, _BridgeStatusController_addTxToHistory, _BridgeStatusController_rekeyHistoryItem, _BridgeStatusController_startPollingForTxId, _BridgeStatusController_handleFetchFailure, _BridgeStatusController_handleOldHistoryItem, _BridgeStatusController_fetchBridgeTxStatus, _BridgeStatusController_setAndGetSrcTxHash, _BridgeStatusController_updateHistoryItem, _BridgeStatusController_deleteHistoryItem, _BridgeStatusController_wipeBridgeStatusByChainId, _BridgeStatusController_executeSubmitStrategy, _BridgeStatusController_trackPollingStatusUpdatedEvent, _BridgeStatusController_trackUnifiedSwapBridgeEvent;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.BridgeStatusController = void 0;
19
+ const bridge_controller_1 = require("@metamask/bridge-controller");
20
+ const bridge_controller_2 = require("@metamask/bridge-controller");
21
+ const polling_controller_1 = require("@metamask/polling-controller");
22
+ const transaction_controller_1 = require("@metamask/transaction-controller");
23
+ const utils_1 = require("@metamask/utils");
24
+ const bridge_status_controller_intent_1 = require("./bridge-status-controller.intent.cjs");
25
+ const constants_js_1 = require("./constants.cjs");
26
+ const constants_js_2 = require("./quote-status-manager/constants.cjs");
27
+ const errors_js_1 = require("./quote-status-manager/errors.cjs");
28
+ const quotes_status_manager_js_1 = require("./quote-status-manager/quotes-status-manager.cjs");
29
+ const index_js_1 = __importDefault(require("./strategy/index.cjs"));
30
+ const types_js_1 = require("./strategy/types.cjs");
31
+ const types_js_2 = require("./types.cjs");
32
+ const accounts_js_1 = require("./utils/accounts.cjs");
33
+ const authentication_js_1 = require("./utils/authentication.cjs");
34
+ const bridge_status_js_1 = require("./utils/bridge-status.cjs");
35
+ const bridge_js_1 = require("./utils/bridge.cjs");
36
+ const history_js_1 = require("./utils/history.cjs");
37
+ const metrics_js_1 = require("./utils/metrics.cjs");
38
+ const network_js_1 = require("./utils/network.cjs");
39
+ const trace_js_1 = require("./utils/trace.cjs");
40
+ const transaction_js_1 = require("./utils/transaction.cjs");
41
+ const metadata = {
42
+ // We want to persist the bridge status state so that we can show the proper data for the Activity list
43
+ // basically match the behavior of TransactionController
44
+ txHistory: {
45
+ includeInStateLogs: true,
46
+ persist: true,
47
+ includeInDebugSnapshot: false,
48
+ usedInUi: true,
49
+ },
50
+ // Deferred status updates used by QuoteStatusUpdateManager
51
+ quoteUpdateStatusStore: {
52
+ includeInStateLogs: false,
53
+ persist: true,
54
+ includeInDebugSnapshot: false,
55
+ usedInUi: false,
56
+ },
57
+ };
58
+ const MESSENGER_EXPOSED_METHODS = [
59
+ 'startPollingForBridgeTxStatus',
60
+ 'wipeBridgeStatus',
61
+ 'resetState',
62
+ 'submitTx',
63
+ 'submitIntent',
64
+ 'submitBatchSell',
65
+ 'restartPollingForFailedAttempts',
66
+ 'getBridgeHistoryItemByTxMetaId',
67
+ ];
68
+ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPollingController)() {
69
+ constructor({ messenger, state, clientId, clientProduct, clientVersion, fetchFn, addTransactionBatchFn, config, traceFn, onQuoteStatusManagerError, isQuoteStatusManagerEnabled, }) {
70
+ super({
71
+ name: constants_js_1.BRIDGE_STATUS_CONTROLLER_NAME,
72
+ metadata,
73
+ messenger,
74
+ // Restore the persisted state
75
+ state: {
76
+ ...constants_js_1.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE,
77
+ ...state,
78
+ },
79
+ });
80
+ _BridgeStatusController_pollingTokensByTxMetaId.set(this, {});
81
+ _BridgeStatusController_intentManager.set(this, void 0);
82
+ _BridgeStatusController_quoteStatusManager.set(this, void 0);
83
+ _BridgeStatusController_clientId.set(this, void 0);
84
+ _BridgeStatusController_fetchFn.set(this, void 0);
85
+ _BridgeStatusController_config.set(this, void 0);
86
+ _BridgeStatusController_addTransactionBatchFn.set(this, void 0);
87
+ _BridgeStatusController_trace.set(this, void 0);
88
+ _BridgeStatusController_traceSwapOperationCompleted.set(this, async (historyKey, result, terminalStage) => {
89
+ if (!historyKey) {
90
+ return;
91
+ }
92
+ const historyItem = this.state.txHistory[historyKey];
93
+ const featureId = historyItem?.featureId ?? bridge_controller_1.FeatureId.UNIFIED_SWAP_BRIDGE;
94
+ if (!historyItem ||
95
+ historyItem.batchSellData ||
96
+ !constants_js_1.ALLOWED_FEATURE_IDS_FOR_STATUS_EVENTS.includes(featureId)) {
97
+ return;
98
+ }
99
+ await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, (0, trace_js_1.getSwapOperationCompletedTraceParams)(historyItem, historyKey, result, terminalStage), () => undefined);
100
+ });
101
+ _BridgeStatusController_onTransactionFailed.set(this, ({ txMeta, historyKey, isApprovalTxMeta, }) => {
102
+ const isHistoryItemAlreadyFailed = historyKey
103
+ ? this.state.txHistory[historyKey]?.status.status === bridge_controller_2.StatusTypes.FAILED
104
+ : false;
105
+ const isIntent = historyKey
106
+ ? Boolean(this.state.txHistory[historyKey]?.quote.intent)
107
+ : false;
108
+ __classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
109
+ historyKey,
110
+ status: bridge_controller_2.StatusTypes.FAILED,
111
+ txHash: isApprovalTxMeta ? undefined : txMeta.hash,
112
+ completionTime: Date.now(),
113
+ });
114
+ if (txMeta.status === transaction_controller_1.TransactionStatus.rejected) {
115
+ return;
116
+ }
117
+ if (isHistoryItemAlreadyFailed) {
118
+ return;
119
+ }
120
+ if (!isIntent) {
121
+ __classPrivateFieldGet(this, _BridgeStatusController_traceSwapOperationCompleted, "f").call(this, historyKey, 'error', 'source').catch(() => undefined);
122
+ }
123
+ // Report finalized failure for swap/bridge transactions.
124
+ // Note: TransactionStatus.rejected means the user cancelled signing, so the tx was never broadcast.
125
+ // `hasNestedSwapTransactions` also covers batch/7702 swaps whose type may
126
+ // still read as `batch` rather than `swap`.
127
+ if ((txMeta.type && (0, transaction_js_1.isCrossChainTx)(txMeta.type)) ||
128
+ (0, transaction_js_1.hasNestedSwapTransactions)(txMeta)) {
129
+ __classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").reportFinalised(txMeta.id, false, txMeta.chainId, txMeta.hash);
130
+ }
131
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Failed, historyKey, (0, metrics_js_1.getEVMTxPropertiesFromTransactionMeta)(txMeta));
132
+ });
133
+ // Only EVM txs
134
+ _BridgeStatusController_onTransactionConfirmed.set(this, ({ txMeta, historyKey, isApprovalTxMeta, }) => {
135
+ // Return early if the confirmed txMeta is for an approval since we
136
+ // still need to wait for the trade to be confirmed
137
+ if (isApprovalTxMeta) {
138
+ return;
139
+ }
140
+ __classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
141
+ historyKey,
142
+ txHash: txMeta.hash,
143
+ });
144
+ const isIntent = historyKey
145
+ ? Boolean(this.state.txHistory[historyKey]?.quote.intent)
146
+ : false;
147
+ const isSwap = txMeta.type === transaction_controller_1.TransactionType.swap || (0, transaction_js_1.hasNestedSwapTransactions)(txMeta);
148
+ if (isSwap) {
149
+ __classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
150
+ historyKey,
151
+ status: bridge_controller_2.StatusTypes.COMPLETE,
152
+ completionTime: Date.now(),
153
+ });
154
+ // For EVM intent-based swaps the synthetic tx transitions
155
+ // submitted→confirmed in a single update that carries the CoW
156
+ // settlement hash, so the submitted status handler never has a hash
157
+ // and reportSubmitted is never called. Call it here (before
158
+ // reportFinalised) so the deferred-queue entry is created.
159
+ const historyItem = historyKey
160
+ ? this.state.txHistory[historyKey]
161
+ : undefined;
162
+ if (historyKey &&
163
+ historyItem &&
164
+ txMeta.hash &&
165
+ !(0, bridge_controller_2.isNonEvmChainId)(historyItem.quote.srcChainId)) {
166
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedOnce, "f").call(this, historyKey, txMeta.hash, txMeta.id);
167
+ }
168
+ __classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").reportFinalised(txMeta.id, true, txMeta.chainId, txMeta.hash);
169
+ if (!isIntent) {
170
+ __classPrivateFieldGet(this, _BridgeStatusController_traceSwapOperationCompleted, "f").call(this, historyKey, 'success', 'source').catch(() => undefined);
171
+ }
172
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Completed, historyKey);
173
+ }
174
+ else if (historyKey) {
175
+ __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, historyKey);
176
+ }
177
+ });
178
+ /**
179
+ * Reports the SUBMITTED quote status for non-EVM transactions.
180
+ *
181
+ * EVM transactions report SUBMITTED via the
182
+ * `TransactionController:transactionStatusUpdated` subscription, which also
183
+ * picks up hash replacements (speed-up/cancel) and the late hash assignment
184
+ * of smart/batch transactions. Non-EVM transactions (Solana, Bitcoin, Tron)
185
+ * are submitted through Snaps and never emit TransactionController lifecycle
186
+ * events, so they are reported here once the history item exists and the
187
+ * source tx hash is known.
188
+ *
189
+ * @param historyKey - The key of the history item in `txHistory`
190
+ * @param txMeta - The submitted trade transaction's id and hash
191
+ * @param txMeta.id - The transaction meta id, used for finalization matching
192
+ * @param txMeta.hash - The source chain transaction hash
193
+ */
194
+ _BridgeStatusController_reportSubmittedForNonEvmTx.set(this, (historyKey, txMeta) => {
195
+ if (!txMeta?.id || !txMeta.hash) {
196
+ return;
197
+ }
198
+ const historyItem = this.state.txHistory[historyKey];
199
+ if (!historyItem || !(0, bridge_controller_2.isNonEvmChainId)(historyItem.quote.srcChainId)) {
200
+ return;
201
+ }
202
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedOnce, "f").call(this, historyKey, txMeta.hash, txMeta.id);
203
+ });
204
+ /**
205
+ * Reports a SUBMITTED quote status update exactly once per source tx hash.
206
+ *
207
+ * SUBMITTED can be triggered from several code paths (submission, the first
208
+ * poll where the hash is known, and the final-status branch) and the poll
209
+ * path runs on every interval.
210
+ *
211
+ * For 7702/nested batch sells a single source transaction carries multiple
212
+ * quotes: the parent history item lists all of them in `quoteIds` (each a key
213
+ * into `txHistory`). In that case every quote is reported under the shared
214
+ * source tx hash and `txMetaId`.
215
+ *
216
+ * @param historyKey - The key of the history item in `txHistory`
217
+ * @param srcTxHash - The source chain transaction hash
218
+ * @param txMetaId - The transaction meta id, used for finalization matching
219
+ */
220
+ _BridgeStatusController_reportSubmittedOnce.set(this, (historyKey, srcTxHash, txMetaId) => {
221
+ const historyItem = this.state.txHistory[historyKey];
222
+ if (!historyItem) {
223
+ return;
224
+ }
225
+ // For a 7702/nested batch the parent item lists every quote in `quoteIds`
226
+ // (keys into `txHistory`); resolve each to its real quote id. Otherwise fall
227
+ // back to the item's own single quote id.
228
+ let quoteIds;
229
+ if (historyItem.quoteIds?.length) {
230
+ quoteIds = historyItem.quoteIds
231
+ .map((quoteKey) => this.state.txHistory[quoteKey]?.quoteId)
232
+ .filter((quoteId) => Boolean(quoteId));
233
+ }
234
+ else if (historyItem.quoteId) {
235
+ quoteIds = [historyItem.quoteId];
236
+ }
237
+ else {
238
+ quoteIds = [];
239
+ }
240
+ if (quoteIds.length === 0) {
241
+ return;
242
+ }
243
+ // `reportedSubmittedTxHash` is set once `reportSubmitted` is called.
244
+ // This avoids processing multiple `eportSubmitted` for the
245
+ // same swap/bridge.
246
+ if (historyItem.reportedSubmittedTxHash === srcTxHash) {
247
+ return;
248
+ }
249
+ for (const quoteId of quoteIds) {
250
+ __classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").reportSubmitted(quoteId, srcTxHash, txMetaId, historyItem.quote.srcChainId);
251
+ }
252
+ this.update((state) => {
253
+ const item = state.txHistory[historyKey];
254
+ if (item) {
255
+ item.reportedSubmittedTxHash = srcTxHash;
256
+ }
257
+ });
258
+ });
259
+ this.resetState = () => {
260
+ __classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").destroy();
261
+ this.update((state) => {
262
+ state.txHistory = constants_js_1.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.txHistory;
263
+ state.quoteUpdateStatusStore =
264
+ constants_js_1.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.quoteUpdateStatusStore;
265
+ });
266
+ };
267
+ this.wipeBridgeStatus = ({ address, ignoreNetwork, }) => {
268
+ // Wipe all networks for this address
269
+ if (ignoreNetwork) {
270
+ this.update((state) => {
271
+ state.txHistory = constants_js_1.DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE.txHistory;
272
+ });
273
+ }
274
+ else {
275
+ const selectedChainId = (0, network_js_1.getSelectedChainId)(this.messenger);
276
+ __classPrivateFieldGet(this, _BridgeStatusController_wipeBridgeStatusByChainId, "f").call(this, address, selectedChainId);
277
+ }
278
+ };
279
+ /**
280
+ * Resets the attempts counter for a bridge transaction history item
281
+ * and restarts polling if it was previously stopped due to max attempts
282
+ *
283
+ * @param identifier - Object containing either txMetaId or txHash to identify the history item
284
+ * @param identifier.txMetaId - The transaction meta ID
285
+ * @param identifier.txHash - The transaction hash
286
+ */
287
+ this.restartPollingForFailedAttempts = (identifier) => {
288
+ const { txMetaId, txHash } = identifier;
289
+ if (!txMetaId && !txHash) {
290
+ throw new Error('Either txMetaId or txHash must be provided');
291
+ }
292
+ // Find the history item by txMetaId or txHash
293
+ let targetTxMetaId;
294
+ if (txMetaId) {
295
+ // Direct lookup by txMetaId
296
+ if (this.state.txHistory[txMetaId]) {
297
+ targetTxMetaId = txMetaId;
298
+ }
299
+ }
300
+ else if (txHash) {
301
+ // Search by txHash in status.srcChain.txHash
302
+ targetTxMetaId = Object.keys(this.state.txHistory).find((id) => this.state.txHistory[id].status.srcChain.txHash === txHash);
303
+ }
304
+ if (!targetTxMetaId) {
305
+ throw new Error(`No bridge transaction history found for ${txMetaId ? `txMetaId: ${txMetaId}` : `txHash: ${txHash}`}`);
306
+ }
307
+ const historyItem = this.state.txHistory[targetTxMetaId];
308
+ // Capture attempts count before resetting for metrics
309
+ const previousAttempts = historyItem.attempts?.counter ?? 0;
310
+ // Reset the attempts counter
311
+ this.update((state) => {
312
+ if (targetTxMetaId) {
313
+ state.txHistory[targetTxMetaId].attempts = undefined;
314
+ }
315
+ });
316
+ // Restart polling if it was stopped and this tx still needs status updates
317
+ if ((0, history_js_1.shouldPollHistoryItem)(historyItem)) {
318
+ // Check if polling was stopped (no active polling token)
319
+ const existingPollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[targetTxMetaId];
320
+ if (!existingPollingToken) {
321
+ // Restart polling
322
+ __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, targetTxMetaId);
323
+ // Track polling manually restarted event
324
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.PollingStatusUpdated, targetTxMetaId, {
325
+ polling_status: bridge_controller_2.PollingStatus.ManuallyRestarted,
326
+ retry_attempts: previousAttempts,
327
+ });
328
+ }
329
+ }
330
+ };
331
+ /**
332
+ * Gets a bridge history item from the history by its transaction meta ID
333
+ *
334
+ * @param txMetaId - The transaction meta ID to look up
335
+ * @returns The bridge history item if found, undefined otherwise
336
+ */
337
+ this.getBridgeHistoryItemByTxMetaId = (txMetaId) => {
338
+ return this.state.txHistory[txMetaId];
339
+ };
340
+ /**
341
+ * Seeds missing quote-status entries from persisted history on startup.
342
+ *
343
+ * The deferred quote-status entry (keyed by `${quoteId}:${srcTxHash}`) is only
344
+ * created when `reportSubmitted` runs. If the client closes after a swap/bridge
345
+ * is submitted but before that happens, the entry is never created and
346
+ * `QuoteStatusManager.init()` has nothing to reconcile. The persisted history
347
+ * item carries the `quoteId`, source tx hash, and `txMetaId` needed to rebuild
348
+ * the entry, so we replay `reportSubmitted` here (idempotent via
349
+ * `#reportSubmittedOnce`) before `init()` runs.
350
+ */
351
+ _BridgeStatusController_seedQuoteStatusEntriesFromHistory.set(this, () => {
352
+ if (!__classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").enabled) {
353
+ // Skip seeding to prevent `#reportSubmittedOnce` from persisting
354
+ // `reportedSubmittedTxHash` so recent bridge history cannot be marked as
355
+ // already reported with no store entry or backend update.
356
+ return;
357
+ }
358
+ for (const [historyKey, historyItem] of Object.entries(this.state.txHistory)) {
359
+ const { quoteId, quoteIds, txMetaId } = historyItem;
360
+ // A 7702/nested batch parent reports its quotes via `quoteIds` rather than
361
+ // its own single `quoteId`, so accept either. `#reportSubmittedOnce`
362
+ // resolves the actual set of quotes to report.
363
+ if ((!quoteId && !quoteIds?.length) || !txMetaId) {
364
+ continue;
365
+ }
366
+ // Skip items older than the backfill window: the backend would reject
367
+ // a status report for a quote that old, so there is no point creating
368
+ // an entry or making a request.
369
+ if (Date.now() - historyItem.startTime >
370
+ constants_js_2.QUOTE_STATUS_BACKFILL_WINDOW_MS) {
371
+ continue;
372
+ }
373
+ // Prefer the history hash; fall back to the tx hash (covers STX swaps
374
+ // confirmed while closed, where the history hash was never written).
375
+ const srcTxHash = historyItem.status.srcChain.txHash ??
376
+ (0, transaction_js_1.getTransactionMetaById)(this.messenger, txMetaId)?.hash;
377
+ if (!srcTxHash) {
378
+ continue;
379
+ }
380
+ // Call `reportSubmittedOnce` for each history item that satisfies
381
+ // the above criteria. The method will then take care the rest
382
+ // (ie. if it actually needs to be reported or not because it already has been).
383
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedOnce, "f").call(this, historyKey, srcTxHash, txMetaId);
384
+ }
385
+ });
386
+ /**
387
+ * Restart polling for txs that are not in a final state
388
+ * This is called during initialization
389
+ */
390
+ _BridgeStatusController_restartPollingForIncompleteHistoryItems.set(this, () => {
391
+ // Check for historyItems that do not have a status of complete and restart polling
392
+ const { txHistory } = this.state;
393
+ const historyItems = Object.entries(txHistory);
394
+ const incompleteHistoryItems = historyItems
395
+ .filter(([_, historyItem]) => historyItem.status.status === bridge_controller_2.StatusTypes.PENDING ||
396
+ historyItem.status.status === bridge_controller_2.StatusTypes.UNKNOWN)
397
+ // Only poll items with txMetaId (post-submission items)
398
+ .filter(([_, historyItem]) => {
399
+ if (!historyItem.txMetaId) {
400
+ return false;
401
+ }
402
+ // Check if we are already polling this tx, if so, skip restarting polling for that
403
+ const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[historyItem.txMetaId];
404
+ return !pollingToken;
405
+ })
406
+ // Only restart polling for items that still require status updates
407
+ .filter(([_, historyItem]) => {
408
+ return (0, history_js_1.shouldPollHistoryItem)(historyItem);
409
+ });
410
+ incompleteHistoryItems.forEach(([historyKey, historyItem]) => {
411
+ const shouldSkipFetch = (0, bridge_status_js_1.shouldSkipFetchDueToFetchFailures)(historyItem.attempts);
412
+ if (shouldSkipFetch) {
413
+ return;
414
+ }
415
+ // We manually call startPolling() here rather than go through startPollingForBridgeTxStatus()
416
+ // because we don't want to overwrite the existing historyItem in state
417
+ __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, historyKey);
418
+ });
419
+ });
420
+ _BridgeStatusController_addTxToHistory.set(this, (historyKey, ...args) => {
421
+ const txHistoryItem = (0, history_js_1.getInitialHistoryItem)(...args);
422
+ this.update((state) => {
423
+ state.txHistory[historyKey] = txHistoryItem;
424
+ });
425
+ return historyKey;
426
+ });
427
+ /**
428
+ * Rekeys a history item from actionId to txMeta.id after successful submission.
429
+ * Also updates txMetaId and srcTxHash which weren't available pre-submission.
430
+ *
431
+ * @param oldKey - The temporary key to use for the history item, usually the actionId
432
+ * @param newKey - The new key to use, typcally the txmeta.id
433
+ * @param txMeta - The transaction meta from the successful submission
434
+ * @param txMeta.id - The transaction meta id to use as the new key
435
+ * @param txMeta.hash - The transaction hash to set on the history item
436
+ */
437
+ _BridgeStatusController_rekeyHistoryItem.set(this, (oldKey, newKey, txMeta) => {
438
+ this.update((state) => {
439
+ (0, history_js_1.rekeyHistoryItemInState)(state, oldKey, newKey, txMeta);
440
+ });
441
+ });
442
+ _BridgeStatusController_startPollingForTxId.set(this, (txId) => {
443
+ // If we are already polling for this tx, stop polling for it before restarting
444
+ const existingPollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[txId];
445
+ if (existingPollingToken) {
446
+ this.stopPollingByPollingToken(existingPollingToken);
447
+ }
448
+ const txHistoryItem = this.state.txHistory[txId];
449
+ if (txHistoryItem && (0, history_js_1.shouldPollHistoryItem)(txHistoryItem)) {
450
+ __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[txId] = this.startPolling({
451
+ bridgeTxMetaId: txId,
452
+ });
453
+ }
454
+ });
455
+ /**
456
+ * @deprecated For EVM/Solana swap/bridge txs we add tx to history in submitTx()
457
+ * For Solana swap/bridge we start polling in submitTx()
458
+ * For EVM bridge we listen for 'TransactionController:transactionConfirmed' and start polling there
459
+ * No clients currently call this, safe to remove in future versions
460
+ *
461
+ * Adds tx to history and starts polling for the bridge tx status
462
+ *
463
+ * @param txHistoryMeta - The parameters for creating the history item
464
+ */
465
+ this.startPollingForBridgeTxStatus = (txHistoryMeta) => {
466
+ const { bridgeTxMeta } = txHistoryMeta;
467
+ if (!bridgeTxMeta?.id) {
468
+ throw new Error('Cannot start polling: bridgeTxMeta.id is required for polling');
469
+ }
470
+ const historyKey = __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, bridgeTxMeta.id, txHistoryMeta);
471
+ __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, historyKey);
472
+ };
473
+ // This will be called after you call this.startPolling()
474
+ // The args passed in are the args you passed in to startPolling()
475
+ this._executePoll = async (pollingInput) => {
476
+ await __classPrivateFieldGet(this, _BridgeStatusController_fetchBridgeTxStatus, "f").call(this, pollingInput);
477
+ };
478
+ /**
479
+ * Handles the failure to fetch the bridge tx status
480
+ * We eventually stop polling for the tx if we fail too many times
481
+ * Failures (500 errors) can be due to:
482
+ * - The srcTxHash not being available immediately for STX
483
+ * - The srcTxHash being invalid for the chain. This case will never resolve so we stop polling for it to avoid hammering the Bridge API forever.
484
+ *
485
+ * @param bridgeTxMetaId - The txMetaId of the bridge tx
486
+ */
487
+ _BridgeStatusController_handleFetchFailure.set(this, (bridgeTxMetaId) => {
488
+ const { attempts } = this.state.txHistory[bridgeTxMetaId];
489
+ const newAttempts = attempts
490
+ ? {
491
+ counter: attempts.counter + 1,
492
+ lastAttemptTime: Date.now(),
493
+ }
494
+ : {
495
+ counter: 1,
496
+ lastAttemptTime: Date.now(),
497
+ };
498
+ // If we've failed too many times, stop polling for the tx
499
+ const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
500
+ if (newAttempts.counter >= constants_js_1.MAX_ATTEMPTS && pollingToken) {
501
+ this.stopPollingByPollingToken(pollingToken);
502
+ delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
503
+ // Track max polling reached event
504
+ const historyItem = this.state.txHistory[bridgeTxMetaId];
505
+ if (historyItem) {
506
+ // Track polling status updated event
507
+ __classPrivateFieldGet(this, _BridgeStatusController_trackPollingStatusUpdatedEvent, "f").call(this, bridgeTxMetaId, bridge_controller_2.PollingStatus.MaxPollingReached);
508
+ }
509
+ }
510
+ // Update the attempts counter
511
+ __classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
512
+ historyKey: bridgeTxMetaId,
513
+ attempts: newAttempts,
514
+ });
515
+ });
516
+ /**
517
+ * Checks if the history item should be preserved so its status can be fetched.
518
+ *
519
+ * @param bridgeTxMetaId - The txMetaId of the bridge tx
520
+ */
521
+ _BridgeStatusController_handleOldHistoryItem.set(this, async (bridgeTxMetaId) => {
522
+ // Continue polling on next restart if the history item is valid
523
+ if (this.state.txHistory[bridgeTxMetaId] &&
524
+ (await (0, bridge_status_js_1.shouldWaitForFinalBridgeStatus)(this.messenger, this.state.txHistory[bridgeTxMetaId]))) {
525
+ return;
526
+ }
527
+ const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
528
+ // Track polling status updated event
529
+ __classPrivateFieldGet(this, _BridgeStatusController_trackPollingStatusUpdatedEvent, "f").call(this, bridgeTxMetaId, bridge_controller_2.PollingStatus.InvalidTransactionHash);
530
+ // If we've failed too many times, stop polling for the tx
531
+ if (pollingToken) {
532
+ this.stopPollingByPollingToken(pollingToken);
533
+ delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
534
+ }
535
+ // Delete the history item so polling doesn't start over on the next restart.
536
+ // Report finalization as a failure here, this is the only place that
537
+ // permanently ends polling, so it's the correct and non-duplicative point
538
+ // to emit the final status.
539
+ const historyItem = this.state.txHistory[bridgeTxMetaId];
540
+ __classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").reportFinalised(bridgeTxMetaId, false, historyItem?.quote.srcChainId, historyItem?.status.srcChain.txHash);
541
+ __classPrivateFieldGet(this, _BridgeStatusController_deleteHistoryItem, "f").call(this, bridgeTxMetaId);
542
+ });
543
+ _BridgeStatusController_fetchBridgeTxStatus.set(this, async ({ bridgeTxMetaId, }) => {
544
+ // 1. Check for history item
545
+ const { txHistory } = this.state;
546
+ const historyItem = txHistory[bridgeTxMetaId];
547
+ if (!historyItem) {
548
+ return;
549
+ }
550
+ // 2. Check for previous failures
551
+ if ((0, bridge_status_js_1.shouldSkipFetchDueToFetchFailures)(historyItem.attempts)) {
552
+ return;
553
+ }
554
+ // 3. Fetch transaction status
555
+ try {
556
+ let status;
557
+ let validationFailures = [];
558
+ if (historyItem.quote.intent) {
559
+ const intentTxStatus = await __classPrivateFieldGet(this, _BridgeStatusController_intentManager, "f").getIntentTransactionStatus(bridgeTxMetaId, historyItem.quote.srcChainId, historyItem.quote.intent.protocol, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"), historyItem.status.srcChain.txHash);
560
+ if (intentTxStatus?.bridgeStatus === null ||
561
+ intentTxStatus?.bridgeStatus === undefined) {
562
+ return;
563
+ }
564
+ status = intentTxStatus.bridgeStatus.status;
565
+ // Report SUBMITTED as soon as the intent's source/settlement hash is
566
+ // known at poll time, before the order reaches a terminal status.
567
+ const intentSrcTxHash = status.srcChain.txHash;
568
+ if (intentSrcTxHash) {
569
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedOnce, "f").call(this, bridgeTxMetaId, intentSrcTxHash, bridgeTxMetaId);
570
+ }
571
+ }
572
+ else {
573
+ // We try here because we receive 500 errors from Bridge API if we try to fetch immediately after submitting the source tx
574
+ // Oddly mostly happens on Optimism, never on Arbitrum. By the 2nd fetch, the Bridge API responds properly.
575
+ // Also srcTxHash may not be available immediately for STX, so we don't want to fetch in those cases
576
+ const srcTxHash = __classPrivateFieldGet(this, _BridgeStatusController_setAndGetSrcTxHash, "f").call(this, bridgeTxMetaId);
577
+ if (!srcTxHash) {
578
+ return;
579
+ }
580
+ // Report SUBMITTED as soon as a srcTxHash is known at poll time, for
581
+ // every chain not just non-EVM sources.
582
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedOnce, "f").call(this, bridgeTxMetaId, srcTxHash, bridgeTxMetaId);
583
+ const statusRequest = (0, bridge_status_js_1.getStatusRequestWithSrcTxHash)(historyItem.quote, srcTxHash);
584
+ const response = (historyItem.quoteId
585
+ ? await (0, bridge_status_js_1.fetchBridgeQuoteStatus)(__classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f"), historyItem.quoteId)
586
+ : null) ??
587
+ (await (0, bridge_status_js_1.fetchBridgeTxStatus)(statusRequest, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"), await (0, authentication_js_1.getJwt)(this.messenger), __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl));
588
+ status = response.status;
589
+ validationFailures = response.validationFailures;
590
+ }
591
+ if (validationFailures.length > 0) {
592
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.StatusValidationFailed, bridgeTxMetaId, {
593
+ failures: validationFailures,
594
+ refresh_count: historyItem.attempts?.counter ?? 0,
595
+ });
596
+ throw new Error(`Bridge status validation failed: ${validationFailures.join(', ')}`);
597
+ }
598
+ // 4. Create bridge history item
599
+ const newBridgeHistoryItem = {
600
+ ...historyItem,
601
+ status,
602
+ completionTime: status.status === bridge_controller_2.StatusTypes.COMPLETE ||
603
+ status.status === bridge_controller_2.StatusTypes.FAILED
604
+ ? Date.now()
605
+ : undefined, // TODO make this more accurate by looking up dest txHash block time
606
+ attempts: undefined,
607
+ };
608
+ // No need to purge these on network change or account change, TransactionController does not purge either.
609
+ // TODO In theory we can skip checking status if it's not the current account/network
610
+ // we need to keep track of the account that this is associated with as well so that we don't show it in Activity list for other accounts
611
+ // First stab at this will not stop polling when you are on a different account
612
+ this.update((state) => {
613
+ state.txHistory[bridgeTxMetaId] = newBridgeHistoryItem;
614
+ });
615
+ if (historyItem.quote.intent) {
616
+ __classPrivateFieldGet(this, _BridgeStatusController_intentManager, "f").syncTransactionFromIntentStatus(bridgeTxMetaId, historyItem);
617
+ }
618
+ // 5. After effects
619
+ const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
620
+ const isFinalStatus = status.status === bridge_controller_2.StatusTypes.COMPLETE ||
621
+ status.status === bridge_controller_2.StatusTypes.FAILED;
622
+ if (isFinalStatus) {
623
+ if (pollingToken) {
624
+ this.stopPollingByPollingToken(pollingToken);
625
+ delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
626
+ }
627
+ // Ensure a deferred entry exists before reportFinalised is called.
628
+ const settlementTxHash = newBridgeHistoryItem.status.srcChain.txHash;
629
+ if (settlementTxHash) {
630
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedOnce, "f").call(this, bridgeTxMetaId, settlementTxHash, bridgeTxMetaId);
631
+ }
632
+ __classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").reportFinalised(bridgeTxMetaId, status.status === bridge_controller_2.StatusTypes.COMPLETE, historyItem.quote.srcChainId, settlementTxHash);
633
+ await __classPrivateFieldGet(this, _BridgeStatusController_traceSwapOperationCompleted, "f").call(this, bridgeTxMetaId, status.status === bridge_controller_2.StatusTypes.COMPLETE ? 'success' : 'error', (0, bridge_controller_2.isCrossChain)(historyItem.quote.srcChainId, historyItem.quote.destChainId)
634
+ ? 'destination'
635
+ : 'source').catch(() => undefined);
636
+ if (status.status === bridge_controller_2.StatusTypes.COMPLETE) {
637
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Completed, bridgeTxMetaId);
638
+ this.messenger.publish('BridgeStatusController:destinationTransactionCompleted', historyItem.quote.destAsset.assetId);
639
+ }
640
+ if (status.status === bridge_controller_2.StatusTypes.FAILED) {
641
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Failed, bridgeTxMetaId);
642
+ }
643
+ }
644
+ }
645
+ catch (error) {
646
+ console.warn('Failed to fetch bridge tx status', error);
647
+ __classPrivateFieldGet(this, _BridgeStatusController_handleFetchFailure, "f").call(this, bridgeTxMetaId);
648
+ }
649
+ finally {
650
+ await __classPrivateFieldGet(this, _BridgeStatusController_handleOldHistoryItem, "f").call(this, bridgeTxMetaId);
651
+ }
652
+ });
653
+ /**
654
+ * Returns the srcTxHash for a non-STX EVM tx, the hash from the bridge status api,
655
+ * or the local hash from the TransactionController if the tx is in a finalized state
656
+ *
657
+ * @param bridgeTxMetaId - The bridge tx meta id
658
+ * @returns The srcTxHash
659
+ */
660
+ _BridgeStatusController_setAndGetSrcTxHash.set(this, (bridgeTxMetaId) => {
661
+ const { txHistory } = this.state;
662
+ // Prefer the srcTxHash from bridgeStatusState so we don't have to look up in TransactionController
663
+ // But it is possible to have bridgeHistoryItem in state without the srcTxHash yet when it is an STX
664
+ const srcTxHash = txHistory[bridgeTxMetaId].status.srcChain.txHash;
665
+ if (srcTxHash ||
666
+ (0, bridge_controller_2.isNonEvmChainId)(txHistory[bridgeTxMetaId].quote.srcChainId)) {
667
+ return srcTxHash;
668
+ }
669
+ // Update history with TransactionController's hash if it has been updated
670
+ const txMeta = (0, transaction_js_1.getTransactionMetaById)(this.messenger, bridgeTxMetaId);
671
+ if (!txMeta) {
672
+ return undefined;
673
+ }
674
+ // Wait for finalized status before updating the history item
675
+ const localTxHash = [
676
+ transaction_controller_1.TransactionStatus.confirmed,
677
+ transaction_controller_1.TransactionStatus.dropped,
678
+ transaction_controller_1.TransactionStatus.rejected,
679
+ transaction_controller_1.TransactionStatus.failed,
680
+ ].includes(txMeta.status)
681
+ ? txMeta.hash
682
+ : undefined;
683
+ __classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
684
+ historyKey: bridgeTxMetaId,
685
+ txHash: localTxHash,
686
+ });
687
+ return localTxHash;
688
+ });
689
+ _BridgeStatusController_updateHistoryItem.set(this, ({ historyKey, status, txHash, attempts, completionTime, }) => {
690
+ if (!historyKey) {
691
+ return;
692
+ }
693
+ this.update((currentState) => {
694
+ if (status) {
695
+ currentState.txHistory[historyKey].status.status = status;
696
+ }
697
+ if (txHash) {
698
+ currentState.txHistory[historyKey].status.srcChain.txHash = txHash;
699
+ }
700
+ if (attempts) {
701
+ currentState.txHistory[historyKey].attempts = attempts;
702
+ }
703
+ if (completionTime) {
704
+ currentState.txHistory[historyKey].completionTime = completionTime;
705
+ }
706
+ });
707
+ });
708
+ _BridgeStatusController_deleteHistoryItem.set(this, (historyKey) => {
709
+ this.update((currentState) => {
710
+ delete currentState.txHistory[historyKey];
711
+ });
712
+ });
713
+ // Wipes the bridge status for the given address and chainId
714
+ // Will match only source chainId to the selectedChainId
715
+ _BridgeStatusController_wipeBridgeStatusByChainId.set(this, (address, selectedChainId) => {
716
+ const sourceTxMetaIdsToDelete = Object.keys(this.state.txHistory).filter((txMetaId) => {
717
+ const bridgeHistoryItem = this.state.txHistory[txMetaId];
718
+ const hexSourceChainId = (0, utils_1.numberToHex)(bridgeHistoryItem.quote.srcChainId);
719
+ return (bridgeHistoryItem.account === address &&
720
+ hexSourceChainId === selectedChainId);
721
+ });
722
+ sourceTxMetaIdsToDelete.forEach((sourceTxMetaId) => {
723
+ const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[sourceTxMetaId];
724
+ if (pollingToken) {
725
+ this.stopPollingByPollingToken(__classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[sourceTxMetaId]);
726
+ delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[sourceTxMetaId];
727
+ }
728
+ });
729
+ this.update((state) => {
730
+ state.txHistory = sourceTxMetaIdsToDelete.reduce((acc, sourceTxMetaId) => {
731
+ delete acc[sourceTxMetaId];
732
+ return acc;
733
+ }, state.txHistory);
734
+ });
735
+ });
736
+ /**
737
+ * ******************************************************
738
+ * TX SUBMISSION HANDLING
739
+ *******************************************************
740
+ */
741
+ _BridgeStatusController_executeSubmitStrategy.set(this, async (params, sharedHistoryItemProperties) => {
742
+ let tradeTxMeta;
743
+ const steps = (0, index_js_1.default)(params);
744
+ // Each submission strategy determines when to execute step, which means these actions can happen in any order
745
+ for await (const { type, payload } of steps) {
746
+ try {
747
+ switch (type) {
748
+ case types_js_1.SubmitStep.RekeyHistoryItem:
749
+ __classPrivateFieldGet(this, _BridgeStatusController_rekeyHistoryItem, "f").call(this, payload.oldHistoryKey, payload.newHistoryKey, payload.tradeMeta);
750
+ // Report SUBMITTED as soon as the trade hash is known at submission
751
+ // time, instead of waiting for the delayed transactionStatusUpdated
752
+ // (submitted) event.
753
+ if (payload.tradeMeta.hash) {
754
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedOnce, "f").call(this, payload.newHistoryKey, payload.tradeMeta.hash, payload.tradeMeta.id);
755
+ }
756
+ break;
757
+ case types_js_1.SubmitStep.UpdateBatchTransactions:
758
+ (0, transaction_js_1.updateTransactionsInBatch)({
759
+ messenger: this.messenger,
760
+ allTradesWithMetadata: payload.quoteAndTxMetas,
761
+ });
762
+ break;
763
+ case types_js_1.SubmitStep.SetTradeMeta:
764
+ tradeTxMeta = payload.tradeMeta;
765
+ break;
766
+ case types_js_1.SubmitStep.AddHistoryItem:
767
+ __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, payload.historyKey, {
768
+ ...payload,
769
+ ...sharedHistoryItemProperties,
770
+ quoteResponse: payload.quoteResponse,
771
+ accountAddress: params.selectedAccount.address,
772
+ isStxEnabled: params.isStxEnabled,
773
+ slippagePercentage: sharedHistoryItemProperties.slippagePercentage ??
774
+ payload.quoteResponse.quote.slippage ??
775
+ 0,
776
+ });
777
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedForNonEvmTx, "f").call(this, payload.historyKey, payload.bridgeTxMeta);
778
+ break;
779
+ case types_js_1.SubmitStep.StartPolling:
780
+ __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, payload.historyKey);
781
+ break;
782
+ case types_js_1.SubmitStep.PublishCompletedEvent: {
783
+ const completedHistoryItem = this.state.txHistory[payload.historyKey];
784
+ __classPrivateFieldGet(this, _BridgeStatusController_traceSwapOperationCompleted, "f").call(this, payload.historyKey, 'success', 'source').catch(() => undefined);
785
+ __classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").reportFinalised(payload.historyKey, true, completedHistoryItem?.quote.srcChainId, completedHistoryItem?.status.srcChain.txHash);
786
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Completed, payload.historyKey);
787
+ break;
788
+ }
789
+ /* c8 ignore start */
790
+ default:
791
+ throw new Error(`Unknown submit step type: ${String(type)}`);
792
+ /* c8 ignore end */
793
+ }
794
+ }
795
+ catch (error) {
796
+ console.error('Failed to add to bridge history and start polling.', error);
797
+ }
798
+ }
799
+ return tradeTxMeta;
800
+ });
801
+ /**
802
+ * Submits a cross-chain swap transaction
803
+ *
804
+ * @param accountAddress - The address of the account to submit the transaction for
805
+ * @param maybeQuoteResponses - A single quote response or an array of quote responses
806
+ * @param isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
807
+ * @param quotesReceivedContext - The context for the QuotesReceived event
808
+ * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, Trending Explore)
809
+ * @param abTests - Legacy A/B test context for `ab_tests` (backward compatibility)
810
+ * @param activeAbTests - New A/B test context for `active_ab_tests` (migration target). Attributes events to specific experiments.
811
+ * @param tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.
812
+ * @param batchSellTrades - Contains transaction data for the quotes, provided by the obtainGaslessBatch API
813
+ * @param inputPrimaryDenomination - The denomination shown as the primary source amount input at submission time.
814
+ * @param migrationPhase - The active migration phase for the quote response
815
+ * @returns The transaction meta
816
+ * @throws An error if transaction submission fails before it gets published
817
+ */
818
+ this.submitTx = async (accountAddress, maybeQuoteResponses, isStxEnabled, quotesReceivedContext, location = bridge_controller_2.MetaMetricsSwapsEventSource.Unknown, abTests, activeAbTests, tokenSecurityTypeDestination, batchSellTrades, inputPrimaryDenomination, migrationPhase) => {
819
+ /**
820
+ * If there are multiple quote responses, we assume that they all originate from the same src chain
821
+ * and the same account. In this case its safe to use the first quote response's properties for
822
+ * metrics and other pre-submission logic
823
+ */
824
+ const quoteResponsesV1orV2 = Array.isArray(maybeQuoteResponses)
825
+ ? maybeQuoteResponses
826
+ : [maybeQuoteResponses];
827
+ // Convert quote responses to V1 format and preserve metadata for consistency
828
+ const quoteResponses = quoteResponsesV1orV2.map((quote) => {
829
+ if (!(0, bridge_controller_1.isQuoteResponseV2)(quote)) {
830
+ return quote;
831
+ }
832
+ const quoteMetadataV1 = (0, bridge_controller_1.toQuoteMetadataV1)(quote, migrationPhase);
833
+ // This coercion omits legacy metadata from the resulting V1 quote
834
+ const quoteResponseV1 = (0, bridge_controller_1.toQuoteResponseV1)(quote);
835
+ // Merge legacy-shaped metadata to V1-shaped quote response
836
+ return { ...quoteResponseV1, ...quoteMetadataV1 };
837
+ });
838
+ const quoteResponse = quoteResponses[0];
839
+ const { quote } = quoteResponse;
840
+ const startTime = Date.now();
841
+ (0, bridge_js_1.stopPollingForQuotes)(this.messenger, quotesReceivedContext);
842
+ const selectedAccount = (0, accounts_js_1.getAccountByAddress)(this.messenger, accountAddress);
843
+ if (!selectedAccount) {
844
+ throw new Error('Failed to submit cross-chain swap transaction: undefined multichain account');
845
+ }
846
+ const accountHardwareType = (0, bridge_controller_2.getAccountHardwareType)(selectedAccount);
847
+ /**
848
+ * For hardware wallets on Mobile, this is fixes an issue where the Ledger does not get prompted for the 2nd approval.
849
+ * Extension does not have this issue
850
+ */
851
+ const requireApproval = __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === types_js_2.BridgeClientId.MOBILE && accountHardwareType !== null;
852
+ const isBridgeTx = (0, bridge_controller_2.isCrossChain)(quote.srcChainId, quote.destChainId);
853
+ const batchId = quoteResponses.some(({ featureId: quoteFeatureId }) => quoteFeatureId === bridge_controller_1.FeatureId.BATCH_SELL)
854
+ ? (0, transaction_controller_1.generateBatchId)()
855
+ : undefined;
856
+ const preConfirmationProperties = (0, metrics_js_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, isStxEnabled, accountHardwareType, location, abTests, activeAbTests, tokenSecurityTypeDestination, batchSellTrades, batchId, quotesReceivedContext);
857
+ try {
858
+ // Emit Submitted event after submit button is clicked
859
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Submitted, undefined, {
860
+ ...preConfirmationProperties,
861
+ ...(inputPrimaryDenomination && {
862
+ input_primary_denomination: inputPrimaryDenomination,
863
+ }),
864
+ });
865
+ /**
866
+ * Check if the account is an EIP-7702 delegated account.
867
+ * Delegated accounts only allow 1 in-flight tx, so approve + swap
868
+ * must be batched into a single transaction
869
+ */
870
+ const isDelegatedAccount = (0, bridge_controller_2.isNonEvmChainId)(quote.srcChainId)
871
+ ? false
872
+ : await (0, transaction_js_1.checkIsDelegatedAccount)(this.messenger, selectedAccount.address, [(0, bridge_controller_2.formatChainIdToHex)(quote.srcChainId)]);
873
+ const strategyParams = {
874
+ messenger: this.messenger,
875
+ quoteResponses,
876
+ batchSellTrades,
877
+ isStxEnabled,
878
+ isBridgeTx,
879
+ isDelegatedAccount,
880
+ selectedAccount,
881
+ requireApproval,
882
+ clientId: __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"),
883
+ bridgeApiBaseUrl: __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl,
884
+ addTransactionBatchFn: __classPrivateFieldGet(this, _BridgeStatusController_addTransactionBatchFn, "f"),
885
+ fetchFn: __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"),
886
+ traceFn: __classPrivateFieldGet(this, _BridgeStatusController_trace, "f"),
887
+ batchId,
888
+ };
889
+ return await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, (0, trace_js_1.getTraceParams)(quoteResponse, isStxEnabled), async () => await __classPrivateFieldGet(this, _BridgeStatusController_executeSubmitStrategy, "f").call(this, strategyParams, {
890
+ startTime,
891
+ location,
892
+ abTests,
893
+ activeAbTests,
894
+ tokenSecurityTypeDestination,
895
+ inputPrimaryDenomination,
896
+ customSlippage: quotesReceivedContext?.custom_slippage,
897
+ slippagePercentage: quotesReceivedContext?.slippage_limit,
898
+ }));
899
+ }
900
+ catch (error) {
901
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Failed, undefined, {
902
+ error_message: error?.message,
903
+ ...preConfirmationProperties,
904
+ });
905
+ throw error;
906
+ }
907
+ };
908
+ /**
909
+ * Submits an intent order and creates a synthetic history entry for UX.
910
+ * The EIP-712 payload is always signed inside this controller via KeyringController.
911
+ *
912
+ * @param params - Object containing intent submission parameters
913
+ * @param params.quoteResponse - Quote carrying intent data
914
+ * @param params.accountAddress - The EOA submitting the order
915
+ * @param params.location - The entry point from which the user initiated the swap or bridge
916
+ * @param params.abTests - Legacy A/B test context for `ab_tests` (backward compatibility)
917
+ * @param params.activeAbTests - New A/B test context for `active_ab_tests` (migration target). Attributes events to specific experiments.
918
+ * @param params.tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.
919
+ * @param params.inputPrimaryDenomination - The denomination shown as the primary source amount input at submission time.
920
+ * @param params.isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
921
+ * @param params.quotesReceivedContext - The context for the QuotesReceived event
922
+ * @param params.migrationPhase - The active migration phase for the quote response
923
+ * @returns A lightweight TransactionMeta-like object for history linking
924
+ * @throws An error if intent or transaction submission fails before they get published
925
+ */
926
+ this.submitIntent = async (params) => {
927
+ const { quoteResponse, accountAddress, location, abTests, migrationPhase, activeAbTests, tokenSecurityTypeDestination, inputPrimaryDenomination, isStxEnabled = false, quotesReceivedContext, } = params;
928
+ return await this.submitTx(accountAddress, quoteResponse, isStxEnabled, quotesReceivedContext, location, abTests, activeAbTests, tokenSecurityTypeDestination, undefined, inputPrimaryDenomination, migrationPhase);
929
+ };
930
+ this.submitBatchSell = async (params) => {
931
+ /**
932
+ * Retrieve the batch sell trades from the BridgeController's state to ensure we submit
933
+ * the original response data from the bridge-api
934
+ */
935
+ const batchSellTrades = (0, bridge_js_1.getBatchSellTrades)(this.messenger);
936
+ return await this.submitTx(params.accountAddress, params.quoteResponses.filter((quoteResponse) => quoteResponse !== null), params.isStxEnabled ?? false, params.quotesReceivedContext, params.location, params.abTests, params.activeAbTests, params.tokenSecurityTypeDestination, batchSellTrades, undefined, params.migrationPhase);
937
+ };
938
+ _BridgeStatusController_trackPollingStatusUpdatedEvent.set(this, (historyKey, pollingStatus) => {
939
+ // Track polling status updated event
940
+ const historyItem = this.state.txHistory[historyKey];
941
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.PollingStatusUpdated, historyKey, {
942
+ polling_status: pollingStatus,
943
+ retry_attempts: historyItem.attempts?.counter ?? 0,
944
+ });
945
+ });
946
+ /**
947
+ * Tracks post-submission events for a cross-chain swap based on the history item
948
+ *
949
+ * @param eventName - The name of the event to track
950
+ * @param txHistoryKey - The txMetaId, actionId or intentUid of the history item to track the event for
951
+ * @param eventProperties - The properties for the event
952
+ */
953
+ _BridgeStatusController_trackUnifiedSwapBridgeEvent.set(this, (eventName, txHistoryKey, eventProperties) => {
954
+ const historyItem = txHistoryKey
955
+ ? this.state.txHistory[txHistoryKey]
956
+ : undefined;
957
+ const featureId = eventProperties?.feature_id ??
958
+ historyItem?.featureId ??
959
+ bridge_controller_1.FeatureId.UNIFIED_SWAP_BRIDGE;
960
+ if (!(constants_js_1.ALLOWED_FEATURE_IDS_FOR_STATUS_EVENTS.includes(featureId) ||
961
+ eventName === bridge_controller_2.UnifiedSwapBridgeEventName.StatusValidationFailed)) {
962
+ return;
963
+ }
964
+ // Legacy/new metrics fields are intentionally kept independent during migration.
965
+ const historyAbTests = txHistoryKey
966
+ ? this.state.txHistory?.[txHistoryKey]?.abTests
967
+ : undefined;
968
+ const historyActiveAbTests = txHistoryKey
969
+ ? this.state.txHistory?.[txHistoryKey]?.activeAbTests
970
+ : undefined;
971
+ const resolvedAbTests = eventProperties?.ab_tests ?? historyAbTests;
972
+ const resolvedActiveAbTests = eventProperties?.active_ab_tests ?? historyActiveAbTests;
973
+ const location = historyItem?.location ??
974
+ eventProperties?.location ??
975
+ bridge_controller_2.MetaMetricsSwapsEventSource.Unknown;
976
+ const baseProperties = {
977
+ action_type: bridge_controller_2.MetricsActionType.SWAPBRIDGE_V1,
978
+ feature_id: featureId ?? bridge_controller_1.FeatureId.UNIFIED_SWAP_BRIDGE,
979
+ ...(historyItem?.batchId ? { batch_id: historyItem.batchId } : {}),
980
+ ...(eventProperties ?? {}),
981
+ location,
982
+ ...(resolvedAbTests &&
983
+ Object.keys(resolvedAbTests).length > 0 && {
984
+ ab_tests: resolvedAbTests,
985
+ }),
986
+ ...(resolvedActiveAbTests &&
987
+ resolvedActiveAbTests.length > 0 && {
988
+ active_ab_tests: resolvedActiveAbTests,
989
+ }),
990
+ };
991
+ // This will publish events for PERPS dropped tx failures as well
992
+ if (!historyItem) {
993
+ (0, bridge_js_1.trackMetricsEvent)({
994
+ messenger: this.messenger,
995
+ eventName,
996
+ properties: baseProperties,
997
+ });
998
+ return;
999
+ }
1000
+ const { approvalTxId, quote } = historyItem;
1001
+ const requestParamProperties = (0, metrics_js_1.getRequestParamFromHistory)(historyItem);
1002
+ if (eventName === bridge_controller_2.UnifiedSwapBridgeEventName.StatusValidationFailed) {
1003
+ (0, bridge_js_1.trackMetricsEvent)({
1004
+ messenger: this.messenger,
1005
+ eventName,
1006
+ properties: {
1007
+ ...baseProperties,
1008
+ chain_id_source: requestParamProperties.chain_id_source,
1009
+ chain_id_destination: requestParamProperties.chain_id_destination,
1010
+ token_address_source: requestParamProperties.token_address_source,
1011
+ token_address_destination: requestParamProperties.token_address_destination,
1012
+ token_security_type_destination: requestParamProperties.token_security_type_destination,
1013
+ refresh_count: historyItem.attempts?.counter ?? 0,
1014
+ },
1015
+ });
1016
+ return;
1017
+ }
1018
+ const selectedAccount = (0, accounts_js_1.getAccountByAddress)(this.messenger, historyItem.account);
1019
+ const transactions = (0, transaction_js_1.getTransactions)(this.messenger);
1020
+ const txMeta = transactions.find((tx) => tx.id === txHistoryKey);
1021
+ const approvalTxMeta = transactions.find((tx) => tx.id === approvalTxId);
1022
+ const requiredEventProperties = {
1023
+ ...baseProperties,
1024
+ ...requestParamProperties,
1025
+ ...(0, metrics_js_1.getRequestMetadataFromHistory)(historyItem, selectedAccount),
1026
+ ...(0, metrics_js_1.getTradeDataFromHistory)(historyItem),
1027
+ ...(0, metrics_js_1.getTxStatusesFromHistory)(historyItem),
1028
+ ...(0, metrics_js_1.getFinalizedTxProperties)(historyItem, txMeta, approvalTxMeta),
1029
+ ...(0, metrics_js_1.getPriceImpactFromQuote)(quote),
1030
+ ...(eventName === bridge_controller_2.UnifiedSwapBridgeEventName.Completed && {
1031
+ ...(!(0, bridge_controller_2.isNonEvmChainId)(historyItem.quote.srcChainId) &&
1032
+ historyItem.txMetaId && {
1033
+ transaction_internal_id: historyItem.txMetaId,
1034
+ }),
1035
+ ...(historyItem.inputPrimaryDenomination && {
1036
+ input_primary_denomination: historyItem.inputPrimaryDenomination,
1037
+ }),
1038
+ }),
1039
+ };
1040
+ (0, bridge_js_1.trackMetricsEvent)({
1041
+ messenger: this.messenger,
1042
+ eventName,
1043
+ properties: requiredEventProperties,
1044
+ });
1045
+ });
1046
+ __classPrivateFieldSet(this, _BridgeStatusController_clientId, clientId, "f");
1047
+ __classPrivateFieldSet(this, _BridgeStatusController_fetchFn, fetchFn, "f");
1048
+ __classPrivateFieldSet(this, _BridgeStatusController_addTransactionBatchFn, addTransactionBatchFn, "f");
1049
+ __classPrivateFieldSet(this, _BridgeStatusController_config, {
1050
+ customBridgeApiBaseUrl: config?.customBridgeApiBaseUrl ?? constants_js_1.BRIDGE_PROD_API_BASE_URL,
1051
+ }, "f");
1052
+ __classPrivateFieldSet(this, _BridgeStatusController_trace, traceFn ?? ((_request, fn) => fn?.()), "f");
1053
+ __classPrivateFieldSet(this, _BridgeStatusController_intentManager, new bridge_status_controller_intent_1.IntentManager({
1054
+ messenger: this.messenger,
1055
+ customBridgeApiBaseUrl: __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl,
1056
+ fetchFn: __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"),
1057
+ }), "f");
1058
+ __classPrivateFieldSet(this, _BridgeStatusController_quoteStatusManager, new quotes_status_manager_js_1.QuoteStatusManager({
1059
+ messenger: this.messenger,
1060
+ clientId: __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"),
1061
+ clientProduct,
1062
+ clientVersion,
1063
+ apiBaseUrl: __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl,
1064
+ initialData: this.state.quoteUpdateStatusStore,
1065
+ onPersistUpdates: (updates) => {
1066
+ this.update((draft) => {
1067
+ draft.quoteUpdateStatusStore = updates;
1068
+ });
1069
+ },
1070
+ entryTtlMs: constants_js_2.QUOTE_STATUS_UPDATE_ENTRY_TTL,
1071
+ updateIntervalMs: constants_js_2.QUOTE_STATUS_UPDATE_RETRY_INTERVAL_MS,
1072
+ onError: onQuoteStatusManagerError,
1073
+ isEnabled: isQuoteStatusManagerEnabled,
1074
+ }), "f");
1075
+ // Register action handlers
1076
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
1077
+ // Set interval
1078
+ this.setIntervalLength(constants_js_1.REFRESH_INTERVAL_MS);
1079
+ this.messenger.subscribe('TransactionController:transactionStatusUpdated', ({ txMeta, historyKey, historyItem, isApprovalTxMeta }) => {
1080
+ if (!txMeta) {
1081
+ return;
1082
+ }
1083
+ const { type, status } = txMeta;
1084
+ // Allow event publishing if the txMeta is a swap/bridge OR if the
1085
+ // corresponding history item exists
1086
+ const isSwapOrBridgeTransaction = type && (0, transaction_js_1.isCrossChainTx)(type);
1087
+ if (!isSwapOrBridgeTransaction && !historyKey && !historyItem) {
1088
+ return;
1089
+ }
1090
+ switch (status) {
1091
+ case transaction_controller_1.TransactionStatus.submitted:
1092
+ // EVM txs report SUBMITTED here (not via transactionSubmitted) so hash
1093
+ // replacements before confirmation still reach the Bridge API.
1094
+ if (txMeta.hash &&
1095
+ txMeta.type &&
1096
+ (0, transaction_js_1.isCrossChainTx)(txMeta.type) &&
1097
+ !isApprovalTxMeta &&
1098
+ historyKey) {
1099
+ __classPrivateFieldGet(this, _BridgeStatusController_reportSubmittedOnce, "f").call(this, historyKey, txMeta.hash, txMeta.id);
1100
+ }
1101
+ break;
1102
+ case transaction_controller_1.TransactionStatus.confirmed:
1103
+ __classPrivateFieldGet(this, _BridgeStatusController_onTransactionConfirmed, "f").call(this, {
1104
+ txMeta,
1105
+ historyKey,
1106
+ isApprovalTxMeta,
1107
+ });
1108
+ break;
1109
+ case transaction_controller_1.TransactionStatus.failed:
1110
+ case transaction_controller_1.TransactionStatus.dropped:
1111
+ case transaction_controller_1.TransactionStatus.rejected:
1112
+ __classPrivateFieldGet(this, _BridgeStatusController_onTransactionFailed, "f").call(this, { txMeta, historyKey, isApprovalTxMeta });
1113
+ break;
1114
+ default:
1115
+ break;
1116
+ }
1117
+ }, ({ transactionMeta }) => {
1118
+ const entry = (0, history_js_1.getMatchingHistoryEntryForTxMeta)(this.state.txHistory, transactionMeta);
1119
+ const approvalEntry = (0, history_js_1.getMatchingHistoryEntryForApprovalTxMeta)(this.state.txHistory, transactionMeta);
1120
+ const entryToUse = entry ?? approvalEntry;
1121
+ return {
1122
+ historyKey: entryToUse?.[0],
1123
+ historyItem: entryToUse?.[1],
1124
+ txMeta: transactionMeta,
1125
+ isApprovalTxMeta: entryToUse?.[1]?.approvalTxId === transactionMeta.id,
1126
+ };
1127
+ });
1128
+ // Seed any missing quote-status entries from persisted history before
1129
+ // init(), so init()'s reconciliation loop can finalize quotes whose
1130
+ // deferred entry was never created (e.g. the client closed before
1131
+ // reportSubmitted ran).
1132
+ __classPrivateFieldGet(this, _BridgeStatusController_seedQuoteStatusEntriesFromHistory, "f").call(this);
1133
+ // Replay swap/bridge finalizations that resolved while the client was
1134
+ // closed, before resuming polling (which recovers in-flight bridges).
1135
+ __classPrivateFieldGet(this, _BridgeStatusController_quoteStatusManager, "f").init();
1136
+ // If you close the extension, but keep the browser open, the polling continues
1137
+ // If you close the browser, the polling stops
1138
+ // Check for historyItems that do not have a status of complete and restart polling
1139
+ __classPrivateFieldGet(this, _BridgeStatusController_restartPollingForIncompleteHistoryItems, "f").call(this);
1140
+ }
1141
+ }
1142
+ exports.BridgeStatusController = BridgeStatusController;
1143
+ _BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_intentManager = new WeakMap(), _BridgeStatusController_quoteStatusManager = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(), _BridgeStatusController_addTransactionBatchFn = new WeakMap(), _BridgeStatusController_trace = new WeakMap(), _BridgeStatusController_traceSwapOperationCompleted = new WeakMap(), _BridgeStatusController_onTransactionFailed = new WeakMap(), _BridgeStatusController_onTransactionConfirmed = new WeakMap(), _BridgeStatusController_reportSubmittedForNonEvmTx = new WeakMap(), _BridgeStatusController_reportSubmittedOnce = new WeakMap(), _BridgeStatusController_seedQuoteStatusEntriesFromHistory = new WeakMap(), _BridgeStatusController_restartPollingForIncompleteHistoryItems = new WeakMap(), _BridgeStatusController_addTxToHistory = new WeakMap(), _BridgeStatusController_rekeyHistoryItem = new WeakMap(), _BridgeStatusController_startPollingForTxId = new WeakMap(), _BridgeStatusController_handleFetchFailure = new WeakMap(), _BridgeStatusController_handleOldHistoryItem = new WeakMap(), _BridgeStatusController_fetchBridgeTxStatus = new WeakMap(), _BridgeStatusController_setAndGetSrcTxHash = new WeakMap(), _BridgeStatusController_updateHistoryItem = new WeakMap(), _BridgeStatusController_deleteHistoryItem = new WeakMap(), _BridgeStatusController_wipeBridgeStatusByChainId = new WeakMap(), _BridgeStatusController_executeSubmitStrategy = new WeakMap(), _BridgeStatusController_trackPollingStatusUpdatedEvent = new WeakMap(), _BridgeStatusController_trackUnifiedSwapBridgeEvent = new WeakMap();
1144
+ //# sourceMappingURL=bridge-status-controller.cjs.map