@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
@@ -1,15 +1,83 @@
1
- import {
2
- DefaultGasFeeFlow
3
- } from "../chunk-AWIJZAW3.mjs";
4
- import "../chunk-SFFOC25Q.mjs";
5
- import "../chunk-JIFPK37W.mjs";
6
- import "../chunk-UHSRHP55.mjs";
7
- import "../chunk-NNHSNPT2.mjs";
8
- import "../chunk-O6ZZVIFH.mjs";
9
- import "../chunk-UQQWZT6C.mjs";
10
- import "../chunk-LFFYCDHB.mjs";
11
- import "../chunk-XUI43LEZ.mjs";
12
- export {
13
- DefaultGasFeeFlow
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 _DefaultGasFeeFlow_instances, _DefaultGasFeeFlow_getFeeMarkEstimates, _DefaultGasFeeFlow_getLegacyEstimates, _DefaultGasFeeFlow_getGasPriceEstimates, _DefaultGasFeeFlow_getFeeMarketLevel, _DefaultGasFeeFlow_getLegacyLevel;
7
+ import { GAS_ESTIMATE_TYPES } from "@metamask/gas-fee-controller";
8
+ import { createModuleLogger } from "@metamask/utils";
9
+ import { projectLogger } from "../logger.mjs";
10
+ import { GasFeeEstimateLevel, GasFeeEstimateType } from "../types.mjs";
11
+ import { gweiDecimalToWeiHex } from "../utils/gas-fees.mjs";
12
+ const log = createModuleLogger(projectLogger, 'default-gas-fee-flow');
13
+ /**
14
+ * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.
15
+ */
16
+ export class DefaultGasFeeFlow {
17
+ constructor() {
18
+ _DefaultGasFeeFlow_instances.add(this);
19
+ }
20
+ matchesTransaction(_transactionMeta) {
21
+ return true;
22
+ }
23
+ async getGasFees(request) {
24
+ const { gasFeeControllerData } = request;
25
+ const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;
26
+ let response;
27
+ switch (gasEstimateType) {
28
+ case GAS_ESTIMATE_TYPES.FEE_MARKET:
29
+ log('Using fee market estimates', gasFeeEstimates);
30
+ response = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getFeeMarkEstimates).call(this, gasFeeEstimates);
31
+ break;
32
+ case GAS_ESTIMATE_TYPES.LEGACY:
33
+ log('Using legacy estimates', gasFeeEstimates);
34
+ response = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getLegacyEstimates).call(this, gasFeeEstimates);
35
+ break;
36
+ case GAS_ESTIMATE_TYPES.ETH_GASPRICE:
37
+ log('Using eth_gasPrice estimates', gasFeeEstimates);
38
+ response = __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getGasPriceEstimates).call(this, gasFeeEstimates);
39
+ break;
40
+ default:
41
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
42
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
43
+ throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);
44
+ }
45
+ return {
46
+ estimates: response,
47
+ };
48
+ }
49
+ }
50
+ _DefaultGasFeeFlow_instances = new WeakSet(), _DefaultGasFeeFlow_getFeeMarkEstimates = function _DefaultGasFeeFlow_getFeeMarkEstimates(gasFeeEstimates) {
51
+ const levels = Object.values(GasFeeEstimateLevel).reduce((result, level) => ({
52
+ ...result,
53
+ [level]: __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getFeeMarketLevel).call(this, gasFeeEstimates, level),
54
+ }), {});
55
+ return {
56
+ type: GasFeeEstimateType.FeeMarket,
57
+ ...levels,
58
+ };
59
+ }, _DefaultGasFeeFlow_getLegacyEstimates = function _DefaultGasFeeFlow_getLegacyEstimates(gasFeeEstimates) {
60
+ const levels = Object.values(GasFeeEstimateLevel).reduce((result, level) => ({
61
+ ...result,
62
+ [level]: __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getLegacyLevel).call(this, gasFeeEstimates, level),
63
+ }), {});
64
+ return {
65
+ type: GasFeeEstimateType.Legacy,
66
+ ...levels,
67
+ };
68
+ }, _DefaultGasFeeFlow_getGasPriceEstimates = function _DefaultGasFeeFlow_getGasPriceEstimates(gasFeeEstimates) {
69
+ return {
70
+ type: GasFeeEstimateType.GasPrice,
71
+ gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice),
72
+ };
73
+ }, _DefaultGasFeeFlow_getFeeMarketLevel = function _DefaultGasFeeFlow_getFeeMarketLevel(gasFeeEstimates, level) {
74
+ const maxFeePerGas = gweiDecimalToWeiHex(gasFeeEstimates[level].suggestedMaxFeePerGas);
75
+ const maxPriorityFeePerGas = gweiDecimalToWeiHex(gasFeeEstimates[level].suggestedMaxPriorityFeePerGas);
76
+ return {
77
+ maxFeePerGas,
78
+ maxPriorityFeePerGas,
79
+ };
80
+ }, _DefaultGasFeeFlow_getLegacyLevel = function _DefaultGasFeeFlow_getLegacyLevel(gasFeeEstimates, level) {
81
+ return gweiDecimalToWeiHex(gasFeeEstimates[level]);
14
82
  };
15
83
  //# sourceMappingURL=DefaultGasFeeFlow.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"DefaultGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,kBAAkB,EAAE,qCAAqC;AAElE,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAErD,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAY1C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,qBAAiB;AACnE,OAAO,EAAE,mBAAmB,EAAE,8BAA0B;AAExD,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAA9B;;IA0GA,CAAC;IAzGC,kBAAkB,CAAC,gBAAiC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC;QACzC,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,GAAG,oBAAoB,CAAC;QAElE,IAAI,QAAyB,CAAC;QAE9B,QAAQ,eAAe,EAAE;YACvB,KAAK,kBAAkB,CAAC,UAAU;gBAChC,GAAG,CAAC,4BAA4B,EAAE,eAAe,CAAC,CAAC;gBACnD,QAAQ,GAAG,uBAAA,IAAI,4EAAqB,MAAzB,IAAI,EAAsB,eAAe,CAAC,CAAC;gBACtD,MAAM;YACR,KAAK,kBAAkB,CAAC,MAAM;gBAC5B,GAAG,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAC;gBAC/C,QAAQ,GAAG,uBAAA,IAAI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AAC,QAAQ;QACjC,QAAQ,EAAE,mBAAmB,CAAC,eAAe,CAAC,QAAQ,CAAC;KACxD,CAAC;AACJ,CAAC,uFAGC,eAA0C,EAC1C,KAA0B;IAE1B,MAAM,YAAY,GAAG,mBAAmB,CACtC,eAAe,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAC7C,CAAC;IAEF,MAAM,oBAAoB,GAAG,mBAAmB,CAC9C,eAAe,CAAC,KAAK,CAAC,CAAC,6BAA6B,CACrD,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,oBAAoB;KACrB,CAAC;AACJ,CAAC,iFAGC,eAAuC,EACvC,KAA0B;IAE1B,OAAO,mBAAmB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import type {\n LegacyGasPriceEstimate,\n GasFeeEstimates as FeeMarketGasPriceEstimate,\n EthGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n GasPriceGasFeeEstimates,\n LegacyGasFeeEstimates,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\nimport { gweiDecimalToWeiHex } from '../utils/gas-fees';\n\nconst log = createModuleLogger(projectLogger, 'default-gas-fee-flow');\n\n/**\n * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.\n */\nexport class DefaultGasFeeFlow implements GasFeeFlow {\n matchesTransaction(_transactionMeta: TransactionMeta): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n const { gasFeeControllerData } = request;\n const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;\n\n let response: GasFeeEstimates;\n\n switch (gasEstimateType) {\n case GAS_ESTIMATE_TYPES.FEE_MARKET:\n log('Using fee market estimates', gasFeeEstimates);\n response = this.#getFeeMarkEstimates(gasFeeEstimates);\n break;\n case GAS_ESTIMATE_TYPES.LEGACY:\n log('Using legacy estimates', gasFeeEstimates);\n response = this.#getLegacyEstimates(\n gasFeeEstimates as LegacyGasPriceEstimate,\n );\n break;\n case GAS_ESTIMATE_TYPES.ETH_GASPRICE:\n log('Using eth_gasPrice estimates', gasFeeEstimates);\n response = this.#getGasPriceEstimates(\n gasFeeEstimates as EthGasPriceEstimate,\n );\n break;\n default:\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);\n }\n\n return {\n estimates: response,\n };\n }\n\n #getFeeMarkEstimates(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n ): FeeMarketGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getFeeMarketLevel(gasFeeEstimates, level),\n }),\n {} as Omit<FeeMarketGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.FeeMarket,\n ...levels,\n };\n }\n\n #getLegacyEstimates(\n gasFeeEstimates: LegacyGasPriceEstimate,\n ): LegacyGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getLegacyLevel(gasFeeEstimates, level),\n }),\n {} as Omit<LegacyGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.Legacy,\n ...levels,\n };\n }\n\n #getGasPriceEstimates(\n gasFeeEstimates: EthGasPriceEstimate,\n ): GasPriceGasFeeEstimates {\n return {\n type: GasFeeEstimateType.GasPrice,\n gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice),\n };\n }\n\n #getFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): FeeMarketGasFeeEstimateForLevel {\n const maxFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n );\n\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n }\n\n #getLegacyLevel(\n gasFeeEstimates: LegacyGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): Hex {\n return gweiDecimalToWeiHex(gasFeeEstimates[level]);\n }\n}\n"]}
@@ -0,0 +1,102 @@
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 _LineaGasFeeFlow_instances, _LineaGasFeeFlow_getLineaGasFees, _LineaGasFeeFlow_getLineaResponse, _LineaGasFeeFlow_getValuesFromMultipliers, _LineaGasFeeFlow_getMaxFees, _LineaGasFeeFlow_feesToString;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LineaGasFeeFlow = void 0;
10
+ const controller_utils_1 = require("@metamask/controller-utils");
11
+ const utils_1 = require("@metamask/utils");
12
+ const logger_1 = require("../logger.cjs");
13
+ const types_1 = require("../types.cjs");
14
+ const DefaultGasFeeFlow_1 = require("./DefaultGasFeeFlow.cjs");
15
+ const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'linea-gas-fee-flow');
16
+ const LINEA_CHAIN_IDS = [
17
+ controller_utils_1.ChainId['linea-mainnet'],
18
+ controller_utils_1.ChainId['linea-goerli'],
19
+ controller_utils_1.ChainId['linea-sepolia'],
20
+ ];
21
+ const BASE_FEE_MULTIPLIERS = {
22
+ low: 1,
23
+ medium: 1.35,
24
+ high: 1.7,
25
+ };
26
+ const PRIORITY_FEE_MULTIPLIERS = {
27
+ low: 1,
28
+ medium: 1.05,
29
+ high: 1.1,
30
+ };
31
+ /**
32
+ * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:
33
+ * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.
34
+ * - Static multipliers to increase the base and priority fees.
35
+ */
36
+ class LineaGasFeeFlow {
37
+ constructor() {
38
+ _LineaGasFeeFlow_instances.add(this);
39
+ }
40
+ matchesTransaction(transactionMeta) {
41
+ return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);
42
+ }
43
+ async getGasFees(request) {
44
+ try {
45
+ return await __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaGasFees).call(this, request);
46
+ }
47
+ catch (error) {
48
+ log('Using default flow as fallback due to error', error);
49
+ return new DefaultGasFeeFlow_1.DefaultGasFeeFlow().getGasFees(request);
50
+ }
51
+ }
52
+ }
53
+ exports.LineaGasFeeFlow = LineaGasFeeFlow;
54
+ _LineaGasFeeFlow_instances = new WeakSet(), _LineaGasFeeFlow_getLineaGasFees = async function _LineaGasFeeFlow_getLineaGasFees(request) {
55
+ const { ethQuery, transactionMeta } = request;
56
+ const lineaResponse = await __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaResponse).call(this, transactionMeta, ethQuery);
57
+ log('Received Linea response', lineaResponse);
58
+ const baseFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.baseFeePerGas, BASE_FEE_MULTIPLIERS);
59
+ log('Generated base fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, baseFees));
60
+ const priorityFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.priorityFeePerGas, PRIORITY_FEE_MULTIPLIERS);
61
+ log('Generated priority fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, priorityFees));
62
+ const maxFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getMaxFees).call(this, baseFees, priorityFees);
63
+ log('Generated max fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, maxFees));
64
+ const estimates = Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => ({
65
+ ...result,
66
+ [level]: {
67
+ maxFeePerGas: (0, controller_utils_1.toHex)(maxFees[level]),
68
+ maxPriorityFeePerGas: (0, controller_utils_1.toHex)(priorityFees[level]),
69
+ },
70
+ }), { type: types_1.GasFeeEstimateType.FeeMarket });
71
+ return { estimates };
72
+ }, _LineaGasFeeFlow_getLineaResponse = function _LineaGasFeeFlow_getLineaResponse(transactionMeta, ethQuery) {
73
+ return (0, controller_utils_1.query)(ethQuery, 'linea_estimateGas', [
74
+ {
75
+ from: transactionMeta.txParams.from,
76
+ to: transactionMeta.txParams.to,
77
+ value: transactionMeta.txParams.value,
78
+ input: transactionMeta.txParams.data,
79
+ // Required in request but no impact on response.
80
+ gasPrice: '0x100000000',
81
+ },
82
+ ]);
83
+ }, _LineaGasFeeFlow_getValuesFromMultipliers = function _LineaGasFeeFlow_getValuesFromMultipliers(value, multipliers) {
84
+ const base = (0, controller_utils_1.hexToBN)(value);
85
+ const low = base.muln(multipliers.low);
86
+ const medium = base.muln(multipliers.medium);
87
+ const high = base.muln(multipliers.high);
88
+ return {
89
+ low,
90
+ medium,
91
+ high,
92
+ };
93
+ }, _LineaGasFeeFlow_getMaxFees = function _LineaGasFeeFlow_getMaxFees(baseFees, priorityFees) {
94
+ return {
95
+ low: baseFees.low.add(priorityFees.low),
96
+ medium: baseFees.medium.add(priorityFees.medium),
97
+ high: baseFees.high.add(priorityFees.high),
98
+ };
99
+ }, _LineaGasFeeFlow_feesToString = function _LineaGasFeeFlow_feesToString(fees) {
100
+ return Object.values(types_1.GasFeeEstimateLevel).map((level) => fees[level].toString(10));
101
+ };
102
+ //# sourceMappingURL=LineaGasFeeFlow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineaGasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;AAAA,iEAA4E;AAE5E,2CAA+D;AAG/D,0CAA0C;AAQ1C,wCAAmE;AACnE,+DAAwD;AAWxD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,oBAAoB,CAAC,CAAC;AAEpE,MAAM,eAAe,GAAU;IAC7B,0BAAO,CAAC,eAAe,CAAC;IACxB,0BAAO,CAAC,cAAc,CAAC;IACvB,0BAAO,CAAC,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,GAAG;CACV,CAAC;AAEF,MAAM,wBAAwB,GAAG;IAC/B,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,GAAG;CACV,CAAC;AAEF;;;;GAIG;AACH,MAAa,eAAe;IAA5B;;IA0GA,CAAC;IAzGC,kBAAkB,CAAC,eAAgC;QACjD,OAAO,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAA0B;QACzC,IAAI;YACF,OAAO,MAAM,uBAAA,IAAI,oEAAiB,MAArB,IAAI,EAAkB,OAAO,CAAC,CAAC;SAC7C;QAAC,OAAO,KAAK,EAAE;YACd,GAAG,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC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,CAAC,yEAEa,IAAiB;IAC7B,OAAO,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACtD,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { ChainId, hexToBN, query, toHex } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\nimport type BN from 'bn.js';\n\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\nimport { DefaultGasFeeFlow } from './DefaultGasFeeFlow';\n\ntype LineaEstimateGasResponse = {\n baseFeePerGas: Hex;\n priorityFeePerGas: Hex;\n};\n\ntype FeesByLevel = {\n [key in GasFeeEstimateLevel]: BN;\n};\n\nconst log = createModuleLogger(projectLogger, 'linea-gas-fee-flow');\n\nconst LINEA_CHAIN_IDS: Hex[] = [\n ChainId['linea-mainnet'],\n ChainId['linea-goerli'],\n ChainId['linea-sepolia'],\n];\n\nconst BASE_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.35,\n high: 1.7,\n};\n\nconst PRIORITY_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.05,\n high: 1.1,\n};\n\n/**\n * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:\n * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.\n * - Static multipliers to increase the base and priority fees.\n */\nexport class LineaGasFeeFlow implements GasFeeFlow {\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n try {\n return await this.#getLineaGasFees(request);\n } catch (error) {\n log('Using default flow as fallback due to error', error);\n return new DefaultGasFeeFlow().getGasFees(request);\n }\n }\n\n async #getLineaGasFees(\n request: GasFeeFlowRequest,\n ): Promise<GasFeeFlowResponse> {\n const { ethQuery, transactionMeta } = request;\n\n const lineaResponse = await this.#getLineaResponse(\n transactionMeta,\n ethQuery,\n );\n\n log('Received Linea response', lineaResponse);\n\n const baseFees = this.#getValuesFromMultipliers(\n lineaResponse.baseFeePerGas,\n BASE_FEE_MULTIPLIERS,\n );\n\n log('Generated base fees', this.#feesToString(baseFees));\n\n const priorityFees = this.#getValuesFromMultipliers(\n lineaResponse.priorityFeePerGas,\n PRIORITY_FEE_MULTIPLIERS,\n );\n\n log('Generated priority fees', this.#feesToString(priorityFees));\n\n const maxFees = this.#getMaxFees(baseFees, priorityFees);\n\n log('Generated max fees', this.#feesToString(maxFees));\n\n const estimates = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: {\n maxFeePerGas: toHex(maxFees[level]),\n maxPriorityFeePerGas: toHex(priorityFees[level]),\n },\n }),\n { type: GasFeeEstimateType.FeeMarket } as GasFeeEstimates,\n );\n\n return { estimates };\n }\n\n #getLineaResponse(\n transactionMeta: TransactionMeta,\n ethQuery: EthQuery,\n ): Promise<LineaEstimateGasResponse> {\n return query(ethQuery, 'linea_estimateGas', [\n {\n from: transactionMeta.txParams.from,\n to: transactionMeta.txParams.to,\n value: transactionMeta.txParams.value,\n input: transactionMeta.txParams.data,\n // Required in request but no impact on response.\n gasPrice: '0x100000000',\n },\n ]);\n }\n\n #getValuesFromMultipliers(\n value: Hex,\n multipliers: { low: number; medium: number; high: number },\n ): FeesByLevel {\n const base = hexToBN(value);\n const low = base.muln(multipliers.low);\n const medium = base.muln(multipliers.medium);\n const high = base.muln(multipliers.high);\n\n return {\n low,\n medium,\n high,\n };\n }\n\n #getMaxFees(\n baseFees: Record<GasFeeEstimateLevel, BN>,\n priorityFees: Record<GasFeeEstimateLevel, BN>,\n ): FeesByLevel {\n return {\n low: baseFees.low.add(priorityFees.low),\n medium: baseFees.medium.add(priorityFees.medium),\n high: baseFees.high.add(priorityFees.high),\n };\n }\n\n #feesToString(fees: FeesByLevel) {\n return Object.values(GasFeeEstimateLevel).map((level) =>\n fees[level].toString(10),\n );\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from '../types';
1
+ import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from "../types.cjs";
2
2
  /**
3
3
  * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:
4
4
  * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.
@@ -9,4 +9,4 @@ export declare class LineaGasFeeFlow implements GasFeeFlow {
9
9
  matchesTransaction(transactionMeta: TransactionMeta): boolean;
10
10
  getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
11
11
  }
12
- //# sourceMappingURL=LineaGasFeeFlow.d.ts.map
12
+ //# sourceMappingURL=LineaGasFeeFlow.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineaGasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,qBAAiB;AAiClB;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,UAAU;;IAChD,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAIvD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAqG1E"}
@@ -0,0 +1,12 @@
1
+ import type { GasFeeFlow, GasFeeFlowRequest, GasFeeFlowResponse, TransactionMeta } from "../types.mjs";
2
+ /**
3
+ * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:
4
+ * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.
5
+ * - Static multipliers to increase the base and priority fees.
6
+ */
7
+ export declare class LineaGasFeeFlow implements GasFeeFlow {
8
+ #private;
9
+ matchesTransaction(transactionMeta: TransactionMeta): boolean;
10
+ getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse>;
11
+ }
12
+ //# sourceMappingURL=LineaGasFeeFlow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineaGasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAChB,qBAAiB;AAiClB;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,UAAU;;IAChD,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;IAIvD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAqG1E"}
@@ -1,16 +1,98 @@
1
- import {
2
- LineaGasFeeFlow
3
- } from "../chunk-KYRW4BLA.mjs";
4
- import "../chunk-AWIJZAW3.mjs";
5
- import "../chunk-SFFOC25Q.mjs";
6
- import "../chunk-JIFPK37W.mjs";
7
- import "../chunk-UHSRHP55.mjs";
8
- import "../chunk-NNHSNPT2.mjs";
9
- import "../chunk-O6ZZVIFH.mjs";
10
- import "../chunk-UQQWZT6C.mjs";
11
- import "../chunk-LFFYCDHB.mjs";
12
- import "../chunk-XUI43LEZ.mjs";
13
- export {
14
- LineaGasFeeFlow
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 _LineaGasFeeFlow_instances, _LineaGasFeeFlow_getLineaGasFees, _LineaGasFeeFlow_getLineaResponse, _LineaGasFeeFlow_getValuesFromMultipliers, _LineaGasFeeFlow_getMaxFees, _LineaGasFeeFlow_feesToString;
7
+ import { ChainId, hexToBN, query, toHex } from "@metamask/controller-utils";
8
+ import { createModuleLogger } from "@metamask/utils";
9
+ import { projectLogger } from "../logger.mjs";
10
+ import { GasFeeEstimateLevel, GasFeeEstimateType } from "../types.mjs";
11
+ import { DefaultGasFeeFlow } from "./DefaultGasFeeFlow.mjs";
12
+ const log = createModuleLogger(projectLogger, 'linea-gas-fee-flow');
13
+ const LINEA_CHAIN_IDS = [
14
+ ChainId['linea-mainnet'],
15
+ ChainId['linea-goerli'],
16
+ ChainId['linea-sepolia'],
17
+ ];
18
+ const BASE_FEE_MULTIPLIERS = {
19
+ low: 1,
20
+ medium: 1.35,
21
+ high: 1.7,
22
+ };
23
+ const PRIORITY_FEE_MULTIPLIERS = {
24
+ low: 1,
25
+ medium: 1.05,
26
+ high: 1.1,
27
+ };
28
+ /**
29
+ * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:
30
+ * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.
31
+ * - Static multipliers to increase the base and priority fees.
32
+ */
33
+ export class LineaGasFeeFlow {
34
+ constructor() {
35
+ _LineaGasFeeFlow_instances.add(this);
36
+ }
37
+ matchesTransaction(transactionMeta) {
38
+ return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);
39
+ }
40
+ async getGasFees(request) {
41
+ try {
42
+ return await __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaGasFees).call(this, request);
43
+ }
44
+ catch (error) {
45
+ log('Using default flow as fallback due to error', error);
46
+ return new DefaultGasFeeFlow().getGasFees(request);
47
+ }
48
+ }
49
+ }
50
+ _LineaGasFeeFlow_instances = new WeakSet(), _LineaGasFeeFlow_getLineaGasFees = async function _LineaGasFeeFlow_getLineaGasFees(request) {
51
+ const { ethQuery, transactionMeta } = request;
52
+ const lineaResponse = await __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaResponse).call(this, transactionMeta, ethQuery);
53
+ log('Received Linea response', lineaResponse);
54
+ const baseFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.baseFeePerGas, BASE_FEE_MULTIPLIERS);
55
+ log('Generated base fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, baseFees));
56
+ const priorityFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.priorityFeePerGas, PRIORITY_FEE_MULTIPLIERS);
57
+ log('Generated priority fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, priorityFees));
58
+ const maxFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getMaxFees).call(this, baseFees, priorityFees);
59
+ log('Generated max fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, maxFees));
60
+ const estimates = Object.values(GasFeeEstimateLevel).reduce((result, level) => ({
61
+ ...result,
62
+ [level]: {
63
+ maxFeePerGas: toHex(maxFees[level]),
64
+ maxPriorityFeePerGas: toHex(priorityFees[level]),
65
+ },
66
+ }), { type: GasFeeEstimateType.FeeMarket });
67
+ return { estimates };
68
+ }, _LineaGasFeeFlow_getLineaResponse = function _LineaGasFeeFlow_getLineaResponse(transactionMeta, ethQuery) {
69
+ return query(ethQuery, 'linea_estimateGas', [
70
+ {
71
+ from: transactionMeta.txParams.from,
72
+ to: transactionMeta.txParams.to,
73
+ value: transactionMeta.txParams.value,
74
+ input: transactionMeta.txParams.data,
75
+ // Required in request but no impact on response.
76
+ gasPrice: '0x100000000',
77
+ },
78
+ ]);
79
+ }, _LineaGasFeeFlow_getValuesFromMultipliers = function _LineaGasFeeFlow_getValuesFromMultipliers(value, multipliers) {
80
+ const base = hexToBN(value);
81
+ const low = base.muln(multipliers.low);
82
+ const medium = base.muln(multipliers.medium);
83
+ const high = base.muln(multipliers.high);
84
+ return {
85
+ low,
86
+ medium,
87
+ high,
88
+ };
89
+ }, _LineaGasFeeFlow_getMaxFees = function _LineaGasFeeFlow_getMaxFees(baseFees, priorityFees) {
90
+ return {
91
+ low: baseFees.low.add(priorityFees.low),
92
+ medium: baseFees.medium.add(priorityFees.medium),
93
+ high: baseFees.high.add(priorityFees.high),
94
+ };
95
+ }, _LineaGasFeeFlow_feesToString = function _LineaGasFeeFlow_feesToString(fees) {
96
+ return Object.values(GasFeeEstimateLevel).map((level) => fees[level].toString(10));
15
97
  };
16
98
  //# sourceMappingURL=LineaGasFeeFlow.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"LineaGasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/LineaGasFeeFlow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,mCAAmC;AAE5E,OAAO,EAAE,kBAAkB,EAAY,wBAAwB;AAG/D,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAQ1C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,qBAAiB;AACnE,OAAO,EAAE,iBAAiB,EAAE,gCAA4B;AAWxD,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;AAEpE,MAAM,eAAe,GAAU;IAC7B,OAAO,CAAC,eAAe,CAAC;IACxB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,CAAC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AAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEzC,OAAO;QACL,GAAG;QACH,MAAM;QACN,IAAI;KACL,CAAC;AACJ,CAAC,qEAGC,QAAyC,EACzC,YAA6C;IAE7C,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC;QACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC;QAChD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;KAC3C,CAAC;AACJ,CAAC,yEAEa,IAAiB;IAC7B,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACtD,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { ChainId, hexToBN, query, toHex } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\nimport type BN from 'bn.js';\n\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\nimport { DefaultGasFeeFlow } from './DefaultGasFeeFlow';\n\ntype LineaEstimateGasResponse = {\n baseFeePerGas: Hex;\n priorityFeePerGas: Hex;\n};\n\ntype FeesByLevel = {\n [key in GasFeeEstimateLevel]: BN;\n};\n\nconst log = createModuleLogger(projectLogger, 'linea-gas-fee-flow');\n\nconst LINEA_CHAIN_IDS: Hex[] = [\n ChainId['linea-mainnet'],\n ChainId['linea-goerli'],\n ChainId['linea-sepolia'],\n];\n\nconst BASE_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.35,\n high: 1.7,\n};\n\nconst PRIORITY_FEE_MULTIPLIERS = {\n low: 1,\n medium: 1.05,\n high: 1.1,\n};\n\n/**\n * Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:\n * - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.\n * - Static multipliers to increase the base and priority fees.\n */\nexport class LineaGasFeeFlow implements GasFeeFlow {\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n try {\n return await this.#getLineaGasFees(request);\n } catch (error) {\n log('Using default flow as fallback due to error', error);\n return new DefaultGasFeeFlow().getGasFees(request);\n }\n }\n\n async #getLineaGasFees(\n request: GasFeeFlowRequest,\n ): Promise<GasFeeFlowResponse> {\n const { ethQuery, transactionMeta } = request;\n\n const lineaResponse = await this.#getLineaResponse(\n transactionMeta,\n ethQuery,\n );\n\n log('Received Linea response', lineaResponse);\n\n const baseFees = this.#getValuesFromMultipliers(\n lineaResponse.baseFeePerGas,\n BASE_FEE_MULTIPLIERS,\n );\n\n log('Generated base fees', this.#feesToString(baseFees));\n\n const priorityFees = this.#getValuesFromMultipliers(\n lineaResponse.priorityFeePerGas,\n PRIORITY_FEE_MULTIPLIERS,\n );\n\n log('Generated priority fees', this.#feesToString(priorityFees));\n\n const maxFees = this.#getMaxFees(baseFees, priorityFees);\n\n log('Generated max fees', this.#feesToString(maxFees));\n\n const estimates = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: {\n maxFeePerGas: toHex(maxFees[level]),\n maxPriorityFeePerGas: toHex(priorityFees[level]),\n },\n }),\n { type: GasFeeEstimateType.FeeMarket } as GasFeeEstimates,\n );\n\n return { estimates };\n }\n\n #getLineaResponse(\n transactionMeta: TransactionMeta,\n ethQuery: EthQuery,\n ): Promise<LineaEstimateGasResponse> {\n return query(ethQuery, 'linea_estimateGas', [\n {\n from: transactionMeta.txParams.from,\n to: transactionMeta.txParams.to,\n value: transactionMeta.txParams.value,\n input: transactionMeta.txParams.data,\n // Required in request but no impact on response.\n gasPrice: '0x100000000',\n },\n ]);\n }\n\n #getValuesFromMultipliers(\n value: Hex,\n multipliers: { low: number; medium: number; high: number },\n ): FeesByLevel {\n const base = hexToBN(value);\n const low = base.muln(multipliers.low);\n const medium = base.muln(multipliers.medium);\n const high = base.muln(multipliers.high);\n\n return {\n low,\n medium,\n high,\n };\n }\n\n #getMaxFees(\n baseFees: Record<GasFeeEstimateLevel, BN>,\n priorityFees: Record<GasFeeEstimateLevel, BN>,\n ): FeesByLevel {\n return {\n low: baseFees.low.add(priorityFees.low),\n medium: baseFees.medium.add(priorityFees.medium),\n high: baseFees.high.add(priorityFees.high),\n };\n }\n\n #feesToString(fees: FeesByLevel) {\n return Object.values(GasFeeEstimateLevel).map((level) =>\n fees[level].toString(10),\n );\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OptimismLayer1GasFeeFlow = void 0;
4
+ const constants_1 = require("../constants.cjs");
5
+ const OracleLayer1GasFeeFlow_1 = require("./OracleLayer1GasFeeFlow.cjs");
6
+ const OPTIMISM_STACK_CHAIN_IDS = [
7
+ constants_1.CHAIN_IDS.OPTIMISM,
8
+ constants_1.CHAIN_IDS.OPTIMISM_TESTNET,
9
+ constants_1.CHAIN_IDS.BASE,
10
+ constants_1.CHAIN_IDS.BASE_TESTNET,
11
+ constants_1.CHAIN_IDS.OPBNB,
12
+ constants_1.CHAIN_IDS.OPBNB_TESTNET,
13
+ constants_1.CHAIN_IDS.ZORA,
14
+ ];
15
+ // BlockExplorer link: https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f#code
16
+ const OPTIMISM_GAS_PRICE_ORACLE_ADDRESS = '0x420000000000000000000000000000000000000F';
17
+ /**
18
+ * Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
19
+ */
20
+ class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow_1.OracleLayer1GasFeeFlow {
21
+ constructor() {
22
+ super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);
23
+ }
24
+ matchesTransaction(transactionMeta) {
25
+ return OPTIMISM_STACK_CHAIN_IDS.includes(transactionMeta.chainId);
26
+ }
27
+ }
28
+ exports.OptimismLayer1GasFeeFlow = OptimismLayer1GasFeeFlow;
29
+ //# sourceMappingURL=OptimismLayer1GasFeeFlow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptimismLayer1GasFeeFlow.cjs","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":";;;AAEA,gDAAyC;AAEzC,yEAAkE;AAElE,MAAM,wBAAwB,GAAU;IACtC,qBAAS,CAAC,QAAQ;IAClB,qBAAS,CAAC,gBAAgB;IAC1B,qBAAS,CAAC,IAAI;IACd,qBAAS,CAAC,YAAY;IACtB,qBAAS,CAAC,KAAK;IACf,qBAAS,CAAC,aAAa;IACvB,qBAAS,CAAC,IAAI;CACf,CAAC;AAEF,8GAA8G;AAC9G,MAAM,iCAAiC,GACrC,4CAA4C,CAAC;AAE/C;;GAEG;AACH,MAAa,wBAAyB,SAAQ,+CAAsB;IAClE;QACE,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC3C,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,OAAO,wBAAwB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACpE,CAAC;CACF;AARD,4DAQC","sourcesContent":["import { type Hex } from '@metamask/utils';\n\nimport { CHAIN_IDS } from '../constants';\nimport type { TransactionMeta } from '../types';\nimport { OracleLayer1GasFeeFlow } from './OracleLayer1GasFeeFlow';\n\nconst OPTIMISM_STACK_CHAIN_IDS: Hex[] = [\n CHAIN_IDS.OPTIMISM,\n CHAIN_IDS.OPTIMISM_TESTNET,\n CHAIN_IDS.BASE,\n CHAIN_IDS.BASE_TESTNET,\n CHAIN_IDS.OPBNB,\n CHAIN_IDS.OPBNB_TESTNET,\n CHAIN_IDS.ZORA,\n];\n\n// BlockExplorer link: https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f#code\nconst OPTIMISM_GAS_PRICE_ORACLE_ADDRESS =\n '0x420000000000000000000000000000000000000F';\n\n/**\n * Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.\n */\nexport class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {\n constructor() {\n super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);\n }\n\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return OPTIMISM_STACK_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
  * Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
5
5
  */
@@ -7,4 +7,4 @@ export declare class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
7
7
  constructor();
8
8
  matchesTransaction(transactionMeta: TransactionMeta): boolean;
9
9
  }
10
- //# sourceMappingURL=OptimismLayer1GasFeeFlow.d.ts.map
10
+ //# sourceMappingURL=OptimismLayer1GasFeeFlow.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptimismLayer1GasFeeFlow.d.cts","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAiB;AAChD,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAgBlE;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,sBAAsB;;IAKlE,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
+ * Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
5
+ */
6
+ export declare class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
7
+ constructor();
8
+ matchesTransaction(transactionMeta: TransactionMeta): boolean;
9
+ }
10
+ //# sourceMappingURL=OptimismLayer1GasFeeFlow.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptimismLayer1GasFeeFlow.d.mts","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAiB;AAChD,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAgBlE;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,sBAAsB;;IAKlE,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO;CAG9D"}
@@ -1,11 +1,25 @@
1
- import {
2
- OptimismLayer1GasFeeFlow
3
- } from "../chunk-VEVVBHP3.mjs";
4
- import "../chunk-FG74Z3F5.mjs";
5
- import "../chunk-O6ZZVIFH.mjs";
6
- import "../chunk-UQQWZT6C.mjs";
7
- import "../chunk-XUI43LEZ.mjs";
8
- export {
9
- OptimismLayer1GasFeeFlow
10
- };
1
+ import { CHAIN_IDS } from "../constants.mjs";
2
+ import { OracleLayer1GasFeeFlow } from "./OracleLayer1GasFeeFlow.mjs";
3
+ const OPTIMISM_STACK_CHAIN_IDS = [
4
+ CHAIN_IDS.OPTIMISM,
5
+ CHAIN_IDS.OPTIMISM_TESTNET,
6
+ CHAIN_IDS.BASE,
7
+ CHAIN_IDS.BASE_TESTNET,
8
+ CHAIN_IDS.OPBNB,
9
+ CHAIN_IDS.OPBNB_TESTNET,
10
+ CHAIN_IDS.ZORA,
11
+ ];
12
+ // BlockExplorer link: https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f#code
13
+ const OPTIMISM_GAS_PRICE_ORACLE_ADDRESS = '0x420000000000000000000000000000000000000F';
14
+ /**
15
+ * Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.
16
+ */
17
+ export class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
18
+ constructor() {
19
+ super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);
20
+ }
21
+ matchesTransaction(transactionMeta) {
22
+ return OPTIMISM_STACK_CHAIN_IDS.includes(transactionMeta.chainId);
23
+ }
24
+ }
11
25
  //# sourceMappingURL=OptimismLayer1GasFeeFlow.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"OptimismLayer1GasFeeFlow.mjs","sourceRoot":"","sources":["../../src/gas-flows/OptimismLayer1GasFeeFlow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,yBAAqB;AAEzC,OAAO,EAAE,sBAAsB,EAAE,qCAAiC;AAElE,MAAM,wBAAwB,GAAU;IACtC,SAAS,CAAC,QAAQ;IAClB,SAAS,CAAC,gBAAgB;IAC1B,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,KAAK;IACf,SAAS,CAAC,aAAa;IACvB,SAAS,CAAC,IAAI;CACf,CAAC;AAEF,8GAA8G;AAC9G,MAAM,iCAAiC,GACrC,4CAA4C,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,sBAAsB;IAClE;QACE,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAC3C,CAAC;IAED,kBAAkB,CAAC,eAAgC;QACjD,OAAO,wBAAwB,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACpE,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 OPTIMISM_STACK_CHAIN_IDS: Hex[] = [\n CHAIN_IDS.OPTIMISM,\n CHAIN_IDS.OPTIMISM_TESTNET,\n CHAIN_IDS.BASE,\n CHAIN_IDS.BASE_TESTNET,\n CHAIN_IDS.OPBNB,\n CHAIN_IDS.OPBNB_TESTNET,\n CHAIN_IDS.ZORA,\n];\n\n// BlockExplorer link: https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f#code\nconst OPTIMISM_GAS_PRICE_ORACLE_ADDRESS =\n '0x420000000000000000000000000000000000000F';\n\n/**\n * Optimism layer 1 gas fee flow that obtains gas fee estimate using an oracle contract.\n */\nexport class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {\n constructor() {\n super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);\n }\n\n matchesTransaction(transactionMeta: TransactionMeta): boolean {\n return OPTIMISM_STACK_CHAIN_IDS.includes(transactionMeta.chainId);\n }\n}\n"]}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _OracleLayer1GasFeeFlow_instances, _OracleLayer1GasFeeFlow_oracleAddress, _OracleLayer1GasFeeFlow_signTransaction, _OracleLayer1GasFeeFlow_getOracleLayer1GasFee, _OracleLayer1GasFeeFlow_buildUnserializedTransaction, _OracleLayer1GasFeeFlow_buildTransactionParams, _OracleLayer1GasFeeFlow_buildTransactionCommon;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.OracleLayer1GasFeeFlow = void 0;
16
+ const common_1 = require("@ethereumjs/common");
17
+ const tx_1 = require("@ethereumjs/tx");
18
+ const contracts_1 = require("@ethersproject/contracts");
19
+ const providers_1 = require("@ethersproject/providers");
20
+ const utils_1 = require("@metamask/utils");
21
+ const lodash_1 = require("lodash");
22
+ const logger_1 = require("../logger.cjs");
23
+ const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'oracle-layer1-gas-fee-flow');
24
+ const DUMMY_KEY = 'abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789';
25
+ const GAS_PRICE_ORACLE_ABI = [
26
+ {
27
+ inputs: [{ internalType: 'bytes', name: '_data', type: 'bytes' }],
28
+ name: 'getL1Fee',
29
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
30
+ stateMutability: 'view',
31
+ type: 'function',
32
+ },
33
+ ];
34
+ /**
35
+ * Layer 1 gas fee flow that obtains gas fee estimate using an oracle smart contract.
36
+ */
37
+ class OracleLayer1GasFeeFlow {
38
+ constructor(oracleAddress, signTransaction) {
39
+ _OracleLayer1GasFeeFlow_instances.add(this);
40
+ _OracleLayer1GasFeeFlow_oracleAddress.set(this, void 0);
41
+ _OracleLayer1GasFeeFlow_signTransaction.set(this, void 0);
42
+ __classPrivateFieldSet(this, _OracleLayer1GasFeeFlow_oracleAddress, oracleAddress, "f");
43
+ __classPrivateFieldSet(this, _OracleLayer1GasFeeFlow_signTransaction, signTransaction ?? false, "f");
44
+ }
45
+ async getLayer1Fee(request) {
46
+ try {
47
+ return await __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_instances, "m", _OracleLayer1GasFeeFlow_getOracleLayer1GasFee).call(this, request);
48
+ }
49
+ catch (error) {
50
+ log('Failed to get oracle layer 1 gas fee', error);
51
+ throw new Error(`Failed to get oracle layer 1 gas fee`);
52
+ }
53
+ }
54
+ }
55
+ exports.OracleLayer1GasFeeFlow = OracleLayer1GasFeeFlow;
56
+ _OracleLayer1GasFeeFlow_oracleAddress = new WeakMap(), _OracleLayer1GasFeeFlow_signTransaction = new WeakMap(), _OracleLayer1GasFeeFlow_instances = new WeakSet(), _OracleLayer1GasFeeFlow_getOracleLayer1GasFee = async function _OracleLayer1GasFeeFlow_getOracleLayer1GasFee(request) {
57
+ const { provider, transactionMeta } = request;
58
+ const contract = new contracts_1.Contract(__classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_oracleAddress, "f"), GAS_PRICE_ORACLE_ABI,
59
+ // Network controller provider type is incompatible with ethers provider
60
+ new providers_1.Web3Provider(provider));
61
+ const serializedTransaction = __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_instances, "m", _OracleLayer1GasFeeFlow_buildUnserializedTransaction).call(this, transactionMeta, __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_signTransaction, "f")).serialize();
62
+ const result = await contract.getL1Fee(serializedTransaction);
63
+ if (result === undefined) {
64
+ throw new Error('No value returned from oracle contract');
65
+ }
66
+ return {
67
+ layer1Fee: result.toHexString(),
68
+ };
69
+ }, _OracleLayer1GasFeeFlow_buildUnserializedTransaction = function _OracleLayer1GasFeeFlow_buildUnserializedTransaction(transactionMeta, sign) {
70
+ const txParams = __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_instances, "m", _OracleLayer1GasFeeFlow_buildTransactionParams).call(this, transactionMeta);
71
+ const common = __classPrivateFieldGet(this, _OracleLayer1GasFeeFlow_instances, "m", _OracleLayer1GasFeeFlow_buildTransactionCommon).call(this, transactionMeta);
72
+ let unserializedTransaction = tx_1.TransactionFactory.fromTxData(txParams, {
73
+ common,
74
+ });
75
+ if (sign) {
76
+ const keyBuffer = Buffer.from(DUMMY_KEY, 'hex');
77
+ unserializedTransaction = unserializedTransaction.sign(keyBuffer);
78
+ }
79
+ return unserializedTransaction;
80
+ }, _OracleLayer1GasFeeFlow_buildTransactionParams = function _OracleLayer1GasFeeFlow_buildTransactionParams(transactionMeta) {
81
+ return {
82
+ ...(0, lodash_1.omit)(transactionMeta.txParams, 'gas'),
83
+ gasLimit: transactionMeta.txParams.gas,
84
+ };
85
+ }, _OracleLayer1GasFeeFlow_buildTransactionCommon = function _OracleLayer1GasFeeFlow_buildTransactionCommon(transactionMeta) {
86
+ const chainId = Number(transactionMeta.chainId);
87
+ return common_1.Common.custom({
88
+ chainId,
89
+ defaultHardfork: common_1.Hardfork.London,
90
+ });
91
+ };
92
+ //# sourceMappingURL=OracleLayer1GasFeeFlow.cjs.map