@metamask-previews/transaction-controller 39.0.0-preview-fefbd325 → 39.0.0-preview-e6757fdb

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 (79) hide show
  1. package/dist/TransactionController.cjs +95 -256
  2. package/dist/TransactionController.cjs.map +1 -1
  3. package/dist/TransactionController.d.cts +34 -53
  4. package/dist/TransactionController.d.cts.map +1 -1
  5. package/dist/TransactionController.d.mts +34 -53
  6. package/dist/TransactionController.d.mts.map +1 -1
  7. package/dist/TransactionController.mjs +97 -258
  8. package/dist/TransactionController.mjs.map +1 -1
  9. package/dist/errors.cjs +1 -8
  10. package/dist/errors.cjs.map +1 -1
  11. package/dist/errors.d.cts +0 -4
  12. package/dist/errors.d.cts.map +1 -1
  13. package/dist/errors.d.mts +0 -4
  14. package/dist/errors.d.mts.map +1 -1
  15. package/dist/errors.mjs +0 -6
  16. package/dist/errors.mjs.map +1 -1
  17. package/dist/helpers/EtherscanRemoteTransactionSource.cjs +1 -0
  18. package/dist/helpers/EtherscanRemoteTransactionSource.cjs.map +1 -1
  19. package/dist/helpers/EtherscanRemoteTransactionSource.d.cts.map +1 -1
  20. package/dist/helpers/EtherscanRemoteTransactionSource.d.mts.map +1 -1
  21. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +1 -0
  22. package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +1 -1
  23. package/dist/helpers/GasFeePoller.cjs +4 -4
  24. package/dist/helpers/GasFeePoller.cjs.map +1 -1
  25. package/dist/helpers/GasFeePoller.d.cts +1 -1
  26. package/dist/helpers/GasFeePoller.d.cts.map +1 -1
  27. package/dist/helpers/GasFeePoller.d.mts +1 -1
  28. package/dist/helpers/GasFeePoller.d.mts.map +1 -1
  29. package/dist/helpers/GasFeePoller.mjs +4 -4
  30. package/dist/helpers/GasFeePoller.mjs.map +1 -1
  31. package/dist/helpers/IncomingTransactionHelper.cjs +12 -5
  32. package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -1
  33. package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -1
  34. package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -1
  35. package/dist/helpers/IncomingTransactionHelper.mjs +13 -6
  36. package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
  37. package/dist/helpers/MultichainTrackingHelper.cjs +70 -84
  38. package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -1
  39. package/dist/helpers/MultichainTrackingHelper.d.cts +12 -18
  40. package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -1
  41. package/dist/helpers/MultichainTrackingHelper.d.mts +12 -18
  42. package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -1
  43. package/dist/helpers/MultichainTrackingHelper.mjs +70 -88
  44. package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
  45. package/dist/helpers/PendingTransactionTracker.cjs +24 -22
  46. package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
  47. package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
  48. package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
  49. package/dist/helpers/PendingTransactionTracker.mjs +24 -22
  50. package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
  51. package/dist/types.cjs.map +1 -1
  52. package/dist/types.d.cts +1 -5
  53. package/dist/types.d.cts.map +1 -1
  54. package/dist/types.d.mts +1 -5
  55. package/dist/types.d.mts.map +1 -1
  56. package/dist/types.mjs.map +1 -1
  57. package/dist/utils/etherscan.cjs +2 -1
  58. package/dist/utils/etherscan.cjs.map +1 -1
  59. package/dist/utils/etherscan.d.cts.map +1 -1
  60. package/dist/utils/etherscan.d.mts.map +1 -1
  61. package/dist/utils/etherscan.mjs +3 -2
  62. package/dist/utils/etherscan.mjs.map +1 -1
  63. package/dist/utils/validation.cjs +1 -24
  64. package/dist/utils/validation.cjs.map +1 -1
  65. package/dist/utils/validation.d.cts +0 -7
  66. package/dist/utils/validation.d.cts.map +1 -1
  67. package/dist/utils/validation.d.mts +0 -7
  68. package/dist/utils/validation.d.mts.map +1 -1
  69. package/dist/utils/validation.mjs +0 -22
  70. package/dist/utils/validation.mjs.map +1 -1
  71. package/package.json +1 -1
  72. package/dist/utils/first-time-interaction-api.cjs +0 -46
  73. package/dist/utils/first-time-interaction-api.cjs.map +0 -1
  74. package/dist/utils/first-time-interaction-api.d.cts +0 -20
  75. package/dist/utils/first-time-interaction-api.d.cts.map +0 -1
  76. package/dist/utils/first-time-interaction-api.d.mts +0 -20
  77. package/dist/utils/first-time-interaction-api.d.mts.map +0 -1
  78. package/dist/utils/first-time-interaction-api.mjs +0 -42
  79. package/dist/utils/first-time-interaction-api.mjs.map +0 -1
