@metamask/transaction-controller 40.1.0 → 41.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/README.md +4 -0
  3. package/dist/TransactionController.cjs +116 -227
  4. package/dist/TransactionController.cjs.map +1 -1
  5. package/dist/TransactionController.d.cts +34 -52
  6. package/dist/TransactionController.d.cts.map +1 -1
  7. package/dist/TransactionController.d.mts +34 -52
  8. package/dist/TransactionController.d.mts.map +1 -1
  9. package/dist/TransactionController.mjs +119 -232
  10. package/dist/TransactionController.mjs.map +1 -1
  11. package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs +1 -2
  12. package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -1
  13. package/dist/helpers/EtherscanRemoteTransactionSource.cjs +13 -12
  14. package/dist/helpers/EtherscanRemoteTransactionSource.cjs.map +1 -1
  15. package/dist/helpers/EtherscanRemoteTransactionSource.d.cts.map +1 -1
  16. package/dist/helpers/EtherscanRemoteTransactionSource.d.mts.map +1 -1
  17. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +13 -12
  18. package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +1 -1
  19. package/dist/helpers/GasFeePoller.cjs +6 -4
  20. package/dist/helpers/GasFeePoller.cjs.map +1 -1
  21. package/dist/helpers/GasFeePoller.d.cts +1 -1
  22. package/dist/helpers/GasFeePoller.d.cts.map +1 -1
  23. package/dist/helpers/GasFeePoller.d.mts +1 -1
  24. package/dist/helpers/GasFeePoller.d.mts.map +1 -1
  25. package/dist/helpers/GasFeePoller.mjs +6 -4
  26. package/dist/helpers/GasFeePoller.mjs.map +1 -1
  27. package/dist/helpers/IncomingTransactionHelper.cjs +20 -11
  28. package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -1
  29. package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -1
  30. package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -1
  31. package/dist/helpers/IncomingTransactionHelper.mjs +21 -12
  32. package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
  33. package/dist/helpers/MethodDataHelper.cjs +80 -0
  34. package/dist/helpers/MethodDataHelper.cjs.map +1 -0
  35. package/dist/helpers/MethodDataHelper.d.cts +14 -0
  36. package/dist/helpers/MethodDataHelper.d.cts.map +1 -0
  37. package/dist/helpers/MethodDataHelper.d.mts +14 -0
  38. package/dist/helpers/MethodDataHelper.d.mts.map +1 -0
  39. package/dist/helpers/MethodDataHelper.mjs +73 -0
  40. package/dist/helpers/MethodDataHelper.mjs.map +1 -0
  41. package/dist/helpers/MultichainTrackingHelper.cjs +87 -104
  42. package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -1
  43. package/dist/helpers/MultichainTrackingHelper.d.cts +16 -22
  44. package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -1
  45. package/dist/helpers/MultichainTrackingHelper.d.mts +16 -22
  46. package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -1
  47. package/dist/helpers/MultichainTrackingHelper.mjs +88 -109
  48. package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
  49. package/dist/helpers/PendingTransactionTracker.cjs +26 -22
  50. package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
  51. package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
  52. package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
  53. package/dist/helpers/PendingTransactionTracker.mjs +26 -22
  54. package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
  55. package/dist/types.cjs.map +1 -1
  56. package/dist/types.d.cts +7 -3
  57. package/dist/types.d.cts.map +1 -1
  58. package/dist/types.d.mts +7 -3
  59. package/dist/types.d.mts.map +1 -1
  60. package/dist/types.mjs.map +1 -1
  61. package/dist/utils/etherscan.cjs +2 -1
  62. package/dist/utils/etherscan.cjs.map +1 -1
  63. package/dist/utils/etherscan.d.cts.map +1 -1
  64. package/dist/utils/etherscan.d.mts.map +1 -1
  65. package/dist/utils/etherscan.mjs +3 -2
  66. package/dist/utils/etherscan.mjs.map +1 -1
  67. package/package.json +8 -6
@@ -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_isFirstTimeInteractionEnabled, _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_updateFirstTimeInteraction, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getNetworkClientId, _TransactionController_getGlobalNetworkClientId, _TransactionController_getGlobalChainId, _TransactionController_isCustomNetwork, _TransactionController_getSelectedAccount, _TransactionController_updateSubmitHistory;
16
+ var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createRemoteTransactionSource, _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_updateFirstTimeInteraction, _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,8 @@ 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");
30
+ // This package purposefully relies on Node's EventEmitter module.
31
+ // eslint-disable-next-line import/no-nodejs-modules
31
32
  const events_1 = require("events");
32
33
  const lodash_1 = require("lodash");
33
34
  const uuid_1 = require("uuid");
@@ -40,6 +41,7 @@ const TestGasFeeFlow_1 = require("./gas-flows/TestGasFeeFlow.cjs");
40
41
  const EtherscanRemoteTransactionSource_1 = require("./helpers/EtherscanRemoteTransactionSource.cjs");
41
42
  const GasFeePoller_1 = require("./helpers/GasFeePoller.cjs");
42
43
  const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper.cjs");
44
+ const MethodDataHelper_1 = require("./helpers/MethodDataHelper.cjs");
43
45
  const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.cjs");
44
46
  const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
45
47
  const logger_1 = require("./logger.cjs");
@@ -149,22 +151,10 @@ class TransactionController extends base_controller_1.BaseController {
149
151
  this.messagingSystem.publish(`${controllerName}:transactionFinished`, newTransactionMeta);
150
152
  __classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, newTransactionMeta);
151
153
  }
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
154
  /**
164
155
  * Constructs a TransactionController.
165
156
  *
166
157
  * @param options - The controller options.
167
- * @param options.blockTracker - The block tracker used to poll for new blocks data.
168
158
  * @param options.disableHistory - Whether to disable storing history in transaction metadata.
169
159
  * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
170
160
  * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
@@ -177,13 +167,10 @@ class TransactionController extends base_controller_1.BaseController {
177
167
  * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
178
168
  * @param options.getSavedGasFees - Gets the saved gas fee config.
179
169
  * @param options.incomingTransactions - Configuration options for incoming transaction support.
180
- * @param options.isMultichainEnabled - Enable multichain support.
181
170
  * @param options.isFirstTimeInteractionEnabled - Whether first time interaction checks are enabled.
182
171
  * @param options.isSimulationEnabled - Whether new transactions will be automatically simulated.
183
172
  * @param options.messenger - The controller messenger.
184
- * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
185
173
  * @param options.pendingTransactions - Configuration options for pending transaction support.
186
- * @param options.provider - The provider used to create the underlying EthQuery instance.
187
174
  * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
188
175
  * @param options.sign - Function used to sign transactions.
189
176
  * @param options.state - Initial state to set on this controller.
@@ -192,7 +179,7 @@ class TransactionController extends base_controller_1.BaseController {
192
179
  * @param options.transactionHistoryLimit - Transaction history limit.
193
180
  * @param options.hooks - The controller hooks.
194
181
  */
195
- constructor({ blockTracker, disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isMultichainEnabled = false, isFirstTimeInteractionEnabled, isSimulationEnabled, messenger, onNetworkStateChange, pendingTransactions = {}, provider, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, }) {
182
+ constructor({ disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isFirstTimeInteractionEnabled, isSimulationEnabled, messenger, pendingTransactions = {}, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, }) {
196
183
  super({
197
184
  name: controllerName,
198
185
  metadata,
@@ -205,6 +192,7 @@ class TransactionController extends base_controller_1.BaseController {
205
192
  _TransactionController_instances.add(this);
206
193
  _TransactionController_internalEvents.set(this, new events_1.EventEmitter());
207
194
  this.approvingTransactionIds = new Set();
195
+ _TransactionController_methodDataHelper.set(this, void 0);
208
196
  this.mutex = new async_mutex_1.Mutex();
209
197
  _TransactionController_incomingTransactionOptions.set(this, void 0);
210
198
  _TransactionController_pendingTransactionOptions.set(this, void 0);
@@ -216,8 +204,6 @@ class TransactionController extends base_controller_1.BaseController {
216
204
  _TransactionController_testGasFeeFlows.set(this, void 0);
217
205
  _TransactionController_multichainTrackingHelper.set(this, void 0);
218
206
  _TransactionController_checkForPendingTransactionAndStartPolling.set(this, () => {
219
- // PendingTransactionTracker reads state through its getTransactions hook
220
- this.pendingTransactionTracker.startIfPendingTransactions();
221
207
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
222
208
  });
223
209
  this.messagingSystem = messenger;
@@ -227,8 +213,6 @@ class TransactionController extends base_controller_1.BaseController {
227
213
  this.isSwapsDisabled = disableSwaps ?? false;
228
214
  __classPrivateFieldSet(this, _TransactionController_isFirstTimeInteractionEnabled, isFirstTimeInteractionEnabled ?? (() => true), "f");
229
215
  __classPrivateFieldSet(this, _TransactionController_isSimulationEnabled, isSimulationEnabled ?? (() => true), "f");
230
- // @ts-expect-error the type in eth-method-registry is inappropriate and should be changed
231
- this.registry = new eth_method_registry_1.MethodRegistry({ provider });
232
216
  this.getSavedGasFees = getSavedGasFees ?? ((_chainId) => undefined);
233
217
  this.getCurrentAccountEIP1559Compatibility =
234
218
  getCurrentAccountEIP1559Compatibility ?? (() => Promise.resolve(true));
@@ -256,18 +240,10 @@ class TransactionController extends base_controller_1.BaseController {
256
240
  hooks?.getAdditionalSignArguments ?? (() => []);
257
241
  this.publish =
258
242
  hooks?.publish ?? (() => Promise.resolve({ transactionHash: undefined }));
259
- this.nonceTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).call(this, {
260
- provider,
261
- blockTracker,
262
- });
263
243
  const findNetworkClientIdByChainId = (chainId) => {
264
244
  return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
265
245
  };
266
246
  __classPrivateFieldSet(this, _TransactionController_multichainTrackingHelper, new MultichainTrackingHelper_1.MultichainTrackingHelper({
267
- isMultichainEnabled,
268
- provider,
269
- nonceTracker: this.nonceTracker,
270
- incomingTransactionOptions: incomingTransactions,
271
247
  findNetworkClientIdByChainId,
272
248
  getNetworkClientById: ((networkClientId) => {
273
249
  return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId);
@@ -278,33 +254,19 @@ class TransactionController extends base_controller_1.BaseController {
278
254
  createNonceTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).bind(this),
279
255
  createIncomingTransactionHelper: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).bind(this),
280
256
  createPendingTransactionTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).bind(this),
257
+ createRemoteTransactionSource: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createRemoteTransactionSource).bind(this),
281
258
  onNetworkStateChange: (listener) => {
282
259
  this.messagingSystem.subscribe('NetworkController:stateChange', listener);
283
260
  },
284
261
  }), "f");
285
262
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").initialize();
286
- const etherscanRemoteTransactionSource = new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
287
- apiKeysByChainId: incomingTransactions.etherscanApiKeysByChainId,
288
- includeTokenTransfers: incomingTransactions.includeTokenTransfers,
289
- });
290
- this.incomingTransactionHelper = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).call(this, {
291
- blockTracker,
292
- etherscanRemoteTransactionSource,
293
- });
294
- this.pendingTransactionTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).call(this, {
295
- provider,
296
- blockTracker,
297
- });
298
263
  this.gasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeFlows).call(this);
299
264
  this.layer1GasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getLayer1GasFeeFlows).call(this);
300
265
  const gasFeePoller = new GasFeePoller_1.GasFeePoller({
301
266
  findNetworkClientIdByChainId,
302
267
  gasFeeFlows: this.gasFeeFlows,
303
268
  getGasFeeControllerEstimates: this.getGasFeeEstimates,
304
- getProvider: (chainId, networkClientId) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
305
- networkClientId,
306
- chainId,
307
- }),
269
+ getProvider: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId }),
308
270
  getTransactions: () => this.state.transactions,
309
271
  layer1GasFeeFlows: this.layer1GasFeeFlows,
310
272
  onStateChange: (listener) => {
@@ -312,15 +274,18 @@ class TransactionController extends base_controller_1.BaseController {
312
274
  },
313
275
  });
314
276
  gasFeePoller.hub.on('transaction-updated', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onGasFeePollerTransactionUpdate).bind(this));
277
+ __classPrivateFieldSet(this, _TransactionController_methodDataHelper, new MethodDataHelper_1.MethodDataHelper({
278
+ getProvider: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId }),
279
+ getState: () => this.state.methodData,
280
+ }), "f");
281
+ __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").hub.on('update', ({ fourBytePrefix, methodData }) => {
282
+ this.update((_state) => {
283
+ _state.methodData[fourBytePrefix] = methodData;
284
+ });
285
+ });
315
286
  // when transactionsController state changes
316
287
  // check for pending transactions and start polling if there are any
317
288
  this.messagingSystem.subscribe('TransactionController:stateChange', __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
318
- // TODO once v2 is merged make sure this only runs when
319
- // selectedNetworkClientId changes
320
- onNetworkStateChange(() => {
321
- (0, logger_1.projectLogger)('Detected network change', this.getChainId());
322
- this.pendingTransactionTracker.startIfPendingTransactions();
323
- });
324
289
  this.onBootCleanup();
325
290
  __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
326
291
  }
@@ -334,25 +299,11 @@ class TransactionController extends base_controller_1.BaseController {
334
299
  * Handle new method data request.
335
300
  *
336
301
  * @param fourBytePrefix - The method prefix.
302
+ * @param networkClientId - The ID of the network client used to fetch the method data.
337
303
  * @returns The method data object corresponding to the given signature prefix.
338
304
  */
339
- async handleMethodData(fourBytePrefix) {
340
- const releaseLock = await this.mutex.acquire();
341
- try {
342
- const { methodData } = this.state;
343
- const knownMethod = Object.keys(methodData).find((knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix);
344
- if (knownMethod) {
345
- return methodData[fourBytePrefix];
346
- }
347
- const registry = await this.registryLookup(fourBytePrefix);
348
- this.update((state) => {
349
- state.methodData[fourBytePrefix] = registry;
350
- });
351
- return registry;
352
- }
353
- finally {
354
- releaseLock();
355
- }
305
+ async handleMethodData(fourBytePrefix, networkClientId) {
306
+ return __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").lookup(fourBytePrefix, networkClientId);
356
307
  }
357
308
  /**
358
309
  * Add a new unapproved transaction to state. Parameters will be validated, a
@@ -360,40 +311,38 @@ class TransactionController extends base_controller_1.BaseController {
360
311
  * if not provided. If A `<tx.id>:unapproved` hub event will be emitted once added.
361
312
  *
362
313
  * @param txParams - Standard parameters for an Ethereum transaction.
363
- * @param opts - Additional options to control how the transaction is added.
364
- * @param opts.actionId - Unique ID to prevent duplicate requests.
365
- * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
366
- * @param opts.method - RPC method that requested the transaction.
367
- * @param opts.origin - The origin of the transaction request, such as a dApp hostname.
368
- * @param opts.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
369
- * @param opts.securityAlertResponse - Response from security validator.
370
- * @param opts.sendFlowHistory - The sendFlowHistory entries to add.
371
- * @param opts.type - Type of transaction to add, such as 'cancel' or 'swap'.
372
- * @param opts.swaps - Options for swaps transactions.
373
- * @param opts.swaps.hasApproveTx - Whether the transaction has an approval transaction.
374
- * @param opts.swaps.meta - Metadata for swap transaction.
375
- * @param opts.networkClientId - The id of the network client for this transaction.
376
- * @param opts.traceContext - The parent context for any new traces.
314
+ * @param options - Additional options to control how the transaction is added.
315
+ * @param options.actionId - Unique ID to prevent duplicate requests.
316
+ * @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
317
+ * @param options.method - RPC method that requested the transaction.
318
+ * @param options.origin - The origin of the transaction request, such as a dApp hostname.
319
+ * @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
320
+ * @param options.securityAlertResponse - Response from security validator.
321
+ * @param options.sendFlowHistory - The sendFlowHistory entries to add.
322
+ * @param options.type - Type of transaction to add, such as 'cancel' or 'swap'.
323
+ * @param options.swaps - Options for swaps transactions.
324
+ * @param options.swaps.hasApproveTx - Whether the transaction has an approval transaction.
325
+ * @param options.swaps.meta - Metadata for swap transaction.
326
+ * @param options.networkClientId - The id of the network client for this transaction.
327
+ * @param options.traceContext - The parent context for any new traces.
377
328
  * @returns Object containing a promise resolving to the transaction hash if approved.
378
329
  */
379
- async addTransaction(txParams, { actionId, deviceConfirmedOn, method, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, networkClientId: requestNetworkClientId, } = {}) {
380
- (0, logger_1.projectLogger)('Adding transaction', txParams);
330
+ async addTransaction(txParams, options) {
331
+ (0, logger_1.projectLogger)('Adding transaction', txParams, options);
332
+ const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
381
333
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
382
- if (requestNetworkClientId &&
383
- !__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(requestNetworkClientId)) {
384
- throw new Error('The networkClientId for this transaction could not be found');
334
+ if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
335
+ throw new Error(`Network client not found - ${networkClientId}`);
385
336
  }
386
- const networkClientId = requestNetworkClientId ?? __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
387
337
  const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
388
338
  (0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
389
339
  if (origin && this.getPermittedAccounts) {
390
340
  await (0, validation_1.validateTransactionOrigin)(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
391
341
  }
392
342
  const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
393
- const chainId = this.getChainId(networkClientId);
394
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
343
+ const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
344
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
395
345
  networkClientId,
396
- chainId,
397
346
  });
398
347
  const transactionType = type ?? (await (0, transaction_type_1.determineTransactionType)(txParams, ethQuery)).type;
399
348
  const existingTransactionMeta = this.getTransactionWithActionId(actionId);
@@ -470,29 +419,13 @@ class TransactionController extends base_controller_1.BaseController {
470
419
  transactionMeta: addedTransactionMeta,
471
420
  };
472
421
  }
473
- startIncomingTransactionPolling(networkClientIds = []) {
474
- if (networkClientIds.length === 0) {
475
- this.incomingTransactionHelper.start();
476
- return;
477
- }
422
+ startIncomingTransactionPolling(networkClientIds) {
478
423
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").startIncomingTransactionPolling(networkClientIds);
479
424
  }
480
- stopIncomingTransactionPolling(networkClientIds = []) {
481
- if (networkClientIds.length === 0) {
482
- this.incomingTransactionHelper.stop();
483
- return;
484
- }
425
+ stopIncomingTransactionPolling(networkClientIds) {
485
426
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopIncomingTransactionPolling(networkClientIds);
486
427
  }
487
- stopAllIncomingTransactionPolling() {
488
- this.incomingTransactionHelper.stop();
489
- __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllIncomingTransactionPolling();
490
- }
491
428
  async updateIncomingTransactions(networkClientIds = []) {
492
- if (networkClientIds.length === 0) {
493
- await this.incomingTransactionHelper.update();
494
- return;
495
- }
496
429
  await __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").updateIncomingTransactions(networkClientIds);
497
430
  }
498
431
  /**
@@ -556,7 +489,7 @@ class TransactionController extends base_controller_1.BaseController {
556
489
  * @returns The gas and gas price.
557
490
  */
558
491
  async estimateGas(transaction, networkClientId) {
559
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
492
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
560
493
  networkClientId,
561
494
  });
562
495
  const { estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
@@ -570,7 +503,7 @@ class TransactionController extends base_controller_1.BaseController {
570
503
  * @param networkClientId - The network client id to use for the estimate.
571
504
  */
572
505
  async estimateGasBuffered(transaction, multiplier, networkClientId) {
573
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
506
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
574
507
  networkClientId,
575
508
  });
576
509
  const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
@@ -613,24 +546,21 @@ class TransactionController extends base_controller_1.BaseController {
613
546
  this.updateTransaction(updatedTransactionMeta, `${controllerName}:updatesecurityAlertResponse - securityAlertResponse updated`);
614
547
  }
615
548
  /**
616
- * Removes all transactions from state, optionally based on the current network.
549
+ * Remove transactions from state.
617
550
  *
618
- * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the
619
- * current network. If `true`, all transactions are wiped.
620
- * @param address - If specified, only transactions originating from this address will be
621
- * wiped on current network.
551
+ * @param options - The options bag.
552
+ * @param options.address - Remove transactions from this account only. Defaults to all accounts.
553
+ * @param options.chainId - Remove transactions for the specified chain only. Defaults to all chains.
622
554
  */
623
- wipeTransactions(ignoreNetwork, address) {
624
- /* istanbul ignore next */
625
- if (ignoreNetwork && !address) {
555
+ wipeTransactions({ address, chainId, } = {}) {
556
+ if (!chainId && !address) {
626
557
  this.update((state) => {
627
558
  state.transactions = [];
628
559
  });
629
560
  return;
630
561
  }
631
- const currentChainId = this.getChainId();
632
- const newTransactions = this.state.transactions.filter(({ chainId, txParams }) => {
633
- const isMatchingNetwork = ignoreNetwork || chainId === currentChainId;
562
+ const newTransactions = this.state.transactions.filter(({ chainId: txChainId, txParams }) => {
563
+ const isMatchingNetwork = !chainId || chainId === txChainId;
634
564
  if (!isMatchingNetwork) {
635
565
  return true;
636
566
  }
@@ -820,10 +750,8 @@ class TransactionController extends base_controller_1.BaseController {
820
750
  };
821
751
  editableParams.txParams = (0, lodash_1.pickBy)(editableParams.txParams);
822
752
  const updatedTransaction = (0, lodash_1.merge)({}, transactionMeta, editableParams);
823
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
824
- chainId: transactionMeta.chainId,
825
- networkClientId: transactionMeta.networkClientId,
826
- });
753
+ const { networkClientId } = transactionMeta;
754
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
827
755
  const ethQuery = new eth_query_1.default(provider);
828
756
  const { type } = await (0, transaction_type_1.determineTransactionType)(updatedTransaction.txParams, ethQuery);
829
757
  updatedTransaction.type = type;
@@ -851,19 +779,9 @@ class TransactionController extends base_controller_1.BaseController {
851
779
  return '';
852
780
  }
853
781
  const initialTx = listOfTxParams[0];
854
- const common = this.getCommonConfiguration(initialTx.chainId);
855
- // We need to ensure we get the nonce using the the NonceTracker on the chain matching
856
- // the txParams. In this context we only have chainId available to us, but the
857
- // NonceTrackers are keyed by networkClientId. To workaround this, we attempt to find
858
- // a networkClientId that matches the chainId. As a fallback, the globally selected
859
- // network's NonceTracker will be used instead.
860
- let networkClientId;
861
- try {
862
- networkClientId = this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, initialTx.chainId);
863
- }
864
- catch (err) {
865
- (0, logger_1.projectLogger)('failed to find networkClientId from chainId', err);
866
- }
782
+ const { chainId } = initialTx;
783
+ const common = this.getCommonConfiguration(chainId);
784
+ const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
867
785
  const initialTxAsEthTx = tx_1.TransactionFactory.fromTxData(initialTx, {
868
786
  common,
869
787
  });
@@ -945,14 +863,12 @@ class TransactionController extends base_controller_1.BaseController {
945
863
  * Search transaction metadata for matching entries.
946
864
  *
947
865
  * @param opts - Options bag.
948
- * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
949
866
  * @param opts.initialList - The transactions to search. Defaults to the current state.
950
- * @param opts.filterToCurrentNetwork - Whether to filter the results to the current network. Defaults to true.
951
867
  * @param opts.limit - The maximum number of transactions to return. No limit by default.
868
+ * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
952
869
  * @returns An array of transactions matching the provided options.
953
870
  */
954
- getTransactions({ searchCriteria = {}, initialList, filterToCurrentNetwork = true, limit, } = {}) {
955
- const chainId = this.getChainId();
871
+ getTransactions({ initialList, limit, searchCriteria = {}, } = {}) {
956
872
  // searchCriteria is an object that might have values that aren't predicate
957
873
  // methods. When providing any other value type (string, number, etc), we
958
874
  // consider this shorthand for "check the value at key for strict equality
@@ -970,9 +886,6 @@ class TransactionController extends base_controller_1.BaseController {
970
886
  // Combine sortBy and pickBy to transform our state object into an array of
971
887
  // matching transactions that are sorted by time.
972
888
  const filteredTransactions = (0, lodash_1.sortBy)((0, lodash_1.pickBy)(transactionsToFilter, (transaction) => {
973
- if (filterToCurrentNetwork && transaction.chainId !== chainId) {
974
- return false;
975
- }
976
889
  // iterate over the predicateMethods keys to check if the transaction
977
890
  // matches the searchCriteria
978
891
  for (const [key, predicate] of Object.entries(predicateMethods)) {
@@ -1028,9 +941,9 @@ class TransactionController extends base_controller_1.BaseController {
1028
941
  return filteredTransactions;
1029
942
  }
1030
943
  async estimateGasFee({ transactionParams, chainId, networkClientId: requestNetworkClientId, }) {
1031
- const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, {
1032
- networkClientId: requestNetworkClientId,
944
+ const { id: networkClientId, provider } = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1033
945
  chainId,
946
+ networkClientId: requestNetworkClientId,
1034
947
  });
1035
948
  const transactionMeta = {
1036
949
  txParams: transactionParams,
@@ -1039,10 +952,7 @@ class TransactionController extends base_controller_1.BaseController {
1039
952
  };
1040
953
  // Guaranteed as the default gas fee flow matches all transactions.
1041
954
  const gasFeeFlow = (0, gas_flow_1.getGasFeeFlow)(transactionMeta, this.gasFeeFlows);
1042
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1043
- networkClientId,
1044
- chainId,
1045
- });
955
+ const ethQuery = new eth_query_1.default(provider);
1046
956
  const gasFeeControllerData = await this.getGasFeeEstimates({
1047
957
  networkClientId,
1048
958
  });
@@ -1061,9 +971,9 @@ class TransactionController extends base_controller_1.BaseController {
1061
971
  * @param request.networkClientId - The ID of a specific network client to process the transaction.
1062
972
  */
1063
973
  async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
1064
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
1065
- networkClientId,
974
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, {
1066
975
  chainId,
976
+ networkClientId,
1067
977
  });
1068
978
  return await (0, layer1_gas_fee_flow_1.getTransactionLayer1GasFee)({
1069
979
  layer1GasFeeFlows: this.layer1GasFeeFlows,
@@ -1134,15 +1044,10 @@ class TransactionController extends base_controller_1.BaseController {
1134
1044
  const isEIP1559Compatible = transactionMeta.txParams.type !== types_1.TransactionEnvelopeType.legacy &&
1135
1045
  (await this.getEIP1559Compatibility(transactionMeta.networkClientId));
1136
1046
  const { networkClientId, chainId } = transactionMeta;
1137
- const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isCustomNetwork).call(this, networkClientId);
1138
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1139
- networkClientId,
1140
- chainId,
1141
- });
1142
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
1143
- networkClientId,
1144
- chainId,
1145
- });
1047
+ const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1048
+ .configuration.type === network_controller_1.NetworkClientType.Custom;
1049
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1050
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
1146
1051
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
1147
1052
  await (0, gas_1.updateGas)({
1148
1053
  ethQuery,
@@ -1300,10 +1205,8 @@ class TransactionController extends base_controller_1.BaseController {
1300
1205
  if (!rawTx) {
1301
1206
  return ApprovalState.NotApproved;
1302
1207
  }
1303
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1304
- networkClientId: transactionMeta.networkClientId,
1305
- chainId: transactionMeta.chainId,
1306
- });
1208
+ const { networkClientId } = transactionMeta;
1209
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1307
1210
  let preTxBalance;
1308
1211
  const shouldUpdatePreTxBalance = transactionMeta.type === types_1.TransactionType.swap;
1309
1212
  if (shouldUpdatePreTxBalance) {
@@ -1497,14 +1400,6 @@ class TransactionController extends base_controller_1.BaseController {
1497
1400
  const isCompleted = this.isLocalFinalState(transaction.status);
1498
1401
  return { meta: transaction, isCompleted };
1499
1402
  }
1500
- getChainId(networkClientId) {
1501
- const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
1502
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
1503
- if (!networkClientId || networkClientId === globalNetworkClientId) {
1504
- return globalChainId;
1505
- }
1506
- return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.chainId;
1507
- }
1508
1403
  prepareUnsignedEthTx(chainId, txParams) {
1509
1404
  return tx_1.TransactionFactory.fromTxData(txParams, {
1510
1405
  freeze: false,
@@ -1530,14 +1425,16 @@ class TransactionController extends base_controller_1.BaseController {
1530
1425
  }
1531
1426
  onIncomingTransactions({ added, updated, }) {
1532
1427
  this.update((state) => {
1533
- const { transactions: currentTransactions } = state;
1534
- const updatedTransactions = [
1535
- ...added,
1536
- ...currentTransactions.map((originalTransaction) => {
1537
- const updatedTransaction = updated.find(({ hash }) => hash === originalTransaction.hash);
1538
- return updatedTransaction ?? originalTransaction;
1539
- }),
1540
- ];
1428
+ const { transactions } = state;
1429
+ const existingTransactions = transactions.map((tx) => updated.find(({ hash }) => hash === tx.hash) ?? tx);
1430
+ const updatedTransactions = [...added, ...existingTransactions].map((tx) => {
1431
+ const { chainId } = tx;
1432
+ const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
1433
+ return {
1434
+ ...tx,
1435
+ networkClientId,
1436
+ };
1437
+ });
1541
1438
  state.transactions = this.trimTransactionsForState(updatedTransactions);
1542
1439
  });
1543
1440
  }
@@ -1730,7 +1627,7 @@ class TransactionController extends base_controller_1.BaseController {
1730
1627
  transactionMeta,
1731
1628
  });
1732
1629
  }
1733
- getNonceTrackerTransactions(status, address, chainId = this.getChainId()) {
1630
+ getNonceTrackerTransactions(status, address, chainId) {
1734
1631
  return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address, status, this.state.transactions);
1735
1632
  }
1736
1633
  onConfirmedTransaction(transactionMeta) {
@@ -1746,13 +1643,11 @@ class TransactionController extends base_controller_1.BaseController {
1746
1643
  }
1747
1644
  async updatePostBalance(transactionMeta) {
1748
1645
  try {
1749
- if (transactionMeta.type !== types_1.TransactionType.swap) {
1646
+ const { networkClientId, type } = transactionMeta;
1647
+ if (type !== types_1.TransactionType.swap) {
1750
1648
  return;
1751
1649
  }
1752
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1753
- networkClientId: transactionMeta.networkClientId,
1754
- chainId: transactionMeta.chainId,
1755
- });
1650
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1756
1651
  const { updatedTransactionMeta, approvalTransactionMeta } = await (0, swaps_1.updatePostTransactionBalance)(transactionMeta, {
1757
1652
  ethQuery,
1758
1653
  getTransaction: this.getTransaction.bind(this),
@@ -1774,7 +1669,6 @@ class TransactionController extends base_controller_1.BaseController {
1774
1669
  }
1775
1670
  catch (error) {
1776
1671
  if (this.isTransactionAlreadyConfirmedError(error)) {
1777
- await this.pendingTransactionTracker.forceCheckTransaction(transactionMeta);
1778
1672
  throw new Error('Previous transaction is already confirmed');
1779
1673
  }
1780
1674
  throw error;
@@ -1795,7 +1689,7 @@ class TransactionController extends base_controller_1.BaseController {
1795
1689
  }
1796
1690
  }
1797
1691
  exports.TransactionController = TransactionController;
1798
- _TransactionController_internalEvents = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_trace = new WeakMap(), _TransactionController_transactionHistoryLimit = new WeakMap(), _TransactionController_isFirstTimeInteractionEnabled = new WeakMap(), _TransactionController_isSimulationEnabled = new WeakMap(), _TransactionController_testGasFeeFlows = new WeakMap(), _TransactionController_multichainTrackingHelper = new WeakMap(), _TransactionController_checkForPendingTransactionAndStartPolling = new WeakMap(), _TransactionController_instances = new WeakSet(), _TransactionController_retryTransaction = async function _TransactionController_retryTransaction({ actionId, afterSubmit, estimatedBaseFee, gasValues, label, prepareTransactionParams, rate, transactionId, transactionType, }) {
1692
+ _TransactionController_internalEvents = new WeakMap(), _TransactionController_methodDataHelper = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_trace = new WeakMap(), _TransactionController_transactionHistoryLimit = new WeakMap(), _TransactionController_isFirstTimeInteractionEnabled = new WeakMap(), _TransactionController_isSimulationEnabled = new WeakMap(), _TransactionController_testGasFeeFlows = new WeakMap(), _TransactionController_multichainTrackingHelper = new WeakMap(), _TransactionController_checkForPendingTransactionAndStartPolling = new WeakMap(), _TransactionController_instances = new WeakSet(), _TransactionController_retryTransaction = async function _TransactionController_retryTransaction({ actionId, afterSubmit, estimatedBaseFee, gasValues, label, prepareTransactionParams, rate, transactionId, transactionType, }) {
1799
1693
  // If transaction is found for same action id, do not create a new transaction.
1800
1694
  if (this.getTransactionWithActionId(actionId)) {
1801
1695
  return;
@@ -1830,10 +1724,8 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1830
1724
  newFee,
1831
1725
  txParams: newTxParams,
1832
1726
  });
1833
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1834
- networkClientId: transactionMeta.networkClientId,
1835
- chainId: transactionMeta.chainId,
1836
- });
1727
+ const { networkClientId } = transactionMeta;
1728
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1837
1729
  const newTransactionMeta = {
1838
1730
  ...transactionMetaWithRsv,
1839
1731
  actionId,
@@ -1862,6 +1754,23 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1862
1754
  actionId,
1863
1755
  });
1864
1756
  afterSubmit?.(newTransactionMeta);
1757
+ }, _TransactionController_getChainId = function _TransactionController_getChainId(networkClientId) {
1758
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1759
+ .configuration.chainId;
1760
+ }, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ chainId, networkClientId, }) {
1761
+ if (networkClientId) {
1762
+ return networkClientId;
1763
+ }
1764
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1765
+ chainId,
1766
+ }).id;
1767
+ }, _TransactionController_getEthQuery = function _TransactionController_getEthQuery({ chainId, networkClientId, }) {
1768
+ return new eth_query_1.default(__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { chainId, networkClientId }));
1769
+ }, _TransactionController_getProvider = function _TransactionController_getProvider({ chainId, networkClientId, }) {
1770
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1771
+ chainId,
1772
+ networkClientId,
1773
+ }).provider;
1865
1774
  }, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
1866
1775
  return new nonce_tracker_1.NonceTracker({
1867
1776
  // TODO: Fix types
@@ -1870,18 +1779,23 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1870
1779
  // TODO: Fix types
1871
1780
  blockTracker,
1872
1781
  getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
1873
- getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed),
1782
+ getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed, chainId),
1874
1783
  });
1875
- }, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, etherscanRemoteTransactionSource, chainId, }) {
1784
+ }, _TransactionController_createRemoteTransactionSource = function _TransactionController_createRemoteTransactionSource() {
1785
+ return new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
1786
+ apiKeysByChainId: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").etherscanApiKeysByChainId,
1787
+ includeTokenTransfers: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").includeTokenTransfers,
1788
+ });
1789
+ }, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, remoteTransactionSource, chainId, }) {
1876
1790
  const incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
1877
1791
  blockTracker,
1878
1792
  getCurrentAccount: () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this),
1879
1793
  getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
1880
1794
  getLocalTransactions: () => this.state.transactions,
1881
- getChainId: chainId ? () => chainId : this.getChainId.bind(this),
1795
+ getChainId: () => chainId,
1882
1796
  isEnabled: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").isEnabled,
1883
1797
  queryEntireHistory: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").queryEntireHistory,
1884
- remoteTransactionSource: etherscanRemoteTransactionSource,
1798
+ remoteTransactionSource,
1885
1799
  transactionLimit: __classPrivateFieldGet(this, _TransactionController_transactionHistoryLimit, "f"),
1886
1800
  updateTransactions: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").updateTransactions,
1887
1801
  });
@@ -1889,15 +1803,14 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1889
1803
  return incomingTransactionHelper;
1890
1804
  }, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, }) {
1891
1805
  const ethQuery = new eth_query_1.default(provider);
1892
- const getChainId = chainId ? () => chainId : this.getChainId.bind(this);
1893
1806
  const pendingTransactionTracker = new PendingTransactionTracker_1.PendingTransactionTracker({
1894
1807
  blockTracker,
1895
- getChainId,
1808
+ getChainId: () => chainId,
1896
1809
  getEthQuery: () => ethQuery,
1897
1810
  getTransactions: () => this.state.transactions,
1898
1811
  isResubmitEnabled: __classPrivateFieldGet(this, _TransactionController_pendingTransactionOptions, "f").isResubmitEnabled,
1899
1812
  getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
1900
- chainId: getChainId(),
1813
+ chainId,
1901
1814
  }),
1902
1815
  publishTransaction: (_ethQuery, transactionMeta) => this.publishTransaction(_ethQuery, transactionMeta, {
1903
1816
  skipSubmitHistory: true,
@@ -1910,10 +1823,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1910
1823
  __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
1911
1824
  return pendingTransactionTracker;
1912
1825
  }, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
1913
- this.pendingTransactionTracker.stop();
1914
- __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).call(this, this.pendingTransactionTracker);
1915
- this.incomingTransactionHelper.stop();
1916
- __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).call(this, this.incomingTransactionHelper);
1917
1826
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
1918
1827
  }, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
1919
1828
  incomingTransactionHelper.hub.removeAllListeners('transactions');
@@ -2070,26 +1979,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
2070
1979
  txMeta.layer1GasFee = layer1GasFee;
2071
1980
  }
2072
1981
  });
2073
- }, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ networkClientId: requestNetworkClientId, chainId, }) {
2074
- const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
2075
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
2076
- if (requestNetworkClientId) {
2077
- return requestNetworkClientId;
2078
- }
2079
- if (!chainId || chainId === globalChainId) {
2080
- return globalNetworkClientId;
2081
- }
2082
- return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
2083
- }, _TransactionController_getGlobalNetworkClientId = function _TransactionController_getGlobalNetworkClientId() {
2084
- return this.getNetworkState().selectedNetworkClientId;
2085
- }, _TransactionController_getGlobalChainId = function _TransactionController_getGlobalChainId() {
2086
- return this.messagingSystem.call(`NetworkController:getNetworkClientById`, this.getNetworkState().selectedNetworkClientId).configuration.chainId;
2087
- }, _TransactionController_isCustomNetwork = function _TransactionController_isCustomNetwork(networkClientId) {
2088
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
2089
- if (!networkClientId || networkClientId === globalNetworkClientId) {
2090
- return !(0, controller_utils_1.isInfuraNetworkType)(this.getNetworkState().selectedNetworkClientId);
2091
- }
2092
- return (this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.type === network_controller_1.NetworkClientType.Custom);
2093
1982
  }, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
2094
1983
  return this.messagingSystem.call('AccountsController:getSelectedAccount');
2095
1984
  }, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {