@metamask-previews/transaction-controller 39.0.0-preview-e6757fdb → 39.0.0-preview-98c8c66

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 (55) hide show
  1. package/dist/TransactionController.cjs +217 -95
  2. package/dist/TransactionController.cjs.map +1 -1
  3. package/dist/TransactionController.d.cts +53 -34
  4. package/dist/TransactionController.d.cts.map +1 -1
  5. package/dist/TransactionController.d.mts +53 -34
  6. package/dist/TransactionController.d.mts.map +1 -1
  7. package/dist/TransactionController.mjs +218 -96
  8. package/dist/TransactionController.mjs.map +1 -1
  9. package/dist/helpers/EtherscanRemoteTransactionSource.cjs +0 -1
  10. package/dist/helpers/EtherscanRemoteTransactionSource.cjs.map +1 -1
  11. package/dist/helpers/EtherscanRemoteTransactionSource.d.cts.map +1 -1
  12. package/dist/helpers/EtherscanRemoteTransactionSource.d.mts.map +1 -1
  13. package/dist/helpers/EtherscanRemoteTransactionSource.mjs +0 -1
  14. package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +1 -1
  15. package/dist/helpers/GasFeePoller.cjs +4 -4
  16. package/dist/helpers/GasFeePoller.cjs.map +1 -1
  17. package/dist/helpers/GasFeePoller.d.cts +1 -1
  18. package/dist/helpers/GasFeePoller.d.cts.map +1 -1
  19. package/dist/helpers/GasFeePoller.d.mts +1 -1
  20. package/dist/helpers/GasFeePoller.d.mts.map +1 -1
  21. package/dist/helpers/GasFeePoller.mjs +4 -4
  22. package/dist/helpers/GasFeePoller.mjs.map +1 -1
  23. package/dist/helpers/IncomingTransactionHelper.cjs +5 -12
  24. package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -1
  25. package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -1
  26. package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -1
  27. package/dist/helpers/IncomingTransactionHelper.mjs +6 -13
  28. package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
  29. package/dist/helpers/MultichainTrackingHelper.cjs +84 -70
  30. package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -1
  31. package/dist/helpers/MultichainTrackingHelper.d.cts +18 -12
  32. package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -1
  33. package/dist/helpers/MultichainTrackingHelper.d.mts +18 -12
  34. package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -1
  35. package/dist/helpers/MultichainTrackingHelper.mjs +88 -70
  36. package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
  37. package/dist/helpers/PendingTransactionTracker.cjs +22 -24
  38. package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
  39. package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
  40. package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
  41. package/dist/helpers/PendingTransactionTracker.mjs +22 -24
  42. package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
  43. package/dist/types.cjs.map +1 -1
  44. package/dist/types.d.cts +1 -1
  45. package/dist/types.d.cts.map +1 -1
  46. package/dist/types.d.mts +1 -1
  47. package/dist/types.d.mts.map +1 -1
  48. package/dist/types.mjs.map +1 -1
  49. package/dist/utils/etherscan.cjs +1 -2
  50. package/dist/utils/etherscan.cjs.map +1 -1
  51. package/dist/utils/etherscan.d.cts.map +1 -1
  52. package/dist/utils/etherscan.d.mts.map +1 -1
  53. package/dist/utils/etherscan.mjs +2 -3
  54. package/dist/utils/etherscan.mjs.map +1 -1
  55. package/package.json +1 -1
