@metamask-previews/transaction-controller 69.6.1-preview-4f4c98e → 69.6.1-preview-eb263b0ee

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 (492) hide show
  1. package/CHANGELOG.md +0 -5
  2. package/dist/TransactionController-method-action-types.cjs +7 -0
  3. package/dist/TransactionController-method-action-types.cjs.map +1 -0
  4. package/dist/{TransactionController-method-action-types.d.ts → TransactionController-method-action-types.d.cts} +2 -2
  5. package/dist/TransactionController-method-action-types.d.cts.map +1 -0
  6. package/dist/TransactionController-method-action-types.d.mts +413 -0
  7. package/dist/TransactionController-method-action-types.d.mts.map +1 -0
  8. package/dist/{TransactionController-method-action-types.js → TransactionController-method-action-types.mjs} +1 -1
  9. package/dist/TransactionController-method-action-types.mjs.map +1 -0
  10. package/dist/TransactionController.cjs +2444 -0
  11. package/dist/TransactionController.cjs.map +1 -0
  12. package/dist/{TransactionController.d.ts → TransactionController.d.cts} +18 -18
  13. package/dist/TransactionController.d.cts.map +1 -0
  14. package/dist/TransactionController.d.mts +751 -0
  15. package/dist/TransactionController.d.mts.map +1 -0
  16. package/dist/{TransactionController.js → TransactionController.mjs} +50 -49
  17. package/dist/TransactionController.mjs.map +1 -0
  18. package/dist/api/accounts-api.cjs +57 -0
  19. package/dist/api/accounts-api.cjs.map +1 -0
  20. package/dist/api/{accounts-api.d.ts → accounts-api.d.cts} +1 -1
  21. package/dist/api/accounts-api.d.cts.map +1 -0
  22. package/dist/api/accounts-api.d.mts +44 -0
  23. package/dist/api/accounts-api.d.mts.map +1 -0
  24. package/dist/api/{accounts-api.js → accounts-api.mjs} +5 -5
  25. package/dist/api/accounts-api.mjs.map +1 -0
  26. package/dist/api/simulation-api.cjs +116 -0
  27. package/dist/api/simulation-api.cjs.map +1 -0
  28. package/dist/api/{simulation-api.d.ts → simulation-api.d.cts} +3 -3
  29. package/dist/api/simulation-api.d.cts.map +1 -0
  30. package/dist/api/simulation-api.d.mts +196 -0
  31. package/dist/api/simulation-api.d.mts.map +1 -0
  32. package/dist/api/{simulation-api.js → simulation-api.mjs} +8 -7
  33. package/dist/api/simulation-api.mjs.map +1 -0
  34. package/dist/constants.cjs +111 -0
  35. package/dist/constants.cjs.map +1 -0
  36. package/dist/{constants.d.ts → constants.d.cts} +37 -37
  37. package/dist/constants.d.cts.map +1 -0
  38. package/dist/constants.d.mts +78 -0
  39. package/dist/constants.d.mts.map +1 -0
  40. package/dist/{constants.js → constants.mjs} +1 -1
  41. package/dist/constants.mjs.map +1 -0
  42. package/dist/errors.cjs +37 -0
  43. package/dist/errors.cjs.map +1 -0
  44. package/dist/{errors.d.ts → errors.d.cts} +2 -2
  45. package/dist/errors.d.cts.map +1 -0
  46. package/dist/errors.d.mts +19 -0
  47. package/dist/errors.d.mts.map +1 -0
  48. package/dist/{errors.js → errors.mjs} +2 -2
  49. package/dist/errors.mjs.map +1 -0
  50. package/dist/gas-flows/DefaultGasFeeFlow.cjs +85 -0
  51. package/dist/gas-flows/{DefaultGasFeeFlow.js.map → DefaultGasFeeFlow.cjs.map} +1 -1
  52. package/dist/gas-flows/{DefaultGasFeeFlow.d.ts → DefaultGasFeeFlow.d.cts} +2 -2
  53. package/dist/gas-flows/DefaultGasFeeFlow.d.cts.map +1 -0
  54. package/dist/gas-flows/DefaultGasFeeFlow.d.mts +10 -0
  55. package/dist/gas-flows/DefaultGasFeeFlow.d.mts.map +1 -0
  56. package/dist/gas-flows/{DefaultGasFeeFlow.js → DefaultGasFeeFlow.mjs} +6 -6
  57. package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -0
  58. package/dist/gas-flows/LineaGasFeeFlow.cjs +111 -0
  59. package/dist/gas-flows/LineaGasFeeFlow.cjs.map +1 -0
  60. package/dist/gas-flows/{LineaGasFeeFlow.d.ts → LineaGasFeeFlow.d.cts} +3 -3
  61. package/dist/gas-flows/LineaGasFeeFlow.d.cts.map +1 -0
  62. package/dist/gas-flows/LineaGasFeeFlow.d.mts +16 -0
  63. package/dist/gas-flows/LineaGasFeeFlow.d.mts.map +1 -0
  64. package/dist/gas-flows/{LineaGasFeeFlow.js → LineaGasFeeFlow.mjs} +7 -7
  65. package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -0
  66. package/dist/gas-flows/MantleLayer1GasFeeFlow.cjs +66 -0
  67. package/dist/gas-flows/MantleLayer1GasFeeFlow.cjs.map +1 -0
  68. package/dist/gas-flows/{MantleLayer1GasFeeFlow.d.ts → MantleLayer1GasFeeFlow.d.cts} +5 -5
  69. package/dist/gas-flows/MantleLayer1GasFeeFlow.d.cts.map +1 -0
  70. package/dist/gas-flows/MantleLayer1GasFeeFlow.d.mts +21 -0
  71. package/dist/gas-flows/MantleLayer1GasFeeFlow.d.mts.map +1 -0
  72. package/dist/gas-flows/{MantleLayer1GasFeeFlow.js → MantleLayer1GasFeeFlow.mjs} +6 -6
  73. package/dist/gas-flows/MantleLayer1GasFeeFlow.mjs.map +1 -0
  74. package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +59 -0
  75. package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -0
  76. package/dist/gas-flows/{OptimismLayer1GasFeeFlow.d.ts → OptimismLayer1GasFeeFlow.d.cts} +4 -4
  77. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -0
  78. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts +14 -0
  79. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -0
  80. package/dist/gas-flows/{OptimismLayer1GasFeeFlow.js → OptimismLayer1GasFeeFlow.mjs} +5 -5
  81. package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -0
  82. package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +201 -0
  83. package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -0
  84. package/dist/gas-flows/{OracleLayer1GasFeeFlow.d.ts → OracleLayer1GasFeeFlow.d.cts} +5 -5
  85. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -0
  86. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts +57 -0
  87. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -0
  88. package/dist/gas-flows/{OracleLayer1GasFeeFlow.js → OracleLayer1GasFeeFlow.mjs} +15 -8
  89. package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -0
  90. package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs +123 -0
  91. package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs.map +1 -0
  92. package/dist/gas-flows/{RandomisedEstimationsGasFeeFlow.d.ts → RandomisedEstimationsGasFeeFlow.d.cts} +4 -4
  93. package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.cts.map +1 -0
  94. package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts +28 -0
  95. package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts.map +1 -0
  96. package/dist/gas-flows/{RandomisedEstimationsGasFeeFlow.js → RandomisedEstimationsGasFeeFlow.mjs} +8 -8
  97. package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.mjs.map +1 -0
  98. package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +24 -0
  99. package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -0
  100. package/dist/gas-flows/{ScrollLayer1GasFeeFlow.d.ts → ScrollLayer1GasFeeFlow.d.cts} +5 -5
  101. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -0
  102. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts +16 -0
  103. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -0
  104. package/dist/gas-flows/{ScrollLayer1GasFeeFlow.js → ScrollLayer1GasFeeFlow.mjs} +3 -3
  105. package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -0
  106. package/dist/gas-flows/TestGasFeeFlow.cjs +73 -0
  107. package/dist/gas-flows/TestGasFeeFlow.cjs.map +1 -0
  108. package/dist/gas-flows/{TestGasFeeFlow.d.ts → TestGasFeeFlow.d.cts} +2 -2
  109. package/dist/gas-flows/TestGasFeeFlow.d.cts.map +1 -0
  110. package/dist/gas-flows/TestGasFeeFlow.d.mts +12 -0
  111. package/dist/gas-flows/TestGasFeeFlow.d.mts.map +1 -0
  112. package/dist/gas-flows/{TestGasFeeFlow.js → TestGasFeeFlow.mjs} +3 -3
  113. package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -0
  114. package/dist/helpers/GasFeePoller.cjs +334 -0
  115. package/dist/helpers/GasFeePoller.cjs.map +1 -0
  116. package/dist/helpers/{GasFeePoller.d.ts → GasFeePoller.d.cts} +10 -7
  117. package/dist/helpers/GasFeePoller.d.cts.map +1 -0
  118. package/dist/helpers/GasFeePoller.d.mts +66 -0
  119. package/dist/helpers/GasFeePoller.d.mts.map +1 -0
  120. package/dist/helpers/{GasFeePoller.js → GasFeePoller.mjs} +9 -9
  121. package/dist/helpers/GasFeePoller.mjs.map +1 -0
  122. package/dist/helpers/MethodDataHelper.cjs +84 -0
  123. package/dist/helpers/MethodDataHelper.cjs.map +1 -0
  124. package/dist/helpers/{MethodDataHelper.d.ts → MethodDataHelper.d.cts} +7 -4
  125. package/dist/helpers/MethodDataHelper.d.cts.map +1 -0
  126. package/dist/helpers/MethodDataHelper.d.mts +16 -0
  127. package/dist/helpers/MethodDataHelper.d.mts.map +1 -0
  128. package/dist/helpers/{MethodDataHelper.js → MethodDataHelper.mjs} +7 -7
  129. package/dist/helpers/MethodDataHelper.mjs.map +1 -0
  130. package/dist/helpers/MultichainTrackingHelper.cjs +231 -0
  131. package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -0
  132. package/dist/helpers/{MultichainTrackingHelper.d.ts → MultichainTrackingHelper.d.cts} +5 -5
  133. package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -0
  134. package/dist/helpers/MultichainTrackingHelper.d.mts +56 -0
  135. package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -0
  136. package/dist/helpers/{MultichainTrackingHelper.js → MultichainTrackingHelper.mjs} +8 -8
  137. package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -0
  138. package/dist/helpers/PendingTransactionTracker.cjs +407 -0
  139. package/dist/helpers/PendingTransactionTracker.cjs.map +1 -0
  140. package/dist/helpers/{PendingTransactionTracker.d.ts → PendingTransactionTracker.d.cts} +8 -5
  141. package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -0
  142. package/dist/helpers/PendingTransactionTracker.d.mts +54 -0
  143. package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -0
  144. package/dist/helpers/{PendingTransactionTracker.js → PendingTransactionTracker.mjs} +15 -14
  145. package/dist/helpers/PendingTransactionTracker.mjs.map +1 -0
  146. package/dist/helpers/ResimulateHelper.cjs +274 -0
  147. package/dist/helpers/ResimulateHelper.cjs.map +1 -0
  148. package/dist/helpers/{ResimulateHelper.d.ts → ResimulateHelper.d.cts} +3 -3
  149. package/dist/helpers/ResimulateHelper.d.cts.map +1 -0
  150. package/dist/helpers/ResimulateHelper.d.mts +36 -0
  151. package/dist/helpers/ResimulateHelper.d.mts.map +1 -0
  152. package/dist/helpers/{ResimulateHelper.js → ResimulateHelper.mjs} +8 -7
  153. package/dist/helpers/ResimulateHelper.mjs.map +1 -0
  154. package/dist/helpers/TransactionPoller.cjs +175 -0
  155. package/dist/helpers/TransactionPoller.cjs.map +1 -0
  156. package/dist/helpers/{TransactionPoller.d.ts → TransactionPoller.d.cts} +5 -5
  157. package/dist/helpers/TransactionPoller.d.cts.map +1 -0
  158. package/dist/helpers/TransactionPoller.d.mts +37 -0
  159. package/dist/helpers/TransactionPoller.d.mts.map +1 -0
  160. package/dist/helpers/{TransactionPoller.js → TransactionPoller.mjs} +11 -10
  161. package/dist/helpers/TransactionPoller.mjs.map +1 -0
  162. package/dist/hooks/CollectPublishHook.cjs +94 -0
  163. package/dist/hooks/CollectPublishHook.cjs.map +1 -0
  164. package/dist/hooks/{CollectPublishHook.d.ts → CollectPublishHook.d.cts} +3 -3
  165. package/dist/hooks/CollectPublishHook.d.cts.map +1 -0
  166. package/dist/hooks/CollectPublishHook.d.mts +29 -0
  167. package/dist/hooks/CollectPublishHook.d.mts.map +1 -0
  168. package/dist/hooks/{CollectPublishHook.js → CollectPublishHook.mjs} +5 -4
  169. package/dist/hooks/CollectPublishHook.mjs.map +1 -0
  170. package/dist/hooks/ExtraTransactionsPublishHook.cjs +126 -0
  171. package/dist/hooks/ExtraTransactionsPublishHook.cjs.map +1 -0
  172. package/dist/hooks/{ExtraTransactionsPublishHook.d.ts → ExtraTransactionsPublishHook.d.cts} +3 -3
  173. package/dist/hooks/ExtraTransactionsPublishHook.d.cts.map +1 -0
  174. package/dist/hooks/ExtraTransactionsPublishHook.d.mts +19 -0
  175. package/dist/hooks/ExtraTransactionsPublishHook.d.mts.map +1 -0
  176. package/dist/hooks/{ExtraTransactionsPublishHook.js → ExtraTransactionsPublishHook.mjs} +3 -3
  177. package/dist/hooks/ExtraTransactionsPublishHook.mjs.map +1 -0
  178. package/dist/hooks/SequentialPublishBatchHook.cjs +112 -0
  179. package/dist/hooks/SequentialPublishBatchHook.cjs.map +1 -0
  180. package/dist/hooks/{SequentialPublishBatchHook.d.ts → SequentialPublishBatchHook.d.cts} +4 -4
  181. package/dist/hooks/SequentialPublishBatchHook.d.cts.map +1 -0
  182. package/dist/hooks/SequentialPublishBatchHook.d.mts +22 -0
  183. package/dist/hooks/SequentialPublishBatchHook.d.mts.map +1 -0
  184. package/dist/hooks/{SequentialPublishBatchHook.js → SequentialPublishBatchHook.mjs} +4 -4
  185. package/dist/hooks/SequentialPublishBatchHook.mjs.map +1 -0
  186. package/dist/index.cjs +40 -0
  187. package/dist/index.cjs.map +1 -0
  188. package/dist/{index.d.ts → index.d.cts} +16 -16
  189. package/dist/index.d.cts.map +1 -0
  190. package/dist/index.d.mts +16 -0
  191. package/dist/index.d.mts.map +1 -0
  192. package/dist/index.mjs +12 -0
  193. package/dist/index.mjs.map +1 -0
  194. package/dist/logger.cjs +9 -0
  195. package/dist/logger.cjs.map +1 -0
  196. package/dist/{logger.d.ts → logger.d.cts} +3 -2
  197. package/dist/logger.d.cts.map +1 -0
  198. package/dist/logger.d.mts +6 -0
  199. package/dist/logger.d.mts.map +1 -0
  200. package/dist/{logger.js → logger.mjs} +2 -2
  201. package/dist/logger.mjs.map +1 -0
  202. package/dist/types.cjs +382 -0
  203. package/dist/types.cjs.map +1 -0
  204. package/dist/{types.d.ts → types.d.cts} +8 -8
  205. package/dist/types.d.cts.map +1 -0
  206. package/dist/types.d.mts +1887 -0
  207. package/dist/types.d.mts.map +1 -0
  208. package/dist/{types.js → types.mjs} +1 -1
  209. package/dist/types.mjs.map +1 -0
  210. package/dist/utils/balance-changes.cjs +592 -0
  211. package/dist/utils/balance-changes.cjs.map +1 -0
  212. package/dist/utils/{balance-changes.d.ts → balance-changes.d.cts} +5 -5
  213. package/dist/utils/balance-changes.d.cts.map +1 -0
  214. package/dist/utils/balance-changes.d.mts +38 -0
  215. package/dist/utils/balance-changes.d.mts.map +1 -0
  216. package/dist/utils/{balance-changes.js → balance-changes.mjs} +20 -13
  217. package/dist/utils/balance-changes.mjs.map +1 -0
  218. package/dist/utils/balance.cjs +44 -0
  219. package/dist/utils/balance.cjs.map +1 -0
  220. package/dist/utils/{balance.d.ts → balance.d.cts} +5 -5
  221. package/dist/utils/balance.d.cts.map +1 -0
  222. package/dist/utils/balance.d.mts +26 -0
  223. package/dist/utils/balance.d.mts.map +1 -0
  224. package/dist/utils/{balance.js → balance.mjs} +3 -3
  225. package/dist/utils/balance.mjs.map +1 -0
  226. package/dist/utils/batch.cjs +712 -0
  227. package/dist/utils/batch.cjs.map +1 -0
  228. package/dist/utils/{batch.d.ts → batch.d.cts} +8 -8
  229. package/dist/utils/batch.d.cts.map +1 -0
  230. package/dist/utils/batch.d.mts +58 -0
  231. package/dist/utils/batch.d.mts.map +1 -0
  232. package/dist/utils/{batch.js → batch.mjs} +18 -18
  233. package/dist/utils/batch.mjs.map +1 -0
  234. package/dist/utils/eip7702.cjs +354 -0
  235. package/dist/utils/eip7702.cjs.map +1 -0
  236. package/dist/utils/{eip7702.d.ts → eip7702.d.cts} +5 -5
  237. package/dist/utils/eip7702.d.cts.map +1 -0
  238. package/dist/utils/eip7702.d.mts +137 -0
  239. package/dist/utils/eip7702.d.mts.map +1 -0
  240. package/dist/utils/{eip7702.js → eip7702.mjs} +12 -12
  241. package/dist/utils/eip7702.mjs.map +1 -0
  242. package/dist/utils/external-transactions.cjs +36 -0
  243. package/dist/utils/external-transactions.cjs.map +1 -0
  244. package/dist/utils/{external-transactions.d.ts → external-transactions.d.cts} +2 -2
  245. package/dist/utils/external-transactions.d.cts.map +1 -0
  246. package/dist/utils/external-transactions.d.mts +10 -0
  247. package/dist/utils/external-transactions.d.mts.map +1 -0
  248. package/dist/utils/{external-transactions.js → external-transactions.mjs} +3 -3
  249. package/dist/utils/external-transactions.mjs.map +1 -0
  250. package/dist/utils/feature-flags.cjs +255 -0
  251. package/dist/utils/feature-flags.cjs.map +1 -0
  252. package/dist/utils/{feature-flags.d.ts → feature-flags.d.cts} +3 -3
  253. package/dist/utils/feature-flags.d.cts.map +1 -0
  254. package/dist/utils/feature-flags.d.mts +313 -0
  255. package/dist/utils/feature-flags.d.mts.map +1 -0
  256. package/dist/utils/{feature-flags.js → feature-flags.mjs} +5 -5
  257. package/dist/utils/feature-flags.mjs.map +1 -0
  258. package/dist/utils/first-time-interaction.cjs +69 -0
  259. package/dist/utils/first-time-interaction.cjs.map +1 -0
  260. package/dist/utils/{first-time-interaction.d.ts → first-time-interaction.d.cts} +3 -3
  261. package/dist/utils/first-time-interaction.d.cts.map +1 -0
  262. package/dist/utils/first-time-interaction.d.mts +30 -0
  263. package/dist/utils/first-time-interaction.d.mts.map +1 -0
  264. package/dist/utils/{first-time-interaction.js → first-time-interaction.mjs} +6 -6
  265. package/dist/utils/first-time-interaction.mjs.map +1 -0
  266. package/dist/utils/gas-fee-tokens.cjs +174 -0
  267. package/dist/utils/gas-fee-tokens.cjs.map +1 -0
  268. package/dist/utils/{gas-fee-tokens.d.ts → gas-fee-tokens.d.cts} +5 -5
  269. package/dist/utils/gas-fee-tokens.d.cts.map +1 -0
  270. package/dist/utils/gas-fee-tokens.d.mts +46 -0
  271. package/dist/utils/gas-fee-tokens.d.mts.map +1 -0
  272. package/dist/utils/{gas-fee-tokens.js → gas-fee-tokens.mjs} +9 -9
  273. package/dist/utils/gas-fee-tokens.mjs.map +1 -0
  274. package/dist/utils/gas-fees.cjs +424 -0
  275. package/dist/utils/gas-fees.cjs.map +1 -0
  276. package/dist/utils/{gas-fees.d.ts → gas-fees.d.cts} +5 -5
  277. package/dist/utils/gas-fees.d.cts.map +1 -0
  278. package/dist/utils/gas-fees.d.mts +57 -0
  279. package/dist/utils/gas-fees.d.mts.map +1 -0
  280. package/dist/utils/{gas-fees.js → gas-fees.mjs} +9 -9
  281. package/dist/utils/gas-fees.mjs.map +1 -0
  282. package/dist/utils/gas-flow.cjs +81 -0
  283. package/dist/utils/gas-flow.cjs.map +1 -0
  284. package/dist/utils/{gas-flow.d.ts → gas-flow.d.cts} +6 -6
  285. package/dist/utils/gas-flow.d.cts.map +1 -0
  286. package/dist/utils/gas-flow.d.mts +29 -0
  287. package/dist/utils/gas-flow.d.mts.map +1 -0
  288. package/dist/utils/{gas-flow.js → gas-flow.mjs} +3 -3
  289. package/dist/utils/gas-flow.mjs.map +1 -0
  290. package/dist/utils/gas.cjs +545 -0
  291. package/dist/utils/gas.cjs.map +1 -0
  292. package/dist/utils/{gas.d.ts → gas.d.cts} +6 -5
  293. package/dist/utils/gas.d.cts.map +1 -0
  294. package/dist/utils/gas.d.mts +116 -0
  295. package/dist/utils/gas.d.mts.map +1 -0
  296. package/dist/utils/{gas.js → gas.mjs} +11 -11
  297. package/dist/utils/gas.mjs.map +1 -0
  298. package/dist/utils/layer1-gas-fee-flow.cjs +73 -0
  299. package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -0
  300. package/dist/utils/{layer1-gas-fee-flow.d.ts → layer1-gas-fee-flow.d.cts} +4 -4
  301. package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -0
  302. package/dist/utils/layer1-gas-fee-flow.d.mts +28 -0
  303. package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -0
  304. package/dist/utils/{layer1-gas-fee-flow.js → layer1-gas-fee-flow.mjs} +3 -3
  305. package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -0
  306. package/dist/utils/nonce.cjs +93 -0
  307. package/dist/utils/nonce.cjs.map +1 -0
  308. package/dist/utils/{nonce.d.ts → nonce.d.cts} +3 -3
  309. package/dist/utils/nonce.d.cts.map +1 -0
  310. package/dist/utils/nonce.d.mts +26 -0
  311. package/dist/utils/nonce.d.mts.map +1 -0
  312. package/dist/utils/{nonce.js → nonce.mjs} +4 -4
  313. package/dist/utils/nonce.mjs.map +1 -0
  314. package/dist/utils/prepare.cjs +97 -0
  315. package/dist/utils/prepare.cjs.map +1 -0
  316. package/dist/utils/{prepare.d.ts → prepare.d.cts} +5 -5
  317. package/dist/utils/prepare.d.cts.map +1 -0
  318. package/dist/utils/prepare.d.mts +22 -0
  319. package/dist/utils/prepare.d.mts.map +1 -0
  320. package/dist/utils/{prepare.js → prepare.mjs} +6 -5
  321. package/dist/utils/prepare.mjs.map +1 -0
  322. package/dist/utils/provider.cjs +106 -0
  323. package/dist/utils/provider.cjs.map +1 -0
  324. package/dist/utils/{provider.d.ts → provider.d.cts} +4 -4
  325. package/dist/utils/provider.d.cts.map +1 -0
  326. package/dist/utils/provider.d.mts +65 -0
  327. package/dist/utils/provider.d.mts.map +1 -0
  328. package/dist/utils/{provider.js → provider.mjs} +3 -3
  329. package/dist/utils/provider.mjs.map +1 -0
  330. package/dist/utils/recipient.cjs +31 -0
  331. package/dist/utils/recipient.cjs.map +1 -0
  332. package/dist/utils/{recipient.d.ts → recipient.d.cts} +2 -2
  333. package/dist/utils/recipient.d.cts.map +1 -0
  334. package/dist/utils/recipient.d.mts +13 -0
  335. package/dist/utils/recipient.d.mts.map +1 -0
  336. package/dist/utils/{recipient.js → recipient.mjs} +3 -3
  337. package/dist/utils/recipient.mjs.map +1 -0
  338. package/dist/utils/retry.cjs +93 -0
  339. package/dist/utils/retry.cjs.map +1 -0
  340. package/dist/utils/{retry.d.ts → retry.d.cts} +2 -2
  341. package/dist/utils/retry.d.cts.map +1 -0
  342. package/dist/utils/retry.d.mts +11 -0
  343. package/dist/utils/retry.d.mts.map +1 -0
  344. package/dist/utils/{retry.js → retry.mjs} +3 -3
  345. package/dist/utils/retry.mjs.map +1 -0
  346. package/dist/utils/revert-reason.cjs +192 -0
  347. package/dist/utils/revert-reason.cjs.map +1 -0
  348. package/dist/utils/{revert-reason.d.ts → revert-reason.d.cts} +5 -5
  349. package/dist/utils/revert-reason.d.cts.map +1 -0
  350. package/dist/utils/revert-reason.d.mts +57 -0
  351. package/dist/utils/revert-reason.d.mts.map +1 -0
  352. package/dist/utils/{revert-reason.js → revert-reason.mjs} +4 -4
  353. package/dist/utils/revert-reason.mjs.map +1 -0
  354. package/dist/utils/signature.cjs +26 -0
  355. package/dist/utils/signature.cjs.map +1 -0
  356. package/dist/utils/{signature.d.ts → signature.d.cts} +2 -2
  357. package/dist/utils/signature.d.cts.map +1 -0
  358. package/dist/utils/signature.d.mts +11 -0
  359. package/dist/utils/signature.d.mts.map +1 -0
  360. package/dist/utils/{signature.js → signature.mjs} +3 -3
  361. package/dist/utils/signature.mjs.map +1 -0
  362. package/dist/utils/swaps.cjs +332 -0
  363. package/dist/utils/swaps.cjs.map +1 -0
  364. package/dist/utils/{swaps.d.ts → swaps.d.cts} +5 -5
  365. package/dist/utils/swaps.d.cts.map +1 -0
  366. package/dist/utils/swaps.d.mts +90 -0
  367. package/dist/utils/swaps.d.mts.map +1 -0
  368. package/dist/utils/{swaps.js → swaps.mjs} +8 -7
  369. package/dist/utils/swaps.mjs.map +1 -0
  370. package/dist/utils/transaction-type.cjs +159 -0
  371. package/dist/utils/transaction-type.cjs.map +1 -0
  372. package/dist/utils/{transaction-type.d.ts → transaction-type.d.cts} +6 -6
  373. package/dist/utils/transaction-type.d.cts.map +1 -0
  374. package/dist/utils/transaction-type.d.mts +44 -0
  375. package/dist/utils/transaction-type.d.mts.map +1 -0
  376. package/dist/utils/{transaction-type.js → transaction-type.mjs} +6 -6
  377. package/dist/utils/transaction-type.mjs.map +1 -0
  378. package/dist/utils/utils.cjs +287 -0
  379. package/dist/utils/utils.cjs.map +1 -0
  380. package/dist/utils/{utils.d.ts → utils.d.cts} +4 -4
  381. package/dist/utils/utils.d.cts.map +1 -0
  382. package/dist/utils/utils.d.mts +101 -0
  383. package/dist/utils/utils.d.mts.map +1 -0
  384. package/dist/utils/{utils.js → utils.mjs} +12 -5
  385. package/dist/utils/utils.mjs.map +1 -0
  386. package/dist/utils/validation.cjs +389 -0
  387. package/dist/utils/validation.cjs.map +1 -0
  388. package/dist/utils/{validation.d.ts → validation.d.cts} +4 -4
  389. package/dist/utils/validation.d.cts.map +1 -0
  390. package/dist/utils/validation.d.mts +66 -0
  391. package/dist/utils/validation.d.mts.map +1 -0
  392. package/dist/utils/{validation.js → validation.mjs} +8 -8
  393. package/dist/utils/validation.mjs.map +1 -0
  394. package/package.json +19 -15
  395. package/dist/TransactionController-method-action-types.d.ts.map +0 -1
  396. package/dist/TransactionController-method-action-types.js.map +0 -1
  397. package/dist/TransactionController.d.ts.map +0 -1
  398. package/dist/TransactionController.js.map +0 -1
  399. package/dist/api/accounts-api.d.ts.map +0 -1
  400. package/dist/api/accounts-api.js.map +0 -1
  401. package/dist/api/simulation-api.d.ts.map +0 -1
  402. package/dist/api/simulation-api.js.map +0 -1
  403. package/dist/constants.d.ts.map +0 -1
  404. package/dist/constants.js.map +0 -1
  405. package/dist/errors.d.ts.map +0 -1
  406. package/dist/errors.js.map +0 -1
  407. package/dist/gas-flows/DefaultGasFeeFlow.d.ts.map +0 -1
  408. package/dist/gas-flows/LineaGasFeeFlow.d.ts.map +0 -1
  409. package/dist/gas-flows/LineaGasFeeFlow.js.map +0 -1
  410. package/dist/gas-flows/MantleLayer1GasFeeFlow.d.ts.map +0 -1
  411. package/dist/gas-flows/MantleLayer1GasFeeFlow.js.map +0 -1
  412. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +0 -1
  413. package/dist/gas-flows/OptimismLayer1GasFeeFlow.js.map +0 -1
  414. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.ts.map +0 -1
  415. package/dist/gas-flows/OracleLayer1GasFeeFlow.js.map +0 -1
  416. package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.ts.map +0 -1
  417. package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.js.map +0 -1
  418. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.ts.map +0 -1
  419. package/dist/gas-flows/ScrollLayer1GasFeeFlow.js.map +0 -1
  420. package/dist/gas-flows/TestGasFeeFlow.d.ts.map +0 -1
  421. package/dist/gas-flows/TestGasFeeFlow.js.map +0 -1
  422. package/dist/helpers/GasFeePoller.d.ts.map +0 -1
  423. package/dist/helpers/GasFeePoller.js.map +0 -1
  424. package/dist/helpers/MethodDataHelper.d.ts.map +0 -1
  425. package/dist/helpers/MethodDataHelper.js.map +0 -1
  426. package/dist/helpers/MultichainTrackingHelper.d.ts.map +0 -1
  427. package/dist/helpers/MultichainTrackingHelper.js.map +0 -1
  428. package/dist/helpers/PendingTransactionTracker.d.ts.map +0 -1
  429. package/dist/helpers/PendingTransactionTracker.js.map +0 -1
  430. package/dist/helpers/ResimulateHelper.d.ts.map +0 -1
  431. package/dist/helpers/ResimulateHelper.js.map +0 -1
  432. package/dist/helpers/TransactionPoller.d.ts.map +0 -1
  433. package/dist/helpers/TransactionPoller.js.map +0 -1
  434. package/dist/hooks/CollectPublishHook.d.ts.map +0 -1
  435. package/dist/hooks/CollectPublishHook.js.map +0 -1
  436. package/dist/hooks/ExtraTransactionsPublishHook.d.ts.map +0 -1
  437. package/dist/hooks/ExtraTransactionsPublishHook.js.map +0 -1
  438. package/dist/hooks/SequentialPublishBatchHook.d.ts.map +0 -1
  439. package/dist/hooks/SequentialPublishBatchHook.js.map +0 -1
  440. package/dist/index.d.ts.map +0 -1
  441. package/dist/index.js +0 -12
  442. package/dist/index.js.map +0 -1
  443. package/dist/logger.d.ts.map +0 -1
  444. package/dist/logger.js.map +0 -1
  445. package/dist/types.d.ts.map +0 -1
  446. package/dist/types.js.map +0 -1
  447. package/dist/utils/balance-changes.d.ts.map +0 -1
  448. package/dist/utils/balance-changes.js.map +0 -1
  449. package/dist/utils/balance.d.ts.map +0 -1
  450. package/dist/utils/balance.js.map +0 -1
  451. package/dist/utils/batch.d.ts.map +0 -1
  452. package/dist/utils/batch.js.map +0 -1
  453. package/dist/utils/eip7702.d.ts.map +0 -1
  454. package/dist/utils/eip7702.js.map +0 -1
  455. package/dist/utils/external-transactions.d.ts.map +0 -1
  456. package/dist/utils/external-transactions.js.map +0 -1
  457. package/dist/utils/feature-flags.d.ts.map +0 -1
  458. package/dist/utils/feature-flags.js.map +0 -1
  459. package/dist/utils/first-time-interaction.d.ts.map +0 -1
  460. package/dist/utils/first-time-interaction.js.map +0 -1
  461. package/dist/utils/gas-fee-tokens.d.ts.map +0 -1
  462. package/dist/utils/gas-fee-tokens.js.map +0 -1
  463. package/dist/utils/gas-fees.d.ts.map +0 -1
  464. package/dist/utils/gas-fees.js.map +0 -1
  465. package/dist/utils/gas-flow.d.ts.map +0 -1
  466. package/dist/utils/gas-flow.js.map +0 -1
  467. package/dist/utils/gas.d.ts.map +0 -1
  468. package/dist/utils/gas.js.map +0 -1
  469. package/dist/utils/layer1-gas-fee-flow.d.ts.map +0 -1
  470. package/dist/utils/layer1-gas-fee-flow.js.map +0 -1
  471. package/dist/utils/nonce.d.ts.map +0 -1
  472. package/dist/utils/nonce.js.map +0 -1
  473. package/dist/utils/prepare.d.ts.map +0 -1
  474. package/dist/utils/prepare.js.map +0 -1
  475. package/dist/utils/provider.d.ts.map +0 -1
  476. package/dist/utils/provider.js.map +0 -1
  477. package/dist/utils/recipient.d.ts.map +0 -1
  478. package/dist/utils/recipient.js.map +0 -1
  479. package/dist/utils/retry.d.ts.map +0 -1
  480. package/dist/utils/retry.js.map +0 -1
  481. package/dist/utils/revert-reason.d.ts.map +0 -1
  482. package/dist/utils/revert-reason.js.map +0 -1
  483. package/dist/utils/signature.d.ts.map +0 -1
  484. package/dist/utils/signature.js.map +0 -1
  485. package/dist/utils/swaps.d.ts.map +0 -1
  486. package/dist/utils/swaps.js.map +0 -1
  487. package/dist/utils/transaction-type.d.ts.map +0 -1
  488. package/dist/utils/transaction-type.js.map +0 -1
  489. package/dist/utils/utils.d.ts.map +0 -1
  490. package/dist/utils/utils.js.map +0 -1
  491. package/dist/utils/validation.d.ts.map +0 -1
  492. package/dist/utils/validation.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas-fees.mjs","sourceRoot":"","sources":["../../src/utils/gas-fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,mCAAmC;AAMnE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,wBAAwB;AAE5D,OAAO,EAAE,aAAa,EAAE,sBAAqB;AAS7C,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACb,qBAAoB;AACrB,OAAO,EACL,uCAAuC,EACvC,wCAAwC,EACzC,4BAA2B;AAC5B,OAAO,EAAE,aAAa,EAAE,uBAAsB;AAC9C,OAAO,EAAE,UAAU,EAAE,uBAAsB;AAC3C,OAAO,EAAE,sBAAsB,EAAE,oBAAmB;AAqCpD,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;AAE1D,MAAM,wCAAwC,GAAG;IAC/C,GAAG,sBAAsB;IACzB,eAAe,CAAC,MAAM;IACtB,eAAe,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import { gweiDecToWEIBN, toHex } from '@metamask/controller-utils';\nimport type {\n FetchGasFeeEstimateOptions,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { add0x, createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type {\n FeeMarketGasFeeEstimateForLevel,\n SavedGasFees,\n TransactionParams,\n TransactionMeta,\n GasFeeFlow,\n} from '../types.js';\nimport {\n GasFeeEstimateLevel,\n GasFeeEstimateType,\n TransactionType,\n UserFeeLevel,\n} from '../types.js';\nimport {\n getReplaceUnderpricedDappGasFeesEnabled,\n getReplaceUnderpricedSavedGasFeesEnabled,\n} from './feature-flags.js';\nimport { getGasFeeFlow } from './gas-flow.js';\nimport { rpcRequest } from './provider.js';\nimport { SWAP_TRANSACTION_TYPES } from './swaps.js';\n\nexport type UpdateGasFeesRequest = {\n eip1559: boolean;\n gasFeeFlows: GasFeeFlow[];\n getGasFeeEstimates: (\n options: FetchGasFeeEstimateOptions,\n ) => Promise<GasFeeState>;\n getSavedGasFees: (\n transactionMeta: TransactionMeta,\n ) => SavedGasFees | undefined;\n messenger: TransactionControllerMessenger;\n txMeta: TransactionMeta;\n};\n\nexport type GetGasFeeRequest = UpdateGasFeesRequest & {\n initialParams: TransactionParams;\n savedGasFees?: SavedGasFees;\n suggestedGasFees: SuggestedGasFees;\n};\n\ntype SuggestedGasFees = {\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n gasPrice?: string;\n\n /**\n * Whether the suggested fee was derived from a specific estimate level,\n * such as `low`/`medium`/`high`. This is `false` for estimate types that\n * do not support per-level pricing, such as a flat `eth_gasPrice` value,\n * or when the gas fee flow failed and a raw RPC fallback was used.\n */\n isEstimateLevelApplied?: boolean;\n\n low?: FeeMarketGasFeeEstimateForLevel;\n};\n\nconst log = createModuleLogger(projectLogger, 'gas-fees');\n\nconst SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES = [\n ...SWAP_TRANSACTION_TYPES,\n TransactionType.bridge,\n TransactionType.bridgeApproval,\n];\n\n/**\n * Update the gas fee properties of the provided transaction meta.\n *\n * @param request - The request object.\n */\nexport async function updateGasFees(\n request: UpdateGasFeesRequest,\n): Promise<void> {\n const { txMeta } = request;\n const initialParams = { ...txMeta.txParams };\n\n const shouldIgnoreSavedGasFees =\n SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES.includes(\n txMeta.type as TransactionType,\n );\n\n let savedGasFees =\n shouldIgnoreSavedGasFees || hasInitialGasFeeParams(initialParams)\n ? undefined\n : request.getSavedGasFees(txMeta);\n\n const suggestedGasFees = await getSuggestedGasFees({\n ...request,\n savedGasFees,\n });\n\n log('Suggested gas fees', suggestedGasFees);\n\n if (\n shouldIgnoreUnderpricedSavedGasFees(savedGasFees, suggestedGasFees, request)\n ) {\n log(\n 'Ignoring saved custom gas fees below low estimate',\n savedGasFees?.maxBaseFee,\n suggestedGasFees.low?.maxFeePerGas,\n );\n savedGasFees = undefined;\n }\n\n const getGasFeeRequest: GetGasFeeRequest = {\n ...request,\n initialParams,\n savedGasFees,\n suggestedGasFees,\n };\n\n txMeta.txParams.maxFeePerGas = getMaxFeePerGas(getGasFeeRequest);\n\n txMeta.txParams.maxPriorityFeePerGas =\n getMaxPriorityFeePerGas(getGasFeeRequest);\n\n txMeta.txParams.gasPrice = getGasPrice(getGasFeeRequest);\n txMeta.userFeeLevel = getUserFeeLevel(getGasFeeRequest);\n\n log('Updated gas fee properties', {\n maxFeePerGas: txMeta.txParams.maxFeePerGas,\n maxPriorityFeePerGas: txMeta.txParams.maxPriorityFeePerGas,\n gasPrice: txMeta.txParams.gasPrice,\n });\n\n if (txMeta.txParams.maxFeePerGas || txMeta.txParams.maxPriorityFeePerGas) {\n delete txMeta.txParams.gasPrice;\n }\n\n if (txMeta.txParams.gasPrice) {\n delete txMeta.txParams.maxFeePerGas;\n delete txMeta.txParams.maxPriorityFeePerGas;\n }\n\n updateDefaultGasEstimates(txMeta);\n}\n\n/**\n * Convert GWEI from decimal string to WEI as hex string.\n *\n * @param value - The GWEI value as a decimal string.\n * @returns The WEI value in hex.\n */\nexport function gweiDecimalToWeiHex(value: string): Hex {\n return toHex(gweiDecToWEIBN(value));\n}\n\n/**\n * Converts a value from Gwei decimal representation to Wei decimal representation\n *\n * @param gweiDecimal - The value in Gwei as a string or number\n * @returns The value in Wei as a string\n *\n * @example\n * // Convert 1.5 Gwei to Wei\n * gweiDecimalToWeiDecimal(\"1.5\")\n * // Returns \"1500000000\"\n */\nexport function gweiDecimalToWeiDecimal(gweiDecimal: string | number): string {\n const weiValue = Number(gweiDecimal) * 1e9;\n\n return weiValue.toString().split('.')[0];\n}\n\n/**\n * Determine whether saved (advanced) gas fee preferences should be ignored in\n * favour of the suggested gas fees, as the saved custom `maxBaseFee` is below\n * the current low estimate and hence unlikely to result in timely inclusion in\n * a block. Level-based saved preferences track current estimates and are never\n * ignored.\n *\n * @param savedGasFees - The saved gas fee preferences.\n * @param suggestedGasFees - The suggested gas fees.\n * @param request - The request object.\n * @returns Whether the saved gas fee preferences should be ignored.\n */\nfunction shouldIgnoreUnderpricedSavedGasFees(\n savedGasFees: SavedGasFees | undefined,\n suggestedGasFees: SuggestedGasFees,\n request: UpdateGasFeesRequest,\n): boolean {\n const { eip1559, messenger, txMeta } = request;\n\n if (\n !eip1559 ||\n !savedGasFees?.maxBaseFee ||\n !getReplaceUnderpricedSavedGasFeesEnabled(txMeta.chainId, messenger)\n ) {\n return false;\n }\n\n const lowMaxFeePerGas = suggestedGasFees.low?.maxFeePerGas;\n\n const hasReplacement =\n Boolean(suggestedGasFees.maxFeePerGas) &&\n Boolean(suggestedGasFees.maxPriorityFeePerGas);\n\n if (!lowMaxFeePerGas || !hasReplacement) {\n return false;\n }\n\n return isFeeBelowLowEstimate(\n gweiDecimalToWeiHex(savedGasFees.maxBaseFee),\n lowMaxFeePerGas,\n );\n}\n\n/**\n * Determine whether a fee value is below the low estimate.\n *\n * @param valueHex - The fee value as a hex string.\n * @param lowMaxFeePerGasHex - The low estimate `maxFeePerGas` as a hex string.\n * @returns Whether the fee value is below the low estimate.\n */\nfunction isFeeBelowLowEstimate(\n valueHex: string,\n lowMaxFeePerGasHex: string,\n): boolean {\n try {\n return BigInt(valueHex) < BigInt(lowMaxFeePerGasHex);\n } catch {\n return false;\n }\n}\n\n/**\n * Determine whether dapp-suggested gas fees should be ignored in favour of the\n * suggested gas fees, as the dapp-suggested `maxFeePerGas` is below the current\n * low estimate and hence unlikely to result in timely inclusion in a block.\n *\n * @param request - The request object.\n * @returns Whether the dapp-suggested gas fees should be ignored.\n */\nfunction shouldIgnoreDappGasFees(request: GetGasFeeRequest): boolean {\n const {\n eip1559,\n initialParams,\n messenger,\n savedGasFees,\n suggestedGasFees,\n txMeta,\n } = request;\n\n if (\n !eip1559 ||\n savedGasFees ||\n txMeta.isInternal ||\n !getReplaceUnderpricedDappGasFeesEnabled(txMeta.chainId, messenger)\n ) {\n return false;\n }\n\n const dappMaxFeePerGas =\n initialParams.maxFeePerGas ??\n (initialParams.gasPrice && !initialParams.maxPriorityFeePerGas\n ? initialParams.gasPrice\n : undefined);\n\n const lowMaxFeePerGas = suggestedGasFees.low?.maxFeePerGas;\n\n const hasReplacement =\n Boolean(suggestedGasFees.maxFeePerGas) &&\n Boolean(suggestedGasFees.maxPriorityFeePerGas);\n\n if (!dappMaxFeePerGas || !lowMaxFeePerGas || !hasReplacement) {\n return false;\n }\n\n return isFeeBelowLowEstimate(dappMaxFeePerGas, lowMaxFeePerGas);\n}\n\n/**\n * Determine the maxFeePerGas value for the transaction.\n *\n * @param request - The request object.\n * @returns The maxFeePerGas value.\n */\nfunction getMaxFeePerGas(request: GetGasFeeRequest): string | undefined {\n const { savedGasFees, eip1559, initialParams, suggestedGasFees } = request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees?.maxBaseFee) {\n const maxFeePerGas = gweiDecimalToWeiHex(savedGasFees.maxBaseFee);\n log('Using maxFeePerGas from savedGasFees', maxFeePerGas);\n return maxFeePerGas;\n }\n\n const ignoreDappGasFees = shouldIgnoreDappGasFees(request);\n\n if (initialParams.maxFeePerGas && !ignoreDappGasFees) {\n log('Using maxFeePerGas from request', initialParams.maxFeePerGas);\n return initialParams.maxFeePerGas;\n }\n\n if (\n initialParams.gasPrice &&\n !initialParams.maxPriorityFeePerGas &&\n !ignoreDappGasFees\n ) {\n log(\n 'Setting maxFeePerGas to gasPrice from request',\n initialParams.gasPrice,\n );\n return initialParams.gasPrice;\n }\n\n if (ignoreDappGasFees) {\n log(\n 'Ignoring dapp-suggested maxFeePerGas below low estimate',\n initialParams.maxFeePerGas ?? initialParams.gasPrice,\n suggestedGasFees.low?.maxFeePerGas,\n );\n }\n\n if (suggestedGasFees.maxFeePerGas) {\n log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas);\n return suggestedGasFees.maxFeePerGas;\n }\n\n if (suggestedGasFees.gasPrice) {\n log(\n 'Setting maxFeePerGas to suggested gasPrice',\n suggestedGasFees.gasPrice,\n );\n return suggestedGasFees.gasPrice;\n }\n\n log('maxFeePerGas not set');\n return undefined;\n}\n\n/**\n * Determine the maxPriorityFeePerGas value for the transaction.\n *\n * @param request - The request object.\n * @returns The maxPriorityFeePerGas value.\n */\nfunction getMaxPriorityFeePerGas(\n request: GetGasFeeRequest,\n): string | undefined {\n const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } =\n request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees?.priorityFee) {\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(savedGasFees.priorityFee);\n log(\n 'Using maxPriorityFeePerGas from savedGasFees.priorityFee',\n maxPriorityFeePerGas,\n );\n return maxPriorityFeePerGas;\n }\n\n const ignoreDappGasFees = shouldIgnoreDappGasFees(request);\n\n if (initialParams.maxPriorityFeePerGas && !ignoreDappGasFees) {\n log(\n 'Using maxPriorityFeePerGas from request',\n initialParams.maxPriorityFeePerGas,\n );\n return initialParams.maxPriorityFeePerGas;\n }\n\n if (\n initialParams.gasPrice &&\n !initialParams.maxFeePerGas &&\n !ignoreDappGasFees\n ) {\n log(\n 'Setting maxPriorityFeePerGas to gasPrice from request',\n initialParams.gasPrice,\n );\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxPriorityFeePerGas) {\n log(\n 'Using suggested maxPriorityFeePerGas',\n suggestedGasFees.maxPriorityFeePerGas,\n );\n return suggestedGasFees.maxPriorityFeePerGas;\n }\n\n if (txMeta.txParams.maxFeePerGas) {\n log(\n 'Setting maxPriorityFeePerGas to maxFeePerGas',\n txMeta.txParams.maxFeePerGas,\n );\n return txMeta.txParams.maxFeePerGas;\n }\n\n log('maxPriorityFeePerGas not set');\n return undefined;\n}\n\n/**\n * Determine the gasPrice value for the transaction.\n *\n * @param request - The request object.\n * @returns The gasPrice value.\n */\nfunction getGasPrice(request: GetGasFeeRequest): string | undefined {\n const { eip1559, initialParams, savedGasFees, suggestedGasFees } = request;\n\n if (eip1559) {\n return undefined;\n }\n\n if (savedGasFees?.gasPrice) {\n const gasPrice = gweiDecimalToWeiHex(savedGasFees.gasPrice);\n log('Using gasPrice from savedGasFees.gasPrice', gasPrice);\n return gasPrice;\n }\n\n if (initialParams.gasPrice) {\n log('Using gasPrice from request', initialParams.gasPrice);\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxFeePerGas) {\n log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas);\n return suggestedGasFees.maxFeePerGas;\n }\n\n if (suggestedGasFees.gasPrice) {\n log('Using suggested gasPrice', suggestedGasFees.gasPrice);\n return suggestedGasFees.gasPrice;\n }\n\n log('gasPrice not set');\n return undefined;\n}\n\n/**\n * Determine the user fee level.\n *\n * @param request - The request object.\n * @returns The user fee level.\n */\nfunction getUserFeeLevel(request: GetGasFeeRequest): string | undefined {\n const { initialParams, savedGasFees, suggestedGasFees, txMeta } = request;\n\n if (savedGasFees) {\n const hasCustomOverride =\n savedGasFees.maxBaseFee !== undefined ||\n savedGasFees.priorityFee !== undefined ||\n savedGasFees.gasPrice !== undefined;\n\n const canUseSavedLevel =\n !hasCustomOverride &&\n savedGasFees.level !== undefined &&\n suggestedGasFees.isEstimateLevelApplied;\n\n // A custom override on any field, or an estimate type that does not\n // support per-level pricing (e.g. a flat eth_gasPrice value), means the\n // fee is no longer purely level-derived, so it must not be tracked as a\n // live estimate level by the gas fee poller, which would otherwise\n // overwrite the override or misrepresent the fee as matching the level.\n return canUseSavedLevel ? savedGasFees.level : UserFeeLevel.CUSTOM;\n }\n\n // Underpriced dapp-suggested fees are replaced with the suggested medium\n // values, so also use the medium fee level to keep the values updated while\n // the transaction is unapproved.\n if (shouldIgnoreDappGasFees(request)) {\n return UserFeeLevel.MEDIUM;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n initialParams.gasPrice\n ) {\n return txMeta.isInternal\n ? UserFeeLevel.CUSTOM\n : UserFeeLevel.DAPP_SUGGESTED;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n suggestedGasFees.maxFeePerGas &&\n suggestedGasFees.maxPriorityFeePerGas\n ) {\n return UserFeeLevel.MEDIUM;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n suggestedGasFees.gasPrice\n ) {\n return UserFeeLevel.MEDIUM;\n }\n\n if (txMeta.isInternal) {\n return UserFeeLevel.MEDIUM;\n }\n\n return UserFeeLevel.DAPP_SUGGESTED;\n}\n\n/**\n * Update the default gas estimates for the provided transaction.\n *\n * @param txMeta - The transaction metadata.\n */\nfunction updateDefaultGasEstimates(txMeta: TransactionMeta): void {\n txMeta.defaultGasEstimates ??= {};\n txMeta.defaultGasEstimates.maxFeePerGas = txMeta.txParams.maxFeePerGas;\n\n txMeta.defaultGasEstimates.maxPriorityFeePerGas =\n txMeta.txParams.maxPriorityFeePerGas;\n\n txMeta.defaultGasEstimates.gasPrice = txMeta.txParams.gasPrice;\n txMeta.defaultGasEstimates.estimateType = txMeta.userFeeLevel;\n}\n\n/**\n * Retrieve the suggested gas fees using the gas fee flows.\n *\n * @param request - The request object.\n * @returns The suggested gas fees.\n */\nasync function getSuggestedGasFees(\n request: UpdateGasFeesRequest & { savedGasFees?: SavedGasFees },\n): Promise<SuggestedGasFees> {\n const {\n eip1559,\n gasFeeFlows,\n getGasFeeEstimates,\n messenger,\n savedGasFees,\n txMeta,\n } = request;\n const { networkClientId } = txMeta;\n\n const hasCompleteDappFees =\n eip1559 &&\n Boolean(txMeta.txParams.maxFeePerGas) &&\n Boolean(txMeta.txParams.maxPriorityFeePerGas);\n\n // Estimates are still required for transactions with complete dapp-suggested\n // fees if they may be replaced due to being underpriced.\n const isEstimateRequiredForDappFees =\n hasCompleteDappFees &&\n !txMeta.isInternal &&\n getReplaceUnderpricedDappGasFeesEnabled(txMeta.chainId, messenger);\n\n if (\n (!eip1559 && txMeta.txParams.gasPrice) ||\n (hasCompleteDappFees && !isEstimateRequiredForDappFees)\n ) {\n return {};\n }\n\n const gasFeeFlow = getGasFeeFlow(\n txMeta,\n gasFeeFlows,\n messenger,\n ) as GasFeeFlow;\n\n try {\n const gasFeeControllerData = await getGasFeeEstimates({ networkClientId });\n\n const response = await gasFeeFlow.getGasFees({\n gasFeeControllerData,\n messenger,\n transactionMeta: txMeta,\n });\n\n const gasFeeEstimateType = response.estimates?.type;\n const savedGasFeeEstimateLevel = getSavedGasFeeEstimateLevel(savedGasFees);\n\n switch (gasFeeEstimateType) {\n case GasFeeEstimateType.FeeMarket:\n return {\n ...(response.estimates[savedGasFeeEstimateLevel] ??\n response.estimates.medium),\n isEstimateLevelApplied: true,\n low: response.estimates.low,\n };\n case GasFeeEstimateType.Legacy:\n return {\n gasPrice:\n response.estimates[savedGasFeeEstimateLevel] ??\n response.estimates.medium,\n isEstimateLevelApplied: true,\n };\n case GasFeeEstimateType.GasPrice:\n return {\n gasPrice: response.estimates.gasPrice,\n isEstimateLevelApplied: false,\n };\n default:\n throw new Error(\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Unsupported gas fee estimate type returned from flow: ${gasFeeEstimateType}`,\n );\n }\n } catch (error) {\n log('Failed to get suggested gas fees', error);\n }\n\n // Estimates on this path are only needed to check complete dapp-suggested\n // fees, so no fallback is required and any failure must not block\n // transaction creation.\n if (hasCompleteDappFees) {\n return {};\n }\n\n const gasPriceHex = (await rpcRequest({\n messenger,\n networkClientId,\n method: 'eth_gasPrice',\n })) as Hex | undefined;\n\n const gasPrice = gasPriceHex ? add0x(gasPriceHex) : undefined;\n\n return { gasPrice };\n}\n\nfunction hasInitialGasFeeParams(initialParams: TransactionParams): boolean {\n return [\n initialParams.maxFeePerGas,\n initialParams.maxPriorityFeePerGas,\n initialParams.gasPrice,\n ].some(Boolean);\n}\n\nfunction getSavedGasFeeEstimateLevel(\n savedGasFees: SavedGasFees | undefined,\n): GasFeeEstimateLevel {\n return isGasFeeEstimateLevel(savedGasFees?.level)\n ? savedGasFees.level\n : GasFeeEstimateLevel.Medium;\n}\n\nfunction isGasFeeEstimateLevel(level: unknown): level is GasFeeEstimateLevel {\n return Object.values(GasFeeEstimateLevel).includes(\n level as GasFeeEstimateLevel,\n );\n}\n"]}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeGasFeeEstimates = exports.getGasFeeFlow = void 0;
4
+ const controller_utils_1 = require("@metamask/controller-utils");
5
+ const types_js_1 = require("../types.cjs");
6
+ /**
7
+ * Returns the first gas fee flow that matches the transaction.
8
+ *
9
+ * @param transactionMeta - The transaction metadata to find a gas fee flow for.
10
+ * @param gasFeeFlows - The gas fee flows to search.
11
+ * @param messenger - The messenger instance.
12
+ * @returns The first gas fee flow that matches the transaction, or undefined if none match.
13
+ */
14
+ function getGasFeeFlow(transactionMeta, gasFeeFlows, messenger) {
15
+ return gasFeeFlows.find((gasFeeFlow) => gasFeeFlow.matchesTransaction({ transactionMeta, messenger }));
16
+ }
17
+ exports.getGasFeeFlow = getGasFeeFlow;
18
+ /**
19
+ * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction.
20
+ *
21
+ * @param request - Data required to merge gas fee estimates.
22
+ * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController.
23
+ * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction.
24
+ * @returns The merged gas fee estimates.
25
+ */
26
+ function mergeGasFeeEstimates({ gasFeeControllerEstimates, transactionGasFeeEstimates, }) {
27
+ const transactionEstimateType = transactionGasFeeEstimates.type;
28
+ if (transactionEstimateType === types_js_1.GasFeeEstimateType.FeeMarket) {
29
+ return Object.values(types_js_1.GasFeeEstimateLevel).reduce((result, level) => ({
30
+ ...result,
31
+ [level]: mergeFeeMarketEstimate(gasFeeControllerEstimates?.[level], transactionGasFeeEstimates[level]),
32
+ }), { ...gasFeeControllerEstimates });
33
+ }
34
+ if (transactionEstimateType === types_js_1.GasFeeEstimateType.Legacy) {
35
+ return Object.values(types_js_1.GasFeeEstimateLevel).reduce((result, level) => ({
36
+ ...result,
37
+ [level]: getLegacyEstimate(transactionGasFeeEstimates, level),
38
+ }), {});
39
+ }
40
+ if (transactionEstimateType === types_js_1.GasFeeEstimateType.GasPrice) {
41
+ return {
42
+ gasPrice: getGasPriceEstimate(transactionGasFeeEstimates),
43
+ };
44
+ }
45
+ return gasFeeControllerEstimates;
46
+ }
47
+ exports.mergeGasFeeEstimates = mergeGasFeeEstimates;
48
+ /**
49
+ * Merge a specific priority level of EIP-1559 gas fee estimates.
50
+ *
51
+ * @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller.
52
+ * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.
53
+ * @returns The merged gas fee estimate.
54
+ */
55
+ function mergeFeeMarketEstimate(gasFeeControllerEstimate, transactionGasFeeEstimate) {
56
+ return {
57
+ ...gasFeeControllerEstimate,
58
+ suggestedMaxFeePerGas: (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxFeePerGas),
59
+ suggestedMaxPriorityFeePerGas: (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxPriorityFeePerGas),
60
+ };
61
+ }
62
+ /**
63
+ * Generate a specific priority level for a legacy gas fee estimate.
64
+ *
65
+ * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.
66
+ * @param level - The gas fee estimate level.
67
+ * @returns The legacy gas fee estimate.
68
+ */
69
+ function getLegacyEstimate(transactionGasFeeEstimate, level) {
70
+ return (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate[level]);
71
+ }
72
+ /**
73
+ * Generate the value for a gas price gas fee estimate.
74
+ *
75
+ * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.
76
+ * @returns The legacy gas fee estimate.
77
+ */
78
+ function getGasPriceEstimate(transactionGasFeeEstimate) {
79
+ return (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.gasPrice);
80
+ }
81
+ //# sourceMappingURL=gas-flow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas-flow.cjs","sourceRoot":"","sources":["../../src/utils/gas-flow.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAU7D,2CAAsE;AAuBtE;;;;;;;GAOG;AACH,SAAgB,aAAa,CAC3B,eAAgC,EAChC,WAAyB,EACzB,SAAyC;IAEzC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACrC,UAAU,CAAC,kBAAkB,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAC9D,CAAC;AACJ,CAAC;AARD,sCAQC;AAED;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAAC,EACnC,yBAAyB,EACzB,0BAA0B,GACE;IAC5B,MAAM,uBAAuB,GAAG,0BAA0B,CAAC,IAAI,CAAC;IAEhE,IAAI,uBAAuB,KAAK,6BAAkB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CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB,CAC1B,yBAAkD;IAElD,OAAO,IAAA,kCAAe,EAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { weiHexToGweiDec } from '@metamask/controller-utils';\nimport type {\n Eip1559GasFee,\n EthGasPriceEstimate,\n GasFeeEstimates,\n LegacyGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\n\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types.js';\nimport type {\n FeeMarketGasFeeEstimates,\n GasPriceGasFeeEstimates,\n LegacyGasFeeEstimates,\n} from '../types.js';\nimport type {\n GasFeeFlow,\n TransactionMeta,\n FeeMarketGasFeeEstimateForLevel,\n} from '../types.js';\n\ntype MergeGasFeeEstimatesRequest = {\n gasFeeControllerEstimates:\n | GasFeeEstimates\n | LegacyGasPriceEstimate\n | EthGasPriceEstimate;\n transactionGasFeeEstimates:\n | FeeMarketGasFeeEstimates\n | LegacyGasFeeEstimates\n | GasPriceGasFeeEstimates;\n};\n\n/**\n * Returns the first gas fee flow that matches the transaction.\n *\n * @param transactionMeta - The transaction metadata to find a gas fee flow for.\n * @param gasFeeFlows - The gas fee flows to search.\n * @param messenger - The messenger instance.\n * @returns The first gas fee flow that matches the transaction, or undefined if none match.\n */\nexport function getGasFeeFlow(\n transactionMeta: TransactionMeta,\n gasFeeFlows: GasFeeFlow[],\n messenger: TransactionControllerMessenger,\n): GasFeeFlow | undefined {\n return gasFeeFlows.find((gasFeeFlow) =>\n gasFeeFlow.matchesTransaction({ transactionMeta, messenger }),\n );\n}\n\n/**\n * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction.\n *\n * @param request - Data required to merge gas fee estimates.\n * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController.\n * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction.\n * @returns The merged gas fee estimates.\n */\nexport function mergeGasFeeEstimates({\n gasFeeControllerEstimates,\n transactionGasFeeEstimates,\n}: MergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates'] {\n const transactionEstimateType = transactionGasFeeEstimates.type;\n\n if (transactionEstimateType === GasFeeEstimateType.FeeMarket) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: mergeFeeMarketEstimate(\n (gasFeeControllerEstimates as GasFeeEstimates)?.[level],\n transactionGasFeeEstimates[level],\n ),\n }),\n { ...gasFeeControllerEstimates } as GasFeeEstimates,\n );\n }\n\n if (transactionEstimateType === GasFeeEstimateType.Legacy) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: getLegacyEstimate(transactionGasFeeEstimates, level),\n }),\n {} as LegacyGasPriceEstimate,\n );\n }\n\n if (transactionEstimateType === GasFeeEstimateType.GasPrice) {\n return {\n gasPrice: getGasPriceEstimate(transactionGasFeeEstimates),\n };\n }\n\n return gasFeeControllerEstimates;\n}\n\n/**\n * Merge a specific priority level of EIP-1559 gas fee estimates.\n *\n * @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller.\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The merged gas fee estimate.\n */\nfunction mergeFeeMarketEstimate(\n gasFeeControllerEstimate: Eip1559GasFee | undefined,\n transactionGasFeeEstimate: FeeMarketGasFeeEstimateForLevel,\n): Eip1559GasFee {\n return {\n ...gasFeeControllerEstimate,\n suggestedMaxFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxFeePerGas,\n ),\n suggestedMaxPriorityFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxPriorityFeePerGas,\n ),\n } as Eip1559GasFee;\n}\n\n/**\n * Generate a specific priority level for a legacy gas fee estimate.\n *\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @param level - The gas fee estimate level.\n * @returns The legacy gas fee estimate.\n */\nfunction getLegacyEstimate(\n transactionGasFeeEstimate: LegacyGasFeeEstimates,\n level: GasFeeEstimateLevel,\n): string {\n return weiHexToGweiDec(transactionGasFeeEstimate[level]);\n}\n\n/**\n * Generate the value for a gas price gas fee estimate.\n *\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The legacy gas fee estimate.\n */\nfunction getGasPriceEstimate(\n transactionGasFeeEstimate: GasPriceGasFeeEstimates,\n): string {\n return weiHexToGweiDec(transactionGasFeeEstimate.gasPrice);\n}\n"]}
@@ -1,8 +1,8 @@
1
- import type { EthGasPriceEstimate, GasFeeEstimates, LegacyGasPriceEstimate } from '@metamask/gas-fee-controller';
2
- import type { GasFeeState } from '@metamask/gas-fee-controller';
3
- import type { TransactionControllerMessenger } from '../TransactionController.js';
4
- import type { FeeMarketGasFeeEstimates, GasPriceGasFeeEstimates, LegacyGasFeeEstimates } from '../types.js';
5
- import type { GasFeeFlow, TransactionMeta } from '../types.js';
1
+ import type { EthGasPriceEstimate, GasFeeEstimates, LegacyGasPriceEstimate } from "@metamask/gas-fee-controller";
2
+ import type { GasFeeState } from "@metamask/gas-fee-controller";
3
+ import type { TransactionControllerMessenger } from "../TransactionController.cjs";
4
+ import type { FeeMarketGasFeeEstimates, GasPriceGasFeeEstimates, LegacyGasFeeEstimates } from "../types.cjs";
5
+ import type { GasFeeFlow, TransactionMeta } from "../types.cjs";
6
6
  type MergeGasFeeEstimatesRequest = {
7
7
  gasFeeControllerEstimates: GasFeeEstimates | LegacyGasPriceEstimate | EthGasPriceEstimate;
8
8
  transactionGasFeeEstimates: FeeMarketGasFeeEstimates | LegacyGasFeeEstimates | GasPriceGasFeeEstimates;
@@ -26,4 +26,4 @@ export declare function getGasFeeFlow(transactionMeta: TransactionMeta, gasFeeFl
26
26
  */
27
27
  export declare function mergeGasFeeEstimates({ gasFeeControllerEstimates, transactionGasFeeEstimates, }: MergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates'];
28
28
  export {};
29
- //# sourceMappingURL=gas-flow.d.ts.map
29
+ //# sourceMappingURL=gas-flow.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas-flow.d.cts","sourceRoot":"","sources":["../../src/utils/gas-flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACvB,qCAAqC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,qCAAqC;AAEhE,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAElF,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACtB,qBAAoB;AACrB,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EAEhB,qBAAoB;AAErB,KAAK,2BAA2B,GAAG;IACjC,yBAAyB,EACrB,eAAe,GACf,sBAAsB,GACtB,mBAAmB,CAAC;IACxB,0BAA0B,EACtB,wBAAwB,GACxB,qBAAqB,GACrB,uBAAuB,CAAC;CAC7B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,UAAU,EAAE,EACzB,SAAS,EAAE,8BAA8B,GACxC,UAAU,GAAG,SAAS,CAIxB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,yBAAyB,EACzB,0BAA0B,GAC3B,EAAE,2BAA2B,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAiC9D"}
@@ -0,0 +1,29 @@
1
+ import type { EthGasPriceEstimate, GasFeeEstimates, LegacyGasPriceEstimate } from "@metamask/gas-fee-controller";
2
+ import type { GasFeeState } from "@metamask/gas-fee-controller";
3
+ import type { TransactionControllerMessenger } from "../TransactionController.mjs";
4
+ import type { FeeMarketGasFeeEstimates, GasPriceGasFeeEstimates, LegacyGasFeeEstimates } from "../types.mjs";
5
+ import type { GasFeeFlow, TransactionMeta } from "../types.mjs";
6
+ type MergeGasFeeEstimatesRequest = {
7
+ gasFeeControllerEstimates: GasFeeEstimates | LegacyGasPriceEstimate | EthGasPriceEstimate;
8
+ transactionGasFeeEstimates: FeeMarketGasFeeEstimates | LegacyGasFeeEstimates | GasPriceGasFeeEstimates;
9
+ };
10
+ /**
11
+ * Returns the first gas fee flow that matches the transaction.
12
+ *
13
+ * @param transactionMeta - The transaction metadata to find a gas fee flow for.
14
+ * @param gasFeeFlows - The gas fee flows to search.
15
+ * @param messenger - The messenger instance.
16
+ * @returns The first gas fee flow that matches the transaction, or undefined if none match.
17
+ */
18
+ export declare function getGasFeeFlow(transactionMeta: TransactionMeta, gasFeeFlows: GasFeeFlow[], messenger: TransactionControllerMessenger): GasFeeFlow | undefined;
19
+ /**
20
+ * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction.
21
+ *
22
+ * @param request - Data required to merge gas fee estimates.
23
+ * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController.
24
+ * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction.
25
+ * @returns The merged gas fee estimates.
26
+ */
27
+ export declare function mergeGasFeeEstimates({ gasFeeControllerEstimates, transactionGasFeeEstimates, }: MergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates'];
28
+ export {};
29
+ //# sourceMappingURL=gas-flow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas-flow.d.mts","sourceRoot":"","sources":["../../src/utils/gas-flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACvB,qCAAqC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,qCAAqC;AAEhE,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAElF,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACtB,qBAAoB;AACrB,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EAEhB,qBAAoB;AAErB,KAAK,2BAA2B,GAAG;IACjC,yBAAyB,EACrB,eAAe,GACf,sBAAsB,GACtB,mBAAmB,CAAC;IACxB,0BAA0B,EACtB,wBAAwB,GACxB,qBAAqB,GACrB,uBAAuB,CAAC;CAC7B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,UAAU,EAAE,EACzB,SAAS,EAAE,8BAA8B,GACxC,UAAU,GAAG,SAAS,CAIxB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,yBAAyB,EACzB,0BAA0B,GAC3B,EAAE,2BAA2B,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAiC9D"}
@@ -1,5 +1,5 @@
1
- import { weiHexToGweiDec } from '@metamask/controller-utils';
2
- import { GasFeeEstimateLevel, GasFeeEstimateType } from '../types.js';
1
+ import { weiHexToGweiDec } from "@metamask/controller-utils";
2
+ import { GasFeeEstimateLevel, GasFeeEstimateType } from "../types.mjs";
3
3
  /**
4
4
  * Returns the first gas fee flow that matches the transaction.
5
5
  *
@@ -73,4 +73,4 @@ function getLegacyEstimate(transactionGasFeeEstimate, level) {
73
73
  function getGasPriceEstimate(transactionGasFeeEstimate) {
74
74
  return weiHexToGweiDec(transactionGasFeeEstimate.gasPrice);
75
75
  }
76
- //# sourceMappingURL=gas-flow.js.map
76
+ //# sourceMappingURL=gas-flow.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas-flow.mjs","sourceRoot":"","sources":["../../src/utils/gas-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mCAAmC;AAU7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,qBAAoB;AAuBtE;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,eAAgC,EAChC,WAAyB,EACzB,SAAyC;IAEzC,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACrC,UAAU,CAAC,kBAAkB,CA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CACvC;QACD,6BAA6B,EAAE,eAAe,CAC5C,yBAAyB,CAAC,oBAAoB,CAC/C;KACe,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB,CACxB,yBAAgD,EAChD,KAA0B;IAE1B,OAAO,eAAe,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB,CAC1B,yBAAkD;IAElD,OAAO,eAAe,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { weiHexToGweiDec } from '@metamask/controller-utils';\nimport type {\n Eip1559GasFee,\n EthGasPriceEstimate,\n GasFeeEstimates,\n LegacyGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\n\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types.js';\nimport type {\n FeeMarketGasFeeEstimates,\n GasPriceGasFeeEstimates,\n LegacyGasFeeEstimates,\n} from '../types.js';\nimport type {\n GasFeeFlow,\n TransactionMeta,\n FeeMarketGasFeeEstimateForLevel,\n} from '../types.js';\n\ntype MergeGasFeeEstimatesRequest = {\n gasFeeControllerEstimates:\n | GasFeeEstimates\n | LegacyGasPriceEstimate\n | EthGasPriceEstimate;\n transactionGasFeeEstimates:\n | FeeMarketGasFeeEstimates\n | LegacyGasFeeEstimates\n | GasPriceGasFeeEstimates;\n};\n\n/**\n * Returns the first gas fee flow that matches the transaction.\n *\n * @param transactionMeta - The transaction metadata to find a gas fee flow for.\n * @param gasFeeFlows - The gas fee flows to search.\n * @param messenger - The messenger instance.\n * @returns The first gas fee flow that matches the transaction, or undefined if none match.\n */\nexport function getGasFeeFlow(\n transactionMeta: TransactionMeta,\n gasFeeFlows: GasFeeFlow[],\n messenger: TransactionControllerMessenger,\n): GasFeeFlow | undefined {\n return gasFeeFlows.find((gasFeeFlow) =>\n gasFeeFlow.matchesTransaction({ transactionMeta, messenger }),\n );\n}\n\n/**\n * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction.\n *\n * @param request - Data required to merge gas fee estimates.\n * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController.\n * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction.\n * @returns The merged gas fee estimates.\n */\nexport function mergeGasFeeEstimates({\n gasFeeControllerEstimates,\n transactionGasFeeEstimates,\n}: MergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates'] {\n const transactionEstimateType = transactionGasFeeEstimates.type;\n\n if (transactionEstimateType === GasFeeEstimateType.FeeMarket) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: mergeFeeMarketEstimate(\n (gasFeeControllerEstimates as GasFeeEstimates)?.[level],\n transactionGasFeeEstimates[level],\n ),\n }),\n { ...gasFeeControllerEstimates } as GasFeeEstimates,\n );\n }\n\n if (transactionEstimateType === GasFeeEstimateType.Legacy) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: getLegacyEstimate(transactionGasFeeEstimates, level),\n }),\n {} as LegacyGasPriceEstimate,\n );\n }\n\n if (transactionEstimateType === GasFeeEstimateType.GasPrice) {\n return {\n gasPrice: getGasPriceEstimate(transactionGasFeeEstimates),\n };\n }\n\n return gasFeeControllerEstimates;\n}\n\n/**\n * Merge a specific priority level of EIP-1559 gas fee estimates.\n *\n * @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller.\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The merged gas fee estimate.\n */\nfunction mergeFeeMarketEstimate(\n gasFeeControllerEstimate: Eip1559GasFee | undefined,\n transactionGasFeeEstimate: FeeMarketGasFeeEstimateForLevel,\n): Eip1559GasFee {\n return {\n ...gasFeeControllerEstimate,\n suggestedMaxFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxFeePerGas,\n ),\n suggestedMaxPriorityFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxPriorityFeePerGas,\n ),\n } as Eip1559GasFee;\n}\n\n/**\n * Generate a specific priority level for a legacy gas fee estimate.\n *\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @param level - The gas fee estimate level.\n * @returns The legacy gas fee estimate.\n */\nfunction getLegacyEstimate(\n transactionGasFeeEstimate: LegacyGasFeeEstimates,\n level: GasFeeEstimateLevel,\n): string {\n return weiHexToGweiDec(transactionGasFeeEstimate[level]);\n}\n\n/**\n * Generate the value for a gas price gas fee estimate.\n *\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The legacy gas fee estimate.\n */\nfunction getGasPriceEstimate(\n transactionGasFeeEstimate: GasPriceGasFeeEstimates,\n): string {\n return weiHexToGweiDec(transactionGasFeeEstimate.gasPrice);\n}\n"]}