@metamask/transaction-controller 25.1.0 → 25.2.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 (107) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/dist/TransactionController.js +10 -10
  3. package/dist/TransactionController.mjs +9 -9
  4. package/dist/{chunk-QPNEFZB3.js → chunk-5IHLDAOF.js} +3 -3
  5. package/dist/{chunk-EEMJC7S7.mjs → chunk-5UL3VDFT.mjs} +2 -2
  6. package/dist/chunk-6XMG522E.mjs +56 -0
  7. package/dist/chunk-6XMG522E.mjs.map +1 -0
  8. package/dist/{chunk-QDIYZX5V.js → chunk-7BG5XOXJ.js} +85 -29
  9. package/dist/chunk-7BG5XOXJ.js.map +1 -0
  10. package/dist/{chunk-QSBIXUMB.mjs → chunk-BYBPZUHS.mjs} +30 -7
  11. package/dist/chunk-BYBPZUHS.mjs.map +1 -0
  12. package/dist/{chunk-2YXA3K67.mjs → chunk-DWHMMJOW.mjs} +2 -2
  13. package/dist/{chunk-CQBXHAYR.js → chunk-FHG5GY6F.js} +6 -6
  14. package/dist/{chunk-WXQZIUNW.js → chunk-GC77BSQZ.js} +32 -9
  15. package/dist/chunk-GC77BSQZ.js.map +1 -0
  16. package/dist/chunk-GE57YNGX.js +56 -0
  17. package/dist/chunk-GE57YNGX.js.map +1 -0
  18. package/dist/{chunk-72OTU5ZW.mjs → chunk-I6RY3XOG.mjs} +83 -27
  19. package/dist/chunk-I6RY3XOG.mjs.map +1 -0
  20. package/dist/{chunk-DTONMSFW.mjs → chunk-IK55QTGO.mjs} +2 -2
  21. package/dist/{chunk-TXVH44HM.js → chunk-PF3UOCRW.js} +7 -7
  22. package/dist/{chunk-K26EBMGI.mjs → chunk-PGTV7236.mjs} +3 -3
  23. package/dist/{chunk-BILEZLAT.js → chunk-QEX3QMSL.js} +3 -3
  24. package/dist/{chunk-OF6NSLXF.mjs → chunk-QRSTF45Q.mjs} +3 -3
  25. package/dist/{chunk-O7H2MC7R.js → chunk-TZTP4JVA.js} +4 -4
  26. package/dist/{chunk-W3GAOR7Y.js → chunk-VEJ3MIZG.js} +1 -1
  27. package/dist/{chunk-W3GAOR7Y.js.map → chunk-VEJ3MIZG.js.map} +1 -1
  28. package/dist/{chunk-NM4LTWRU.mjs → chunk-W57BD6NX.mjs} +1 -1
  29. package/dist/{chunk-NM4LTWRU.mjs.map → chunk-W57BD6NX.mjs.map} +1 -1
  30. package/dist/gas-flows/DefaultGasFeeFlow.js +5 -5
  31. package/dist/gas-flows/DefaultGasFeeFlow.mjs +4 -4
  32. package/dist/gas-flows/LineaGasFeeFlow.js +6 -6
  33. package/dist/gas-flows/LineaGasFeeFlow.mjs +5 -5
  34. package/dist/helpers/EtherscanRemoteTransactionSource.js +1 -1
  35. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +1 -1
  36. package/dist/helpers/GasFeePoller.js +4 -4
  37. package/dist/helpers/GasFeePoller.mjs +3 -3
  38. package/dist/helpers/MultichainTrackingHelper.js +1 -1
  39. package/dist/helpers/MultichainTrackingHelper.mjs +1 -1
  40. package/dist/helpers/PendingTransactionTracker.js +1 -1
  41. package/dist/helpers/PendingTransactionTracker.mjs +1 -1
  42. package/dist/index.js +12 -10
  43. package/dist/index.mjs +11 -9
  44. package/dist/tsconfig.build.tsbuildinfo +1 -1
  45. package/dist/types/TransactionController.d.ts +26 -26
  46. package/dist/types/TransactionController.d.ts.map +1 -1
  47. package/dist/types/helpers/IncomingTransactionHelper.d.ts +1 -1
  48. package/dist/types/helpers/IncomingTransactionHelper.d.ts.map +1 -1
  49. package/dist/types/helpers/MultichainTrackingHelper.d.ts +1 -1
  50. package/dist/types/helpers/MultichainTrackingHelper.d.ts.map +1 -1
  51. package/dist/types/helpers/PendingTransactionTracker.d.ts +1 -1
  52. package/dist/types/helpers/PendingTransactionTracker.d.ts.map +1 -1
  53. package/dist/types/index.d.ts +2 -2
  54. package/dist/types/index.d.ts.map +1 -1
  55. package/dist/types/types.d.ts +40 -29
  56. package/dist/types/types.d.ts.map +1 -1
  57. package/dist/types/utils/gas-fees.d.ts +3 -3
  58. package/dist/types/utils/gas-fees.d.ts.map +1 -1
  59. package/dist/types/utils/gas-flow.d.ts +2 -2
  60. package/dist/types/utils/gas-flow.d.ts.map +1 -1
  61. package/dist/types/utils/gas.d.ts +1 -1
  62. package/dist/types/utils/gas.d.ts.map +1 -1
  63. package/dist/types/utils/layer1-gas-fee-flow.d.ts +1 -1
  64. package/dist/types/utils/layer1-gas-fee-flow.d.ts.map +1 -1
  65. package/dist/types/utils/simulation-api.d.ts +21 -13
  66. package/dist/types/utils/simulation-api.d.ts.map +1 -1
  67. package/dist/types/utils/simulation.d.ts +2 -2
  68. package/dist/types/utils/simulation.d.ts.map +1 -1
  69. package/dist/types.js +2 -2
  70. package/dist/types.mjs +1 -1
  71. package/dist/utils/external-transactions.js +1 -1
  72. package/dist/utils/external-transactions.mjs +1 -1
  73. package/dist/utils/gas-fees.js +4 -4
  74. package/dist/utils/gas-fees.mjs +3 -3
  75. package/dist/utils/gas-flow.js +3 -3
  76. package/dist/utils/gas-flow.mjs +2 -2
  77. package/dist/utils/simulation-api.js +2 -3
  78. package/dist/utils/simulation-api.mjs +1 -2
  79. package/dist/utils/simulation.js +4 -5
  80. package/dist/utils/simulation.mjs +3 -4
  81. package/dist/utils/swaps.js +1 -1
  82. package/dist/utils/swaps.mjs +1 -1
  83. package/dist/utils/transaction-type.js +1 -1
  84. package/dist/utils/transaction-type.mjs +1 -1
  85. package/dist/utils/utils.js +1 -1
  86. package/dist/utils/utils.mjs +1 -1
  87. package/dist/utils/validation.js +1 -1
  88. package/dist/utils/validation.mjs +1 -1
  89. package/package.json +3 -4
  90. package/dist/chunk-4S25HUCL.js +0 -46
  91. package/dist/chunk-4S25HUCL.js.map +0 -1
  92. package/dist/chunk-72OTU5ZW.mjs.map +0 -1
  93. package/dist/chunk-7XPI7KU5.mjs +0 -46
  94. package/dist/chunk-7XPI7KU5.mjs.map +0 -1
  95. package/dist/chunk-QDIYZX5V.js.map +0 -1
  96. package/dist/chunk-QSBIXUMB.mjs.map +0 -1
  97. package/dist/chunk-WXQZIUNW.js.map +0 -1
  98. /package/dist/{chunk-QPNEFZB3.js.map → chunk-5IHLDAOF.js.map} +0 -0
  99. /package/dist/{chunk-EEMJC7S7.mjs.map → chunk-5UL3VDFT.mjs.map} +0 -0
  100. /package/dist/{chunk-2YXA3K67.mjs.map → chunk-DWHMMJOW.mjs.map} +0 -0
  101. /package/dist/{chunk-CQBXHAYR.js.map → chunk-FHG5GY6F.js.map} +0 -0
  102. /package/dist/{chunk-DTONMSFW.mjs.map → chunk-IK55QTGO.mjs.map} +0 -0
  103. /package/dist/{chunk-TXVH44HM.js.map → chunk-PF3UOCRW.js.map} +0 -0
  104. /package/dist/{chunk-K26EBMGI.mjs.map → chunk-PGTV7236.mjs.map} +0 -0
  105. /package/dist/{chunk-BILEZLAT.js.map → chunk-QEX3QMSL.js.map} +0 -0
  106. /package/dist/{chunk-OF6NSLXF.mjs.map → chunk-QRSTF45Q.mjs.map} +0 -0
  107. /package/dist/{chunk-O7H2MC7R.js.map → chunk-TZTP4JVA.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [25.2.1]
11
+
12
+ ### Changed
13
+
14
+ - Bump `TypeScript` version to `~4.9.5` ([#4084](https://github.com/MetaMask/core/pull/4084))
15
+
16
+ ### Fixed
17
+
18
+ - Emit finished event for custodial transactions when updating status to `submitted` or `failed` ([#4092](https://github.com/MetaMask/core/pull/4092))
19
+
20
+ ## [25.2.0]
21
+
22
+ ### Added
23
+
24
+ - Add simulation types ([#4067](https://github.com/MetaMask/core/pull/4067))
25
+ - SimulationBalanceChange
26
+ - SimulationData
27
+ - SimulationError
28
+ - SimulationToken
29
+ - SimulationTokenBalanceChange
30
+ - SimulationTokenStandard
31
+
32
+ ### Changed
33
+
34
+ - No longer wait for simulation to complete before creating approval request ([#4067](https://github.com/MetaMask/core/pull/4067))
35
+ - Automatically update simulation data if transaction parameters are updated ([#4067](https://github.com/MetaMask/core/pull/4067))
36
+ - Determine networks supporting simulation dynamically using API ([#4087](https://github.com/MetaMask/core/pull/4087))
37
+
10
38
  ## [25.1.0]
11
39
 
12
40
  ### Added
@@ -684,7 +712,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
684
712
 
685
713
  All changes listed after this point were applied to this package following the monorepo conversion.
686
714
 
687
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@25.1.0...HEAD
715
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@25.2.1...HEAD
716
+ [25.2.1]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@25.2.0...@metamask/transaction-controller@25.2.1
717
+ [25.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@25.1.0...@metamask/transaction-controller@25.2.0
688
718
  [25.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@25.0.0...@metamask/transaction-controller@25.1.0
689
719
  [25.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@24.0.0...@metamask/transaction-controller@25.0.0
690
720
  [24.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@23.1.0...@metamask/transaction-controller@24.0.0
@@ -4,31 +4,31 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkQDIYZX5Vjs = require('./chunk-QDIYZX5V.js');
7
+ var _chunk7BG5XOXJjs = require('./chunk-7BG5XOXJ.js');
8
8
  require('./chunk-VH47Q6TS.js');
9
9
  require('./chunk-RQKICZYP.js');
10
10
  require('./chunk-QP75SWIQ.js');
11
11
  require('./chunk-ZNZEJDOE.js');
12
- require('./chunk-WXQZIUNW.js');
13
- require('./chunk-4S25HUCL.js');
12
+ require('./chunk-GC77BSQZ.js');
13
+ require('./chunk-GE57YNGX.js');
14
14
  require('./chunk-HS277C77.js');
15
- require('./chunk-BILEZLAT.js');
15
+ require('./chunk-QEX3QMSL.js');
16
16
  require('./chunk-R7NJVDWN.js');
17
17
  require('./chunk-DTDTOMTB.js');
18
18
  require('./chunk-NRWEI43Q.js');
19
19
  require('./chunk-5XBULBP2.js');
20
20
  require('./chunk-7LXE4KHV.js');
21
- require('./chunk-CQBXHAYR.js');
22
- require('./chunk-TXVH44HM.js');
23
- require('./chunk-QPNEFZB3.js');
21
+ require('./chunk-FHG5GY6F.js');
22
+ require('./chunk-PF3UOCRW.js');
23
+ require('./chunk-5IHLDAOF.js');
24
24
  require('./chunk-5OQ373JS.js');
25
25
  require('./chunk-UGFBA4GV.js');
26
- require('./chunk-O7H2MC7R.js');
26
+ require('./chunk-TZTP4JVA.js');
27
27
  require('./chunk-F3CMU2DM.js');
28
28
  require('./chunk-CXXGL43K.js');
29
29
  require('./chunk-ITDY6AIZ.js');
30
30
  require('./chunk-S6VGOPUY.js');
31
- require('./chunk-W3GAOR7Y.js');
31
+ require('./chunk-VEJ3MIZG.js');
32
32
  require('./chunk-Z4BLTVTB.js');
33
33
 
34
34
 
@@ -36,5 +36,5 @@ require('./chunk-Z4BLTVTB.js');
36
36
 
37
37
 
38
38
 
39
- exports.ApprovalState = _chunkQDIYZX5Vjs.ApprovalState; exports.CANCEL_RATE = _chunkQDIYZX5Vjs.CANCEL_RATE; exports.HARDFORK = _chunkQDIYZX5Vjs.HARDFORK; exports.SPEED_UP_RATE = _chunkQDIYZX5Vjs.SPEED_UP_RATE; exports.TransactionController = _chunkQDIYZX5Vjs.TransactionController;
39
+ exports.ApprovalState = _chunk7BG5XOXJjs.ApprovalState; exports.CANCEL_RATE = _chunk7BG5XOXJjs.CANCEL_RATE; exports.HARDFORK = _chunk7BG5XOXJjs.HARDFORK; exports.SPEED_UP_RATE = _chunk7BG5XOXJjs.SPEED_UP_RATE; exports.TransactionController = _chunk7BG5XOXJjs.TransactionController;
40
40
  //# sourceMappingURL=TransactionController.js.map
@@ -4,31 +4,31 @@ import {
4
4
  HARDFORK,
5
5
  SPEED_UP_RATE,
6
6
  TransactionController
7
- } from "./chunk-72OTU5ZW.mjs";
7
+ } from "./chunk-I6RY3XOG.mjs";
8
8
  import "./chunk-NM6OYEPP.mjs";
9
9
  import "./chunk-XKNFL657.mjs";
10
10
  import "./chunk-XGRAHX6T.mjs";
11
11
  import "./chunk-NHRBO3LU.mjs";
12
- import "./chunk-QSBIXUMB.mjs";
13
- import "./chunk-7XPI7KU5.mjs";
12
+ import "./chunk-BYBPZUHS.mjs";
13
+ import "./chunk-6XMG522E.mjs";
14
14
  import "./chunk-JRBREX22.mjs";
15
- import "./chunk-EEMJC7S7.mjs";
15
+ import "./chunk-5UL3VDFT.mjs";
16
16
  import "./chunk-KFL2GGZC.mjs";
17
17
  import "./chunk-Y7ENNK7L.mjs";
18
18
  import "./chunk-ZQFMTLZJ.mjs";
19
19
  import "./chunk-JRQHIBG5.mjs";
20
20
  import "./chunk-FRKQ3Z2L.mjs";
21
- import "./chunk-K26EBMGI.mjs";
22
- import "./chunk-OF6NSLXF.mjs";
23
- import "./chunk-DTONMSFW.mjs";
21
+ import "./chunk-PGTV7236.mjs";
22
+ import "./chunk-QRSTF45Q.mjs";
23
+ import "./chunk-IK55QTGO.mjs";
24
24
  import "./chunk-3D3SA6PY.mjs";
25
25
  import "./chunk-J56A7UCK.mjs";
26
- import "./chunk-2YXA3K67.mjs";
26
+ import "./chunk-DWHMMJOW.mjs";
27
27
  import "./chunk-IZI7FQIN.mjs";
28
28
  import "./chunk-VEREDMI2.mjs";
29
29
  import "./chunk-Z3HHSD5I.mjs";
30
30
  import "./chunk-UQQWZT6C.mjs";
31
- import "./chunk-NM4LTWRU.mjs";
31
+ import "./chunk-W57BD6NX.mjs";
32
32
  import "./chunk-XUI43LEZ.mjs";
33
33
  export {
34
34
  ApprovalState,
@@ -3,7 +3,7 @@
3
3
  var _chunk5OQ373JSjs = require('./chunk-5OQ373JS.js');
4
4
 
5
5
 
6
- var _chunkO7H2MC7Rjs = require('./chunk-O7H2MC7R.js');
6
+ var _chunkTZTP4JVAjs = require('./chunk-TZTP4JVA.js');
7
7
 
8
8
 
9
9
  var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
@@ -185,7 +185,7 @@ async function getSuggestedGasFees(request) {
185
185
  if (!eip1559 && txMeta.txParams.gasPrice || eip1559 && txMeta.txParams.maxFeePerGas && txMeta.txParams.maxPriorityFeePerGas) {
186
186
  return {};
187
187
  }
188
- const gasFeeFlow = _chunkO7H2MC7Rjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
188
+ const gasFeeFlow = _chunkTZTP4JVAjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
189
189
  try {
190
190
  const response = await gasFeeFlow.getGasFees({
191
191
  ethQuery,
@@ -205,4 +205,4 @@ async function getSuggestedGasFees(request) {
205
205
 
206
206
 
207
207
  exports.updateGasFees = updateGasFees; exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
208
- //# sourceMappingURL=chunk-QPNEFZB3.js.map
208
+ //# sourceMappingURL=chunk-5IHLDAOF.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-KFL2GGZC.mjs";
4
4
  import {
5
5
  getGasFeeFlow
6
- } from "./chunk-2YXA3K67.mjs";
6
+ } from "./chunk-DWHMMJOW.mjs";
7
7
  import {
8
8
  projectLogger
9
9
  } from "./chunk-UQQWZT6C.mjs";
@@ -179,4 +179,4 @@ getUnapprovedTransactions_fn = function() {
179
179
  export {
180
180
  GasFeePoller
181
181
  };
182
- //# sourceMappingURL=chunk-EEMJC7S7.mjs.map
182
+ //# sourceMappingURL=chunk-5UL3VDFT.mjs.map
@@ -0,0 +1,56 @@
1
+ import {
2
+ projectLogger
3
+ } from "./chunk-UQQWZT6C.mjs";
4
+
5
+ // src/utils/simulation-api.ts
6
+ import { convertHexToDecimal } from "@metamask/controller-utils";
7
+ import { createModuleLogger } from "@metamask/utils";
8
+ var log = createModuleLogger(projectLogger, "simulation-api");
9
+ var RPC_METHOD = "infura_simulateTransactions";
10
+ var BASE_URL = "https://tx-sentinel-{0}.api.cx.metamask.io/";
11
+ var ENDPOINT_NETWORKS = "networks";
12
+ var requestIdCounter = 0;
13
+ async function simulateTransactions(chainId, request) {
14
+ const url = await getSimulationUrl(chainId);
15
+ log("Sending request", url, request);
16
+ const requestId = requestIdCounter;
17
+ requestIdCounter += 1;
18
+ const response = await fetch(url, {
19
+ method: "POST",
20
+ body: JSON.stringify({
21
+ id: String(requestId),
22
+ jsonrpc: "2.0",
23
+ method: RPC_METHOD,
24
+ params: [request]
25
+ })
26
+ });
27
+ const responseJson = await response.json();
28
+ log("Received response", responseJson);
29
+ if (responseJson.error) {
30
+ throw responseJson.error;
31
+ }
32
+ return responseJson?.result;
33
+ }
34
+ async function getSimulationUrl(chainId) {
35
+ const networkData = await getNetworkData();
36
+ const chainIdDecimal = convertHexToDecimal(chainId);
37
+ const network = networkData[chainIdDecimal];
38
+ if (!network?.confirmations) {
39
+ log("Chain is not supported", chainId);
40
+ throw new Error(`Chain is not supported: ${chainId}`);
41
+ }
42
+ return getUrl(network.network);
43
+ }
44
+ async function getNetworkData() {
45
+ const url = `${getUrl("ethereum-mainnet")}${ENDPOINT_NETWORKS}`;
46
+ const response = await fetch(url);
47
+ return response.json();
48
+ }
49
+ function getUrl(subdomain) {
50
+ return BASE_URL.replace("{0}", subdomain);
51
+ }
52
+
53
+ export {
54
+ simulateTransactions
55
+ };
56
+ //# sourceMappingURL=chunk-6XMG522E.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/simulation-api.ts"],"sourcesContent":["import { convertHexToDecimal } from '@metamask/controller-utils';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\n\nconst log = createModuleLogger(projectLogger, 'simulation-api');\n\nconst RPC_METHOD = 'infura_simulateTransactions';\nconst BASE_URL = 'https://tx-sentinel-{0}.api.cx.metamask.io/';\nconst ENDPOINT_NETWORKS = 'networks';\n\n/** Single transaction to simulate in a simulation API request. */\nexport type SimulationRequestTransaction = {\n /** Data to send with the transaction. */\n data?: Hex;\n\n /** Sender of the transaction. */\n from: Hex;\n\n /** Gas limit for the transaction. */\n gas?: Hex;\n\n /** Maximum fee per gas for the transaction. */\n maxFeePerGas?: Hex;\n\n /** Maximum priority fee per gas for the transaction. */\n maxPriorityFeePerGas?: Hex;\n\n /** Recipient of the transaction. */\n to?: Hex;\n\n /** Value to send with the transaction. */\n value?: Hex;\n};\n\n/** Request to the simulation API to simulate transactions. */\nexport type SimulationRequest = {\n /**\n * Transactions to be sequentially simulated.\n * State changes impact subsequent transactions in the list.\n */\n transactions: SimulationRequestTransaction[];\n\n /**\n * Overrides to the state of the blockchain, keyed by smart contract address.\n */\n overrides?: {\n [address: Hex]: {\n /** Overrides to the storage slots for a smart contract account. */\n stateDiff: {\n [slot: Hex]: Hex;\n };\n };\n };\n\n /**\n * Whether to include call traces in the response.\n * Defaults to false.\n */\n withCallTrace?: boolean;\n\n /**\n * Whether to include event logs in the response.\n * Defaults to false.\n */\n withLogs?: boolean;\n};\n\n/** Raw event log emitted by a simulated transaction. */\nexport type SimulationResponseLog = {\n /** Address of the account that created the event. */\n address: Hex;\n\n /** Raw data in the event that is not indexed. */\n data: Hex;\n\n /** Raw indexed data from the event. */\n topics: Hex[];\n};\n\n/** Call trace of a single simulated transaction. */\nexport type SimulationResponseCallTrace = {\n /** Nested calls. */\n calls: SimulationResponseCallTrace[];\n\n /** Raw event logs created by the call. */\n logs: SimulationResponseLog[];\n};\n\n/**\n * Changes to the blockchain state.\n * Keyed by account address.\n */\nexport type SimulationResponseStateDiff = {\n [address: Hex]: {\n /** Native balance of the account. */\n balance?: Hex;\n\n /** Nonce of the account. */\n nonce?: Hex;\n\n /** Storage values per slot. */\n storage?: {\n [slot: Hex]: Hex;\n };\n };\n};\n\n/** Response from the simulation API for a single transaction. */\nexport type SimulationResponseTransaction = {\n /** An error message indicating the transaction could not be simulated. */\n error?: string;\n\n /** Return value of the transaction, such as the balance if calling balanceOf. */\n return: Hex;\n\n /** Hierarchy of call data including nested calls and logs. */\n callTrace?: SimulationResponseCallTrace;\n\n /** Changes to the blockchain state. */\n stateDiff?: {\n /** Initial blockchain state before the transaction. */\n pre?: SimulationResponseStateDiff;\n\n /** Updated blockchain state after the transaction. */\n post?: SimulationResponseStateDiff;\n };\n};\n\n/** Response from the simulation API. */\nexport type SimulationResponse = {\n /** Simulation data for each transaction in the request. */\n transactions: SimulationResponseTransaction[];\n};\n\n/** Data for a network supported by the Simulation API. */\ntype SimulationNetwork = {\n /** Subdomain of the API for the network. */\n network: string;\n\n /** Whether the network supports confirmation simulations. */\n confirmations: boolean;\n};\n\n/** Response from the simulation API containing supported networks. */\ntype SimulationNetworkResponse = {\n [chainIdDecimal: string]: SimulationNetwork;\n};\n\nlet requestIdCounter = 0;\n\n/**\n * Simulate transactions using the transaction simulation API.\n * @param chainId - The chain ID to simulate transactions on.\n * @param request - The request to simulate transactions.\n */\nexport async function simulateTransactions(\n chainId: Hex,\n request: SimulationRequest,\n): Promise<SimulationResponse> {\n const url = await getSimulationUrl(chainId);\n\n log('Sending request', url, request);\n\n const requestId = requestIdCounter;\n requestIdCounter += 1;\n\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify({\n id: String(requestId),\n jsonrpc: '2.0',\n method: RPC_METHOD,\n params: [request],\n }),\n });\n\n const responseJson = await response.json();\n\n log('Received response', responseJson);\n\n if (responseJson.error) {\n throw responseJson.error;\n }\n\n return responseJson?.result;\n}\n\n/**\n * Get the URL for the transaction simulation API.\n * @param chainId - The chain ID to get the URL for.\n * @returns The URL for the transaction simulation API.\n */\nasync function getSimulationUrl(chainId: Hex): Promise<string> {\n const networkData = await getNetworkData();\n const chainIdDecimal = convertHexToDecimal(chainId);\n const network = networkData[chainIdDecimal];\n\n if (!network?.confirmations) {\n log('Chain is not supported', chainId);\n throw new Error(`Chain is not supported: ${chainId}`);\n }\n\n return getUrl(network.network);\n}\n\n/**\n * Retrieve the supported network data from the simulation API.\n */\nasync function getNetworkData(): Promise<SimulationNetworkResponse> {\n const url = `${getUrl('ethereum-mainnet')}${ENDPOINT_NETWORKS}`;\n const response = await fetch(url);\n return response.json();\n}\n\n/**\n * Generate the URL for the specified subdomain in the simulation API.\n * @param subdomain - The subdomain to generate the URL for.\n * @returns The URL for the transaction simulation API.\n */\nfunction getUrl(subdomain: string): string {\n return BASE_URL.replace('{0}', subdomain);\n}\n"],"mappings":";;;;;AAAA,SAAS,2BAA2B;AACpC,SAAS,0BAAoC;AAI7C,IAAM,MAAM,mBAAmB,eAAe,gBAAgB;AAE9D,IAAM,aAAa;AACnB,IAAM,WAAW;AACjB,IAAM,oBAAoB;AA4I1B,IAAI,mBAAmB;AAOvB,eAAsB,qBACpB,SACA,SAC6B;AAC7B,QAAM,MAAM,MAAM,iBAAiB,OAAO;AAE1C,MAAI,mBAAmB,KAAK,OAAO;AAEnC,QAAM,YAAY;AAClB,sBAAoB;AAEpB,QAAM,WAAW,MAAM,MAAM,KAAK;AAAA,IAChC,QAAQ;AAAA,IACR,MAAM,KAAK,UAAU;AAAA,MACnB,IAAI,OAAO,SAAS;AAAA,MACpB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,QAAQ,CAAC,OAAO;AAAA,IAClB,CAAC;AAAA,EACH,CAAC;AAED,QAAM,eAAe,MAAM,SAAS,KAAK;AAEzC,MAAI,qBAAqB,YAAY;AAErC,MAAI,aAAa,OAAO;AACtB,UAAM,aAAa;AAAA,EACrB;AAEA,SAAO,cAAc;AACvB;AAOA,eAAe,iBAAiB,SAA+B;AAC7D,QAAM,cAAc,MAAM,eAAe;AACzC,QAAM,iBAAiB,oBAAoB,OAAO;AAClD,QAAM,UAAU,YAAY,cAAc;AAE1C,MAAI,CAAC,SAAS,eAAe;AAC3B,QAAI,0BAA0B,OAAO;AACrC,UAAM,IAAI,MAAM,2BAA2B,OAAO,EAAE;AAAA,EACtD;AAEA,SAAO,OAAO,QAAQ,OAAO;AAC/B;AAKA,eAAe,iBAAqD;AAClE,QAAM,MAAM,GAAG,OAAO,kBAAkB,CAAC,GAAG,iBAAiB;AAC7D,QAAM,WAAW,MAAM,MAAM,GAAG;AAChC,SAAO,SAAS,KAAK;AACvB;AAOA,SAAS,OAAO,WAA2B;AACzC,SAAO,SAAS,QAAQ,OAAO,SAAS;AAC1C;","names":[]}
@@ -17,13 +17,13 @@ var _chunkQP75SWIQjs = require('./chunk-QP75SWIQ.js');
17
17
  var _chunkZNZEJDOEjs = require('./chunk-ZNZEJDOE.js');
18
18
 
19
19
 
20
- var _chunkWXQZIUNWjs = require('./chunk-WXQZIUNW.js');
20
+ var _chunkGC77BSQZjs = require('./chunk-GC77BSQZ.js');
21
21
 
22
22
 
23
23
  var _chunkHS277C77js = require('./chunk-HS277C77.js');
24
24
 
25
25
 
26
- var _chunkBILEZLATjs = require('./chunk-BILEZLAT.js');
26
+ var _chunkQEX3QMSLjs = require('./chunk-QEX3QMSL.js');
27
27
 
28
28
 
29
29
  var _chunkR7NJVDWNjs = require('./chunk-R7NJVDWN.js');
@@ -41,13 +41,13 @@ var _chunk5XBULBP2js = require('./chunk-5XBULBP2.js');
41
41
  var _chunk7LXE4KHVjs = require('./chunk-7LXE4KHV.js');
42
42
 
43
43
 
44
- var _chunkCQBXHAYRjs = require('./chunk-CQBXHAYR.js');
44
+ var _chunkFHG5GY6Fjs = require('./chunk-FHG5GY6F.js');
45
45
 
46
46
 
47
- var _chunkTXVH44HMjs = require('./chunk-TXVH44HM.js');
47
+ var _chunkPF3UOCRWjs = require('./chunk-PF3UOCRW.js');
48
48
 
49
49
 
50
- var _chunkQPNEFZB3js = require('./chunk-QPNEFZB3.js');
50
+ var _chunk5IHLDAOFjs = require('./chunk-5IHLDAOF.js');
51
51
 
52
52
 
53
53
 
@@ -130,7 +130,7 @@ function getDefaultTransactionControllerState() {
130
130
  lastFetchedBlockNumbers: {}
131
131
  };
132
132
  }
133
- var _internalEvents, _incomingTransactionOptions, _pendingTransactionOptions, _transactionHistoryLimit, _isSimulationEnabled, _multichainTrackingHelper, _createNonceTracker, createNonceTracker_fn, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn, _createPendingTransactionTracker, createPendingTransactionTracker_fn, _checkForPendingTransactionAndStartPolling, _stopAllTracking, stopAllTracking_fn, _removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners_fn, _addIncomingTransactionHelperListeners, addIncomingTransactionHelperListeners_fn, _removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners_fn, _addPendingTransactionTrackerListeners, addPendingTransactionTrackerListeners_fn, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn, _getGasFeeFlows, getGasFeeFlows_fn, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn, _updateTransactionInternal, updateTransactionInternal_fn, _simulateTransaction, simulateTransaction_fn;
133
+ var _internalEvents, _incomingTransactionOptions, _pendingTransactionOptions, _transactionHistoryLimit, _isSimulationEnabled, _multichainTrackingHelper, _createNonceTracker, createNonceTracker_fn, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn, _createPendingTransactionTracker, createPendingTransactionTracker_fn, _checkForPendingTransactionAndStartPolling, _stopAllTracking, stopAllTracking_fn, _removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners_fn, _addIncomingTransactionHelperListeners, addIncomingTransactionHelperListeners_fn, _removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners_fn, _addPendingTransactionTrackerListeners, addPendingTransactionTrackerListeners_fn, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn, _getGasFeeFlows, getGasFeeFlows_fn, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn, _updateTransactionInternal, updateTransactionInternal_fn, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn, _updateSimulationData, updateSimulationData_fn;
134
134
  var TransactionController = class extends _basecontroller.BaseController {
135
135
  /**
136
136
  * Constructs a TransactionController.
@@ -210,7 +210,9 @@ var TransactionController = class extends _basecontroller.BaseController {
210
210
  _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getGasFeeFlows);
211
211
  _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getLayer1GasFeeFlows);
212
212
  _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateTransactionInternal);
213
- _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _simulateTransaction);
213
+ _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _checkIfTransactionParamsUpdated);
214
+ _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _onTransactionParamsUpdated);
215
+ _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateSimulationData);
214
216
  _chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _internalEvents, new (0, _events.EventEmitter)());
215
217
  this.inProcessOfSigning = /* @__PURE__ */ new Set();
216
218
  this.mutex = new (0, _asyncmutex.Mutex)();
@@ -298,7 +300,7 @@ var TransactionController = class extends _basecontroller.BaseController {
298
300
  });
299
301
  this.gasFeeFlows = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGasFeeFlows, getGasFeeFlows_fn).call(this);
300
302
  this.layer1GasFeeFlows = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn).call(this);
301
- const gasFeePoller = new (0, _chunkBILEZLATjs.GasFeePoller)({
303
+ const gasFeePoller = new (0, _chunkQEX3QMSLjs.GasFeePoller)({
302
304
  // Default gas fee polling is not yet supported by the clients
303
305
  gasFeeFlows: this.gasFeeFlows.slice(0, -1),
304
306
  getEthQuery: (chainId, networkClientId) => _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).getEthQuery({
@@ -476,10 +478,7 @@ var TransactionController = class extends _basecontroller.BaseController {
476
478
  type: transactionType,
477
479
  networkClientId
478
480
  };
479
- await Promise.all([
480
- this.updateGasProperties(addedTransactionMeta),
481
- _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _simulateTransaction, simulateTransaction_fn).call(this, addedTransactionMeta)
482
- ]);
481
+ await this.updateGasProperties(addedTransactionMeta);
483
482
  if (!existingTransactionMeta) {
484
483
  if (method && this.securityProviderRequest) {
485
484
  const securityProviderResponse = await this.securityProviderRequest(
@@ -505,6 +504,7 @@ var TransactionController = class extends _basecontroller.BaseController {
505
504
  }
506
505
  );
507
506
  this.addMetadata(addedTransactionMeta);
507
+ _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateSimulationData, updateSimulationData_fn).call(this, addedTransactionMeta);
508
508
  this.messagingSystem.publish(
509
509
  `${controllerName}:unapprovedTransactionAdded`,
510
510
  addedTransactionMeta
@@ -1269,6 +1269,10 @@ var TransactionController = class extends _basecontroller.BaseController {
1269
1269
  `${controllerName}:transactionFinished`,
1270
1270
  updatedTransactionMeta
1271
1271
  );
1272
+ _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _internalEvents).emit(
1273
+ `${updatedTransactionMeta.id}:finished`,
1274
+ updatedTransactionMeta
1275
+ );
1272
1276
  }
1273
1277
  }
1274
1278
  /**
@@ -1429,7 +1433,7 @@ var TransactionController = class extends _basecontroller.BaseController {
1429
1433
  isCustomNetwork,
1430
1434
  txMeta: transactionMeta
1431
1435
  });
1432
- await _chunkQPNEFZB3js.updateGasFees.call(void 0, {
1436
+ await _chunk5IHLDAOFjs.updateGasFees.call(void 0, {
1433
1437
  eip1559: isEIP1559Compatible,
1434
1438
  ethQuery,
1435
1439
  gasFeeFlows: this.gasFeeFlows,
@@ -2280,7 +2284,7 @@ getNonceTrackerPendingTransactions_fn = function(chainId, address) {
2280
2284
  };
2281
2285
  _getGasFeeFlows = new WeakSet();
2282
2286
  getGasFeeFlows_fn = function() {
2283
- return [new (0, _chunkCQBXHAYRjs.LineaGasFeeFlow)(), new (0, _chunkTXVH44HMjs.DefaultGasFeeFlow)()];
2287
+ return [new (0, _chunkFHG5GY6Fjs.LineaGasFeeFlow)(), new (0, _chunkPF3UOCRWjs.DefaultGasFeeFlow)()];
2284
2288
  };
2285
2289
  _getLayer1GasFeeFlows = new WeakSet();
2286
2290
  getLayer1GasFeeFlows_fn = function() {
@@ -2293,6 +2297,7 @@ updateTransactionInternal_fn = function(transactionMeta, { note, skipHistory })
2293
2297
  txParams: _chunkUGFBA4GVjs.normalizeTransactionParams.call(void 0, transactionMeta.txParams)
2294
2298
  };
2295
2299
  _chunkVH47Q6TSjs.validateTxParams.call(void 0, normalizedTransaction.txParams);
2300
+ const updatedTransactionParams = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn).call(this, normalizedTransaction);
2296
2301
  const transactionWithUpdatedHistory = skipHistory === true ? normalizedTransaction : _chunkQP75SWIQjs.updateTransactionHistory.call(void 0,
2297
2302
  normalizedTransaction,
2298
2303
  note ?? "Transaction updated"
@@ -2303,23 +2308,74 @@ updateTransactionInternal_fn = function(transactionMeta, { note, skipHistory })
2303
2308
  );
2304
2309
  state.transactions[index] = transactionWithUpdatedHistory;
2305
2310
  });
2311
+ if (updatedTransactionParams.length > 0) {
2312
+ _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn).call(this, normalizedTransaction, updatedTransactionParams);
2313
+ }
2306
2314
  };
2307
- _simulateTransaction = new WeakSet();
2308
- simulateTransaction_fn = async function(transactionMeta) {
2309
- if (!_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _isSimulationEnabled).call(this)) {
2310
- _chunkS6VGOPUYjs.projectLogger.call(void 0, "Skipping simulation as disabled");
2311
- return;
2315
+ _checkIfTransactionParamsUpdated = new WeakSet();
2316
+ checkIfTransactionParamsUpdated_fn = function(newTransactionMeta) {
2317
+ const { id: transactionId, txParams: newParams } = newTransactionMeta;
2318
+ const originalParams = this.getTransaction(transactionId)?.txParams;
2319
+ if (!originalParams || _lodash.isEqual.call(void 0, originalParams, newParams)) {
2320
+ return [];
2321
+ }
2322
+ const params = Object.keys(newParams);
2323
+ const updatedProperties = params.filter(
2324
+ (param) => newParams[param] !== originalParams[param]
2325
+ );
2326
+ _chunkS6VGOPUYjs.projectLogger.call(void 0,
2327
+ "Transaction parameters have been updated",
2328
+ transactionId,
2329
+ updatedProperties,
2330
+ originalParams,
2331
+ newParams
2332
+ );
2333
+ return updatedProperties;
2334
+ };
2335
+ _onTransactionParamsUpdated = new WeakSet();
2336
+ onTransactionParamsUpdated_fn = function(transactionMeta, updatedParams) {
2337
+ if (["to", "value", "data"].some(
2338
+ (param) => updatedParams.includes(param)
2339
+ )) {
2340
+ _chunkS6VGOPUYjs.projectLogger.call(void 0, "Updating simulation data due to transaction parameter update");
2341
+ _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateSimulationData, updateSimulationData_fn).call(this, transactionMeta);
2312
2342
  }
2313
- const { chainId, txParams } = transactionMeta;
2343
+ };
2344
+ _updateSimulationData = new WeakSet();
2345
+ updateSimulationData_fn = async function(transactionMeta) {
2346
+ const { id, chainId, txParams } = transactionMeta;
2314
2347
  const { from, to, value, data } = txParams;
2315
- transactionMeta.simulationData = await _chunkWXQZIUNWjs.getSimulationData.call(void 0, {
2316
- chainId,
2317
- from,
2318
- to,
2319
- value,
2320
- data
2321
- });
2322
- _chunkS6VGOPUYjs.projectLogger.call(void 0, "Retrieved simulation data", transactionMeta.simulationData);
2348
+ let simulationData = {
2349
+ error: {
2350
+ message: "Simulation disabled",
2351
+ isReverted: false
2352
+ },
2353
+ tokenBalanceChanges: []
2354
+ };
2355
+ if (_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _isSimulationEnabled).call(this)) {
2356
+ _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, { ...transactionMeta, simulationData: void 0 }, { skipHistory: true });
2357
+ simulationData = await _chunkGC77BSQZjs.getSimulationData.call(void 0, {
2358
+ chainId,
2359
+ from,
2360
+ to,
2361
+ value,
2362
+ data
2363
+ });
2364
+ }
2365
+ const finalTransactionMeta = this.getTransaction(id);
2366
+ if (!finalTransactionMeta) {
2367
+ _chunkS6VGOPUYjs.projectLogger.call(void 0,
2368
+ "Cannot update simulation data as transaction not found",
2369
+ id,
2370
+ simulationData
2371
+ );
2372
+ return;
2373
+ }
2374
+ this.updateTransaction(
2375
+ { ...finalTransactionMeta, simulationData },
2376
+ "TransactionController#updateSimulationData - Update simulation data"
2377
+ );
2378
+ _chunkS6VGOPUYjs.projectLogger.call(void 0, "Updated simulation data", id, simulationData);
2323
2379
  };
2324
2380
 
2325
2381
 
@@ -2329,4 +2385,4 @@ simulateTransaction_fn = async function(transactionMeta) {
2329
2385
 
2330
2386
 
2331
2387
  exports.HARDFORK = HARDFORK; exports.CANCEL_RATE = CANCEL_RATE; exports.SPEED_UP_RATE = SPEED_UP_RATE; exports.ApprovalState = ApprovalState; exports.TransactionController = TransactionController;
2332
- //# sourceMappingURL=chunk-QDIYZX5V.js.map
2388
+ //# sourceMappingURL=chunk-7BG5XOXJ.js.map