@metamask/transaction-controller 36.1.0 → 37.1.0

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 (480) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/dist/TransactionController.cjs +2071 -0
  3. package/dist/TransactionController.cjs.map +1 -0
  4. package/dist/{types/TransactionController.d.ts → TransactionController.d.cts} +19 -26
  5. package/dist/TransactionController.d.cts.map +1 -0
  6. package/dist/TransactionController.d.mts +828 -0
  7. package/dist/TransactionController.d.mts.map +1 -0
  8. package/dist/TransactionController.mjs +2072 -44
  9. package/dist/TransactionController.mjs.map +1 -1
  10. package/dist/constants.cjs +170 -0
  11. package/dist/constants.cjs.map +1 -0
  12. package/dist/{types/constants.d.ts → constants.d.cts} +1 -1
  13. package/dist/constants.d.cts.map +1 -0
  14. package/dist/constants.d.mts +143 -0
  15. package/dist/constants.d.mts.map +1 -0
  16. package/dist/constants.mjs +165 -18
  17. package/dist/constants.mjs.map +1 -1
  18. package/dist/errors.cjs +30 -0
  19. package/dist/{chunk-HMOSP33F.js.map → errors.cjs.map} +1 -1
  20. package/dist/{types/errors.d.ts → errors.d.cts} +2 -2
  21. package/dist/errors.d.cts.map +1 -0
  22. package/dist/errors.d.mts +15 -0
  23. package/dist/errors.d.mts.map +1 -0
  24. package/dist/errors.mjs +22 -14
  25. package/dist/errors.mjs.map +1 -1
  26. package/dist/gas-flows/DefaultGasFeeFlow.cjs +87 -0
  27. package/dist/gas-flows/DefaultGasFeeFlow.cjs.map +1 -0
  28. package/dist/{types/gas-flows/DefaultGasFeeFlow.d.ts → gas-flows/DefaultGasFeeFlow.d.cts} +2 -2
  29. package/dist/gas-flows/DefaultGasFeeFlow.d.cts.map +1 -0
  30. package/dist/gas-flows/DefaultGasFeeFlow.d.mts +10 -0
  31. package/dist/gas-flows/DefaultGasFeeFlow.d.mts.map +1 -0
  32. package/dist/gas-flows/DefaultGasFeeFlow.mjs +81 -13
  33. package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -1
  34. package/dist/gas-flows/LineaGasFeeFlow.cjs +102 -0
  35. package/dist/gas-flows/LineaGasFeeFlow.cjs.map +1 -0
  36. package/dist/{types/gas-flows/LineaGasFeeFlow.d.ts → gas-flows/LineaGasFeeFlow.d.cts} +2 -2
  37. package/dist/gas-flows/LineaGasFeeFlow.d.cts.map +1 -0
  38. package/dist/gas-flows/LineaGasFeeFlow.d.mts +12 -0
  39. package/dist/gas-flows/LineaGasFeeFlow.d.mts.map +1 -0
  40. package/dist/gas-flows/LineaGasFeeFlow.mjs +96 -14
  41. package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -1
  42. package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +29 -0
  43. package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -0
  44. package/dist/{types/gas-flows/OptimismLayer1GasFeeFlow.d.ts → gas-flows/OptimismLayer1GasFeeFlow.d.cts} +3 -3
  45. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -0
  46. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts +10 -0
  47. package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -0
  48. package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +24 -10
  49. package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -1
  50. package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +92 -0
  51. package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -0
  52. package/dist/{types/gas-flows/OracleLayer1GasFeeFlow.d.ts → gas-flows/OracleLayer1GasFeeFlow.d.cts} +3 -3
  53. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -0
  54. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts +12 -0
  55. package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -0
  56. package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs +88 -7
  57. package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -1
  58. package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +21 -0
  59. package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -0
  60. package/dist/{types/gas-flows/ScrollLayer1GasFeeFlow.d.ts → gas-flows/ScrollLayer1GasFeeFlow.d.cts} +3 -3
  61. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -0
  62. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts +10 -0
  63. package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -0
  64. package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs +16 -10
  65. package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -1
  66. package/dist/gas-flows/TestGasFeeFlow.cjs +73 -0
  67. package/dist/{chunk-FMRLPVFZ.mjs.map → gas-flows/TestGasFeeFlow.cjs.map} +1 -1
  68. package/dist/{types/gas-flows/TestGasFeeFlow.d.ts → gas-flows/TestGasFeeFlow.d.cts} +2 -2
  69. package/dist/gas-flows/TestGasFeeFlow.d.cts.map +1 -0
  70. package/dist/gas-flows/TestGasFeeFlow.d.mts +12 -0
  71. package/dist/gas-flows/TestGasFeeFlow.d.mts.map +1 -0
  72. package/dist/gas-flows/TestGasFeeFlow.mjs +67 -7
  73. package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -1
  74. package/dist/helpers/EtherscanRemoteTransactionSource.cjs +149 -0
  75. package/dist/helpers/EtherscanRemoteTransactionSource.cjs.map +1 -0
  76. package/dist/{types/helpers/EtherscanRemoteTransactionSource.d.ts → helpers/EtherscanRemoteTransactionSource.d.cts} +3 -3
  77. package/dist/helpers/EtherscanRemoteTransactionSource.d.cts.map +1 -0
  78. package/dist/helpers/EtherscanRemoteTransactionSource.d.mts +15 -0
  79. package/dist/helpers/EtherscanRemoteTransactionSource.d.mts.map +1 -0
  80. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +147 -10
  81. package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +1 -1
  82. package/dist/helpers/GasFeePoller.cjs +185 -0
  83. package/dist/helpers/GasFeePoller.cjs.map +1 -0
  84. package/dist/{types/helpers/GasFeePoller.d.ts → helpers/GasFeePoller.d.cts} +7 -7
  85. package/dist/helpers/GasFeePoller.d.cts.map +1 -0
  86. package/dist/helpers/GasFeePoller.d.mts +35 -0
  87. package/dist/helpers/GasFeePoller.d.mts.map +1 -0
  88. package/dist/helpers/GasFeePoller.mjs +183 -10
  89. package/dist/helpers/GasFeePoller.mjs.map +1 -1
  90. package/dist/helpers/IncomingTransactionHelper.cjs +199 -0
  91. package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -0
  92. package/dist/{types/helpers/IncomingTransactionHelper.d.ts → helpers/IncomingTransactionHelper.d.cts} +6 -6
  93. package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -0
  94. package/dist/helpers/IncomingTransactionHelper.d.mts +40 -0
  95. package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -0
  96. package/dist/helpers/IncomingTransactionHelper.mjs +190 -7
  97. package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
  98. package/dist/helpers/MultichainTrackingHelper.cjs +284 -0
  99. package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -0
  100. package/dist/{types/helpers/MultichainTrackingHelper.d.ts → helpers/MultichainTrackingHelper.d.cts} +8 -8
  101. package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -0
  102. package/dist/helpers/MultichainTrackingHelper.d.mts +76 -0
  103. package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -0
  104. package/dist/helpers/MultichainTrackingHelper.mjs +282 -11
  105. package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
  106. package/dist/helpers/PendingTransactionTracker.cjs +327 -0
  107. package/dist/helpers/PendingTransactionTracker.cjs.map +1 -0
  108. package/dist/{types/helpers/PendingTransactionTracker.d.ts → helpers/PendingTransactionTracker.d.cts} +7 -8
  109. package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -0
  110. package/dist/helpers/PendingTransactionTracker.d.mts +42 -0
  111. package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -0
  112. package/dist/helpers/PendingTransactionTracker.mjs +319 -8
  113. package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
  114. package/dist/index.cjs +32 -0
  115. package/dist/index.cjs.map +1 -0
  116. package/dist/{types/index.d.ts → index.d.cts} +11 -10
  117. package/dist/index.d.cts.map +1 -0
  118. package/dist/index.d.mts +11 -0
  119. package/dist/index.d.mts.map +1 -0
  120. package/dist/index.mjs +7 -76
  121. package/dist/index.mjs.map +1 -1
  122. package/dist/logger.cjs +9 -0
  123. package/dist/logger.cjs.map +1 -0
  124. package/dist/{types/logger.d.ts → logger.d.cts} +2 -2
  125. package/dist/logger.d.cts.map +1 -0
  126. package/dist/logger.d.mts +6 -0
  127. package/dist/logger.d.mts.map +1 -0
  128. package/dist/logger.mjs +5 -11
  129. package/dist/logger.mjs.map +1 -1
  130. package/dist/types.cjs +308 -0
  131. package/dist/types.cjs.map +1 -0
  132. package/dist/{types/types.d.ts → types.d.cts} +35 -35
  133. package/dist/types.d.cts.map +1 -0
  134. package/dist/types.d.mts +1027 -0
  135. package/dist/types.d.mts.map +1 -0
  136. package/dist/types.mjs +304 -23
  137. package/dist/types.mjs.map +1 -1
  138. package/dist/utils/etherscan.cjs +111 -0
  139. package/dist/utils/etherscan.cjs.map +1 -0
  140. package/dist/{types/utils/etherscan.d.ts → utils/etherscan.d.cts} +2 -2
  141. package/dist/utils/etherscan.d.cts.map +1 -0
  142. package/dist/utils/etherscan.d.mts +71 -0
  143. package/dist/utils/etherscan.d.mts.map +1 -0
  144. package/dist/utils/etherscan.mjs +104 -13
  145. package/dist/utils/etherscan.mjs.map +1 -1
  146. package/dist/utils/external-transactions.cjs +36 -0
  147. package/dist/utils/external-transactions.cjs.map +1 -0
  148. package/dist/{types/utils/external-transactions.d.ts → utils/external-transactions.d.cts} +2 -2
  149. package/dist/utils/external-transactions.d.cts.map +1 -0
  150. package/dist/utils/external-transactions.d.mts +10 -0
  151. package/dist/utils/external-transactions.d.mts.map +1 -0
  152. package/dist/utils/external-transactions.mjs +31 -8
  153. package/dist/utils/external-transactions.mjs.map +1 -1
  154. package/dist/utils/gas-fees.cjs +208 -0
  155. package/dist/utils/gas-fees.cjs.map +1 -0
  156. package/dist/{types/utils/gas-fees.d.ts → utils/gas-fees.d.cts} +5 -5
  157. package/dist/utils/gas-fees.d.cts.map +1 -0
  158. package/dist/utils/gas-fees.d.mts +26 -0
  159. package/dist/utils/gas-fees.d.mts.map +1 -0
  160. package/dist/utils/gas-fees.mjs +202 -15
  161. package/dist/utils/gas-fees.mjs.map +1 -1
  162. package/dist/utils/gas-flow.cjs +76 -0
  163. package/dist/utils/gas-flow.cjs.map +1 -0
  164. package/dist/{types/utils/gas-flow.d.ts → utils/gas-flow.d.cts} +5 -5
  165. package/dist/utils/gas-flow.d.cts.map +1 -0
  166. package/dist/utils/gas-flow.d.mts +26 -0
  167. package/dist/utils/gas-flow.d.mts.map +1 -0
  168. package/dist/utils/gas-flow.mjs +70 -10
  169. package/dist/utils/gas-flow.mjs.map +1 -1
  170. package/dist/utils/gas.cjs +112 -0
  171. package/dist/utils/gas.cjs.map +1 -0
  172. package/dist/{types/utils/gas.d.ts → utils/gas.d.cts} +4 -4
  173. package/dist/utils/gas.d.cts.map +1 -0
  174. package/dist/utils/gas.d.mts +28 -0
  175. package/dist/utils/gas.d.mts.map +1 -0
  176. package/dist/utils/gas.mjs +105 -19
  177. package/dist/utils/gas.mjs.map +1 -1
  178. package/dist/utils/history.cjs +164 -0
  179. package/dist/utils/history.cjs.map +1 -0
  180. package/dist/{types/utils/history.d.ts → utils/history.d.cts} +2 -2
  181. package/dist/utils/history.d.cts.map +1 -0
  182. package/dist/utils/history.d.mts +29 -0
  183. package/dist/utils/history.d.mts.map +1 -0
  184. package/dist/utils/history.mjs +163 -13
  185. package/dist/utils/history.mjs.map +1 -1
  186. package/dist/utils/layer1-gas-fee-flow.cjs +59 -0
  187. package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -0
  188. package/dist/{types/utils/layer1-gas-fee-flow.d.ts → utils/layer1-gas-fee-flow.d.cts} +4 -4
  189. package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -0
  190. package/dist/utils/layer1-gas-fee-flow.d.mts +25 -0
  191. package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -0
  192. package/dist/utils/layer1-gas-fee-flow.mjs +53 -10
  193. package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -1
  194. package/dist/utils/nonce.cjs +66 -0
  195. package/dist/utils/nonce.cjs.map +1 -0
  196. package/dist/{types/utils/nonce.d.ts → utils/nonce.d.cts} +3 -3
  197. package/dist/utils/nonce.d.cts.map +1 -0
  198. package/dist/utils/nonce.d.mts +21 -0
  199. package/dist/utils/nonce.d.mts.map +1 -0
  200. package/dist/utils/nonce.mjs +60 -10
  201. package/dist/utils/nonce.mjs.map +1 -1
  202. package/dist/utils/retry.cjs +89 -0
  203. package/dist/utils/retry.cjs.map +1 -0
  204. package/dist/{types/utils/retry.d.ts → utils/retry.d.cts} +3 -3
  205. package/dist/utils/retry.d.cts.map +1 -0
  206. package/dist/utils/retry.d.mts +11 -0
  207. package/dist/utils/retry.d.mts.map +1 -0
  208. package/dist/utils/retry.mjs +84 -7
  209. package/dist/utils/retry.mjs.map +1 -1
  210. package/dist/utils/simulation-api.cjs +72 -0
  211. package/dist/utils/simulation-api.cjs.map +1 -0
  212. package/dist/{types/utils/simulation-api.d.ts → utils/simulation-api.d.cts} +2 -2
  213. package/dist/utils/simulation-api.d.cts.map +1 -0
  214. package/dist/utils/simulation-api.d.mts +107 -0
  215. package/dist/utils/simulation-api.d.mts.map +1 -0
  216. package/dist/utils/simulation-api.mjs +67 -10
  217. package/dist/utils/simulation-api.mjs.map +1 -1
  218. package/dist/utils/simulation.cjs +443 -0
  219. package/dist/utils/simulation.cjs.map +1 -0
  220. package/dist/{types/utils/simulation.d.ts → utils/simulation.d.cts} +6 -6
  221. package/dist/utils/simulation.d.cts.map +1 -0
  222. package/dist/utils/simulation.d.mts +46 -0
  223. package/dist/utils/simulation.d.mts.map +1 -0
  224. package/dist/utils/simulation.mjs +436 -15
  225. package/dist/utils/simulation.mjs.map +1 -1
  226. package/dist/utils/swaps.cjs +309 -0
  227. package/dist/utils/swaps.cjs.map +1 -0
  228. package/dist/{types/utils/swaps.d.ts → utils/swaps.d.cts} +5 -5
  229. package/dist/utils/swaps.d.cts.map +1 -0
  230. package/dist/utils/swaps.d.mts +84 -0
  231. package/dist/utils/swaps.d.mts.map +1 -0
  232. package/dist/utils/swaps.mjs +303 -22
  233. package/dist/utils/swaps.mjs.map +1 -1
  234. package/dist/utils/transaction-type.cjs +115 -0
  235. package/dist/utils/transaction-type.cjs.map +1 -0
  236. package/dist/{types/utils/transaction-type.d.ts → utils/transaction-type.d.cts} +3 -3
  237. package/dist/utils/transaction-type.d.cts.map +1 -0
  238. package/dist/utils/transaction-type.d.mts +14 -0
  239. package/dist/utils/transaction-type.d.mts.map +1 -0
  240. package/dist/utils/transaction-type.mjs +110 -10
  241. package/dist/utils/transaction-type.mjs.map +1 -1
  242. package/dist/utils/utils.cjs +151 -0
  243. package/dist/utils/utils.cjs.map +1 -0
  244. package/dist/{types/utils/utils.d.ts → utils/utils.d.cts} +2 -2
  245. package/dist/utils/utils.d.cts.map +1 -0
  246. package/dist/utils/utils.d.mts +52 -0
  247. package/dist/utils/utils.d.mts.map +1 -0
  248. package/dist/utils/utils.mjs +139 -21
  249. package/dist/utils/utils.mjs.map +1 -1
  250. package/dist/utils/validation.cjs +267 -0
  251. package/dist/{chunk-4OYPDGHO.js.map → utils/validation.cjs.map} +1 -1
  252. package/dist/{types/utils/validation.d.ts → utils/validation.d.cts} +2 -2
  253. package/dist/utils/validation.d.cts.map +1 -0
  254. package/dist/utils/validation.d.mts +20 -0
  255. package/dist/utils/validation.d.mts.map +1 -0
  256. package/dist/utils/validation.mjs +261 -11
  257. package/dist/utils/validation.mjs.map +1 -1
  258. package/package.json +20 -15
  259. package/dist/TransactionController.js +0 -46
  260. package/dist/TransactionController.js.map +0 -1
  261. package/dist/chunk-2XKEAKQG.js +0 -55
  262. package/dist/chunk-2XKEAKQG.js.map +0 -1
  263. package/dist/chunk-3AVRGHUO.mjs +0 -360
  264. package/dist/chunk-3AVRGHUO.mjs.map +0 -1
  265. package/dist/chunk-3ZV5YEUV.mjs +0 -239
  266. package/dist/chunk-3ZV5YEUV.mjs.map +0 -1
  267. package/dist/chunk-4OYPDGHO.js +0 -201
  268. package/dist/chunk-4V4XIPCI.mjs +0 -338
  269. package/dist/chunk-4V4XIPCI.mjs.map +0 -1
  270. package/dist/chunk-5G6OHAXI.mjs +0 -137
  271. package/dist/chunk-5G6OHAXI.mjs.map +0 -1
  272. package/dist/chunk-5HYWLTVQ.js +0 -228
  273. package/dist/chunk-5HYWLTVQ.js.map +0 -1
  274. package/dist/chunk-5QVDIVJH.js +0 -68
  275. package/dist/chunk-5QVDIVJH.js.map +0 -1
  276. package/dist/chunk-6B5BEO3R.mjs +0 -399
  277. package/dist/chunk-6B5BEO3R.mjs.map +0 -1
  278. package/dist/chunk-6DDVVUJC.mjs +0 -50
  279. package/dist/chunk-6DDVVUJC.mjs.map +0 -1
  280. package/dist/chunk-6OLJWLKK.js +0 -338
  281. package/dist/chunk-6OLJWLKK.js.map +0 -1
  282. package/dist/chunk-7LXE4KHV.js +0 -40
  283. package/dist/chunk-7LXE4KHV.js.map +0 -1
  284. package/dist/chunk-7NMV2NPM.js +0 -172
  285. package/dist/chunk-7NMV2NPM.js.map +0 -1
  286. package/dist/chunk-AWIJZAW3.mjs +0 -112
  287. package/dist/chunk-AWIJZAW3.mjs.map +0 -1
  288. package/dist/chunk-BZV72SCF.js +0 -226
  289. package/dist/chunk-BZV72SCF.js.map +0 -1
  290. package/dist/chunk-EGQCE3FK.mjs +0 -85
  291. package/dist/chunk-EGQCE3FK.mjs.map +0 -1
  292. package/dist/chunk-EHWAY6XU.js +0 -112
  293. package/dist/chunk-EHWAY6XU.js.map +0 -1
  294. package/dist/chunk-EKJXGERC.mjs +0 -172
  295. package/dist/chunk-EKJXGERC.mjs.map +0 -1
  296. package/dist/chunk-FG74Z3F5.mjs +0 -102
  297. package/dist/chunk-FG74Z3F5.mjs.map +0 -1
  298. package/dist/chunk-FMRLPVFZ.mjs +0 -66
  299. package/dist/chunk-FRKQ3Z2L.mjs +0 -40
  300. package/dist/chunk-FRKQ3Z2L.mjs.map +0 -1
  301. package/dist/chunk-HMOSP33F.js +0 -36
  302. package/dist/chunk-HQSNKCXI.mjs +0 -36
  303. package/dist/chunk-HQSNKCXI.mjs.map +0 -1
  304. package/dist/chunk-JIFPK37W.mjs +0 -257
  305. package/dist/chunk-JIFPK37W.mjs.map +0 -1
  306. package/dist/chunk-JOQK7A5G.mjs +0 -68
  307. package/dist/chunk-JOQK7A5G.mjs.map +0 -1
  308. package/dist/chunk-K4KOSAGM.mjs +0 -61
  309. package/dist/chunk-K4KOSAGM.mjs.map +0 -1
  310. package/dist/chunk-KG4UW4K4.mjs +0 -88
  311. package/dist/chunk-KG4UW4K4.mjs.map +0 -1
  312. package/dist/chunk-KT6UAKBB.js +0 -61
  313. package/dist/chunk-KT6UAKBB.js.map +0 -1
  314. package/dist/chunk-KTGMNUTQ.js +0 -106
  315. package/dist/chunk-KTGMNUTQ.js.map +0 -1
  316. package/dist/chunk-KYRW4BLA.mjs +0 -121
  317. package/dist/chunk-KYRW4BLA.mjs.map +0 -1
  318. package/dist/chunk-LFFYCDHB.mjs +0 -92
  319. package/dist/chunk-LFFYCDHB.mjs.map +0 -1
  320. package/dist/chunk-NNCUD3QF.js +0 -360
  321. package/dist/chunk-NNCUD3QF.js.map +0 -1
  322. package/dist/chunk-NNHSNPT2.mjs +0 -67
  323. package/dist/chunk-NNHSNPT2.mjs.map +0 -1
  324. package/dist/chunk-NOHEXQ7Y.mjs +0 -55
  325. package/dist/chunk-NOHEXQ7Y.mjs.map +0 -1
  326. package/dist/chunk-NYKRCWBG.js +0 -31
  327. package/dist/chunk-NYKRCWBG.js.map +0 -1
  328. package/dist/chunk-O6ZZVIFH.mjs +0 -176
  329. package/dist/chunk-O6ZZVIFH.mjs.map +0 -1
  330. package/dist/chunk-PRUNMTRD.js +0 -50
  331. package/dist/chunk-PRUNMTRD.js.map +0 -1
  332. package/dist/chunk-PSZ34BI5.js +0 -92
  333. package/dist/chunk-PSZ34BI5.js.map +0 -1
  334. package/dist/chunk-QKV7E5BO.js +0 -257
  335. package/dist/chunk-QKV7E5BO.js.map +0 -1
  336. package/dist/chunk-RHDPOIS4.js +0 -239
  337. package/dist/chunk-RHDPOIS4.js.map +0 -1
  338. package/dist/chunk-S6VGOPUY.js +0 -14
  339. package/dist/chunk-S6VGOPUY.js.map +0 -1
  340. package/dist/chunk-SD6CWFDF.js +0 -88
  341. package/dist/chunk-SD6CWFDF.js.map +0 -1
  342. package/dist/chunk-SFFOC25Q.mjs +0 -226
  343. package/dist/chunk-SFFOC25Q.mjs.map +0 -1
  344. package/dist/chunk-SMC5Q6ZH.mjs +0 -120
  345. package/dist/chunk-SMC5Q6ZH.mjs.map +0 -1
  346. package/dist/chunk-TIE3CPF7.js +0 -120
  347. package/dist/chunk-TIE3CPF7.js.map +0 -1
  348. package/dist/chunk-TJMQEH57.js +0 -66
  349. package/dist/chunk-TJMQEH57.js.map +0 -1
  350. package/dist/chunk-UGN7PBON.js +0 -176
  351. package/dist/chunk-UGN7PBON.js.map +0 -1
  352. package/dist/chunk-UHAFIPSL.js +0 -121
  353. package/dist/chunk-UHAFIPSL.js.map +0 -1
  354. package/dist/chunk-UHSRHP55.mjs +0 -106
  355. package/dist/chunk-UHSRHP55.mjs.map +0 -1
  356. package/dist/chunk-ULD4JC3Q.js +0 -399
  357. package/dist/chunk-ULD4JC3Q.js.map +0 -1
  358. package/dist/chunk-UQQWZT6C.mjs +0 -14
  359. package/dist/chunk-UQQWZT6C.mjs.map +0 -1
  360. package/dist/chunk-V72C4MCR.js +0 -137
  361. package/dist/chunk-V72C4MCR.js.map +0 -1
  362. package/dist/chunk-VEVVBHP3.mjs +0 -31
  363. package/dist/chunk-VEVVBHP3.mjs.map +0 -1
  364. package/dist/chunk-VGFPVAKX.mjs +0 -228
  365. package/dist/chunk-VGFPVAKX.mjs.map +0 -1
  366. package/dist/chunk-VKWOHNDO.js +0 -2509
  367. package/dist/chunk-VKWOHNDO.js.map +0 -1
  368. package/dist/chunk-WR5F34OW.js +0 -23
  369. package/dist/chunk-WR5F34OW.js.map +0 -1
  370. package/dist/chunk-X4XSEYPL.mjs +0 -201
  371. package/dist/chunk-X4XSEYPL.mjs.map +0 -1
  372. package/dist/chunk-XTMJ25EF.mjs +0 -2509
  373. package/dist/chunk-XTMJ25EF.mjs.map +0 -1
  374. package/dist/chunk-XUI43LEZ.mjs +0 -30
  375. package/dist/chunk-XUI43LEZ.mjs.map +0 -1
  376. package/dist/chunk-XVYXRCRL.js +0 -85
  377. package/dist/chunk-XVYXRCRL.js.map +0 -1
  378. package/dist/chunk-YVCX6Z75.js +0 -102
  379. package/dist/chunk-YVCX6Z75.js.map +0 -1
  380. package/dist/chunk-YWLMT7XH.js +0 -67
  381. package/dist/chunk-YWLMT7XH.js.map +0 -1
  382. package/dist/chunk-Z4BLTVTB.js +0 -30
  383. package/dist/chunk-Z4BLTVTB.js.map +0 -1
  384. package/dist/chunk-Z4GV3YQQ.mjs +0 -23
  385. package/dist/chunk-Z4GV3YQQ.mjs.map +0 -1
  386. package/dist/constants.js +0 -20
  387. package/dist/constants.js.map +0 -1
  388. package/dist/errors.js +0 -15
  389. package/dist/errors.js.map +0 -1
  390. package/dist/gas-flows/DefaultGasFeeFlow.js +0 -15
  391. package/dist/gas-flows/DefaultGasFeeFlow.js.map +0 -1
  392. package/dist/gas-flows/LineaGasFeeFlow.js +0 -16
  393. package/dist/gas-flows/LineaGasFeeFlow.js.map +0 -1
  394. package/dist/gas-flows/OptimismLayer1GasFeeFlow.js +0 -11
  395. package/dist/gas-flows/OptimismLayer1GasFeeFlow.js.map +0 -1
  396. package/dist/gas-flows/OracleLayer1GasFeeFlow.js +0 -9
  397. package/dist/gas-flows/OracleLayer1GasFeeFlow.js.map +0 -1
  398. package/dist/gas-flows/ScrollLayer1GasFeeFlow.js +0 -11
  399. package/dist/gas-flows/ScrollLayer1GasFeeFlow.js.map +0 -1
  400. package/dist/gas-flows/TestGasFeeFlow.js +0 -9
  401. package/dist/gas-flows/TestGasFeeFlow.js.map +0 -1
  402. package/dist/helpers/EtherscanRemoteTransactionSource.js +0 -12
  403. package/dist/helpers/EtherscanRemoteTransactionSource.js.map +0 -1
  404. package/dist/helpers/GasFeePoller.js +0 -12
  405. package/dist/helpers/GasFeePoller.js.map +0 -1
  406. package/dist/helpers/IncomingTransactionHelper.js +0 -9
  407. package/dist/helpers/IncomingTransactionHelper.js.map +0 -1
  408. package/dist/helpers/MultichainTrackingHelper.js +0 -13
  409. package/dist/helpers/MultichainTrackingHelper.js.map +0 -1
  410. package/dist/helpers/PendingTransactionTracker.js +0 -10
  411. package/dist/helpers/PendingTransactionTracker.js.map +0 -1
  412. package/dist/index.js +0 -77
  413. package/dist/index.js.map +0 -1
  414. package/dist/logger.js +0 -12
  415. package/dist/logger.js.map +0 -1
  416. package/dist/tsconfig.build.tsbuildinfo +0 -1
  417. package/dist/types/TransactionController.d.ts.map +0 -1
  418. package/dist/types/constants.d.ts.map +0 -1
  419. package/dist/types/errors.d.ts.map +0 -1
  420. package/dist/types/gas-flows/DefaultGasFeeFlow.d.ts.map +0 -1
  421. package/dist/types/gas-flows/LineaGasFeeFlow.d.ts.map +0 -1
  422. package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +0 -1
  423. package/dist/types/gas-flows/OracleLayer1GasFeeFlow.d.ts.map +0 -1
  424. package/dist/types/gas-flows/ScrollLayer1GasFeeFlow.d.ts.map +0 -1
  425. package/dist/types/gas-flows/TestGasFeeFlow.d.ts.map +0 -1
  426. package/dist/types/helpers/EtherscanRemoteTransactionSource.d.ts.map +0 -1
  427. package/dist/types/helpers/GasFeePoller.d.ts.map +0 -1
  428. package/dist/types/helpers/IncomingTransactionHelper.d.ts.map +0 -1
  429. package/dist/types/helpers/MultichainTrackingHelper.d.ts.map +0 -1
  430. package/dist/types/helpers/PendingTransactionTracker.d.ts.map +0 -1
  431. package/dist/types/index.d.ts.map +0 -1
  432. package/dist/types/logger.d.ts.map +0 -1
  433. package/dist/types/types.d.ts.map +0 -1
  434. package/dist/types/utils/etherscan.d.ts.map +0 -1
  435. package/dist/types/utils/external-transactions.d.ts.map +0 -1
  436. package/dist/types/utils/gas-fees.d.ts.map +0 -1
  437. package/dist/types/utils/gas-flow.d.ts.map +0 -1
  438. package/dist/types/utils/gas.d.ts.map +0 -1
  439. package/dist/types/utils/history.d.ts.map +0 -1
  440. package/dist/types/utils/layer1-gas-fee-flow.d.ts.map +0 -1
  441. package/dist/types/utils/nonce.d.ts.map +0 -1
  442. package/dist/types/utils/retry.d.ts.map +0 -1
  443. package/dist/types/utils/simulation-api.d.ts.map +0 -1
  444. package/dist/types/utils/simulation.d.ts.map +0 -1
  445. package/dist/types/utils/swaps.d.ts.map +0 -1
  446. package/dist/types/utils/transaction-type.d.ts.map +0 -1
  447. package/dist/types/utils/utils.d.ts.map +0 -1
  448. package/dist/types/utils/validation.d.ts.map +0 -1
  449. package/dist/types.js +0 -24
  450. package/dist/types.js.map +0 -1
  451. package/dist/utils/etherscan.js +0 -14
  452. package/dist/utils/etherscan.js.map +0 -1
  453. package/dist/utils/external-transactions.js +0 -9
  454. package/dist/utils/external-transactions.js.map +0 -1
  455. package/dist/utils/gas-fees.js +0 -16
  456. package/dist/utils/gas-fees.js.map +0 -1
  457. package/dist/utils/gas-flow.js +0 -11
  458. package/dist/utils/gas-flow.js.map +0 -1
  459. package/dist/utils/gas.js +0 -20
  460. package/dist/utils/gas.js.map +0 -1
  461. package/dist/utils/history.js +0 -14
  462. package/dist/utils/history.js.map +0 -1
  463. package/dist/utils/layer1-gas-fee-flow.js +0 -11
  464. package/dist/utils/layer1-gas-fee-flow.js.map +0 -1
  465. package/dist/utils/nonce.js +0 -11
  466. package/dist/utils/nonce.js.map +0 -1
  467. package/dist/utils/retry.js +0 -8
  468. package/dist/utils/retry.js.map +0 -1
  469. package/dist/utils/simulation-api.js +0 -11
  470. package/dist/utils/simulation-api.js.map +0 -1
  471. package/dist/utils/simulation.js +0 -17
  472. package/dist/utils/simulation.js.map +0 -1
  473. package/dist/utils/swaps.js +0 -24
  474. package/dist/utils/swaps.js.map +0 -1
  475. package/dist/utils/transaction-type.js +0 -11
  476. package/dist/utils/transaction-type.js.map +0 -1
  477. package/dist/utils/utils.js +0 -23
  478. package/dist/utils/utils.js.map +0 -1
  479. package/dist/utils/validation.js +0 -12
  480. package/dist/utils/validation.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OracleLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,uCAAoD;AACpD,wDAAoD;AACpD,wDAA+E;AAE/E,2CAAqD;AACrD,mCAA8B;AAE9B,0CAA0C;AAQ1C,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,4BAA4B,CAAC,CAAC;AAE5E,MAAM,SAAS,GACb,kEAAkE,CAAC;AAErE,MAAM,oBAAoB,GAAG;IAC3B;QACE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACjE,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACjE,eAAe,EAAE,MAA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IAAI,yFAAwB,MAA5B,IAAI,EAAyB,eAAe,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,uBAAA,IAAI,yFAAwB,MAA5B,IAAI,EAAyB,eAAe,CAAC,CAAC;IAE7D,IAAI,uBAAuB,GAAG,uBAAkB,CAAC,UAAU,CAAC,QAAQ,EAAE;QACpE,MAAM;KACP,CAAC,CAAC;IAEH,IAAI,IAAI,EAAE;QACR,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAChD,uBAAuB,GAAG,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACnE;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC,2GAGC,eAAgC;IAEhC,OAAO;QACL,GAAG,IAAA,aAAI,EAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC;QACxC,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG;KACvC,CAAC;AACJ,CAAC,2GAEuB,eAAgC;IACtD,MAAM,OAAO,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAEhD,OAAO,eAAM,CAAC,MAAM,CAAC;QACnB,OAAO;QACP,eAAe,EAAE,iBAAQ,CAAC,MAAM;KACjC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Common, Hardfork } from '@ethereumjs/common';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport { Contract } from '@ethersproject/contracts';\nimport { Web3Provider, type ExternalProvider } from '@ethersproject/providers';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport { omit } from 'lodash';\n\nimport { projectLogger } from '../logger';\nimport type {\n Layer1GasFeeFlow,\n Layer1GasFeeFlowRequest,\n Layer1GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\n\nconst log = createModuleLogger(projectLogger, 'oracle-layer1-gas-fee-flow');\n\nconst DUMMY_KEY =\n 'abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789';\n\nconst GAS_PRICE_ORACLE_ABI = [\n {\n inputs: [{ internalType: 'bytes', name: '_data', type: 'bytes' }],\n name: 'getL1Fee',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n];\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 #oracleAddress: Hex;\n\n #signTransaction: boolean;\n\n constructor(oracleAddress: Hex, signTransaction?: boolean) {\n this.#oracleAddress = oracleAddress;\n this.#signTransaction = signTransaction ?? false;\n }\n\n abstract matchesTransaction(transactionMeta: TransactionMeta): boolean;\n\n async getLayer1Fee(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n try {\n return await this.#getOracleLayer1GasFee(request);\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(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n const { provider, transactionMeta } = request;\n\n const contract = new Contract(\n this.#oracleAddress,\n GAS_PRICE_ORACLE_ABI,\n // Network controller provider type is incompatible with ethers provider\n new Web3Provider(provider as unknown as ExternalProvider),\n );\n\n const serializedTransaction = this.#buildUnserializedTransaction(\n transactionMeta,\n this.#signTransaction,\n ).serialize();\n\n const result = await contract.getL1Fee(serializedTransaction);\n\n if (result === undefined) {\n throw new Error('No value returned from oracle contract');\n }\n\n return {\n layer1Fee: result.toHexString(),\n };\n }\n\n #buildUnserializedTransaction(\n transactionMeta: TransactionMeta,\n sign: boolean,\n ) {\n const txParams = this.#buildTransactionParams(transactionMeta);\n const common = this.#buildTransactionCommon(transactionMeta);\n\n let unserializedTransaction = TransactionFactory.fromTxData(txParams, {\n common,\n });\n\n if (sign) {\n const keyBuffer = Buffer.from(DUMMY_KEY, 'hex');\n unserializedTransaction = unserializedTransaction.sign(keyBuffer);\n }\n\n return unserializedTransaction;\n }\n\n #buildTransactionParams(\n transactionMeta: TransactionMeta,\n ): TransactionMeta['txParams'] {\n return {\n ...omit(transactionMeta.txParams, 'gas'),\n gasLimit: transactionMeta.txParams.gas,\n };\n }\n\n #buildTransactionCommon(transactionMeta: TransactionMeta) {\n const chainId = Number(transactionMeta.chainId);\n\n return Common.custom({\n chainId,\n defaultHardfork: Hardfork.London,\n });\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Hex } from '@metamask/utils';
2
- import type { Layer1GasFeeFlow, Layer1GasFeeFlowRequest, Layer1GasFeeFlowResponse, TransactionMeta } from '../types';
1
+ import type { Hex } from "@metamask/utils";
2
+ import type { Layer1GasFeeFlow, Layer1GasFeeFlowRequest, Layer1GasFeeFlowResponse, TransactionMeta } from "../types.cjs";
3
3
  /**
4
4
  * Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.
5
5
  */
@@ -9,4 +9,4 @@ export declare abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow
9
9
  abstract matchesTransaction(transactionMeta: TransactionMeta): boolean;
10
10
  getLayer1Fee(request: Layer1GasFeeFlowRequest): Promise<Layer1GasFeeFlowResponse>;
11
11
  }
12
- //# sourceMappingURL=OracleLayer1GasFeeFlow.d.ts.map
12
+ //# sourceMappingURL=OracleLayer1GasFeeFlow.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OracleLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAK3C,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EAChB,qBAAiB;AAiBlB;;GAEG;AACH,8BAAsB,sBAAuB,YAAW,gBAAgB;;gBAK1D,aAAa,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,OAAO;IAKzD,QAAQ,CAAC,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAEhE,YAAY,CAChB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC;CAyErC"}
@@ -0,0 +1,12 @@
1
+ import type { Hex } from "@metamask/utils";
2
+ import type { Layer1GasFeeFlow, Layer1GasFeeFlowRequest, Layer1GasFeeFlowResponse, TransactionMeta } from "../types.mjs";
3
+ /**
4
+ * Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.
5
+ */
6
+ export declare abstract class OracleLayer1GasFeeFlow implements Layer1GasFeeFlow {
7
+ #private;
8
+ constructor(oracleAddress: Hex, signTransaction?: boolean);
9
+ abstract matchesTransaction(transactionMeta: TransactionMeta): boolean;
10
+ getLayer1Fee(request: Layer1GasFeeFlowRequest): Promise<Layer1GasFeeFlowResponse>;
11
+ }
12
+ //# sourceMappingURL=OracleLayer1GasFeeFlow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OracleLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAK3C,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EAChB,qBAAiB;AAiBlB;;GAEG;AACH,8BAAsB,sBAAuB,YAAW,gBAAgB;;gBAK1D,aAAa,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,OAAO;IAKzD,QAAQ,CAAC,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAEhE,YAAY,CAChB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,wBAAwB,CAAC;CAyErC"}
@@ -1,9 +1,90 @@
1
- import {
2
- OracleLayer1GasFeeFlow
3
- } from "../chunk-FG74Z3F5.mjs";
4
- import "../chunk-UQQWZT6C.mjs";
5
- import "../chunk-XUI43LEZ.mjs";
6
- export {
7
- OracleLayer1GasFeeFlow
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _OracleLayer1GasFeeFlow_instances, _OracleLayer1GasFeeFlow_oracleAddress, _OracleLayer1GasFeeFlow_signTransaction, _OracleLayer1GasFeeFlow_getOracleLayer1GasFee, _OracleLayer1GasFeeFlow_buildUnserializedTransaction, _OracleLayer1GasFeeFlow_buildTransactionParams, _OracleLayer1GasFeeFlow_buildTransactionCommon;
13
+ import $ethereumjscommon from "@ethereumjs/common";
14
+ const { Common, Hardfork } = $ethereumjscommon;
15
+ import { TransactionFactory } from "@ethereumjs/tx";
16
+ import { Contract } from "@ethersproject/contracts";
17
+ import { Web3Provider } from "@ethersproject/providers";
18
+ import { createModuleLogger } from "@metamask/utils";
19
+ import $lodash from "lodash";
20
+ const { omit } = $lodash;
21
+ import { projectLogger } from "../logger.mjs";
22
+ const log = createModuleLogger(projectLogger, 'oracle-layer1-gas-fee-flow');
23
+ const DUMMY_KEY = 'abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789';
24
+ const GAS_PRICE_ORACLE_ABI = [
25
+ {
26
+ inputs: [{ internalType: 'bytes', name: '_data', type: 'bytes' }],
27
+ name: 'getL1Fee',
28
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
29
+ stateMutability: 'view',
30
+ type: 'function',
31
+ },
32
+ ];
33
+ /**
34
+ * Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.
35
+ */
36
+ export class OracleLayer1GasFeeFlow {
37
+ constructor(oracleAddress, signTransaction) {
38
+ _OracleLayer1GasFeeFlow_instances.add(this);
39
+ _OracleLayer1GasFeeFlow_oracleAddress.set(this, void 0);
40
+ _OracleLayer1GasFeeFlow_signTransaction.set(this, void 0);
41
+ __classPrivateFieldSet(this, _OracleLayer1GasFeeFlow_oracleAddress, oracleAddress, "f");
42
+ __classPrivateFieldSet(this, _OracleLayer1GasFeeFlow_signTransaction, signTransaction ?? false, "f");
43
+ }
44
+ async getLayer1Fee(request) {
45
+ try {
46
+ return await __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_instances, "m", _OracleLayer1GasFeeFlow_getOracleLayer1GasFee).call(this, request);
47
+ }
48
+ catch (error) {
49
+ log('Failed to get oracle layer 1 gas fee', error);
50
+ throw new Error(`Failed to get oracle layer 1 gas fee`);
51
+ }
52
+ }
53
+ }
54
+ _OracleLayer1GasFeeFlow_oracleAddress = new WeakMap(), _OracleLayer1GasFeeFlow_signTransaction = new WeakMap(), _OracleLayer1GasFeeFlow_instances = new WeakSet(), _OracleLayer1GasFeeFlow_getOracleLayer1GasFee = async function _OracleLayer1GasFeeFlow_getOracleLayer1GasFee(request) {
55
+ const { provider, transactionMeta } = request;
56
+ const contract = new Contract(__classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_oracleAddress, "f"), GAS_PRICE_ORACLE_ABI,
57
+ // Network controller provider type is incompatible with ethers provider
58
+ new Web3Provider(provider));
59
+ const serializedTransaction = __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_instances, "m", _OracleLayer1GasFeeFlow_buildUnserializedTransaction).call(this, transactionMeta, __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_signTransaction, "f")).serialize();
60
+ const result = await contract.getL1Fee(serializedTransaction);
61
+ if (result === undefined) {
62
+ throw new Error('No value returned from oracle contract');
63
+ }
64
+ return {
65
+ layer1Fee: result.toHexString(),
66
+ };
67
+ }, _OracleLayer1GasFeeFlow_buildUnserializedTransaction = function _OracleLayer1GasFeeFlow_buildUnserializedTransaction(transactionMeta, sign) {
68
+ const txParams = __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_instances, "m", _OracleLayer1GasFeeFlow_buildTransactionParams).call(this, transactionMeta);
69
+ const common = __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_instances, "m", _OracleLayer1GasFeeFlow_buildTransactionCommon).call(this, transactionMeta);
70
+ let unserializedTransaction = TransactionFactory.fromTxData(txParams, {
71
+ common,
72
+ });
73
+ if (sign) {
74
+ const keyBuffer = Buffer.from(DUMMY_KEY, 'hex');
75
+ unserializedTransaction = unserializedTransaction.sign(keyBuffer);
76
+ }
77
+ return unserializedTransaction;
78
+ }, _OracleLayer1GasFeeFlow_buildTransactionParams = function _OracleLayer1GasFeeFlow_buildTransactionParams(transactionMeta) {
79
+ return {
80
+ ...omit(transactionMeta.txParams, 'gas'),
81
+ gasLimit: transactionMeta.txParams.gas,
82
+ };
83
+ }, _OracleLayer1GasFeeFlow_buildTransactionCommon = function _OracleLayer1GasFeeFlow_buildTransactionCommon(transactionMeta) {
84
+ const chainId = Number(transactionMeta.chainId);
85
+ return Common.custom({
86
+ chainId,
87
+ defaultHardfork: Hardfork.London,
88
+ });
8
89
  };
9
90
  //# sourceMappingURL=OracleLayer1GasFeeFlow.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"OracleLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/OracleLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,uB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C,OAAO,CAAC,CAAC;IAEhD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO;QACP,eAAe,EAAE,QAAQ,CAAC,MAAM;KACjC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Common, Hardfork } from '@ethereumjs/common';\nimport { TransactionFactory } from '@ethereumjs/tx';\nimport { Contract } from '@ethersproject/contracts';\nimport { Web3Provider, type ExternalProvider } from '@ethersproject/providers';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport { omit } from 'lodash';\n\nimport { projectLogger } from '../logger';\nimport type {\n Layer1GasFeeFlow,\n Layer1GasFeeFlowRequest,\n Layer1GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\n\nconst log = createModuleLogger(projectLogger, 'oracle-layer1-gas-fee-flow');\n\nconst DUMMY_KEY =\n 'abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789';\n\nconst GAS_PRICE_ORACLE_ABI = [\n {\n inputs: [{ internalType: 'bytes', name: '_data', type: 'bytes' }],\n name: 'getL1Fee',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n];\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 #oracleAddress: Hex;\n\n #signTransaction: boolean;\n\n constructor(oracleAddress: Hex, signTransaction?: boolean) {\n this.#oracleAddress = oracleAddress;\n this.#signTransaction = signTransaction ?? false;\n }\n\n abstract matchesTransaction(transactionMeta: TransactionMeta): boolean;\n\n async getLayer1Fee(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n try {\n return await this.#getOracleLayer1GasFee(request);\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(\n request: Layer1GasFeeFlowRequest,\n ): Promise<Layer1GasFeeFlowResponse> {\n const { provider, transactionMeta } = request;\n\n const contract = new Contract(\n this.#oracleAddress,\n GAS_PRICE_ORACLE_ABI,\n // Network controller provider type is incompatible with ethers provider\n new Web3Provider(provider as unknown as ExternalProvider),\n );\n\n const serializedTransaction = this.#buildUnserializedTransaction(\n transactionMeta,\n this.#signTransaction,\n ).serialize();\n\n const result = await contract.getL1Fee(serializedTransaction);\n\n if (result === undefined) {\n throw new Error('No value returned from oracle contract');\n }\n\n return {\n layer1Fee: result.toHexString(),\n };\n }\n\n #buildUnserializedTransaction(\n transactionMeta: TransactionMeta,\n sign: boolean,\n ) {\n const txParams = this.#buildTransactionParams(transactionMeta);\n const common = this.#buildTransactionCommon(transactionMeta);\n\n let unserializedTransaction = TransactionFactory.fromTxData(txParams, {\n common,\n });\n\n if (sign) {\n const keyBuffer = Buffer.from(DUMMY_KEY, 'hex');\n unserializedTransaction = unserializedTransaction.sign(keyBuffer);\n }\n\n return unserializedTransaction;\n }\n\n #buildTransactionParams(\n transactionMeta: TransactionMeta,\n ): TransactionMeta['txParams'] {\n return {\n ...omit(transactionMeta.txParams, 'gas'),\n gasLimit: transactionMeta.txParams.gas,\n };\n }\n\n #buildTransactionCommon(transactionMeta: TransactionMeta) {\n const chainId = Number(transactionMeta.chainId);\n\n return Common.custom({\n chainId,\n defaultHardfork: Hardfork.London,\n });\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScrollLayer1GasFeeFlow = void 0;
4
+ const constants_1 = require("../constants.cjs");
5
+ const OracleLayer1GasFeeFlow_1 = require("./OracleLayer1GasFeeFlow.cjs");
6
+ const SCROLL_CHAIN_IDS = [constants_1.CHAIN_IDS.SCROLL, constants_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_1.OracleLayer1GasFeeFlow {
13
+ constructor() {
14
+ super(SCROLL_GAS_PRICE_ORACLE_ADDRESS, true);
15
+ }
16
+ matchesTransaction(transactionMeta) {
17
+ return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);
18
+ }
19
+ }
20
+ exports.ScrollLayer1GasFeeFlow = ScrollLayer1GasFeeFlow;
21
+ //# sourceMappingURL=ScrollLayer1GasFeeFlow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;AAEA,gDAAyC;AAEzC,yEAAkE;AAElE,MAAM,gBAAgB,GAAU,CAAC,qBAAS,CAAC,MAAM,EAAE,qBAAS,CAAC,cAAc,CAAC,CAAC;AAE7E,qGAAqG;AACrG,MAAM,+BAA+B,GACnC,4CAA4C,CAAC;AAE/C;;GAEG;AACH,MAAa,sBAAuB,SAAQ,+CAAsB;IAChE;QACE,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,OAAO,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF;AARD,wDAQC","sourcesContent":["import { type Hex } from '@metamask/utils';\n\nimport { CHAIN_IDS } from '../constants';\nimport type { TransactionMeta } from '../types';\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow';\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';\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 constructor() {\n super(SCROLL_GAS_PRICE_ORACLE_ADDRESS, true);\n }\n\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { TransactionMeta } from '../types';
2
- import { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow';
1
+ import type { TransactionMeta } from "../types.cjs";
2
+ import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.cjs";
3
3
  /**
4
4
  * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
5
5
  */
@@ -7,4 +7,4 @@ export declare class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
7
7
  constructor();
8
8
  matchesTransaction(transactionMeta: TransactionMeta): boolean;
9
9
  }
10
- //# sourceMappingURL=ScrollLayer1GasFeeFlow.d.ts.map
10
+ //# sourceMappingURL=ScrollLayer1GasFeeFlow.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAiB;AAChD,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAQlE;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,sBAAsB;;IAKhE,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;CAG9D"}
@@ -0,0 +1,10 @@
1
+ import type { TransactionMeta } from "../types.mjs";
2
+ import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.mjs";
3
+ /**
4
+ * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
5
+ */
6
+ export declare class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
7
+ constructor();
8
+ matchesTransaction(transactionMeta: TransactionMeta): boolean;
9
+ }
10
+ //# sourceMappingURL=ScrollLayer1GasFeeFlow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScrollLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAiB;AAChD,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAQlE;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,sBAAsB;;IAKhE,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;CAG9D"}
@@ -1,11 +1,17 @@
1
- import {
2
- ScrollLayer1GasFeeFlow
3
- } from "../chunk-Z4GV3YQQ.mjs";
4
- import "../chunk-FG74Z3F5.mjs";
5
- import "../chunk-O6ZZVIFH.mjs";
6
- import "../chunk-UQQWZT6C.mjs";
7
- import "../chunk-XUI43LEZ.mjs";
8
- export {
9
- ScrollLayer1GasFeeFlow
10
- };
1
+ import { CHAIN_IDS } from "../constants.mjs";
2
+ import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.mjs";
3
+ const SCROLL_CHAIN_IDS = [CHAIN_IDS.SCROLL, CHAIN_IDS.SCROLL_SEPOLIA];
4
+ // BlockExplorer link: https://scrollscan.com/address/0x5300000000000000000000000000000000000002#code
5
+ const SCROLL_GAS_PRICE_ORACLE_ADDRESS = '0x5300000000000000000000000000000000000002';
6
+ /**
7
+ * Scroll layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
8
+ */
9
+ export class ScrollLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
10
+ constructor() {
11
+ super(SCROLL_GAS_PRICE_ORACLE_ADDRESS, true);
12
+ }
13
+ matchesTransaction(transactionMeta) {
14
+ return SCROLL_CHAIN_IDS.includes(transactionMeta.chainId);
15
+ }
16
+ }
11
17
  //# sourceMappingURL=ScrollLayer1GasFeeFlow.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"ScrollLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/ScrollLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,yBAAqB;AAEzC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,MAAM,gBAAgB,GAAU,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;AAE7E,qGAAqG;AACrG,MAAM,+BAA+B,GACnC,4CAA4C,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,sBAAsB;IAChE;QACE,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,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';\nimport type { TransactionMeta } from '../types';\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow';\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';\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 constructor() {\n super(SCROLL_GAS_PRICE_ORACLE_ADDRESS, true);\n }\n\n matchesTransaction(transactionMeta: TransactionMeta): 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_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(_transactionMeta) {
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_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.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/gas-flows/TestGasFeeFlow.ts"],"sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport {\n GasFeeEstimateType,\n type GasFeeFlow,\n type GasFeeFlowRequest,\n type GasFeeFlowResponse,\n type TransactionMeta,\n} from '../types';\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(_transactionMeta: TransactionMeta): 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"],"mappings":";;;;;;;;AAAA,SAAS,aAAa;AAWtB,IAAM,YAAY;AAClB,IAAM,mBAAmB;AAZzB;AAmBO,IAAM,iBAAN,MAA2C;AAAA,EAA3C;AA0DL;AAzDA,iCAAW;AAAA;AAAA,EAEX,mBAAmB,kBAA4C;AAC7D,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,SAAyD;AACxE,UAAM,EAAE,gBAAgB,IAAI;AAC5B,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM,EAAE,KAAK,OAAO,IAAI;AAExB,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,uCAAuC;AAAA,IACzD;AAEA,UAAM,aAAa,SAAS,QAAQ,EAAE;AACtC,UAAM,aAAa,YAAY;AAE/B,UAAM,mBAAmB,mBAAK,YAAW,KAAK;AAC9C,UAAM,uBAAuB,mBAAK,YAAW;AAE7C,UAAM,eAAe,kBAAkB;AACvC,UAAM,oBAAoB,uBAAuB;AAEjD,UAAM,gBAAgB,kBAAkB;AACxC,UAAM,qBAAqB,uBAAuB;AAElD,uBAAK,UAAL,mBAAK,YAAY;AAEjB,WAAO;AAAA,MACL,WAAW;AAAA,QACT;AAAA,QACA,KA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I,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 {\n GasFeeEstimateType,\n type GasFeeFlow,\n type GasFeeFlowRequest,\n type GasFeeFlowResponse,\n type TransactionMeta,\n} from '../types';\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(_transactionMeta: TransactionMeta): 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, type GasFeeFlowRequest, type GasFeeFlowResponse, type TransactionMeta } from '../types';
1
+ import { type GasFeeFlow, type GasFeeFlowRequest, type GasFeeFlowResponse, type TransactionMeta } 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(_transactionMeta: TransactionMeta): 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":"AAGA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,qBAAiB;AAKlB;;;;GAIG;AACH,qBAAa,cAAe,YAAW,UAAU;;IAG/C,kBAAkB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO;IAIxD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAuD1E"}
@@ -0,0 +1,12 @@
1
+ import { type GasFeeFlow, type GasFeeFlowRequest, type GasFeeFlowResponse, type TransactionMeta } 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(_transactionMeta: TransactionMeta): 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":"AAGA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,qBAAiB;AAKlB;;;;GAIG;AACH,qBAAa,cAAe,YAAW,UAAU;;IAG/C,kBAAkB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO;IAIxD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAuD1E"}
@@ -1,9 +1,69 @@
1
- import {
2
- TestGasFeeFlow
3
- } from "../chunk-FMRLPVFZ.mjs";
4
- import "../chunk-LFFYCDHB.mjs";
5
- import "../chunk-XUI43LEZ.mjs";
6
- export {
7
- TestGasFeeFlow
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ 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");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ 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");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _TestGasFeeFlow_instances, _TestGasFeeFlow_counter, _TestGasFeeFlow_getValueForTotalFee;
13
+ import { toHex } from "@metamask/controller-utils";
14
+ import { GasFeeEstimateType } from "../types.mjs";
15
+ const INCREMENT = 1e15; // 0.001 ETH
16
+ const LEVEL_DIFFERENCE = 0.5;
17
+ /**
18
+ * A gas fee flow to facilitate testing in the clients.
19
+ * Increments the total gas fee by a fixed amount each time it is called.
20
+ * Relies on the transaction's gas value to generate a distinct total fee in the UI.
21
+ */
22
+ export class TestGasFeeFlow {
23
+ constructor() {
24
+ _TestGasFeeFlow_instances.add(this);
25
+ _TestGasFeeFlow_counter.set(this, 1);
26
+ }
27
+ matchesTransaction(_transactionMeta) {
28
+ return true;
29
+ }
30
+ async getGasFees(request) {
31
+ const { transactionMeta } = request;
32
+ const { txParams } = transactionMeta;
33
+ const { gas: gasHex } = txParams;
34
+ if (!gasHex) {
35
+ throw new Error('Cannot estimate fee without gas value');
36
+ }
37
+ const gasDecimal = parseInt(gasHex, 16);
38
+ const difference = INCREMENT * LEVEL_DIFFERENCE;
39
+ const mediumMaxTarget = (__classPrivateFieldGet(this, _TestGasFeeFlow_counter, "f") + 1) * INCREMENT;
40
+ const mediumPriorityTarget = __classPrivateFieldGet(this, _TestGasFeeFlow_counter, "f") * INCREMENT;
41
+ const lowMaxTarget = mediumMaxTarget - difference;
42
+ const lowPriorityTarget = mediumPriorityTarget - difference;
43
+ const highMaxTarget = mediumMaxTarget + difference;
44
+ const highPriorityTarget = mediumPriorityTarget + difference;
45
+ __classPrivateFieldSet(this, _TestGasFeeFlow_counter, __classPrivateFieldGet(this, _TestGasFeeFlow_counter, "f") + 1, "f");
46
+ return {
47
+ estimates: {
48
+ type: GasFeeEstimateType.FeeMarket,
49
+ low: {
50
+ maxFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, lowMaxTarget, gasDecimal),
51
+ maxPriorityFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, lowPriorityTarget, gasDecimal),
52
+ },
53
+ medium: {
54
+ maxFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, mediumMaxTarget, gasDecimal),
55
+ maxPriorityFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, mediumPriorityTarget, gasDecimal),
56
+ },
57
+ high: {
58
+ maxFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, highMaxTarget, gasDecimal),
59
+ maxPriorityFeePerGas: __classPrivateFieldGet(this, _TestGasFeeFlow_instances, "m", _TestGasFeeFlow_getValueForTotalFee).call(this, highPriorityTarget, gasDecimal),
60
+ },
61
+ },
62
+ };
63
+ }
64
+ }
65
+ _TestGasFeeFlow_counter = new WeakMap(), _TestGasFeeFlow_instances = new WeakSet(), _TestGasFeeFlow_getValueForTotalFee = function _TestGasFeeFlow_getValueForTotalFee(totalFee, gas) {
66
+ const feeDecimal = Math.ceil(totalFee / gas);
67
+ return toHex(feeDecimal);
8
68
  };
9
69
  //# sourceMappingURL=TestGasFeeFlow.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"TestGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/TestGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,mCAAmC;AAGnD,OAAO,EACL,kBAAkB,EAKnB,qBAAiB;AAElB,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,YAAY;AACpC,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;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;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 {\n GasFeeEstimateType,\n type GasFeeFlow,\n type GasFeeFlowRequest,\n type GasFeeFlowResponse,\n type TransactionMeta,\n} from '../types';\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(_transactionMeta: TransactionMeta): 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"]}