@metamask/transaction-controller 35.1.1 → 35.2.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 (105) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/TransactionController.js +12 -11
  3. package/dist/TransactionController.mjs +11 -10
  4. package/dist/{chunk-GPS6RX64.js → chunk-4OYPDGHO.js} +6 -6
  5. package/dist/{chunk-2EU6346V.js → chunk-5HYWLTVQ.js} +3 -3
  6. package/dist/chunk-5QVDIVJH.js +68 -0
  7. package/dist/chunk-5QVDIVJH.js.map +1 -0
  8. package/dist/{chunk-H2KZOK3J.mjs → chunk-AWIJZAW3.mjs} +3 -3
  9. package/dist/{chunk-C3WC4OJ3.js → chunk-BZV72SCF.js} +5 -5
  10. package/dist/{chunk-QTKXIDGE.js → chunk-EHWAY6XU.js} +9 -9
  11. package/dist/{chunk-GNAL5HC2.mjs → chunk-JIFPK37W.mjs} +2 -2
  12. package/dist/chunk-JOQK7A5G.mjs +68 -0
  13. package/dist/chunk-JOQK7A5G.mjs.map +1 -0
  14. package/dist/{chunk-OZ6UB42C.js → chunk-KTGMNUTQ.js} +2 -23
  15. package/dist/chunk-KTGMNUTQ.js.map +1 -0
  16. package/dist/{chunk-UHG2LLVV.mjs → chunk-KYRW4BLA.mjs} +3 -3
  17. package/dist/{chunk-6SJYXSF3.mjs → chunk-LFFYCDHB.mjs} +1 -1
  18. package/dist/{chunk-6SJYXSF3.mjs.map → chunk-LFFYCDHB.mjs.map} +1 -1
  19. package/dist/{chunk-JXXTNVU4.mjs → chunk-NNHSNPT2.mjs} +2 -2
  20. package/dist/{chunk-AYTU4HU5.js → chunk-PSZ34BI5.js} +1 -1
  21. package/dist/{chunk-AYTU4HU5.js.map → chunk-PSZ34BI5.js.map} +1 -1
  22. package/dist/{chunk-QH2H4W3N.js → chunk-QKV7E5BO.js} +5 -5
  23. package/dist/{chunk-VXNPVIYL.mjs → chunk-SFFOC25Q.mjs} +3 -3
  24. package/dist/{chunk-ARZHJFVG.js → chunk-UHAFIPSL.js} +6 -6
  25. package/dist/{chunk-Q56I5ONX.mjs → chunk-UHSRHP55.mjs} +1 -22
  26. package/dist/chunk-UHSRHP55.mjs.map +1 -0
  27. package/dist/{chunk-SFFTNB2X.mjs → chunk-VGFPVAKX.mjs} +2 -2
  28. package/dist/{chunk-S3RZBMF7.js → chunk-VKWOHNDO.js} +214 -284
  29. package/dist/chunk-VKWOHNDO.js.map +1 -0
  30. package/dist/{chunk-LTPS73D7.mjs → chunk-X4XSEYPL.mjs} +3 -3
  31. package/dist/{chunk-T3GOPPVF.mjs → chunk-XTMJ25EF.mjs} +195 -265
  32. package/dist/chunk-XTMJ25EF.mjs.map +1 -0
  33. package/dist/{chunk-76FONEDA.js → chunk-YWLMT7XH.js} +4 -4
  34. package/dist/errors.js +1 -1
  35. package/dist/errors.mjs +1 -1
  36. package/dist/gas-flows/DefaultGasFeeFlow.js +7 -7
  37. package/dist/gas-flows/DefaultGasFeeFlow.mjs +6 -6
  38. package/dist/gas-flows/LineaGasFeeFlow.js +8 -8
  39. package/dist/gas-flows/LineaGasFeeFlow.mjs +7 -7
  40. package/dist/gas-flows/TestGasFeeFlow.js +1 -1
  41. package/dist/gas-flows/TestGasFeeFlow.mjs +1 -1
  42. package/dist/helpers/EtherscanRemoteTransactionSource.js +1 -1
  43. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +1 -1
  44. package/dist/helpers/GasFeePoller.js +4 -4
  45. package/dist/helpers/GasFeePoller.mjs +3 -3
  46. package/dist/helpers/MultichainTrackingHelper.js +1 -1
  47. package/dist/helpers/MultichainTrackingHelper.mjs +1 -1
  48. package/dist/helpers/PendingTransactionTracker.js +1 -1
  49. package/dist/helpers/PendingTransactionTracker.mjs +1 -1
  50. package/dist/index.js +12 -11
  51. package/dist/index.mjs +11 -10
  52. package/dist/tsconfig.build.tsbuildinfo +1 -1
  53. package/dist/types/TransactionController.d.ts +8 -10
  54. package/dist/types/TransactionController.d.ts.map +1 -1
  55. package/dist/types/index.d.ts +2 -2
  56. package/dist/types/index.d.ts.map +1 -1
  57. package/dist/types/types.d.ts +40 -0
  58. package/dist/types/types.d.ts.map +1 -1
  59. package/dist/types/utils/retry.d.ts +11 -0
  60. package/dist/types/utils/retry.d.ts.map +1 -0
  61. package/dist/types/utils/utils.d.ts +1 -15
  62. package/dist/types/utils/utils.d.ts.map +1 -1
  63. package/dist/types.js +2 -2
  64. package/dist/types.mjs +1 -1
  65. package/dist/utils/external-transactions.js +1 -1
  66. package/dist/utils/external-transactions.mjs +1 -1
  67. package/dist/utils/gas-fees.js +6 -6
  68. package/dist/utils/gas-fees.mjs +5 -5
  69. package/dist/utils/gas-flow.js +3 -3
  70. package/dist/utils/gas-flow.mjs +2 -2
  71. package/dist/utils/retry.js +8 -0
  72. package/dist/utils/retry.js.map +1 -0
  73. package/dist/utils/retry.mjs +8 -0
  74. package/dist/utils/retry.mjs.map +1 -0
  75. package/dist/utils/simulation-api.js +1 -1
  76. package/dist/utils/simulation-api.mjs +1 -1
  77. package/dist/utils/simulation.js +1 -1
  78. package/dist/utils/simulation.mjs +1 -1
  79. package/dist/utils/swaps.js +4 -4
  80. package/dist/utils/swaps.mjs +3 -3
  81. package/dist/utils/transaction-type.js +1 -1
  82. package/dist/utils/transaction-type.mjs +1 -1
  83. package/dist/utils/utils.js +3 -13
  84. package/dist/utils/utils.mjs +4 -14
  85. package/dist/utils/validation.js +4 -4
  86. package/dist/utils/validation.mjs +3 -3
  87. package/package.json +6 -5
  88. package/dist/chunk-OZ6UB42C.js.map +0 -1
  89. package/dist/chunk-Q56I5ONX.mjs.map +0 -1
  90. package/dist/chunk-S3RZBMF7.js.map +0 -1
  91. package/dist/chunk-T3GOPPVF.mjs.map +0 -1
  92. /package/dist/{chunk-GPS6RX64.js.map → chunk-4OYPDGHO.js.map} +0 -0
  93. /package/dist/{chunk-2EU6346V.js.map → chunk-5HYWLTVQ.js.map} +0 -0
  94. /package/dist/{chunk-H2KZOK3J.mjs.map → chunk-AWIJZAW3.mjs.map} +0 -0
  95. /package/dist/{chunk-C3WC4OJ3.js.map → chunk-BZV72SCF.js.map} +0 -0
  96. /package/dist/{chunk-QTKXIDGE.js.map → chunk-EHWAY6XU.js.map} +0 -0
  97. /package/dist/{chunk-GNAL5HC2.mjs.map → chunk-JIFPK37W.mjs.map} +0 -0
  98. /package/dist/{chunk-UHG2LLVV.mjs.map → chunk-KYRW4BLA.mjs.map} +0 -0
  99. /package/dist/{chunk-JXXTNVU4.mjs.map → chunk-NNHSNPT2.mjs.map} +0 -0
  100. /package/dist/{chunk-QH2H4W3N.js.map → chunk-QKV7E5BO.js.map} +0 -0
  101. /package/dist/{chunk-VXNPVIYL.mjs.map → chunk-SFFOC25Q.mjs.map} +0 -0
  102. /package/dist/{chunk-ARZHJFVG.js.map → chunk-UHAFIPSL.js.map} +0 -0
  103. /package/dist/{chunk-SFFTNB2X.mjs.map → chunk-VGFPVAKX.mjs.map} +0 -0
  104. /package/dist/{chunk-LTPS73D7.mjs.map → chunk-X4XSEYPL.mjs.map} +0 -0
  105. /package/dist/{chunk-76FONEDA.js.map → chunk-YWLMT7XH.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [35.2.0]
11
+
12
+ ### Added
13
+
14
+ - Add tracing infrastructure ([#4575](https://github.com/MetaMask/core/pull/4575))
15
+ - Add optional `trace` callback to constructor.
16
+ - Add optional `traceContext` option to `addTransaction` method.
17
+ - Add initial tracing of transaction lifecycle.
18
+
19
+ ### Changed
20
+
21
+ - Bump `@metamask/base-controller` from `^6.0.2` to `^6.0.3` ([#4625](https://github.com/MetaMask/core/pull/4625))
22
+ - Bump `@metamask/network-controller` from `^20.1.0` to `^20.2.0` ([#4618](https://github.com/MetaMask/core/pull/4618))
23
+ - Bump `@metamask/eth-json-rpc-provider` from `^4.1.2` to `^4.1.3` ([#4607](https://github.com/MetaMask/core/pull/4607))
24
+
25
+ ### Removed
26
+
27
+ - Remove validation of `gasValues` passed to `speedUpTransaction` and `stopTransaction` methods ([#4617](https://github.com/MetaMask/core/pull/4617))
28
+
10
29
  ## [35.1.1]
11
30
 
12
31
  ### Changed
@@ -959,7 +978,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
959
978
 
960
979
  All changes listed after this point were applied to this package following the monorepo conversion.
961
980
 
962
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@35.1.1...HEAD
981
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@35.2.0...HEAD
982
+ [35.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@35.1.1...@metamask/transaction-controller@35.2.0
963
983
  [35.1.1]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@35.1.0...@metamask/transaction-controller@35.1.1
964
984
  [35.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@35.0.1...@metamask/transaction-controller@35.1.0
965
985
  [35.0.1]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@35.0.0...@metamask/transaction-controller@35.0.1
@@ -4,12 +4,13 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkS3RZBMF7js = require('./chunk-S3RZBMF7.js');
7
+ var _chunkVKWOHNDOjs = require('./chunk-VKWOHNDO.js');
8
8
  require('./chunk-PRUNMTRD.js');
9
+ require('./chunk-5QVDIVJH.js');
9
10
  require('./chunk-NNCUD3QF.js');
10
11
  require('./chunk-KT6UAKBB.js');
11
12
  require('./chunk-SD6CWFDF.js');
12
- require('./chunk-GPS6RX64.js');
13
+ require('./chunk-4OYPDGHO.js');
13
14
  require('./chunk-ULD4JC3Q.js');
14
15
  require('./chunk-7LXE4KHV.js');
15
16
  require('./chunk-V72C4MCR.js');
@@ -18,22 +19,22 @@ require('./chunk-NYKRCWBG.js');
18
19
  require('./chunk-WR5F34OW.js');
19
20
  require('./chunk-YVCX6Z75.js');
20
21
  require('./chunk-TJMQEH57.js');
21
- require('./chunk-2EU6346V.js');
22
+ require('./chunk-5HYWLTVQ.js');
22
23
  require('./chunk-2XKEAKQG.js');
23
24
  require('./chunk-RHDPOIS4.js');
24
25
  require('./chunk-6OLJWLKK.js');
25
26
  require('./chunk-7NMV2NPM.js');
26
27
  require('./chunk-XVYXRCRL.js');
27
28
  require('./chunk-HMOSP33F.js');
28
- require('./chunk-ARZHJFVG.js');
29
- require('./chunk-QTKXIDGE.js');
30
- require('./chunk-C3WC4OJ3.js');
31
- require('./chunk-QH2H4W3N.js');
32
- require('./chunk-OZ6UB42C.js');
33
- require('./chunk-76FONEDA.js');
29
+ require('./chunk-UHAFIPSL.js');
30
+ require('./chunk-EHWAY6XU.js');
31
+ require('./chunk-BZV72SCF.js');
32
+ require('./chunk-QKV7E5BO.js');
33
+ require('./chunk-KTGMNUTQ.js');
34
+ require('./chunk-YWLMT7XH.js');
34
35
  require('./chunk-UGN7PBON.js');
35
36
  require('./chunk-S6VGOPUY.js');
36
- require('./chunk-AYTU4HU5.js');
37
+ require('./chunk-PSZ34BI5.js');
37
38
  require('./chunk-Z4BLTVTB.js');
38
39
 
39
40
 
@@ -41,5 +42,5 @@ require('./chunk-Z4BLTVTB.js');
41
42
 
42
43
 
43
44
 
44
- exports.ApprovalState = _chunkS3RZBMF7js.ApprovalState; exports.CANCEL_RATE = _chunkS3RZBMF7js.CANCEL_RATE; exports.HARDFORK = _chunkS3RZBMF7js.HARDFORK; exports.SPEED_UP_RATE = _chunkS3RZBMF7js.SPEED_UP_RATE; exports.TransactionController = _chunkS3RZBMF7js.TransactionController;
45
+ exports.ApprovalState = _chunkVKWOHNDOjs.ApprovalState; exports.CANCEL_RATE = _chunkVKWOHNDOjs.CANCEL_RATE; exports.HARDFORK = _chunkVKWOHNDOjs.HARDFORK; exports.SPEED_UP_RATE = _chunkVKWOHNDOjs.SPEED_UP_RATE; exports.TransactionController = _chunkVKWOHNDOjs.TransactionController;
45
46
  //# sourceMappingURL=TransactionController.js.map
@@ -4,12 +4,13 @@ import {
4
4
  HARDFORK,
5
5
  SPEED_UP_RATE,
6
6
  TransactionController
7
- } from "./chunk-T3GOPPVF.mjs";
7
+ } from "./chunk-XTMJ25EF.mjs";
8
8
  import "./chunk-6DDVVUJC.mjs";
9
+ import "./chunk-JOQK7A5G.mjs";
9
10
  import "./chunk-3AVRGHUO.mjs";
10
11
  import "./chunk-K4KOSAGM.mjs";
11
12
  import "./chunk-KG4UW4K4.mjs";
12
- import "./chunk-LTPS73D7.mjs";
13
+ import "./chunk-X4XSEYPL.mjs";
13
14
  import "./chunk-6B5BEO3R.mjs";
14
15
  import "./chunk-FRKQ3Z2L.mjs";
15
16
  import "./chunk-5G6OHAXI.mjs";
@@ -18,22 +19,22 @@ import "./chunk-VEVVBHP3.mjs";
18
19
  import "./chunk-Z4GV3YQQ.mjs";
19
20
  import "./chunk-FG74Z3F5.mjs";
20
21
  import "./chunk-FMRLPVFZ.mjs";
21
- import "./chunk-SFFTNB2X.mjs";
22
+ import "./chunk-VGFPVAKX.mjs";
22
23
  import "./chunk-NOHEXQ7Y.mjs";
23
24
  import "./chunk-3ZV5YEUV.mjs";
24
25
  import "./chunk-4V4XIPCI.mjs";
25
26
  import "./chunk-EKJXGERC.mjs";
26
27
  import "./chunk-EGQCE3FK.mjs";
27
28
  import "./chunk-HQSNKCXI.mjs";
28
- import "./chunk-UHG2LLVV.mjs";
29
- import "./chunk-H2KZOK3J.mjs";
30
- import "./chunk-VXNPVIYL.mjs";
31
- import "./chunk-GNAL5HC2.mjs";
32
- import "./chunk-Q56I5ONX.mjs";
33
- import "./chunk-JXXTNVU4.mjs";
29
+ import "./chunk-KYRW4BLA.mjs";
30
+ import "./chunk-AWIJZAW3.mjs";
31
+ import "./chunk-SFFOC25Q.mjs";
32
+ import "./chunk-JIFPK37W.mjs";
33
+ import "./chunk-UHSRHP55.mjs";
34
+ import "./chunk-NNHSNPT2.mjs";
34
35
  import "./chunk-O6ZZVIFH.mjs";
35
36
  import "./chunk-UQQWZT6C.mjs";
36
- import "./chunk-6SJYXSF3.mjs";
37
+ import "./chunk-LFFYCDHB.mjs";
37
38
  import "./chunk-XUI43LEZ.mjs";
38
39
  export {
39
40
  ApprovalState,
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkOZ6UB42Cjs = require('./chunk-OZ6UB42C.js');
3
+ var _chunkKTGMNUTQjs = require('./chunk-KTGMNUTQ.js');
4
4
 
5
5
 
6
- var _chunkAYTU4HU5js = require('./chunk-AYTU4HU5.js');
6
+ var _chunkPSZ34BI5js = require('./chunk-PSZ34BI5.js');
7
7
 
8
8
  // src/utils/validation.ts
9
9
  var _abi = require('@ethersproject/abi');
@@ -39,18 +39,18 @@ function validateTxParams(txParams, isEIP1559Compatible = true) {
39
39
  validateGasFeeParams(txParams);
40
40
  }
41
41
  function validateEnvelopeType(type) {
42
- if (type && !Object.values(_chunkAYTU4HU5js.TransactionEnvelopeType).includes(
42
+ if (type && !Object.values(_chunkPSZ34BI5js.TransactionEnvelopeType).includes(
43
43
  type
44
44
  )) {
45
45
  throw _rpcerrors.rpcErrors.invalidParams(
46
46
  `Invalid transaction envelope type: "${type}". Must be one of: ${Object.values(
47
- _chunkAYTU4HU5js.TransactionEnvelopeType
47
+ _chunkPSZ34BI5js.TransactionEnvelopeType
48
48
  ).join(", ")}`
49
49
  );
50
50
  }
51
51
  }
52
52
  function validateEIP1559Compatibility(txParams, isEIP1559Compatible) {
53
- if (_chunkOZ6UB42Cjs.isEIP1559Transaction.call(void 0, txParams) && !isEIP1559Compatible) {
53
+ if (_chunkKTGMNUTQjs.isEIP1559Transaction.call(void 0, txParams) && !isEIP1559Compatible) {
54
54
  throw _rpcerrors.rpcErrors.invalidParams(
55
55
  "Invalid transaction params: params specify an EIP-1559 transaction but the current network does not support EIP-1559"
56
56
  );
@@ -198,4 +198,4 @@ function ensureFieldIsString(txParams, field) {
198
198
 
199
199
 
200
200
  exports.validateTransactionOrigin = validateTransactionOrigin; exports.validateTxParams = validateTxParams;
201
- //# sourceMappingURL=chunk-GPS6RX64.js.map
201
+ //# sourceMappingURL=chunk-4OYPDGHO.js.map
@@ -3,7 +3,7 @@
3
3
  var _chunk2XKEAKQGjs = require('./chunk-2XKEAKQG.js');
4
4
 
5
5
 
6
- var _chunk76FONEDAjs = require('./chunk-76FONEDA.js');
6
+ var _chunkYWLMT7XHjs = require('./chunk-YWLMT7XH.js');
7
7
 
8
8
 
9
9
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
@@ -148,7 +148,7 @@ _updateTransactionGasFeeEstimates = new WeakSet();
148
148
  updateTransactionGasFeeEstimates_fn = async function(transactionMeta, gasFeeControllerData) {
149
149
  const { chainId, networkClientId } = transactionMeta;
150
150
  const ethQuery = new (0, _ethquery2.default)(_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getProvider).call(this, chainId, networkClientId));
151
- const gasFeeFlow = _chunk76FONEDAjs.getGasFeeFlow.call(void 0, transactionMeta, _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _gasFeeFlows));
151
+ const gasFeeFlow = _chunkYWLMT7XHjs.getGasFeeFlow.call(void 0, transactionMeta, _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _gasFeeFlows));
152
152
  if (gasFeeFlow) {
153
153
  log(
154
154
  "Found gas fee flow",
@@ -225,4 +225,4 @@ getGasFeeControllerData_fn = async function(transactions) {
225
225
 
226
226
 
227
227
  exports.GasFeePoller = GasFeePoller;
228
- //# sourceMappingURL=chunk-2EU6346V.js.map
228
+ //# sourceMappingURL=chunk-5HYWLTVQ.js.map
@@ -0,0 +1,68 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/retry.ts
2
+ var _controllerutils = require('@metamask/controller-utils');
3
+ var _utils = require('@metamask/utils');
4
+ function getTransactionParamsWithIncreasedGasFee(originalTransactionParams, rate, newGasValues) {
5
+ const newGasPrice = getIncreasedGasPrice(
6
+ originalTransactionParams,
7
+ rate,
8
+ newGasValues
9
+ );
10
+ const new1559Values = getIncreased1559Values(
11
+ originalTransactionParams,
12
+ rate,
13
+ newGasValues
14
+ );
15
+ if (new1559Values) {
16
+ const newTxParams = {
17
+ ...originalTransactionParams,
18
+ ...new1559Values
19
+ };
20
+ delete newTxParams.gasPrice;
21
+ return newTxParams;
22
+ }
23
+ if (newGasPrice) {
24
+ const newTxParams = {
25
+ ...originalTransactionParams,
26
+ gasPrice: newGasPrice
27
+ };
28
+ delete newTxParams.maxFeePerGas;
29
+ delete newTxParams.maxPriorityFeePerGas;
30
+ return newTxParams;
31
+ }
32
+ throw new Error(
33
+ "Cannot increase gas fee as no current values and no new values were provided"
34
+ );
35
+ }
36
+ function getIncreased1559Values(originalTransactionParams, rate, newGasValues) {
37
+ if (newGasValues && "maxFeePerGas" in newGasValues && "maxPriorityFeePerGas" in newGasValues) {
38
+ return newGasValues;
39
+ }
40
+ const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas;
41
+ const currentMaxPriorityFeePerGas = originalTransactionParams.maxPriorityFeePerGas;
42
+ if (!currentMaxFeePerGas || !currentMaxPriorityFeePerGas || currentMaxFeePerGas === "0x0" || currentMaxPriorityFeePerGas === "0x0") {
43
+ return void 0;
44
+ }
45
+ const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);
46
+ const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);
47
+ return { maxFeePerGas, maxPriorityFeePerGas };
48
+ }
49
+ function getIncreasedGasPrice(originalTransactionParams, rate, newGasValues) {
50
+ if (newGasValues && "gasPrice" in newGasValues) {
51
+ return newGasValues.gasPrice;
52
+ }
53
+ const currentGasPrice = originalTransactionParams.gasPrice;
54
+ if (!currentGasPrice || currentGasPrice === "0x0") {
55
+ return void 0;
56
+ }
57
+ return multiplyHex(currentGasPrice, rate);
58
+ }
59
+ function multiplyHex(value, multiplier) {
60
+ const decimalValue = _controllerutils.convertHexToDecimal.call(void 0, value);
61
+ const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);
62
+ return _utils.add0x.call(void 0, decimalResult.toString(16));
63
+ }
64
+
65
+
66
+
67
+ exports.getTransactionParamsWithIncreasedGasFee = getTransactionParamsWithIncreasedGasFee;
68
+ //# sourceMappingURL=chunk-5QVDIVJH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/retry.ts"],"names":[],"mappings":";AAAA,SAAS,2BAA2B;AAEpC,SAAS,aAAa;AAYf,SAAS,wCACd,2BACA,MACA,cACmB;AACnB,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,eAAe;AACjB,UAAM,cAAiC;AAAA,MACrC,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAEA,WAAO,YAAY;AAEnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa;AACf,UAAM,cAAiC;AAAA,MACrC,GAAG;AAAA,MACH,UAAU;AAAA,IACZ;AAEA,WAAO,YAAY;AACnB,WAAO,YAAY;AAEnB,WAAO;AAAA,EACT;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AASA,SAAS,uBACP,2BACA,MACA,cACoC;AACpC,MACE,gBACA,kBAAkB,gBAClB,0BAA0B,cAC1B;AACA,WAAO;AAAA,EACT;AAEA,QAAM,sBAAsB,0BAA0B;AAItD,QAAM,8BACJ,0BAA0B;AAE5B,MACE,CAAC,uBACD,CAAC,+BACD,wBAAwB,SACxB,gCAAgC,OAChC;AACA,WAAO;AAAA,EACT;AAEA,QAAM,eAAe,YAAY,qBAAqB,IAAI;AAC1D,QAAM,uBAAuB,YAAY,6BAA6B,IAAI;AAE1E,SAAO,EAAE,cAAc,qBAAqB;AAC9C;AASA,SAAS,qBACP,2BACA,MACA,cACiB;AACjB,MAAI,gBAAgB,cAAc,cAAc;AAC9C,WAAO,aAAa;AAAA,EACtB;AAEA,QAAM,kBAAkB,0BAA0B;AAElD,MAAI,CAAC,mBAAmB,oBAAoB,OAAO;AACjD,WAAO;AAAA,EACT;AAEA,SAAO,YAAY,iBAAiB,IAAI;AAC1C;AAQA,SAAS,YAAY,OAAwB,YAAyB;AACpE,QAAM,eAAe,oBAAoB,KAAK;AAC9C,QAAM,gBAAgB,SAAS,GAAG,eAAe,UAAU,IAAI,EAAE;AAEjE,SAAO,MAAM,cAAc,SAAS,EAAE,CAAC;AACzC","sourcesContent":["import { convertHexToDecimal } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { add0x } from '@metamask/utils';\n\nimport type { FeeMarketEIP1559Values, GasPriceValue } from '../types';\nimport { type TransactionParams } from '../types';\n\n/**\n * Returns new transaction parameters with increased gas fees.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new transaction parameters with the increased gas fee properties.\n */\nexport function getTransactionParamsWithIncreasedGasFee(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): TransactionParams {\n const newGasPrice = getIncreasedGasPrice(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n const new1559Values = getIncreased1559Values(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n if (new1559Values) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n ...new1559Values,\n };\n\n delete newTxParams.gasPrice;\n\n return newTxParams;\n }\n\n if (newGasPrice) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n gasPrice: newGasPrice,\n };\n\n delete newTxParams.maxFeePerGas;\n delete newTxParams.maxPriorityFeePerGas;\n\n return newTxParams;\n }\n\n throw new Error(\n 'Cannot increase gas fee as no current values and no new values were provided',\n );\n}\n\n/**\n * Generate the increased EIP-1559 gas properties.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new EIP-1559 gas properties.\n */\nfunction getIncreased1559Values(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): FeeMarketEIP1559Values | undefined {\n if (\n newGasValues &&\n 'maxFeePerGas' in newGasValues &&\n 'maxPriorityFeePerGas' in newGasValues\n ) {\n return newGasValues;\n }\n\n const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas as\n | Hex\n | undefined;\n\n const currentMaxPriorityFeePerGas =\n originalTransactionParams.maxPriorityFeePerGas as Hex | undefined;\n\n if (\n !currentMaxFeePerGas ||\n !currentMaxPriorityFeePerGas ||\n currentMaxFeePerGas === '0x0' ||\n currentMaxPriorityFeePerGas === '0x0'\n ) {\n return undefined;\n }\n\n const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);\n const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n}\n\n/**\n * Generate the increased gas price.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new gas price.\n */\nfunction getIncreasedGasPrice(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): Hex | undefined {\n if (newGasValues && 'gasPrice' in newGasValues) {\n return newGasValues.gasPrice as Hex;\n }\n\n const currentGasPrice = originalTransactionParams.gasPrice as Hex | undefined;\n\n if (!currentGasPrice || currentGasPrice === '0x0') {\n return undefined;\n }\n\n return multiplyHex(currentGasPrice, rate);\n}\n\n/**\n * Multiply a hex value by a multiplier.\n * @param value - The hex value to multiply.\n * @param multiplier - The multiplier.\n * @returns The multiplied hex value.\n */\nfunction multiplyHex(value: Hex | undefined, multiplier: number): Hex {\n const decimalValue = convertHexToDecimal(value);\n const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);\n\n return add0x(decimalResult.toString(16));\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  gweiDecimalToWeiHex
3
- } from "./chunk-VXNPVIYL.mjs";
3
+ } from "./chunk-SFFOC25Q.mjs";
4
4
  import {
5
5
  projectLogger
6
6
  } from "./chunk-UQQWZT6C.mjs";
7
7
  import {
8
8
  GasFeeEstimateLevel
9
- } from "./chunk-6SJYXSF3.mjs";
9
+ } from "./chunk-LFFYCDHB.mjs";
10
10
  import {
11
11
  __privateAdd,
12
12
  __privateMethod
@@ -109,4 +109,4 @@ getLegacyLevel_fn = function(gasFeeEstimates, level) {
109
109
  export {
110
110
  DefaultGasFeeFlow
111
111
  };
112
- //# sourceMappingURL=chunk-H2KZOK3J.mjs.map
112
+ //# sourceMappingURL=chunk-AWIJZAW3.mjs.map
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkQH2H4W3Njs = require('./chunk-QH2H4W3N.js');
3
+ var _chunkQKV7E5BOjs = require('./chunk-QKV7E5BO.js');
4
4
 
5
5
 
6
- var _chunk76FONEDAjs = require('./chunk-76FONEDA.js');
6
+ var _chunkYWLMT7XHjs = require('./chunk-YWLMT7XH.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 = _chunkQH2H4W3Njs.SWAP_TRANSACTION_TYPES.includes(
23
+ const isSwap = _chunkQKV7E5BOjs.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 = _chunk76FONEDAjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
189
+ const gasFeeFlow = _chunkYWLMT7XHjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
190
190
  try {
191
191
  const gasFeeControllerData = await getGasFeeEstimates({ networkClientId });
192
192
  const response = await gasFeeFlow.getGasFees({
@@ -223,4 +223,4 @@ async function getSuggestedGasFees(request) {
223
223
 
224
224
 
225
225
  exports.updateGasFees = updateGasFees; exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
226
- //# sourceMappingURL=chunk-C3WC4OJ3.js.map
226
+ //# sourceMappingURL=chunk-BZV72SCF.js.map
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkC3WC4OJ3js = require('./chunk-C3WC4OJ3.js');
3
+ var _chunkBZV72SCFjs = require('./chunk-BZV72SCF.js');
4
4
 
5
5
 
6
6
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
7
7
 
8
8
 
9
- var _chunkAYTU4HU5js = require('./chunk-AYTU4HU5.js');
9
+ var _chunkPSZ34BI5js = require('./chunk-PSZ34BI5.js');
10
10
 
11
11
 
12
12
 
@@ -55,7 +55,7 @@ var DefaultGasFeeFlow = class {
55
55
  };
56
56
  _getFeeMarkEstimates = new WeakSet();
57
57
  getFeeMarkEstimates_fn = function(gasFeeEstimates) {
58
- const levels = Object.values(_chunkAYTU4HU5js.GasFeeEstimateLevel).reduce(
58
+ const levels = Object.values(_chunkPSZ34BI5js.GasFeeEstimateLevel).reduce(
59
59
  (result, level) => ({
60
60
  ...result,
61
61
  [level]: _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getFeeMarketLevel, getFeeMarketLevel_fn).call(this, gasFeeEstimates, level)
@@ -69,7 +69,7 @@ getFeeMarkEstimates_fn = function(gasFeeEstimates) {
69
69
  };
70
70
  _getLegacyEstimates = new WeakSet();
71
71
  getLegacyEstimates_fn = function(gasFeeEstimates) {
72
- const levels = Object.values(_chunkAYTU4HU5js.GasFeeEstimateLevel).reduce(
72
+ const levels = Object.values(_chunkPSZ34BI5js.GasFeeEstimateLevel).reduce(
73
73
  (result, level) => ({
74
74
  ...result,
75
75
  [level]: _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLegacyLevel, getLegacyLevel_fn).call(this, gasFeeEstimates, level)
@@ -85,15 +85,15 @@ _getGasPriceEstimates = new WeakSet();
85
85
  getGasPriceEstimates_fn = function(gasFeeEstimates) {
86
86
  return {
87
87
  type: "eth_gasPrice" /* GasPrice */,
88
- gasPrice: _chunkC3WC4OJ3js.gweiDecimalToWeiHex.call(void 0, gasFeeEstimates.gasPrice)
88
+ gasPrice: _chunkBZV72SCFjs.gweiDecimalToWeiHex.call(void 0, gasFeeEstimates.gasPrice)
89
89
  };
90
90
  };
91
91
  _getFeeMarketLevel = new WeakSet();
92
92
  getFeeMarketLevel_fn = function(gasFeeEstimates, level) {
93
- const maxFeePerGas = _chunkC3WC4OJ3js.gweiDecimalToWeiHex.call(void 0,
93
+ const maxFeePerGas = _chunkBZV72SCFjs.gweiDecimalToWeiHex.call(void 0,
94
94
  gasFeeEstimates[level].suggestedMaxFeePerGas
95
95
  );
96
- const maxPriorityFeePerGas = _chunkC3WC4OJ3js.gweiDecimalToWeiHex.call(void 0,
96
+ const maxPriorityFeePerGas = _chunkBZV72SCFjs.gweiDecimalToWeiHex.call(void 0,
97
97
  gasFeeEstimates[level].suggestedMaxPriorityFeePerGas
98
98
  );
99
99
  return {
@@ -103,10 +103,10 @@ getFeeMarketLevel_fn = function(gasFeeEstimates, level) {
103
103
  };
104
104
  _getLegacyLevel = new WeakSet();
105
105
  getLegacyLevel_fn = function(gasFeeEstimates, level) {
106
- return _chunkC3WC4OJ3js.gweiDecimalToWeiHex.call(void 0, gasFeeEstimates[level]);
106
+ return _chunkBZV72SCFjs.gweiDecimalToWeiHex.call(void 0, gasFeeEstimates[level]);
107
107
  };
108
108
 
109
109
 
110
110
 
111
111
  exports.DefaultGasFeeFlow = DefaultGasFeeFlow;
112
- //# sourceMappingURL=chunk-QTKXIDGE.js.map
112
+ //# sourceMappingURL=chunk-EHWAY6XU.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  validateIfTransactionUnapproved
3
- } from "./chunk-Q56I5ONX.mjs";
3
+ } from "./chunk-UHSRHP55.mjs";
4
4
  import {
5
5
  CHAIN_IDS
6
6
  } from "./chunk-O6ZZVIFH.mjs";
@@ -254,4 +254,4 @@ export {
254
254
  updateSwapsTransaction,
255
255
  updatePostTransactionBalance
256
256
  };
257
- //# sourceMappingURL=chunk-GNAL5HC2.mjs.map
257
+ //# sourceMappingURL=chunk-JIFPK37W.mjs.map
@@ -0,0 +1,68 @@
1
+ // src/utils/retry.ts
2
+ import { convertHexToDecimal } from "@metamask/controller-utils";
3
+ import { add0x } from "@metamask/utils";
4
+ function getTransactionParamsWithIncreasedGasFee(originalTransactionParams, rate, newGasValues) {
5
+ const newGasPrice = getIncreasedGasPrice(
6
+ originalTransactionParams,
7
+ rate,
8
+ newGasValues
9
+ );
10
+ const new1559Values = getIncreased1559Values(
11
+ originalTransactionParams,
12
+ rate,
13
+ newGasValues
14
+ );
15
+ if (new1559Values) {
16
+ const newTxParams = {
17
+ ...originalTransactionParams,
18
+ ...new1559Values
19
+ };
20
+ delete newTxParams.gasPrice;
21
+ return newTxParams;
22
+ }
23
+ if (newGasPrice) {
24
+ const newTxParams = {
25
+ ...originalTransactionParams,
26
+ gasPrice: newGasPrice
27
+ };
28
+ delete newTxParams.maxFeePerGas;
29
+ delete newTxParams.maxPriorityFeePerGas;
30
+ return newTxParams;
31
+ }
32
+ throw new Error(
33
+ "Cannot increase gas fee as no current values and no new values were provided"
34
+ );
35
+ }
36
+ function getIncreased1559Values(originalTransactionParams, rate, newGasValues) {
37
+ if (newGasValues && "maxFeePerGas" in newGasValues && "maxPriorityFeePerGas" in newGasValues) {
38
+ return newGasValues;
39
+ }
40
+ const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas;
41
+ const currentMaxPriorityFeePerGas = originalTransactionParams.maxPriorityFeePerGas;
42
+ if (!currentMaxFeePerGas || !currentMaxPriorityFeePerGas || currentMaxFeePerGas === "0x0" || currentMaxPriorityFeePerGas === "0x0") {
43
+ return void 0;
44
+ }
45
+ const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);
46
+ const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);
47
+ return { maxFeePerGas, maxPriorityFeePerGas };
48
+ }
49
+ function getIncreasedGasPrice(originalTransactionParams, rate, newGasValues) {
50
+ if (newGasValues && "gasPrice" in newGasValues) {
51
+ return newGasValues.gasPrice;
52
+ }
53
+ const currentGasPrice = originalTransactionParams.gasPrice;
54
+ if (!currentGasPrice || currentGasPrice === "0x0") {
55
+ return void 0;
56
+ }
57
+ return multiplyHex(currentGasPrice, rate);
58
+ }
59
+ function multiplyHex(value, multiplier) {
60
+ const decimalValue = convertHexToDecimal(value);
61
+ const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);
62
+ return add0x(decimalResult.toString(16));
63
+ }
64
+
65
+ export {
66
+ getTransactionParamsWithIncreasedGasFee
67
+ };
68
+ //# sourceMappingURL=chunk-JOQK7A5G.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/retry.ts"],"sourcesContent":["import { convertHexToDecimal } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { add0x } from '@metamask/utils';\n\nimport type { FeeMarketEIP1559Values, GasPriceValue } from '../types';\nimport { type TransactionParams } from '../types';\n\n/**\n * Returns new transaction parameters with increased gas fees.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new transaction parameters with the increased gas fee properties.\n */\nexport function getTransactionParamsWithIncreasedGasFee(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): TransactionParams {\n const newGasPrice = getIncreasedGasPrice(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n const new1559Values = getIncreased1559Values(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n if (new1559Values) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n ...new1559Values,\n };\n\n delete newTxParams.gasPrice;\n\n return newTxParams;\n }\n\n if (newGasPrice) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n gasPrice: newGasPrice,\n };\n\n delete newTxParams.maxFeePerGas;\n delete newTxParams.maxPriorityFeePerGas;\n\n return newTxParams;\n }\n\n throw new Error(\n 'Cannot increase gas fee as no current values and no new values were provided',\n );\n}\n\n/**\n * Generate the increased EIP-1559 gas properties.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new EIP-1559 gas properties.\n */\nfunction getIncreased1559Values(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): FeeMarketEIP1559Values | undefined {\n if (\n newGasValues &&\n 'maxFeePerGas' in newGasValues &&\n 'maxPriorityFeePerGas' in newGasValues\n ) {\n return newGasValues;\n }\n\n const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas as\n | Hex\n | undefined;\n\n const currentMaxPriorityFeePerGas =\n originalTransactionParams.maxPriorityFeePerGas as Hex | undefined;\n\n if (\n !currentMaxFeePerGas ||\n !currentMaxPriorityFeePerGas ||\n currentMaxFeePerGas === '0x0' ||\n currentMaxPriorityFeePerGas === '0x0'\n ) {\n return undefined;\n }\n\n const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);\n const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n}\n\n/**\n * Generate the increased gas price.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new gas price.\n */\nfunction getIncreasedGasPrice(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): Hex | undefined {\n if (newGasValues && 'gasPrice' in newGasValues) {\n return newGasValues.gasPrice as Hex;\n }\n\n const currentGasPrice = originalTransactionParams.gasPrice as Hex | undefined;\n\n if (!currentGasPrice || currentGasPrice === '0x0') {\n return undefined;\n }\n\n return multiplyHex(currentGasPrice, rate);\n}\n\n/**\n * Multiply a hex value by a multiplier.\n * @param value - The hex value to multiply.\n * @param multiplier - The multiplier.\n * @returns The multiplied hex value.\n */\nfunction multiplyHex(value: Hex | undefined, multiplier: number): Hex {\n const decimalValue = convertHexToDecimal(value);\n const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);\n\n return add0x(decimalResult.toString(16));\n}\n"],"mappings":";AAAA,SAAS,2BAA2B;AAEpC,SAAS,aAAa;AAYf,SAAS,wCACd,2BACA,MACA,cACmB;AACnB,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,eAAe;AACjB,UAAM,cAAiC;AAAA,MACrC,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAEA,WAAO,YAAY;AAEnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa;AACf,UAAM,cAAiC;AAAA,MACrC,GAAG;AAAA,MACH,UAAU;AAAA,IACZ;AAEA,WAAO,YAAY;AACnB,WAAO,YAAY;AAEnB,WAAO;AAAA,EACT;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AASA,SAAS,uBACP,2BACA,MACA,cACoC;AACpC,MACE,gBACA,kBAAkB,gBAClB,0BAA0B,cAC1B;AACA,WAAO;AAAA,EACT;AAEA,QAAM,sBAAsB,0BAA0B;AAItD,QAAM,8BACJ,0BAA0B;AAE5B,MACE,CAAC,uBACD,CAAC,+BACD,wBAAwB,SACxB,gCAAgC,OAChC;AACA,WAAO;AAAA,EACT;AAEA,QAAM,eAAe,YAAY,qBAAqB,IAAI;AAC1D,QAAM,uBAAuB,YAAY,6BAA6B,IAAI;AAE1E,SAAO,EAAE,cAAc,qBAAqB;AAC9C;AASA,SAAS,qBACP,2BACA,MACA,cACiB;AACjB,MAAI,gBAAgB,cAAc,cAAc;AAC9C,WAAO,aAAa;AAAA,EACtB;AAEA,QAAM,kBAAkB,0BAA0B;AAElD,MAAI,CAAC,mBAAmB,oBAAoB,OAAO;AACjD,WAAO;AAAA,EACT;AAEA,SAAO,YAAY,iBAAiB,IAAI;AAC1C;AAQA,SAAS,YAAY,OAAwB,YAAyB;AACpE,QAAM,eAAe,oBAAoB,KAAK;AAC9C,QAAM,gBAAgB,SAAS,GAAG,eAAe,UAAU,IAAI,EAAE;AAEjE,SAAO,MAAM,cAAc,SAAS,EAAE,CAAC;AACzC;","names":[]}
@@ -1,5 +1,4 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/utils.ts
2
- var _controllerutils = require('@metamask/controller-utils');
3
2
 
4
3
 
5
4
 
@@ -48,21 +47,6 @@ var validateGasValues = (gasValues) => {
48
47
  }
49
48
  });
50
49
  };
51
- var isFeeMarketEIP1559Values = (gasValues) => gasValues?.maxFeePerGas !== void 0 || gasValues?.maxPriorityFeePerGas !== void 0;
52
- var isGasPriceValue = (gasValues) => gasValues?.gasPrice !== void 0;
53
- var getIncreasedPriceHex = (value, rate) => _utils.add0x.call(void 0, `${parseInt(`${value * rate}`, 10).toString(16)}`);
54
- var getIncreasedPriceFromExisting = (value, rate) => {
55
- return getIncreasedPriceHex(_controllerutils.convertHexToDecimal.call(void 0, value), rate);
56
- };
57
- function validateMinimumIncrease(proposed, min) {
58
- const proposedDecimal = _controllerutils.convertHexToDecimal.call(void 0, proposed);
59
- const minDecimal = _controllerutils.convertHexToDecimal.call(void 0, min);
60
- if (proposedDecimal >= minDecimal) {
61
- return proposed;
62
- }
63
- const errorMsg = `The proposed value: ${proposedDecimal} should meet or exceed the minimum value: ${minDecimal}`;
64
- throw new Error(errorMsg);
65
- }
66
50
  function validateIfTransactionUnapproved(transactionMeta, fnName) {
67
51
  if (transactionMeta?.status !== "unapproved" /* unapproved */) {
68
52
  throw new Error(
@@ -118,10 +102,5 @@ function padHexToEvenLength(hex) {
118
102
 
119
103
 
120
104
 
121
-
122
-
123
-
124
-
125
-
126
- exports.ESTIMATE_GAS_ERROR = ESTIMATE_GAS_ERROR; exports.normalizeTransactionParams = normalizeTransactionParams; exports.isEIP1559Transaction = isEIP1559Transaction; exports.validateGasValues = validateGasValues; exports.isFeeMarketEIP1559Values = isFeeMarketEIP1559Values; exports.isGasPriceValue = isGasPriceValue; exports.getIncreasedPriceHex = getIncreasedPriceHex; exports.getIncreasedPriceFromExisting = getIncreasedPriceFromExisting; exports.validateMinimumIncrease = validateMinimumIncrease; exports.validateIfTransactionUnapproved = validateIfTransactionUnapproved; exports.normalizeTxError = normalizeTxError; exports.normalizeGasFeeValues = normalizeGasFeeValues; exports.padHexToEvenLength = padHexToEvenLength;
127
- //# sourceMappingURL=chunk-OZ6UB42C.js.map
105
+ exports.ESTIMATE_GAS_ERROR = ESTIMATE_GAS_ERROR; exports.normalizeTransactionParams = normalizeTransactionParams; exports.isEIP1559Transaction = isEIP1559Transaction; exports.validateGasValues = validateGasValues; exports.validateIfTransactionUnapproved = validateIfTransactionUnapproved; exports.normalizeTxError = normalizeTxError; exports.normalizeGasFeeValues = normalizeGasFeeValues; exports.padHexToEvenLength = padHexToEvenLength;
106
+ //# sourceMappingURL=chunk-KTGMNUTQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/utils.ts"],"names":[],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAYA,IAAM,qBAAqB;AAIlC,IAAM,cAA2D;AAAA,EAC/D,MAAM,CAAC,SAAiB,MAAM,mBAAmB,IAAI,CAAC;AAAA,EACtD,MAAM,CAAC,SAAiB,MAAM,IAAI,EAAE,YAAY;AAAA,EAChD,KAAK,CAAC,QAAgB,MAAM,GAAG;AAAA,EAC/B,UAAU,CAAC,QAAgB,MAAM,GAAG;AAAA,EACpC,UAAU,CAAC,aAAqB,MAAM,QAAQ;AAAA,EAC9C,OAAO,CAAC,UAAkB,MAAM,KAAK;AAAA,EACrC,IAAI,CAAC,OAAe,MAAM,EAAE,EAAE,YAAY;AAAA,EAC1C,OAAO,CAAC,UAAkB,MAAM,KAAK;AAAA,EACrC,cAAc,CAAC,iBAAyB,MAAM,YAAY;AAAA,EAC1D,sBAAsB,CAAC,yBACrB,MAAM,oBAAoB;AAAA,EAC5B,kBAAkB,CAAC,yBACjB,MAAM,oBAAoB;AAAA,EAC5B,MAAM,CAAC,SAAiB,MAAM,IAAI;AACpC;AAQO,SAAS,2BAA2B,UAA6B;AACtE,QAAM,qBAAwC,EAAE,MAAM,GAAG;AAEzD,aAAW,OAAO,sBAAsB,WAAW,GAAG;AACpD,QAAI,SAAS,GAAG,GAAG;AACjB,yBAAmB,GAAG,IAAI,YAAY,GAAG,EAAE,SAAS,GAAG,CAAC;AAAA,IAC1D;AAAA,EACF;AAEA,MAAI,CAAC,mBAAmB,OAAO;AAC7B,uBAAmB,QAAQ;AAAA,EAC7B;AAEA,SAAO;AACT;AASO,SAAS,qBAAqB,UAAsC;AACzE,QAAM,aAAa,CAAC,KAAwB,QAC1C,OAAO,UAAU,eAAe,KAAK,KAAK,GAAG;AAC/C,SACE,WAAW,UAAU,cAAc,KACnC,WAAW,UAAU,sBAAsB;AAE/C;AAEO,IAAM,oBAAoB,CAC/B,cACG;AACH,SAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,QAAQ;AAGtC,UAAM,QAAS,UAAkB,GAAG;AACpC,QAAI,OAAO,UAAU,YAAY,CAAC,kBAAkB,KAAK,GAAG;AAC1D,YAAM,IAAI;AAAA;AAAA;AAAA,QAGR,2BAA2B,GAAG,kBAAkB,KAAK;AAAA,MACvD;AAAA,IACF;AAAA,EACF,CAAC;AACH;AASO,SAAS,gCACd,iBACA,QACA;AACA,MAAI,iBAAiB,0CAAyC;AAC5D,UAAM,IAAI;AAAA;AAAA;AAAA,MAGR,yCAAyC,MAAM;AAAA,2BAA4D,iBAAiB,MAAM;AAAA,IACpI;AAAA,EACF;AACF;AAQO,SAAS,iBACd,OACkB;AAClB,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM;AAAA,IACf,OAAO,MAAM;AAAA,IACb,MAAM,MAAM;AAAA,IACZ,KAAK,iBAAiB,MAAM,KAAK,IAAI,MAAM,QAAQ;AAAA,EACrD;AACF;AAQO,SAAS,sBACd,cACwC;AAGxC,QAAM,YAAY,CAAC,UACjB,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;AAE7C,MAAI,cAAc,cAAc;AAC9B,WAAO;AAAA,MACL,UAAU,UAAU,aAAa,QAAQ;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO;AAAA,IACL,cAAc,UAAU,aAAa,YAAY;AAAA,IACjD,sBAAsB,UAAU,aAAa,oBAAoB;AAAA,EACnE;AACF;AAQA,SAAS,iBAAiB,OAA+B;AACvD,MAAI;AACF,SAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AAChC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AASO,SAAS,mBAAmB,KAAa;AAC9C,QAAM,SAAS,IAAI,YAAY,EAAE,WAAW,IAAI,IAAI,IAAI,MAAM,GAAG,CAAC,IAAI;AACtE,QAAM,OAAO,SAAS,IAAI,MAAM,CAAC,IAAI;AACrC,QAAM,WAAW,KAAK,SAAS,MAAM,IAAI,OAAO,IAAI,IAAI;AAExD,SAAO,SAAS;AAClB","sourcesContent":["import {\n add0x,\n getKnownPropertyNames,\n isStrictHexString,\n} from '@metamask/utils';\nimport type { Json } from '@metamask/utils';\n\nimport { TransactionStatus } from '../types';\nimport type {\n TransactionParams,\n TransactionMeta,\n TransactionError,\n GasPriceValue,\n FeeMarketEIP1559Values,\n} from '../types';\n\nexport const ESTIMATE_GAS_ERROR = 'eth_estimateGas rpc method error';\n\n// TODO: Replace `any` with type\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst NORMALIZERS: { [param in keyof TransactionParams]: any } = {\n data: (data: string) => add0x(padHexToEvenLength(data)),\n from: (from: string) => add0x(from).toLowerCase(),\n gas: (gas: string) => add0x(gas),\n gasLimit: (gas: string) => add0x(gas),\n gasPrice: (gasPrice: string) => add0x(gasPrice),\n nonce: (nonce: string) => add0x(nonce),\n to: (to: string) => add0x(to).toLowerCase(),\n value: (value: string) => add0x(value),\n maxFeePerGas: (maxFeePerGas: string) => add0x(maxFeePerGas),\n maxPriorityFeePerGas: (maxPriorityFeePerGas: string) =>\n add0x(maxPriorityFeePerGas),\n estimatedBaseFee: (maxPriorityFeePerGas: string) =>\n add0x(maxPriorityFeePerGas),\n type: (type: string) => add0x(type),\n};\n\n/**\n * Normalizes properties on transaction params.\n *\n * @param txParams - The transaction params to normalize.\n * @returns Normalized transaction params.\n */\nexport function normalizeTransactionParams(txParams: TransactionParams) {\n const normalizedTxParams: TransactionParams = { from: '' };\n\n for (const key of getKnownPropertyNames(NORMALIZERS)) {\n if (txParams[key]) {\n normalizedTxParams[key] = NORMALIZERS[key](txParams[key]);\n }\n }\n\n if (!normalizedTxParams.value) {\n normalizedTxParams.value = '0x0';\n }\n\n return normalizedTxParams;\n}\n\n/**\n * Checks if a transaction is EIP-1559 by checking for the existence of\n * maxFeePerGas and maxPriorityFeePerGas within its parameters.\n *\n * @param txParams - Transaction params object to add.\n * @returns Boolean that is true if the transaction is EIP-1559 (has maxFeePerGas and maxPriorityFeePerGas), otherwise returns false.\n */\nexport function isEIP1559Transaction(txParams: TransactionParams): boolean {\n const hasOwnProp = (obj: TransactionParams, key: string) =>\n Object.prototype.hasOwnProperty.call(obj, key);\n return (\n hasOwnProp(txParams, 'maxFeePerGas') &&\n hasOwnProp(txParams, 'maxPriorityFeePerGas')\n );\n}\n\nexport const validateGasValues = (\n gasValues: GasPriceValue | FeeMarketEIP1559Values,\n) => {\n Object.keys(gasValues).forEach((key) => {\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const value = (gasValues as any)[key];\n if (typeof value !== 'string' || !isStrictHexString(value)) {\n throw new TypeError(\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 `expected hex string for ${key} but received: ${value}`,\n );\n }\n });\n};\n\n/**\n * Validates that a transaction is unapproved.\n * Throws if the transaction is not unapproved.\n *\n * @param transactionMeta - The transaction metadata to check.\n * @param fnName - The name of the function calling this helper.\n */\nexport function validateIfTransactionUnapproved(\n transactionMeta: TransactionMeta | undefined,\n fnName: string,\n) {\n if (transactionMeta?.status !== TransactionStatus.unapproved) {\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 `TransactionsController: Can only call ${fnName} on an unapproved transaction.\\n Current tx status: ${transactionMeta?.status}`,\n );\n }\n}\n\n/**\n * Normalizes properties on transaction params.\n *\n * @param error - The error to be normalize.\n * @returns Normalized transaction error.\n */\nexport function normalizeTxError(\n error: Error & { code?: string; value?: unknown },\n): TransactionError {\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n code: error.code,\n rpc: isJsonCompatible(error.value) ? error.value : undefined,\n };\n}\n\n/**\n * Normalize an object containing gas fee values.\n *\n * @param gasFeeValues - An object containing gas fee values.\n * @returns An object containing normalized gas fee values.\n */\nexport function normalizeGasFeeValues(\n gasFeeValues: GasPriceValue | FeeMarketEIP1559Values,\n): GasPriceValue | FeeMarketEIP1559Values {\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const normalize = (value: any) =>\n typeof value === 'string' ? add0x(value) : value;\n\n if ('gasPrice' in gasFeeValues) {\n return {\n gasPrice: normalize(gasFeeValues.gasPrice),\n };\n }\n\n return {\n maxFeePerGas: normalize(gasFeeValues.maxFeePerGas),\n maxPriorityFeePerGas: normalize(gasFeeValues.maxPriorityFeePerGas),\n };\n}\n\n/**\n * Determines whether the given value can be encoded as JSON.\n *\n * @param value - The value.\n * @returns True if the value is JSON-encodable, false if not.\n */\nfunction isJsonCompatible(value: unknown): value is Json {\n try {\n JSON.parse(JSON.stringify(value));\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Ensure a hex string is of even length by adding a leading 0 if necessary.\n * Any existing `0x` prefix is preserved but is not added if missing.\n *\n * @param hex - The hex string to ensure is even.\n * @returns The hex string with an even length.\n */\nexport function padHexToEvenLength(hex: string) {\n const prefix = hex.toLowerCase().startsWith('0x') ? hex.slice(0, 2) : '';\n const data = prefix ? hex.slice(2) : hex;\n const evenData = data.length % 2 === 0 ? data : `0${data}`;\n\n return prefix + evenData;\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  DefaultGasFeeFlow
3
- } from "./chunk-H2KZOK3J.mjs";
3
+ } from "./chunk-AWIJZAW3.mjs";
4
4
  import {
5
5
  projectLogger
6
6
  } from "./chunk-UQQWZT6C.mjs";
7
7
  import {
8
8
  GasFeeEstimateLevel
9
- } from "./chunk-6SJYXSF3.mjs";
9
+ } from "./chunk-LFFYCDHB.mjs";
10
10
  import {
11
11
  __privateAdd,
12
12
  __privateMethod
@@ -118,4 +118,4 @@ feesToString_fn = function(fees) {
118
118
  export {
119
119
  LineaGasFeeFlow
120
120
  };
121
- //# sourceMappingURL=chunk-UHG2LLVV.mjs.map
121
+ //# sourceMappingURL=chunk-KYRW4BLA.mjs.map
@@ -89,4 +89,4 @@ export {
89
89
  SimulationTokenStandard,
90
90
  SimulationErrorCode
91
91
  };
92
- //# sourceMappingURL=chunk-6SJYXSF3.mjs.map
92
+ //# sourceMappingURL=chunk-LFFYCDHB.mjs.map