@metamask/transaction-controller 32.0.0 → 33.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 (145) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/dist/TransactionController.js +17 -17
  3. package/dist/TransactionController.mjs +16 -16
  4. package/dist/{chunk-Q6Q44V4W.js → chunk-3LWN55E6.js} +6 -6
  5. package/dist/{chunk-RAOYRJ25.js → chunk-3WTSRETF.js} +1 -1
  6. package/dist/chunk-3WTSRETF.js.map +1 -0
  7. package/dist/{chunk-Y7ENNK7L.mjs → chunk-3ZV5YEUV.mjs} +6 -5
  8. package/dist/chunk-3ZV5YEUV.mjs.map +1 -0
  9. package/dist/{chunk-3ZRHCVVS.js → chunk-4IBBHNWG.js} +7 -5
  10. package/dist/chunk-4IBBHNWG.js.map +1 -0
  11. package/dist/{chunk-AZ4WIRH3.mjs → chunk-4V4XIPCI.mjs} +5 -2
  12. package/dist/chunk-4V4XIPCI.mjs.map +1 -0
  13. package/dist/{chunk-NM6OYEPP.mjs → chunk-5ZEJT5SN.mjs} +6 -2
  14. package/dist/chunk-5ZEJT5SN.mjs.map +1 -0
  15. package/dist/{chunk-5YES3V2R.mjs → chunk-6B5BEO3R.mjs} +1 -1
  16. package/dist/chunk-6B5BEO3R.mjs.map +1 -0
  17. package/dist/{chunk-PUESYN62.js → chunk-6OLJWLKK.js} +6 -3
  18. package/dist/chunk-6OLJWLKK.js.map +1 -0
  19. package/dist/{chunk-IT3SYNZ6.js → chunk-74W7X6BE.js} +1 -1
  20. package/dist/chunk-74W7X6BE.js.map +1 -0
  21. package/dist/{chunk-7MKQDZKY.js → chunk-7KREIKNY.js} +3 -3
  22. package/dist/{chunk-EQT25RSP.js → chunk-7NMV2NPM.js} +6 -4
  23. package/dist/chunk-7NMV2NPM.js.map +1 -0
  24. package/dist/{chunk-CDF4QNJA.mjs → chunk-D6BF3IZK.mjs} +2 -2
  25. package/dist/{chunk-QZLPYOGC.mjs → chunk-EGQCE3FK.mjs} +1 -1
  26. package/dist/chunk-EGQCE3FK.mjs.map +1 -0
  27. package/dist/{chunk-CPMTUMMZ.mjs → chunk-EKJXGERC.mjs} +4 -2
  28. package/dist/chunk-EKJXGERC.mjs.map +1 -0
  29. package/dist/{chunk-AHSDUIMT.mjs → chunk-EVL6KODQ.mjs} +1 -1
  30. package/dist/chunk-EVL6KODQ.mjs.map +1 -0
  31. package/dist/{chunk-IJ5GUKRO.mjs → chunk-GNAL5HC2.mjs} +2 -2
  32. package/dist/{chunk-PQCHA5KF.mjs → chunk-K2JC276W.mjs} +38 -26
  33. package/dist/chunk-K2JC276W.mjs.map +1 -0
  34. package/dist/{chunk-G5U6ABRU.mjs → chunk-KLDYR4HR.mjs} +5 -3
  35. package/dist/{chunk-G5U6ABRU.mjs.map → chunk-KLDYR4HR.mjs.map} +1 -1
  36. package/dist/{chunk-METHOFMG.mjs → chunk-KPP6SU7S.mjs} +1 -1
  37. package/dist/chunk-KPP6SU7S.mjs.map +1 -0
  38. package/dist/{chunk-PBYK4OMK.js → chunk-LLXPT2H5.js} +83 -71
  39. package/dist/chunk-LLXPT2H5.js.map +1 -0
  40. package/dist/{chunk-NRQUBP3S.mjs → chunk-MILG772S.mjs} +2 -2
  41. package/dist/{chunk-YXSCBWTU.js → chunk-N6OMDPDK.js} +9 -9
  42. package/dist/{chunk-YXSCBWTU.js.map → chunk-N6OMDPDK.js.map} +1 -1
  43. package/dist/{chunk-V6HVF4EN.mjs → chunk-OGK76ZPK.mjs} +3 -3
  44. package/dist/chunk-OGK76ZPK.mjs.map +1 -0
  45. package/dist/{chunk-UGFBA4GV.js → chunk-OZ6UB42C.js} +5 -1
  46. package/dist/chunk-OZ6UB42C.js.map +1 -0
  47. package/dist/{chunk-J56A7UCK.mjs → chunk-Q56I5ONX.mjs} +5 -1
  48. package/dist/chunk-Q56I5ONX.mjs.map +1 -0
  49. package/dist/{chunk-UT4M4XI3.js → chunk-QH2H4W3N.js} +5 -5
  50. package/dist/{chunk-DTDTOMTB.js → chunk-RHDPOIS4.js} +6 -5
  51. package/dist/chunk-RHDPOIS4.js.map +1 -0
  52. package/dist/{chunk-VH47Q6TS.js → chunk-RXIUMVA5.js} +7 -3
  53. package/dist/chunk-RXIUMVA5.js.map +1 -0
  54. package/dist/{chunk-5KMU2IAT.js → chunk-ULD4JC3Q.js} +1 -1
  55. package/dist/chunk-ULD4JC3Q.js.map +1 -0
  56. package/dist/{chunk-2TUDWNEI.mjs → chunk-UZFDPHQI.mjs} +3 -3
  57. package/dist/{chunk-DLOQPH4M.js → chunk-V4FONAI2.js} +4 -4
  58. package/dist/{chunk-FDUCRHYT.js → chunk-XVYXRCRL.js} +1 -1
  59. package/dist/chunk-XVYXRCRL.js.map +1 -0
  60. package/dist/errors.js +1 -1
  61. package/dist/errors.mjs +1 -1
  62. package/dist/gas-flows/DefaultGasFeeFlow.js +7 -7
  63. package/dist/gas-flows/DefaultGasFeeFlow.mjs +6 -6
  64. package/dist/gas-flows/LineaGasFeeFlow.js +8 -8
  65. package/dist/gas-flows/LineaGasFeeFlow.mjs +7 -7
  66. package/dist/gas-flows/TestGasFeeFlow.js +1 -1
  67. package/dist/gas-flows/TestGasFeeFlow.mjs +1 -1
  68. package/dist/helpers/EtherscanRemoteTransactionSource.js +4 -4
  69. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +3 -3
  70. package/dist/helpers/GasFeePoller.js +4 -4
  71. package/dist/helpers/GasFeePoller.mjs +3 -3
  72. package/dist/helpers/IncomingTransactionHelper.js +2 -2
  73. package/dist/helpers/IncomingTransactionHelper.mjs +1 -1
  74. package/dist/helpers/MultichainTrackingHelper.js +5 -5
  75. package/dist/helpers/MultichainTrackingHelper.mjs +4 -4
  76. package/dist/helpers/PendingTransactionTracker.js +3 -3
  77. package/dist/helpers/PendingTransactionTracker.mjs +2 -2
  78. package/dist/index.js +17 -17
  79. package/dist/index.mjs +16 -16
  80. package/dist/tsconfig.build.tsbuildinfo +1 -1
  81. package/dist/types/TransactionController.d.ts +3 -5
  82. package/dist/types/TransactionController.d.ts.map +1 -1
  83. package/dist/types/gas-flows/DefaultGasFeeFlow.d.ts.map +1 -1
  84. package/dist/types/helpers/EtherscanRemoteTransactionSource.d.ts.map +1 -1
  85. package/dist/types/helpers/IncomingTransactionHelper.d.ts +2 -1
  86. package/dist/types/helpers/IncomingTransactionHelper.d.ts.map +1 -1
  87. package/dist/types/helpers/MultichainTrackingHelper.d.ts.map +1 -1
  88. package/dist/types/helpers/PendingTransactionTracker.d.ts.map +1 -1
  89. package/dist/types/types.d.ts.map +1 -1
  90. package/dist/types/utils/etherscan.d.ts.map +1 -1
  91. package/dist/types/utils/simulation.d.ts.map +1 -1
  92. package/dist/types/utils/utils.d.ts.map +1 -1
  93. package/dist/types.js +2 -2
  94. package/dist/types.mjs +1 -1
  95. package/dist/utils/etherscan.js +2 -2
  96. package/dist/utils/etherscan.mjs +1 -1
  97. package/dist/utils/external-transactions.js +1 -1
  98. package/dist/utils/external-transactions.mjs +1 -1
  99. package/dist/utils/gas-fees.js +6 -6
  100. package/dist/utils/gas-fees.mjs +5 -5
  101. package/dist/utils/gas-flow.js +3 -3
  102. package/dist/utils/gas-flow.mjs +2 -2
  103. package/dist/utils/simulation-api.js +1 -1
  104. package/dist/utils/simulation-api.mjs +1 -1
  105. package/dist/utils/simulation.js +3 -3
  106. package/dist/utils/simulation.mjs +2 -2
  107. package/dist/utils/swaps.js +4 -4
  108. package/dist/utils/swaps.mjs +3 -3
  109. package/dist/utils/transaction-type.js +1 -1
  110. package/dist/utils/transaction-type.mjs +1 -1
  111. package/dist/utils/utils.js +3 -3
  112. package/dist/utils/utils.mjs +2 -2
  113. package/dist/utils/validation.js +4 -4
  114. package/dist/utils/validation.mjs +3 -3
  115. package/package.json +5 -1
  116. package/dist/chunk-3ZRHCVVS.js.map +0 -1
  117. package/dist/chunk-5KMU2IAT.js.map +0 -1
  118. package/dist/chunk-5YES3V2R.mjs.map +0 -1
  119. package/dist/chunk-AHSDUIMT.mjs.map +0 -1
  120. package/dist/chunk-AZ4WIRH3.mjs.map +0 -1
  121. package/dist/chunk-CPMTUMMZ.mjs.map +0 -1
  122. package/dist/chunk-DTDTOMTB.js.map +0 -1
  123. package/dist/chunk-EQT25RSP.js.map +0 -1
  124. package/dist/chunk-FDUCRHYT.js.map +0 -1
  125. package/dist/chunk-IT3SYNZ6.js.map +0 -1
  126. package/dist/chunk-J56A7UCK.mjs.map +0 -1
  127. package/dist/chunk-METHOFMG.mjs.map +0 -1
  128. package/dist/chunk-NM6OYEPP.mjs.map +0 -1
  129. package/dist/chunk-PBYK4OMK.js.map +0 -1
  130. package/dist/chunk-PQCHA5KF.mjs.map +0 -1
  131. package/dist/chunk-PUESYN62.js.map +0 -1
  132. package/dist/chunk-QZLPYOGC.mjs.map +0 -1
  133. package/dist/chunk-RAOYRJ25.js.map +0 -1
  134. package/dist/chunk-UGFBA4GV.js.map +0 -1
  135. package/dist/chunk-V6HVF4EN.mjs.map +0 -1
  136. package/dist/chunk-VH47Q6TS.js.map +0 -1
  137. package/dist/chunk-Y7ENNK7L.mjs.map +0 -1
  138. /package/dist/{chunk-Q6Q44V4W.js.map → chunk-3LWN55E6.js.map} +0 -0
  139. /package/dist/{chunk-7MKQDZKY.js.map → chunk-7KREIKNY.js.map} +0 -0
  140. /package/dist/{chunk-CDF4QNJA.mjs.map → chunk-D6BF3IZK.mjs.map} +0 -0
  141. /package/dist/{chunk-IJ5GUKRO.mjs.map → chunk-GNAL5HC2.mjs.map} +0 -0
  142. /package/dist/{chunk-NRQUBP3S.mjs.map → chunk-MILG772S.mjs.map} +0 -0
  143. /package/dist/{chunk-UT4M4XI3.js.map → chunk-QH2H4W3N.js.map} +0 -0
  144. /package/dist/{chunk-2TUDWNEI.mjs.map → chunk-UZFDPHQI.mjs.map} +0 -0
  145. /package/dist/{chunk-DLOQPH4M.js.map → chunk-V4FONAI2.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [33.0.0]
11
+
12
+ ### Changed
13
+
14
+ - **BREAKING:** The `TransactionController` messenger must now allow the `AccountsController:getSelectedAccount` action ([#4244](https://github.com/MetaMask/core/pull/4244))
15
+ - **BREAKING:** `getCurrentAccount` returns an `InternalAccount` instead of a `string` in the `IncomingTransactionHelper` ([#4244](https://github.com/MetaMask/core/pull/4244))
16
+ - **BREAKING:** Bump dependency and peer dependency `@metamask/accounts-controller` to `^17.0.0` ([#4413](https://github.com/MetaMask/core/pull/4413))
17
+ - Bump `@metamask/eth-snap-keyring` to `^4.3.1` ([#4405](https://github.com/MetaMask/core/pull/4405))
18
+ - Bump `@metamask/keyring-api` to `^8.0.0` ([#4405](https://github.com/MetaMask/core/pull/4405))
19
+
20
+ ### Removed
21
+
22
+ - **BREAKING:** Remove `getSelectedAddress` option from `TransactionController` ([#4244](https://github.com/MetaMask/core/pull/4244))
23
+ - The AccountsController is used to get the currently selected address automatically.
24
+
25
+ ### Fixed
26
+
27
+ - `MultichainTrackingHelper.getEthQuery` now returns global `ethQuery` with ([#4390](https://github.com/MetaMask/core/pull/4390))
28
+ - Support skipping updates to the simulation history for clients with disabled history ([#4349](https://github.com/MetaMask/core/pull/4349))
29
+
10
30
  ## [32.0.0]
11
31
 
12
32
  ### Changed
@@ -876,7 +896,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
876
896
 
877
897
  All changes listed after this point were applied to this package following the monorepo conversion.
878
898
 
879
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@32.0.0...HEAD
899
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@33.0.0...HEAD
900
+ [33.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@32.0.0...@metamask/transaction-controller@33.0.0
880
901
  [32.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@31.0.0...@metamask/transaction-controller@32.0.0
881
902
  [31.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@30.0.0...@metamask/transaction-controller@31.0.0
882
903
  [30.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@29.1.0...@metamask/transaction-controller@30.0.0
@@ -4,13 +4,13 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkPBYK4OMKjs = require('./chunk-PBYK4OMK.js');
7
+ var _chunkLLXPT2H5js = require('./chunk-LLXPT2H5.js');
8
8
  require('./chunk-PRUNMTRD.js');
9
- require('./chunk-IT3SYNZ6.js');
9
+ require('./chunk-74W7X6BE.js');
10
10
  require('./chunk-KT6UAKBB.js');
11
11
  require('./chunk-SD6CWFDF.js');
12
- require('./chunk-VH47Q6TS.js');
13
- require('./chunk-5KMU2IAT.js');
12
+ require('./chunk-RXIUMVA5.js');
13
+ require('./chunk-ULD4JC3Q.js');
14
14
  require('./chunk-7LXE4KHV.js');
15
15
  require('./chunk-V72C4MCR.js');
16
16
  require('./chunk-QP75SWIQ.js');
@@ -18,22 +18,22 @@ require('./chunk-NYKRCWBG.js');
18
18
  require('./chunk-WR5F34OW.js');
19
19
  require('./chunk-YVCX6Z75.js');
20
20
  require('./chunk-TJMQEH57.js');
21
- require('./chunk-7MKQDZKY.js');
21
+ require('./chunk-7KREIKNY.js');
22
22
  require('./chunk-2XKEAKQG.js');
23
- require('./chunk-DTDTOMTB.js');
24
- require('./chunk-PUESYN62.js');
25
- require('./chunk-EQT25RSP.js');
26
- require('./chunk-FDUCRHYT.js');
23
+ require('./chunk-RHDPOIS4.js');
24
+ require('./chunk-6OLJWLKK.js');
25
+ require('./chunk-7NMV2NPM.js');
26
+ require('./chunk-XVYXRCRL.js');
27
27
  require('./chunk-HMOSP33F.js');
28
- require('./chunk-Q6Q44V4W.js');
29
- require('./chunk-YXSCBWTU.js');
30
- require('./chunk-3ZRHCVVS.js');
31
- require('./chunk-UT4M4XI3.js');
32
- require('./chunk-UGFBA4GV.js');
33
- require('./chunk-DLOQPH4M.js');
28
+ require('./chunk-3LWN55E6.js');
29
+ require('./chunk-N6OMDPDK.js');
30
+ require('./chunk-4IBBHNWG.js');
31
+ require('./chunk-QH2H4W3N.js');
32
+ require('./chunk-OZ6UB42C.js');
33
+ require('./chunk-V4FONAI2.js');
34
34
  require('./chunk-UGN7PBON.js');
35
35
  require('./chunk-S6VGOPUY.js');
36
- require('./chunk-RAOYRJ25.js');
36
+ require('./chunk-3WTSRETF.js');
37
37
  require('./chunk-Z4BLTVTB.js');
38
38
 
39
39
 
@@ -41,5 +41,5 @@ require('./chunk-Z4BLTVTB.js');
41
41
 
42
42
 
43
43
 
44
- exports.ApprovalState = _chunkPBYK4OMKjs.ApprovalState; exports.CANCEL_RATE = _chunkPBYK4OMKjs.CANCEL_RATE; exports.HARDFORK = _chunkPBYK4OMKjs.HARDFORK; exports.SPEED_UP_RATE = _chunkPBYK4OMKjs.SPEED_UP_RATE; exports.TransactionController = _chunkPBYK4OMKjs.TransactionController;
44
+ exports.ApprovalState = _chunkLLXPT2H5js.ApprovalState; exports.CANCEL_RATE = _chunkLLXPT2H5js.CANCEL_RATE; exports.HARDFORK = _chunkLLXPT2H5js.HARDFORK; exports.SPEED_UP_RATE = _chunkLLXPT2H5js.SPEED_UP_RATE; exports.TransactionController = _chunkLLXPT2H5js.TransactionController;
45
45
  //# sourceMappingURL=TransactionController.js.map
@@ -4,13 +4,13 @@ import {
4
4
  HARDFORK,
5
5
  SPEED_UP_RATE,
6
6
  TransactionController
7
- } from "./chunk-PQCHA5KF.mjs";
7
+ } from "./chunk-K2JC276W.mjs";
8
8
  import "./chunk-6DDVVUJC.mjs";
9
- import "./chunk-AHSDUIMT.mjs";
9
+ import "./chunk-EVL6KODQ.mjs";
10
10
  import "./chunk-K4KOSAGM.mjs";
11
11
  import "./chunk-KG4UW4K4.mjs";
12
- import "./chunk-NM6OYEPP.mjs";
13
- import "./chunk-5YES3V2R.mjs";
12
+ import "./chunk-5ZEJT5SN.mjs";
13
+ import "./chunk-6B5BEO3R.mjs";
14
14
  import "./chunk-FRKQ3Z2L.mjs";
15
15
  import "./chunk-5G6OHAXI.mjs";
16
16
  import "./chunk-XGRAHX6T.mjs";
@@ -18,22 +18,22 @@ import "./chunk-VEVVBHP3.mjs";
18
18
  import "./chunk-Z4GV3YQQ.mjs";
19
19
  import "./chunk-FG74Z3F5.mjs";
20
20
  import "./chunk-FMRLPVFZ.mjs";
21
- import "./chunk-NRQUBP3S.mjs";
21
+ import "./chunk-MILG772S.mjs";
22
22
  import "./chunk-NOHEXQ7Y.mjs";
23
- import "./chunk-Y7ENNK7L.mjs";
24
- import "./chunk-AZ4WIRH3.mjs";
25
- import "./chunk-CPMTUMMZ.mjs";
26
- import "./chunk-QZLPYOGC.mjs";
23
+ import "./chunk-3ZV5YEUV.mjs";
24
+ import "./chunk-4V4XIPCI.mjs";
25
+ import "./chunk-EKJXGERC.mjs";
26
+ import "./chunk-EGQCE3FK.mjs";
27
27
  import "./chunk-HQSNKCXI.mjs";
28
- import "./chunk-2TUDWNEI.mjs";
29
- import "./chunk-V6HVF4EN.mjs";
30
- import "./chunk-G5U6ABRU.mjs";
31
- import "./chunk-IJ5GUKRO.mjs";
32
- import "./chunk-J56A7UCK.mjs";
33
- import "./chunk-CDF4QNJA.mjs";
28
+ import "./chunk-UZFDPHQI.mjs";
29
+ import "./chunk-OGK76ZPK.mjs";
30
+ import "./chunk-KLDYR4HR.mjs";
31
+ import "./chunk-GNAL5HC2.mjs";
32
+ import "./chunk-Q56I5ONX.mjs";
33
+ import "./chunk-D6BF3IZK.mjs";
34
34
  import "./chunk-O6ZZVIFH.mjs";
35
35
  import "./chunk-UQQWZT6C.mjs";
36
- import "./chunk-METHOFMG.mjs";
36
+ import "./chunk-KPP6SU7S.mjs";
37
37
  import "./chunk-XUI43LEZ.mjs";
38
38
  export {
39
39
  ApprovalState,
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkYXSCBWTUjs = require('./chunk-YXSCBWTU.js');
3
+ var _chunkN6OMDPDKjs = require('./chunk-N6OMDPDK.js');
4
4
 
5
5
 
6
6
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
7
7
 
8
8
 
9
- var _chunkRAOYRJ25js = require('./chunk-RAOYRJ25.js');
9
+ var _chunk3WTSRETFjs = require('./chunk-3WTSRETF.js');
10
10
 
11
11
 
12
12
 
@@ -48,7 +48,7 @@ var LineaGasFeeFlow = class {
48
48
  return await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLineaGasFees, getLineaGasFees_fn).call(this, request);
49
49
  } catch (error) {
50
50
  log("Using default flow as fallback due to error", error);
51
- return new (0, _chunkYXSCBWTUjs.DefaultGasFeeFlow)().getGasFees(request);
51
+ return new (0, _chunkN6OMDPDKjs.DefaultGasFeeFlow)().getGasFees(request);
52
52
  }
53
53
  }
54
54
  };
@@ -63,7 +63,7 @@ getLineaGasFees_fn = async function(request) {
63
63
  log("Generated priority fees", _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _feesToString, feesToString_fn).call(this, priorityFees));
64
64
  const maxFees = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getMaxFees, getMaxFees_fn).call(this, baseFees, priorityFees);
65
65
  log("Generated max fees", _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _feesToString, feesToString_fn).call(this, maxFees));
66
- const estimates = Object.values(_chunkRAOYRJ25js.GasFeeEstimateLevel).reduce(
66
+ const estimates = Object.values(_chunk3WTSRETFjs.GasFeeEstimateLevel).reduce(
67
67
  (result, level) => ({
68
68
  ...result,
69
69
  [level]: {
@@ -110,7 +110,7 @@ getMaxFees_fn = function(baseFees, priorityFees) {
110
110
  };
111
111
  _feesToString = new WeakSet();
112
112
  feesToString_fn = function(fees) {
113
- return Object.values(_chunkRAOYRJ25js.GasFeeEstimateLevel).map(
113
+ return Object.values(_chunk3WTSRETFjs.GasFeeEstimateLevel).map(
114
114
  (level) => fees[level].toString(10)
115
115
  );
116
116
  };
@@ -118,4 +118,4 @@ feesToString_fn = function(fees) {
118
118
 
119
119
 
120
120
  exports.LineaGasFeeFlow = LineaGasFeeFlow;
121
- //# sourceMappingURL=chunk-Q6Q44V4W.js.map
121
+ //# sourceMappingURL=chunk-3LWN55E6.js.map
@@ -89,4 +89,4 @@ var SimulationErrorCode = /* @__PURE__ */ ((SimulationErrorCode2) => {
89
89
 
90
90
 
91
91
  exports.TransactionStatus = TransactionStatus; exports.WalletDevice = WalletDevice; exports.TransactionType = TransactionType; exports.TransactionEnvelopeType = TransactionEnvelopeType; exports.UserFeeLevel = UserFeeLevel; exports.GasFeeEstimateLevel = GasFeeEstimateLevel; exports.GasFeeEstimateType = GasFeeEstimateType; exports.SimulationTokenStandard = SimulationTokenStandard; exports.SimulationErrorCode = SimulationErrorCode;
92
- //# sourceMappingURL=chunk-RAOYRJ25.js.map
92
+ //# sourceMappingURL=chunk-3WTSRETF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"names":["TransactionStatus","WalletDevice","TransactionType","TransactionEnvelopeType","UserFeeLevel","GasFeeEstimateLevel","GasFeeEstimateType","SimulationTokenStandard","SimulationErrorCode"],"mappings":";AAwcO,IAAK,oBAAL,kBAAKA,uBAAL;AAGL,EAAAA,mBAAA,cAAW;AAIX,EAAAA,mBAAA,eAAY;AAGZ,EAAAA,mBAAA,eAAY;AAGZ,EAAAA,mBAAA,aAAU;AAGV,EAAAA,mBAAA,YAAS;AAGT,EAAAA,mBAAA,cAAW;AAGX,EAAAA,mBAAA,YAAS;AAGT,EAAAA,mBAAA,eAAY;AAGZ,EAAAA,mBAAA,gBAAa;AA5BH,SAAAA;AAAA,GAAA;AAkCL,IAAK,eAAL,kBAAKC,kBAAL;AAGL,EAAAA,cAAA,eAAY;AAGZ,EAAAA,cAAA,kBAAe;AACf,EAAAA,cAAA,WAAQ;AAPE,SAAAA;AAAA,GAAA;AAaL,I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A,WAAQ;AAGR,EAAAA,yBAAA,YAAS;AAGT,EAAAA,yBAAA,aAAU;AATA,SAAAA;AAAA,GAAA;AA4BL,IAAK,sBAAL,kBAAKC,yBAAL;AACL,EAAAA,qBAAA,uBAAoB;AACpB,EAAAA,qBAAA,cAAW;AACX,EAAAA,qBAAA,qBAAkB;AAClB,EAAAA,qBAAA,cAAW;AAJD,SAAAA;AAAA,GAAA","sourcesContent":["import type { AccessList } from '@ethereumjs/tx';\nimport type EthQuery from '@metamask/eth-query';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport type { NetworkClientId, Provider } from '@metamask/network-controller';\nimport type { Hex, Json } from '@metamask/utils';\nimport type { Operation } from 'fast-json-patch';\n\n/**\n * Given a record, ensures that each property matches the `Json` type.\n */\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\ntype MakeJsonCompatible<T> = T extends Json\n ? T\n : {\n [K in keyof T]: T[K] extends Json ? T[K] : never;\n };\n\n/**\n * `Json` from `@metamask/utils` is defined as a recursive type alias, but\n * `Operation` is defined as an interface, and the two are not compatible with\n * each other. Therefore, this is a variant of Operation from `fast-json-patch`\n * which is guaranteed to be type-compatible with `Json`.\n */\ntype JsonCompatibleOperation = MakeJsonCompatible<Operation>;\n\n/**\n * Representation of transaction metadata.\n */\nexport type TransactionMeta = TransactionMetaBase &\n (\n | {\n status: Exclude<TransactionStatus, TransactionStatus.failed>;\n }\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 raw amount of the destination token\n */\n destinationTokenAmount?: 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 * Additional gas fees to cover the cost of persisting data on layer 1 for layer 2 networks.\n */\n layer1GasFee?: Hex;\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 * Simulation data for the transaction used to predict its outcome.\n */\n simulationData?: SimulationData;\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 address of the token being swapped\n */\n sourceTokenAddress?: string;\n\n /**\n * The raw amount of the source swap token\n */\n sourceTokenAmount?: string;\n\n /**\n * The decimals of the token being swapped.\n */\n sourceTokenDecimals?: number;\n\n /**\n * The symbol of the token being swapped.\n */\n sourceTokenSymbol?: string;\n\n /**\n * The address of the swap recipient.\n */\n swapAndSendRecipient?: 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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n approved = 'approved',\n /** @deprecated Determined by the clients using the transaction type. No longer used. */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n cancelled = 'cancelled',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n confirmed = 'confirmed',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n dropped = 'dropped',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n failed = 'failed',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n rejected = 'rejected',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n signed = 'signed',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n submitted = 'submitted',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n unapproved = 'unapproved',\n}\n\n/**\n * Options for wallet device.\n */\nexport enum WalletDevice {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n MM_MOBILE = 'metamask_mobile',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n contractInteraction = 'contractInteraction',\n\n /**\n * A transaction that deployed a smart contract.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n deployContract = 'contractDeployment',\n\n /**\n * A transaction for Ethereum decryption.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ethDecrypt = 'eth_decrypt',\n\n /**\n * A transaction for getting an encryption public key.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ethGetEncryptionPublicKey = 'eth_getEncryptionPublicKey',\n\n /**\n * An incoming (deposit) transaction.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n incoming = 'incoming',\n\n /**\n * A transaction for personal sign.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n retry = 'retry',\n\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n simpleSend = 'simpleSend',\n\n /**\n * A transaction that is signing typed data.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n signTypedData = 'eth_signTypedData',\n\n /**\n * A transaction sending a network's native asset to a recipient.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n smart = 'smart',\n\n /**\n * A transaction swapping one token for another through MetaMask Swaps.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n swap = 'swap',\n\n /**\n * A transaction swapping one token for another through MetaMask Swaps, then sending the swapped token to a recipient.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n swapAndSend = 'swapAndSend',\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n tokenMethodSafeTransferFrom = 'safetransferfrom',\n\n /**\n * A token transaction where the user is sending tokens that they own to\n * another address.\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n tokenMethodSetApprovalForAll = 'setapprovalforall',\n\n /**\n * Increase the allowance by a given increment\n */\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n tokenMethodIncreaseAllowance = 'increaseAllowance',\n}\n\n/**\n * Standard data concerning a transaction to be processed by the blockchain.\n */\nexport type 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 */\nexport type 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 */\nexport type 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 */\nexport type 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 = JsonCompatibleOperation & {\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 ...JsonCompatibleOperation[],\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\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 // We are intentionally using `any` here instead of `Json` because it causes\n // `WritableDraft<TransactionMeta>` from Immer to cause TypeScript to error\n // with \"Type instantiation is excessively deep and possibly infinite\". See:\n // <https://github.com/immerjs/immer/issues/839>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rpc?: any;\n};\n\n/**\n * Type for security alert response from transaction validator.\n */\nexport type SecurityAlertResponse = {\n reason: string;\n features?: string[];\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n result_type: string;\n providerRequestsCount?: Record<string, number>;\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/** Type of gas fee estimate generated by a GasFeeFlow. */\nexport enum GasFeeEstimateType {\n FeeMarket = 'fee-market',\n Legacy = 'legacy',\n GasPrice = 'eth_gasPrice',\n}\n\n/** Gas fee estimates for a specific priority level. */\nexport type FeeMarketGasFeeEstimateForLevel = {\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/** Gas fee estimates for a EIP-1559 transaction. */\nexport type FeeMarketGasFeeEstimates = {\n type: GasFeeEstimateType.FeeMarket;\n [GasFeeEstimateLevel.Low]: FeeMarketGasFeeEstimateForLevel;\n [GasFeeEstimateLevel.Medium]: FeeMarketGasFeeEstimateForLevel;\n [GasFeeEstimateLevel.High]: FeeMarketGasFeeEstimateForLevel;\n};\n\n/** Gas fee estimates for a legacy transaction. */\nexport type LegacyGasFeeEstimates = {\n type: GasFeeEstimateType.Legacy;\n [GasFeeEstimateLevel.Low]: Hex;\n [GasFeeEstimateLevel.Medium]: Hex;\n [GasFeeEstimateLevel.High]: Hex;\n};\n\n/** Gas fee estimates for a transaction retrieved with the eth_gasPrice method. */\nexport type GasPriceGasFeeEstimates = {\n type: GasFeeEstimateType.GasPrice;\n gasPrice: Hex;\n};\n\n/** Gas fee estimates for a transaction. */\nexport type GasFeeEstimates =\n | FeeMarketGasFeeEstimates\n | LegacyGasFeeEstimates\n | GasPriceGasFeeEstimates;\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 /** Gas fee controller data matching the chain ID of the transaction. */\n gasFeeControllerData: 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\n/** Request to a layer 1 gas fee flow to obtain layer 1 fee estimate. */\nexport type Layer1GasFeeFlowRequest = {\n /** RPC Provider instance. */\n provider: Provider;\n\n /** The metadata of the transaction to obtain estimates for. */\n transactionMeta: TransactionMeta;\n};\n\n/** Response from a layer 1 gas fee flow containing layer 1 fee estimate. */\nexport type Layer1GasFeeFlowResponse = {\n /** The gas fee estimates for the transaction. */\n layer1Fee: Hex;\n};\n\n/** A method of obtaining layer 1 gas fee estimates for a specific transaction. */\nexport type Layer1GasFeeFlow = {\n /**\n * Determine if the gas fee flow supports the specified transaction.\n * @param transactionMeta - The transaction metadata.\n * @returns Whether the layer1 gas fee flow supports the transaction.\n */\n matchesTransaction(transactionMeta: TransactionMeta): boolean;\n\n /**\n * Get layer 1 gas fee estimates for a specific transaction.\n * @param request - The gas fee flow request.\n * @returns The gas fee flow response containing the layer 1 gas fee estimate.\n */\n getLayer1Fee: (\n request: Layer1GasFeeFlowRequest,\n ) => Promise<Layer1GasFeeFlowResponse>;\n};\n\n/** Simulation data concerning an update to a native or token balance. */\nexport type SimulationBalanceChange = {\n /** The balance before the transaction. */\n previousBalance: Hex;\n\n /** The balance after the transaction. */\n newBalance: Hex;\n\n /** The difference in balance. */\n difference: Hex;\n\n /** Whether the balance is increasing or decreasing. */\n isDecrease: boolean;\n};\n\n/** Token standards supported by simulation. */\nexport enum SimulationTokenStandard {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n erc20 = 'erc20',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n erc721 = 'erc721',\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n erc1155 = 'erc1155',\n}\n\n/** Simulation data concerning an updated token. */\nexport type SimulationToken = {\n /** The token's contract address. */\n address: Hex;\n\n /** The standard of the token. */\n standard: SimulationTokenStandard;\n\n /** The ID of the token if supported by the standard. */\n id?: Hex;\n};\n\n/** Simulation data concerning a change to the a token balance. */\nexport type SimulationTokenBalanceChange = SimulationToken &\n SimulationBalanceChange;\n\nexport enum SimulationErrorCode {\n ChainNotSupported = 'chain-not-supported',\n Disabled = 'disabled',\n InvalidResponse = 'invalid-response',\n Reverted = 'reverted',\n}\n\n/** Error data for a failed simulation. */\nexport type SimulationError = {\n /** Error code to identify the error type. */\n code?: string | number;\n\n /** Error message to describe the error. */\n message?: string;\n};\n\n/** Simulation data for a transaction. */\nexport type SimulationData = {\n /** Error data if the simulation failed or the transaction reverted. */\n error?: SimulationError;\n\n /** Data concerning a change to the user's native balance. */\n nativeBalanceChange?: SimulationBalanceChange;\n\n /** Data concerning a change to the user's token balances. */\n tokenBalanceChanges: SimulationTokenBalanceChange[];\n};\n"]}
@@ -99,12 +99,12 @@ var IncomingTransactionHelper = class {
99
99
  );
100
100
  const additionalLastFetchedKeys = __privateGet(this, _remoteTransactionSource).getLastBlockVariations?.() ?? [];
101
101
  const fromBlock = __privateMethod(this, _getFromBlock, getFromBlock_fn).call(this, latestBlockNumber);
102
- const address = __privateGet(this, _getCurrentAccount).call(this);
102
+ const account = __privateGet(this, _getCurrentAccount).call(this);
103
103
  const currentChainId = __privateGet(this, _getChainId).call(this);
104
104
  let remoteTransactions = [];
105
105
  try {
106
106
  remoteTransactions = await __privateGet(this, _remoteTransactionSource).fetchTransactions({
107
- address,
107
+ address: account.address,
108
108
  currentChainId,
109
109
  fromBlock,
110
110
  limit: __privateGet(this, _transactionLimit)
@@ -114,8 +114,9 @@ var IncomingTransactionHelper = class {
114
114
  return;
115
115
  }
116
116
  if (!__privateGet(this, _updateTransactions)) {
117
+ const address = account.address.toLowerCase();
117
118
  remoteTransactions = remoteTransactions.filter(
118
- (tx) => tx.txParams.to?.toLowerCase() === address.toLowerCase()
119
+ (tx) => tx.txParams.to?.toLowerCase() === address
119
120
  );
120
121
  }
121
122
  const localTransactions = !__privateGet(this, _updateTransactions) ? [] : __privateGet(this, _getLocalTransactions).call(this);
@@ -221,7 +222,7 @@ updateLastFetchedBlockNumber_fn = function(remoteTxs, additionalKeys) {
221
222
  _getBlockNumberKey = new WeakSet();
222
223
  getBlockNumberKey_fn = function(additionalKeys) {
223
224
  const currentChainId = __privateGet(this, _getChainId).call(this);
224
- const currentAccount = __privateGet(this, _getCurrentAccount).call(this)?.toLowerCase();
225
+ const currentAccount = __privateGet(this, _getCurrentAccount).call(this)?.address.toLowerCase();
225
226
  return [currentChainId, currentAccount, ...additionalKeys].join("#");
226
227
  };
227
228
  _canStart = new WeakSet();
@@ -235,4 +236,4 @@ canStart_fn = function() {
235
236
  export {
236
237
  IncomingTransactionHelper
237
238
  };
238
- //# sourceMappingURL=chunk-Y7ENNK7L.mjs.map
239
+ //# sourceMappingURL=chunk-3ZV5YEUV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/IncomingTransactionHelper.ts"],"sourcesContent":["import type { AccountsController } from '@metamask/accounts-controller';\nimport type { BlockTracker } from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\nimport EventEmitter from 'events';\n\nimport { incomingTransactionsLogger as log } from '../logger';\nimport type { RemoteTransactionSource, TransactionMeta } from '../types';\n\nconst RECENT_HISTORY_BLOCK_RANGE = 10;\n\n// TODO: Replace `any` with type\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst UPDATE_CHECKS: ((txMeta: TransactionMeta) => any)[] = [\n (txMeta) => txMeta.status,\n (txMeta) => txMeta.txParams.gasUsed,\n];\n\n/**\n * Configuration options for the IncomingTransactionHelper\n *\n * @property includeTokenTransfers - Whether or not to include ERC20 token transfers.\n * @property isEnabled - Whether or not incoming transaction retrieval is enabled.\n * @property queryEntireHistory - Whether to initially query the entire transaction history or only recent blocks.\n * @property updateTransactions - Whether to update local transactions using remote transaction data.\n */\nexport type IncomingTransactionOptions = {\n includeTokenTransfers?: boolean;\n isEnabled?: () => boolean;\n queryEntireHistory?: boolean;\n updateTransactions?: boolean;\n};\n\nexport class IncomingTransactionHelper {\n hub: EventEmitter;\n\n #blockTracker: BlockTracker;\n\n #getCurrentAccount: () => ReturnType<\n AccountsController['getSelectedAccount']\n >;\n\n #getLastFetchedBlockNumbers: () => Record<string, number>;\n\n #getLocalTransactions: () => TransactionMeta[];\n\n #getChainId: () => Hex;\n\n #isEnabled: () => boolean;\n\n #isRunning: boolean;\n\n #mutex = new Mutex();\n\n #onLatestBlock: (blockNumberHex: Hex) => Promise<void>;\n\n #queryEntireHistory: boolean;\n\n #remoteTransactionSource: RemoteTransactionSource;\n\n #transactionLimit?: number;\n\n #updateTransactions: boolean;\n\n constructor({\n blockTracker,\n getCurrentAccount,\n getLastFetchedBlockNumbers,\n getLocalTransactions,\n getChainId,\n isEnabled,\n queryEntireHistory,\n remoteTransactionSource,\n transactionLimit,\n updateTransactions,\n }: {\n blockTracker: BlockTracker;\n getCurrentAccount: () => ReturnType<\n AccountsController['getSelectedAccount']\n >;\n getLastFetchedBlockNumbers: () => Record<string, number>;\n getLocalTransactions?: () => TransactionMeta[];\n getChainId: () => Hex;\n isEnabled?: () => boolean;\n queryEntireHistory?: boolean;\n remoteTransactionSource: RemoteTransactionSource;\n transactionLimit?: number;\n updateTransactions?: boolean;\n }) {\n this.hub = new EventEmitter();\n\n this.#blockTracker = blockTracker;\n this.#getCurrentAccount = getCurrentAccount;\n this.#getLastFetchedBlockNumbers = getLastFetchedBlockNumbers;\n this.#getLocalTransactions = getLocalTransactions || (() => []);\n this.#getChainId = getChainId;\n this.#isEnabled = isEnabled ?? (() => true);\n this.#isRunning = false;\n this.#queryEntireHistory = queryEntireHistory ?? true;\n this.#remoteTransactionSource = remoteTransactionSource;\n this.#transactionLimit = transactionLimit;\n this.#updateTransactions = updateTransactions ?? false;\n\n // Using a property instead of a method to provide a listener reference\n // with the correct scope that we can remove later if stopped.\n this.#onLatestBlock = async (blockNumberHex: Hex) => {\n try {\n await this.update(blockNumberHex);\n } catch (error) {\n console.error('Error while checking incoming transactions', error);\n }\n };\n }\n\n start() {\n if (this.#isRunning) {\n return;\n }\n\n if (!this.#canStart()) {\n return;\n }\n\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.#blockTracker.addListener('latest', this.#onLatestBlock);\n this.#isRunning = true;\n }\n\n stop() {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.#blockTracker.removeListener('latest', this.#onLatestBlock);\n this.#isRunning = false;\n }\n\n async update(latestBlockNumberHex?: Hex): Promise<void> {\n const releaseLock = await this.#mutex.acquire();\n\n log('Checking for incoming transactions');\n\n try {\n if (!this.#canStart()) {\n return;\n }\n\n const latestBlockNumber = parseInt(\n latestBlockNumberHex || (await this.#blockTracker.getLatestBlock()),\n 16,\n );\n\n const additionalLastFetchedKeys =\n this.#remoteTransactionSource.getLastBlockVariations?.() ?? [];\n\n const fromBlock = this.#getFromBlock(latestBlockNumber);\n const account = this.#getCurrentAccount();\n const currentChainId = this.#getChainId();\n\n let remoteTransactions = [];\n\n try {\n remoteTransactions =\n await this.#remoteTransactionSource.fetchTransactions({\n address: account.address,\n currentChainId,\n fromBlock,\n limit: this.#transactionLimit,\n });\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n log('Error while fetching remote transactions', error);\n return;\n }\n if (!this.#updateTransactions) {\n const address = account.address.toLowerCase();\n remoteTransactions = remoteTransactions.filter(\n (tx) => tx.txParams.to?.toLowerCase() === address,\n );\n }\n\n const localTransactions = !this.#updateTransactions\n ? []\n : this.#getLocalTransactions();\n\n const newTransactions = this.#getNewTransactions(\n remoteTransactions,\n localTransactions,\n );\n\n const updatedTransactions = this.#getUpdatedTransactions(\n remoteTransactions,\n localTransactions,\n );\n\n if (newTransactions.length > 0 || updatedTransactions.length > 0) {\n this.#sortTransactionsByTime(newTransactions);\n this.#sortTransactionsByTime(updatedTransactions);\n\n log('Found incoming transactions', {\n new: newTransactions,\n updated: updatedTransactions,\n });\n\n this.hub.emit('transactions', {\n added: newTransactions,\n updated: updatedTransactions,\n });\n }\n this.#updateLastFetchedBlockNumber(\n remoteTransactions,\n additionalLastFetchedKeys,\n );\n } finally {\n releaseLock();\n }\n }\n\n #sortTransactionsByTime(transactions: TransactionMeta[]) {\n transactions.sort((a, b) => (a.time < b.time ? -1 : 1));\n }\n\n #getNewTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter(\n (tx) => !localTxs.some(({ hash }) => hash === tx.hash),\n );\n }\n\n #getUpdatedTransactions(\n remoteTxs: TransactionMeta[],\n localTxs: TransactionMeta[],\n ): TransactionMeta[] {\n return remoteTxs.filter((remoteTx) =>\n localTxs.some(\n (localTx) =>\n remoteTx.hash === localTx.hash &&\n this.#isTransactionOutdated(remoteTx, localTx),\n ),\n );\n }\n\n #isTransactionOutdated(\n remoteTx: TransactionMeta,\n localTx: TransactionMeta,\n ): boolean {\n return UPDATE_CHECKS.some(\n (getValue) => getValue(remoteTx) !== getValue(localTx),\n );\n }\n\n #getLastFetchedBlockNumberDec(): number {\n const additionalLastFetchedKeys =\n this.#remoteTransactionSource.getLastBlockVariations?.() ?? [];\n const lastFetchedKey = this.#getBlockNumberKey(additionalLastFetchedKeys);\n const lastFetchedBlockNumbers = this.#getLastFetchedBlockNumbers();\n return lastFetchedBlockNumbers[lastFetchedKey];\n }\n\n #getFromBlock(latestBlockNumber: number): number | undefined {\n const lastFetchedBlockNumber = this.#getLastFetchedBlockNumberDec();\n\n if (lastFetchedBlockNumber) {\n return lastFetchedBlockNumber + 1;\n }\n\n return this.#queryEntireHistory\n ? undefined\n : latestBlockNumber - RECENT_HISTORY_BLOCK_RANGE;\n }\n\n #updateLastFetchedBlockNumber(\n remoteTxs: TransactionMeta[],\n additionalKeys: string[],\n ) {\n let lastFetchedBlockNumber = -1;\n\n for (const tx of remoteTxs) {\n const currentBlockNumberValue = tx.blockNumber\n ? parseInt(tx.blockNumber, 10)\n : -1;\n\n lastFetchedBlockNumber = Math.max(\n lastFetchedBlockNumber,\n currentBlockNumberValue,\n );\n }\n\n if (lastFetchedBlockNumber === -1) {\n return;\n }\n\n const lastFetchedKey = this.#getBlockNumberKey(additionalKeys);\n const lastFetchedBlockNumbers = this.#getLastFetchedBlockNumbers();\n const previousValue = lastFetchedBlockNumbers[lastFetchedKey];\n\n if (previousValue >= lastFetchedBlockNumber) {\n return;\n }\n\n this.hub.emit('updatedLastFetchedBlockNumbers', {\n lastFetchedBlockNumbers: {\n ...lastFetchedBlockNumbers,\n [lastFetchedKey]: lastFetchedBlockNumber,\n },\n blockNumber: lastFetchedBlockNumber,\n });\n }\n\n #getBlockNumberKey(additionalKeys: string[]): string {\n const currentChainId = this.#getChainId();\n const currentAccount = this.#getCurrentAccount()?.address.toLowerCase();\n\n return [currentChainId, currentAccount, ...additionalKeys].join('#');\n }\n\n #canStart(): boolean {\n const isEnabled = this.#isEnabled();\n const currentChainId = this.#getChainId();\n\n const isSupportedNetwork =\n this.#remoteTransactionSource.isSupportedNetwork(currentChainId);\n\n return isEnabled && isSupportedNetwork;\n }\n}\n"],"mappings":";;;;;;;;;;;AAGA,SAAS,aAAa;AACtB,OAAO,kBAAkB;AAKzB,IAAM,6BAA6B;AAInC,IAAM,gBAAsD;AAAA,EAC1D,CAAC,WAAW,OAAO;AAAA,EACnB,CAAC,WAAW,OAAO,SAAS;AAC9B;AAhBA;AAiCO,IAAM,4BAAN,MAAgC;AAAA,EA+BrC,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAaG;AAkIH;AAIA;AASA;AAaA;AASA;AAQA;AAYA;AAsCA;AAOA;AA1RA;AAEA;AAIA;AAEA;AAEA;AAEA;AAEA;AAEA,+BAAS,IAAI,MAAM;AAEnB;AAEA;AAEA;AAEA;AAEA;AA2BE,SAAK,MAAM,IAAI,aAAa;AAE5B,uBAAK,eAAgB;AACrB,uBAAK,oBAAqB;AAC1B,uBAAK,6BAA8B;AACnC,uBAAK,uBAAwB,yBAAyB,MAAM,CAAC;AAC7D,uBAAK,aAAc;AACnB,uBAAK,YAAa,cAAc,MAAM;AACtC,uBAAK,YAAa;AAClB,uBAAK,qBAAsB,sBAAsB;AACjD,uBAAK,0BAA2B;AAChC,uBAAK,mBAAoB;AACzB,uBAAK,qBAAsB,sBAAsB;AAIjD,uBAAK,gBAAiB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QAAM,qBACJ,mBAAK,0BAAyB,mBAAmB,cAAc;AAEjE,SAAO,aAAa;AACtB;","names":[]}
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUT4M4XI3js = require('./chunk-UT4M4XI3.js');
3
+ var _chunkQH2H4W3Njs = require('./chunk-QH2H4W3N.js');
4
4
 
5
5
 
6
- var _chunkDLOQPH4Mjs = require('./chunk-DLOQPH4M.js');
6
+ var _chunkV4FONAI2js = require('./chunk-V4FONAI2.js');
7
7
 
8
8
 
9
9
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
@@ -20,7 +20,7 @@ var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger,
20
20
  async function updateGasFees(request) {
21
21
  const { txMeta } = request;
22
22
  const initialParams = { ...txMeta.txParams };
23
- const isSwap = _chunkUT4M4XI3js.SWAP_TRANSACTION_TYPES.includes(
23
+ const isSwap = _chunkQH2H4W3Njs.SWAP_TRANSACTION_TYPES.includes(
24
24
  txMeta.type
25
25
  );
26
26
  const savedGasFees = isSwap ? void 0 : request.getSavedGasFees(txMeta.chainId);
@@ -186,7 +186,7 @@ async function getSuggestedGasFees(request) {
186
186
  if (!eip1559 && txMeta.txParams.gasPrice || eip1559 && txMeta.txParams.maxFeePerGas && txMeta.txParams.maxPriorityFeePerGas) {
187
187
  return {};
188
188
  }
189
- const gasFeeFlow = _chunkDLOQPH4Mjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
189
+ const gasFeeFlow = _chunkV4FONAI2js.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
190
190
  try {
191
191
  const gasFeeControllerData = await getGasFeeEstimates({ networkClientId });
192
192
  const response = await gasFeeFlow.getGasFees({
@@ -206,6 +206,8 @@ async function getSuggestedGasFees(request) {
206
206
  return { gasPrice: response.estimates.gasPrice };
207
207
  default:
208
208
  throw new Error(
209
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
210
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
209
211
  `Unsupported gas fee estimate type returned from flow: ${gasFeeEstimateType}`
210
212
  );
211
213
  }
@@ -221,4 +223,4 @@ async function getSuggestedGasFees(request) {
221
223
 
222
224
 
223
225
  exports.updateGasFees = updateGasFees; exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
224
- //# sourceMappingURL=chunk-3ZRHCVVS.js.map
226
+ //# sourceMappingURL=chunk-4IBBHNWG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/gas-fees.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,SAAS,OAAO,0BAA0B;AAqC1C,IAAM,MAAM,mBAAmB,eAAe,UAAU;AAExD,eAAsB,cAAc,SAA+B;AACjE,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,gBAAgB,EAAE,GAAG,OAAO,SAAS;AAE3C,QAAM,SAAS,uBAAuB;AAAA,IACpC,OAAO;AAAA,EACT;AACA,QAAM,eAAe,SACjB,SACA,QAAQ,gBAAgB,OAAO,OAAO;AAE1C,QAAM,mBAAmB,MAAM,oBAAoB,OAAO;AAE1D,MAAI,sBAAsB,gBAAgB;AAE1C,QAAM,mBAAqC;AAAA,IACzC,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,SAAS,eAAe,gBAAgB,gBAAgB;AAE/D,SAAO,SAAS,uBACd,wBAAwB,gBAAgB;AAE1C,SAAO,SAAS,WAAW,YAAY,gBAAgB;AACvD,SAAO,eAAe,gBAAgB,gBAAgB;AAEtD,MAAI,8BAA8B;AAAA,IAChC,cAAc,OAAO,SAAS;AAAA,IAC9B,sBAAsB,OAAO,SAAS;AAAA,IACtC,UAAU,OAAO,SAAS;AAAA,EAC5B,CAAC;AAED,MAAI,OAAO,SAAS,gBAAgB,OAAO,SAAS,sBAAsB;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c/require-jsdoc */\n\nimport {\n ORIGIN_METAMASK,\n gweiDecToWEIBN,\n query,\n toHex,\n} from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type {\n FetchGasFeeEstimateOptions,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { add0x, createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n SavedGasFees,\n TransactionParams,\n TransactionMeta,\n TransactionType,\n GasFeeFlow,\n} from '../types';\nimport { GasFeeEstimateType, UserFeeLevel } from '../types';\nimport { getGasFeeFlow } from './gas-flow';\nimport { SWAP_TRANSACTION_TYPES } from './swaps';\n\nexport type UpdateGasFeesRequest = {\n eip1559: boolean;\n ethQuery: EthQuery;\n gasFeeFlows: GasFeeFlow[];\n getGasFeeEstimates: (\n options: FetchGasFeeEstimateOptions,\n ) => Promise<GasFeeState>;\n getSavedGasFees: (chainId: Hex) => SavedGasFees | undefined;\n txMeta: TransactionMeta;\n};\n\nexport type GetGasFeeRequest = UpdateGasFeesRequest & {\n initialParams: TransactionParams;\n savedGasFees?: SavedGasFees;\n suggestedGasFees: SuggestedGasFees;\n};\n\ntype SuggestedGasFees = {\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n gasPrice?: string;\n};\n\nconst log = createModuleLogger(projectLogger, 'gas-fees');\n\nexport async function updateGasFees(request: UpdateGasFeesRequest) {\n const { txMeta } = request;\n const initialParams = { ...txMeta.txParams };\n\n const isSwap = SWAP_TRANSACTION_TYPES.includes(\n txMeta.type as TransactionType,\n );\n const savedGasFees = isSwap\n ? undefined\n : request.getSavedGasFees(txMeta.chainId);\n\n const suggestedGasFees = await getSuggestedGasFees(request);\n\n log('Suggested gas fees', suggestedGasFees);\n\n const getGasFeeRequest: GetGasFeeRequest = {\n ...request,\n initialParams,\n savedGasFees,\n suggestedGasFees,\n };\n\n txMeta.txParams.maxFeePerGas = getMaxFeePerGas(getGasFeeRequest);\n\n txMeta.txParams.maxPriorityFeePerGas =\n getMaxPriorityFeePerGas(getGasFeeRequest);\n\n txMeta.txParams.gasPrice = getGasPrice(getGasFeeRequest);\n txMeta.userFeeLevel = getUserFeeLevel(getGasFeeRequest);\n\n log('Updated gas fee properties', {\n maxFeePerGas: txMeta.txParams.maxFeePerGas,\n maxPriorityFeePerGas: txMeta.txParams.maxPriorityFeePerGas,\n gasPrice: txMeta.txParams.gasPrice,\n });\n\n if (txMeta.txParams.maxFeePerGas || txMeta.txParams.maxPriorityFeePerGas) {\n delete txMeta.txParams.gasPrice;\n }\n\n if (txMeta.txParams.gasPrice) {\n delete txMeta.txParams.maxFeePerGas;\n delete txMeta.txParams.maxPriorityFeePerGas;\n }\n\n updateDefaultGasEstimates(txMeta);\n}\n\nexport function gweiDecimalToWeiHex(value: string) {\n return toHex(gweiDecToWEIBN(value));\n}\n\nfunction getMaxFeePerGas(request: GetGasFeeRequest): string | undefined {\n const { savedGasFees, eip1559, initialParams, suggestedGasFees } = request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n const maxFeePerGas = gweiDecimalToWeiHex(savedGasFees.maxBaseFee as string);\n log('Using maxFeePerGas from savedGasFees', maxFeePerGas);\n return maxFeePerGas;\n }\n\n if (initialParams.maxFeePerGas) {\n log('Using maxFeePerGas from request', initialParams.maxFeePerGas);\n return initialParams.maxFeePerGas;\n }\n\n if (initialParams.gasPrice && !initialParams.maxPriorityFeePerGas) {\n log(\n 'Setting maxFeePerGas to gasPrice from request',\n initialParams.gasPrice,\n );\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxFeePerGas) {\n log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas);\n return suggestedGasFees.maxFeePerGas;\n }\n\n if (suggestedGasFees.gasPrice) {\n log(\n 'Setting maxFeePerGas to suggested gasPrice',\n suggestedGasFees.gasPrice,\n );\n return suggestedGasFees.gasPrice;\n }\n\n log('maxFeePerGas not set');\n return undefined;\n}\n\nfunction getMaxPriorityFeePerGas(\n request: GetGasFeeRequest,\n): string | undefined {\n const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } =\n request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(savedGasFees.priorityFee);\n log(\n 'Using maxPriorityFeePerGas from savedGasFees.priorityFee',\n maxPriorityFeePerGas,\n );\n return maxPriorityFeePerGas;\n }\n\n if (initialParams.maxPriorityFeePerGas) {\n log(\n 'Using maxPriorityFeePerGas from request',\n initialParams.maxPriorityFeePerGas,\n );\n return initialParams.maxPriorityFeePerGas;\n }\n\n if (initialParams.gasPrice && !initialParams.maxFeePerGas) {\n log(\n 'Setting maxPriorityFeePerGas to gasPrice from request',\n initialParams.gasPrice,\n );\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxPriorityFeePerGas) {\n log(\n 'Using suggested maxPriorityFeePerGas',\n suggestedGasFees.maxPriorityFeePerGas,\n );\n return suggestedGasFees.maxPriorityFeePerGas;\n }\n\n if (txMeta.txParams.maxFeePerGas) {\n log(\n 'Setting maxPriorityFeePerGas to maxFeePerGas',\n txMeta.txParams.maxFeePerGas,\n );\n return txMeta.txParams.maxFeePerGas;\n }\n\n log('maxPriorityFeePerGas not set');\n return undefined;\n}\n\nfunction getGasPrice(request: GetGasFeeRequest): string | undefined {\n const { eip1559, initialParams, suggestedGasFees } = request;\n\n if (eip1559) {\n return undefined;\n }\n\n if (initialParams.gasPrice) {\n log('Using gasPrice from request', initialParams.gasPrice);\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxFeePerGas) {\n log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas);\n return suggestedGasFees.maxFeePerGas;\n }\n\n if (suggestedGasFees.gasPrice) {\n log('Using suggested gasPrice', suggestedGasFees.gasPrice);\n return suggestedGasFees.gasPrice;\n }\n\n log('gasPrice not set');\n return undefined;\n}\n\nfunction getUserFeeLevel(request: GetGasFeeRequest): UserFeeLevel | undefined {\n const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } =\n request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n return UserFeeLevel.CUSTOM;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n initialParams.gasPrice\n ) {\n return txMeta.origin === ORIGIN_METAMASK\n ? UserFeeLevel.CUSTOM\n : UserFeeLevel.DAPP_SUGGESTED;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n suggestedGasFees.maxFeePerGas &&\n suggestedGasFees.maxPriorityFeePerGas\n ) {\n return UserFeeLevel.MEDIUM;\n }\n\n if (txMeta.origin === ORIGIN_METAMASK) {\n return UserFeeLevel.MEDIUM;\n }\n\n return UserFeeLevel.DAPP_SUGGESTED;\n}\n\nfunction updateDefaultGasEstimates(txMeta: TransactionMeta) {\n if (!txMeta.defaultGasEstimates) {\n txMeta.defaultGasEstimates = {};\n }\n\n txMeta.defaultGasEstimates.maxFeePerGas = txMeta.txParams.maxFeePerGas;\n\n txMeta.defaultGasEstimates.maxPriorityFeePerGas =\n txMeta.txParams.maxPriorityFeePerGas;\n\n txMeta.defaultGasEstimates.gasPrice = txMeta.txParams.gasPrice;\n txMeta.defaultGasEstimates.estimateType = txMeta.userFeeLevel;\n}\n\nasync function getSuggestedGasFees(\n request: UpdateGasFeesRequest,\n): Promise<SuggestedGasFees> {\n const { eip1559, ethQuery, gasFeeFlows, getGasFeeEstimates, txMeta } =\n request;\n\n const { networkClientId } = txMeta;\n\n if (\n (!eip1559 && txMeta.txParams.gasPrice) ||\n (eip1559 &&\n txMeta.txParams.maxFeePerGas &&\n txMeta.txParams.maxPriorityFeePerGas)\n ) {\n return {};\n }\n\n const gasFeeFlow = getGasFeeFlow(txMeta, gasFeeFlows) as GasFeeFlow;\n\n try {\n const gasFeeControllerData = await getGasFeeEstimates({ networkClientId });\n\n const response = await gasFeeFlow.getGasFees({\n ethQuery,\n gasFeeControllerData,\n transactionMeta: txMeta,\n });\n\n const gasFeeEstimateType = response.estimates?.type;\n\n switch (gasFeeEstimateType) {\n case GasFeeEstimateType.FeeMarket:\n return response.estimates.medium;\n case GasFeeEstimateType.Legacy:\n return {\n gasPrice: response.estimates.medium,\n };\n case GasFeeEstimateType.GasPrice:\n return { gasPrice: response.estimates.gasPrice };\n default:\n throw new Error(\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Unsupported gas fee estimate type returned from flow: ${gasFeeEstimateType}`,\n );\n }\n } catch (error) {\n log('Failed to get suggested gas fees', error);\n }\n\n const gasPriceDecimal = (await query(ethQuery, 'gasPrice')) as number;\n\n const gasPrice = gasPriceDecimal\n ? add0x(gasPriceDecimal.toString(16))\n : undefined;\n\n return { gasPrice };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EtherscanRemoteTransactionSource
3
- } from "./chunk-CPMTUMMZ.mjs";
3
+ } from "./chunk-EKJXGERC.mjs";
4
4
  import {
5
5
  incomingTransactionsLogger
6
6
  } from "./chunk-UQQWZT6C.mjs";
@@ -125,6 +125,9 @@ var MultichainTrackingHelper = class {
125
125
  networkClientId,
126
126
  chainId
127
127
  } = {}) {
128
+ if (!__privateGet(this, _isMultichainEnabled)) {
129
+ return new EthQuery(this.getProvider());
130
+ }
128
131
  return new EthQuery(this.getProvider({ networkClientId, chainId }));
129
132
  }
130
133
  getProvider({
@@ -332,4 +335,4 @@ getNetworkClient_fn = function({
332
335
  export {
333
336
  MultichainTrackingHelper
334
337
  };
335
- //# sourceMappingURL=chunk-AZ4WIRH3.mjs.map
338
+ //# sourceMappingURL=chunk-4V4XIPCI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/MultichainTrackingHelper.ts"],"sourcesContent":["import EthQuery from '@metamask/eth-query';\nimport type {\n NetworkClientId,\n NetworkController,\n NetworkClient,\n BlockTracker,\n Provider,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { NonceLock, NonceTracker } from '@metamask/nonce-tracker';\nimport type { Hex } from '@metamask/utils';\nimport { Mutex } from 'async-mutex';\n\nimport { incomingTransactionsLogger as log } from '../logger';\nimport { EtherscanRemoteTransactionSource } from './EtherscanRemoteTransactionSource';\nimport type {\n IncomingTransactionHelper,\n IncomingTransactionOptions,\n} from './IncomingTransactionHelper';\nimport type { PendingTransactionTracker } from './PendingTransactionTracker';\n\n/**\n * Registry of network clients provided by the NetworkController\n */\ntype NetworkClientRegistry = ReturnType<\n NetworkController['getNetworkClientRegistry']\n>;\n\nexport type MultichainTrackingHelperOptions = {\n isMultichainEnabled: boolean;\n provider: Provider;\n nonceTracker: NonceTracker;\n incomingTransactionOptions: IncomingTransactionOptions;\n\n findNetworkClientIdByChainId: NetworkController['findNetworkClientIdByChainId'];\n getNetworkClientById: NetworkController['getNetworkClientById'];\n getNetworkClientRegistry: NetworkController['getNetworkClientRegistry'];\n\n removeIncomingTransactionHelperListeners: (\n IncomingTransactionHelper: IncomingTransactionHelper,\n ) => void;\n removePendingTransactionTrackerListeners: (\n pendingTransactionTracker: PendingTransactionTracker,\n ) => void;\n createNonceTracker: (opts: {\n provider: Provider;\n blockTracker: BlockTracker;\n chainId?: Hex;\n }) => NonceTracker;\n createIncomingTransactionHelper: (opts: {\n blockTracker: BlockTracker;\n etherscanRemoteTransactionSource: EtherscanRemoteTransactionSource;\n chainId?: Hex;\n }) => IncomingTransactionHelper;\n createPendingTransactionTracker: (opts: {\n provider: Provider;\n blockTracker: BlockTracker;\n chainId?: Hex;\n }) => PendingTransactionTracker;\n onNetworkStateChange: (\n listener: (\n ...payload: NetworkControllerStateChangeEvent['payload']\n ) => void,\n ) => void;\n};\n\nexport class MultichainTrackingHelper {\n #isMultichainEnabled: boolean;\n\n readonly #provider: Provider;\n\n readonly #nonceTracker: NonceTracker;\n\n readonly #incomingTransactionOptions: IncomingTransactionOptions;\n\n readonly #findNetworkClientIdByChainId: NetworkController['findNetworkClientIdByChainId'];\n\n readonly #getNetworkClientById: NetworkController['getNetworkClientById'];\n\n readonly #getNetworkClientRegistry: NetworkController['getNetworkClientRegistry'];\n\n readonly #removeIncomingTransactionHelperListeners: (\n IncomingTransactionHelper: IncomingTransactionHelper,\n ) => void;\n\n readonly #removePendingTransactionTrackerListeners: (\n pendingTransactionTracker: PendingTransactionTracker,\n ) => void;\n\n readonly #createNonceTracker: (opts: {\n provider: Provider;\n blockTracker: BlockTracker;\n chainId?: Hex;\n }) => NonceTracker;\n\n readonly #createIncomingTransactionHelper: (opts: {\n blockTracker: BlockTracker;\n chainId?: Hex;\n etherscanRemoteTransactionSource: EtherscanRemoteTransactionSource;\n }) => IncomingTransactionHelper;\n\n readonly #createPendingTransactionTracker: (opts: {\n provider: Provider;\n blockTracker: BlockTracker;\n chainId?: Hex;\n }) => PendingTransactionTracker;\n\n readonly #nonceMutexesByChainId = new Map<Hex, Map<string, Mutex>>();\n\n readonly #trackingMap: Map<\n NetworkClientId,\n {\n nonceTracker: NonceTracker;\n pendingTransactionTracker: PendingTransactionTracker;\n incomingTransactionHelper: IncomingTransactionHelper;\n }\n > = new Map();\n\n readonly #etherscanRemoteTransactionSourcesMap: Map<\n Hex,\n EtherscanRemoteTransactionSource\n > = new Map();\n\n constructor({\n isMultichainEnabled,\n provider,\n nonceTracker,\n incomingTransactionOptions,\n findNetworkClientIdByChainId,\n getNetworkClientById,\n getNetworkClientRegistry,\n removeIncomingTransactionHelperListeners,\n removePendingTransactionTrackerListeners,\n createNonceTracker,\n createIncomingTransactionHelper,\n createPendingTransactionTracker,\n onNetworkStateChange,\n }: MultichainTrackingHelperOptions) {\n this.#isMultichainEnabled = isMultichainEnabled;\n this.#provider = provider;\n this.#nonceTracker = nonceTracker;\n this.#incomingTransactionOptions = incomingTransactionOptions;\n\n this.#findNetworkClientIdByChainId = findNetworkClientIdByChainId;\n this.#getNetworkClientById = getNetworkClientById;\n this.#getNetworkClientRegistry = getNetworkClientRegistry;\n\n this.#removeIncomingTransactionHelperListeners =\n removeIncomingTransactionHelperListeners;\n this.#removePendingTransactionTrackerListeners =\n removePendingTransactionTrackerListeners;\n this.#createNonceTracker = createNonceTracker;\n this.#createIncomingTransactionHelper = createIncomingTransactionHelper;\n this.#createPendingTransactionTracker = createPendingTransactionTracker;\n\n onNetworkStateChange((_, patches) => {\n if (this.#isMultichainEnabled) {\n const networkClients = this.#getNetworkClientRegistry();\n patches.forEach(({ op, path }) => {\n if (op === 'remove' && path[0] === 'networkConfigurations') {\n const networkClientId = path[1] as NetworkClientId;\n delete networkClients[networkClientId];\n }\n });\n\n this.#refreshTrackingMap(networkClients);\n }\n });\n }\n\n initialize() {\n if (!this.#isMultichainEnabled) {\n return;\n }\n const networkClients = this.#getNetworkClientRegistry();\n this.#refreshTrackingMap(networkClients);\n }\n\n has(networkClientId: NetworkClientId) {\n return this.#trackingMap.has(networkClientId);\n }\n\n getEthQuery({\n networkClientId,\n chainId,\n }: {\n networkClientId?: NetworkClientId;\n chainId?: Hex;\n } = {}): EthQuery {\n if (!this.#isMultichainEnabled) {\n return new EthQuery(this.getProvider());\n }\n return new EthQuery(this.getProvider({ networkClientId, chainId }));\n }\n\n getProvider({\n networkClientId,\n chainId,\n }: {\n networkClientId?: NetworkClientId;\n chainId?: Hex;\n } = {}): Provider {\n if (!this.#isMultichainEnabled) {\n return this.#provider;\n }\n\n const networkClient = this.#getNetworkClient({\n networkClientId,\n chainId,\n });\n\n return networkClient?.provider || this.#provider;\n }\n\n /**\n * Gets the mutex intended to guard the nonceTracker for a particular chainId and key .\n *\n * @param opts - The options object.\n * @param opts.chainId - The hex chainId.\n * @param opts.key - The hex address (or constant) pertaining to the chainId\n * @returns Mutex instance for the given chainId and key pair\n */\n async acquireNonceLockForChainIdKey({\n chainId,\n key = 'global',\n }: {\n chainId: Hex;\n key?: string;\n }): Promise<() => void> {\n let nonceMutexesForChainId = this.#nonceMutexesByChainId.get(chainId);\n if (!nonceMutexesForChainId) {\n nonceMutexesForChainId = new Map<string, Mutex>();\n this.#nonceMutexesByChainId.set(chainId, nonceMutexesForChainId);\n }\n let nonceMutexForKey = nonceMutexesForChainId.get(key);\n if (!nonceMutexForKey) {\n nonceMutexForKey = new Mutex();\n nonceMutexesForChainId.set(key, nonceMutexForKey);\n }\n\n return await nonceMutexForKey.acquire();\n }\n\n /**\n * Gets the next nonce according to the nonce-tracker.\n * Ensure `releaseLock` is called once processing of the `nonce` value is complete.\n *\n * @param address - The hex string address for the transaction.\n * @param networkClientId - The network client ID for the transaction, used to fetch the correct nonce tracker.\n * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock.\n */\n async getNonceLock(\n address: string,\n networkClientId?: NetworkClientId,\n ): Promise<NonceLock> {\n let releaseLockForChainIdKey: (() => void) | undefined;\n let nonceTracker = this.#nonceTracker;\n if (networkClientId && this.#isMultichainEnabled) {\n const networkClient = this.#getNetworkClientById(networkClientId);\n releaseLockForChainIdKey = await this.acquireNonceLockForChainIdKey({\n chainId: networkClient.configuration.chainId,\n key: address,\n });\n const trackers = this.#trackingMap.get(networkClientId);\n if (!trackers) {\n throw new Error('missing nonceTracker for networkClientId');\n }\n nonceTracker = trackers.nonceTracker;\n }\n\n // Acquires the lock for the chainId + address and the nonceLock from the nonceTracker, then\n // couples them together by replacing the nonceLock's releaseLock method with\n // an anonymous function that calls releases both the original nonceLock and the\n // lock for the chainId.\n try {\n const nonceLock = await nonceTracker.getNonceLock(address);\n return {\n ...nonceLock,\n releaseLock: () => {\n nonceLock.releaseLock();\n releaseLockForChainIdKey?.();\n },\n };\n } catch (err) {\n releaseLockForChainIdKey?.();\n throw err;\n }\n }\n\n startIncomingTransactionPolling(networkClientIds: NetworkClientId[] = []) {\n networkClientIds.forEach((networkClientId) => {\n this.#trackingMap.get(networkClientId)?.incomingTransactionHelper.start();\n });\n }\n\n stopIncomingTransactionPolling(networkClientIds: NetworkClientId[] = []) {\n networkClientIds.forEach((networkClientId) => {\n this.#trackingMap.get(networkClientId)?.incomingTransactionHelper.stop();\n });\n }\n\n stopAllIncomingTransactionPolling() {\n for (const [, trackers] of this.#trackingMap) {\n trackers.incomingTransactionHelper.stop();\n }\n }\n\n async updateIncomingTransactions(networkClientIds: NetworkClientId[] = []) {\n const promises = await Promise.allSettled(\n networkClientIds.map(async (networkClientId) => {\n return await this.#trackingMap\n .get(networkClientId)\n ?.incomingTransactionHelper.update();\n }),\n );\n\n promises\n .filter((result) => result.status === 'rejected')\n .forEach((result) => {\n log(\n 'failed to update incoming transactions',\n (result as PromiseRejectedResult).reason,\n );\n });\n }\n\n checkForPendingTransactionAndStartPolling = () => {\n for (const [, trackers] of this.#trackingMap) {\n trackers.pendingTransactionTracker.startIfPendingTransactions();\n }\n };\n\n stopAllTracking() {\n for (const [networkClientId] of this.#trackingMap) {\n this.#stopTrackingByNetworkClientId(networkClientId);\n }\n }\n\n #refreshTrackingMap = (networkClients: NetworkClientRegistry) => {\n this.#refreshEtherscanRemoteTransactionSources(networkClients);\n\n const networkClientIds = Object.keys(networkClients);\n const existingNetworkClientIds = Array.from(this.#trackingMap.keys());\n\n // Remove tracking for NetworkClientIds that no longer exist\n const networkClientIdsToRemove = existingNetworkClientIds.filter(\n (id) => !networkClientIds.includes(id),\n );\n networkClientIdsToRemove.forEach((id) => {\n this.#stopTrackingByNetworkClientId(id);\n });\n\n // Start tracking new NetworkClientIds from the registry\n const networkClientIdsToAdd = networkClientIds.filter(\n (id) => !existingNetworkClientIds.includes(id),\n );\n networkClientIdsToAdd.forEach((id) => {\n this.#startTrackingByNetworkClientId(id);\n });\n };\n\n #stopTrackingByNetworkClientId(networkClientId: NetworkClientId) {\n const trackers = this.#trackingMap.get(networkClientId);\n if (trackers) {\n trackers.pendingTransactionTracker.stop();\n this.#removePendingTransactionTrackerListeners(\n trackers.pendingTransactionTracker,\n );\n trackers.incomingTransactionHelper.stop();\n this.#removeIncomingTransactionHelperListeners(\n trackers.incomingTransactionHelper,\n );\n this.#trackingMap.delete(networkClientId);\n }\n }\n\n #startTrackingByNetworkClientId(networkClientId: NetworkClientId) {\n const trackers = this.#trackingMap.get(networkClientId);\n if (trackers) {\n return;\n }\n\n const {\n provider,\n blockTracker,\n configuration: { chainId },\n } = this.#getNetworkClientById(networkClientId);\n\n let etherscanRemoteTransactionSource =\n this.#etherscanRemoteTransactionSourcesMap.get(chainId);\n if (!etherscanRemoteTransactionSource) {\n etherscanRemoteTransactionSource = new EtherscanRemoteTransactionSource({\n includeTokenTransfers:\n this.#incomingTransactionOptions.includeTokenTransfers,\n });\n this.#etherscanRemoteTransactionSourcesMap.set(\n chainId,\n etherscanRemoteTransactionSource,\n );\n }\n\n const nonceTracker = this.#createNonceTracker({\n provider,\n blockTracker,\n chainId,\n });\n\n const incomingTransactionHelper = this.#createIncomingTransactionHelper({\n blockTracker,\n etherscanRemoteTransactionSource,\n chainId,\n });\n\n const pendingTransactionTracker = this.#createPendingTransactionTracker({\n provider,\n blockTracker,\n chainId,\n });\n\n this.#trackingMap.set(networkClientId, {\n nonceTracker,\n incomingTransactionHelper,\n pendingTransactionTracker,\n });\n }\n\n #refreshEtherscanRemoteTransactionSources = (\n networkClients: NetworkClientRegistry,\n ) => {\n // this will be prettier when we have consolidated network clients with a single chainId:\n // check if there are still other network clients using the same chainId\n // if not remove the etherscanRemoteTransaction source from the map\n const chainIdsInRegistry = new Set();\n Object.values(networkClients).forEach((networkClient) =>\n chainIdsInRegistry.add(networkClient.configuration.chainId),\n );\n const existingChainIds = Array.from(\n this.#etherscanRemoteTransactionSourcesMap.keys(),\n );\n const chainIdsToRemove = existingChainIds.filter(\n (chainId) => !chainIdsInRegistry.has(chainId),\n );\n\n chainIdsToRemove.forEach((chainId) => {\n this.#etherscanRemoteTransactionSourcesMap.delete(chainId);\n });\n };\n\n #getNetworkClient({\n networkClientId,\n chainId,\n }: {\n networkClientId?: NetworkClientId;\n chainId?: Hex;\n } = {}): NetworkClient | undefined {\n let networkClient: NetworkClient | undefined;\n\n if (networkClientId) {\n try {\n networkClient = this.#getNetworkClientById(networkClientId);\n } catch (err) {\n log('failed to get network client by networkClientId');\n }\n }\n if (!networkClient && chainId) {\n try {\n const networkClientIdForChainId =\n this.#findNetworkClientIdByChainId(chainId);\n networkClient = this.#getNetworkClientById(networkClientIdForChainId);\n } catch (err) {\n log('failed to get network client by chainId');\n }\n }\n return networkClient;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAO,cAAc;AAWrB,SAAS,aAAa;AAXtB;AAkEO,IAAM,2BAAN,MAA+B;AAAA,EAyDpC,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAoC;AAgOpC;AAeA;AAwEA;AA7XA;AAEA,uBAAS,WAAT;AAEA,uBAAS,eAAT;AAEA,uBAAS,6BAAT;AAEA,uBAAS,+BAAT;AAEA,uBAAS,uBAAT;AAEA,uBAAS,2BAAT;AAEA,uBAAS,2CAAT;AAIA,uBAAS,2CAAT;AAIA,uBAAS,qBAAT;AAMA,uBAAS,kCAAT;AAMA,uBAAS,kCAAT;AAMA,uBAAS,wBAAyB,oBAAI,IAA6B;AAEnE,uBAAS,cAOL,oBAAI,IAAI;AAEZ,uBAAS,uCAGL,oBAAI,IAAI;AA6MZ,qDAA4C,MAAM;AAChD,iBAAW,CAAC,EAAE,QAAQ,KAAK,mBAAK,eAAc;AAC5C,iBAAS,0BAA0B,2BAA2B;AAAA,MAChE;AAAA,IACF;AAQA,4CAAsB,CAAC,mBAA0C;AAC/D,yBAAK,2CAAL,WAA+C;AAE/C,YAAM,mBAAmB,OAAO,KAAK,cAAc;AACnD,YAAM,2BAA2B,MAAM,KAAK,mBAAK,cAAa,KAAK,CAAC;AAGpE,YAAM,2BAA2B,yBAAyB;AAAA,QACxD,CAAC,OAAO,CAAC,iBAAiB,SAAS,EA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B;AAAA,IAC5C;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,4BAA4B,mBAAK,kCAAL,WAAsC;AAAA,IACtE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,4BAA4B,mBAAK,kCAAL,WAAsC;AAAA,IACtE;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,qBAAK,cAAa,IAAI,iBAAiB;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEA;AAsBA;AAAA,sBAAiB,SAAC;AAAA,EAChB;AAAA,EACA;AACF,IAGI,CAAC,GAA8B;AACjC,MAAI;AAEJ,MAAI,iBAAiB;AACnB,QAAI;AACF,sBAAgB,mBAAK,uBAAL,WAA2B;AAAA,IAC7C,SAAS,KAAK;AACZ,iCAAI,iDAAiD;AAAA,IACvD;AAAA,EACF;AACA,MAAI,CAAC,iBAAiB,SAAS;AAC7B,QAAI;AACF,YAAM,4BACJ,mBAAK,+BAAL,WAAmC;AACrC,sBAAgB,mBAAK,uBAAL,WAA2B;AAAA,IAC7C,SAAS,KAAK;AACZ,iCAAI,yCAAyC;AAAA,IAC/C;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isEIP1559Transaction
3
- } from "./chunk-J56A7UCK.mjs";
3
+ } from "./chunk-Q56I5ONX.mjs";
4
4
 
5
5
  // src/utils/validation.ts
6
6
  import { Interface } from "@ethersproject/abi";
@@ -100,6 +100,8 @@ function validateParamData(value) {
100
100
  function validateParamChainId(chainId) {
101
101
  if (chainId !== void 0 && typeof chainId !== "number" && typeof chainId !== "string") {
102
102
  throw rpcErrors.invalidParams(
103
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
104
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
103
105
  `Invalid transaction params: chainId is not a Number or hex string. got: (${chainId})`
104
106
  );
105
107
  }
@@ -170,6 +172,8 @@ function ensureMutuallyExclusiveFieldsNotProvided(txParams, fieldBeingValidated,
170
172
  function ensureFieldIsString(txParams, field) {
171
173
  if (typeof txParams[field] !== "string") {
172
174
  throw rpcErrors.invalidParams(
175
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
176
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
173
177
  `Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`
174
178
  );
175
179
  }
@@ -179,4 +183,4 @@ export {
179
183
  validateTransactionOrigin,
180
184
  validateTxParams
181
185
  };
182
- //# sourceMappingURL=chunk-NM6OYEPP.mjs.map
186
+ //# sourceMappingURL=chunk-5ZEJT5SN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/validation.ts"],"sourcesContent":["import { Interface } from '@ethersproject/abi';\nimport { ORIGIN_METAMASK, isValidHexAddress } from '@metamask/controller-utils';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { providerErrors, rpcErrors } from '@metamask/rpc-errors';\n\nimport { TransactionEnvelopeType, type TransactionParams } from '../types';\nimport { isEIP1559Transaction } from './utils';\n\ntype GasFieldsToValidate = 'gasPrice' | 'maxFeePerGas' | 'maxPriorityFeePerGas';\n\n/**\n * Validates whether a transaction initiated by a specific 'from' address is permitted by the origin.\n *\n * @param permittedAddresses - The permitted accounts for the given origin.\n * @param selectedAddress - The currently selected Ethereum address in the wallet.\n * @param from - The address from which the transaction is initiated.\n * @param origin - The origin or source of the transaction.\n * @throws Throws an error if the transaction is not permitted.\n */\nexport async function validateTransactionOrigin(\n permittedAddresses: string[],\n selectedAddress: string,\n from: string,\n origin: string,\n) {\n if (origin === ORIGIN_METAMASK) {\n // Ensure the 'from' address matches the currently selected address\n if (from !== selectedAddress) {\n throw rpcErrors.internal({\n message: `Internally initiated transaction is using invalid account.`,\n data: {\n origin,\n fromAddress: from,\n selectedAddress,\n },\n });\n }\n return;\n }\n\n // Check if the origin has permissions to initiate transactions from the specified address\n if (!permittedAddresses.includes(from)) {\n throw providerErrors.unauthorized({ data: { origin } });\n }\n}\n\n/**\n * Validates the transaction params for required properties and throws in\n * the event of any validation error.\n *\n * @param txParams - Transaction params object to validate.\n * @param isEIP1559Compatible - whether or not the current network supports EIP-1559 transactions.\n */\nexport function validateTxParams(\n txParams: TransactionParams,\n isEIP1559Compatible = true,\n) {\n validateEIP1559Compatibility(txParams, isEIP1559Compatible);\n validateParamFrom(txParams.from);\n validateParamRecipient(txParams);\n validateParamValue(txParams.value);\n validateParamData(txParams.data);\n validateParamChainId(txParams.chainId);\n validateGasFeeParams(txParams);\n}\n\n/**\n * Validates EIP-1559 compatibility for transaction creation.\n *\n * @param txParams - The transaction parameters to validate.\n * @param isEIP1559Compatible - Indicates if the current network supports EIP-1559.\n * @throws Throws invalid params if the transaction specifies EIP-1559 but the network does not support it.\n */\nfunction validateEIP1559Compatibility(\n txParams: TransactionParams,\n isEIP1559Compatible: boolean,\n) {\n if (isEIP1559Transaction(txParams) && !isEIP1559Compatible) {\n throw rpcErrors.invalidParams(\n 'Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559',\n );\n }\n}\n\n/**\n * Validates value property, ensuring it is a valid positive integer number\n * denominated in wei.\n *\n * @param value - The value to validate, expressed as a string.\n * @throws Throws an error if the value is not a valid positive integer\n * number denominated in wei.\n * - If the value contains a hyphen (-), it is considered invalid.\n * - If the value contains a decimal point (.), it is considered invalid.\n * - If the value is not a finite number, is NaN, or is not a safe integer, it is considered invalid.\n */\nfunction validateParamValue(value?: string) {\n if (value !== undefined) {\n if (value.includes('-')) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value \"${value}\": not a positive number.`,\n );\n }\n\n if (value.includes('.')) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value \"${value}\": number must be in wei.`,\n );\n }\n const intValue = parseInt(value, 10);\n const isValid =\n Number.isFinite(intValue) &&\n !Number.isNaN(intValue) &&\n !isNaN(Number(value)) &&\n Number.isSafeInteger(intValue);\n if (!isValid) {\n throw rpcErrors.invalidParams(\n `Invalid transaction value ${value}: number must be a valid number.`,\n );\n }\n }\n}\n\n/**\n * Validates the recipient address in a transaction's parameters.\n *\n * @param txParams - The transaction parameters object to validate.\n * @throws Throws an error if the recipient address is invalid:\n * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data,\n * the \"to\" field is removed from the transaction parameters.\n * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown.\n */\nfunction validateParamRecipient(txParams: TransactionParams) {\n if (txParams.to === '0x' || txParams.to === undefined) {\n if (txParams.data) {\n delete txParams.to;\n } else {\n throw rpcErrors.invalidParams(`Invalid \"to\" address.`);\n }\n } else if (txParams.to !== undefined && !isValidHexAddress(txParams.to)) {\n throw rpcErrors.invalidParams(`Invalid \"to\" address.`);\n }\n}\n\n/**\n * Validates the recipient address in a transaction's parameters.\n *\n * @param from - The from property to validate.\n * @throws Throws an error if the recipient address is invalid:\n * - If the recipient address is an empty string ('0x') or undefined and the transaction contains data,\n * the \"to\" field is removed from the transaction parameters.\n * - If the recipient address is not a valid hexadecimal Ethereum address, an error is thrown.\n */\nfunction validateParamFrom(from: string) {\n if (!from || typeof from !== 'string') {\n throw rpcErrors.invalidParams(\n `Invalid \"from\" address ${from}: not a string.`,\n );\n }\n if (!isValidHexAddress(from)) {\n throw rpcErrors.invalidParams('Invalid \"from\" address.');\n }\n}\n\n/**\n * Validates input data for transactions.\n *\n * @param value - The input data to validate.\n * @throws Throws invalid params if the input data is invalid.\n */\nfunction validateParamData(value?: string) {\n if (value) {\n const ERC20Interface = new Interface(abiERC20);\n try {\n ERC20Interface.parseTransaction({ data: value });\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.message.match(/BUFFER_OVERRUN/u)) {\n throw rpcErrors.invalidParams(\n 'Invalid transaction params: data out-of-bounds, BUFFER_OVERRUN.',\n );\n }\n }\n }\n}\n\n/**\n * Validates chainId type.\n *\n * @param chainId - The chainId to validate.\n */\nfunction validateParamChainId(chainId: number | string | undefined) {\n if (\n chainId !== undefined &&\n typeof chainId !== 'number' &&\n typeof chainId !== 'string'\n ) {\n throw rpcErrors.invalidParams(\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 `Invalid transaction params: chainId is not a Number or hex string. got: (${chainId})`,\n );\n }\n}\n\n/**\n * Validates gas values.\n *\n * @param txParams - The transaction parameters to validate.\n */\nfunction validateGasFeeParams(txParams: TransactionParams) {\n if (txParams.gasPrice) {\n ensureProperTransactionEnvelopeTypeProvided(txParams, 'gasPrice');\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'gasPrice',\n 'maxFeePerGas',\n );\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'gasPrice',\n 'maxPriorityFeePerGas',\n );\n ensureFieldIsString(txParams, 'gasPrice');\n }\n\n if (txParams.maxFeePerGas) {\n ensureProperTransactionEnvelopeTypeProvided(txParams, 'maxFeePerGas');\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'maxFeePerGas',\n 'gasPrice',\n );\n ensureFieldIsString(txParams, 'maxFeePerGas');\n }\n\n if (txParams.maxPriorityFeePerGas) {\n ensureProperTransactionEnvelopeTypeProvided(\n txParams,\n 'maxPriorityFeePerGas',\n );\n ensureMutuallyExclusiveFieldsNotProvided(\n txParams,\n 'maxPriorityFeePerGas',\n 'gasPrice',\n );\n ensureFieldIsString(txParams, 'maxPriorityFeePerGas');\n }\n}\n\n/**\n * Ensures that the provided txParams has the proper 'type' specified for the\n * given field, if it is provided. If types do not match throws an\n * invalidParams error.\n *\n * @param txParams - The transaction parameters object\n * @param field - The current field being validated\n * @throws {ethErrors.rpc.invalidParams} Throws if type does not match the\n * expectations for provided field.\n */\nfunction ensureProperTransactionEnvelopeTypeProvided(\n txParams: TransactionParams,\n field: GasFieldsToValidate,\n) {\n switch (field) {\n case 'maxFeePerGas':\n case 'maxPriorityFeePerGas':\n if (\n txParams.type &&\n txParams.type !== TransactionEnvelopeType.feeMarket\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: specified type \"${txParams.type}\" but including maxFeePerGas and maxPriorityFeePerGas requires type: \"${TransactionEnvelopeType.feeMarket}\"`,\n );\n }\n break;\n case 'gasPrice':\n default:\n if (\n txParams.type &&\n txParams.type === TransactionEnvelopeType.feeMarket\n ) {\n throw rpcErrors.invalidParams(\n `Invalid transaction envelope type: specified type \"${txParams.type}\" but included a gasPrice instead of maxFeePerGas and maxPriorityFeePerGas`,\n );\n }\n }\n}\n\n/**\n * Given two fields, ensure that the second field is not included in txParams,\n * and if it is throw an invalidParams error.\n *\n * @param txParams - The transaction parameters object\n * @param fieldBeingValidated - The current field being validated\n * @param mutuallyExclusiveField - The field to ensure is not provided\n * @throws {ethErrors.rpc.invalidParams} Throws if mutuallyExclusiveField is\n * present in txParams.\n */\nfunction ensureMutuallyExclusiveFieldsNotProvided(\n txParams: TransactionParams,\n fieldBeingValidated: GasFieldsToValidate,\n mutuallyExclusiveField: GasFieldsToValidate,\n) {\n if (typeof txParams[mutuallyExclusiveField] !== 'undefined') {\n throw rpcErrors.invalidParams(\n `Invalid transaction params: specified ${fieldBeingValidated} but also included ${mutuallyExclusiveField}, these cannot be mixed`,\n );\n }\n}\n\n/**\n * Ensures that the provided value for field is a string, throws an\n * invalidParams error if field is not a string.\n *\n * @param txParams - The transaction parameters object\n * @param field - The current field being validated\n * @throws {rpcErrors.invalidParams} Throws if field is not a string\n */\nfunction ensureFieldIsString(\n txParams: TransactionParams,\n field: GasFieldsToValidate,\n) {\n if (typeof txParams[field] !== 'string') {\n throw rpcErrors.invalidParams(\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 `Invalid transaction params: ${field} is not a string. got: (${txParams[field]})`,\n );\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,gBAAgB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U,UAAU;AAAA,EAC1C;AAEA,MAAI,SAAS,cAAc;AACzB,gDAA4C,UAAU,cAAc;AACpE;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,wBAAoB,UAAU,cAAc;AAAA,EAC9C;AAEA,MAAI,SAAS,sBAAsB;AACjC;AAAA,MACE;AAAA,MACA;AAAA,IACF;AACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,wBAAoB,UAAU,sBAAsB;AAAA,EACtD;AACF;AAYA,SAAS,4CACP,UACA,OACA;AACA,UAAQ,OAAO;AAAA,IACb,KAAK;AAAA,IACL,KAAK;AACH,UACE,SAAS,QACT,SAAS,gCACT;AACA,cAAM,UAAU;AAAA,UACd,sDAAsD,SAAS,IAAI,8FAA0G;AAAA,QAC/K;AAAA,MACF;AACA;AAAA,IACF,KAAK;AAAA,IACL;AACE,UACE,SAAS,QACT,SAAS,gCACT;AACA,cAAM,UAAU;AAAA,UACd,sDAAsD,SAAS,IAAI;AAAA,QACrE;AAAA,MACF;AAAA,EACJ;AACF;AAYA,SAAS,yCACP,UACA,qBACA,wBACA;AACA,MAAI,OAAO,SAAS,sBAAsB,MAAM,aAAa;AAC3D,UAAM,UAAU;AAAA,MACd,yCAAyC,mBAAmB,sBAAsB,sBAAsB;AAAA,IAC1G;AAAA,EACF;AACF;AAUA,SAAS,oBACP,UACA,OACA;AACA,MAAI,OAAO,SAAS,KAAK,MAAM,UAAU;AACvC,UAAM,UAAU;AAAA;AAAA;AAAA,MAGd,+BAA+B,KAAK,2BAA2B,SAAS,KAAK,CAAC;AAAA,IAChF;AAAA,EACF;AACF;","names":[]}
@@ -396,4 +396,4 @@ getCurrentChainTransactions_fn = function() {
396
396
  export {
397
397
  PendingTransactionTracker
398
398
  };
399
- //# sourceMappingURL=chunk-5YES3V2R.mjs.map
399
+ //# sourceMappingURL=chunk-6B5BEO3R.mjs.map