@@ -13,7 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
13
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
- var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_createNonceTracker, _TransactionController_createIncomingTransactionHelper, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_updateFirstInteraction, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getNetworkClientId, _TransactionController_getGlobalNetworkClientId, _TransactionController_getGlobalChainId, _TransactionController_isCustomNetwork, _TransactionController_getSelectedAccount, _TransactionController_updateSubmitHistory;
16
+ var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createIncomingTransactionHelper, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getSelectedAccount, _TransactionController_updateSubmitHistory;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.HARDFORK = void 0;
19
19
  const common_1 = require("@ethereumjs/common");
@@ -27,7 +27,6 @@ const nonce_tracker_1 = require("@metamask/nonce-tracker");
27
27
  const rpc_errors_1 = require("@metamask/rpc-errors");
28
28
  const utils_1 = require("@metamask/utils");
29
29
  const async_mutex_1 = require("async-mutex");
30
- const eth_method_registry_1 = require("eth-method-registry");
31
30
  const events_1 = require("events");
32
31
  const lodash_1 = require("lodash");
33
32
  const uuid_1 = require("uuid");
@@ -36,7 +35,6 @@ const LineaGasFeeFlow_1 = require("./gas-flows/LineaGasFeeFlow.cjs");
36
35
  const OptimismLayer1GasFeeFlow_1 = require("./gas-flows/OptimismLayer1GasFeeFlow.cjs");
37
36
  const ScrollLayer1GasFeeFlow_1 = require("./gas-flows/ScrollLayer1GasFeeFlow.cjs");
38
37
  const TestGasFeeFlow_1 = require("./gas-flows/TestGasFeeFlow.cjs");
39
- const EtherscanRemoteTransactionSource_1 = require("./helpers/EtherscanRemoteTransactionSource.cjs");
40
38
  const GasFeePoller_1 = require("./helpers/GasFeePoller.cjs");
41
39
  const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper.cjs");
42
40
  const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.cjs");
@@ -44,7 +42,6 @@ const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker
44
42
  const logger_1 = require("./logger.cjs");
45
43
  const types_1 = require("./types.cjs");
46
44
  const external_transactions_1 = require("./utils/external-transactions.cjs");
47
- const first_time_interaction_api_1 = require("./utils/first-time-interaction-api.cjs");
48
45
  const gas_1 = require("./utils/gas.cjs");
49
46
  const gas_fees_1 = require("./utils/gas-fees.cjs");
50
47
  const gas_flow_1 = require("./utils/gas-flow.cjs");
@@ -149,22 +146,10 @@ class TransactionController extends base_controller_1.BaseController {
149
146
  this.messagingSystem.publish(`${controllerName}:transactionFinished`, newTransactionMeta);
150
147
  __classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, newTransactionMeta);
151
148
  }
152
- async registryLookup(fourBytePrefix) {
153
- const registryMethod = await this.registry.lookup(fourBytePrefix);
154
- if (!registryMethod) {
155
- return {
156
- registryMethod: '',
157
- parsedRegistryMethod: { name: undefined, args: undefined },
158
- };
159
- }
160
- const parsedRegistryMethod = this.registry.parse(registryMethod);
161
- return { registryMethod, parsedRegistryMethod };
162
- }
163
149
  /**
164
150
  * Constructs a TransactionController.
165
151
  *
166
152
  * @param options - The controller options.
167
- * @param options.blockTracker - The block tracker used to poll for new blocks data.
168
153
  * @param options.disableHistory - Whether to disable storing history in transaction metadata.
169
154
  * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
170
155
  * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
@@ -177,12 +162,9 @@ class TransactionController extends base_controller_1.BaseController {
177
162
  * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
178
163
  * @param options.getSavedGasFees - Gets the saved gas fee config.
179
164
  * @param options.incomingTransactions - Configuration options for incoming transaction support.
180
- * @param options.isMultichainEnabled - Enable multichain support.
181
165
  * @param options.isSimulationEnabled - Whether new transactions will be automatically simulated.
182
166
  * @param options.messenger - The controller messenger.
183
- * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
184
167
  * @param options.pendingTransactions - Configuration options for pending transaction support.
185
- * @param options.provider - The provider used to create the underlying EthQuery instance.
186
168
  * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
187
169
  * @param options.sign - Function used to sign transactions.
188
170
  * @param options.state - Initial state to set on this controller.
@@ -191,7 +173,7 @@ class TransactionController extends base_controller_1.BaseController {
191
173
  * @param options.transactionHistoryLimit - Transaction history limit.
192
174
  * @param options.hooks - The controller hooks.
193
175
  */
194
- constructor({ blockTracker, disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isMultichainEnabled = false, isSimulationEnabled, messenger, onNetworkStateChange, pendingTransactions = {}, provider, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, }) {
176
+ constructor({ disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isSimulationEnabled, messenger, pendingTransactions = {}, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, }) {
195
177
  super({
196
178
  name: controllerName,
197
179
  metadata,
@@ -212,10 +194,19 @@ class TransactionController extends base_controller_1.BaseController {
212
194
  _TransactionController_transactionHistoryLimit.set(this, void 0);
213
195
  _TransactionController_isSimulationEnabled.set(this, void 0);
214
196
  _TransactionController_testGasFeeFlows.set(this, void 0);
197
+ // private async registryLookup(fourBytePrefix: string): Promise<MethodData> {
198
+ // const registryMethod = await this.registry.lookup(fourBytePrefix);
199
+ // if (!registryMethod) {
200
+ // return {
201
+ // registryMethod: '',
202
+ // parsedRegistryMethod: { name: undefined, args: undefined },
203
+ // };
204
+ // }
205
+ // const parsedRegistryMethod = this.registry.parse(registryMethod);
206
+ // return { registryMethod, parsedRegistryMethod };
207
+ // }
215
208
  _TransactionController_multichainTrackingHelper.set(this, void 0);
216
209
  _TransactionController_checkForPendingTransactionAndStartPolling.set(this, () => {
217
- // PendingTransactionTracker reads state through its getTransactions hook
218
- this.pendingTransactionTracker.startIfPendingTransactions();
219
210
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
220
211
  });
221
212
  this.messagingSystem = messenger;
@@ -224,8 +215,6 @@ class TransactionController extends base_controller_1.BaseController {
224
215
  this.isHistoryDisabled = disableHistory ?? false;
225
216
  this.isSwapsDisabled = disableSwaps ?? false;
226
217
  __classPrivateFieldSet(this, _TransactionController_isSimulationEnabled, isSimulationEnabled ?? (() => true), "f");
227
- // @ts-expect-error the type in eth-method-registry is inappropriate and should be changed
228
- this.registry = new eth_method_registry_1.MethodRegistry({ provider });
229
218
  this.getSavedGasFees = getSavedGasFees ?? ((_chainId) => undefined);
230
219
  this.getCurrentAccountEIP1559Compatibility =
231
220
  getCurrentAccountEIP1559Compatibility ?? (() => Promise.resolve(true));
@@ -253,17 +242,10 @@ class TransactionController extends base_controller_1.BaseController {
253
242
  hooks?.getAdditionalSignArguments ?? (() => []);
254
243
  this.publish =
255
244
  hooks?.publish ?? (() => Promise.resolve({ transactionHash: undefined }));
256
- this.nonceTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).call(this, {
257
- provider,
258
- blockTracker,
259
- });
260
245
  const findNetworkClientIdByChainId = (chainId) => {
261
246
  return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
262
247
  };
263
248
  __classPrivateFieldSet(this, _TransactionController_multichainTrackingHelper, new MultichainTrackingHelper_1.MultichainTrackingHelper({
264
- isMultichainEnabled,
265
- provider,
266
- nonceTracker: this.nonceTracker,
267
249
  incomingTransactionOptions: incomingTransactions,
268
250
  findNetworkClientIdByChainId,
269
251
  getNetworkClientById: ((networkClientId) => {
@@ -280,28 +262,13 @@ class TransactionController extends base_controller_1.BaseController {
280
262
  },
281
263
  }), "f");
282
264
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").initialize();
283
- const etherscanRemoteTransactionSource = new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
284
- apiKeysByChainId: incomingTransactions.etherscanApiKeysByChainId,
285
- includeTokenTransfers: incomingTransactions.includeTokenTransfers,
286
- });
287
- this.incomingTransactionHelper = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).call(this, {
288
- blockTracker,
289
- etherscanRemoteTransactionSource,
290
- });
291
- this.pendingTransactionTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).call(this, {
292
- provider,
293
- blockTracker,
294
- });
295
265
  this.gasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeFlows).call(this);
296
266
  this.layer1GasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getLayer1GasFeeFlows).call(this);
297
267
  const gasFeePoller = new GasFeePoller_1.GasFeePoller({
298
268
  findNetworkClientIdByChainId,
299
269
  gasFeeFlows: this.gasFeeFlows,
300
270
  getGasFeeControllerEstimates: this.getGasFeeEstimates,
301
- getProvider: (chainId, networkClientId) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
302
- networkClientId,
303
- chainId,
304
- }),
271
+ getProvider: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId }),
305
272
  getTransactions: () => this.state.transactions,
306
273
  layer1GasFeeFlows: this.layer1GasFeeFlows,
307
274
  onStateChange: (listener) => {
@@ -312,12 +279,6 @@ class TransactionController extends base_controller_1.BaseController {
312
279
  // when transactionsController state changes
313
280
  // check for pending transactions and start polling if there are any
314
281
  this.messagingSystem.subscribe('TransactionController:stateChange', __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
315
- // TODO once v2 is merged make sure this only runs when
316
- // selectedNetworkClientId changes
317
- onNetworkStateChange(() => {
318
- (0, logger_1.projectLogger)('Detected network change', this.getChainId());
319
- this.pendingTransactionTracker.startIfPendingTransactions();
320
- });
321
282
  this.onBootCleanup();
322
283
  __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
323
284
  }
@@ -330,26 +291,11 @@ class TransactionController extends base_controller_1.BaseController {
330
291
  /**
331
292
  * Handle new method data request.
332
293
  *
333
- * @param fourBytePrefix - The method prefix.
294
+ * @param _fourBytePrefix - The method prefix.
334
295
  * @returns The method data object corresponding to the given signature prefix.
335
296
  */
336
- async handleMethodData(fourBytePrefix) {
337
- const releaseLock = await this.mutex.acquire();
338
- try {
339
- const { methodData } = this.state;
340
- const knownMethod = Object.keys(methodData).find((knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix);
341
- if (knownMethod) {
342
- return methodData[fourBytePrefix];
343
- }
344
- const registry = await this.registryLookup(fourBytePrefix);
345
- this.update((state) => {
346
- state.methodData[fourBytePrefix] = registry;
347
- });
348
- return registry;
349
- }
350
- finally {
351
- releaseLock();
352
- }
297
+ async handleMethodData(_fourBytePrefix) {
298
+ throw new Error('Method not implemented.');
353
299
  }
354
300
  /**
355
301
  * Add a new unapproved transaction to state. Parameters will be validated, a
@@ -357,40 +303,38 @@ class TransactionController extends base_controller_1.BaseController {
357
303
  * if not provided. If A `<tx.id>:unapproved` hub event will be emitted once added.
358
304
  *
359
305
  * @param txParams - Standard parameters for an Ethereum transaction.
360
- * @param opts - Additional options to control how the transaction is added.
361
- * @param opts.actionId - Unique ID to prevent duplicate requests.
362
- * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
363
- * @param opts.method - RPC method that requested the transaction.
364
- * @param opts.origin - The origin of the transaction request, such as a dApp hostname.
365
- * @param opts.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
366
- * @param opts.securityAlertResponse - Response from security validator.
367
- * @param opts.sendFlowHistory - The sendFlowHistory entries to add.
368
- * @param opts.type - Type of transaction to add, such as 'cancel' or 'swap'.
369
- * @param opts.swaps - Options for swaps transactions.
370
- * @param opts.swaps.hasApproveTx - Whether the transaction has an approval transaction.
371
- * @param opts.swaps.meta - Metadata for swap transaction.
372
- * @param opts.networkClientId - The id of the network client for this transaction.
373
- * @param opts.traceContext - The parent context for any new traces.
306
+ * @param options - Additional options to control how the transaction is added.
307
+ * @param options.actionId - Unique ID to prevent duplicate requests.
308
+ * @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
309
+ * @param options.method - RPC method that requested the transaction.
310
+ * @param options.origin - The origin of the transaction request, such as a dApp hostname.
311
+ * @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
312
+ * @param options.securityAlertResponse - Response from security validator.
313
+ * @param options.sendFlowHistory - The sendFlowHistory entries to add.
314
+ * @param options.type - Type of transaction to add, such as 'cancel' or 'swap'.
315
+ * @param options.swaps - Options for swaps transactions.
316
+ * @param options.swaps.hasApproveTx - Whether the transaction has an approval transaction.
317
+ * @param options.swaps.meta - Metadata for swap transaction.
318
+ * @param options.networkClientId - The id of the network client for this transaction.
319
+ * @param options.traceContext - The parent context for any new traces.
374
320
  * @returns Object containing a promise resolving to the transaction hash if approved.
375
321
  */
376
- async addTransaction(txParams, { actionId, deviceConfirmedOn, method, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, networkClientId: requestNetworkClientId, } = {}) {
377
- (0, logger_1.projectLogger)('Adding transaction', txParams);
322
+ async addTransaction(txParams, options) {
323
+ (0, logger_1.projectLogger)('Adding transaction', txParams, options);
324
+ const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
378
325
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
379
- if (requestNetworkClientId &&
380
- !__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(requestNetworkClientId)) {
381
- throw new Error('The networkClientId for this transaction could not be found');
326
+ if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
327
+ throw new Error(`Network client not found - ${networkClientId}`);
382
328
  }
383
- const networkClientId = requestNetworkClientId ?? __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
384
329
  const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
385
330
  (0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
386
331
  if (origin && this.getPermittedAccounts) {
387
332
  await (0, validation_1.validateTransactionOrigin)(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
388
333
  }
389
334
  const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
390
- const chainId = this.getChainId(networkClientId);
391
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
335
+ const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
336
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
392
337
  networkClientId,
393
- chainId,
394
338
  });
395
339
  const transactionType = type ?? (await (0, transaction_type_1.determineTransactionType)(txParams, ethQuery)).type;
396
340
  const existingTransactionMeta = this.getTransactionWithActionId(actionId);
@@ -445,12 +389,6 @@ class TransactionController extends base_controller_1.BaseController {
445
389
  (0, logger_1.projectLogger)('Error while updating simulation data', error);
446
390
  throw error;
447
391
  });
448
- __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateFirstInteraction).call(this, addedTransactionMeta, {
449
- traceContext,
450
- }).catch((error) => {
451
- (0, logger_1.projectLogger)('Error while updating first interaction', error);
452
- throw error;
453
- });
454
392
  }
455
393
  else {
456
394
  (0, logger_1.projectLogger)('Skipping simulation as approval not required');
@@ -467,29 +405,13 @@ class TransactionController extends base_controller_1.BaseController {
467
405
  transactionMeta: addedTransactionMeta,
468
406
  };
469
407
  }
470
- startIncomingTransactionPolling(networkClientIds = []) {
471
- if (networkClientIds.length === 0) {
472
- this.incomingTransactionHelper.start();
473
- return;
474
- }
408
+ startIncomingTransactionPolling(networkClientIds) {
475
409
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").startIncomingTransactionPolling(networkClientIds);
476
410
  }
477
- stopIncomingTransactionPolling(networkClientIds = []) {
478
- if (networkClientIds.length === 0) {
479
- this.incomingTransactionHelper.stop();
480
- return;
481
- }
411
+ stopIncomingTransactionPolling(networkClientIds) {
482
412
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopIncomingTransactionPolling(networkClientIds);
483
413
  }
484
- stopAllIncomingTransactionPolling() {
485
- this.incomingTransactionHelper.stop();
486
- __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllIncomingTransactionPolling();
487
- }
488
414
  async updateIncomingTransactions(networkClientIds = []) {
489
- if (networkClientIds.length === 0) {
490
- await this.incomingTransactionHelper.update();
491
- return;
492
- }
493
415
  await __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").updateIncomingTransactions(networkClientIds);
494
416
  }
495
417
  /**
@@ -553,7 +475,7 @@ class TransactionController extends base_controller_1.BaseController {
553
475
  * @returns The gas and gas price.
554
476
  */
555
477
  async estimateGas(transaction, networkClientId) {
556
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
478
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
557
479
  networkClientId,
558
480
  });
559
481
  const { estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
@@ -567,7 +489,7 @@ class TransactionController extends base_controller_1.BaseController {
567
489
  * @param networkClientId - The network client id to use for the estimate.
568
490
  */
569
491
  async estimateGasBuffered(transaction, multiplier, networkClientId) {
570
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
492
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
571
493
  networkClientId,
572
494
  });
573
495
  const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
@@ -610,24 +532,21 @@ class TransactionController extends base_controller_1.BaseController {
610
532
  this.updateTransaction(updatedTransactionMeta, `${controllerName}:updatesecurityAlertResponse - securityAlertResponse updated`);
611
533
  }
612
534
  /**
613
- * Removes all transactions from state, optionally based on the current network.
535
+ * Remove transactions from state.
614
536
  *
615
- * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the
616
- * current network. If `true`, all transactions are wiped.
617
- * @param address - If specified, only transactions originating from this address will be
618
- * wiped on current network.
537
+ * @param options - The options bag.
538
+ * @param options.address - Remove transactions from this account only. Defaults to all accounts.
539
+ * @param options.chainId - Remove transactions for the specified chain only. Defaults to all chains.
619
540
  */
620
- wipeTransactions(ignoreNetwork, address) {
621
- /* istanbul ignore next */
622
- if (ignoreNetwork && !address) {
541
+ wipeTransactions({ address, chainId, } = {}) {
542
+ if (!chainId && !address) {
623
543
  this.update((state) => {
624
544
  state.transactions = [];
625
545
  });
626
546
  return;
627
547
  }
628
- const currentChainId = this.getChainId();
629
- const newTransactions = this.state.transactions.filter(({ chainId, txParams }) => {
630
- const isMatchingNetwork = ignoreNetwork || chainId === currentChainId;
548
+ const newTransactions = this.state.transactions.filter(({ chainId: txChainId, txParams }) => {
549
+ const isMatchingNetwork = !chainId || chainId === txChainId;
631
550
  if (!isMatchingNetwork) {
632
551
  return true;
633
552
  }
@@ -817,10 +736,8 @@ class TransactionController extends base_controller_1.BaseController {
817
736
  };
818
737
  editableParams.txParams = (0, lodash_1.pickBy)(editableParams.txParams);
819
738
  const updatedTransaction = (0, lodash_1.merge)({}, transactionMeta, editableParams);
820
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
821
- chainId: transactionMeta.chainId,
822
- networkClientId: transactionMeta.networkClientId,
823
- });
739
+ const { networkClientId } = transactionMeta;
740
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
824
741
  const ethQuery = new eth_query_1.default(provider);
825
742
  const { type } = await (0, transaction_type_1.determineTransactionType)(updatedTransaction.txParams, ethQuery);
826
743
  updatedTransaction.type = type;
@@ -848,19 +765,9 @@ class TransactionController extends base_controller_1.BaseController {
848
765
  return '';
849
766
  }
850
767
  const initialTx = listOfTxParams[0];
851
- const common = this.getCommonConfiguration(initialTx.chainId);
852
- // We need to ensure we get the nonce using the the NonceTracker on the chain matching
853
- // the txParams. In this context we only have chainId available to us, but the
854
- // NonceTrackers are keyed by networkClientId. To workaround this, we attempt to find
855
- // a networkClientId that matches the chainId. As a fallback, the globally selected
856
- // network's NonceTracker will be used instead.
857
- let networkClientId;
858
- try {
859
- networkClientId = this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, initialTx.chainId);
860
- }
861
- catch (err) {
862
- (0, logger_1.projectLogger)('failed to find networkClientId from chainId', err);
863
- }
768
+ const { chainId } = initialTx;
769
+ const common = this.getCommonConfiguration(chainId);
770
+ const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
864
771
  const initialTxAsEthTx = tx_1.TransactionFactory.fromTxData(initialTx, {
865
772
  common,
866
773
  });
@@ -942,14 +849,12 @@ class TransactionController extends base_controller_1.BaseController {
942
849
  * Search transaction metadata for matching entries.
943
850
  *
944
851
  * @param opts - Options bag.
945
- * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
946
852
  * @param opts.initialList - The transactions to search. Defaults to the current state.
947
- * @param opts.filterToCurrentNetwork - Whether to filter the results to the current network. Defaults to true.
948
853
  * @param opts.limit - The maximum number of transactions to return. No limit by default.
854
+ * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
949
855
  * @returns An array of transactions matching the provided options.
950
856
  */
951
- getTransactions({ searchCriteria = {}, initialList, filterToCurrentNetwork = true, limit, } = {}) {
952
- const chainId = this.getChainId();
857
+ getTransactions({ initialList, limit, searchCriteria = {}, } = {}) {
953
858
  // searchCriteria is an object that might have values that aren't predicate
954
859
  // methods. When providing any other value type (string, number, etc), we
955
860
  // consider this shorthand for "check the value at key for strict equality
@@ -967,9 +872,6 @@ class TransactionController extends base_controller_1.BaseController {
967
872
  // Combine sortBy and pickBy to transform our state object into an array of
968
873
  // matching transactions that are sorted by time.
969
874
  const filteredTransactions = (0, lodash_1.sortBy)((0, lodash_1.pickBy)(transactionsToFilter, (transaction) => {
970
- if (filterToCurrentNetwork && transaction.chainId !== chainId) {
971
- return false;
972
- }
973
875
  // iterate over the predicateMethods keys to check if the transaction
974
876
  // matches the searchCriteria
975
877
  for (const [key, predicate] of Object.entries(predicateMethods)) {
@@ -1025,9 +927,9 @@ class TransactionController extends base_controller_1.BaseController {
1025
927
  return filteredTransactions;
1026
928
  }
1027
929
  async estimateGasFee({ transactionParams, chainId, networkClientId: requestNetworkClientId, }) {
1028
- const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, {
1029
- networkClientId: requestNetworkClientId,
930
+ const { id: networkClientId, provider } = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1030
931
  chainId,
932
+ networkClientId: requestNetworkClientId,
1031
933
  });
1032
934
  const transactionMeta = {
1033
935
  txParams: transactionParams,
@@ -1036,10 +938,7 @@ class TransactionController extends base_controller_1.BaseController {
1036
938
  };
1037
939
  // Guaranteed as the default gas fee flow matches all transactions.
1038
940
  const gasFeeFlow = (0, gas_flow_1.getGasFeeFlow)(transactionMeta, this.gasFeeFlows);
1039
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1040
- networkClientId,
1041
- chainId,
1042
- });
941
+ const ethQuery = new eth_query_1.default(provider);
1043
942
  const gasFeeControllerData = await this.getGasFeeEstimates({
1044
943
  networkClientId,
1045
944
  });
@@ -1058,9 +957,9 @@ class TransactionController extends base_controller_1.BaseController {
1058
957
  * @param request.networkClientId - The ID of a specific network client to process the transaction.
1059
958
  */
1060
959
  async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
1061
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
1062
- networkClientId,
960
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, {
1063
961
  chainId,
962
+ networkClientId,
1064
963
  });
1065
964
  return await (0, layer1_gas_fee_flow_1.getTransactionLayer1GasFee)({
1066
965
  layer1GasFeeFlows: this.layer1GasFeeFlows,
@@ -1131,15 +1030,10 @@ class TransactionController extends base_controller_1.BaseController {
1131
1030
  const isEIP1559Compatible = transactionMeta.txParams.type !== types_1.TransactionEnvelopeType.legacy &&
1132
1031
  (await this.getEIP1559Compatibility(transactionMeta.networkClientId));
1133
1032
  const { networkClientId, chainId } = transactionMeta;
1134
- const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isCustomNetwork).call(this, networkClientId);
1135
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1136
- networkClientId,
1137
- chainId,
1138
- });
1139
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
1140
- networkClientId,
1141
- chainId,
1142
- });
1033
+ const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1034
+ .configuration.type === network_controller_1.NetworkClientType.Custom;
1035
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1036
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
1143
1037
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
1144
1038
  await (0, gas_1.updateGas)({
1145
1039
  ethQuery,
@@ -1297,10 +1191,8 @@ class TransactionController extends base_controller_1.BaseController {
1297
1191
  if (!rawTx) {
1298
1192
  return ApprovalState.NotApproved;
1299
1193
  }
1300
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1301
- networkClientId: transactionMeta.networkClientId,
1302
- chainId: transactionMeta.chainId,
1303
- });
1194
+ const { networkClientId } = transactionMeta;
1195
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1304
1196
  let preTxBalance;
1305
1197
  const shouldUpdatePreTxBalance = transactionMeta.type === types_1.TransactionType.swap;
1306
1198
  if (shouldUpdatePreTxBalance) {
@@ -1494,14 +1386,6 @@ class TransactionController extends base_controller_1.BaseController {
1494
1386
  const isCompleted = this.isLocalFinalState(transaction.status);
1495
1387
  return { meta: transaction, isCompleted };
1496
1388
  }
1497
- getChainId(networkClientId) {
1498
- const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
1499
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
1500
- if (!networkClientId || networkClientId === globalNetworkClientId) {
1501
- return globalChainId;
1502
- }
1503
- return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.chainId;
1504
- }
1505
1389
  prepareUnsignedEthTx(chainId, txParams) {
1506
1390
  return tx_1.TransactionFactory.fromTxData(txParams, {
1507
1391
  freeze: false,
@@ -1727,7 +1611,7 @@ class TransactionController extends base_controller_1.BaseController {
1727
1611
  transactionMeta,
1728
1612
  });
1729
1613
  }
1730
- getNonceTrackerTransactions(status, address, chainId = this.getChainId()) {
1614
+ getNonceTrackerTransactions(status, address, chainId) {
1731
1615
  return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address, status, this.state.transactions);
1732
1616
  }
1733
1617
  onConfirmedTransaction(transactionMeta) {
@@ -1743,13 +1627,11 @@ class TransactionController extends base_controller_1.BaseController {
1743
1627
  }
1744
1628
  async updatePostBalance(transactionMeta) {
1745
1629
  try {
1746
- if (transactionMeta.type !== types_1.TransactionType.swap) {
1630
+ const { networkClientId, type } = transactionMeta;
1631
+ if (type !== types_1.TransactionType.swap) {
1747
1632
  return;
1748
1633
  }
1749
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1750
- networkClientId: transactionMeta.networkClientId,
1751
- chainId: transactionMeta.chainId,
1752
- });
1634
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1753
1635
  const { updatedTransactionMeta, approvalTransactionMeta } = await (0, swaps_1.updatePostTransactionBalance)(transactionMeta, {
1754
1636
  ethQuery,
1755
1637
  getTransaction: this.getTransaction.bind(this),
@@ -1771,7 +1653,6 @@ class TransactionController extends base_controller_1.BaseController {
1771
1653
  }
1772
1654
  catch (error) {
1773
1655
  if (this.isTransactionAlreadyConfirmedError(error)) {
1774
- await this.pendingTransactionTracker.forceCheckTransaction(transactionMeta);
1775
1656
  throw new Error('Previous transaction is already confirmed');
1776
1657
  }
1777
1658
  throw error;
@@ -1827,10 +1708,8 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1827
1708
  newFee,
1828
1709
  txParams: newTxParams,
1829
1710
  });
1830
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1831
- networkClientId: transactionMeta.networkClientId,
1832
- chainId: transactionMeta.chainId,
1833
- });
1711
+ const { networkClientId } = transactionMeta;
1712
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1834
1713
  const newTransactionMeta = {
1835
1714
  ...transactionMetaWithRsv,
1836
1715
  actionId,
@@ -1859,6 +1738,23 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1859
1738
  actionId,
1860
1739
  });
1861
1740
  afterSubmit?.(newTransactionMeta);
1741
+ }, _TransactionController_getChainId = function _TransactionController_getChainId(networkClientId) {
1742
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1743
+ .configuration.chainId;
1744
+ }, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ chainId, networkClientId, }) {
1745
+ if (networkClientId) {
1746
+ return networkClientId;
1747
+ }
1748
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1749
+ chainId,
1750
+ }).id;
1751
+ }, _TransactionController_getEthQuery = function _TransactionController_getEthQuery({ chainId, networkClientId, }) {
1752
+ return new eth_query_1.default(__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { chainId, networkClientId }));
1753
+ }, _TransactionController_getProvider = function _TransactionController_getProvider({ chainId, networkClientId, }) {
1754
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1755
+ chainId,
1756
+ networkClientId,
1757
+ }).provider;
1862
1758
  }, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
1863
1759
  return new nonce_tracker_1.NonceTracker({
1864
1760
  // TODO: Fix types
@@ -1867,7 +1763,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1867
1763
  // TODO: Fix types
1868
1764
  blockTracker,
1869
1765
  getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
1870
- getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed),
1766
+ getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed, chainId),
1871
1767
  });
1872
1768
  }, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, etherscanRemoteTransactionSource, chainId, }) {
1873
1769
  const incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
@@ -1875,7 +1771,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1875
1771
  getCurrentAccount: () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this),
1876
1772
  getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
1877
1773
  getLocalTransactions: () => this.state.transactions,
1878
- getChainId: chainId ? () => chainId : this.getChainId.bind(this),
1774
+ getChainId: () => chainId,
1879
1775
  isEnabled: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").isEnabled,
1880
1776
  queryEntireHistory: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").queryEntireHistory,
1881
1777
  remoteTransactionSource: etherscanRemoteTransactionSource,
@@ -1886,15 +1782,14 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1886
1782
  return incomingTransactionHelper;
1887
1783
  }, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, }) {
1888
1784
  const ethQuery = new eth_query_1.default(provider);
1889
- const getChainId = chainId ? () => chainId : this.getChainId.bind(this);
1890
1785
  const pendingTransactionTracker = new PendingTransactionTracker_1.PendingTransactionTracker({
1891
1786
  blockTracker,
1892
- getChainId,
1787
+ getChainId: () => chainId,
1893
1788
  getEthQuery: () => ethQuery,
1894
1789
  getTransactions: () => this.state.transactions,
1895
1790
  isResubmitEnabled: __classPrivateFieldGet(this, _TransactionController_pendingTransactionOptions, "f").isResubmitEnabled,
1896
1791
  getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
1897
- chainId: getChainId(),
1792
+ chainId,
1898
1793
  }),
1899
1794
  publishTransaction: (_ethQuery, transactionMeta) => this.publishTransaction(_ethQuery, transactionMeta, {
1900
1795
  skipSubmitHistory: true,
@@ -1907,10 +1802,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1907
1802
  __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
1908
1803
  return pendingTransactionTracker;
1909
1804
  }, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
1910
- this.pendingTransactionTracker.stop();
1911
- __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).call(this, this.pendingTransactionTracker);
1912
- this.incomingTransactionHelper.stop();
1913
- __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).call(this, this.incomingTransactionHelper);
1914
1805
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
1915
1806
  }, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
1916
1807
  incomingTransactionHelper.hub.removeAllListeners('transactions');
@@ -1970,38 +1861,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1970
1861
  });
1971
1862
  }
1972
1863
  return transactionMeta;
1973
- }, _TransactionController_updateFirstInteraction = async function _TransactionController_updateFirstInteraction(transactionMeta, { traceContext, } = {}) {
1974
- const { chainId, id: transactionId, txParams: { to, from }, } = transactionMeta;
1975
- const request = {
1976
- chainId,
1977
- to,
1978
- from,
1979
- };
1980
- let firstTimeInteractionResponse;
1981
- try {
1982
- (0, validation_1.validateFirstTimeInteraction)(request);
1983
- firstTimeInteractionResponse = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'FirstTimeInteraction', parentContext: traceContext }, () => (0, first_time_interaction_api_1.getFirstTimeInteraction)(request));
1984
- }
1985
- catch (error) {
1986
- (0, logger_1.projectLogger)('Error during first interaction check', error);
1987
- firstTimeInteractionResponse = {
1988
- isFirstTimeInteraction: undefined,
1989
- };
1990
- }
1991
- const finalTransactionMeta = this.getTransaction(transactionId);
1992
- /* istanbul ignore if */
1993
- if (!finalTransactionMeta) {
1994
- (0, logger_1.projectLogger)('Cannot update first time interaction as transaction not found', transactionId, firstTimeInteractionResponse);
1995
- return;
1996
- }
1997
- __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
1998
- transactionId,
1999
- note: 'TransactionController#updateFirstInteraction - Update first time interaction',
2000
- }, (txMeta) => {
2001
- txMeta.firstTimeInteraction =
2002
- firstTimeInteractionResponse.isFirstTimeInteraction;
2003
- });
2004
- (0, logger_1.projectLogger)('Updated first time interaction', transactionId, firstTimeInteractionResponse);
2005
1864
  }, _TransactionController_updateSimulationData = async function _TransactionController_updateSimulationData(transactionMeta, { blockTime, traceContext, } = {}) {
2006
1865
  const { id: transactionId, chainId, txParams, simulationData: prevSimulationData, } = transactionMeta;
2007
1866
  const { from, to, value, data } = txParams;
@@ -2057,26 +1916,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
2057
1916
  txMeta.layer1GasFee = layer1GasFee;
2058
1917
  }
2059
1918
  });
2060
- }, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ networkClientId: requestNetworkClientId, chainId, }) {
2061
- const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
2062
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
2063
- if (requestNetworkClientId) {
2064
- return requestNetworkClientId;
2065
- }
2066
- if (!chainId || chainId === globalChainId) {
2067
- return globalNetworkClientId;
2068
- }
2069
- return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
2070
- }, _TransactionController_getGlobalNetworkClientId = function _TransactionController_getGlobalNetworkClientId() {
2071
- return this.getNetworkState().selectedNetworkClientId;
2072
- }, _TransactionController_getGlobalChainId = function _TransactionController_getGlobalChainId() {
2073
- return this.messagingSystem.call(`NetworkController:getNetworkClientById`, this.getNetworkState().selectedNetworkClientId).configuration.chainId;
2074
- }, _TransactionController_isCustomNetwork = function _TransactionController_isCustomNetwork(networkClientId) {
2075
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
2076
- if (!networkClientId || networkClientId === globalNetworkClientId) {
2077
- return !(0, controller_utils_1.isInfuraNetworkType)(this.getNetworkState().selectedNetworkClientId);
2078
- }
2079
- return (this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.type === network_controller_1.NetworkClientType.Custom);
2080
1919
  }, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
2081
1920
  return this.messagingSystem.call('AccountsController:getSelectedAccount');
2082
1921
  }, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {