@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
@@ -4,13 +4,20 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _OracleLayer1GasFeeFlow_instances, _OracleLayer1GasFeeFlow_getOracleLayer1GasFee, _OracleLayer1GasFeeFlow_getOperatorLayer1GasFee, _OracleLayer1GasFeeFlow_buildUnserializedTransaction, _OracleLayer1GasFeeFlow_buildTransactionParams, _OracleLayer1GasFeeFlow_callGasPriceOracle;
7
- import { Interface } from '@ethersproject/abi';
8
- import { add0x, createModuleLogger } from '@metamask/utils';
9
- import BN from 'bn.js';
10
- import { projectLogger } from '../logger.js';
11
- import { prepareTransaction } from '../utils/prepare.js';
12
- import { rpcRequest } from '../utils/provider.js';
13
- import { padHexToEvenLength, toBN } from '../utils/utils.js';
7
+ function $importDefault(module) {
8
+ if (module?.__esModule) {
9
+ return module.default;
10
+ }
11
+ return module;
12
+ }
13
+ import { Interface } from "@ethersproject/abi";
14
+ import { add0x, createModuleLogger } from "@metamask/utils";
15
+ import $BN from "bn.js";
16
+ const BN = $importDefault($BN);
17
+ import { projectLogger } from "../logger.mjs";
18
+ import { prepareTransaction } from "../utils/prepare.mjs";
19
+ import { rpcRequest } from "../utils/provider.mjs";
20
+ import { padHexToEvenLength, toBN } from "../utils/utils.mjs";
14
21
  const log = createModuleLogger(projectLogger, 'oracle-layer1-gas-fee-flow');
15
22
  const ZERO = new BN(0);
16
23
  const DUMMY_KEY = 'abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789';
@@ -191,4 +198,4 @@ async function _OracleLayer1GasFeeFlow_callGasPriceOracle(request, functionName,
191
198
  params: [{ to, data }, 'latest'],
192
199
  });
193
200
  };
194
- //# sourceMappingURL=OracleLayer1GasFeeFlow.js.map
201
+ //# sourceMappingURL=OracleLayer1GasFeeFlow.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OracleLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,2BAA2B;AAE/C,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,wBAAwB;AAC5D,OAAO,GAAE,cAAc;;AAEvB,OAAO,EAAE,aAAa,EAAE,sBAAqB;AAQ7C,OAAO,EAAE,kBAAkB,EAAE,6BAA4B;AACzD,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAClD,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,2BAA0B;AAE7D,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,4BAA4B,CAAC,CAAC;AAE5E,MAAM,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAEvB,MAAM,SAAS,GACb,kEAAkE,CAAC;AAErE,MAAM,oBAAoB,GAAG;IAC3B;QACE,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,OAAO;gBAC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AAG,OAAO,CAAC;IAC/C,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,eAAe,CAAC;IAErD,MAAM,EAAE,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,0BAA0B,CAAC,kBAAkB,CACxD,YAAY,EACZ,IAAI,CACE,CAAC;IAET,OAAO,MAAM,UAAU,CAAC;QACtB,SAAS;QACT,eAAe;QACf,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC;KACjC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Interface } from '@ethersproject/abi';\nimport type { Hex } from '@metamask/utils';\nimport { add0x, createModuleLogger } from '@metamask/utils';\nimport BN from 'bn.js';\n\nimport { projectLogger } from '../logger.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type {\n Layer1GasFeeFlow,\n Layer1GasFeeFlowRequest,\n Layer1GasFeeFlowResponse,\n TransactionMeta,\n} from '../types.js';\nimport { prepareTransaction } from '../utils/prepare.js';\nimport { rpcRequest } from '../utils/provider.js';\nimport { padHexToEvenLength, toBN } from '../utils/utils.js';\n\nconst log = createModuleLogger(projectLogger, 'oracle-layer1-gas-fee-flow');\n\nconst ZERO = new BN(0);\n\nconst DUMMY_KEY =\n 'abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789';\n\nconst GAS_PRICE_ORACLE_ABI = [\n {\n inputs: [\n {\n internalType: 'bytes',\n name: '_data',\n type: 'bytes',\n },\n ],\n name: 'getL1Fee',\n outputs: [\n {\n internalType: 'uint256',\n name: '',\n type: 'uint256',\n },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n // only available post Isthmus\n {\n inputs: [\n {\n internalType: 'uint256',\n name: '_gasUsed',\n type: 'uint256',\n },\n ],\n name: 'getOperatorFee',\n outputs: [\n {\n internalType: 'uint256',\n name: '',\n type: 'uint256',\n },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n];\n\n// Default OP Stack gas price oracle address used across supported networks\nconst DEFAULT_GAS_PRICE_ORACLE_ADDRESS =\n '0x420000000000000000000000000000000000000F' as Hex;\n\nconst GAS_PRICE_ORACLE_INTERFACE = new Interface(GAS_PRICE_ORACLE_ABI);\n\n/**\n * Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.\n */\nexport abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow {\n /**\n * Resolves the oracle address for the given chain. Subclasses can override\n * this method to provide chain-specific oracle addresses. By default, this\n * returns the standard OP Stack gas price oracle address.\n *\n * @param _chainId - The chain ID to resolve the oracle address for.\n * @returns The oracle address for the given chain.\n */\n protected getOracleAddressForChain(_chainId: Hex): Hex {\n return DEFAULT_GAS_PRICE_ORACLE_ADDRESS;\n }\n\n /**\n * Whether to sign the transaction with a dummy key prior to calling the\n * oracle contract. Some oracle contracts require a signed payload even for\n * read-only methods.\n *\n * Subclasses can override to enable signing when needed. Defaults to false.\n *\n * @returns Whether the transaction should be signed prior to the oracle call.\n */\n protected shouldSignTransaction(): boolean {\n return false;\n }\n\n abstract matchesTransaction({\n transactionMeta,\n messenger,\n }: {\n transactionMeta: TransactionMeta;\n messenger: TransactionControllerMessenger;\n }): Promise<boolean>;\n\n /**\n * Transforms the raw oracle L1 fee before it is combined with the operator\n * fee. Subclasses can override this to apply chain-specific conversions\n * (e.g. currency conversion via an on-chain exchange rate).\n *\n * Defaults to returning the fee unchanged.\n *\n * @param oracleFee - The raw L1 fee returned by the oracle contract.\n * @param _request - The original fee flow request (messenger + transaction).\n * @returns The transformed fee.\n */\n protected async transformOracleFee(\n oracleFee: BN,\n _request: Layer1GasFeeFlowRequest,\n ): Promise<BN> {\n return oracleFee;\n }\n\n async getLayer1Fee(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n try {\n const oracleFee = await this.#getOracleLayer1GasFee(request);\n const transformedFee = await this.transformOracleFee(oracleFee, request);\n const operatorFee = await this.#getOperatorLayer1GasFee(request);\n\n return {\n layer1Fee: add0x(\n padHexToEvenLength(transformedFee.add(operatorFee).toString(16)),\n ),\n };\n } catch (error) {\n log('Failed to get oracle layer 1 gas fee', error);\n throw new Error(`Failed to get oracle layer 1 gas fee`);\n }\n }\n\n async #getOracleLayer1GasFee(request: Layer1GasFeeFlowRequest): Promise<BN> {\n const serializedTransaction = this.#buildUnserializedTransaction(\n request.transactionMeta,\n this.shouldSignTransaction(),\n ).serialize();\n\n const result = await this.#callGasPriceOracle(request, 'getL1Fee', [\n serializedTransaction,\n ]);\n\n if (typeof result !== 'string' || result === '0x') {\n throw new Error('No value returned from oracle contract');\n }\n\n return toBN(result);\n }\n\n /**\n * Returns the gas value to pass to the operator-fee oracle, or undefined\n * to skip the operator-fee call entirely. Defaults to the simulated\n * `gasUsed` on the transaction. Subclasses can override to supply a\n * fallback (e.g. estimated gas limit) when `gasUsed` is unavailable.\n *\n * @param transactionMeta - The transaction metadata.\n * @returns The gas value, or undefined to skip the operator-fee call.\n */\n protected getOperatorFeeGas(\n transactionMeta: TransactionMeta,\n ): string | undefined {\n return transactionMeta.gasUsed;\n }\n\n async #getOperatorLayer1GasFee(\n request: Layer1GasFeeFlowRequest,\n ): Promise<BN> {\n const gas = this.getOperatorFeeGas(request.transactionMeta);\n\n if (!gas) {\n return ZERO;\n }\n\n try {\n const result = await this.#callGasPriceOracle(request, 'getOperatorFee', [\n gas,\n ]);\n\n if (typeof result !== 'string' || result === '0x') {\n return ZERO;\n }\n\n return toBN(result);\n } catch (error) {\n log('Failed to get operator layer 1 gas fee', error);\n return ZERO;\n }\n }\n\n #buildUnserializedTransaction(\n transactionMeta: TransactionMeta,\n sign: boolean,\n ): ReturnType<typeof prepareTransaction> {\n const txParams = this.#buildTransactionParams(transactionMeta);\n const { chainId } = transactionMeta;\n\n let unserializedTransaction = prepareTransaction(chainId, txParams);\n\n if (sign) {\n // eslint-disable-next-line no-restricted-globals\n const keyBuffer = Buffer.from(DUMMY_KEY, 'hex');\n const keyBytes = Uint8Array.from(keyBuffer);\n unserializedTransaction = unserializedTransaction.sign(keyBytes);\n }\n\n return unserializedTransaction;\n }\n\n #buildTransactionParams(\n transactionMeta: TransactionMeta,\n ): TransactionMeta['txParams'] {\n return {\n ...transactionMeta.txParams,\n gasLimit: transactionMeta.txParams.gas,\n };\n }\n\n // The oracle is called via a direct `eth_call` RPC request rather than an\n // ethers `Contract` with `Web3Provider`, as `Web3Provider` schedules its\n // JSON-RPC dispatch with `setTimeout`, which never fires on React Native\n // when the timer pump is starved (e.g. iOS display link freeze), blocking\n // `addTransaction` indefinitely.\n // See https://github.com/MetaMask/metamask-mobile/issues/32863\n async #callGasPriceOracle(\n request: Layer1GasFeeFlowRequest,\n functionName: string,\n args: readonly unknown[],\n ): Promise<unknown> {\n const { messenger, transactionMeta } = request;\n const { chainId, networkClientId } = transactionMeta;\n\n const to = this.getOracleAddressForChain(chainId);\n const data = GAS_PRICE_ORACLE_INTERFACE.encodeFunctionData(\n functionName,\n args,\n ) as Hex;\n\n return await rpcRequest({\n messenger,\n networkClientId,\n method: 'eth_call',\n params: [{ to, data }, 'latest'],\n });\n }\n}\n"]}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ 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");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _RandomisedEstimationsGasFeeFlow_instances, _RandomisedEstimationsGasFeeFlow_getDefaultGasFees, _RandomisedEstimationsGasFeeFlow_getRandomisedGasFees, _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketEstimates, _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketLevel;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.randomiseDecimalGWEIAndConvertToHex = exports.RandomisedEstimationsGasFeeFlow = void 0;
10
+ const gas_fee_controller_1 = require("@metamask/gas-fee-controller");
11
+ const utils_1 = require("@metamask/utils");
12
+ const logger_js_1 = require("../logger.cjs");
13
+ const types_js_1 = require("../types.cjs");
14
+ const feature_flags_js_1 = require("../utils/feature-flags.cjs");
15
+ const gas_fees_js_1 = require("../utils/gas-fees.cjs");
16
+ const DefaultGasFeeFlow_js_1 = require("./DefaultGasFeeFlow.cjs");
17
+ const log = (0, utils_1.createModuleLogger)(logger_js_1.projectLogger, 'randomised-estimation-gas-fee-flow');
18
+ const DEFAULT_PRESERVE_NUMBER_OF_DIGITS = 2;
19
+ /**
20
+ * Implementation of a gas fee flow that randomises the last digits of gas fee estimations
21
+ */
22
+ class RandomisedEstimationsGasFeeFlow {
23
+ constructor() {
24
+ _RandomisedEstimationsGasFeeFlow_instances.add(this);
25
+ }
26
+ matchesTransaction({ transactionMeta, messenger, }) {
27
+ const { chainId } = transactionMeta;
28
+ const gasFeeRandomisation = (0, feature_flags_js_1.getGasFeeRandomisation)(messenger);
29
+ const randomisedGasFeeDigits = gasFeeRandomisation.randomisedGasFeeDigits[chainId];
30
+ return randomisedGasFeeDigits !== undefined;
31
+ }
32
+ async getGasFees(request) {
33
+ try {
34
+ return await __classPrivateFieldGet(this, _RandomisedEstimationsGasFeeFlow_instances, "m", _RandomisedEstimationsGasFeeFlow_getRandomisedGasFees).call(this, request);
35
+ }
36
+ catch (error) {
37
+ log('Using default flow as fallback due to error', error);
38
+ return await __classPrivateFieldGet(this, _RandomisedEstimationsGasFeeFlow_instances, "m", _RandomisedEstimationsGasFeeFlow_getDefaultGasFees).call(this, request);
39
+ }
40
+ }
41
+ }
42
+ exports.RandomisedEstimationsGasFeeFlow = RandomisedEstimationsGasFeeFlow;
43
+ _RandomisedEstimationsGasFeeFlow_instances = new WeakSet(), _RandomisedEstimationsGasFeeFlow_getDefaultGasFees = async function _RandomisedEstimationsGasFeeFlow_getDefaultGasFees(request) {
44
+ return new DefaultGasFeeFlow_js_1.DefaultGasFeeFlow().getGasFees(request);
45
+ }, _RandomisedEstimationsGasFeeFlow_getRandomisedGasFees = async function _RandomisedEstimationsGasFeeFlow_getRandomisedGasFees(request) {
46
+ const { messenger, gasFeeControllerData, transactionMeta } = request;
47
+ const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;
48
+ const gasFeeRandomisation = (0, feature_flags_js_1.getGasFeeRandomisation)(messenger);
49
+ const randomisedGasFeeDigits = gasFeeRandomisation.randomisedGasFeeDigits[transactionMeta.chainId];
50
+ const preservedNumberOfDigits = gasFeeRandomisation.preservedNumberOfDigits ??
51
+ DEFAULT_PRESERVE_NUMBER_OF_DIGITS;
52
+ if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) {
53
+ log('Randomising fee market estimates', gasFeeEstimates);
54
+ const randomisedFeeMarketEstimates = __classPrivateFieldGet(this, _RandomisedEstimationsGasFeeFlow_instances, "m", _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketEstimates).call(this, gasFeeEstimates, randomisedGasFeeDigits, preservedNumberOfDigits);
55
+ log('Added randomised fee market estimates', randomisedFeeMarketEstimates);
56
+ return {
57
+ estimates: randomisedFeeMarketEstimates,
58
+ };
59
+ }
60
+ return await __classPrivateFieldGet(this, _RandomisedEstimationsGasFeeFlow_instances, "m", _RandomisedEstimationsGasFeeFlow_getDefaultGasFees).call(this, request);
61
+ }, _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketEstimates = function _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketEstimates(gasFeeEstimates, lastNDigits, preservedNumberOfDigits) {
62
+ const levels = Object.values(types_js_1.GasFeeEstimateLevel).reduce((result, level) => ({
63
+ ...result,
64
+ [level]: __classPrivateFieldGet(this, _RandomisedEstimationsGasFeeFlow_instances, "m", _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketLevel).call(this, gasFeeEstimates, level, lastNDigits, preservedNumberOfDigits),
65
+ }), {});
66
+ return {
67
+ type: types_js_1.GasFeeEstimateType.FeeMarket,
68
+ ...levels,
69
+ };
70
+ }, _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketLevel = function _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketLevel(gasFeeEstimates, level, lastNDigits, preservedNumberOfDigits) {
71
+ return {
72
+ maxFeePerGas: (0, gas_fees_js_1.gweiDecimalToWeiHex)(gasFeeEstimates[level].suggestedMaxFeePerGas),
73
+ // Only priority fee is randomised
74
+ maxPriorityFeePerGas: randomiseDecimalGWEIAndConvertToHex(gasFeeEstimates[level].suggestedMaxPriorityFeePerGas, lastNDigits, preservedNumberOfDigits),
75
+ };
76
+ };
77
+ /**
78
+ * Generates a random number with the specified number of digits that is greater than or equal to the given minimum value.
79
+ *
80
+ * @param digitCount - The number of digits the random number should have
81
+ * @param minValue - The minimum value the random number should have
82
+ * @returns A random number with the specified number of digits
83
+ */
84
+ function generateRandomDigits(digitCount, minValue) {
85
+ const multiplier = 10 ** digitCount;
86
+ return minValue + Math.floor(Math.random() * (multiplier - minValue));
87
+ }
88
+ /**
89
+ * Randomises the least significant digits of a decimal gas fee value and converts it to a hexadecimal Wei value.
90
+ *
91
+ * This function preserves the more significant digits while randomizing only the least significant ones,
92
+ * ensuring that fees remain close to the original estimation while providing randomisation.
93
+ * The randomisation is performed in Wei units for more precision.
94
+ *
95
+ * @param gweiDecimalValue - The original gas fee value in Gwei (decimal)
96
+ * @param numberOfDigitsToRandomizeAtTheEnd - The number of least significant digits to randomise
97
+ * @param preservedNumberOfDigits - The number of most significant digits to preserve
98
+ * @returns The randomised value converted to Wei in hexadecimal format
99
+ */
100
+ function randomiseDecimalGWEIAndConvertToHex(gweiDecimalValue, numberOfDigitsToRandomizeAtTheEnd, preservedNumberOfDigits) {
101
+ const weiDecimalValue = (0, gas_fees_js_1.gweiDecimalToWeiDecimal)(gweiDecimalValue);
102
+ const decimalLength = weiDecimalValue.length;
103
+ // Determine how many digits to randomise while preserving the PRESERVE_NUMBER_OF_DIGITS
104
+ const effectiveDigitsToRandomise = Math.min(numberOfDigitsToRandomizeAtTheEnd, decimalLength - preservedNumberOfDigits);
105
+ // Handle the case when the value is 0 or too small
106
+ if (Number(weiDecimalValue) === 0 || effectiveDigitsToRandomise <= 0) {
107
+ return `0x${Number(weiDecimalValue).toString(16)}`;
108
+ }
109
+ // Use string manipulation to get the base part (significant digits)
110
+ const significantDigitsCount = decimalLength - effectiveDigitsToRandomise;
111
+ const significantDigits = weiDecimalValue.slice(0, significantDigitsCount);
112
+ // Get the original ending digits using string manipulation
113
+ const endingDigits = weiDecimalValue.slice(-effectiveDigitsToRandomise);
114
+ const originalEndingDigits = Number(endingDigits);
115
+ // Generate random digits that are greater than or equal to the original ending digits
116
+ const randomEndingDigits = generateRandomDigits(effectiveDigitsToRandomise, originalEndingDigits);
117
+ const basePart = BigInt(significantDigits + '0'.repeat(effectiveDigitsToRandomise));
118
+ const randomisedWeiDecimal = basePart + BigInt(randomEndingDigits);
119
+ const hexRandomisedWei = `0x${randomisedWeiDecimal.toString(16)}`;
120
+ return (0, utils_1.add0x)(hexRandomisedWei);
121
+ }
122
+ exports.randomiseDecimalGWEIAndConvertToHex = randomiseDecimalGWEIAndConvertToHex;
123
+ //# sourceMappingURL=RandomisedEstimationsGasFeeFlow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RandomisedEstimationsGasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/RandomisedEstimationsGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;AACA,qEAAkE;AAClE,2CAA4D;AAG5D,6CAA6C;AAU7C,2CAAsE;AACtE,iEAAmE;AACnE,uDAG8B;AAC9B,kEAA2D;AAE3D,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAC5B,yBAAa,EACb,oCAAoC,CACrC,CAAC;AAEF,MAAM,iCAAiC,GAAG,CAAC,CA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GAAG,KAAK,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAElE,OAAO,IAAA,aAAK,EAAC,gBAAgB,CAAC,CAAC;AACjC,CAAC;AAzCD,kFAyCC","sourcesContent":["import type { GasFeeEstimates as FeeMarketGasPriceEstimate } from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport { add0x, createModuleLogger } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { projectLogger } from '../logger.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type {\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types.js';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types.js';\nimport { getGasFeeRandomisation } from '../utils/feature-flags.js';\nimport {\n gweiDecimalToWeiDecimal,\n gweiDecimalToWeiHex,\n} from '../utils/gas-fees.js';\nimport { DefaultGasFeeFlow } from './DefaultGasFeeFlow.js';\n\nconst log = createModuleLogger(\n projectLogger,\n 'randomised-estimation-gas-fee-flow',\n);\n\nconst DEFAULT_PRESERVE_NUMBER_OF_DIGITS = 2;\n\n/**\n * Implementation of a gas fee flow that randomises the last digits of gas fee estimations\n */\nexport class RandomisedEstimationsGasFeeFlow implements GasFeeFlow {\n matchesTransaction({\n transactionMeta,\n messenger,\n }: {\n transactionMeta: TransactionMeta;\n messenger: TransactionControllerMessenger;\n }): boolean {\n const { chainId } = transactionMeta;\n\n const gasFeeRandomisation = getGasFeeRandomisation(messenger);\n\n const randomisedGasFeeDigits =\n gasFeeRandomisation.randomisedGasFeeDigits[chainId];\n\n return randomisedGasFeeDigits !== undefined;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n try {\n return await this.#getRandomisedGasFees(request);\n } catch (error) {\n log('Using default flow as fallback due to error', error);\n return await this.#getDefaultGasFees(request);\n }\n }\n\n async #getDefaultGasFees(\n request: GasFeeFlowRequest,\n ): Promise<GasFeeFlowResponse> {\n return new DefaultGasFeeFlow().getGasFees(request);\n }\n\n async #getRandomisedGasFees(\n request: GasFeeFlowRequest,\n ): Promise<GasFeeFlowResponse> {\n const { messenger, gasFeeControllerData, transactionMeta } = request;\n const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;\n\n const gasFeeRandomisation = getGasFeeRandomisation(messenger);\n\n const randomisedGasFeeDigits =\n gasFeeRandomisation.randomisedGasFeeDigits[transactionMeta.chainId];\n\n const preservedNumberOfDigits =\n gasFeeRandomisation.preservedNumberOfDigits ??\n DEFAULT_PRESERVE_NUMBER_OF_DIGITS;\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n log('Randomising fee market estimates', gasFeeEstimates);\n const randomisedFeeMarketEstimates =\n this.#getRandomisedFeeMarketEstimates(\n gasFeeEstimates,\n randomisedGasFeeDigits,\n preservedNumberOfDigits,\n );\n log(\n 'Added randomised fee market estimates',\n randomisedFeeMarketEstimates,\n );\n\n return {\n estimates: randomisedFeeMarketEstimates,\n };\n }\n\n return await this.#getDefaultGasFees(request);\n }\n\n #getRandomisedFeeMarketEstimates(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n lastNDigits: number,\n preservedNumberOfDigits: number,\n ): FeeMarketGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getRandomisedFeeMarketLevel(\n gasFeeEstimates,\n level,\n lastNDigits,\n preservedNumberOfDigits,\n ),\n }),\n {} as Omit<FeeMarketGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.FeeMarket,\n ...levels,\n };\n }\n\n #getRandomisedFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n lastNDigits: number,\n preservedNumberOfDigits: number,\n ): FeeMarketGasFeeEstimateForLevel {\n return {\n maxFeePerGas: gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n ),\n // Only priority fee is randomised\n maxPriorityFeePerGas: randomiseDecimalGWEIAndConvertToHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n lastNDigits,\n preservedNumberOfDigits,\n ),\n };\n }\n}\n\n/**\n * Generates a random number with the specified number of digits that is greater than or equal to the given minimum value.\n *\n * @param digitCount - The number of digits the random number should have\n * @param minValue - The minimum value the random number should have\n * @returns A random number with the specified number of digits\n */\nfunction generateRandomDigits(digitCount: number, minValue: number): number {\n const multiplier = 10 ** digitCount;\n return minValue + Math.floor(Math.random() * (multiplier - minValue));\n}\n\n/**\n * Randomises the least significant digits of a decimal gas fee value and converts it to a hexadecimal Wei value.\n *\n * This function preserves the more significant digits while randomizing only the least significant ones,\n * ensuring that fees remain close to the original estimation while providing randomisation.\n * The randomisation is performed in Wei units for more precision.\n *\n * @param gweiDecimalValue - The original gas fee value in Gwei (decimal)\n * @param numberOfDigitsToRandomizeAtTheEnd - The number of least significant digits to randomise\n * @param preservedNumberOfDigits - The number of most significant digits to preserve\n * @returns The randomised value converted to Wei in hexadecimal format\n */\nexport function randomiseDecimalGWEIAndConvertToHex(\n gweiDecimalValue: string | number,\n numberOfDigitsToRandomizeAtTheEnd: number,\n preservedNumberOfDigits: number,\n): Hex {\n const weiDecimalValue = gweiDecimalToWeiDecimal(gweiDecimalValue);\n const decimalLength = weiDecimalValue.length;\n\n // Determine how many digits to randomise while preserving the PRESERVE_NUMBER_OF_DIGITS\n const effectiveDigitsToRandomise = Math.min(\n numberOfDigitsToRandomizeAtTheEnd,\n decimalLength - preservedNumberOfDigits,\n );\n\n // Handle the case when the value is 0 or too small\n if (Number(weiDecimalValue) === 0 || effectiveDigitsToRandomise <= 0) {\n return `0x${Number(weiDecimalValue).toString(16)}` as const;\n }\n\n // Use string manipulation to get the base part (significant digits)\n const significantDigitsCount = decimalLength - effectiveDigitsToRandomise;\n const significantDigits = weiDecimalValue.slice(0, significantDigitsCount);\n\n // Get the original ending digits using string manipulation\n const endingDigits = weiDecimalValue.slice(-effectiveDigitsToRandomise);\n const originalEndingDigits = Number(endingDigits);\n\n // Generate random digits that are greater than or equal to the original ending digits\n const randomEndingDigits = generateRandomDigits(\n effectiveDigitsToRandomise,\n originalEndingDigits,\n );\n\n const basePart = BigInt(\n significantDigits + '0'.repeat(effectiveDigitsToRandomise),\n );\n const randomisedWeiDecimal = basePart + BigInt(randomEndingDigits);\n\n const hexRandomisedWei = `0x${randomisedWeiDecimal.toString(16)}`;\n\n return add0x(hexRandomisedWei);\n}\n"]}
@@ -1,6 +1,6 @@
1
- import type { Hex } from '@metamask/utils';
2
- import type { TransactionControllerMessenger } from '../TransactionController.js';
3
- import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from '../types.js';
1
+ import type { Hex } from "@metamask/utils";
2
+ import type { TransactionControllerMessenger } from "../TransactionController.cjs";
3
+ import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from "../types.cjs";
4
4
  /**
5
5
  * Implementation of a gas fee flow that randomises the last digits of gas fee estimations
6
6
  */
@@ -25,4 +25,4 @@ export declare class RandomisedEstimationsGasFeeFlow implements GasFeeFlow {
25
25
  * @returns The randomised value converted to Wei in hexadecimal format
26
26
  */
27
27
  export declare function randomiseDecimalGWEIAndConvertToHex(gweiDecimalValue: string | number, numberOfDigitsToRandomizeAtTheEnd: number, preservedNumberOfDigits: number): Hex;
28
- //# sourceMappingURL=RandomisedEstimationsGasFeeFlow.d.ts.map
28
+ //# sourceMappingURL=RandomisedEstimationsGasFeeFlow.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RandomisedEstimationsGasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/RandomisedEstimationsGasFeeFlow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAClF,OAAO,KAAK,EAGV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,qBAAoB;AAgBrB;;GAEG;AACH,qBAAa,+BAAgC,YAAW,UAAU;;IAChE,kBAAkB,CAAC,EACjB,eAAe,EACf,SAAS,GACV,EAAE;QACD,eAAe,EAAE,eAAe,CAAC;QACjC,SAAS,EAAE,8BAA8B,CAAC;KAC3C,GAAG,OAAO;IAWL,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA6F1E;AAcD;;;;;;;;;;;GAWG;AACH,wBAAgB,mCAAmC,CACjD,gBAAgB,EAAE,MAAM,GAAG,MAAM,EACjC,iCAAiC,EAAE,MAAM,EACzC,uBAAuB,EAAE,MAAM,GAC9B,GAAG,CAqCL"}
@@ -0,0 +1,28 @@
1
+ import type { Hex } from "@metamask/utils";
2
+ import type { TransactionControllerMessenger } from "../TransactionController.mjs";
3
+ import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from "../types.mjs";
4
+ /**
5
+ * Implementation of a gas fee flow that randomises the last digits of gas fee estimations
6
+ */
7
+ export declare class RandomisedEstimationsGasFeeFlow implements GasFeeFlow {
8
+ #private;
9
+ matchesTransaction({ transactionMeta, messenger, }: {
10
+ transactionMeta: TransactionMeta;
11
+ messenger: TransactionControllerMessenger;
12
+ }): boolean;
13
+ getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
14
+ }
15
+ /**
16
+ * Randomises the least significant digits of a decimal gas fee value and converts it to a hexadecimal Wei value.
17
+ *
18
+ * This function preserves the more significant digits while randomizing only the least significant ones,
19
+ * ensuring that fees remain close to the original estimation while providing randomisation.
20
+ * The randomisation is performed in Wei units for more precision.
21
+ *
22
+ * @param gweiDecimalValue - The original gas fee value in Gwei (decimal)
23
+ * @param numberOfDigitsToRandomizeAtTheEnd - The number of least significant digits to randomise
24
+ * @param preservedNumberOfDigits - The number of most significant digits to preserve
25
+ * @returns The randomised value converted to Wei in hexadecimal format
26
+ */
27
+ export declare function randomiseDecimalGWEIAndConvertToHex(gweiDecimalValue: string | number, numberOfDigitsToRandomizeAtTheEnd: number, preservedNumberOfDigits: number): Hex;
28
+ //# sourceMappingURL=RandomisedEstimationsGasFeeFlow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RandomisedEstimationsGasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/RandomisedEstimationsGasFeeFlow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAClF,OAAO,KAAK,EAGV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,qBAAoB;AAgBrB;;GAEG;AACH,qBAAa,+BAAgC,YAAW,UAAU;;IAChE,kBAAkB,CAAC,EACjB,eAAe,EACf,SAAS,GACV,EAAE;QACD,eAAe,EAAE,eAAe,CAAC;QACjC,SAAS,EAAE,8BAA8B,CAAC;KAC3C,GAAG,OAAO;IAWL,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA6F1E;AAcD;;;;;;;;;;;GAWG;AACH,wBAAgB,mCAAmC,CACjD,gBAAgB,EAAE,MAAM,GAAG,MAAM,EACjC,iCAAiC,EAAE,MAAM,EACzC,uBAAuB,EAAE,MAAM,GAC9B,GAAG,CAqCL"}
@@ -4,13 +4,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _RandomisedEstimationsGasFeeFlow_instances, _RandomisedEstimationsGasFeeFlow_getDefaultGasFees, _RandomisedEstimationsGasFeeFlow_getRandomisedGasFees, _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketEstimates, _RandomisedEstimationsGasFeeFlow_getRandomisedFeeMarketLevel;
7
- import { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';
8
- import { add0x, createModuleLogger } from '@metamask/utils';
9
- import { projectLogger } from '../logger.js';
10
- import { GasFeeEstimateLevel, GasFeeEstimateType } from '../types.js';
11
- import { getGasFeeRandomisation } from '../utils/feature-flags.js';
12
- import { gweiDecimalToWeiDecimal, gweiDecimalToWeiHex, } from '../utils/gas-fees.js';
13
- import { DefaultGasFeeFlow } from './DefaultGasFeeFlow.js';
7
+ import { GAS_ESTIMATE_TYPES } from "@metamask/gas-fee-controller";
8
+ import { add0x, createModuleLogger } from "@metamask/utils";
9
+ import { projectLogger } from "../logger.mjs";
10
+ import { GasFeeEstimateLevel, GasFeeEstimateType } from "../types.mjs";
11
+ import { getGasFeeRandomisation } from "../utils/feature-flags.mjs";
12
+ import { gweiDecimalToWeiDecimal, gweiDecimalToWeiHex } from "../utils/gas-fees.mjs";
13
+ import { DefaultGasFeeFlow } from "./DefaultGasFeeFlow.mjs";
14
14
  const log = createModuleLogger(projectLogger, 'randomised-estimation-gas-fee-flow');
15
15
  const DEFAULT_PRESERVE_NUMBER_OF_DIGITS = 2;
16
16
  /**
@@ -115,4 +115,4 @@ export function randomiseDecimalGWEIAndConvertToHex(gweiDecimalValue, numberOfDi
115
115
  const hexRandomisedWei = `0x${randomisedWeiDecimal.toString(16)}`;
116
116
  return add0x(hexRandomisedWei);
117
117
  }
118
- //# sourceMappingURL=RandomisedEstimationsGasFeeFlow.js.map
118
+ //# sourceMappingURL=RandomisedEstimationsGasFeeFlow.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RandomisedEstimationsGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/RandomisedEstimationsGasFeeFlow.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,qCAAqC;AAClE,OAAO,EAAE,KAAK,EAAE,kBAAkB,E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GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAElD,sFAAsF;IACtF,MAAM,kBAAkB,GAAG,oBAAoB,CAC7C,0BAA0B,EAC1B,oBAAoB,CACrB,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,CACrB,iBAAiB,GAAG,GAAG,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAC3D,CAAC;IACF,MAAM,oBAAoB,GAAG,QAAQ,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAEnE,MAAM,gBAAgB,GAAG,KAAK,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAElE,OAAO,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import type { GasFeeEstimates as FeeMarketGasPriceEstimate } from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport { add0x, createModuleLogger } from '@metamask/utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { projectLogger } from '../logger.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type {\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types.js';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types.js';\nimport { getGasFeeRandomisation } from '../utils/feature-flags.js';\nimport {\n gweiDecimalToWeiDecimal,\n gweiDecimalToWeiHex,\n} from '../utils/gas-fees.js';\nimport { DefaultGasFeeFlow } from './DefaultGasFeeFlow.js';\n\nconst log = createModuleLogger(\n projectLogger,\n 'randomised-estimation-gas-fee-flow',\n);\n\nconst DEFAULT_PRESERVE_NUMBER_OF_DIGITS = 2;\n\n/**\n * Implementation of a gas fee flow that randomises the last digits of gas fee estimations\n */\nexport class RandomisedEstimationsGasFeeFlow implements GasFeeFlow {\n matchesTransaction({\n transactionMeta,\n messenger,\n }: {\n transactionMeta: TransactionMeta;\n messenger: TransactionControllerMessenger;\n }): boolean {\n const { chainId } = transactionMeta;\n\n const gasFeeRandomisation = getGasFeeRandomisation(messenger);\n\n const randomisedGasFeeDigits =\n gasFeeRandomisation.randomisedGasFeeDigits[chainId];\n\n return randomisedGasFeeDigits !== undefined;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n try {\n return await this.#getRandomisedGasFees(request);\n } catch (error) {\n log('Using default flow as fallback due to error', error);\n return await this.#getDefaultGasFees(request);\n }\n }\n\n async #getDefaultGasFees(\n request: GasFeeFlowRequest,\n ): Promise<GasFeeFlowResponse> {\n return new DefaultGasFeeFlow().getGasFees(request);\n }\n\n async #getRandomisedGasFees(\n request: GasFeeFlowRequest,\n ): Promise<GasFeeFlowResponse> {\n const { messenger, gasFeeControllerData, transactionMeta } = request;\n const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;\n\n const gasFeeRandomisation = getGasFeeRandomisation(messenger);\n\n const randomisedGasFeeDigits =\n gasFeeRandomisation.randomisedGasFeeDigits[transactionMeta.chainId];\n\n const preservedNumberOfDigits =\n gasFeeRandomisation.preservedNumberOfDigits ??\n DEFAULT_PRESERVE_NUMBER_OF_DIGITS;\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n log('Randomising fee market estimates', gasFeeEstimates);\n const randomisedFeeMarketEstimates =\n this.#getRandomisedFeeMarketEstimates(\n gasFeeEstimates,\n randomisedGasFeeDigits,\n preservedNumberOfDigits,\n );\n log(\n 'Added randomised fee market estimates',\n randomisedFeeMarketEstimates,\n );\n\n return {\n estimates: randomisedFeeMarketEstimates,\n };\n }\n\n return await this.#getDefaultGasFees(request);\n }\n\n #getRandomisedFeeMarketEstimates(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n lastNDigits: number,\n preservedNumberOfDigits: number,\n ): FeeMarketGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getRandomisedFeeMarketLevel(\n gasFeeEstimates,\n level,\n lastNDigits,\n preservedNumberOfDigits,\n ),\n }),\n {} as Omit<FeeMarketGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.FeeMarket,\n ...levels,\n };\n }\n\n #getRandomisedFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n lastNDigits: number,\n preservedNumberOfDigits: number,\n ): FeeMarketGasFeeEstimateForLevel {\n return {\n maxFeePerGas: gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n ),\n // Only priority fee is randomised\n maxPriorityFeePerGas: randomiseDecimalGWEIAndConvertToHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n lastNDigits,\n preservedNumberOfDigits,\n ),\n };\n }\n}\n\n/**\n * Generates a random number with the specified number of digits that is greater than or equal to the given minimum value.\n *\n * @param digitCount - The number of digits the random number should have\n * @param minValue - The minimum value the random number should have\n * @returns A random number with the specified number of digits\n */\nfunction generateRandomDigits(digitCount: number, minValue: number): number {\n const multiplier = 10 ** digitCount;\n return minValue + Math.floor(Math.random() * (multiplier - minValue));\n}\n\n/**\n * Randomises the least significant digits of a decimal gas fee value and converts it to a hexadecimal Wei value.\n *\n * This function preserves the more significant digits while randomizing only the least significant ones,\n * ensuring that fees remain close to the original estimation while providing randomisation.\n * The randomisation is performed in Wei units for more precision.\n *\n * @param gweiDecimalValue - The original gas fee value in Gwei (decimal)\n * @param numberOfDigitsToRandomizeAtTheEnd - The number of least significant digits to randomise\n * @param preservedNumberOfDigits - The number of most significant digits to preserve\n * @returns The randomised value converted to Wei in hexadecimal format\n */\nexport function randomiseDecimalGWEIAndConvertToHex(\n gweiDecimalValue: string | number,\n numberOfDigitsToRandomizeAtTheEnd: number,\n preservedNumberOfDigits: number,\n): Hex {\n const weiDecimalValue = gweiDecimalToWeiDecimal(gweiDecimalValue);\n const decimalLength = weiDecimalValue.length;\n\n // Determine how many digits to randomise while preserving the PRESERVE_NUMBER_OF_DIGITS\n const effectiveDigitsToRandomise = Math.min(\n numberOfDigitsToRandomizeAtTheEnd,\n decimalLength - preservedNumberOfDigits,\n );\n\n // Handle the case when the value is 0 or too small\n if (Number(weiDecimalValue) === 0 || effectiveDigitsToRandomise <= 0) {\n return `0x${Number(weiDecimalValue).toString(16)}` as const;\n }\n\n // Use string manipulation to get the base part (significant digits)\n const significantDigitsCount = decimalLength - effectiveDigitsToRandomise;\n const significantDigits = weiDecimalValue.slice(0, significantDigitsCount);\n\n // Get the original ending digits using string manipulation\n const endingDigits = weiDecimalValue.slice(-effectiveDigitsToRandomise);\n const originalEndingDigits = Number(endingDigits);\n\n // Generate random digits that are greater than or equal to the original ending digits\n const randomEndingDigits = generateRandomDigits(\n effectiveDigitsToRandomise,\n originalEndingDigits,\n );\n\n const basePart = BigInt(\n significantDigits + '0'.repeat(effectiveDigitsToRandomise),\n );\n const randomisedWeiDecimal = basePart + BigInt(randomEndingDigits);\n\n const hexRandomisedWei = `0x${randomisedWeiDecimal.toString(16)}`;\n\n return add0x(hexRandomisedWei);\n}\n"]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScrollLayer1GasFeeFlow = void 0;
4
+ const constants_js_1 = require("../constants.cjs");
5
+ const OracleLayer1GasFeeFlow_js_1 = require("./OracleLayer1GasFeeFlow.cjs");
6
+ const SCROLL_CHAIN_IDS = [constants_js_1.CHAIN_IDS.SCROLL, constants_js_1.CHAIN_IDS.SCROLL_SEPOLIA];
7
+ // BlockExplorer link: https://scrollscan.com/address/0x5300000000000000000000000000000000000002#code
8
+ const SCROLL_GAS_PRICE_ORACLE_ADDRESS = '0x5300000000000000000000000000000000000002';
9
+ /**
10
+ * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
11
+ */
12
+ class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow_js_1.OracleLayer1GasFeeFlow {
13
+ getOracleAddressForChain(_chainId) {
14
+ return SCROLL_GAS_PRICE_ORACLE_ADDRESS;
15
+ }
16
+ shouldSignTransaction() {
17
+ return true;
18
+ }
19
+ async matchesTransaction({ transactionMeta, }) {
20
+ return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);
21
+ }
22
+ }
23
+ exports.ScrollLayer1GasFeeFlow = ScrollLayer1GasFeeFlow;
24
+ //# sourceMappingURL=ScrollLayer1GasFeeFlow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;AAEA,mDAA4C;AAG5C,4EAAqE;AAErE,MAAM,gBAAgB,GAAU,CAAC,wBAAS,CAAC,MAAM,EAAE,wBAAS,CAAC,cAAc,CAAC,CAAC;AAE7E,qGAAqG;AACrG,MAAM,+BAA+B,GACnC,4CAAmD,CAAC;AAEtD;;GAEG;AACH,MAAa,sBAAuB,SAAQ,kDAAsB;IAC7C,wBAAwB,CAAC,QAAa;QACvD,OAAO,+BAA+B,CAAC;IACzC,CAAC;IAEkB,qBAAqB;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,EACvB,eAAe,GAIhB;QACC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF;AAjBD,wDAiBC","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport { CHAIN_IDS } from '../constants.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type { TransactionMeta } from '../types.js';\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow.js';\n\nconst SCROLL_CHAIN_IDS: Hex[] = [CHAIN_IDS.SCROLL, CHAIN_IDS.SCROLL_SEPOLIA];\n\n// BlockExplorer link: https://scrollscan.com/address/0x5300000000000000000000000000000000000002#code\nconst SCROLL_GAS_PRICE_ORACLE_ADDRESS =\n '0x5300000000000000000000000000000000000002' as Hex;\n\n/**\n * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.\n */\nexport class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {\n protected override getOracleAddressForChain(_chainId: Hex): Hex {\n return SCROLL_GAS_PRICE_ORACLE_ADDRESS;\n }\n\n protected override shouldSignTransaction(): boolean {\n return true;\n }\n\n async matchesTransaction({\n transactionMeta,\n }: {\n transactionMeta: TransactionMeta;\n messenger: TransactionControllerMessenger;\n }): Promise<boolean> {\n return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { Hex } from '@metamask/utils';
2
- import type { TransactionControllerMessenger } from '../TransactionController.js';
3
- import type { TransactionMeta } from '../types.js';
4
- import { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow.js';
1
+ import type { Hex } from "@metamask/utils";
2
+ import type { TransactionControllerMessenger } from "../TransactionController.cjs";
3
+ import type { TransactionMeta } from "../types.cjs";
4
+ import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.cjs";
5
5
  /**
6
6
  * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
7
7
  */
@@ -13,4 +13,4 @@ export declare class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
13
13
  messenger: TransactionControllerMessenger;
14
14
  }): Promise<boolean>;
15
15
  }
16
- //# sourceMappingURL=ScrollLayer1GasFeeFlow.d.ts.map
16
+ //# sourceMappingURL=ScrollLayer1GasFeeFlow.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAoB;AACnD,OAAO,EAAE,sBAAsB,EAAE,qCAAoC;AAQrE;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,sBAAsB;cAC7C,wBAAwB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG;cAI5C,qBAAqB,IAAI,OAAO;IAI7C,kBAAkB,CAAC,EACvB,eAAe,GAChB,EAAE;QACD,eAAe,EAAE,eAAe,CAAC;QACjC,SAAS,EAAE,8BAA8B,CAAC;KAC3C,GAAG,OAAO,CAAC,OAAO,CAAC;CAGrB"}
@@ -0,0 +1,16 @@
1
+ import type { Hex } from "@metamask/utils";
2
+ import type { TransactionControllerMessenger } from "../TransactionController.mjs";
3
+ import type { TransactionMeta } from "../types.mjs";
4
+ import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.mjs";
5
+ /**
6
+ * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
7
+ */
8
+ export declare class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
9
+ protected getOracleAddressForChain(_chainId: Hex): Hex;
10
+ protected shouldSignTransaction(): boolean;
11
+ matchesTransaction({ transactionMeta, }: {
12
+ transactionMeta: TransactionMeta;
13
+ messenger: TransactionControllerMessenger;
14
+ }): Promise<boolean>;
15
+ }
16
+ //# sourceMappingURL=ScrollLayer1GasFeeFlow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAoC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAoB;AACnD,OAAO,EAAE,sBAAsB,EAAE,qCAAoC;AAQrE;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,sBAAsB;cAC7C,wBAAwB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG;cAI5C,qBAAqB,IAAI,OAAO;IAI7C,kBAAkB,CAAC,EACvB,eAAe,GAChB,EAAE;QACD,eAAe,EAAE,eAAe,CAAC;QACjC,SAAS,EAAE,8BAA8B,CAAC;KAC3C,GAAG,OAAO,CAAC,OAAO,CAAC;CAGrB"}
@@ -1,5 +1,5 @@
1
- import { CHAIN_IDS } from '../constants.js';
2
- import { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow.js';
1
+ import { CHAIN_IDS } from "../constants.mjs";
2
+ import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.mjs";
3
3
  const SCROLL_CHAIN_IDS = [CHAIN_IDS.SCROLL, CHAIN_IDS.SCROLL_SEPOLIA];
4
4
  // BlockExplorer link: https://scrollscan.com/address/0x5300000000000000000000000000000000000002#code
5
5
  const SCROLL_GAS_PRICE_ORACLE_ADDRESS = '0x5300000000000000000000000000000000000002';
@@ -17,4 +17,4 @@ export class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
17
17
  return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);
18
18
  }
19
19
  }
20
- //# sourceMappingURL=ScrollLayer1GasFeeFlow.js.map
20
+ //# sourceMappingURL=ScrollLayer1GasFeeFlow.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,yBAAwB;AAG5C,OAAO,EAAE,sBAAsB,EAAE,qCAAoC;AAErE,MAAM,gBAAgB,GAAU,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;AAE7E,qGAAqG;AACrG,MAAM,+BAA+B,GACnC,4CAAmD,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,sBAAsB;IAC7C,wBAAwB,CAAC,QAAa;QACvD,OAAO,+BAA+B,CAAC;IACzC,CAAC;IAEkB,qBAAqB;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,EACvB,eAAe,GAIhB;QACC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport { CHAIN_IDS } from '../constants.js';\nimport type { TransactionControllerMessenger } from '../TransactionController.js';\nimport type { TransactionMeta } from '../types.js';\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow.js';\n\nconst SCROLL_CHAIN_IDS: Hex[] = [CHAIN_IDS.SCROLL, CHAIN_IDS.SCROLL_SEPOLIA];\n\n// BlockExplorer link: https://scrollscan.com/address/0x5300000000000000000000000000000000000002#code\nconst SCROLL_GAS_PRICE_ORACLE_ADDRESS =\n '0x5300000000000000000000000000000000000002' as Hex;\n\n/**\n * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.\n */\nexport class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {\n protected override getOracleAddressForChain(_chainId: Hex): Hex {\n return SCROLL_GAS_PRICE_ORACLE_ADDRESS;\n }\n\n protected override shouldSignTransaction(): boolean {\n return true;\n }\n\n async matchesTransaction({\n transactionMeta,\n }: {\n transactionMeta: TransactionMeta;\n messenger: TransactionControllerMessenger;\n }): Promise<boolean> {\n return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n}\n"]}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ 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");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ 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");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var _TestGasFeeFlow_instances, _TestGasFeeFlow_counter, _TestGasFeeFlow_getValueForTotalFee;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TestGasFeeFlow = void 0;
16
+ const controller_utils_1 = require("@metamask/controller-utils");
17
+ const types_js_1 = require("../types.cjs");
18
+ const INCREMENT = 1e15; // 0.001 ETH
19
+ const LEVEL_DIFFERENCE = 0.5;
20
+ /**
21
+ * A gas fee flow to facilitate testing in the clients.
22
+ * Increments the total gas fee by a fixed amount each time it is called.
23
+ * Relies on the transaction's gas value to generate a distinct total fee in the UI.
24
+ */
25
+ class TestGasFeeFlow {
26
+ constructor() {
27
+ _TestGasFeeFlow_instances.add(this);
28
+ _TestGasFeeFlow_counter.set(this, 1);
29
+ }
30
+ matchesTransaction() {
31
+ return true;
32
+ }
33
+ async getGasFees(request) {
34
+ const { transactionMeta } = request;
35
+ const { txParams } = transactionMeta;
36
+ const { gas: gasHex } = txParams;
37
+ if (!gasHex) {
38
+ throw new Error('Cannot estimate fee without gas value');
39
+ }
40
+ const gasDecimal = parseInt(gasHex, 16);
41
+ const difference = INCREMENT * LEVEL_DIFFERENCE;
42
+ const mediumMaxTarget = (__classPrivateFieldGet(this, _TestGasFeeFlow_counter, "f") + 1) * INCREMENT;
43
+ const mediumPriorityTarget = __classPrivateFieldGet(this, _TestGasFeeFlow_counter, "f") * INCREMENT;
44
+ const lowMaxTarget = mediumMaxTarget - difference;
45
+ const lowPriorityTarget = mediumPriorityTarget - difference;
46
+ const highMaxTarget = mediumMaxTarget + difference;
47
+ const highPriorityTarget = mediumPriorityTarget + difference;
48
+ __classPrivateFieldSet(this, _TestGasFeeFlow_counter, __classPrivateFieldGet(this, _TestGasFeeFlow_counter, "f") + 1, "f");
49
+ return {
50
+ estimates: {
51
+ type: types_js_1.GasFeeEstimateType.FeeMarket,
52
+ low: {
53
+ maxFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, lowMaxTarget, gasDecimal),
54
+ maxPriorityFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, lowPriorityTarget, gasDecimal),
55
+ },
56
+ medium: {
57
+ maxFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, mediumMaxTarget, gasDecimal),
58
+ maxPriorityFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, mediumPriorityTarget, gasDecimal),
59
+ },
60
+ high: {
61
+ maxFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, highMaxTarget, gasDecimal),
62
+ maxPriorityFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, highPriorityTarget, gasDecimal),
63
+ },
64
+ },
65
+ };
66
+ }
67
+ }
68
+ exports.TestGasFeeFlow = TestGasFeeFlow;
69
+ _TestGasFeeFlow_counter = new WeakMap(), _TestGasFeeFlow_instances = new WeakSet(), _TestGasFeeFlow_getValueForTotalFee = function _TestGasFeeFlow_getValueForTotalFee(totalFee, gas) {
70
+ const feeDecimal = Math.ceil(totalFee / gas);
71
+ return (0, controller_utils_1.toHex)(feeDecimal);
72
+ };
73
+ //# sourceMappingURL=TestGasFeeFlow.cj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6BAAkB,CAAC,SAAS;gBAClC,GAAG,EAAE;oBACH,YAAY,EAAE,uBAAA,IAAI,sEAAqB,MAAzB,IAAI,EAAsB,YAAY,EAAE,UAAU,CAAC;oBACjE,oBAAoB,EAAE,uBAAA,IAAI,sEAAqB,MAAzB,IAAI,EACxB,iBAAiB,EACjB,UAAU,CACX;iBACF;gBACD,MAAM,EAAE;oBACN,YAAY,EAAE,uBAAA,IAAI,sEAAqB,MAAzB,IAAI,EAAsB,eAAe,EAAE,UAAU,CAAC;oBACpE,oBAAoB,EAAE,uBAAA,IAAI,sEAAqB,MAAzB,IAAI,EACxB,oBAAoB,EACpB,UAAU,CACX;iBACF;gBACD,IAAI,EAAE;oBACJ,YAAY,EAAE,uBAAA,IAAI,sEAAqB,MAAzB,IAAI,EAAsB,aAAa,EAAE,UAAU,CAAC;oBAClE,oBAAoB,EAAE,uBAAA,IAAI,sEAAqB,MAAzB,IAAI,EACxB,kBAAkB,EAClB,UAAU,CACX;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CAMF;AA9DD,wCA8DC;uKAJsB,QAAgB,EAAE,GAAW;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;IAC7C,OAAO,IAAA,wBAAK,EAAC,UAAU,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { GasFeeEstimateType } from '../types.js';\nimport type {\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n} from '../types.js';\n\nconst INCREMENT = 1e15; // 0.001 ETH\nconst LEVEL_DIFFERENCE = 0.5;\n\n/**\n * A gas fee flow to facilitate testing in the clients.\n * Increments the total gas fee by a fixed amount each time it is called.\n * Relies on the transaction's gas value to generate a distinct total fee in the UI.\n */\nexport class TestGasFeeFlow implements GasFeeFlow {\n #counter = 1;\n\n matchesTransaction(): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n const { transactionMeta } = request;\n const { txParams } = transactionMeta;\n const { gas: gasHex } = txParams;\n\n if (!gasHex) {\n throw new Error('Cannot estimate fee without gas value');\n }\n\n const gasDecimal = parseInt(gasHex, 16);\n const difference = INCREMENT * LEVEL_DIFFERENCE;\n\n const mediumMaxTarget = (this.#counter + 1) * INCREMENT;\n const mediumPriorityTarget = this.#counter * INCREMENT;\n\n const lowMaxTarget = mediumMaxTarget - difference;\n const lowPriorityTarget = mediumPriorityTarget - difference;\n\n const highMaxTarget = mediumMaxTarget + difference;\n const highPriorityTarget = mediumPriorityTarget + difference;\n\n this.#counter += 1;\n\n return {\n estimates: {\n type: GasFeeEstimateType.FeeMarket,\n low: {\n maxFeePerGas: this.#getValueForTotalFee(lowMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n lowPriorityTarget,\n gasDecimal,\n ),\n },\n medium: {\n maxFeePerGas: this.#getValueForTotalFee(mediumMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n mediumPriorityTarget,\n gasDecimal,\n ),\n },\n high: {\n maxFeePerGas: this.#getValueForTotalFee(highMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n highPriorityTarget,\n gasDecimal,\n ),\n },\n },\n };\n }\n\n #getValueForTotalFee(totalFee: number, gas: number): Hex {\n const feeDecimal = Math.ceil(totalFee / gas);\n return toHex(feeDecimal);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse } from '../types.js';
1
+ import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse } from "../types.cjs";
2
2
  /**
3
3
  * A gas fee flow to facilitate testing in the clients.
4
4
  * Increments the total gas fee by a fixed amount each time it is called.
@@ -9,4 +9,4 @@ export declare class TestGasFeeFlow implements GasFeeFlow {
9
9
  matchesTransaction(): boolean;
10
10
  getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
11
11
  }
12
- //# sourceMappingURL=TestGasFeeFlow.d.ts.map
12
+ //# sourceMappingURL=TestGasFeeFlow.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestGasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/TestGasFeeFlow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,qBAAoB;AAKrB;;;;GAIG;AACH,qBAAa,cAAe,YAAW,UAAU;;IAG/C,kBAAkB,IAAI,OAAO;IAIvB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAuD1E"}
@@ -0,0 +1,12 @@
1
+ import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse } from "../types.mjs";
2
+ /**
3
+ * A gas fee flow to facilitate testing in the clients.
4
+ * Increments the total gas fee by a fixed amount each time it is called.
5
+ * Relies on the transaction's gas value to generate a distinct total fee in the UI.
6
+ */
7
+ export declare class TestGasFeeFlow implements GasFeeFlow {
8
+ #private;
9
+ matchesTransaction(): boolean;
10
+ getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
11
+ }
12
+ //# sourceMappingURL=TestGasFeeFlow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestGasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/TestGasFeeFlow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,qBAAoB;AAKrB;;;;GAIG;AACH,qBAAa,cAAe,YAAW,UAAU;;IAG/C,kBAAkB,IAAI,OAAO;IAIvB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAuD1E"}
@@ -10,8 +10,8 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
12
  var _TestGasFeeFlow_instances, _TestGasFeeFlow_counter, _TestGasFeeFlow_getValueForTotalFee;
13
- import { toHex } from '@metamask/controller-utils';
14
- import { GasFeeEstimateType } from '../types.js';
13
+ import { toHex } from "@metamask/controller-utils";
14
+ import { GasFeeEstimateType } from "../types.mjs";
15
15
  const INCREMENT = 1e15; // 0.001 ETH
16
16
  const LEVEL_DIFFERENCE = 0.5;
17
17
  /**
@@ -66,4 +66,4 @@ _TestGasFeeFlow_counter = new WeakMap(), _TestGasFeeFlow_instances = new WeakSet
66
66
  const feeDecimal = Math.ceil(totalFee / gas);
67
67
  return toHex(feeDecimal);
68
68
  };
69
- //# sourceMappingURL=TestGasFeeFlow.js.map
69
+ //# sourceMappingURL=TestGasFeeFlow.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/TestGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,mCAAmC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,qBAAoB;AAOjD,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,YAAY;AACpC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAA3B;;QACE,kCAAW,CAAC,EAAC;IA6Df,CAAC;IA3DC,kBAAkB;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;QACpC,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;QACrC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;QAEjC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK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AC;CAMF;uKAJsB,QAAgB,EAAE,GAAW;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;IAC7C,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { GasFeeEstimateType } from '../types.js';\nimport type {\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n} from '../types.js';\n\nconst INCREMENT = 1e15; // 0.001 ETH\nconst LEVEL_DIFFERENCE = 0.5;\n\n/**\n * A gas fee flow to facilitate testing in the clients.\n * Increments the total gas fee by a fixed amount each time it is called.\n * Relies on the transaction's gas value to generate a distinct total fee in the UI.\n */\nexport class TestGasFeeFlow implements GasFeeFlow {\n #counter = 1;\n\n matchesTransaction(): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n const { transactionMeta } = request;\n const { txParams } = transactionMeta;\n const { gas: gasHex } = txParams;\n\n if (!gasHex) {\n throw new Error('Cannot estimate fee without gas value');\n }\n\n const gasDecimal = parseInt(gasHex, 16);\n const difference = INCREMENT * LEVEL_DIFFERENCE;\n\n const mediumMaxTarget = (this.#counter + 1) * INCREMENT;\n const mediumPriorityTarget = this.#counter * INCREMENT;\n\n const lowMaxTarget = mediumMaxTarget - difference;\n const lowPriorityTarget = mediumPriorityTarget - difference;\n\n const highMaxTarget = mediumMaxTarget + difference;\n const highPriorityTarget = mediumPriorityTarget + difference;\n\n this.#counter += 1;\n\n return {\n estimates: {\n type: GasFeeEstimateType.FeeMarket,\n low: {\n maxFeePerGas: this.#getValueForTotalFee(lowMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n lowPriorityTarget,\n gasDecimal,\n ),\n },\n medium: {\n maxFeePerGas: this.#getValueForTotalFee(mediumMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n mediumPriorityTarget,\n gasDecimal,\n ),\n },\n high: {\n maxFeePerGas: this.#getValueForTotalFee(highMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n highPriorityTarget,\n gasDecimal,\n ),\n },\n },\n };\n }\n\n #getValueForTotalFee(totalFee: number, gas: number): Hex {\n const feeDecimal = Math.ceil(totalFee / gas);\n return toHex(feeDecimal);\n }\n}\n"]}