@@ -9,7 +9,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
- var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createIncomingTransactionHelper, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getSelectedAccount, _TransactionController_updateSubmitHistory;
12
+ 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;
13
13
  function $importDefault(module) {
14
14
  if (module?.__esModule) {
15
15
  return module.default;
@@ -22,7 +22,7 @@ import { TransactionFactory } from "@ethereumjs/tx";
22
22
  import $ethereumjsutil from "@ethereumjs/util";
23
23
  const { bufferToHex } = $ethereumjsutil;
24
24
  import { BaseController } from "@metamask/base-controller";
25
- import { query, ApprovalType, ORIGIN_METAMASK, convertHexToDecimal } from "@metamask/controller-utils";
25
+ import { query, ApprovalType, ORIGIN_METAMASK, convertHexToDecimal, isInfuraNetworkType } from "@metamask/controller-utils";
26
26
  import $EthQuery from "@metamask/eth-query";
27
27
  const EthQuery = $importDefault($EthQuery);
28
28
  import { NetworkClientType } from "@metamask/network-controller";
@@ -30,6 +30,7 @@ import { NonceTracker } from "@metamask/nonce-tracker";
30
30
  import { errorCodes, rpcErrors, providerErrors } from "@metamask/rpc-errors";
31
31
  import { add0x } from "@metamask/utils";
32
32
  import { Mutex } from "async-mutex";
33
+ import { MethodRegistry } from "eth-method-registry";
33
34
  import { EventEmitter } from "events";
34
35
  import $lodash from "lodash";
35
36
  const { cloneDeep, mapValues, merge, pickBy, sortBy } = $lodash;
@@ -39,6 +40,7 @@ import { LineaGasFeeFlow } from "./gas-flows/LineaGasFeeFlow.mjs";
39
40
  import { OptimismLayer1GasFeeFlow } from "./gas-flows/OptimismLayer1GasFeeFlow.mjs";
40
41
  import { ScrollLayer1GasFeeFlow } from "./gas-flows/ScrollLayer1GasFeeFlow.mjs";
41
42
  import { TestGasFeeFlow } from "./gas-flows/TestGasFeeFlow.mjs";
43
+ import { EtherscanRemoteTransactionSource } from "./helpers/EtherscanRemoteTransactionSource.mjs";
42
44
  import { GasFeePoller } from "./helpers/GasFeePoller.mjs";
43
45
  import { IncomingTransactionHelper } from "./helpers/IncomingTransactionHelper.mjs";
44
46
  import { MultichainTrackingHelper } from "./helpers/MultichainTrackingHelper.mjs";
@@ -150,10 +152,22 @@ export class TransactionController extends BaseController {
150
152
  this.messagingSystem.publish(`${controllerName}:transactionFinished`, newTransactionMeta);
151
153
  __classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, newTransactionMeta);
152
154
  }
155
+ async registryLookup(fourBytePrefix) {
156
+ const registryMethod = await this.registry.lookup(fourBytePrefix);
157
+ if (!registryMethod) {
158
+ return {
159
+ registryMethod: '',
160
+ parsedRegistryMethod: { name: undefined, args: undefined },
161
+ };
162
+ }
163
+ const parsedRegistryMethod = this.registry.parse(registryMethod);
164
+ return { registryMethod, parsedRegistryMethod };
165
+ }
153
166
  /**
154
167
  * Constructs a TransactionController.
155
168
  *
156
169
  * @param options - The controller options.
170
+ * @param options.blockTracker - The block tracker used to poll for new blocks data.
157
171
  * @param options.disableHistory - Whether to disable storing history in transaction metadata.
158
172
  * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
159
173
  * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
@@ -166,9 +180,12 @@ export class TransactionController extends BaseController {
166
180
  * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
167
181
  * @param options.getSavedGasFees - Gets the saved gas fee config.
168
182
  * @param options.incomingTransactions - Configuration options for incoming transaction support.
183
+ * @param options.isMultichainEnabled - Enable multichain support.
169
184
  * @param options.isSimulationEnabled - Whether new transactions will be automatically simulated.
170
185
  * @param options.messenger - The controller messenger.
186
+ * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
171
187
  * @param options.pendingTransactions - Configuration options for pending transaction support.
188
+ * @param options.provider - The provider used to create the underlying EthQuery instance.
172
189
  * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
173
190
  * @param options.sign - Function used to sign transactions.
174
191
  * @param options.state - Initial state to set on this controller.
@@ -177,7 +194,7 @@ export class TransactionController extends BaseController {
177
194
  * @param options.transactionHistoryLimit - Transaction history limit.
178
195
  * @param options.hooks - The controller hooks.
179
196
  */
180
- constructor({ disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isSimulationEnabled, messenger, pendingTransactions = {}, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, }) {
197
+ 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, }) {
181
198
  super({
182
199
  name: controllerName,
183
200
  metadata,
@@ -198,19 +215,10 @@ export class TransactionController extends BaseController {
198
215
  _TransactionController_transactionHistoryLimit.set(this, void 0);
199
216
  _TransactionController_isSimulationEnabled.set(this, void 0);
200
217
  _TransactionController_testGasFeeFlows.set(this, void 0);
201
- // private async registryLookup(fourBytePrefix: string): Promise<MethodData> {
202
- // const registryMethod = await this.registry.lookup(fourBytePrefix);
203
- // if (!registryMethod) {
204
- // return {
205
- // registryMethod: '',
206
- // parsedRegistryMethod: { name: undefined, args: undefined },
207
- // };
208
- // }
209
- // const parsedRegistryMethod = this.registry.parse(registryMethod);
210
- // return { registryMethod, parsedRegistryMethod };
211
- // }
212
218
  _TransactionController_multichainTrackingHelper.set(this, void 0);
213
219
  _TransactionController_checkForPendingTransactionAndStartPolling.set(this, () => {
220
+ // PendingTransactionTracker reads state through its getTransactions hook
221
+ this.pendingTransactionTracker.startIfPendingTransactions();
214
222
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
215
223
  });
216
224
  this.messagingSystem = messenger;
@@ -219,6 +227,8 @@ export class TransactionController extends BaseController {
219
227
  this.isHistoryDisabled = disableHistory ?? false;
220
228
  this.isSwapsDisabled = disableSwaps ?? false;
221
229
  __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 MethodRegistry({ provider });
222
232
  this.getSavedGasFees = getSavedGasFees ?? ((_chainId) => undefined);
223
233
  this.getCurrentAccountEIP1559Compatibility =
224
234
  getCurrentAccountEIP1559Compatibility ?? (() => Promise.resolve(true));
@@ -246,10 +256,17 @@ export class TransactionController extends BaseController {
246
256
  hooks?.getAdditionalSignArguments ?? (() => []);
247
257
  this.publish =
248
258
  hooks?.publish ?? (() => Promise.resolve({ transactionHash: undefined }));
259
+ this.nonceTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).call(this, {
260
+ provider,
261
+ blockTracker,
262
+ });
249
263
  const findNetworkClientIdByChainId = (chainId) => {
250
264
  return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
251
265
  };
252
266
  __classPrivateFieldSet(this, _TransactionController_multichainTrackingHelper, new MultichainTrackingHelper({
267
+ isMultichainEnabled,
268
+ provider,
269
+ nonceTracker: this.nonceTracker,
253
270
  incomingTransactionOptions: incomingTransactions,
254
271
  findNetworkClientIdByChainId,
255
272
  getNetworkClientById: ((networkClientId) => {
@@ -266,13 +283,28 @@ export class TransactionController extends BaseController {
266
283
  },
267
284
  }), "f");
268
285
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").initialize();
286
+ const etherscanRemoteTransactionSource = new 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
+ });
269
298
  this.gasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeFlows).call(this);
270
299
  this.layer1GasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getLayer1GasFeeFlows).call(this);
271
300
  const gasFeePoller = new GasFeePoller({
272
301
  findNetworkClientIdByChainId,
273
302
  gasFeeFlows: this.gasFeeFlows,
274
303
  getGasFeeControllerEstimates: this.getGasFeeEstimates,
275
- getProvider: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId }),
304
+ getProvider: (chainId, networkClientId) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
305
+ networkClientId,
306
+ chainId,
307
+ }),
276
308
  getTransactions: () => this.state.transactions,
277
309
  layer1GasFeeFlows: this.layer1GasFeeFlows,
278
310
  onStateChange: (listener) => {
@@ -283,6 +315,12 @@ export class TransactionController extends BaseController {
283
315
  // when transactionsController state changes
284
316
  // check for pending transactions and start polling if there are any
285
317
  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
+ log('Detected network change', this.getChainId());
322
+ this.pendingTransactionTracker.startIfPendingTransactions();
323
+ });
286
324
  this.onBootCleanup();
287
325
  __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
288
326
  }
@@ -295,11 +333,26 @@ export class TransactionController extends BaseController {
295
333
  /**
296
334
  * Handle new method data request.
297
335
  *
298
- * @param _fourBytePrefix - The method prefix.
336
+ * @param fourBytePrefix - The method prefix.
299
337
  * @returns The method data object corresponding to the given signature prefix.
300
338
  */
301
- async handleMethodData(_fourBytePrefix) {
302
- throw new Error('Method not implemented.');
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
+ }
303
356
  }
304
357
  /**
305
358
  * Add a new unapproved transaction to state. Parameters will be validated, a
@@ -307,38 +360,40 @@ export class TransactionController extends BaseController {
307
360
  * if not provided. If A `<tx.id>:unapproved` hub event will be emitted once added.
308
361
  *
309
362
  * @param txParams - Standard parameters for an Ethereum transaction.
310
- * @param options - Additional options to control how the transaction is added.
311
- * @param options.actionId - Unique ID to prevent duplicate requests.
312
- * @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
313
- * @param options.method - RPC method that requested the transaction.
314
- * @param options.origin - The origin of the transaction request, such as a dApp hostname.
315
- * @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
316
- * @param options.securityAlertResponse - Response from security validator.
317
- * @param options.sendFlowHistory - The sendFlowHistory entries to add.
318
- * @param options.type - Type of transaction to add, such as 'cancel' or 'swap'.
319
- * @param options.swaps - Options for swaps transactions.
320
- * @param options.swaps.hasApproveTx - Whether the transaction has an approval transaction.
321
- * @param options.swaps.meta - Metadata for swap transaction.
322
- * @param options.networkClientId - The id of the network client for this transaction.
323
- * @param options.traceContext - The parent context for any new traces.
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.
324
377
  * @returns Object containing a promise resolving to the transaction hash if approved.
325
378
  */
326
- async addTransaction(txParams, options) {
327
- log('Adding transaction', txParams, options);
328
- const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
379
+ async addTransaction(txParams, { actionId, deviceConfirmedOn, method, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, networkClientId: requestNetworkClientId, } = {}) {
380
+ log('Adding transaction', txParams);
329
381
  txParams = normalizeTransactionParams(txParams);
330
- if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
331
- throw new Error(`Network client not found - ${networkClientId}`);
382
+ if (requestNetworkClientId &&
383
+ !__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(requestNetworkClientId)) {
384
+ throw new Error('The networkClientId for this transaction could not be found');
332
385
  }
386
+ const networkClientId = requestNetworkClientId ?? __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
333
387
  const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
334
388
  validateTxParams(txParams, isEIP1559Compatible);
335
389
  if (origin && this.getPermittedAccounts) {
336
390
  await validateTransactionOrigin(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
337
391
  }
338
392
  const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
339
- const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
340
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
393
+ const chainId = this.getChainId(networkClientId);
394
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
341
395
  networkClientId,
396
+ chainId,
342
397
  });
343
398
  const transactionType = type ?? (await determineTransactionType(txParams, ethQuery)).type;
344
399
  const existingTransactionMeta = this.getTransactionWithActionId(actionId);
@@ -409,13 +464,29 @@ export class TransactionController extends BaseController {
409
464
  transactionMeta: addedTransactionMeta,
410
465
  };
411
466
  }
412
- startIncomingTransactionPolling(networkClientIds) {
467
+ startIncomingTransactionPolling(networkClientIds = []) {
468
+ if (networkClientIds.length === 0) {
469
+ this.incomingTransactionHelper.start();
470
+ return;
471
+ }
413
472
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").startIncomingTransactionPolling(networkClientIds);
414
473
  }
415
- stopIncomingTransactionPolling(networkClientIds) {
474
+ stopIncomingTransactionPolling(networkClientIds = []) {
475
+ if (networkClientIds.length === 0) {
476
+ this.incomingTransactionHelper.stop();
477
+ return;
478
+ }
416
479
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopIncomingTransactionPolling(networkClientIds);
417
480
  }
481
+ stopAllIncomingTransactionPolling() {
482
+ this.incomingTransactionHelper.stop();
483
+ __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllIncomingTransactionPolling();
484
+ }
418
485
  async updateIncomingTransactions(networkClientIds = []) {
486
+ if (networkClientIds.length === 0) {
487
+ await this.incomingTransactionHelper.update();
488
+ return;
489
+ }
419
490
  await __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").updateIncomingTransactions(networkClientIds);
420
491
  }
421
492
  /**
@@ -479,7 +550,7 @@ export class TransactionController extends BaseController {
479
550
  * @returns The gas and gas price.
480
551
  */
481
552
  async estimateGas(transaction, networkClientId) {
482
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
553
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
483
554
  networkClientId,
484
555
  });
485
556
  const { estimatedGas, simulationFails } = await estimateGas(transaction, ethQuery);
@@ -493,7 +564,7 @@ export class TransactionController extends BaseController {
493
564
  * @param networkClientId - The network client id to use for the estimate.
494
565
  */
495
566
  async estimateGasBuffered(transaction, multiplier, networkClientId) {
496
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
567
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
497
568
  networkClientId,
498
569
  });
499
570
  const { blockGasLimit, estimatedGas, simulationFails } = await estimateGas(transaction, ethQuery);
@@ -536,21 +607,24 @@ export class TransactionController extends BaseController {
536
607
  this.updateTransaction(updatedTransactionMeta, `${controllerName}:updatesecurityAlertResponse - securityAlertResponse updated`);
537
608
  }
538
609
  /**
539
- * Remove transactions from state.
610
+ * Removes all transactions from state, optionally based on the current network.
540
611
  *
541
- * @param options - The options bag.
542
- * @param options.address - Remove transactions from this account only. Defaults to all accounts.
543
- * @param options.chainId - Remove transactions for the specified chain only. Defaults to all chains.
612
+ * @param ignoreNetwork - Determines whether to wipe all transactions, or just those on the
613
+ * current network. If `true`, all transactions are wiped.
614
+ * @param address - If specified, only transactions originating from this address will be
615
+ * wiped on current network.
544
616
  */
545
- wipeTransactions({ address, chainId, } = {}) {
546
- if (!chainId && !address) {
617
+ wipeTransactions(ignoreNetwork, address) {
618
+ /* istanbul ignore next */
619
+ if (ignoreNetwork && !address) {
547
620
  this.update((state) => {
548
621
  state.transactions = [];
549
622
  });
550
623
  return;
551
624
  }
552
- const newTransactions = this.state.transactions.filter(({ chainId: txChainId, txParams }) => {
553
- const isMatchingNetwork = !chainId || chainId === txChainId;
625
+ const currentChainId = this.getChainId();
626
+ const newTransactions = this.state.transactions.filter(({ chainId, txParams }) => {
627
+ const isMatchingNetwork = ignoreNetwork || chainId === currentChainId;
554
628
  if (!isMatchingNetwork) {
555
629
  return true;
556
630
  }
@@ -740,8 +814,10 @@ export class TransactionController extends BaseController {
740
814
  };
741
815
  editableParams.txParams = pickBy(editableParams.txParams);
742
816
  const updatedTransaction = merge({}, transactionMeta, editableParams);
743
- const { networkClientId } = transactionMeta;
744
- const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
817
+ const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
818
+ chainId: transactionMeta.chainId,
819
+ networkClientId: transactionMeta.networkClientId,
820
+ });
745
821
  const ethQuery = new EthQuery(provider);
746
822
  const { type } = await determineTransactionType(updatedTransaction.txParams, ethQuery);
747
823
  updatedTransaction.type = type;
@@ -769,9 +845,19 @@ export class TransactionController extends BaseController {
769
845
  return '';
770
846
  }
771
847
  const initialTx = listOfTxParams[0];
772
- const { chainId } = initialTx;
773
- const common = this.getCommonConfiguration(chainId);
774
- const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
848
+ const common = this.getCommonConfiguration(initialTx.chainId);
849
+ // We need to ensure we get the nonce using the the NonceTracker on the chain matching
850
+ // the txParams. In this context we only have chainId available to us, but the
851
+ // NonceTrackers are keyed by networkClientId. To workaround this, we attempt to find
852
+ // a networkClientId that matches the chainId. As a fallback, the globally selected
853
+ // network's NonceTracker will be used instead.
854
+ let networkClientId;
855
+ try {
856
+ networkClientId = this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, initialTx.chainId);
857
+ }
858
+ catch (err) {
859
+ log('failed to find networkClientId from chainId', err);
860
+ }
775
861
  const initialTxAsEthTx = TransactionFactory.fromTxData(initialTx, {
776
862
  common,
777
863
  });
@@ -853,12 +939,14 @@ export class TransactionController extends BaseController {
853
939
  * Search transaction metadata for matching entries.
854
940
  *
855
941
  * @param opts - Options bag.
942
+ * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
856
943
  * @param opts.initialList - The transactions to search. Defaults to the current state.
944
+ * @param opts.filterToCurrentNetwork - Whether to filter the results to the current network. Defaults to true.
857
945
  * @param opts.limit - The maximum number of transactions to return. No limit by default.
858
- * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
859
946
  * @returns An array of transactions matching the provided options.
860
947
  */
861
- getTransactions({ initialList, limit, searchCriteria = {}, } = {}) {
948
+ getTransactions({ searchCriteria = {}, initialList, filterToCurrentNetwork = true, limit, } = {}) {
949
+ const chainId = this.getChainId();
862
950
  // searchCriteria is an object that might have values that aren't predicate
863
951
  // methods. When providing any other value type (string, number, etc), we
864
952
  // consider this shorthand for "check the value at key for strict equality
@@ -876,6 +964,9 @@ export class TransactionController extends BaseController {
876
964
  // Combine sortBy and pickBy to transform our state object into an array of
877
965
  // matching transactions that are sorted by time.
878
966
  const filteredTransactions = sortBy(pickBy(transactionsToFilter, (transaction) => {
967
+ if (filterToCurrentNetwork && transaction.chainId !== chainId) {
968
+ return false;
969
+ }
879
970
  // iterate over the predicateMethods keys to check if the transaction
880
971
  // matches the searchCriteria
881
972
  for (const [key, predicate] of Object.entries(predicateMethods)) {
@@ -931,9 +1022,9 @@ export class TransactionController extends BaseController {
931
1022
  return filteredTransactions;
932
1023
  }
933
1024
  async estimateGasFee({ transactionParams, chainId, networkClientId: requestNetworkClientId, }) {
934
- const { id: networkClientId, provider } = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
935
- chainId,
1025
+ const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, {
936
1026
  networkClientId: requestNetworkClientId,
1027
+ chainId,
937
1028
  });
938
1029
  const transactionMeta = {
939
1030
  txParams: transactionParams,
@@ -942,7 +1033,10 @@ export class TransactionController extends BaseController {
942
1033
  };
943
1034
  // Guaranteed as the default gas fee flow matches all transactions.
944
1035
  const gasFeeFlow = getGasFeeFlow(transactionMeta, this.gasFeeFlows);
945
- const ethQuery = new EthQuery(provider);
1036
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1037
+ networkClientId,
1038
+ chainId,
1039
+ });
946
1040
  const gasFeeControllerData = await this.getGasFeeEstimates({
947
1041
  networkClientId,
948
1042
  });
@@ -961,9 +1055,9 @@ export class TransactionController extends BaseController {
961
1055
  * @param request.networkClientId - The ID of a specific network client to process the transaction.
962
1056
  */
963
1057
  async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
964
- const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, {
965
- chainId,
1058
+ const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
966
1059
  networkClientId,
1060
+ chainId,
967
1061
  });
968
1062
  return await getTransactionLayer1GasFee({
969
1063
  layer1GasFeeFlows: this.layer1GasFeeFlows,
@@ -1034,10 +1128,15 @@ export class TransactionController extends BaseController {
1034
1128
  const isEIP1559Compatible = transactionMeta.txParams.type !== TransactionEnvelopeType.legacy &&
1035
1129
  (await this.getEIP1559Compatibility(transactionMeta.networkClientId));
1036
1130
  const { networkClientId, chainId } = transactionMeta;
1037
- const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1038
- .configuration.type === NetworkClientType.Custom;
1039
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1040
- const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
1131
+ const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isCustomNetwork).call(this, networkClientId);
1132
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1133
+ networkClientId,
1134
+ chainId,
1135
+ });
1136
+ const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
1137
+ networkClientId,
1138
+ chainId,
1139
+ });
1041
1140
  await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
1042
1141
  await updateGas({
1043
1142
  ethQuery,
@@ -1195,8 +1294,10 @@ export class TransactionController extends BaseController {
1195
1294
  if (!rawTx) {
1196
1295
  return ApprovalState.NotApproved;
1197
1296
  }
1198
- const { networkClientId } = transactionMeta;
1199
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1297
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1298
+ networkClientId: transactionMeta.networkClientId,
1299
+ chainId: transactionMeta.chainId,
1300
+ });
1200
1301
  let preTxBalance;
1201
1302
  const shouldUpdatePreTxBalance = transactionMeta.type === TransactionType.swap;
1202
1303
  if (shouldUpdatePreTxBalance) {
@@ -1390,6 +1491,14 @@ export class TransactionController extends BaseController {
1390
1491
  const isCompleted = this.isLocalFinalState(transaction.status);
1391
1492
  return { meta: transaction, isCompleted };
1392
1493
  }
1494
+ getChainId(networkClientId) {
1495
+ const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
1496
+ const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
1497
+ if (!networkClientId || networkClientId === globalNetworkClientId) {
1498
+ return globalChainId;
1499
+ }
1500
+ return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.chainId;
1501
+ }
1393
1502
  prepareUnsignedEthTx(chainId, txParams) {
1394
1503
  return TransactionFactory.fromTxData(txParams, {
1395
1504
  freeze: false,
@@ -1615,7 +1724,7 @@ export class TransactionController extends BaseController {
1615
1724
  transactionMeta,
1616
1725
  });
1617
1726
  }
1618
- getNonceTrackerTransactions(status, address, chainId) {
1727
+ getNonceTrackerTransactions(status, address, chainId = this.getChainId()) {
1619
1728
  return getAndFormatTransactionsForNonceTracker(chainId, address, status, this.state.transactions);
1620
1729
  }
1621
1730
  onConfirmedTransaction(transactionMeta) {
@@ -1631,11 +1740,13 @@ export class TransactionController extends BaseController {
1631
1740
  }
1632
1741
  async updatePostBalance(transactionMeta) {
1633
1742
  try {
1634
- const { networkClientId, type } = transactionMeta;
1635
- if (type !== TransactionType.swap) {
1743
+ if (transactionMeta.type !== TransactionType.swap) {
1636
1744
  return;
1637
1745
  }
1638
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1746
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1747
+ networkClientId: transactionMeta.networkClientId,
1748
+ chainId: transactionMeta.chainId,
1749
+ });
1639
1750
  const { updatedTransactionMeta, approvalTransactionMeta } = await updatePostTransactionBalance(transactionMeta, {
1640
1751
  ethQuery,
1641
1752
  getTransaction: this.getTransaction.bind(this),
@@ -1657,6 +1768,7 @@ export class TransactionController extends BaseController {
1657
1768
  }
1658
1769
  catch (error) {
1659
1770
  if (this.isTransactionAlreadyConfirmedError(error)) {
1771
+ await this.pendingTransactionTracker.forceCheckTransaction(transactionMeta);
1660
1772
  throw new Error('Previous transaction is already confirmed');
1661
1773
  }
1662
1774
  throw error;
@@ -1711,8 +1823,10 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1711
1823
  newFee,
1712
1824
  txParams: newTxParams,
1713
1825
  });
1714
- const { networkClientId } = transactionMeta;
1715
- const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
1826
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1827
+ networkClientId: transactionMeta.networkClientId,
1828
+ chainId: transactionMeta.chainId,
1829
+ });
1716
1830
  const newTransactionMeta = {
1717
1831
  ...transactionMetaWithRsv,
1718
1832
  actionId,
@@ -1741,23 +1855,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1741
1855
  actionId,
1742
1856
  });
1743
1857
  afterSubmit?.(newTransactionMeta);
1744
- }, _TransactionController_getChainId = function _TransactionController_getChainId(networkClientId) {
1745
- return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
1746
- .configuration.chainId;
1747
- }, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ chainId, networkClientId, }) {
1748
- if (networkClientId) {
1749
- return networkClientId;
1750
- }
1751
- return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1752
- chainId,
1753
- }).id;
1754
- }, _TransactionController_getEthQuery = function _TransactionController_getEthQuery({ chainId, networkClientId, }) {
1755
- return new EthQuery(__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { chainId, networkClientId }));
1756
- }, _TransactionController_getProvider = function _TransactionController_getProvider({ chainId, networkClientId, }) {
1757
- return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
1758
- chainId,
1759
- networkClientId,
1760
- }).provider;
1761
1858
  }, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
1762
1859
  return new NonceTracker({
1763
1860
  // TODO: Fix types
@@ -1766,7 +1863,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1766
1863
  // TODO: Fix types
1767
1864
  blockTracker,
1768
1865
  getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
1769
- getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, TransactionStatus.confirmed, chainId),
1866
+ getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, TransactionStatus.confirmed),
1770
1867
  });
1771
1868
  }, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, etherscanRemoteTransactionSource, chainId, }) {
1772
1869
  const incomingTransactionHelper = new IncomingTransactionHelper({
@@ -1774,7 +1871,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1774
1871
  getCurrentAccount: () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this),
1775
1872
  getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
1776
1873
  getLocalTransactions: () => this.state.transactions,
1777
- getChainId: () => chainId,
1874
+ getChainId: chainId ? () => chainId : this.getChainId.bind(this),
1778
1875
  isEnabled: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").isEnabled,
1779
1876
  queryEntireHistory: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").queryEntireHistory,
1780
1877
  remoteTransactionSource: etherscanRemoteTransactionSource,
@@ -1785,14 +1882,15 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1785
1882
  return incomingTransactionHelper;
1786
1883
  }, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, }) {
1787
1884
  const ethQuery = new EthQuery(provider);
1885
+ const getChainId = chainId ? () => chainId : this.getChainId.bind(this);
1788
1886
  const pendingTransactionTracker = new PendingTransactionTracker({
1789
1887
  blockTracker,
1790
- getChainId: () => chainId,
1888
+ getChainId,
1791
1889
  getEthQuery: () => ethQuery,
1792
1890
  getTransactions: () => this.state.transactions,
1793
1891
  isResubmitEnabled: __classPrivateFieldGet(this, _TransactionController_pendingTransactionOptions, "f").isResubmitEnabled,
1794
1892
  getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
1795
- chainId,
1893
+ chainId: getChainId(),
1796
1894
  }),
1797
1895
  publishTransaction: (_ethQuery, transactionMeta) => this.publishTransaction(_ethQuery, transactionMeta, {
1798
1896
  skipSubmitHistory: true,
@@ -1805,6 +1903,10 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1805
1903
  __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
1806
1904
  return pendingTransactionTracker;
1807
1905
  }, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
1906
+ this.pendingTransactionTracker.stop();
1907
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).call(this, this.pendingTransactionTracker);
1908
+ this.incomingTransactionHelper.stop();
1909
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).call(this, this.incomingTransactionHelper);
1808
1910
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
1809
1911
  }, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
1810
1912
  incomingTransactionHelper.hub.removeAllListeners('transactions');
@@ -1919,6 +2021,26 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
1919
2021
  txMeta.layer1GasFee = layer1GasFee;
1920
2022
  }
1921
2023
  });
2024
+ }, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ networkClientId: requestNetworkClientId, chainId, }) {
2025
+ const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
2026
+ const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
2027
+ if (requestNetworkClientId) {
2028
+ return requestNetworkClientId;
2029
+ }
2030
+ if (!chainId || chainId === globalChainId) {
2031
+ return globalNetworkClientId;
2032
+ }
2033
+ return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
2034
+ }, _TransactionController_getGlobalNetworkClientId = function _TransactionController_getGlobalNetworkClientId() {
2035
+ return this.getNetworkState().selectedNetworkClientId;
2036
+ }, _TransactionController_getGlobalChainId = function _TransactionController_getGlobalChainId() {
2037
+ return this.messagingSystem.call(`NetworkController:getNetworkClientById`, this.getNetworkState().selectedNetworkClientId).configuration.chainId;
2038
+ }, _TransactionController_isCustomNetwork = function _TransactionController_isCustomNetwork(networkClientId) {
2039
+ const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
2040
+ if (!networkClientId || networkClientId === globalNetworkClientId) {
2041
+ return !isInfuraNetworkType(this.getNetworkState().selectedNetworkClientId);
2042
+ }
2043
+ return (this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.type === NetworkClientType.Custom);
1922
2044
  }, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
1923
2045
  return this.messagingSystem.call('AccountsController:getSelectedAccount');
1924
2046
  }, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {