@metamask-previews/transaction-controller 39.0.0-preview-e23a91fa → 39.0.0-preview-913113cf

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 (64) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/TransactionController.cjs +104 -219
  3. package/dist/TransactionController.cjs.map +1 -1
  4. package/dist/TransactionController.d.cts +34 -52
  5. package/dist/TransactionController.d.cts.map +1 -1
  6. package/dist/TransactionController.d.mts +34 -52
  7. package/dist/TransactionController.d.mts.map +1 -1
  8. package/dist/TransactionController.mjs +105 -220
  9. package/dist/TransactionController.mjs.map +1 -1
  10. package/dist/helpers/EtherscanRemoteTransactionSource.cjs +1 -0
  11. package/dist/helpers/EtherscanRemoteTransactionSource.cjs.map +1 -1
  12. package/dist/helpers/EtherscanRemoteTransactionSource.d.cts.map +1 -1
  13. package/dist/helpers/EtherscanRemoteTransactionSource.d.mts.map +1 -1
  14. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +1 -0
  15. package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +1 -1
  16. package/dist/helpers/GasFeePoller.cjs +4 -4
  17. package/dist/helpers/GasFeePoller.cjs.map +1 -1
  18. package/dist/helpers/GasFeePoller.d.cts +1 -1
  19. package/dist/helpers/GasFeePoller.d.cts.map +1 -1
  20. package/dist/helpers/GasFeePoller.d.mts +1 -1
  21. package/dist/helpers/GasFeePoller.d.mts.map +1 -1
  22. package/dist/helpers/GasFeePoller.mjs +4 -4
  23. package/dist/helpers/GasFeePoller.mjs.map +1 -1
  24. package/dist/helpers/IncomingTransactionHelper.cjs +12 -5
  25. package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -1
  26. package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -1
  27. package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -1
  28. package/dist/helpers/IncomingTransactionHelper.mjs +13 -6
  29. package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
  30. package/dist/helpers/MethodDataHelper.cjs +78 -0
  31. package/dist/helpers/MethodDataHelper.cjs.map +1 -0
  32. package/dist/helpers/MethodDataHelper.d.cts +14 -0
  33. package/dist/helpers/MethodDataHelper.d.cts.map +1 -0
  34. package/dist/helpers/MethodDataHelper.d.mts +14 -0
  35. package/dist/helpers/MethodDataHelper.d.mts.map +1 -0
  36. package/dist/helpers/MethodDataHelper.mjs +71 -0
  37. package/dist/helpers/MethodDataHelper.mjs.map +1 -0
  38. package/dist/helpers/MultichainTrackingHelper.cjs +87 -104
  39. package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -1
  40. package/dist/helpers/MultichainTrackingHelper.d.cts +16 -22
  41. package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -1
  42. package/dist/helpers/MultichainTrackingHelper.d.mts +16 -22
  43. package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -1
  44. package/dist/helpers/MultichainTrackingHelper.mjs +88 -109
  45. package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
  46. package/dist/helpers/PendingTransactionTracker.cjs +24 -22
  47. package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
  48. package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
  49. package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
  50. package/dist/helpers/PendingTransactionTracker.mjs +24 -22
  51. package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
  52. package/dist/types.cjs.map +1 -1
  53. package/dist/types.d.cts +1 -1
  54. package/dist/types.d.cts.map +1 -1
  55. package/dist/types.d.mts +1 -1
  56. package/dist/types.d.mts.map +1 -1
  57. package/dist/types.mjs.map +1 -1
  58. package/dist/utils/etherscan.cjs +2 -1
  59. package/dist/utils/etherscan.cjs.map +1 -1
  60. package/dist/utils/etherscan.d.cts.map +1 -1
  61. package/dist/utils/etherscan.d.mts.map +1 -1
  62. package/dist/utils/etherscan.mjs +3 -2
  63. package/dist/utils/etherscan.mjs.map +1 -1
  64. package/package.json +1 -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_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_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_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");
@@ -39,6 +38,7 @@ const TestGasFeeFlow_1 = require("./gas-flows/TestGasFeeFlow.cjs");
39
38
  const EtherscanRemoteTransactionSource_1 = require("./helpers/EtherscanRemoteTransactionSource.cjs");
40
39
  const GasFeePoller_1 = require("./helpers/GasFeePoller.cjs");
41
40
  const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper.cjs");
41
+ const MethodDataHelper_1 = require("./helpers/MethodDataHelper.cjs");
42
42
  const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.cjs");
43
43
  const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
44
44
  const logger_1 = require("./logger.cjs");
