@metamask/transaction-controller 23.1.0 → 25.0.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 (278) hide show
  1. package/CHANGELOG.md +134 -1
  2. package/dist/TransactionController.js +38 -1816
  3. package/dist/TransactionController.js.map +1 -1
  4. package/dist/TransactionController.mjs +39 -0
  5. package/dist/TransactionController.mjs.map +1 -0
  6. package/dist/chunk-2K7J3EY3.mjs +170 -0
  7. package/dist/chunk-2K7J3EY3.mjs.map +1 -0
  8. package/dist/chunk-5XBULBP2.js +399 -0
  9. package/dist/chunk-5XBULBP2.js.map +1 -0
  10. package/dist/chunk-6MYNWYJK.mjs +158 -0
  11. package/dist/chunk-6MYNWYJK.mjs.map +1 -0
  12. package/dist/chunk-7APMBUKB.js +158 -0
  13. package/dist/chunk-7APMBUKB.js.map +1 -0
  14. package/dist/chunk-7LXE4KHV.js +40 -0
  15. package/dist/chunk-7LXE4KHV.js.map +1 -0
  16. package/dist/chunk-7MZ57ILQ.mjs +62 -0
  17. package/dist/chunk-7MZ57ILQ.mjs.map +1 -0
  18. package/dist/chunk-BJEESIBE.js +2313 -0
  19. package/dist/chunk-BJEESIBE.js.map +1 -0
  20. package/dist/chunk-C67QD5PV.mjs +320 -0
  21. package/dist/chunk-C67QD5PV.mjs.map +1 -0
  22. package/dist/chunk-DE3MZYVY.mjs +2313 -0
  23. package/dist/chunk-DE3MZYVY.mjs.map +1 -0
  24. package/dist/chunk-DEKM6PVG.mjs +46 -0
  25. package/dist/chunk-DEKM6PVG.mjs.map +1 -0
  26. package/dist/chunk-DQP6X25N.mjs +208 -0
  27. package/dist/chunk-DQP6X25N.mjs.map +1 -0
  28. package/dist/chunk-DTDTOMTB.js +238 -0
  29. package/dist/chunk-DTDTOMTB.js.map +1 -0
  30. package/dist/chunk-DTEDYRTL.js +242 -0
  31. package/dist/chunk-DTEDYRTL.js.map +1 -0
  32. package/dist/chunk-EQ3RRHB7.mjs +211 -0
  33. package/dist/chunk-EQ3RRHB7.mjs.map +1 -0
  34. package/dist/chunk-FDJPXQTF.js +46 -0
  35. package/dist/chunk-FDJPXQTF.js.map +1 -0
  36. package/dist/chunk-FRKQ3Z2L.mjs +40 -0
  37. package/dist/chunk-FRKQ3Z2L.mjs.map +1 -0
  38. package/dist/chunk-FS7FRO7B.mjs +90 -0
  39. package/dist/chunk-FS7FRO7B.mjs.map +1 -0
  40. package/dist/chunk-GKTIFXPN.js +170 -0
  41. package/dist/chunk-GKTIFXPN.js.map +1 -0
  42. package/dist/chunk-H4M66BA3.js +62 -0
  43. package/dist/chunk-H4M66BA3.js.map +1 -0
  44. package/dist/chunk-HPNXIKFY.js +76 -0
  45. package/dist/chunk-HPNXIKFY.js.map +1 -0
  46. package/dist/chunk-HS277C77.js +75 -0
  47. package/dist/chunk-HS277C77.js.map +1 -0
  48. package/dist/chunk-I5YZ7QUK.js +121 -0
  49. package/dist/chunk-I5YZ7QUK.js.map +1 -0
  50. package/dist/chunk-IC233ZQS.js +211 -0
  51. package/dist/chunk-IC233ZQS.js.map +1 -0
  52. package/dist/chunk-IUBAETUH.js +137 -0
  53. package/dist/chunk-IUBAETUH.js.map +1 -0
  54. package/dist/chunk-J56A7UCK.mjs +123 -0
  55. package/dist/chunk-J56A7UCK.mjs.map +1 -0
  56. package/dist/chunk-JR6HDRNV.mjs +242 -0
  57. package/dist/chunk-JR6HDRNV.mjs.map +1 -0
  58. package/dist/chunk-JRBREX22.mjs +75 -0
  59. package/dist/chunk-JRBREX22.mjs.map +1 -0
  60. package/dist/chunk-JRQHIBG5.mjs +399 -0
  61. package/dist/chunk-JRQHIBG5.mjs.map +1 -0
  62. package/dist/chunk-LM4NUNMT.mjs +76 -0
  63. package/dist/chunk-LM4NUNMT.mjs.map +1 -0
  64. package/dist/chunk-M7455RU7.js +320 -0
  65. package/dist/chunk-M7455RU7.js.map +1 -0
  66. package/dist/chunk-MHM5LRRF.mjs +122 -0
  67. package/dist/chunk-MHM5LRRF.mjs.map +1 -0
  68. package/dist/chunk-NHRBO3LU.mjs +50 -0
  69. package/dist/chunk-NHRBO3LU.mjs.map +1 -0
  70. package/dist/chunk-NM6OYEPP.mjs +182 -0
  71. package/dist/chunk-NM6OYEPP.mjs.map +1 -0
  72. package/dist/chunk-NUOBUW7C.js +85 -0
  73. package/dist/chunk-NUOBUW7C.js.map +1 -0
  74. package/dist/chunk-QP75SWIQ.js +53 -0
  75. package/dist/chunk-QP75SWIQ.js.map +1 -0
  76. package/dist/chunk-RI6MVJJN.js +122 -0
  77. package/dist/chunk-RI6MVJJN.js.map +1 -0
  78. package/dist/chunk-S6VGOPUY.js +14 -0
  79. package/dist/chunk-S6VGOPUY.js.map +1 -0
  80. package/dist/chunk-UGFBA4GV.js +123 -0
  81. package/dist/chunk-UGFBA4GV.js.map +1 -0
  82. package/dist/chunk-UKYY2RVS.mjs +137 -0
  83. package/dist/chunk-UKYY2RVS.mjs.map +1 -0
  84. package/dist/chunk-UM4ORJ5B.mjs +121 -0
  85. package/dist/chunk-UM4ORJ5B.mjs.map +1 -0
  86. package/dist/chunk-UQQWZT6C.mjs +14 -0
  87. package/dist/chunk-UQQWZT6C.mjs.map +1 -0
  88. package/dist/chunk-VH47Q6TS.js +182 -0
  89. package/dist/chunk-VH47Q6TS.js.map +1 -0
  90. package/dist/chunk-XGRAHX6T.mjs +53 -0
  91. package/dist/chunk-XGRAHX6T.mjs.map +1 -0
  92. package/dist/chunk-XUI43LEZ.mjs +30 -0
  93. package/dist/chunk-XUI43LEZ.mjs.map +1 -0
  94. package/dist/chunk-Y734U4V6.mjs +85 -0
  95. package/dist/chunk-Y734U4V6.mjs.map +1 -0
  96. package/dist/chunk-Y7ENNK7L.mjs +238 -0
  97. package/dist/chunk-Y7ENNK7L.mjs.map +1 -0
  98. package/dist/chunk-Z4BLTVTB.js +30 -0
  99. package/dist/chunk-Z4BLTVTB.js.map +1 -0
  100. package/dist/chunk-ZCQRDZ36.js +208 -0
  101. package/dist/chunk-ZCQRDZ36.js.map +1 -0
  102. package/dist/chunk-ZJLZSFOZ.js +90 -0
  103. package/dist/chunk-ZJLZSFOZ.js.map +1 -0
  104. package/dist/chunk-ZNZEJDOE.js +50 -0
  105. package/dist/chunk-ZNZEJDOE.js.map +1 -0
  106. package/dist/constants.js +15 -110
  107. package/dist/constants.js.map +1 -1
  108. package/dist/constants.mjs +16 -0
  109. package/dist/constants.mjs.map +1 -0
  110. package/dist/gas-flows/DefaultGasFeeFlow.js +14 -77
  111. package/dist/gas-flows/DefaultGasFeeFlow.js.map +1 -1
  112. package/dist/gas-flows/DefaultGasFeeFlow.mjs +15 -0
  113. package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -0
  114. package/dist/gas-flows/LineaGasFeeFlow.js +15 -110
  115. package/dist/gas-flows/LineaGasFeeFlow.js.map +1 -1
  116. package/dist/gas-flows/LineaGasFeeFlow.mjs +16 -0
  117. package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -0
  118. package/dist/helpers/EtherscanRemoteTransactionSource.js +11 -145
  119. package/dist/helpers/EtherscanRemoteTransactionSource.js.map +1 -1
  120. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +12 -0
  121. package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +1 -0
  122. package/dist/helpers/GasFeePoller.js +10 -143
  123. package/dist/helpers/GasFeePoller.js.map +1 -1
  124. package/dist/helpers/GasFeePoller.mjs +11 -0
  125. package/dist/helpers/GasFeePoller.mjs.map +1 -0
  126. package/dist/helpers/IncomingTransactionHelper.js +8 -205
  127. package/dist/helpers/IncomingTransactionHelper.js.map +1 -1
  128. package/dist/helpers/IncomingTransactionHelper.mjs +9 -0
  129. package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -0
  130. package/dist/helpers/MultichainTrackingHelper.js +12 -291
  131. package/dist/helpers/MultichainTrackingHelper.js.map +1 -1
  132. package/dist/helpers/MultichainTrackingHelper.mjs +13 -0
  133. package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -0
  134. package/dist/helpers/PendingTransactionTracker.js +9 -360
  135. package/dist/helpers/PendingTransactionTracker.js.map +1 -1
  136. package/dist/helpers/PendingTransactionTracker.mjs +10 -0
  137. package/dist/helpers/PendingTransactionTracker.mjs.map +1 -0
  138. package/dist/index.js +56 -25
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.mjs +57 -0
  141. package/dist/index.mjs.map +1 -0
  142. package/dist/logger.js +11 -8
  143. package/dist/logger.js.map +1 -1
  144. package/dist/logger.mjs +12 -0
  145. package/dist/logger.mjs.map +1 -0
  146. package/dist/tsconfig.build.tsbuildinfo +1 -0
  147. package/dist/{TransactionController.d.ts → types/TransactionController.d.ts} +235 -46
  148. package/dist/types/TransactionController.d.ts.map +1 -0
  149. package/dist/{constants.d.ts → types/constants.d.ts} +8 -3
  150. package/dist/types/constants.d.ts.map +1 -0
  151. package/dist/types/gas-flows/DefaultGasFeeFlow.d.ts.map +1 -0
  152. package/dist/types/gas-flows/LineaGasFeeFlow.d.ts.map +1 -0
  153. package/dist/types/helpers/EtherscanRemoteTransactionSource.d.ts.map +1 -0
  154. package/dist/types/helpers/GasFeePoller.d.ts.map +1 -0
  155. package/dist/types/helpers/IncomingTransactionHelper.d.ts.map +1 -0
  156. package/dist/types/helpers/MultichainTrackingHelper.d.ts.map +1 -0
  157. package/dist/types/helpers/PendingTransactionTracker.d.ts.map +1 -0
  158. package/dist/types/index.d.ts +9 -0
  159. package/dist/types/index.d.ts.map +1 -0
  160. package/dist/types/logger.d.ts.map +1 -0
  161. package/dist/{types.d.ts → types/types.d.ts} +63 -65
  162. package/dist/types/types.d.ts.map +1 -0
  163. package/dist/types/utils/etherscan.d.ts.map +1 -0
  164. package/dist/types/utils/external-transactions.d.ts.map +1 -0
  165. package/dist/types/utils/gas-fees.d.ts.map +1 -0
  166. package/dist/types/utils/gas-flow.d.ts.map +1 -0
  167. package/dist/types/utils/gas.d.ts.map +1 -0
  168. package/dist/types/utils/history.d.ts +20 -0
  169. package/dist/types/utils/history.d.ts.map +1 -0
  170. package/dist/types/utils/nonce.d.ts.map +1 -0
  171. package/dist/types/utils/simulation-api.d.ts +99 -0
  172. package/dist/types/utils/simulation-api.d.ts.map +1 -0
  173. package/dist/types/utils/simulation.d.ts +21 -0
  174. package/dist/types/utils/simulation.d.ts.map +1 -0
  175. package/dist/{utils → types/utils}/swaps.d.ts +8 -5
  176. package/dist/types/utils/swaps.d.ts.map +1 -0
  177. package/dist/types/utils/transaction-type.d.ts.map +1 -0
  178. package/dist/{utils → types/utils}/utils.d.ts +9 -1
  179. package/dist/types/utils/utils.d.ts.map +1 -0
  180. package/dist/types/utils/validation.d.ts.map +1 -0
  181. package/dist/types.js +19 -170
  182. package/dist/types.js.map +1 -1
  183. package/dist/types.mjs +20 -0
  184. package/dist/types.mjs.map +1 -0
  185. package/dist/utils/etherscan.js +13 -118
  186. package/dist/utils/etherscan.js.map +1 -1
  187. package/dist/utils/etherscan.mjs +14 -0
  188. package/dist/utils/etherscan.mjs.map +1 -0
  189. package/dist/utils/external-transactions.js +8 -35
  190. package/dist/utils/external-transactions.js.map +1 -1
  191. package/dist/utils/external-transactions.mjs +9 -0
  192. package/dist/utils/external-transactions.mjs.map +1 -0
  193. package/dist/utils/gas-fees.js +15 -200
  194. package/dist/utils/gas-fees.js.map +1 -1
  195. package/dist/utils/gas-fees.mjs +16 -0
  196. package/dist/utils/gas-fees.mjs.map +1 -0
  197. package/dist/utils/gas-flow.js +10 -52
  198. package/dist/utils/gas-flow.js.map +1 -1
  199. package/dist/utils/gas-flow.mjs +11 -0
  200. package/dist/utils/gas-flow.mjs.map +1 -0
  201. package/dist/utils/gas.js +19 -133
  202. package/dist/utils/gas.js.map +1 -1
  203. package/dist/utils/gas.mjs +20 -0
  204. package/dist/utils/gas.mjs.map +1 -0
  205. package/dist/utils/history.js +9 -83
  206. package/dist/utils/history.js.map +1 -1
  207. package/dist/utils/history.mjs +10 -0
  208. package/dist/utils/history.mjs.map +1 -0
  209. package/dist/utils/nonce.js +10 -76
  210. package/dist/utils/nonce.js.map +1 -1
  211. package/dist/utils/nonce.mjs +11 -0
  212. package/dist/utils/nonce.mjs.map +1 -0
  213. package/dist/utils/simulation-api.js +10 -0
  214. package/dist/utils/simulation-api.js.map +1 -0
  215. package/dist/utils/simulation-api.mjs +10 -0
  216. package/dist/utils/simulation-api.mjs.map +1 -0
  217. package/dist/utils/simulation.js +12 -0
  218. package/dist/utils/simulation.js.map +1 -0
  219. package/dist/utils/simulation.mjs +12 -0
  220. package/dist/utils/simulation.mjs.map +1 -0
  221. package/dist/utils/swaps.js +23 -256
  222. package/dist/utils/swaps.js.map +1 -1
  223. package/dist/utils/swaps.mjs +24 -0
  224. package/dist/utils/swaps.mjs.map +1 -0
  225. package/dist/utils/transaction-type.js +10 -120
  226. package/dist/utils/transaction-type.js.map +1 -1
  227. package/dist/utils/transaction-type.mjs +11 -0
  228. package/dist/utils/transaction-type.mjs.map +1 -0
  229. package/dist/utils/utils.js +32 -146
  230. package/dist/utils/utils.js.map +1 -1
  231. package/dist/utils/utils.mjs +33 -0
  232. package/dist/utils/utils.mjs.map +1 -0
  233. package/dist/utils/validation.js +11 -258
  234. package/dist/utils/validation.js.map +1 -1
  235. package/dist/utils/validation.mjs +12 -0
  236. package/dist/utils/validation.mjs.map +1 -0
  237. package/package.json +21 -9
  238. package/dist/TransactionController.d.ts.map +0 -1
  239. package/dist/constants.d.ts.map +0 -1
  240. package/dist/gas-flows/DefaultGasFeeFlow.d.ts.map +0 -1
  241. package/dist/gas-flows/LineaGasFeeFlow.d.ts.map +0 -1
  242. package/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +0 -1
  243. package/dist/helpers/GasFeePoller.d.ts.map +0 -1
  244. package/dist/helpers/IncomingTransactionHelper.d.ts.map +0 -1
  245. package/dist/helpers/MultichainTrackingHelper.d.ts.map +0 -1
  246. package/dist/helpers/PendingTransactionTracker.d.ts.map +0 -1
  247. package/dist/index.d.ts +0 -7
  248. package/dist/index.d.ts.map +0 -1
  249. package/dist/logger.d.ts.map +0 -1
  250. package/dist/types.d.ts.map +0 -1
  251. package/dist/utils/etherscan.d.ts.map +0 -1
  252. package/dist/utils/external-transactions.d.ts.map +0 -1
  253. package/dist/utils/gas-fees.d.ts.map +0 -1
  254. package/dist/utils/gas-flow.d.ts.map +0 -1
  255. package/dist/utils/gas.d.ts.map +0 -1
  256. package/dist/utils/history.d.ts +0 -15
  257. package/dist/utils/history.d.ts.map +0 -1
  258. package/dist/utils/nonce.d.ts.map +0 -1
  259. package/dist/utils/swaps.d.ts.map +0 -1
  260. package/dist/utils/transaction-type.d.ts.map +0 -1
  261. package/dist/utils/utils.d.ts.map +0 -1
  262. package/dist/utils/validation.d.ts.map +0 -1
  263. /package/dist/{gas-flows → types/gas-flows}/DefaultGasFeeFlow.d.ts +0 -0
  264. /package/dist/{gas-flows → types/gas-flows}/LineaGasFeeFlow.d.ts +0 -0
  265. /package/dist/{helpers → types/helpers}/EtherscanRemoteTransactionSource.d.ts +0 -0
  266. /package/dist/{helpers → types/helpers}/GasFeePoller.d.ts +0 -0
  267. /package/dist/{helpers → types/helpers}/IncomingTransactionHelper.d.ts +0 -0
  268. /package/dist/{helpers → types/helpers}/MultichainTrackingHelper.d.ts +0 -0
  269. /package/dist/{helpers → types/helpers}/PendingTransactionTracker.d.ts +0 -0
  270. /package/dist/{logger.d.ts → types/logger.d.ts} +0 -0
  271. /package/dist/{utils → types/utils}/etherscan.d.ts +0 -0
  272. /package/dist/{utils → types/utils}/external-transactions.d.ts +0 -0
  273. /package/dist/{utils → types/utils}/gas-fees.d.ts +0 -0
  274. /package/dist/{utils → types/utils}/gas-flow.d.ts +0 -0
  275. /package/dist/{utils → types/utils}/gas.d.ts +0 -0
  276. /package/dist/{utils → types/utils}/nonce.d.ts +0 -0
  277. /package/dist/{utils → types/utils}/transaction-type.d.ts +0 -0
  278. /package/dist/{utils → types/utils}/validation.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/utils/validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAK3E;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,kBAAkB,EAAE,MAAM,EAAE,EAC5B,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,iBAqBf;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,iBAAiB,EAC3B,mBAAmB,UAAO,QAS3B"}
package/dist/types.js CHANGED
@@ -1,171 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GasFeeEstimateLevel = exports.UserFeeLevel = exports.TransactionEnvelopeType = exports.TransactionType = exports.WalletDevice = exports.TransactionStatus = void 0;
4
- /**
5
- * The status of the transaction. Each status represents the state of the transaction internally
6
- * in the wallet. Some of these correspond with the state of the transaction on the network, but
7
- * some are wallet-specific.
8
- */
9
- var TransactionStatus;
10
- (function (TransactionStatus) {
11
- TransactionStatus["approved"] = "approved";
12
- /** @deprecated Determined by the clients using the transaction type. No longer used. */
13
- TransactionStatus["cancelled"] = "cancelled";
14
- TransactionStatus["confirmed"] = "confirmed";
15
- TransactionStatus["dropped"] = "dropped";
16
- TransactionStatus["failed"] = "failed";
17
- TransactionStatus["rejected"] = "rejected";
18
- TransactionStatus["signed"] = "signed";
19
- TransactionStatus["submitted"] = "submitted";
20
- TransactionStatus["unapproved"] = "unapproved";
21
- })(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {}));
22
- /**
23
- * Options for wallet device.
24
- */
25
- var WalletDevice;
26
- (function (WalletDevice) {
27
- WalletDevice["MM_MOBILE"] = "metamask_mobile";
28
- WalletDevice["MM_EXTENSION"] = "metamask_extension";
29
- WalletDevice["OTHER"] = "other_device";
30
- })(WalletDevice = exports.WalletDevice || (exports.WalletDevice = {}));
31
- /**
32
- * The type of the transaction.
33
- */
34
- var TransactionType;
35
- (function (TransactionType) {
36
- /**
37
- * A transaction sending a network's native asset to a recipient.
38
- */
39
- TransactionType["cancel"] = "cancel";
40
- /**
41
- * A transaction that is interacting with a smart contract's methods that we
42
- * have not treated as a special case, such as approve, transfer, and
43
- * transferfrom.
44
- */
45
- TransactionType["contractInteraction"] = "contractInteraction";
46
- /**
47
- * A transaction that deployed a smart contract.
48
- */
49
- TransactionType["deployContract"] = "contractDeployment";
50
- /**
51
- * A transaction for Ethereum decryption.
52
- */
53
- TransactionType["ethDecrypt"] = "eth_decrypt";
54
- /**
55
- * A transaction for getting an encryption public key.
56
- */
57
- TransactionType["ethGetEncryptionPublicKey"] = "eth_getEncryptionPublicKey";
58
- /**
59
- * An incoming (deposit) transaction.
60
- */
61
- TransactionType["incoming"] = "incoming";
62
- /**
63
- * A transaction for personal sign.
64
- */
65
- TransactionType["personalSign"] = "personal_sign";
66
- /**
67
- * When a transaction is failed it can be retried by
68
- * resubmitting the same transaction with a higher gas fee. This type is also used
69
- * to speed up pending transactions. This is accomplished by creating a new tx with
70
- * the same nonce and higher gas fees.
71
- */
72
- TransactionType["retry"] = "retry";
73
- /**
74
- * A transaction sending a network's native asset to a recipient.
75
- */
76
- TransactionType["simpleSend"] = "simpleSend";
77
- /**
78
- * A transaction that is signing a message.
79
- */
80
- TransactionType["sign"] = "eth_sign";
81
- /**
82
- * A transaction that is signing typed data.
83
- */
84
- TransactionType["signTypedData"] = "eth_signTypedData";
85
- /**
86
- * A transaction sending a network's native asset to a recipient.
87
- */
88
- TransactionType["smart"] = "smart";
89
- /**
90
- * A transaction swapping one token for another through MetaMask Swaps.
91
- */
92
- TransactionType["swap"] = "swap";
93
- /**
94
- * Similar to the approve type, a swap approval is a special case of ERC20
95
- * approve method that requests an allowance of the token to spend on behalf
96
- * of the user for the MetaMask Swaps contract. The first swap for any token
97
- * will have an accompanying swapApproval transaction.
98
- */
99
- TransactionType["swapApproval"] = "swapApproval";
100
- /**
101
- * A token transaction requesting an allowance of the token to spend on
102
- * behalf of the user.
103
- */
104
- TransactionType["tokenMethodApprove"] = "approve";
105
- /**
106
- * A token transaction transferring tokens from an account that the sender
107
- * has an allowance of. The method is prefixed with safe because when calling
108
- * this method the contract checks to ensure that the receiver is an address
109
- * capable of handling the token being sent.
110
- */
111
- TransactionType["tokenMethodSafeTransferFrom"] = "safetransferfrom";
112
- /**
113
- * A token transaction where the user is sending tokens that they own to
114
- * another address.
115
- */
116
- TransactionType["tokenMethodTransfer"] = "transfer";
117
- /**
118
- * A token transaction transferring tokens from an account that the sender
119
- * has an allowance of. For more information on allowances, see the approve
120
- * type.
121
- */
122
- TransactionType["tokenMethodTransferFrom"] = "transferfrom";
123
- /**
124
- * A token transaction requesting an allowance of all of a user's tokens to
125
- * spend on behalf of the user.
126
- */
127
- TransactionType["tokenMethodSetApprovalForAll"] = "setapprovalforall";
128
- })(TransactionType = exports.TransactionType || (exports.TransactionType = {}));
129
- /**
130
- * Specifies the shape of the base transaction parameters.
131
- * Added in EIP-2718.
132
- */
133
- var TransactionEnvelopeType;
134
- (function (TransactionEnvelopeType) {
135
- /**
136
- * A legacy transaction, the very first type.
137
- */
138
- TransactionEnvelopeType["legacy"] = "0x0";
139
- /**
140
- * EIP-2930 defined the access list transaction type that allowed for
141
- * specifying the state that a transaction would act upon in advance and
142
- * theoretically save on gas fees.
143
- */
144
- TransactionEnvelopeType["accessList"] = "0x1";
145
- /**
146
- * The type introduced comes from EIP-1559, Fee Market describes the addition
147
- * of a baseFee to blocks that will be burned instead of distributed to
148
- * miners. Transactions of this type have both a maxFeePerGas (maximum total
149
- * amount in gwei per gas to spend on the transaction) which is inclusive of
150
- * the maxPriorityFeePerGas (maximum amount of gwei per gas from the
151
- * transaction fee to distribute to miner).
152
- */
153
- TransactionEnvelopeType["feeMarket"] = "0x2";
154
- })(TransactionEnvelopeType = exports.TransactionEnvelopeType || (exports.TransactionEnvelopeType = {}));
155
- /**
156
- * The source of the gas fee parameters on a transaction.
157
- */
158
- var UserFeeLevel;
159
- (function (UserFeeLevel) {
160
- UserFeeLevel["CUSTOM"] = "custom";
161
- UserFeeLevel["DAPP_SUGGESTED"] = "dappSuggested";
162
- UserFeeLevel["MEDIUM"] = "medium";
163
- })(UserFeeLevel = exports.UserFeeLevel || (exports.UserFeeLevel = {}));
164
- /** Alternate priority levels for which values are provided in gas fee estimates. */
165
- var GasFeeEstimateLevel;
166
- (function (GasFeeEstimateLevel) {
167
- GasFeeEstimateLevel["low"] = "low";
168
- GasFeeEstimateLevel["medium"] = "medium";
169
- GasFeeEstimateLevel["high"] = "high";
170
- })(GasFeeEstimateLevel = exports.GasFeeEstimateLevel || (exports.GasFeeEstimateLevel = {}));
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+ var _chunkHPNXIKFYjs = require('./chunk-HPNXIKFY.js');
10
+ require('./chunk-Z4BLTVTB.js');
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ exports.GasFeeEstimateLevel = _chunkHPNXIKFYjs.GasFeeEstimateLevel; exports.SimulationTokenStandard = _chunkHPNXIKFYjs.SimulationTokenStandard; exports.TransactionEnvelopeType = _chunkHPNXIKFYjs.TransactionEnvelopeType; exports.TransactionStatus = _chunkHPNXIKFYjs.TransactionStatus; exports.TransactionType = _chunkHPNXIKFYjs.TransactionType; exports.UserFeeLevel = _chunkHPNXIKFYjs.UserFeeLevel; exports.WalletDevice = _chunkHPNXIKFYjs.WalletDevice;
171
20
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAmbA;;;;GAIG;AACH,IAAY,iBAWX;AAXD,WAAY,iBAAiB;IAC3B,0CAAqB,CAAA;IACrB,wFAAwF;IACxF,4CAAuB,CAAA;IACvB,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;IACnB,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,sCAAiB,CAAA;IACjB,4CAAuB,CAAA;IACvB,8CAAyB,CAAA;AAC3B,CAAC,EAXW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAW5B;AAED;;GAEG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,6CAA6B,CAAA;IAC7B,mDAAmC,CAAA;IACnC,sCAAsB,CAAA;AACxB,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAED;;GAEG;AACH,IAAY,eA+GX;AA/GD,WAAY,eAAe;IACzB;;OAEG;IACH,oCAAiB,CAAA;IAEjB;;;;OAIG;IACH,8DAA2C,CAAA;IAE3C;;OAEG;IACH,wDAAqC,CAAA;IAErC;;OAEG;IACH,6CAA0B,CAAA;IAE1B;;OAEG;IACH,2EAAwD,CAAA;IAExD;;OAEG;IACH,wCAAqB,CAAA;IAErB;;OAEG;IACH,iDAA8B,CAAA;IAE9B;;;;;OAKG;IACH,kCAAe,CAAA;IAEf;;OAEG;IACH,4CAAyB,CAAA;IAEzB;;OAEG;IACH,oCAAiB,CAAA;IAEjB;;OAEG;IACH,sDAAmC,CAAA;IAEnC;;OAEG;IACH,kCAAe,CAAA;IAEf;;OAEG;IACH,gCAAa,CAAA;IAEb;;;;;OAKG;IACH,gDAA6B,CAAA;IAE7B;;;OAGG;IACH,iDAA8B,CAAA;IAE9B;;;;;OAKG;IACH,mEAAgD,CAAA;IAEhD;;;OAGG;IACH,mDAAgC,CAAA;IAEhC;;;;OAIG;IACH,2DAAwC,CAAA;IAExC;;;OAGG;IACH,qEAAkD,CAAA;AACpD,CAAC,EA/GW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QA+G1B;AAySD;;;GAGG;AACH,IAAY,uBAsBX;AAtBD,WAAY,uBAAuB;IACjC;;OAEG;IACH,yCAAc,CAAA;IAEd;;;;OAIG;IACH,6CAAkB,CAAA;IAElB;;;;;;;OAOG;IACH,4CAAiB,CAAA;AACnB,CAAC,EAtBW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAsBlC;AAED;;GAEG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,gDAAgC,CAAA;IAChC,iCAAiB,CAAA;AACnB,CAAC,EAJW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAIvB;AAiFD,oFAAoF;AACpF,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,kCAAW,CAAA;IACX,wCAAiB,CAAA;IACjB,oCAAa,CAAA;AACf,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B","sourcesContent":["import type { AccessList } from '@ethereumjs/tx';\nimport type EthQuery from '@metamask/eth-query';\nimport type {\n FetchGasFeeEstimateOptions,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\nimport type { Operation } from 'fast-json-patch';\n\nexport type Events = {\n ['incomingTransactionBlock']: [blockNumber: number];\n ['post-transaction-balance-updated']: [\n {\n transactionMeta: TransactionMeta;\n approvalTransactionMeta?: TransactionMeta;\n },\n ];\n ['transaction-approved']: [\n { transactionMeta: TransactionMeta; actionId?: string },\n ];\n ['transaction-confirmed']: [{ transactionMeta: TransactionMeta }];\n\n ['transaction-dropped']: [{ transactionMeta: TransactionMeta }];\n ['transaction-failed']: [\n {\n actionId?: string;\n error: string;\n transactionMeta: TransactionMeta;\n },\n ];\n ['transaction-new-swap']: [{ transactionMeta: TransactionMeta }];\n ['transaction-new-swap-approval']: [{ transactionMeta: TransactionMeta }];\n ['transaction-rejected']: [\n { transactionMeta: TransactionMeta; actionId?: string },\n ];\n ['transaction-status-update']: [{ transactionMeta: TransactionMeta }];\n ['transaction-submitted']: [\n { transactionMeta: TransactionMeta; actionId?: string },\n ];\n ['unapprovedTransaction']: [transactionMeta: TransactionMeta];\n [key: `${string}:confirmed`]: [transactionMeta: TransactionMeta];\n [key: `${string}:finished`]: [transactionMeta: TransactionMeta];\n [key: `${string}:publish-skip`]: [tansactionMeta: TransactionMeta];\n [key: `${string}:speedup`]: [transactionMeta: TransactionMeta];\n};\n\n/**\n * Representation of transaction metadata.\n */\nexport type TransactionMeta = TransactionMetaBase &\n (\n | { status: Exclude<TransactionStatus, TransactionStatus.failed> }\n | {\n status: TransactionStatus.failed;\n error: TransactionError;\n }\n );\n\n/**\n * Information about a single transaction such as status and block number.\n */\ntype TransactionMetaBase = {\n /**\n * ID of the transaction that approved the swap token transfer.\n */\n approvalTxId?: string;\n\n /**\n * Unique ID to prevent duplicate requests.\n */\n actionId?: string;\n\n /**\n * Base fee of the block as a hex value, introduced in EIP-1559.\n */\n baseFeePerGas?: Hex;\n\n /**\n * Number of the block where the transaction has been included.\n */\n blockNumber?: string;\n\n /**\n * The timestamp for when the block was collated.\n */\n blockTimestamp?: string;\n\n /**\n * Network code as per EIP-155 for this transaction.\n */\n chainId: Hex;\n\n /**\n * A string representing a name of transaction contract method.\n */\n contractMethodName?: string;\n\n /**\n * The balance of the token that is being sent.\n */\n currentTokenBalance?: string;\n\n /**\n * Unique ID for custodian transaction.\n */\n custodyId?: string;\n\n /**\n * Custodian transaction status.\n */\n custodyStatus?: string;\n\n /** The optional custom nonce override as a decimal string. */\n customNonceValue?: string;\n\n /**\n * The custom token amount is the amount set by the user.\n */\n customTokenAmount?: string;\n\n /**\n * The dapp proposed token amount.\n */\n dappProposedTokenAmount?: string;\n\n /**\n * Gas values provided by the dApp.\n */\n dappSuggestedGasFees?: DappSuggestedGasFees;\n\n /**\n * The initial gas values set when the transaction was first created.\n */\n defaultGasEstimates?: DefaultGasEstimates;\n\n /**\n * String to indicate what device the transaction was confirmed on.\n */\n deviceConfirmedOn?: WalletDevice;\n\n /**\n * The address of the token being received of swap transaction.\n */\n destinationTokenAddress?: string;\n\n /**\n * The decimals of the token being received of swap transaction.\n */\n destinationTokenDecimals?: number;\n\n /**\n * The symbol of the token being received with swap.\n */\n destinationTokenSymbol?: string;\n\n /**\n * The estimated base fee of the transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * The chosen amount which will be the same as the originally proposed token\n * amount if the user does not edit the amount or will be a custom token\n * amount set by the user.\n */\n finalApprovalAmount?: string;\n\n /**\n * The number of the latest block when the transaction submit was first retried.\n */\n firstRetryBlockNumber?: string;\n\n /** Alternate EIP-1559 gas fee estimates for multiple priority levels. */\n gasFeeEstimates?: GasFeeEstimates;\n\n /** Whether the gas fee estimates have been checked at least once. */\n gasFeeEstimatesLoaded?: boolean;\n\n /**\n * A hex string of the transaction hash, used to identify the transaction on the network.\n */\n hash?: string;\n\n /**\n * A history of mutations to TransactionMeta.\n */\n history?: TransactionHistory;\n\n /**\n * Generated UUID associated with this transaction.\n */\n id: string;\n\n /**\n * Whether the transaction is a transfer.\n */\n isTransfer?: boolean;\n\n /**\n * Whether the transaction entry is generated from a user operation.\n */\n isUserOperation?: boolean;\n\n /**\n * The ID of the network client used by the transaction.\n */\n networkClientId?: NetworkClientId;\n\n /**\n * Network code as per EIP-155 for this transaction\n *\n * @deprecated Use `chainId` instead.\n */\n readonly networkID?: string;\n\n /**\n * Origin this transaction was sent from.\n */\n origin?: string;\n\n /**\n * The original dapp proposed token approval amount before edit by user.\n */\n originalApprovalAmount?: string;\n\n /**\n * The original gas estimation of the transaction.\n */\n originalGasEstimate?: string;\n\n /**\n * When we speed up a transaction, we set the type as Retry and we lose\n * information about type of transaction that is being set up, so we use\n * original type to track that information.\n */\n originalType?: TransactionType;\n\n /**\n * Account transaction balance after swap.\n */\n postTxBalance?: string;\n\n /**\n * Account transaction balance before swap.\n */\n preTxBalance?: string;\n\n /**\n * The previous gas properties before they were updated.\n */\n previousGas?: {\n /**\n * Maxmimum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n };\n\n /**\n * The transaction's 'r' value as a hex string.\n */\n r?: string;\n\n /**\n * Hex representation of the underlying transaction.\n */\n rawTx?: string;\n\n /**\n * When the transaction is dropped, this is the replacement transaction hash.\n */\n replacedBy?: string;\n\n /**\n * When the transaction is dropped, this is the replacement transaction ID.\n */\n replacedById?: string;\n\n /**\n * The number of times that the transaction submit has been retried.\n */\n retryCount?: number;\n\n /**\n * The transaction's 's' value as a hex string.\n */\n s?: string;\n\n /**\n * Response from security validator.\n */\n securityAlertResponse?: SecurityAlertResponse;\n\n /**\n * Response from security provider.\n */\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n securityProviderResponse?: Record<string, any>;\n\n /**\n * An array of entries that describe the user's journey through the send flow.\n * This is purely attached to state logs for troubleshooting and support.\n */\n sendFlowHistory?: SendFlowHistoryEntry[];\n\n /**\n * If the gas estimation fails, an object containing error and block information.\n */\n simulationFails?: {\n reason?: string;\n errorKey?: string;\n debug: {\n blockNumber?: string;\n blockGasLimit?: string;\n };\n };\n\n /**\n * The time the transaction was submitted to the network, in Unix epoch time (ms).\n */\n submittedTime?: number;\n\n /**\n * The symbol of the token being swapped.\n */\n sourceTokenSymbol?: string;\n\n /**\n * The metadata of the swap transaction.\n */\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n swapMetaData?: Record<string, any>;\n\n /**\n * The value of the token being swapped.\n */\n swapTokenValue?: string;\n\n /**\n * Timestamp associated with this transaction.\n */\n time: number;\n\n /**\n * Whether transaction recipient is a smart contract.\n */\n toSmartContract?: boolean;\n\n /**\n * Additional transfer information.\n */\n transferInformation?: {\n contractAddress: string;\n decimals: number;\n symbol: string;\n };\n\n /**\n * Underlying Transaction object.\n */\n txParams: TransactionParams;\n\n /**\n * Transaction receipt.\n */\n txReceipt?: TransactionReceipt;\n\n /**\n * The type of transaction such as `cancel` or `swap`.\n */\n type?: TransactionType;\n\n /**\n * The gas limit supplied by user.\n */\n userEditedGasLimit?: boolean;\n\n /**\n * Estimate level user selected.\n */\n userFeeLevel?: string;\n\n /**\n * The transaction's 'v' value as a hex string.\n */\n v?: string;\n\n /**\n * Whether the transaction is verified on the blockchain.\n */\n verifiedOnBlockchain?: boolean;\n\n /**\n * Warning information for the transaction.\n */\n warning?: {\n error: string;\n message: string;\n };\n};\n\nexport type SendFlowHistoryEntry = {\n /**\n * String to indicate user interaction information.\n */\n entry: string;\n\n /**\n * Timestamp associated with this entry.\n */\n timestamp: number;\n};\n\n/**\n * The status of the transaction. Each status represents the state of the transaction internally\n * in the wallet. Some of these correspond with the state of the transaction on the network, but\n * some are wallet-specific.\n */\nexport enum TransactionStatus {\n approved = 'approved',\n /** @deprecated Determined by the clients using the transaction type. No longer used. */\n cancelled = 'cancelled',\n confirmed = 'confirmed',\n dropped = 'dropped',\n failed = 'failed',\n rejected = 'rejected',\n signed = 'signed',\n submitted = 'submitted',\n unapproved = 'unapproved',\n}\n\n/**\n * Options for wallet device.\n */\nexport enum WalletDevice {\n MM_MOBILE = 'metamask_mobile',\n MM_EXTENSION = 'metamask_extension',\n OTHER = 'other_device',\n}\n\n/**\n * The type of the transaction.\n */\nexport enum TransactionType {\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n cancel = 'cancel',\n\n /**\n * A transaction that is interacting with a smart contract's methods that we\n * have not treated as a special case, such as approve, transfer, and\n * transferfrom.\n */\n contractInteraction = 'contractInteraction',\n\n /**\n * A transaction that deployed a smart contract.\n */\n deployContract = 'contractDeployment',\n\n /**\n * A transaction for Ethereum decryption.\n */\n ethDecrypt = 'eth_decrypt',\n\n /**\n * A transaction for getting an encryption public key.\n */\n ethGetEncryptionPublicKey = 'eth_getEncryptionPublicKey',\n\n /**\n * An incoming (deposit) transaction.\n */\n incoming = 'incoming',\n\n /**\n * A transaction for personal sign.\n */\n personalSign = 'personal_sign',\n\n /**\n * When a transaction is failed it can be retried by\n * resubmitting the same transaction with a higher gas fee. This type is also used\n * to speed up pending transactions. This is accomplished by creating a new tx with\n * the same nonce and higher gas fees.\n */\n retry = 'retry',\n\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n simpleSend = 'simpleSend',\n\n /**\n * A transaction that is signing a message.\n */\n sign = 'eth_sign',\n\n /**\n * A transaction that is signing typed data.\n */\n signTypedData = 'eth_signTypedData',\n\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n smart = 'smart',\n\n /**\n * A transaction swapping one token for another through MetaMask Swaps.\n */\n swap = 'swap',\n\n /**\n * Similar to the approve type, a swap approval is a special case of ERC20\n * approve method that requests an allowance of the token to spend on behalf\n * of the user for the MetaMask Swaps contract. The first swap for any token\n * will have an accompanying swapApproval transaction.\n */\n swapApproval = 'swapApproval',\n\n /**\n * A token transaction requesting an allowance of the token to spend on\n * behalf of the user.\n */\n tokenMethodApprove = 'approve',\n\n /**\n * A token transaction transferring tokens from an account that the sender\n * has an allowance of. The method is prefixed with safe because when calling\n * this method the contract checks to ensure that the receiver is an address\n * capable of handling the token being sent.\n */\n tokenMethodSafeTransferFrom = 'safetransferfrom',\n\n /**\n * A token transaction where the user is sending tokens that they own to\n * another address.\n */\n tokenMethodTransfer = 'transfer',\n\n /**\n * A token transaction transferring tokens from an account that the sender\n * has an allowance of. For more information on allowances, see the approve\n * type.\n */\n tokenMethodTransferFrom = 'transferfrom',\n\n /**\n * A token transaction requesting an allowance of all of a user's tokens to\n * spend on behalf of the user.\n */\n tokenMethodSetApprovalForAll = 'setapprovalforall',\n}\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface TransactionParams {\n /**\n * A list of addresses and storage keys that the transaction plans to access.\n */\n accessList?: AccessList;\n\n /**\n * Network ID as per EIP-155.\n */\n chainId?: Hex;\n\n /**\n * Data to pass with this transaction.\n */\n data?: string;\n\n /**\n * Error message for gas estimation failure.\n */\n estimateGasError?: string;\n\n /**\n * Estimated base fee for this transaction.\n */\n estimatedBaseFee?: string;\n\n /**\n * Which estimate level that the API suggested.\n */\n estimateSuggested?: string;\n\n /**\n * Which estimate level was used\n */\n estimateUsed?: string;\n\n /**\n * Address to send this transaction from.\n */\n from: string;\n\n /**\n * same as gasLimit?\n */\n gas?: string;\n\n /**\n * Maxmimum number of units of gas to use for this transaction.\n */\n gasLimit?: string;\n\n /**\n * Price per gas for legacy txs\n */\n gasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority\n * fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n\n /**\n * Unique number to prevent replay attacks.\n */\n nonce?: string;\n\n /**\n * Address to send this transaction to.\n */\n to?: string;\n\n /**\n * Value associated with this transaction.\n */\n value?: string;\n\n /**\n * Type of transaction.\n * 0x0 indicates a legacy transaction.\n */\n type?: string;\n}\n\n/**\n * Standard data concerning a transaction processed by the blockchain.\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface TransactionReceipt {\n /**\n * The block hash of the block that this transaction was included in.\n */\n blockHash?: string;\n\n /**\n * The block number of the block that this transaction was included in.\n */\n blockNumber?: string;\n\n /**\n * Effective gas price the transaction was charged at.\n */\n effectiveGasPrice?: string;\n\n /**\n * Gas used in the transaction.\n */\n gasUsed?: string;\n\n /**\n * Total used gas in hex.\n */\n l1Fee?: string;\n\n /**\n * All the logs emitted by this transaction.\n */\n logs?: Log[];\n\n /**\n * The status of the transaction.\n */\n status?: string;\n\n /**\n * The hexadecimal index of this transaction in the list of transactions included in the block this transaction was mined in.\n */\n transactionIndex?: string;\n}\n\n/**\n * Represents an event that has been included in a transaction using the EVM `LOG` opcode.\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface Log {\n /**\n * Address of the contract that generated log.\n */\n address?: string;\n /**\n * List of topics for log.\n */\n topics?: string;\n}\n\n/**\n * The configuration required to fetch transaction data from a RemoteTransactionSource.\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface RemoteTransactionSourceRequest {\n /**\n * The address of the account to fetch transactions for.\n */\n address: string;\n\n /**\n * The chainId of the current network.\n */\n currentChainId: Hex;\n\n /**\n * Block number to start fetching transactions from.\n */\n fromBlock?: number;\n\n /**\n * Maximum number of transactions to retrieve.\n */\n limit?: number;\n}\n\n/**\n * An object capable of fetching transaction data from a remote source.\n * Used by the IncomingTransactionHelper to retrieve remote transaction data.\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface RemoteTransactionSource {\n /**\n * @param chainId - The chainId of the current network.\n * @returns Whether the remote transaction source supports the specified network.\n */\n isSupportedNetwork: (chainId: Hex) => boolean;\n\n /**\n * @returns An array of additional keys to use when caching the last fetched block number.\n */\n getLastBlockVariations?: () => string[];\n\n /**\n * @param request - A request object containing data such as the address and chain ID.\n * @returns An array of transaction metadata for the retrieved transactions.\n */\n fetchTransactions: (\n request: RemoteTransactionSourceRequest,\n ) => Promise<TransactionMeta[]>;\n}\n\n/**\n * Gas values initially suggested by the dApp.\n */\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface DappSuggestedGasFees {\n gas?: string;\n gasPrice?: string;\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n}\n\n/**\n * Gas values saved by the user for a specific chain.\n */\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface SavedGasFees {\n maxBaseFee: string;\n priorityFee: string;\n}\n\n/**\n * A transaction history operation that includes a note and timestamp.\n */\ntype ExtendedHistoryOperation = Operation & {\n note?: string;\n timestamp?: number;\n};\n\n/**\n * A transaction history entry that includes the ExtendedHistoryOperation as the first element.\n */\nexport type TransactionHistoryEntry = [\n ExtendedHistoryOperation,\n ...Operation[],\n];\n\n/**\n * A transaction history that includes the transaction meta as the first element.\n * And the rest of the elements are the operation arrays that were applied to the transaction meta.\n */\nexport type TransactionHistory = [\n TransactionMeta,\n ...TransactionHistoryEntry[],\n];\n\n/**\n * Result of inferring the transaction type.\n */\nexport type InferTransactionTypeResult = {\n /**\n * The contract code, in hex format if it exists. '0x0' or\n * '0x' are also indicators of non-existent contract code.\n */\n getCodeResponse?: string | null;\n\n /**\n * The type of transaction\n */\n type: TransactionType;\n};\n\n/**\n * A function for verifying a transaction, whether it is malicious or not.\n */\nexport type SecurityProviderRequest = (\n requestData: TransactionMeta,\n messageType: string,\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => Promise<any>;\n\n/**\n * Specifies the shape of the base transaction parameters.\n * Added in EIP-2718.\n */\nexport enum TransactionEnvelopeType {\n /**\n * A legacy transaction, the very first type.\n */\n legacy = '0x0',\n\n /**\n * EIP-2930 defined the access list transaction type that allowed for\n * specifying the state that a transaction would act upon in advance and\n * theoretically save on gas fees.\n */\n accessList = '0x1',\n\n /**\n * The type introduced comes from EIP-1559, Fee Market describes the addition\n * of a baseFee to blocks that will be burned instead of distributed to\n * miners. Transactions of this type have both a maxFeePerGas (maximum total\n * amount in gwei per gas to spend on the transaction) which is inclusive of\n * the maxPriorityFeePerGas (maximum amount of gwei per gas from the\n * transaction fee to distribute to miner).\n */\n feeMarket = '0x2',\n}\n\n/**\n * The source of the gas fee parameters on a transaction.\n */\nexport enum UserFeeLevel {\n CUSTOM = 'custom',\n DAPP_SUGGESTED = 'dappSuggested',\n MEDIUM = 'medium',\n}\n\n/**\n * Initial gas values set when the transaction was first created.\n */\nexport type DefaultGasEstimates = {\n /**\n * Source of the gas fee values, such as `dappSuggested` or `medium`.\n */\n estimateType?: string;\n\n /**\n * Maxmimum number of units of gas to use for this transaction.\n */\n gas?: string;\n\n /**\n * Price per gas for legacy transactions.\n */\n gasPrice?: string;\n\n /**\n * Maximum amount per gas to pay for the transaction, including the priority fee.\n */\n maxFeePerGas?: string;\n\n /**\n * Maximum amount per gas to give to validator as incentive.\n */\n maxPriorityFeePerGas?: string;\n};\n\n/**\n * Data concerning an error while processing a transaction.\n */\nexport type TransactionError = {\n /**\n * A descriptive error name.\n */\n name: string;\n\n /**\n * A descriptive error message providing details about the encountered error.\n */\n message: string;\n\n /**\n * The stack trace associated with the error, if available.\n */\n stack?: string;\n\n /**\n * An optional error code associated with the error.\n */\n code?: string;\n\n /**\n * The rpc property holds additional information related to the error.\n */\n rpc?: unknown;\n};\n\n/**\n * Type for security alert response from transaction validator.\n */\nexport type SecurityAlertResponse = {\n reason: string;\n features?: string[];\n result_type: string;\n providerRequestsCount?: Record<string, number>;\n};\n\n/** Gas fee estimates for a specific priority level. */\nexport type GasFeeEstimatesForLevel = {\n /** Maximum amount to pay per gas. */\n maxFeePerGas: Hex;\n\n /** Maximum amount per gas to give to the validator as an incentive. */\n maxPriorityFeePerGas: Hex;\n};\n\n/** Alternate priority levels for which values are provided in gas fee estimates. */\nexport enum GasFeeEstimateLevel {\n low = 'low',\n medium = 'medium',\n high = 'high',\n}\n\n/** Gas fee estimates for a transaction. */\nexport type GasFeeEstimates = {\n /** The gas fee estimate for a low priority transaction. */\n [GasFeeEstimateLevel.low]: GasFeeEstimatesForLevel;\n\n /** The gas fee estimate for a medium priority transaction. */\n [GasFeeEstimateLevel.medium]: GasFeeEstimatesForLevel;\n\n /** The gas fee estimate for a high priority transaction. */\n [GasFeeEstimateLevel.high]: GasFeeEstimatesForLevel;\n};\n\n/** Request to a gas fee flow to obtain gas fee estimates. */\nexport type GasFeeFlowRequest = {\n /** An EthQuery instance to enable queries to the associated RPC provider. */\n ethQuery: EthQuery;\n\n /** Callback to get the GasFeeController estimates. */\n getGasFeeControllerEstimates: (\n options: FetchGasFeeEstimateOptions,\n ) => Promise<GasFeeState>;\n\n /** The metadata of the transaction to obtain estimates for. */\n transactionMeta: TransactionMeta;\n};\n\n/** Response from a gas fee flow containing gas fee estimates. */\nexport type GasFeeFlowResponse = {\n /** The gas fee estimates for the transaction. */\n estimates: GasFeeEstimates;\n};\n\n/** A method of obtaining gas fee estimates for a specific transaction. */\nexport type GasFeeFlow = {\n /**\n * Determine if the gas fee flow supports the specified transaction.\n * @param transactionMeta - The transaction metadata.\n * @returns Whether the gas fee flow supports the transaction.\n */\n matchesTransaction(transactionMeta: TransactionMeta): boolean;\n\n /**\n * Get gas fee estimates for a specific transaction.\n * @param request - The gas fee flow request.\n * @returns The gas fee flow response containing the gas fee estimates.\n */\n getGasFees: (request: GasFeeFlowRequest) => Promise<GasFeeFlowResponse>;\n};\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
package/dist/types.mjs ADDED
@@ -0,0 +1,20 @@
1
+ import {
2
+ GasFeeEstimateLevel,
3
+ SimulationTokenStandard,
4
+ TransactionEnvelopeType,
5
+ TransactionStatus,
6
+ TransactionType,
7
+ UserFeeLevel,
8
+ WalletDevice
9
+ } from "./chunk-LM4NUNMT.mjs";
10
+ import "./chunk-XUI43LEZ.mjs";
11
+ export {
12
+ GasFeeEstimateLevel,
13
+ SimulationTokenStandard,
14
+ TransactionEnvelopeType,
15
+ TransactionStatus,
16
+ TransactionType,
17
+ UserFeeLevel,
18
+ WalletDevice
19
+ };
20
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,119 +1,14 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getEtherscanApiHost = exports.fetchEtherscanTokenTransactions = exports.fetchEtherscanTransactions = void 0;
13
- const controller_utils_1 = require("@metamask/controller-utils");
14
- const constants_1 = require("../constants");
15
- const logger_1 = require("../logger");
16
- /**
17
- * Retrieves transaction data from Etherscan.
18
- *
19
- * @param request - Configuration required to fetch transactions.
20
- * @param request.address - Address to retrieve transactions for.
21
- * @param request.chainId - Current chain ID used to determine subdomain and domain.
22
- * @param request.fromBlock - Block number to start fetching transactions from.
23
- * @param request.limit - Number of transactions to retrieve.
24
- * @returns An Etherscan response object containing the request status and an array of token transaction data.
25
- */
26
- function fetchEtherscanTransactions({ address, chainId, fromBlock, limit, }) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- return yield fetchTransactions('txlist', {
29
- address,
30
- chainId,
31
- fromBlock,
32
- limit,
33
- });
34
- });
35
- }
36
- exports.fetchEtherscanTransactions = fetchEtherscanTransactions;
37
- /**
38
- * Retrieves token transaction data from Etherscan.
39
- *
40
- * @param request - Configuration required to fetch token transactions.
41
- * @param request.address - Address to retrieve token transactions for.
42
- * @param request.chainId - Current chain ID used to determine subdomain and domain.
43
- * @param request.fromBlock - Block number to start fetching token transactions from.
44
- * @param request.limit - Number of token transactions to retrieve.
45
- * @returns An Etherscan response object containing the request status and an array of token transaction data.
46
- */
47
- function fetchEtherscanTokenTransactions({ address, chainId, fromBlock, limit, }) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- return yield fetchTransactions('tokentx', {
50
- address,
51
- chainId,
52
- fromBlock,
53
- limit,
54
- });
55
- });
56
- }
57
- exports.fetchEtherscanTokenTransactions = fetchEtherscanTokenTransactions;
58
- /**
59
- * Retrieves transaction data from Etherscan from a specific endpoint.
60
- *
61
- * @param action - The Etherscan endpoint to use.
62
- * @param options - Options bag.
63
- * @param options.address - Address to retrieve transactions for.
64
- * @param options.chainId - Current chain ID used to determine subdomain and domain.
65
- * @param options.fromBlock - Block number to start fetching transactions from.
66
- * @param options.limit - Number of transactions to retrieve.
67
- * @returns An object containing the request status and an array of transaction data.
68
- */
69
- function fetchTransactions(action, { address, chainId, fromBlock, limit, }) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- const urlParams = {
72
- module: 'account',
73
- address,
74
- startBlock: fromBlock === null || fromBlock === void 0 ? void 0 : fromBlock.toString(),
75
- offset: limit === null || limit === void 0 ? void 0 : limit.toString(),
76
- sort: 'desc',
77
- };
78
- const etherscanTxUrl = getEtherscanApiUrl(chainId, Object.assign(Object.assign({}, urlParams), { action }));
79
- (0, logger_1.incomingTransactionsLogger)('Sending Etherscan request', etherscanTxUrl);
80
- const response = (yield (0, controller_utils_1.handleFetch)(etherscanTxUrl));
81
- return response;
82
- });
83
- }
84
- /**
85
- * Return a URL that can be used to fetch data from Etherscan.
86
- *
87
- * @param chainId - Current chain ID used to determine subdomain and domain.
88
- * @param urlParams - The parameters used to construct the URL.
89
- * @returns URL to access Etherscan data.
90
- */
91
- function getEtherscanApiUrl(chainId, urlParams) {
92
- const apiUrl = getEtherscanApiHost(chainId);
93
- let url = `${apiUrl}/api?`;
94
- for (const paramKey of Object.keys(urlParams)) {
95
- const value = urlParams[paramKey];
96
- if (!value) {
97
- continue;
98
- }
99
- url += `${paramKey}=${value}&`;
100
- }
101
- url += 'tag=latest&page=1';
102
- return url;
103
- }
104
- /**
105
- * Return the host url used to fetch data from Etherscan.
106
- *
107
- * @param chainId - Current chain ID used to determine subdomain and domain.
108
- * @returns host URL to access Etherscan data.
109
- */
110
- function getEtherscanApiHost(chainId) {
111
- // @ts-expect-error We account for `chainId` not being a property below
112
- const networkInfo = constants_1.ETHERSCAN_SUPPORTED_NETWORKS[chainId];
113
- if (!networkInfo) {
114
- throw new Error(`Etherscan does not support chain with ID: ${chainId}`);
115
- }
116
- return `https://${networkInfo.subdomain}.${networkInfo.domain}`;
117
- }
118
- exports.getEtherscanApiHost = getEtherscanApiHost;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkNUOBUW7Cjs = require('../chunk-NUOBUW7C.js');
6
+ require('../chunk-RI6MVJJN.js');
7
+ require('../chunk-S6VGOPUY.js');
8
+ require('../chunk-Z4BLTVTB.js');
9
+
10
+
11
+
12
+
13
+ exports.fetchEtherscanTokenTransactions = _chunkNUOBUW7Cjs.fetchEtherscanTokenTransactions; exports.fetchEtherscanTransactions = _chunkNUOBUW7Cjs.fetchEtherscanTransactions; exports.getEtherscanApiHost = _chunkNUOBUW7Cjs.getEtherscanApiHost;
119
14
  //# sourceMappingURL=etherscan.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"etherscan.js","sourceRoot":"","sources":["../../src/utils/etherscan.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iEAAyD;AAGzD,4CAA4D;AAC5D,sCAA8D;AAiE9D;;;;;;;;;GASG;AACH,SAAsB,0BAA0B,CAAC,EAC/C,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,GACuB;;QAG5B,OAAO,MAAM,iBAAiB,CAAC,QAAQ,EAAE;YACvC,OAAO;YACP,OAAO;YACP,SAAS;YACT,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CAAA;AAdD,gEAcC;AAED;;;;;;;;;GASG;AACH,SAAsB,+BAA+B,CAAC,EACpD,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,GACuB;;QAG5B,OAAO,MAAM,iBAAiB,CAAC,SAAS,EAAE;YACxC,OAAO;YACP,OAAO;YACP,SAAS;YACT,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CAAA;AAdD,0EAcC;AAED;;;;;;;;;;GAUG;AACH,SAAe,iBAAiB,CAC9B,MAAc,EACd,EACE,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,GAMN;;QAED,MAAM,SAAS,GAAG;YAChB,MAAM,EAAE,SAAS;YACjB,OAAO;YACP,UAAU,EAAE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE;YACjC,MAAM,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE;YACzB,IAAI,EAAE,MAAM;SACb,CAAC;QAEF,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,kCAC5C,SAAS,KACZ,MAAM,IACN,CAAC;QAEH,IAAA,mCAAG,EAAC,2BAA2B,EAAE,cAAc,CAAC,CAAC;QAEjD,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,8BAAW,EACjC,cAAc,CACf,CAAoC,CAAC;QAEtC,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CACzB,OAAY,EACZ,SAA6C;IAE7C,MAAM,MAAM,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,GAAG,GAAG,GAAG,MAAM,OAAO,CAAC;IAE3B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAElC,IAAI,CAAC,KAAK,EAAE;YACV,SAAS;SACV;QAED,GAAG,IAAI,GAAG,QAAQ,IAAI,KAAK,GAAG,CAAC;KAChC;IAED,GAAG,IAAI,mBAAmB,CAAC;IAE3B,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,OAAY;IAC9C,uEAAuE;IACvE,MAAM,WAAW,GAAG,wCAA4B,CAAC,OAAO,CAAC,CAAC;IAE1D,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,6CAA6C,OAAO,EAAE,CAAC,CAAC;KACzE;IAED,OAAO,WAAW,WAAW,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;AAClE,CAAC;AATD,kDASC","sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants';\nimport { incomingTransactionsLogger as log } from '../logger';\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionMetaBase {\n blockNumber: string;\n blockHash: string;\n confirmations: string;\n contractAddress: string;\n cumulativeGasUsed: string;\n from: string;\n gas: string;\n gasPrice: string;\n gasUsed: string;\n hash: string;\n nonce: string;\n timeStamp: string;\n to: string;\n transactionIndex: string;\n value: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionMeta extends EtherscanTransactionMetaBase {\n functionName: string;\n input: string;\n isError: string;\n methodId: string;\n txreceipt_status: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTokenTransactionMeta\n extends EtherscanTransactionMetaBase {\n tokenDecimal: string;\n tokenName: string;\n tokenSymbol: string;\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionResponse<\n T extends EtherscanTransactionMetaBase,\n> {\n status: '0' | '1';\n message?: string;\n result: string | T[];\n}\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface EtherscanTransactionRequest {\n address: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\n}\n\n/**\n * Retrieves transaction data from Etherscan.\n *\n * @param request - Configuration required to fetch transactions.\n * @param request.address - Address to retrieve transactions for.\n * @param request.chainId - Current chain ID used to determine subdomain and domain.\n * @param request.fromBlock - Block number to start fetching transactions from.\n * @param request.limit - Number of transactions to retrieve.\n * @returns An Etherscan response object containing the request status and an array of token transaction data.\n */\nexport async function fetchEtherscanTransactions({\n address,\n chainId,\n fromBlock,\n limit,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse<EtherscanTransactionMeta>\n> {\n return await fetchTransactions('txlist', {\n address,\n chainId,\n fromBlock,\n limit,\n });\n}\n\n/**\n * Retrieves token transaction data from Etherscan.\n *\n * @param request - Configuration required to fetch token transactions.\n * @param request.address - Address to retrieve token transactions for.\n * @param request.chainId - Current chain ID used to determine subdomain and domain.\n * @param request.fromBlock - Block number to start fetching token transactions from.\n * @param request.limit - Number of token transactions to retrieve.\n * @returns An Etherscan response object containing the request status and an array of token transaction data.\n */\nexport async function fetchEtherscanTokenTransactions({\n address,\n chainId,\n fromBlock,\n limit,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse<EtherscanTokenTransactionMeta>\n> {\n return await fetchTransactions('tokentx', {\n address,\n chainId,\n fromBlock,\n limit,\n });\n}\n\n/**\n * Retrieves transaction data from Etherscan from a specific endpoint.\n *\n * @param action - The Etherscan endpoint to use.\n * @param options - Options bag.\n * @param options.address - Address to retrieve transactions for.\n * @param options.chainId - Current chain ID used to determine subdomain and domain.\n * @param options.fromBlock - Block number to start fetching transactions from.\n * @param options.limit - Number of transactions to retrieve.\n * @returns An object containing the request status and an array of transaction data.\n */\nasync function fetchTransactions<T extends EtherscanTransactionMetaBase>(\n action: string,\n {\n address,\n chainId,\n fromBlock,\n limit,\n }: {\n address: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\n },\n): Promise<EtherscanTransactionResponse<T>> {\n const urlParams = {\n module: 'account',\n address,\n startBlock: fromBlock?.toString(),\n offset: limit?.toString(),\n sort: 'desc',\n };\n\n const etherscanTxUrl = getEtherscanApiUrl(chainId, {\n ...urlParams,\n action,\n });\n\n log('Sending Etherscan request', etherscanTxUrl);\n\n const response = (await handleFetch(\n etherscanTxUrl,\n )) as EtherscanTransactionResponse<T>;\n\n return response;\n}\n\n/**\n * Return a URL that can be used to fetch data from Etherscan.\n *\n * @param chainId - Current chain ID used to determine subdomain and domain.\n * @param urlParams - The parameters used to construct the URL.\n * @returns URL to access Etherscan data.\n */\nfunction getEtherscanApiUrl(\n chainId: Hex,\n urlParams: Record<string, string | undefined>,\n): string {\n const apiUrl = getEtherscanApiHost(chainId);\n let url = `${apiUrl}/api?`;\n\n for (const paramKey of Object.keys(urlParams)) {\n const value = urlParams[paramKey];\n\n if (!value) {\n continue;\n }\n\n url += `${paramKey}=${value}&`;\n }\n\n url += 'tag=latest&page=1';\n\n return url;\n}\n\n/**\n * Return the host url used to fetch data from Etherscan.\n *\n * @param chainId - Current chain ID used to determine subdomain and domain.\n * @returns host URL to access Etherscan data.\n */\nexport function getEtherscanApiHost(chainId: Hex) {\n // @ts-expect-error We account for `chainId` not being a property below\n const networkInfo = ETHERSCAN_SUPPORTED_NETWORKS[chainId];\n\n if (!networkInfo) {\n throw new Error(`Etherscan does not support chain with ID: ${chainId}`);\n }\n\n return `https://${networkInfo.subdomain}.${networkInfo.domain}`;\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import {
2
+ fetchEtherscanTokenTransactions,
3
+ fetchEtherscanTransactions,
4
+ getEtherscanApiHost
5
+ } from "../chunk-Y734U4V6.mjs";
6
+ import "../chunk-MHM5LRRF.mjs";
7
+ import "../chunk-UQQWZT6C.mjs";
8
+ import "../chunk-XUI43LEZ.mjs";
9
+ export {
10
+ fetchEtherscanTokenTransactions,
11
+ fetchEtherscanTransactions,
12
+ getEtherscanApiHost
13
+ };
14
+ //# sourceMappingURL=etherscan.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,36 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateConfirmedExternalTransaction = void 0;
4
- // These utility functions are exclusively used by `confirmExternalTransaction` method in controller
5
- const rpc_errors_1 = require("@metamask/rpc-errors");
6
- const types_1 = require("../types");
7
- /**
8
- * Validates the external provided transaction meta.
9
- *
10
- * @param transactionMeta - The transaction meta to validate.
11
- * @param confirmedTxs - The confirmed transactions in controller state.
12
- * @param pendingTxs - The submitted transactions in controller state.
13
- */
14
- function validateConfirmedExternalTransaction(transactionMeta, confirmedTxs, pendingTxs) {
15
- if (!transactionMeta || !transactionMeta.txParams) {
16
- throw rpc_errors_1.rpcErrors.invalidParams('"transactionMeta" or "transactionMeta.txParams" is missing');
17
- }
18
- if (transactionMeta.status !== types_1.TransactionStatus.confirmed) {
19
- throw rpc_errors_1.rpcErrors.invalidParams('External transaction status should be "confirmed"');
20
- }
21
- const externalTxNonce = transactionMeta.txParams.nonce;
22
- if (pendingTxs && pendingTxs.length > 0) {
23
- const foundPendingTxByNonce = pendingTxs.find((tx) => { var _a; return ((_a = tx.txParams) === null || _a === void 0 ? void 0 : _a.nonce) === externalTxNonce; });
24
- if (foundPendingTxByNonce) {
25
- throw rpc_errors_1.rpcErrors.invalidParams('External transaction nonce should not be in pending txs');
26
- }
27
- }
28
- if (confirmedTxs && confirmedTxs.length > 0) {
29
- const foundConfirmedTxByNonce = confirmedTxs.find((tx) => { var _a; return ((_a = tx.txParams) === null || _a === void 0 ? void 0 : _a.nonce) === externalTxNonce; });
30
- if (foundConfirmedTxByNonce) {
31
- throw rpc_errors_1.rpcErrors.invalidParams('External transaction nonce should not be in confirmed txs');
32
- }
33
- }
34
- }
35
- exports.validateConfirmedExternalTransaction = validateConfirmedExternalTransaction;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk7LXE4KHVjs = require('../chunk-7LXE4KHV.js');
4
+ require('../chunk-HPNXIKFY.js');
5
+ require('../chunk-Z4BLTVTB.js');
6
+
7
+
8
+ exports.validateConfirmedExternalTransaction = _chunk7LXE4KHVjs.validateConfirmedExternalTransaction;
36
9
  //# sourceMappingURL=external-transactions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-transactions.js","sourceRoot":"","sources":["../../src/utils/external-transactions.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,qDAAiD;AAEjD,oCAA6C;AAG7C;;;;;;GAMG;AACH,SAAgB,oCAAoC,CAClD,eAAiC,EACjC,YAAgC,EAChC,UAA8B;IAE9B,IAAI,CAAC,eAAe,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;QACjD,MAAM,sBAAS,CAAC,aAAa,CAC3B,4DAA4D,CAC7D,CAAC;KACH;IAED,IAAI,eAAe,CAAC,MAAM,KAAK,yBAAiB,CAAC,SAAS,EAAE;QAC1D,MAAM,sBAAS,CAAC,aAAa,CAC3B,mDAAmD,CACpD,CAAC;KACH;IAED,MAAM,eAAe,GAAG,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC;IACvD,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;QACvC,MAAM,qBAAqB,GAAG,UAAU,CAAC,IAAI,CAC3C,CAAC,EAAE,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,EAAE,CAAC,QAAQ,0CAAE,KAAK,MAAK,eAAe,CAAA,EAAA,CAC/C,CAAC;QACF,IAAI,qBAAqB,EAAE;YACzB,MAAM,sBAAS,CAAC,aAAa,CAC3B,yDAAyD,CAC1D,CAAC;SACH;KACF;IAED,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3C,MAAM,uBAAuB,GAAG,YAAY,CAAC,IAAI,CAC/C,CAAC,EAAE,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,EAAE,CAAC,QAAQ,0CAAE,KAAK,MAAK,eAAe,CAAA,EAAA,CAC/C,CAAC;QACF,IAAI,uBAAuB,EAAE;YAC3B,MAAM,sBAAS,CAAC,aAAa,CAC3B,2DAA2D,CAC5D,CAAC;SACH;KACF;AACH,CAAC;AAvCD,oFAuCC","sourcesContent":["// These utility functions are exclusively used by `confirmExternalTransaction` method in controller\nimport { rpcErrors } from '@metamask/rpc-errors';\n\nimport { TransactionStatus } from '../types';\nimport type { TransactionMeta } from '../types';\n\n/**\n * Validates the external provided transaction meta.\n *\n * @param transactionMeta - The transaction meta to validate.\n * @param confirmedTxs - The confirmed transactions in controller state.\n * @param pendingTxs - The submitted transactions in controller state.\n */\nexport function validateConfirmedExternalTransaction(\n transactionMeta?: TransactionMeta,\n confirmedTxs?: TransactionMeta[],\n pendingTxs?: TransactionMeta[],\n) {\n if (!transactionMeta || !transactionMeta.txParams) {\n throw rpcErrors.invalidParams(\n '\"transactionMeta\" or \"transactionMeta.txParams\" is missing',\n );\n }\n\n if (transactionMeta.status !== TransactionStatus.confirmed) {\n throw rpcErrors.invalidParams(\n 'External transaction status should be \"confirmed\"',\n );\n }\n\n const externalTxNonce = transactionMeta.txParams.nonce;\n if (pendingTxs && pendingTxs.length > 0) {\n const foundPendingTxByNonce = pendingTxs.find(\n (tx) => tx.txParams?.nonce === externalTxNonce,\n );\n if (foundPendingTxByNonce) {\n throw rpcErrors.invalidParams(\n 'External transaction nonce should not be in pending txs',\n );\n }\n }\n\n if (confirmedTxs && confirmedTxs.length > 0) {\n const foundConfirmedTxByNonce = confirmedTxs.find(\n (tx) => tx.txParams?.nonce === externalTxNonce,\n );\n if (foundConfirmedTxByNonce) {\n throw rpcErrors.invalidParams(\n 'External transaction nonce should not be in confirmed txs',\n );\n }\n }\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import {
2
+ validateConfirmedExternalTransaction
3
+ } from "../chunk-FRKQ3Z2L.mjs";
4
+ import "../chunk-LM4NUNMT.mjs";
5
+ import "../chunk-XUI43LEZ.mjs";
6
+ export {
7
+ validateConfirmedExternalTransaction
8
+ };
9
+ //# sourceMappingURL=external-transactions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}