@metamask/transaction-controller 27.0.0 → 27.0.1

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 (85) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/TransactionController.js +13 -13
  3. package/dist/TransactionController.mjs +12 -12
  4. package/dist/{chunk-7HNSDVVO.mjs → chunk-2XFBWPHD.mjs} +2 -2
  5. package/dist/{chunk-C3UHJPYJ.js → chunk-3JEUO765.js} +6 -6
  6. package/dist/{chunk-V5X6MZHN.js → chunk-3VF7ZGRV.js} +126 -63
  7. package/dist/chunk-3VF7ZGRV.js.map +1 -0
  8. package/dist/{chunk-DTMKGTYC.mjs → chunk-4VLQV2GA.mjs} +48 -2
  9. package/dist/chunk-4VLQV2GA.mjs.map +1 -0
  10. package/dist/{chunk-JW6P2G5A.mjs → chunk-53IYIDVS.mjs} +2 -2
  11. package/dist/{chunk-YS23EOJX.js → chunk-5SKCGFUC.js} +22 -22
  12. package/dist/{chunk-GRQB2ARK.js → chunk-AO3AE3L7.js} +3 -3
  13. package/dist/{chunk-I7VD6IET.js → chunk-CPYXP2OC.js} +3 -3
  14. package/dist/{chunk-KKCD5UMP.mjs → chunk-CWWZQZVR.mjs} +2 -2
  15. package/dist/{chunk-RIYIJTEU.mjs → chunk-DOX6H5UJ.mjs} +2 -2
  16. package/dist/{chunk-HLG525BC.mjs → chunk-DRSMLO7B.mjs} +2 -2
  17. package/dist/{chunk-QG2WVQE3.js → chunk-ETMW527M.js} +9 -9
  18. package/dist/{chunk-VP2DBWOT.js → chunk-F247MMTE.js} +3 -3
  19. package/dist/{chunk-H7O3Y7EQ.mjs → chunk-JDLNCMGI.mjs} +10 -10
  20. package/dist/{chunk-UUSYJGGQ.js → chunk-L337FYVS.js} +3 -3
  21. package/dist/{chunk-A4P4B3OF.mjs → chunk-L7ZKSKEI.mjs} +125 -62
  22. package/dist/chunk-L7ZKSKEI.mjs.map +1 -0
  23. package/dist/{chunk-WIZVJM2B.js → chunk-LQS2M5QR.js} +48 -2
  24. package/dist/chunk-LQS2M5QR.js.map +1 -0
  25. package/dist/{chunk-6V2LR6JL.js → chunk-LYD4TEKH.js} +5 -5
  26. package/dist/{chunk-TZEAWUXE.mjs → chunk-P74YLPJO.mjs} +2 -2
  27. package/dist/{chunk-TJXPMOA6.mjs → chunk-RBF6CW7D.mjs} +2 -2
  28. package/dist/{chunk-FTB6MCSH.mjs → chunk-RXRJSBSF.mjs} +2 -2
  29. package/dist/{chunk-RU6NJIUD.mjs → chunk-TKWTUPCQ.mjs} +3 -3
  30. package/dist/{chunk-XZILQVNW.js → chunk-UBXRAA6G.js} +3 -3
  31. package/dist/{chunk-QTQSCTQA.js → chunk-WLCFETHR.js} +10 -10
  32. package/dist/constants.js +6 -2
  33. package/dist/constants.mjs +5 -1
  34. package/dist/gas-flows/DefaultGasFeeFlow.js +5 -5
  35. package/dist/gas-flows/DefaultGasFeeFlow.mjs +4 -4
  36. package/dist/gas-flows/LineaGasFeeFlow.js +6 -6
  37. package/dist/gas-flows/LineaGasFeeFlow.mjs +5 -5
  38. package/dist/gas-flows/OptimismLayer1GasFeeFlow.js +3 -3
  39. package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +2 -2
  40. package/dist/helpers/EtherscanRemoteTransactionSource.js +4 -4
  41. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +3 -3
  42. package/dist/helpers/MultichainTrackingHelper.js +5 -5
  43. package/dist/helpers/MultichainTrackingHelper.mjs +4 -4
  44. package/dist/index.js +13 -13
  45. package/dist/index.mjs +12 -12
  46. package/dist/tsconfig.build.tsbuildinfo +1 -1
  47. package/dist/types/constants.d.ts +22 -0
  48. package/dist/types/constants.d.ts.map +1 -1
  49. package/dist/types/utils/simulation.d.ts +7 -0
  50. package/dist/types/utils/simulation.d.ts.map +1 -1
  51. package/dist/utils/etherscan.js +3 -3
  52. package/dist/utils/etherscan.mjs +2 -2
  53. package/dist/utils/gas-fees.js +4 -4
  54. package/dist/utils/gas-fees.mjs +3 -3
  55. package/dist/utils/gas.js +3 -3
  56. package/dist/utils/gas.mjs +2 -2
  57. package/dist/utils/simulation.js +5 -2
  58. package/dist/utils/simulation.mjs +4 -1
  59. package/dist/utils/swaps.js +3 -3
  60. package/dist/utils/swaps.mjs +2 -2
  61. package/package.json +1 -1
  62. package/dist/chunk-A4P4B3OF.mjs.map +0 -1
  63. package/dist/chunk-DTMKGTYC.mjs.map +0 -1
  64. package/dist/chunk-V5X6MZHN.js.map +0 -1
  65. package/dist/chunk-WIZVJM2B.js.map +0 -1
  66. /package/dist/{chunk-7HNSDVVO.mjs.map → chunk-2XFBWPHD.mjs.map} +0 -0
  67. /package/dist/{chunk-C3UHJPYJ.js.map → chunk-3JEUO765.js.map} +0 -0
  68. /package/dist/{chunk-JW6P2G5A.mjs.map → chunk-53IYIDVS.mjs.map} +0 -0
  69. /package/dist/{chunk-YS23EOJX.js.map → chunk-5SKCGFUC.js.map} +0 -0
  70. /package/dist/{chunk-GRQB2ARK.js.map → chunk-AO3AE3L7.js.map} +0 -0
  71. /package/dist/{chunk-I7VD6IET.js.map → chunk-CPYXP2OC.js.map} +0 -0
  72. /package/dist/{chunk-KKCD5UMP.mjs.map → chunk-CWWZQZVR.mjs.map} +0 -0
  73. /package/dist/{chunk-RIYIJTEU.mjs.map → chunk-DOX6H5UJ.mjs.map} +0 -0
  74. /package/dist/{chunk-HLG525BC.mjs.map → chunk-DRSMLO7B.mjs.map} +0 -0
  75. /package/dist/{chunk-QG2WVQE3.js.map → chunk-ETMW527M.js.map} +0 -0
  76. /package/dist/{chunk-VP2DBWOT.js.map → chunk-F247MMTE.js.map} +0 -0
  77. /package/dist/{chunk-H7O3Y7EQ.mjs.map → chunk-JDLNCMGI.mjs.map} +0 -0
  78. /package/dist/{chunk-UUSYJGGQ.js.map → chunk-L337FYVS.js.map} +0 -0
  79. /package/dist/{chunk-6V2LR6JL.js.map → chunk-LYD4TEKH.js.map} +0 -0
  80. /package/dist/{chunk-TZEAWUXE.mjs.map → chunk-P74YLPJO.mjs.map} +0 -0
  81. /package/dist/{chunk-TJXPMOA6.mjs.map → chunk-RBF6CW7D.mjs.map} +0 -0
  82. /package/dist/{chunk-FTB6MCSH.mjs.map → chunk-RXRJSBSF.mjs.map} +0 -0
  83. /package/dist/{chunk-RU6NJIUD.mjs.map → chunk-TKWTUPCQ.mjs.map} +0 -0
  84. /package/dist/{chunk-XZILQVNW.js.map → chunk-UBXRAA6G.js.map} +0 -0
  85. /package/dist/{chunk-QTQSCTQA.js.map → chunk-WLCFETHR.js.map} +0 -0
@@ -9,7 +9,7 @@ var _chunkVH47Q6TSjs = require('./chunk-VH47Q6TS.js');
9
9
 
10
10
 
11
11
 
12
- var _chunkGRQB2ARKjs = require('./chunk-GRQB2ARK.js');
12
+ var _chunkAO3AE3L7js = require('./chunk-AO3AE3L7.js');
13
13
 
14
14
 
15
15
 
@@ -20,10 +20,10 @@ var _chunkQP75SWIQjs = require('./chunk-QP75SWIQ.js');
20
20
  var _chunkZNZEJDOEjs = require('./chunk-ZNZEJDOE.js');
21
21
 
22
22
 
23
- var _chunkV5X6MZHNjs = require('./chunk-V5X6MZHN.js');
23
+ var _chunk3VF7ZGRVjs = require('./chunk-3VF7ZGRV.js');
24
24
 
25
25
 
26
- var _chunkQG2WVQE3js = require('./chunk-QG2WVQE3.js');
26
+ var _chunkETMW527Mjs = require('./chunk-ETMW527M.js');
27
27
 
28
28
 
29
29
  var _chunkHUVOOFOMjs = require('./chunk-HUVOOFOM.js');
@@ -36,10 +36,10 @@ var _chunk5WFLNKCLjs = require('./chunk-5WFLNKCL.js');
36
36
  var _chunkDTDTOMTBjs = require('./chunk-DTDTOMTB.js');
37
37
 
38
38
 
39
- var _chunkI7VD6IETjs = require('./chunk-I7VD6IET.js');
39
+ var _chunkCPYXP2OCjs = require('./chunk-CPYXP2OC.js');
40
40
 
41
41
 
42
- var _chunkC3UHJPYJjs = require('./chunk-C3UHJPYJ.js');
42
+ var _chunk3JEUO765js = require('./chunk-3JEUO765.js');
43
43
 
44
44
 
45
45
  var _chunk5KMU2IATjs = require('./chunk-5KMU2IAT.js');
@@ -48,17 +48,17 @@ var _chunk5KMU2IATjs = require('./chunk-5KMU2IAT.js');
48
48
  var _chunk7LXE4KHVjs = require('./chunk-7LXE4KHV.js');
49
49
 
50
50
 
51
- var _chunkXZILQVNWjs = require('./chunk-XZILQVNW.js');
51
+ var _chunkUBXRAA6Gjs = require('./chunk-UBXRAA6G.js');
52
52
 
53
53
 
54
- var _chunk6V2LR6JLjs = require('./chunk-6V2LR6JL.js');
54
+ var _chunkLYD4TEKHjs = require('./chunk-LYD4TEKH.js');
55
55
 
56
56
 
57
- var _chunkUUSYJGGQjs = require('./chunk-UUSYJGGQ.js');
57
+ var _chunkL337FYVSjs = require('./chunk-L337FYVS.js');
58
58
 
59
59
 
60
60
 
61
- var _chunkQTQSCTQAjs = require('./chunk-QTQSCTQA.js');
61
+ var _chunkWLCFETHRjs = require('./chunk-WLCFETHR.js');
62
62
 
63
63
 
64
64
 
@@ -260,7 +260,7 @@ var TransactionController = class extends _basecontroller.BaseController {
260
260
  provider,
261
261
  blockTracker
262
262
  });
263
- _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _multichainTrackingHelper, new (0, _chunkI7VD6IETjs.MultichainTrackingHelper)({
263
+ _chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _multichainTrackingHelper, new (0, _chunkCPYXP2OCjs.MultichainTrackingHelper)({
264
264
  isMultichainEnabled,
265
265
  provider,
266
266
  nonceTracker: this.nonceTracker,
@@ -291,7 +291,7 @@ var TransactionController = class extends _basecontroller.BaseController {
291
291
  }
292
292
  }));
293
293
  _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).initialize();
294
- const etherscanRemoteTransactionSource = new (0, _chunkC3UHJPYJjs.EtherscanRemoteTransactionSource)({
294
+ const etherscanRemoteTransactionSource = new (0, _chunk3JEUO765js.EtherscanRemoteTransactionSource)({
295
295
  includeTokenTransfers: incomingTransactions.includeTokenTransfers
296
296
  });
297
297
  this.incomingTransactionHelper = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn).call(this, {
@@ -498,7 +498,7 @@ var TransactionController = class extends _basecontroller.BaseController {
498
498
  if (!this.isHistoryDisabled) {
499
499
  addedTransactionMeta = _chunkQP75SWIQjs.addInitialHistorySnapshot.call(void 0, addedTransactionMeta);
500
500
  }
501
- addedTransactionMeta = _chunkQTQSCTQAjs.updateSwapsTransaction.call(void 0,
501
+ addedTransactionMeta = _chunkWLCFETHRjs.updateSwapsTransaction.call(void 0,
502
502
  addedTransactionMeta,
503
503
  transactionType,
504
504
  swaps,
@@ -823,7 +823,7 @@ var TransactionController = class extends _basecontroller.BaseController {
823
823
  const ethQuery = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).getEthQuery({
824
824
  networkClientId
825
825
  });
826
- const { estimatedGas, simulationFails } = await _chunkGRQB2ARKjs.estimateGas.call(void 0,
826
+ const { estimatedGas, simulationFails } = await _chunkAO3AE3L7js.estimateGas.call(void 0,
827
827
  transaction,
828
828
  ethQuery
829
829
  );
@@ -840,11 +840,11 @@ var TransactionController = class extends _basecontroller.BaseController {
840
840
  const ethQuery = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).getEthQuery({
841
841
  networkClientId
842
842
  });
843
- const { blockGasLimit, estimatedGas, simulationFails } = await _chunkGRQB2ARKjs.estimateGas.call(void 0,
843
+ const { blockGasLimit, estimatedGas, simulationFails } = await _chunkAO3AE3L7js.estimateGas.call(void 0,
844
844
  transaction,
845
845
  ethQuery
846
846
  );
847
- const gas = _chunkGRQB2ARKjs.addGasBuffer.call(void 0, estimatedGas, blockGasLimit, multiplier);
847
+ const gas = _chunkAO3AE3L7js.addGasBuffer.call(void 0, estimatedGas, blockGasLimit, multiplier);
848
848
  return {
849
849
  gas,
850
850
  simulationFails
@@ -1463,13 +1463,13 @@ var TransactionController = class extends _basecontroller.BaseController {
1463
1463
  networkClientId,
1464
1464
  chainId
1465
1465
  });
1466
- await _chunkGRQB2ARKjs.updateGas.call(void 0, {
1466
+ await _chunkAO3AE3L7js.updateGas.call(void 0, {
1467
1467
  ethQuery,
1468
1468
  chainId,
1469
1469
  isCustomNetwork,
1470
1470
  txMeta: transactionMeta
1471
1471
  });
1472
- await _chunkUUSYJGGQjs.updateGasFees.call(void 0, {
1472
+ await _chunkL337FYVSjs.updateGasFees.call(void 0, {
1473
1473
  eip1559: isEIP1559Compatible,
1474
1474
  ethQuery,
1475
1475
  gasFeeFlows: this.gasFeeFlows,
@@ -2133,7 +2133,7 @@ var TransactionController = class extends _basecontroller.BaseController {
2133
2133
  networkClientId: transactionMeta.networkClientId,
2134
2134
  chainId: transactionMeta.chainId
2135
2135
  });
2136
- const { updatedTransactionMeta, approvalTransactionMeta } = await _chunkQTQSCTQAjs.updatePostTransactionBalance.call(void 0, transactionMeta, {
2136
+ const { updatedTransactionMeta, approvalTransactionMeta } = await _chunkWLCFETHRjs.updatePostTransactionBalance.call(void 0, transactionMeta, {
2137
2137
  ethQuery,
2138
2138
  getTransaction: this.getTransaction.bind(this),
2139
2139
  updateTransaction: this.updateTransaction.bind(this)
@@ -2320,11 +2320,11 @@ getNonceTrackerPendingTransactions_fn = function(chainId, address) {
2320
2320
  };
2321
2321
  _getGasFeeFlows = new WeakSet();
2322
2322
  getGasFeeFlows_fn = function() {
2323
- return [new (0, _chunkXZILQVNWjs.LineaGasFeeFlow)(), new (0, _chunk6V2LR6JLjs.DefaultGasFeeFlow)()];
2323
+ return [new (0, _chunkUBXRAA6Gjs.LineaGasFeeFlow)(), new (0, _chunkLYD4TEKHjs.DefaultGasFeeFlow)()];
2324
2324
  };
2325
2325
  _getLayer1GasFeeFlows = new WeakSet();
2326
2326
  getLayer1GasFeeFlows_fn = function() {
2327
- return [new (0, _chunkQG2WVQE3js.OptimismLayer1GasFeeFlow)()];
2327
+ return [new (0, _chunkETMW527Mjs.OptimismLayer1GasFeeFlow)()];
2328
2328
  };
2329
2329
  _updateTransactionInternal = new WeakSet();
2330
2330
  updateTransactionInternal_fn = function(transactionMeta, { note, skipHistory }) {
@@ -2390,7 +2390,7 @@ updateSimulationData_fn = async function(transactionMeta) {
2390
2390
  };
2391
2391
  if (_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _isSimulationEnabled).call(this)) {
2392
2392
  _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, { ...transactionMeta, simulationData: void 0 }, { skipHistory: true });
2393
- simulationData = await _chunkV5X6MZHNjs.getSimulationData.call(void 0, {
2393
+ simulationData = await _chunk3VF7ZGRVjs.getSimulationData.call(void 0, {
2394
2394
  chainId,
2395
2395
  from,
2396
2396
  to,
@@ -2421,4 +2421,4 @@ updateSimulationData_fn = async function(transactionMeta) {
2421
2421
 
2422
2422
 
2423
2423
  exports.HARDFORK = HARDFORK; exports.CANCEL_RATE = CANCEL_RATE; exports.SPEED_UP_RATE = SPEED_UP_RATE; exports.ApprovalState = ApprovalState; exports.TransactionController = TransactionController;
2424
- //# sourceMappingURL=chunk-YS23EOJX.js.map
2424
+ //# sourceMappingURL=chunk-5SKCGFUC.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkWIZVJM2Bjs = require('./chunk-WIZVJM2B.js');
3
+ var _chunkLQS2M5QRjs = require('./chunk-LQS2M5QR.js');
4
4
 
5
5
 
6
6
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
@@ -97,7 +97,7 @@ async function getGas(request) {
97
97
  log("Using original estimate as custom network");
98
98
  return [estimatedGas, simulationFails];
99
99
  }
100
- const bufferMultiplier = _chunkWIZVJM2Bjs.GAS_BUFFER_CHAIN_OVERRIDES[chainId] ?? DEFAULT_GAS_MULTIPLIER;
100
+ const bufferMultiplier = _chunkLQS2M5QRjs.GAS_BUFFER_CHAIN_OVERRIDES[chainId] ?? DEFAULT_GAS_MULTIPLIER;
101
101
  const bufferedGas = addGasBuffer(
102
102
  estimatedGas,
103
103
  blockGasLimit,
@@ -134,4 +134,4 @@ async function getLatestBlock(ethQuery) {
134
134
 
135
135
 
136
136
  exports.log = log; exports.FIXED_GAS = FIXED_GAS; exports.DEFAULT_GAS_MULTIPLIER = DEFAULT_GAS_MULTIPLIER; exports.updateGas = updateGas; exports.estimateGas = estimateGas; exports.addGasBuffer = addGasBuffer;
137
- //# sourceMappingURL=chunk-GRQB2ARK.js.map
137
+ //# sourceMappingURL=chunk-AO3AE3L7.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkC3UHJPYJjs = require('./chunk-C3UHJPYJ.js');
3
+ var _chunk3JEUO765js = require('./chunk-3JEUO765.js');
4
4
 
5
5
 
6
6
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
@@ -275,7 +275,7 @@ startTrackingByNetworkClientId_fn = function(networkClientId) {
275
275
  } = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getNetworkClientById).call(this, networkClientId);
276
276
  let etherscanRemoteTransactionSource = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _etherscanRemoteTransactionSourcesMap).get(chainId);
277
277
  if (!etherscanRemoteTransactionSource) {
278
- etherscanRemoteTransactionSource = new (0, _chunkC3UHJPYJjs.EtherscanRemoteTransactionSource)({
278
+ etherscanRemoteTransactionSource = new (0, _chunk3JEUO765js.EtherscanRemoteTransactionSource)({
279
279
  includeTokenTransfers: _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _incomingTransactionOptions).includeTokenTransfers
280
280
  });
281
281
  _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _etherscanRemoteTransactionSourcesMap).set(
@@ -332,4 +332,4 @@ getNetworkClient_fn = function({
332
332
 
333
333
 
334
334
  exports.MultichainTrackingHelper = MultichainTrackingHelper;
335
- //# sourceMappingURL=chunk-I7VD6IET.js.map
335
+ //# sourceMappingURL=chunk-CPYXP2OC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  gweiDecimalToWeiHex
3
- } from "./chunk-TZEAWUXE.mjs";
3
+ } from "./chunk-P74YLPJO.mjs";
4
4
  import {
5
5
  projectLogger
6
6
  } from "./chunk-UQQWZT6C.mjs";
@@ -87,4 +87,4 @@ getLegacyLevel_fn = function(gasFeeEstimates, level) {
87
87
  export {
88
88
  DefaultGasFeeFlow
89
89
  };
90
- //# sourceMappingURL=chunk-KKCD5UMP.mjs.map
90
+ //# sourceMappingURL=chunk-CWWZQZVR.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ETHERSCAN_SUPPORTED_NETWORKS
3
- } from "./chunk-DTMKGTYC.mjs";
3
+ } from "./chunk-4VLQV2GA.mjs";
4
4
  import {
5
5
  incomingTransactionsLogger
6
6
  } from "./chunk-UQQWZT6C.mjs";
@@ -82,4 +82,4 @@ export {
82
82
  fetchEtherscanTokenTransactions,
83
83
  getEtherscanApiHost
84
84
  };
85
- //# sourceMappingURL=chunk-RIYIJTEU.mjs.map
85
+ //# sourceMappingURL=chunk-DOX6H5UJ.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  GAS_BUFFER_CHAIN_OVERRIDES
3
- } from "./chunk-DTMKGTYC.mjs";
3
+ } from "./chunk-4VLQV2GA.mjs";
4
4
  import {
5
5
  projectLogger
6
6
  } from "./chunk-UQQWZT6C.mjs";
@@ -134,4 +134,4 @@ export {
134
134
  estimateGas,
135
135
  addGasBuffer
136
136
  };
137
- //# sourceMappingURL=chunk-HLG525BC.mjs.map
137
+ //# sourceMappingURL=chunk-DRSMLO7B.mjs.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkWIZVJM2Bjs = require('./chunk-WIZVJM2B.js');
3
+ var _chunkLQS2M5QRjs = require('./chunk-LQS2M5QR.js');
4
4
 
5
5
 
6
6
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
@@ -18,13 +18,13 @@ var _utils = require('@metamask/utils');
18
18
  var _bnjs = require('bn.js'); var _bnjs2 = _interopRequireDefault(_bnjs);
19
19
  var _lodash = require('lodash');
20
20
  var OPTIMISM_STACK_CHAIN_IDS = [
21
- _chunkWIZVJM2Bjs.CHAIN_IDS.OPTIMISM,
22
- _chunkWIZVJM2Bjs.CHAIN_IDS.OPTIMISM_TESTNET,
23
- _chunkWIZVJM2Bjs.CHAIN_IDS.BASE,
24
- _chunkWIZVJM2Bjs.CHAIN_IDS.BASE_TESTNET,
25
- _chunkWIZVJM2Bjs.CHAIN_IDS.OPBNB,
26
- _chunkWIZVJM2Bjs.CHAIN_IDS.OPBNB_TESTNET,
27
- _chunkWIZVJM2Bjs.CHAIN_IDS.ZORA
21
+ _chunkLQS2M5QRjs.CHAIN_IDS.OPTIMISM,
22
+ _chunkLQS2M5QRjs.CHAIN_IDS.OPTIMISM_TESTNET,
23
+ _chunkLQS2M5QRjs.CHAIN_IDS.BASE,
24
+ _chunkLQS2M5QRjs.CHAIN_IDS.BASE_TESTNET,
25
+ _chunkLQS2M5QRjs.CHAIN_IDS.OPBNB,
26
+ _chunkLQS2M5QRjs.CHAIN_IDS.OPBNB_TESTNET,
27
+ _chunkLQS2M5QRjs.CHAIN_IDS.ZORA
28
28
  ];
29
29
  var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger, "optimisim-layer1-gas-fee-flow");
30
30
  var OPTIMISM_GAS_PRICE_ORACLE_ABI = [
@@ -129,4 +129,4 @@ buildTransactionCommon_fn = function(transactionMeta) {
129
129
 
130
130
 
131
131
  exports.OptimismLayer1GasFeeFlow = OptimismLayer1GasFeeFlow;
132
- //# sourceMappingURL=chunk-QG2WVQE3.js.map
132
+ //# sourceMappingURL=chunk-ETMW527M.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkWIZVJM2Bjs = require('./chunk-WIZVJM2B.js');
3
+ var _chunkLQS2M5QRjs = require('./chunk-LQS2M5QR.js');
4
4
 
5
5
 
6
6
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
@@ -70,7 +70,7 @@ function getEtherscanApiUrl(chainId, urlParams) {
70
70
  return url;
71
71
  }
72
72
  function getEtherscanApiHost(chainId) {
73
- const networkInfo = _chunkWIZVJM2Bjs.ETHERSCAN_SUPPORTED_NETWORKS[chainId];
73
+ const networkInfo = _chunkLQS2M5QRjs.ETHERSCAN_SUPPORTED_NETWORKS[chainId];
74
74
  if (!networkInfo) {
75
75
  throw new Error(`Etherscan does not support chain with ID: ${chainId}`);
76
76
  }
@@ -82,4 +82,4 @@ function getEtherscanApiHost(chainId) {
82
82
 
83
83
 
84
84
  exports.fetchEtherscanTransactions = fetchEtherscanTransactions; exports.fetchEtherscanTokenTransactions = fetchEtherscanTokenTransactions; exports.getEtherscanApiHost = getEtherscanApiHost;
85
- //# sourceMappingURL=chunk-VP2DBWOT.js.map
85
+ //# sourceMappingURL=chunk-F247MMTE.js.map
@@ -9,7 +9,7 @@ import {
9
9
  addGasBuffer,
10
10
  estimateGas,
11
11
  updateGas
12
- } from "./chunk-HLG525BC.mjs";
12
+ } from "./chunk-DRSMLO7B.mjs";
13
13
  import {
14
14
  addInitialHistorySnapshot,
15
15
  updateTransactionHistory
@@ -20,10 +20,10 @@ import {
20
20
  } from "./chunk-NHRBO3LU.mjs";
21
21
  import {
22
22
  getSimulationData
23
- } from "./chunk-A4P4B3OF.mjs";
23
+ } from "./chunk-L7ZKSKEI.mjs";
24
24
  import {
25
25
  OptimismLayer1GasFeeFlow
26
- } from "./chunk-JW6P2G5A.mjs";
26
+ } from "./chunk-53IYIDVS.mjs";
27
27
  import {
28
28
  GasFeePoller
29
29
  } from "./chunk-35MG26Y3.mjs";
@@ -36,10 +36,10 @@ import {
36
36
  } from "./chunk-Y7ENNK7L.mjs";
37
37
  import {
38
38
  MultichainTrackingHelper
39
- } from "./chunk-FTB6MCSH.mjs";
39
+ } from "./chunk-RXRJSBSF.mjs";
40
40
  import {
41
41
  EtherscanRemoteTransactionSource
42
- } from "./chunk-RU6NJIUD.mjs";
42
+ } from "./chunk-TKWTUPCQ.mjs";
43
43
  import {
44
44
  PendingTransactionTracker
45
45
  } from "./chunk-5YES3V2R.mjs";
@@ -48,17 +48,17 @@ import {
48
48
  } from "./chunk-FRKQ3Z2L.mjs";
49
49
  import {
50
50
  LineaGasFeeFlow
51
- } from "./chunk-7HNSDVVO.mjs";
51
+ } from "./chunk-2XFBWPHD.mjs";
52
52
  import {
53
53
  DefaultGasFeeFlow
54
- } from "./chunk-KKCD5UMP.mjs";
54
+ } from "./chunk-CWWZQZVR.mjs";
55
55
  import {
56
56
  updateGasFees
57
- } from "./chunk-TZEAWUXE.mjs";
57
+ } from "./chunk-P74YLPJO.mjs";
58
58
  import {
59
59
  updatePostTransactionBalance,
60
60
  updateSwapsTransaction
61
- } from "./chunk-TJXPMOA6.mjs";
61
+ } from "./chunk-RBF6CW7D.mjs";
62
62
  import {
63
63
  getIncreasedPriceFromExisting,
64
64
  isEIP1559Transaction,
@@ -2421,4 +2421,4 @@ export {
2421
2421
  ApprovalState,
2422
2422
  TransactionController
2423
2423
  };
2424
- //# sourceMappingURL=chunk-H7O3Y7EQ.mjs.map
2424
+ //# sourceMappingURL=chunk-JDLNCMGI.mjs.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkQTQSCTQAjs = require('./chunk-QTQSCTQA.js');
3
+ var _chunkWLCFETHRjs = require('./chunk-WLCFETHR.js');
4
4
 
5
5
 
6
6
  var _chunkUH7FNVKSjs = require('./chunk-UH7FNVKS.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 = _chunkQTQSCTQAjs.SWAP_TRANSACTION_TYPES.includes(
23
+ const isSwap = _chunkWLCFETHRjs.SWAP_TRANSACTION_TYPES.includes(
24
24
  txMeta.type
25
25
  );
26
26
  const savedGasFees = isSwap ? void 0 : request.getSavedGasFees(txMeta.chainId);
@@ -205,4 +205,4 @@ async function getSuggestedGasFees(request) {
205
205
 
206
206
 
207
207
  exports.updateGasFees = updateGasFees; exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
208
- //# sourceMappingURL=chunk-UUSYJGGQ.js.map
208
+ //# sourceMappingURL=chunk-L337FYVS.js.map
@@ -6,6 +6,10 @@ import {
6
6
  SimulationInvalidResponseError,
7
7
  SimulationRevertedError
8
8
  } from "./chunk-HQSNKCXI.mjs";
9
+ import {
10
+ ABI_SIMULATION_ERC20_WRAPPED,
11
+ ABI_SIMULATION_ERC721_LEGACY
12
+ } from "./chunk-4VLQV2GA.mjs";
9
13
  import {
10
14
  projectLogger
11
15
  } from "./chunk-UQQWZT6C.mjs";
@@ -15,7 +19,44 @@ import { Interface } from "@ethersproject/abi";
15
19
  import { hexToBN, toHex } from "@metamask/controller-utils";
16
20
  import { abiERC20, abiERC721, abiERC1155 } from "@metamask/metamask-eth-abis";
17
21
  import { createModuleLogger } from "@metamask/utils";
22
+ var SupportedToken = /* @__PURE__ */ ((SupportedToken2) => {
23
+ SupportedToken2["ERC20"] = "erc20";
24
+ SupportedToken2["ERC721"] = "erc721";
25
+ SupportedToken2["ERC1155"] = "erc1155";
26
+ SupportedToken2["ERC20_WRAPPED"] = "erc20Wrapped";
27
+ SupportedToken2["ERC721_LEGACY"] = "erc721Legacy";
28
+ return SupportedToken2;
29
+ })(SupportedToken || {});
18
30
  var log = createModuleLogger(projectLogger, "simulation");
31
+ var SUPPORTED_EVENTS = [
32
+ "Transfer",
33
+ "TransferSingle",
34
+ "TransferBatch",
35
+ "Deposit",
36
+ "Withdrawal"
37
+ ];
38
+ var SUPPORTED_TOKEN_ABIS = {
39
+ ["erc20" /* ERC20 */]: {
40
+ abi: abiERC20,
41
+ standard: "erc20" /* erc20 */
42
+ },
43
+ ["erc721" /* ERC721 */]: {
44
+ abi: abiERC721,
45
+ standard: "erc721" /* erc721 */
46
+ },
47
+ ["erc1155" /* ERC1155 */]: {
48
+ abi: abiERC1155,
49
+ standard: "erc1155" /* erc1155 */
50
+ },
51
+ ["erc20Wrapped" /* ERC20_WRAPPED */]: {
52
+ abi: ABI_SIMULATION_ERC20_WRAPPED,
53
+ standard: "erc20" /* erc20 */
54
+ },
55
+ ["erc721Legacy" /* ERC721_LEGACY */]: {
56
+ abi: ABI_SIMULATION_ERC721_LEGACY,
57
+ standard: "erc721" /* erc721 */
58
+ }
59
+ };
19
60
  var REVERTED_ERRORS = ["execution reverted", "insufficient funds for gas"];
20
61
  async function getSimulationData(request) {
21
62
  const { chainId, from, to, value, data } = request;
@@ -36,9 +77,6 @@ async function getSimulationData(request) {
36
77
  withLogs: true
37
78
  });
38
79
  const transactionError = response.transactions?.[0]?.error;
39
- if (REVERTED_ERRORS.some((error) => transactionError?.includes(error))) {
40
- throw new SimulationRevertedError();
41
- }
42
80
  if (transactionError) {
43
81
  throw new SimulationError(transactionError);
44
82
  }
@@ -52,12 +90,18 @@ async function getSimulationData(request) {
52
90
  };
53
91
  } catch (error) {
54
92
  log("Failed to get simulation data", error, request);
55
- const rawError = error;
93
+ let simulationError = error;
94
+ if (REVERTED_ERRORS.some(
95
+ (revertErrorMessage) => simulationError.message?.includes(revertErrorMessage)
96
+ )) {
97
+ simulationError = new SimulationRevertedError();
98
+ }
99
+ const { code, message } = simulationError;
56
100
  return {
57
101
  tokenBalanceChanges: [],
58
102
  error: {
59
- code: rawError.code,
60
- message: rawError.message
103
+ code,
104
+ message
61
105
  }
62
106
  };
63
107
  }
@@ -80,16 +124,9 @@ function getEvents(response) {
80
124
  response.transactions[0]?.callTrace ?? {}
81
125
  );
82
126
  log("Extracted logs", logs);
83
- const erc20Interface = new Interface(abiERC20);
84
- const erc721Interface = new Interface(abiERC721);
85
- const erc1155Interface = new Interface(abiERC1155);
127
+ const interfaces = getContractInterfaces();
86
128
  return logs.map((currentLog) => {
87
- const event = parseLog(
88
- currentLog,
89
- erc20Interface,
90
- erc721Interface,
91
- erc1155Interface
92
- );
129
+ const event = parseLog(currentLog, interfaces);
93
130
  if (!event) {
94
131
  log("Failed to parse log", currentLog);
95
132
  return void 0;
@@ -141,11 +178,15 @@ async function getTokenBalanceChanges(request, events) {
141
178
  throw new SimulationInvalidResponseError();
142
179
  }
143
180
  return [...balanceTransactionsByToken.keys()].map((token, index) => {
144
- const previousBalance = normalizeReturnValue(
145
- response.transactions[index].return
181
+ const previousBalance = getValueFromBalanceTransaction(
182
+ request.from,
183
+ token,
184
+ response.transactions[index]
146
185
  );
147
- const newBalance = normalizeReturnValue(
148
- response.transactions[index + balanceTransactions.length + 1].return
186
+ const newBalance = getValueFromBalanceTransaction(
187
+ request.from,
188
+ token,
189
+ response.transactions[index + balanceTransactions.length + 1]
149
190
  );
150
191
  const balanceChange = getSimulationBalanceChange(
151
192
  previousBalance,
@@ -162,21 +203,12 @@ async function getTokenBalanceChanges(request, events) {
162
203
  }
163
204
  function getTokenBalanceTransactions(request, events) {
164
205
  const tokenKeys = /* @__PURE__ */ new Set();
165
- return events.reduce((result, event) => {
166
- if (!["Transfer", "TransferSingle", "TransferBatch"].includes(event.name) || ![event.args.from, event.args.to].includes(request.from)) {
167
- log("Ignoring event", event);
168
- return result;
169
- }
170
- let tokenIds = [void 0];
171
- if (event.tokenStandard === "erc721" /* erc721 */) {
172
- tokenIds = [event.args.tokenId];
173
- }
174
- if (event.tokenStandard === "erc1155" /* erc1155 */ && event.name === "TransferSingle") {
175
- tokenIds = [event.args.id];
176
- }
177
- if (event.tokenStandard === "erc1155" /* erc1155 */ && event.name === "TransferBatch") {
178
- tokenIds = event.args.ids;
179
- }
206
+ const userEvents = events.filter(
207
+ (event) => SUPPORTED_EVENTS.includes(event.name) && [event.args.from, event.args.to].includes(request.from)
208
+ );
209
+ log("Filtered user events", userEvents);
210
+ return userEvents.reduce((result, event) => {
211
+ const tokenIds = getEventTokenIds(event);
180
212
  log("Extracted token ids", tokenIds);
181
213
  for (const tokenId of tokenIds) {
182
214
  const simulationToken = {
@@ -193,42 +225,62 @@ function getTokenBalanceTransactions(request, events) {
193
225
  continue;
194
226
  }
195
227
  tokenKeys.add(tokenKey);
196
- const parameters = [request.from];
197
- if (event.tokenStandard === "erc1155" /* erc1155 */) {
198
- parameters.push(tokenId);
199
- }
228
+ const data = getBalanceTransactionData(
229
+ event.tokenStandard,
230
+ request.from,
231
+ tokenId
232
+ );
200
233
  result.set(simulationToken, {
201
234
  from: request.from,
202
235
  to: event.contractAddress,
203
- data: new Interface(event.abi).encodeFunctionData(
204
- "balanceOf",
205
- parameters
206
- )
236
+ data
207
237
  });
208
238
  }
209
239
  return result;
210
240
  }, /* @__PURE__ */ new Map());
211
241
  }
212
- function parseLog(eventLog, erc20, erc721, erc1155) {
213
- const abisByStandard = [
214
- {
215
- abi: abiERC20,
216
- contractInterface: erc20,
217
- standard: "erc20" /* erc20 */
218
- },
219
- {
220
- abi: abiERC721,
221
- contractInterface: erc721,
222
- standard: "erc721" /* erc721 */
223
- },
224
- {
225
- abi: abiERC1155,
226
- contractInterface: erc1155,
227
- standard: "erc1155" /* erc1155 */
228
- }
229
- ];
230
- for (const { abi, contractInterface, standard } of abisByStandard) {
242
+ function getEventTokenIds(event) {
243
+ if (event.tokenStandard === "erc721" /* erc721 */) {
244
+ return [event.args.tokenId];
245
+ }
246
+ if (event.tokenStandard === "erc1155" /* erc1155 */ && event.name === "TransferSingle") {
247
+ return [event.args.id];
248
+ }
249
+ if (event.tokenStandard === "erc1155" /* erc1155 */ && event.name === "TransferBatch") {
250
+ return event.args.ids;
251
+ }
252
+ return [void 0];
253
+ }
254
+ function getValueFromBalanceTransaction(from, token, response) {
255
+ const normalizedReturn = normalizeReturnValue(response.return);
256
+ if (token.standard === "erc721" /* erc721 */) {
257
+ return normalizedReturn === from ? "0x1" : "0x0";
258
+ }
259
+ return normalizedReturn;
260
+ }
261
+ function getBalanceTransactionData(tokenStandard, from, tokenId) {
262
+ switch (tokenStandard) {
263
+ case "erc721" /* erc721 */:
264
+ return new Interface(abiERC721).encodeFunctionData("ownerOf", [
265
+ tokenId
266
+ ]);
267
+ case "erc1155" /* erc1155 */:
268
+ return new Interface(abiERC1155).encodeFunctionData("balanceOf", [
269
+ from,
270
+ tokenId
271
+ ]);
272
+ default:
273
+ return new Interface(abiERC20).encodeFunctionData("balanceOf", [
274
+ from
275
+ ]);
276
+ }
277
+ }
278
+ function parseLog(eventLog, interfaces) {
279
+ const supportedTokens = Object.values(SupportedToken);
280
+ for (const token of supportedTokens) {
231
281
  try {
282
+ const contractInterface = interfaces.get(token);
283
+ const { abi, standard } = SUPPORTED_TOKEN_ABIS[token];
232
284
  return {
233
285
  ...contractInterface.parseLog(eventLog),
234
286
  abi,
@@ -266,8 +318,19 @@ function getSimulationBalanceChange(previousBalance, newBalance) {
266
318
  function normalizeReturnValue(value) {
267
319
  return toHex(hexToBN(value));
268
320
  }
321
+ function getContractInterfaces() {
322
+ const supportedTokens = Object.values(SupportedToken);
323
+ return new Map(
324
+ supportedTokens.map((tokenType) => {
325
+ const { abi } = SUPPORTED_TOKEN_ABIS[tokenType];
326
+ const contractInterface = new Interface(abi);
327
+ return [tokenType, contractInterface];
328
+ })
329
+ );
330
+ }
269
331
 
270
332
  export {
333
+ SupportedToken,
271
334
  getSimulationData
272
335
  };
273
- //# sourceMappingURL=chunk-A4P4B3OF.mjs.map
336
+ //# sourceMappingURL=chunk-L7ZKSKEI.mjs.map