@@ -148,22 +148,10 @@ class TransactionController extends base_controller_1.BaseController {
148
148
  this.messagingSystem.publish(`${controllerName}:transactionFinished`, newTransactionMeta);
149
149
  __classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, newTransactionMeta);
150
150
  }
151
- async registryLookup(fourBytePrefix) {
152
- const registryMethod = await this.registry.lookup(fourBytePrefix);
153
- if (!registryMethod) {
154
- return {
155
- registryMethod: '',
156
- parsedRegistryMethod: { name: undefined, args: undefined },
157
- };
158
- }
159
- const parsedRegistryMethod = this.registry.parse(registryMethod);
160
- return { registryMethod, parsedRegistryMethod };
161
- }
162
151
  /**
163
152
  * Constructs a TransactionController.
164
153
  *
165
154
  * @param options - The controller options.
166
- * @param options.blockTracker - The block tracker used to poll for new blocks data.
167
155
  * @param options.disableHistory - Whether to disable storing history in transaction metadata.
168
156
  * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
169
157
  * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
@@ -176,12 +164,9 @@ class TransactionController extends base_controller_1.BaseController {
176
164
  * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
177
165
  * @param options.getSavedGasFees - Gets the saved gas fee config.
178
166
  * @param options.incomingTransactions - Configuration options for incoming transaction support.
179
- * @param options.isMultichainEnabled - Enable multichain support.
180
167
  * @param options.isSimulationEnabled - Whether new transactions will be automatically simulated.
181
168
  * @param options.messenger - The controller messenger.
182
- * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
183
169
  * @param options.pendingTransactions - Configuration options for pending transaction support.
184
- * @param options.provider - The provider used to create the underlying EthQuery instance.
185
170
  * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
186
171
  * @param options.sign - Function used to sign transactions.
187
172
  * @param options.state - Initial state to set on this controller.
@@ -190,7 +175,7 @@ class TransactionController extends base_controller_1.BaseController {
190
175
  * @param options.transactionHistoryLimit - Transaction history limit.
191
176
  * @param options.hooks - The controller hooks.
192
177
  */
193
- 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, }) {
178
+ constructor({ disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isSimulationEnabled, messenger, pendingTransactions = {}, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, }) {
194
179
  super({
195
180
  name: controllerName,
196
181
  metadata,
@@ -203,6 +188,7 @@ class TransactionController extends base_controller_1.BaseController {
203
188
  _TransactionController_instances.add(this);
204
189
  _TransactionController_internalEvents.set(this, new events_1.EventEmitter());
205
190
  this.approvingTransactionIds = new Set();
191
+ _TransactionController_methodDataHelper.set(this, void 0);
206
192
  this.mutex = new async_mutex_1.Mutex();
207
193
  _TransactionController_incomingTransactionOptions.set(this, void 0);
208
194
  _TransactionController_pendingTransactionOptions.set(this, void 0);
@@ -213,8 +199,6 @@ class TransactionController extends base_controller_1.BaseController {
213
199
  _TransactionController_testGasFeeFlows.set(this, void 0);
214
200
  _TransactionController_multichainTrackingHelper.set(this, void 0);
215
201
  _TransactionController_checkForPendingTransactionAndStartPolling.set(this, () => {
216
- // PendingTransactionTracker reads state through its getTransactions hook
217
- this.pendingTransactionTracker.startIfPendingTransactions();
218
202
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
219
203
  });
220
204
  this.messagingSystem = messenger;
@@ -223,8 +207,6 @@ class TransactionController extends base_controller_1.BaseController {
223
207
  this.isHistoryDisabled = disableHistory ?? false;
224
208
  this.isSwapsDisabled = disableSwaps ?? false;
225
209
  __classPrivateFieldSet(this, _TransactionController_isSimulationEnabled, isSimulationEnabled ?? (() => true), "f");
226
- // @ts-expect-error the type in eth-method-registry is inappropriate and should be changed
227
- this.registry = new eth_method_registry_1.MethodRegistry({ provider });
228
210
  this.getSavedGasFees = getSavedGasFees ?? ((_chainId) => undefined);
229
211
  this.getCurrentAccountEIP1559Compatibility =
230
212
  getCurrentAccountEIP1559Compatibility ?? (() => Promise.resolve(true));
@@ -252,18 +234,10 @@ class TransactionController extends base_controller_1.BaseController {
252
234
  hooks?.getAdditionalSignArguments ?? (() => []);
253
235
  this.publish =
254
236
  hooks?.publish ?? (() => Promise.resolve({ transactionHash: undefined }));
255
- this.nonceTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).call(this, {
256
- provider,
257
- blockTracker,
258
- });
259
237
  const findNetworkClientIdByChainId = (chainId) => {
260
238
  return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
261
239
  };
262
240
  __classPrivateFieldSet(this, _TransactionController_multichainTrackingHelper, new MultichainTrackingHelper_1.MultichainTrackingHelper({
263
- isMultichainEnabled,
264
- provider,
265
- nonceTracker: this.nonceTracker,
266
- incomingTransactionOptions: incomingTransactions,
267
241
  findNetworkClientIdByChainId,
268
242
  getNetworkClientById: ((networkClientId) => {
269
243
  return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId);
@@ -274,33 +248,19 @@ class TransactionController extends base_controller_1.BaseController {
274
248
  createNonceTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).bind(this),
275
249
  createIncomingTransactionHelper: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).bind(this),
276
250
  createPendingTransactionTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).bind(this),
251
+ createRemoteTransactionSource: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createRemoteTransactionSource).bind(this),
277
252
  onNetworkStateChange: (listener) => {
278
253
  this.messagingSystem.subscribe('NetworkController:stateChange', listener);
279
254
  },
280
255
  }), "f");
281
256
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").initialize();
282
- const etherscanRemoteTransactionSource = new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
283
- apiKeysByChainId: incomingTransactions.etherscanApiKeysByChainId,
284
- includeTokenTransfers: incomingTransactions.includeTokenTransfers,
285
- });
286
- this.incomingTransactionHelper = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).call(this, {
287
- blockTracker,
288
- etherscanRemoteTransactionSource,
289
- });
290
- this.pendingTransactionTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).call(this, {
291
- provider,
292
- blockTracker,
293
- });
294
257
  this.gasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeFlows).call(this);
295
258
  this.layer1GasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getLayer1GasFeeFlows).call(this);
296
259
  const gasFeePoller = new GasFeePoller_1.GasFeePoller({
297
260
  findNetworkClientIdByChainId,
298
261
  gasFeeFlows: this.gasFeeFlows,
299
262
  getGasFeeControllerEstimates: this.getGasFeeEstimates,
300
- getProvider: (chainId, networkClientId) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
301
- networkClientId,
302
- chainId,
303
- }),
263
+ getProvider: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId }),
304
264
  getTransactions: () => this.state.transactions,
305
265
  layer1GasFeeFlows: this.layer1GasFeeFlows,
306
266
  onStateChange: (listener) => {
@@ -308,15 +268,18 @@ class TransactionController extends base_controller_1.BaseController {
308
268
  },
309
269
  });
310
270
  gasFeePoller.hub.on('transaction-updated', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onGasFeePollerTransactionUpdate).bind(this));
271
+ __classPrivateFieldSet(this, _TransactionController_methodDataHelper, new MethodDataHelper_1.MethodDataHelper({
272
+ getProvider: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId }),
273
+ getState: () => this.state.methodData,
274
+ }), "f");
275
+ __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").hub.on('update', ({ fourBytePrefix, methodData }) => {
276
+ this.update((_state) => {
277
+ _state.methodData[fourBytePrefix] = methodData;
278
+ });
279
+ });
311
280
  // when transactionsController state changes
312
281
  // check for pending transactions and start polling if there are any
313
282
  this.messagingSystem.subscribe('TransactionController:stateChange', __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
314
- // TODO once v2 is merged make sure this only runs when
315
- // selectedNetworkClientId changes
316
- onNetworkStateChange(() => {
317
- (0, logger_1.projectLogger)('Detected network change', this.getChainId());
318
- this.pendingTransactionTracker.startIfPendingTransactions();
319
- });
320
283
  this.onBootCleanup();
321
284
  __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
322
285
  }
@@ -330,25 +293,11 @@ class TransactionController extends base_controller_1.BaseController {
330
293
  * Handle new method data request.
331
294
  *
332
295
  * @param fourBytePrefix - The method prefix.
296
+ * @param networkClientId - The ID of the network client used to fetch the method data.
333
297
  * @returns The method data object corresponding to the given signature prefix.
334
298
  */
335
- async handleMethodData(fourBytePrefix) {
336
- const releaseLock = await this.mutex.acquire();
337
- try {
338
- const { methodData } = this.state;
339
- const knownMethod = Object.keys(methodData).find((knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix);
340
- if (knownMethod) {
341
- return methodData[fourBytePrefix];
342
- }
343
- const registry = await this.registryLookup(fourBytePrefix);
344
- this.update((state) => {
345
- state.methodData[fourBytePrefix] = registry;
346
- });
347
- return registry;
348
- }
349
- finally {
350
- releaseLock();
351
- }
299
+ async handleMethodData(fourBytePrefix, networkClientId) {
300
+ return __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").lookup(fourBytePrefix, networkClientId);
352
301
  }
353
302
  /**
354
303
  * Add a new unapproved transaction to state. Parameters will be validated, a
@@ -356,40 +305,38 @@ class TransactionController extends base_controller_1.BaseController {
356
305
  * if not provided. If A `<tx.id>:unapproved` hub event will be emitted once added.
357
306
  *
358
307
  * @param txParams - Standard parameters for an Ethereum transaction.
359
- * @param opts - Additional options to control how the transaction is added.
360
- * @param opts.actionId - Unique ID to prevent duplicate requests.
361
- * @param opts.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
362
- * @param opts.method - RPC method that requested the transaction.
363
- * @param opts.origin - The origin of the transaction request, such as a dApp hostname.
364
- * @param opts.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
365
- * @param opts.securityAlertResponse - Response from security validator.
366
- * @param opts.sendFlowHistory - The sendFlowHistory entries to add.
367
- * @param opts.type - Type of transaction to add, such as 'cancel' or 'swap'.
368
- * @param opts.swaps - Options for swaps transactions.
369
- * @param opts.swaps.hasApproveTx - Whether the transaction has an approval transaction.
370
- * @param opts.swaps.meta - Metadata for swap transaction.
371
- * @param opts.networkClientId - The id of the network client for this transaction.
372
- * @param opts.traceContext - The parent context for any new traces.
308
+ * @param options - Additional options to control how the transaction is added.
309
+ * @param options.actionId - Unique ID to prevent duplicate requests.
310
+ * @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
311
+ * @param options.method - RPC method that requested the transaction.
312
+ * @param options.origin - The origin of the transaction request, such as a dApp hostname.
313
+ * @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
314
+ * @param options.securityAlertResponse - Response from security validator.
315
+ * @param options.sendFlowHistory - The sendFlowHistory entries to add.
316
+ * @param options.type - Type of transaction to add, such as 'cancel' or 'swap'.
317
+ * @param options.swaps - Options for swaps transactions.
318
+ * @param options.swaps.hasApproveTx - Whether the transaction has an approval transaction.
319
+ * @param options.swaps.meta - Metadata for swap transaction.
320
+ * @param options.networkClientId - The id of the network client for this transaction.
321
+ * @param options.traceContext - The parent context for any new traces.
373
322
  * @returns Object containing a promise resolving to the transaction hash if approved.
374
323
  */
375
- async addTransaction(txParams, { actionId, deviceConfirmedOn, method, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, networkClientId: requestNetworkClientId, } = {}) {
376
- (0, logger_1.projectLogger)('Adding transaction', txParams);
324
+ async addTransaction(txParams, options) {
325
+ (0, logger_1.projectLogger)('Adding transaction', txParams, options);
326
+ const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
377
327
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
378
- if (requestNetworkClientId &&
379
- !__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(requestNetworkClientId)) {
380
- throw new Error('The networkClientId for this transaction could not be found');
328
+ if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
329
+ throw new Error(`Network client not found - ${networkClientId}`);
381
330
  }
382
- const networkClientId = requestNetworkClientId ?? __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
383
331
  const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
384
332
  (0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
385
333
  if (origin && this.getPermittedAccounts) {
386
334
  await (0, validation_1.validateTransactionOrigin)(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
387
335
  }
388
336
  const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
389
- const chainId = this.getChainId(networkClientId);
390
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
337
+ const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
338
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
391
339
  networkClientId,
392
- chainId,
393
340
  });
394
341
  const transactionType = type ?? (await (0, transaction_type_1.determineTransactionType)(txParams, ethQuery)).type;
395
342
  const existingTransactionMeta = this.getTransactionWithActionId(actionId);
@@ -460,29 +407,13 @@ class TransactionController extends base_controller_1.BaseController {
460
407
  transactionMeta: addedTransactionMeta,
461
408
  };
462
409
  }
463
- startIncomingTransactionPolling(networkClientIds = []) {
464
- if (networkClientIds.length === 0) {
465
- this.incomingTransactionHelper.start();
466
- return;
467
- }
410
+ startIncomingTransactionPolling(networkClientIds) {
468
411
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").startIncomingTransactionPolling(networkClientIds);
469
412
  }
470
- stopIncomingTransactionPolling(networkClientIds = []) {
471
- if (networkClientIds.length === 0) {
472
- this.incomingTransactionHelper.stop();
473
- return;
474
- }
413
+ stopIncomingTransactionPolling(networkClientIds) {
475
414
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopIncomingTransactionPolling(networkClientIds);
476
415
  }
477
- stopAllIncomingTransactionPolling() {
478
- this.incomingTransactionHelper.stop();
479
- __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllIncomingTransactionPolling();
480
- }
481
416
  async updateIncomingTransactions(networkClientIds = []) {
482
- if (networkClientIds.length === 0) {
483
- await this.incomingTransactionHelper.update();
484
- return;
485
- }
486
417
  await __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").updateIncomingTransactions(networkClientIds);
487
418
  }
488
419
  /**
@@ -546,7 +477,7 @@ class TransactionController extends base_controller_1.BaseController {
546
477
  * @returns The gas and gas price.
547
478
  */
548
479
  async estimateGas(transaction, networkClientId) {
549
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
480
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
550
481
  networkClientId,
551
482
  });
552
483
  const { estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
@@ -560,7 +491,7 @@ class TransactionController extends base_controller_1.BaseController {
560
491
  * @param networkClientId - The network client id to use for the estimate.
561
492
  */
562
493
  async estimateGasBuffered(transaction, multiplier, networkClientId) {
563
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
494
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
564
495
  networkClientId,
565
496
  });
566
497
  const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
@@ -603,24 +534,21 @@ class TransactionController extends base_controller_1.BaseController {
603
534
  this.updateTransaction(updatedTransactionMeta, `${controllerName}:updatesecurityAlertResponse - securityAlertResponse updated`);
604
535
  }
605
536
  /**
606
- * Removes all transactions from state, optionally based on the current network.
537
+ * Remove transactions from state.
607
538
  *
608
- * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the
609
- * current network. If `true`, all transactions are wiped.
610
- * @param address - If specified, only transactions originating from this address will be
611
- * wiped on current network.
539
+ * @param options - The options bag.
540
+ * @param options.address - Remove transactions from this account only. Defaults to all accounts.
541
+ * @param options.chainId - Remove transactions for the specified chain only. Defaults to all chains.
612
542
  */
613
- wipeTransactions(ignoreNetwork, address) {
614
- /* istanbul ignore next */
615
- if (ignoreNetwork && !address) {
543
+ wipeTransactions({ address, chainId, } = {}) {
544
+ if (!chainId && !address) {
616
545
  this.update((state) => {
617
546
  state.transactions = [];
618
547
  });
619
548
  return;
620
549
  }
621
- const currentChainId = this.getChainId();
622
- const newTransactions = this.state.transactions.filter(({ chainId, txParams }) => {
623
- const isMatchingNetwork = ignoreNetwork || chainId === currentChainId;
550
+ const newTransactions = this.state.transactions.filter(({ chainId: txChainId, txParams }) => {
551
+ const isMatchingNetwork = !chainId || chainId === txChainId;
624
552
  if (!isMatchingNetwork) {
625
553
  return true;
626
554
  }
@@ -810,10 +738,8 @@ class TransactionController extends base_controller_1.BaseController {
810
738
  };
811
739
  editableParams.txParams = (0, lodash_1.pickBy)(editableParams.txParams);
812
740
  const updatedTransaction = (0, lodash_1.merge)({}, transactionMeta, editableParams);
813
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
814
- chainId: transactionMeta.chainId,
815
- networkClientId: transactionMeta.networkClientId,
816
- });
741
+ const { networkClientId } = transactionMeta;
742
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
817
743
  const ethQuery = new eth_query_1.default(provider);
818
744
  const { type } = await (0, transaction_type_1.determineTransactionType)(updatedTransaction.txParams, ethQuery);
819
745
  updatedTransaction.type = type;
@@ -841,19 +767,9 @@ class TransactionController extends base_controller_1.BaseController {
841
767
  return '';
842
768
  }
843
769
  const initialTx = listOfTxParams[0];
844
- const common = this.getCommonConfiguration(initialTx.chainId);
845
- // We need to ensure we get the nonce using the the NonceTracker on the chain matching
846
- // the txParams. In this context we only have chainId available to us, but the
847
- // NonceTrackers are keyed by networkClientId. To workaround this, we attempt to find
848
- // a networkClientId that matches the chainId. As a fallback, the globally selected
849
- // network's NonceTracker will be used instead.
850
- let networkClientId;
851
- try {
852
- networkClientId = this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, initialTx.chainId);
853
- }
854
- catch (err) {
855
- (0, logger_1.projectLogger)('failed to find networkClientId from chainId', err);
856
- }
770
+ const { chainId } = initialTx;
771
+ const common = this.getCommonConfiguration(chainId);
772
+ const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
857
773
  const initialTxAsEthTx = tx_1.TransactionFactory.fromTxData(initialTx, {
858
774
  common,
859
775
  });
@@ -935,14 +851,12 @@ class TransactionController extends base_controller_1.BaseController {
935
851
  * Search transaction metadata for matching entries.
936
852
  *
937
853
  * @param opts - Options bag.
938
- * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
939
854
  * @param opts.initialList - The transactions to search. Defaults to the current state.
940
- * @param opts.filterToCurrentNetwork - Whether to filter the results to the current network. Defaults to true.
941
855
  * @param opts.limit - The maximum number of transactions to return. No limit by default.
856
+ * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
942
857
  * @returns An array of transactions matching the provided options.
943
858
  */
944
- getTransactions({ searchCriteria = {}, initialList, filterToCurrentNetwork = true, limit, } = {}) {
945
- const chainId = this.getChainId();
859
+ getTransactions({ initialList, limit, searchCriteria = {}, } = {}) {
946
860
  // searchCriteria is an object that might have values that aren't predicate
947
861
  // methods. When providing any other value type (string, number, etc), we
948
862
  // consider this shorthand for "check the value at key for strict equality
@@ -960,9 +874,6 @@ class TransactionController extends base_controller_1.BaseController {
960
874
  // Combine sortBy and pickBy to transform our state object into an array of
961
875
  // matching transactions that are sorted by time.
962
876
  const filteredTransactions = (0, lodash_1.sortBy)((0, lodash_1.pickBy)(transactionsToFilter, (transaction) => {
963
- if (filterToCurrentNetwork && transaction.chainId !== chainId) {
964
- return false;
965
- }
966
877
  // iterate over the predicateMethods keys to check if the transaction
967
878
  // matches the searchCriteria
968
879
  for (const [key, predicate] of Object.entries(predicateMethods)) {
@@ -1018,9 +929,9 @@ class TransactionController extends base_controller_1.BaseController {
1018
929
  return filteredTransactions;
1019
930
  }
1020
931
  async estimateGasFee({ transactionParams, chainId, networkClientId: requestNetworkClientId, }) {
1021
- const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, {
1022
- networkClientId: requestNetworkClientId,
932
+ const { id: networkClientId, provider } = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1023
933
  chainId,
934
+ networkClientId: requestNetworkClientId,
1024
935
  });
1025
936
  const transactionMeta = {
1026
937
  txParams: transactionParams,
@@ -1029,10 +940,7 @@ class TransactionController extends base_controller_1.BaseController {
1029
940
  };
1030
941
  // Guaranteed as the default gas fee flow matches all transactions.
1031
942
  const gasFeeFlow = (0, gas_flow_1.getGasFeeFlow)(transactionMeta, this.gasFeeFlows);
1032
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1033
- networkClientId,
1034
- chainId,
1035
- });
943
+ const ethQuery = new eth_query_1.default(provider);
1036
944
  const gasFeeControllerData = await this.getGasFeeEstimates({
1037
945
  networkClientId,
1038
946
  });
@@ -1051,9 +959,9 @@ class TransactionController extends base_controller_1.BaseController {
1051
959
  * @param request.networkClientId - The ID of a specific network client to process the transaction.
1052
960
  */
1053
961
  async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
1054
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
1055
- networkClientId,
962
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, {
1056
963
  chainId,
964
+ networkClientId,
1057
965
  });
1058
966
  return await (0, layer1_gas_fee_flow_1.getTransactionLayer1GasFee)({
1059
967
  layer1GasFeeFlows: this.layer1GasFeeFlows,
@@ -1124,15 +1032,10 @@ class TransactionController extends base_controller_1.BaseController {
1124
1032
  const isEIP1559Compatible = transactionMeta.txParams.type !== types_1.TransactionEnvelopeType.legacy &&
1125
1033
  (await this.getEIP1559Compatibility(transactionMeta.networkClientId));
1126
1034
  const { networkClientId, chainId } = transactionMeta;
1127
- const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isCustomNetwork).call(this, networkClientId);
1128
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1129
- networkClientId,
1130
- chainId,
1131
- });
1132
- const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
1133
- networkClientId,
1134
- chainId,
1135
- });
1035
+ const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1036
+ .configuration.type === network_controller_1.NetworkClientType.Custom;
1037
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1038
+ const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
1136
1039
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
1137
1040
  await (0, gas_1.updateGas)({
1138
1041
  ethQuery,
@@ -1290,10 +1193,8 @@ class TransactionController extends base_controller_1.BaseController {
1290
1193
  if (!rawTx) {
1291
1194
  return ApprovalState.NotApproved;
1292
1195
  }
1293
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1294
- networkClientId: transactionMeta.networkClientId,
1295
- chainId: transactionMeta.chainId,
1296
- });
1196
+ const { networkClientId } = transactionMeta;
1197
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1297
1198
  let preTxBalance;
1298
1199
  const shouldUpdatePreTxBalance = transactionMeta.type === types_1.TransactionType.swap;
1299
1200
  if (shouldUpdatePreTxBalance) {
@@ -1487,14 +1388,6 @@ class TransactionController extends base_controller_1.BaseController {
1487
1388
  const isCompleted = this.isLocalFinalState(transaction.status);
1488
1389
  return { meta: transaction, isCompleted };
1489
1390
  }
1490
- getChainId(networkClientId) {
1491
- const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
1492
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
1493
- if (!networkClientId || networkClientId === globalNetworkClientId) {
1494
- return globalChainId;
1495
- }
1496
- return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.chainId;
1497
- }
1498
1391
  prepareUnsignedEthTx(chainId, txParams) {
1499
1392
  return tx_1.TransactionFactory.fromTxData(txParams, {
1500
1393
  freeze: false,
@@ -1720,7 +1613,7 @@ class TransactionController extends base_controller_1.BaseController {
1720
1613
  transactionMeta,
1721
1614
  });
1722
1615
  }
1723
- getNonceTrackerTransactions(status, address, chainId = this.getChainId()) {
1616
+ getNonceTrackerTransactions(status, address, chainId) {
1724
1617
  return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address, status, this.state.transactions);
1725
1618
  }
1726
1619
  onConfirmedTransaction(transactionMeta) {
@@ -1736,13 +1629,11 @@ class TransactionController extends base_controller_1.BaseController {
1736
1629
  }
1737
1630
  async updatePostBalance(transactionMeta) {
1738
1631
  try {
1739
- if (transactionMeta.type !== types_1.TransactionType.swap) {
1632
+ const { networkClientId, type } = transactionMeta;
1633
+ if (type !== types_1.TransactionType.swap) {
1740
1634
  return;
1741
1635
  }
1742
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1743
- networkClientId: transactionMeta.networkClientId,
1744
- chainId: transactionMeta.chainId,
1745
- });
1636
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1746
1637
  const { updatedTransactionMeta, approvalTransactionMeta } = await (0, swaps_1.updatePostTransactionBalance)(transactionMeta, {
1747
1638
  ethQuery,
1748
1639
  getTransaction: this.getTransaction.bind(this),
@@ -1764,7 +1655,6 @@ class TransactionController extends base_controller_1.BaseController {
1764
1655
  }
1765
1656
  catch (error) {
1766
1657
  if (this.isTransactionAlreadyConfirmedError(error)) {
1767
- await this.pendingTransactionTracker.forceCheckTransaction(transactionMeta);
1768
1658
  throw new Error('Previous transaction is already confirmed');
1769
1659
  }
1770
1660
  throw error;
@@ -1785,7 +1675,7 @@ class TransactionController extends base_controller_1.BaseController {
1785
1675
  }
1786
1676
  }
1787
1677
  exports.TransactionController = TransactionController;
1788
- _TransactionController_internalEvents = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_trace = new WeakMap(), _TransactionController_transactionHistoryLimit = 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, }) {
1678
+ _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_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, }) {
1789
1679
  // If transaction is found for same action id, do not create a new transaction.
1790
1680
  if (this.getTransactionWithActionId(actionId)) {
1791
1681
  return;
@@ -1820,10 +1710,8 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1820
1710
  newFee,
1821
1711
  txParams: newTxParams,
1822
1712
  });
1823
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1824
- networkClientId: transactionMeta.networkClientId,
1825
- chainId: transactionMeta.chainId,
1826
- });
1713
+ const { networkClientId } = transactionMeta;
1714
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1827
1715
  const newTransactionMeta = {
1828
1716
  ...transactionMetaWithRsv,
1829
1717
  actionId,
@@ -1852,6 +1740,23 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1852
1740
  actionId,
1853
1741
  });
1854
1742
  afterSubmit?.(newTransactionMeta);
1743
+ }, _TransactionController_getChainId = function _TransactionController_getChainId(networkClientId) {
1744
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1745
+ .configuration.chainId;
1746
+ }, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ chainId, networkClientId, }) {
1747
+ if (networkClientId) {
1748
+ return networkClientId;
1749
+ }
1750
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1751
+ chainId,
1752
+ }).id;
1753
+ }, _TransactionController_getEthQuery = function _TransactionController_getEthQuery({ chainId, networkClientId, }) {
1754
+ return new eth_query_1.default(__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { chainId, networkClientId }));
1755
+ }, _TransactionController_getProvider = function _TransactionController_getProvider({ chainId, networkClientId, }) {
1756
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1757
+ chainId,
1758
+ networkClientId,
1759
+ }).provider;
1855
1760
  }, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
1856
1761
  return new nonce_tracker_1.NonceTracker({
1857
1762
  // TODO: Fix types
@@ -1860,18 +1765,23 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1860
1765
  // TODO: Fix types
1861
1766
  blockTracker,
1862
1767
  getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
1863
- getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed),
1768
+ getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed, chainId),
1864
1769
  });
1865
- }, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, etherscanRemoteTransactionSource, chainId, }) {
1770
+ }, _TransactionController_createRemoteTransactionSource = function _TransactionController_createRemoteTransactionSource() {
1771
+ return new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
1772
+ apiKeysByChainId: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").etherscanApiKeysByChainId,
1773
+ includeTokenTransfers: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").includeTokenTransfers,
1774
+ });
1775
+ }, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, remoteTransactionSource, chainId, }) {
1866
1776
  const incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
1867
1777
  blockTracker,
1868
1778
  getCurrentAccount: () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this),
1869
1779
  getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
1870
1780
  getLocalTransactions: () => this.state.transactions,
1871
- getChainId: chainId ? () => chainId : this.getChainId.bind(this),
1781
+ getChainId: () => chainId,
1872
1782
  isEnabled: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").isEnabled,
1873
1783
  queryEntireHistory: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").queryEntireHistory,
1874
- remoteTransactionSource: etherscanRemoteTransactionSource,
1784
+ remoteTransactionSource,
1875
1785
  transactionLimit: __classPrivateFieldGet(this, _TransactionController_transactionHistoryLimit, "f"),
1876
1786
  updateTransactions: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").updateTransactions,
1877
1787
  });
@@ -1879,15 +1789,14 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1879
1789
  return incomingTransactionHelper;
1880
1790
  }, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, }) {
1881
1791
  const ethQuery = new eth_query_1.default(provider);
1882
- const getChainId = chainId ? () => chainId : this.getChainId.bind(this);
1883
1792
  const pendingTransactionTracker = new PendingTransactionTracker_1.PendingTransactionTracker({
1884
1793
  blockTracker,
1885
- getChainId,
1794
+ getChainId: () => chainId,
1886
1795
  getEthQuery: () => ethQuery,
1887
1796
  getTransactions: () => this.state.transactions,
1888
1797
  isResubmitEnabled: __classPrivateFieldGet(this, _TransactionController_pendingTransactionOptions, "f").isResubmitEnabled,
1889
1798
  getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
1890
- chainId: getChainId(),
1799
+ chainId,
1891
1800
  }),
1892
1801
  publishTransaction: (_ethQuery, transactionMeta) => this.publishTransaction(_ethQuery, transactionMeta, {
1893
1802
  skipSubmitHistory: true,
@@ -1900,10 +1809,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1900
1809
  __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
1901
1810
  return pendingTransactionTracker;
1902
1811
  }, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
1903
- this.pendingTransactionTracker.stop();
1904
- __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).call(this, this.pendingTransactionTracker);
1905
- this.incomingTransactionHelper.stop();
1906
- __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).call(this, this.incomingTransactionHelper);
1907
1812
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
1908
1813
  }, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
1909
1814
  incomingTransactionHelper.hub.removeAllListeners('transactions');
@@ -2018,26 +1923,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
2018
1923
  txMeta.layer1GasFee = layer1GasFee;
2019
1924
  }
2020
1925
  });
2021
- }, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ networkClientId: requestNetworkClientId, chainId, }) {
2022
- const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
2023
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
2024
- if (requestNetworkClientId) {
2025
- return requestNetworkClientId;
2026
- }
2027
- if (!chainId || chainId === globalChainId) {
2028
- return globalNetworkClientId;
2029
- }
2030
- return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
2031
- }, _TransactionController_getGlobalNetworkClientId = function _TransactionController_getGlobalNetworkClientId() {
2032
- return this.getNetworkState().selectedNetworkClientId;
2033
- }, _TransactionController_getGlobalChainId = function _TransactionController_getGlobalChainId() {
2034
- return this.messagingSystem.call(`NetworkController:getNetworkClientById`, this.getNetworkState().selectedNetworkClientId).configuration.chainId;
2035
- }, _TransactionController_isCustomNetwork = function _TransactionController_isCustomNetwork(networkClientId) {
2036
- const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
2037
- if (!networkClientId || networkClientId === globalNetworkClientId) {
2038
- return !(0, controller_utils_1.isInfuraNetworkType)(this.getNetworkState().selectedNetworkClientId);
2039
- }
2040
- return (this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.type === network_controller_1.NetworkClientType.Custom);
2041
1926
  }, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
2042
1927
  return this.messagingSystem.call('AccountsController:getSelectedAccount');
2043
1928
  }, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {