@metamask-previews/transaction-controller 21.2.0-preview.dad68d4 → 23.0.0-preview.0dea691a

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 (61) hide show
  1. package/CHANGELOG.md +58 -1
  2. package/dist/TransactionController.d.ts +114 -113
  3. package/dist/TransactionController.d.ts.map +1 -1
  4. package/dist/TransactionController.js +347 -187
  5. package/dist/TransactionController.js.map +1 -1
  6. package/dist/gas-flows/DefaultGasFeeFlow.d.ts +10 -0
  7. package/dist/gas-flows/DefaultGasFeeFlow.d.ts.map +1 -0
  8. package/dist/gas-flows/DefaultGasFeeFlow.js +78 -0
  9. package/dist/gas-flows/DefaultGasFeeFlow.js.map +1 -0
  10. package/dist/gas-flows/LineaGasFeeFlow.d.ts +12 -0
  11. package/dist/gas-flows/LineaGasFeeFlow.d.ts.map +1 -0
  12. package/dist/gas-flows/LineaGasFeeFlow.js +111 -0
  13. package/dist/gas-flows/LineaGasFeeFlow.js.map +1 -0
  14. package/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +1 -1
  15. package/dist/helpers/EtherscanRemoteTransactionSource.js +28 -8
  16. package/dist/helpers/EtherscanRemoteTransactionSource.js.map +1 -1
  17. package/dist/helpers/GasFeePoller.d.ts +32 -0
  18. package/dist/helpers/GasFeePoller.d.ts.map +1 -0
  19. package/dist/helpers/GasFeePoller.js +144 -0
  20. package/dist/helpers/GasFeePoller.js.map +1 -0
  21. package/dist/helpers/IncomingTransactionHelper.d.ts +17 -3
  22. package/dist/helpers/IncomingTransactionHelper.d.ts.map +1 -1
  23. package/dist/helpers/IncomingTransactionHelper.js +17 -14
  24. package/dist/helpers/IncomingTransactionHelper.js.map +1 -1
  25. package/dist/helpers/MultichainTrackingHelper.d.ts +72 -0
  26. package/dist/helpers/MultichainTrackingHelper.d.ts.map +1 -0
  27. package/dist/helpers/MultichainTrackingHelper.js +292 -0
  28. package/dist/helpers/MultichainTrackingHelper.js.map +1 -0
  29. package/dist/helpers/PendingTransactionTracker.d.ts +13 -7
  30. package/dist/helpers/PendingTransactionTracker.d.ts.map +1 -1
  31. package/dist/helpers/PendingTransactionTracker.js +43 -23
  32. package/dist/helpers/PendingTransactionTracker.js.map +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +3 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/types.d.ts +62 -0
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/types.js +8 -1
  40. package/dist/types.js.map +1 -1
  41. package/dist/utils/etherscan.d.ts +7 -0
  42. package/dist/utils/etherscan.d.ts.map +1 -1
  43. package/dist/utils/etherscan.js +17 -6
  44. package/dist/utils/etherscan.js.map +1 -1
  45. package/dist/utils/gas-fees.d.ts +14 -19
  46. package/dist/utils/gas-fees.d.ts.map +1 -1
  47. package/dist/utils/gas-fees.js +23 -33
  48. package/dist/utils/gas-fees.js.map +1 -1
  49. package/dist/utils/gas-flow.d.ts +32 -0
  50. package/dist/utils/gas-flow.d.ts.map +1 -0
  51. package/dist/utils/gas-flow.js +53 -0
  52. package/dist/utils/gas-flow.js.map +1 -0
  53. package/dist/utils/gas.d.ts +3 -2
  54. package/dist/utils/gas.d.ts.map +1 -1
  55. package/dist/utils/gas.js +4 -5
  56. package/dist/utils/gas.js.map +1 -1
  57. package/dist/utils/nonce.d.ts +3 -3
  58. package/dist/utils/nonce.d.ts.map +1 -1
  59. package/dist/utils/nonce.js +3 -3
  60. package/dist/utils/nonce.js.map +1 -1
  61. package/package.json +9 -8
@@ -8,9 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ 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");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
25
+ var _TransactionController_instances, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_multichainTrackingHelper, _TransactionController_createNonceTracker, _TransactionController_createIncomingTransactionHelper, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_updateTransactionInternal;
14
26
  Object.defineProperty(exports, "__esModule", { value: true });
15
27
  exports.TransactionController = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.HARDFORK = void 0;
16
28
  const common_1 = require("@ethereumjs/common");
@@ -18,6 +30,7 @@ const tx_1 = require("@ethereumjs/tx");
18
30
  const base_controller_1 = require("@metamask/base-controller");
19
31
  const controller_utils_1 = require("@metamask/controller-utils");
20
32
  const eth_query_1 = __importDefault(require("@metamask/eth-query"));
33
+ const network_controller_1 = require("@metamask/network-controller");
21
34
  const rpc_errors_1 = require("@metamask/rpc-errors");
22
35
  const async_mutex_1 = require("async-mutex");
23
36
  const eth_method_registry_1 = require("eth-method-registry");
@@ -26,8 +39,12 @@ const events_1 = require("events");
26
39
  const lodash_1 = require("lodash");
27
40
  const nonce_tracker_1 = require("nonce-tracker");
28
41
  const uuid_1 = require("uuid");
42
+ const DefaultGasFeeFlow_1 = require("./gas-flows/DefaultGasFeeFlow");
43
+ const LineaGasFeeFlow_1 = require("./gas-flows/LineaGasFeeFlow");
29
44
  const EtherscanRemoteTransactionSource_1 = require("./helpers/EtherscanRemoteTransactionSource");
45
+ const GasFeePoller_1 = require("./helpers/GasFeePoller");
30
46
  const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper");
47
+ const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper");
31
48
  const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker");
32
49
  const logger_1 = require("./logger");
33
50
  const types_1 = require("./types");
@@ -44,7 +61,7 @@ exports.HARDFORK = common_1.Hardfork.London;
44
61
  /**
45
62
  * Multiplier used to determine a transaction's increased gas fee during cancellation
46
63
  */
47
- exports.CANCEL_RATE = 1.5;
64
+ exports.CANCEL_RATE = 1.1;
48
65
  /**
49
66
  * Multiplier used to determine a transaction's increased gas fee during speed up
50
67
  */
@@ -57,51 +74,16 @@ const controllerName = 'TransactionController';
57
74
  * Controller responsible for submitting and managing transactions.
58
75
  */
59
76
  class TransactionController extends base_controller_1.BaseControllerV1 {
60
- /**
61
- * Creates a TransactionController instance.
62
- *
63
- * @param options - The controller options.
64
- * @param options.blockTracker - The block tracker used to poll for new blocks data.
65
- * @param options.cancelMultiplier - Multiplier used to determine a transaction's increased gas fee during cancellation.
66
- * @param options.disableHistory - Whether to disable storing history in transaction metadata.
67
- * @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
68
- * @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
69
- * @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
70
- * @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
71
- * @param options.getExternalPendingTransactions - Callback to retrieve pending transactions from external sources.
72
- * @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
73
- * @param options.getNetworkState - Gets the state of the network controller.
74
- * @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
75
- * @param options.getSavedGasFees - Gets the saved gas fee config.
76
- * @param options.getSelectedAddress - Gets the address of the currently selected account.
77
- * @param options.incomingTransactions - Configuration options for incoming transaction support.
78
- * @param options.incomingTransactions.includeTokenTransfers - Whether or not to include ERC20 token transfers.
79
- * @param options.incomingTransactions.isEnabled - Whether or not incoming transaction retrieval is enabled.
80
- * @param options.incomingTransactions.queryEntireHistory - Whether to initially query the entire transaction history or only recent blocks.
81
- * @param options.incomingTransactions.updateTransactions - Whether to update local transactions using remote transaction data.
82
- * @param options.messenger - The controller messenger.
83
- * @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
84
- * @param options.pendingTransactions - Configuration options for pending transaction support.
85
- * @param options.pendingTransactions.isResubmitEnabled - Whether transaction publishing is automatically retried.
86
- * @param options.provider - The provider used to create the underlying EthQuery instance.
87
- * @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
88
- * @param options.speedUpMultiplier - Multiplier used to determine a transaction's increased gas fee during speed up.
89
- * @param options.hooks - The controller hooks.
90
- * @param options.hooks.afterSign - Additional logic to execute after signing a transaction. Return false to not change the status to signed.
91
- * @param options.hooks.beforeApproveOnInit - Additional logic to execute before starting an approval flow for a transaction during initialization. Return false to skip the transaction.
92
- * @param options.hooks.beforeCheckPendingTransaction - Additional logic to execute before checking pending transactions. Return false to prevent the broadcast of the transaction.
93
- * @param options.hooks.beforePublish - Additional logic to execute before publishing a transaction. Return false to prevent the broadcast of the transaction.
94
- * @param options.hooks.getAdditionalSignArguments - Returns additional arguments required to sign a transaction.
95
- * @param options.hooks.publish - Alternate logic to publish a transaction.
96
- * @param config - Initial options used to configure this controller.
97
- * @param state - Initial state to set on this controller.
98
- */
99
- constructor({ blockTracker, cancelMultiplier, disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSavedGasFees, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, pendingTransactions = {}, provider, securityProviderRequest, speedUpMultiplier, hooks = {}, }, config, state) {
77
+ constructor({ blockTracker, disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkState, getPermittedAccounts, getSavedGasFees, getSelectedAddress, incomingTransactions = {}, messenger, onNetworkStateChange, pendingTransactions = {}, provider, securityProviderRequest, getNetworkClientRegistry, isMultichainEnabled = false, hooks, }, config, state) {
100
78
  var _a, _b, _c, _d, _e, _f;
101
79
  super(config, state);
80
+ _TransactionController_instances.add(this);
102
81
  this.inProcessOfSigning = new Set();
103
82
  this.mutex = new async_mutex_1.Mutex();
83
+ _TransactionController_incomingTransactionOptions.set(this, void 0);
84
+ _TransactionController_pendingTransactionOptions.set(this, void 0);
104
85
  this.signAbortCallbacks = new Map();
86
+ _TransactionController_multichainTrackingHelper.set(this, void 0);
105
87
  /**
106
88
  * EventEmitter instance used to listen to specific transactional events
107
89
  */
@@ -110,6 +92,11 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
110
92
  * Name of this controller used during composition
111
93
  */
112
94
  this.name = 'TransactionController';
95
+ _TransactionController_checkForPendingTransactionAndStartPolling.set(this, () => {
96
+ // PendingTransactionTracker reads state through its getTransactions hook
97
+ this.pendingTransactionTracker.startIfPendingTransactions();
98
+ __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
99
+ });
113
100
  this.defaultConfig = {
114
101
  txHistoryLimit: 40,
115
102
  };
@@ -119,10 +106,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
119
106
  lastFetchedBlockNumbers: {},
120
107
  };
121
108
  this.initialize();
122
- this.provider = provider;
123
109
  this.messagingSystem = messenger;
124
110
  this.getNetworkState = getNetworkState;
125
- this.ethQuery = new eth_query_1.default(provider);
126
111
  this.isSendFlowHistoryDisabled = disableSendFlowHistory !== null && disableSendFlowHistory !== void 0 ? disableSendFlowHistory : false;
127
112
  this.isHistoryDisabled = disableHistory !== null && disableHistory !== void 0 ? disableHistory : false;
128
113
  this.isSwapsDisabled = disableSwaps !== null && disableSwaps !== void 0 ? disableSwaps : false;
@@ -140,8 +125,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
140
125
  this.getExternalPendingTransactions =
141
126
  getExternalPendingTransactions !== null && getExternalPendingTransactions !== void 0 ? getExternalPendingTransactions : (() => []);
142
127
  this.securityProviderRequest = securityProviderRequest;
143
- this.cancelMultiplier = cancelMultiplier !== null && cancelMultiplier !== void 0 ? cancelMultiplier : exports.CANCEL_RATE;
144
- this.speedUpMultiplier = speedUpMultiplier !== null && speedUpMultiplier !== void 0 ? speedUpMultiplier : exports.SPEED_UP_RATE;
128
+ __classPrivateFieldSet(this, _TransactionController_incomingTransactionOptions, incomingTransactions, "f");
129
+ __classPrivateFieldSet(this, _TransactionController_pendingTransactionOptions, pendingTransactions, "f");
145
130
  this.afterSign = (_a = hooks === null || hooks === void 0 ? void 0 : hooks.afterSign) !== null && _a !== void 0 ? _a : (() => true);
146
131
  this.beforeApproveOnInit = (_b = hooks === null || hooks === void 0 ? void 0 : hooks.beforeApproveOnInit) !== null && _b !== void 0 ? _b : (() => true);
147
132
  this.beforeCheckPendingTransaction =
@@ -153,50 +138,66 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
153
138
  (_e = hooks === null || hooks === void 0 ? void 0 : hooks.getAdditionalSignArguments) !== null && _e !== void 0 ? _e : (() => []);
154
139
  this.publish =
155
140
  (_f = hooks === null || hooks === void 0 ? void 0 : hooks.publish) !== null && _f !== void 0 ? _f : (() => Promise.resolve({ transactionHash: undefined }));
156
- this.nonceTracker = new nonce_tracker_1.NonceTracker({
157
- // @ts-expect-error provider types misaligned: SafeEventEmitterProvider vs Record<string,string>
141
+ this.nonceTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).call(this, {
158
142
  provider,
159
143
  blockTracker,
160
- getPendingTransactions: this.getNonceTrackerPendingTransactions.bind(this),
161
- getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed),
162
144
  });
163
- this.incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
164
- blockTracker,
165
- getCurrentAccount: getSelectedAddress,
166
- getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
167
- getNetworkState,
168
- isEnabled: incomingTransactions.isEnabled,
169
- queryEntireHistory: incomingTransactions.queryEntireHistory,
170
- remoteTransactionSource: new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
171
- includeTokenTransfers: incomingTransactions.includeTokenTransfers,
145
+ __classPrivateFieldSet(this, _TransactionController_multichainTrackingHelper, new MultichainTrackingHelper_1.MultichainTrackingHelper({
146
+ isMultichainEnabled,
147
+ provider,
148
+ nonceTracker: this.nonceTracker,
149
+ incomingTransactionOptions: incomingTransactions,
150
+ findNetworkClientIdByChainId: (chainId) => {
151
+ return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
152
+ },
153
+ getNetworkClientById: ((networkClientId) => {
154
+ return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId);
172
155
  }),
173
- transactionLimit: this.config.txHistoryLimit,
174
- updateTransactions: incomingTransactions.updateTransactions,
156
+ getNetworkClientRegistry,
157
+ removeIncomingTransactionHelperListeners: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).bind(this),
158
+ removePendingTransactionTrackerListeners: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).bind(this),
159
+ createNonceTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).bind(this),
160
+ createIncomingTransactionHelper: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).bind(this),
161
+ createPendingTransactionTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).bind(this),
162
+ onNetworkStateChange: (listener) => {
163
+ this.messagingSystem.subscribe('NetworkController:stateChange', listener);
164
+ },
165
+ }), "f");
166
+ __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").initialize();
167
+ const etherscanRemoteTransactionSource = new EtherscanRemoteTransactionSource_1.EtherscanRemoteTransactionSource({
168
+ includeTokenTransfers: incomingTransactions.includeTokenTransfers,
175
169
  });
176
- this.incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
177
- this.incomingTransactionHelper.hub.on('updatedLastFetchedBlockNumbers', this.onUpdatedLastFetchedBlockNumbers.bind(this));
178
- this.pendingTransactionTracker = new PendingTransactionTracker_1.PendingTransactionTracker({
179
- approveTransaction: this.approveTransaction.bind(this),
170
+ this.incomingTransactionHelper = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createIncomingTransactionHelper).call(this, {
180
171
  blockTracker,
181
- getChainId: this.getChainId.bind(this),
182
- getEthQuery: () => this.ethQuery,
172
+ etherscanRemoteTransactionSource,
173
+ });
174
+ this.pendingTransactionTracker = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).call(this, {
175
+ provider,
176
+ blockTracker,
177
+ });
178
+ this.gasFeeFlows = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeFlows).call(this);
179
+ const gasFeePoller = new GasFeePoller_1.GasFeePoller({
180
+ // Default gas fee polling is not yet supported by the clients
181
+ gasFeeFlows: this.gasFeeFlows.slice(0, -1),
182
+ getEthQuery: (chainId, networkClientId) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
183
+ networkClientId,
184
+ chainId,
185
+ }),
186
+ getGasFeeControllerEstimates: this.getGasFeeEstimates,
183
187
  getTransactions: () => this.state.transactions,
184
- isResubmitEnabled: pendingTransactions.isResubmitEnabled,
185
- nonceTracker: this.nonceTracker,
186
188
  onStateChange: (listener) => {
187
189
  this.subscribe(listener);
188
- onNetworkStateChange(listener);
189
- listener();
190
- },
191
- publishTransaction: this.publishTransaction.bind(this),
192
- hooks: {
193
- beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
194
- beforePublish: this.beforePublish.bind(this),
195
190
  },
196
191
  });
197
- this.addPendingTransactionTrackerListeners();
192
+ gasFeePoller.hub.on('transaction-updated', (transactionMeta) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, transactionMeta, { skipHistory: true }));
193
+ // when transactionsController state changes
194
+ // check for pending transactions and start polling if there are any
195
+ this.subscribe(__classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
196
+ // TODO once v2 is merged make sure this only runs when
197
+ // selectedNetworkClientId changes
198
198
  onNetworkStateChange(() => {
199
199
  (0, logger_1.projectLogger)('Detected network change', this.getChainId());
200
+ this.pendingTransactionTracker.startIfPendingTransactions();
200
201
  this.onBootCleanup();
201
202
  });
202
203
  this.onBootCleanup();
@@ -219,6 +220,12 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
219
220
  return { registryMethod, parsedRegistryMethod };
220
221
  });
221
222
  }
223
+ /**
224
+ * Stops polling and removes listeners to prepare the controller for garbage collection.
225
+ */
226
+ destroy() {
227
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_stopAllTracking).call(this);
228
+ }
222
229
  /**
223
230
  * Handle new method data request.
224
231
  *
@@ -263,21 +270,30 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
263
270
  * @param opts.swaps - Options for swaps transactions.
264
271
  * @param opts.swaps.hasApproveTx - Whether the transaction has an approval transaction.
265
272
  * @param opts.swaps.meta - Metadata for swap transaction.
273
+ * @param opts.networkClientId - The id of the network client for this transaction.
266
274
  * @returns Object containing a promise resolving to the transaction hash if approved.
267
275
  */
268
- addTransaction(txParams, { actionId, deviceConfirmedOn, method, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, type, } = {}) {
276
+ addTransaction(txParams, { actionId, deviceConfirmedOn, method, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, type, networkClientId, } = {}) {
269
277
  return __awaiter(this, void 0, void 0, function* () {
270
278
  (0, logger_1.projectLogger)('Adding transaction', txParams);
271
279
  txParams = (0, utils_1.normalizeTxParams)(txParams);
272
- const isEIP1559Compatible = yield this.getEIP1559Compatibility();
280
+ if (networkClientId &&
281
+ !__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
282
+ throw new Error('The networkClientId for this transaction could not be found');
283
+ }
284
+ const isEIP1559Compatible = yield this.getEIP1559Compatibility(networkClientId);
273
285
  (0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
274
286
  if (origin) {
275
287
  yield (0, validation_1.validateTransactionOrigin)(yield this.getPermittedAccounts(origin), this.getSelectedAddress(), txParams.from, origin);
276
288
  }
277
289
  const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
278
- const transactionType = type !== null && type !== void 0 ? type : (yield (0, transaction_type_1.determineTransactionType)(txParams, this.ethQuery)).type;
290
+ const chainId = this.getChainId(networkClientId);
291
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
292
+ networkClientId,
293
+ chainId,
294
+ });
295
+ const transactionType = type !== null && type !== void 0 ? type : (yield (0, transaction_type_1.determineTransactionType)(txParams, ethQuery)).type;
279
296
  const existingTransactionMeta = this.getTransactionWithActionId(actionId);
280
- const chainId = this.getChainId();
281
297
  // If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.
282
298
  const transactionMeta = existingTransactionMeta || {
283
299
  // Add actionId to txMeta to check if same actionId is seen again
@@ -294,6 +310,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
294
310
  userEditedGasLimit: false,
295
311
  verifiedOnBlockchain: false,
296
312
  type: transactionType,
313
+ networkClientId,
297
314
  };
298
315
  yield this.updateGasProperties(transactionMeta);
299
316
  // Checks if a transaction already exists with a given actionId
@@ -330,15 +347,31 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
330
347
  };
331
348
  });
332
349
  }
333
- startIncomingTransactionPolling() {
334
- this.incomingTransactionHelper.start();
350
+ startIncomingTransactionPolling(networkClientIds = []) {
351
+ if (networkClientIds.length === 0) {
352
+ this.incomingTransactionHelper.start();
353
+ return;
354
+ }
355
+ __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").startIncomingTransactionPolling(networkClientIds);
335
356
  }
336
- stopIncomingTransactionPolling() {
357
+ stopIncomingTransactionPolling(networkClientIds = []) {
358
+ if (networkClientIds.length === 0) {
359
+ this.incomingTransactionHelper.stop();
360
+ return;
361
+ }
362
+ __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopIncomingTransactionPolling(networkClientIds);
363
+ }
364
+ stopAllIncomingTransactionPolling() {
337
365
  this.incomingTransactionHelper.stop();
366
+ __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllIncomingTransactionPolling();
338
367
  }
339
- updateIncomingTransactions() {
368
+ updateIncomingTransactions(networkClientIds = []) {
340
369
  return __awaiter(this, void 0, void 0, function* () {
341
- yield this.incomingTransactionHelper.update();
370
+ if (networkClientIds.length === 0) {
371
+ yield this.incomingTransactionHelper.update();
372
+ return;
373
+ }
374
+ yield __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").updateIncomingTransactions(networkClientIds);
342
375
  });
343
376
  }
344
377
  /**
@@ -372,21 +405,21 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
372
405
  throw new Error('No sign method defined.');
373
406
  }
374
407
  // gasPrice (legacy non EIP1559)
375
- const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, this.cancelMultiplier);
408
+ const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, exports.CANCEL_RATE);
376
409
  const gasPriceFromValues = (0, utils_1.isGasPriceValue)(gasValues) && gasValues.gasPrice;
377
410
  const newGasPrice = (gasPriceFromValues &&
378
411
  (0, utils_1.validateMinimumIncrease)(gasPriceFromValues, minGasPrice)) ||
379
412
  minGasPrice;
380
413
  // maxFeePerGas (EIP1559)
381
414
  const existingMaxFeePerGas = (_a = transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.maxFeePerGas;
382
- const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, this.cancelMultiplier);
415
+ const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, exports.CANCEL_RATE);
383
416
  const maxFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxFeePerGas;
384
417
  const newMaxFeePerGas = (maxFeePerGasValues &&
385
418
  (0, utils_1.validateMinimumIncrease)(maxFeePerGasValues, minMaxFeePerGas)) ||
386
419
  (existingMaxFeePerGas && minMaxFeePerGas);
387
420
  // maxPriorityFeePerGas (EIP1559)
388
421
  const existingMaxPriorityFeePerGas = (_b = transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.maxPriorityFeePerGas;
389
- const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, this.cancelMultiplier);
422
+ const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, exports.CANCEL_RATE);
390
423
  const maxPriorityFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxPriorityFeePerGas;
391
424
  const newMaxPriorityFeePerGas = (maxPriorityFeePerGasValues &&
392
425
  (0, utils_1.validateMinimumIncrease)(maxPriorityFeePerGasValues, minMaxPriorityFeePerGas)) ||
@@ -410,7 +443,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
410
443
  to: transactionMeta.txParams.from,
411
444
  value: '0x0',
412
445
  };
413
- const unsignedEthTx = this.prepareUnsignedEthTx(newTxParams);
446
+ const unsignedEthTx = this.prepareUnsignedEthTx(transactionMeta.chainId, newTxParams);
414
447
  const signedTx = yield this.sign(unsignedEthTx, transactionMeta.txParams.from);
415
448
  const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
416
449
  const newFee = (_c = newTxParams.maxFeePerGas) !== null && _c !== void 0 ? _c : newTxParams.gasPrice;
@@ -422,10 +455,15 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
422
455
  newFee,
423
456
  txParams: newTxParams,
424
457
  });
425
- const hash = yield this.publishTransaction(rawTx);
458
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
459
+ networkClientId: transactionMeta.networkClientId,
460
+ chainId: transactionMeta.chainId,
461
+ });
462
+ const hash = yield this.publishTransactionForRetry(ethQuery, rawTx, transactionMeta);
426
463
  const cancelTransactionMeta = {
427
464
  actionId,
428
465
  chainId: transactionMeta.chainId,
466
+ networkClientId: transactionMeta.networkClientId,
429
467
  estimatedBaseFee,
430
468
  hash,
431
469
  id: (0, uuid_1.v1)(),
@@ -480,28 +518,28 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
480
518
  throw new Error('No sign method defined.');
481
519
  }
482
520
  // gasPrice (legacy non EIP1559)
483
- const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, this.speedUpMultiplier);
521
+ const minGasPrice = (0, utils_1.getIncreasedPriceFromExisting)(transactionMeta.txParams.gasPrice, exports.SPEED_UP_RATE);
484
522
  const gasPriceFromValues = (0, utils_1.isGasPriceValue)(gasValues) && gasValues.gasPrice;
485
523
  const newGasPrice = (gasPriceFromValues &&
486
524
  (0, utils_1.validateMinimumIncrease)(gasPriceFromValues, minGasPrice)) ||
487
525
  minGasPrice;
488
526
  // maxFeePerGas (EIP1559)
489
527
  const existingMaxFeePerGas = (_a = transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.maxFeePerGas;
490
- const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, this.speedUpMultiplier);
528
+ const minMaxFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxFeePerGas, exports.SPEED_UP_RATE);
491
529
  const maxFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxFeePerGas;
492
530
  const newMaxFeePerGas = (maxFeePerGasValues &&
493
531
  (0, utils_1.validateMinimumIncrease)(maxFeePerGasValues, minMaxFeePerGas)) ||
494
532
  (existingMaxFeePerGas && minMaxFeePerGas);
495
533
  // maxPriorityFeePerGas (EIP1559)
496
534
  const existingMaxPriorityFeePerGas = (_b = transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.maxPriorityFeePerGas;
497
- const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, this.speedUpMultiplier);
535
+ const minMaxPriorityFeePerGas = (0, utils_1.getIncreasedPriceFromExisting)(existingMaxPriorityFeePerGas, exports.SPEED_UP_RATE);
498
536
  const maxPriorityFeePerGasValues = (0, utils_1.isFeeMarketEIP1559Values)(gasValues) && gasValues.maxPriorityFeePerGas;
499
537
  const newMaxPriorityFeePerGas = (maxPriorityFeePerGasValues &&
500
538
  (0, utils_1.validateMinimumIncrease)(maxPriorityFeePerGasValues, minMaxPriorityFeePerGas)) ||
501
539
  (existingMaxPriorityFeePerGas && minMaxPriorityFeePerGas);
502
540
  const txParams = newMaxFeePerGas && newMaxPriorityFeePerGas
503
541
  ? Object.assign(Object.assign({}, transactionMeta.txParams), { gasLimit: transactionMeta.txParams.gas, maxFeePerGas: newMaxFeePerGas, maxPriorityFeePerGas: newMaxPriorityFeePerGas, type: types_1.TransactionEnvelopeType.feeMarket }) : Object.assign(Object.assign({}, transactionMeta.txParams), { gasLimit: transactionMeta.txParams.gas, gasPrice: newGasPrice });
504
- const unsignedEthTx = this.prepareUnsignedEthTx(txParams);
542
+ const unsignedEthTx = this.prepareUnsignedEthTx(transactionMeta.chainId, txParams);
505
543
  const signedTx = yield this.sign(unsignedEthTx, transactionMeta.txParams.from);
506
544
  yield this.updateTransactionMetaRSV(transactionMeta, signedTx);
507
545
  const rawTx = (0, ethereumjs_util_1.bufferToHex)(signedTx.serialize());
@@ -510,7 +548,11 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
510
548
  ? transactionMeta.txParams.maxFeePerGas
511
549
  : transactionMeta.txParams.gasPrice;
512
550
  (0, logger_1.projectLogger)('Submitting speed up transaction', { oldFee, newFee, txParams });
513
- const hash = yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTx]);
551
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
552
+ networkClientId: transactionMeta.networkClientId,
553
+ chainId: transactionMeta.chainId,
554
+ });
555
+ const hash = yield this.publishTransactionForRetry(ethQuery, rawTx, transactionMeta);
514
556
  const baseTransactionMeta = Object.assign(Object.assign({}, transactionMeta), { estimatedBaseFee, id: (0, uuid_1.v1)(), time: Date.now(), hash,
515
557
  actionId, originalGasEstimate: transactionMeta.txParams.gas, type: types_1.TransactionType.retry, originalType: transactionMeta.type });
516
558
  const newTransactionMeta = newMaxFeePerGas && newMaxPriorityFeePerGas
@@ -532,11 +574,15 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
532
574
  * Estimates required gas for a given transaction.
533
575
  *
534
576
  * @param transaction - The transaction to estimate gas for.
577
+ * @param networkClientId - The network client id to use for the estimate.
535
578
  * @returns The gas and gas price.
536
579
  */
537
- estimateGas(transaction) {
580
+ estimateGas(transaction, networkClientId) {
538
581
  return __awaiter(this, void 0, void 0, function* () {
539
- const { estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, this.ethQuery);
582
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
583
+ networkClientId,
584
+ });
585
+ const { estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, ethQuery);
540
586
  return { gas: estimatedGas, simulationFails };
541
587
  });
542
588
  }
@@ -545,10 +591,14 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
545
591
  *
546
592
  * @param transaction - The transaction params to estimate gas for.
547
593
  * @param multiplier - The multiplier to use for the gas buffer.
594
+ * @param networkClientId - The network client id to use for the estimate.
548
595
  */
549
- estimateGasBuffered(transaction, multiplier) {
596
+ estimateGasBuffered(transaction, multiplier, networkClientId) {
550
597
  return __awaiter(this, void 0, void 0, function* () {
551
- const { blockGasLimit, estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, this.ethQuery);
598
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
599
+ networkClientId,
600
+ });
601
+ const { blockGasLimit, estimatedGas, simulationFails } = yield (0, gas_1.estimateGas)(transaction, ethQuery);
552
602
  const gas = (0, gas_1.addGasBuffer)(estimatedGas, blockGasLimit, multiplier);
553
603
  return {
554
604
  gas,
@@ -563,15 +613,10 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
563
613
  * @param note - A note or update reason to include in the transaction history.
564
614
  */
565
615
  updateTransaction(transactionMeta, note) {
566
- const { transactions } = this.state;
567
- transactionMeta.txParams = (0, utils_1.normalizeTxParams)(transactionMeta.txParams);
568
- (0, validation_1.validateTxParams)(transactionMeta.txParams);
569
- if (!this.isHistoryDisabled) {
570
- (0, history_1.updateTransactionHistory)(transactionMeta, note);
571
- }
572
- const index = transactions.findIndex(({ id }) => transactionMeta.id === id);
573
- transactions[index] = transactionMeta;
574
- this.update({ transactions: this.trimTransactionsForState(transactions) });
616
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, transactionMeta, {
617
+ note,
618
+ skipHistory: this.isHistoryDisabled,
619
+ });
575
620
  }
576
621
  /**
577
622
  * Update the security alert response for a transaction.
@@ -618,12 +663,6 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
618
663
  transactions: this.trimTransactionsForState(newTransactions),
619
664
  });
620
665
  }
621
- startIncomingTransactionProcessing() {
622
- this.incomingTransactionHelper.start();
623
- }
624
- stopIncomingTransactionProcessing() {
625
- this.incomingTransactionHelper.stop();
626
- }
627
666
  /**
628
667
  * Adds external provided transaction to state as confirmed transaction.
629
668
  *
@@ -769,16 +808,9 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
769
808
  this.updateTransaction(updatedMeta, 'TransactionController:updatePreviousGasParams - Previous gas values updated');
770
809
  return this.getTransaction(transactionId);
771
810
  }
772
- /**
773
- * Gets the next nonce according to the nonce-tracker.
774
- * Ensure `releaseLock` is called once processing of the `nonce` value is complete.
775
- *
776
- * @param address - The hex string address for the transaction.
777
- * @returns object with the `nextNonce` `nonceDetails`, and the releaseLock.
778
- */
779
- getNonceLock(address) {
811
+ getNonceLock(address, networkClientId) {
780
812
  return __awaiter(this, void 0, void 0, function* () {
781
- return this.nonceTracker.getNonceLock(address);
813
+ return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNonceLock(address, networkClientId);
782
814
  });
783
815
  }
784
816
  /**
@@ -813,7 +845,10 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
813
845
  };
814
846
  editableParams.txParams = (0, lodash_1.pickBy)(editableParams.txParams);
815
847
  const updatedTransaction = (0, lodash_1.merge)(transactionMeta, editableParams);
816
- const { type } = yield (0, transaction_type_1.determineTransactionType)(updatedTransaction.txParams, this.ethQuery);
848
+ const { type } = yield (0, transaction_type_1.determineTransactionType)(updatedTransaction.txParams, __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
849
+ networkClientId: transactionMeta.networkClientId,
850
+ chainId: transactionMeta.chainId,
851
+ }));
817
852
  updatedTransaction.type = type;
818
853
  this.updateTransaction(updatedTransaction, `Update Editable Params for ${txId}`);
819
854
  return this.getTransaction(txId);
@@ -836,7 +871,19 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
836
871
  return '';
837
872
  }
838
873
  const initialTx = listOfTxParams[0];
839
- const common = this.getCommonConfiguration();
874
+ const common = this.getCommonConfiguration(initialTx.chainId);
875
+ // We need to ensure we get the nonce using the the NonceTracker on the chain matching
876
+ // the txParams. In this context we only have chainId available to us, but the
877
+ // NonceTrackers are keyed by networkClientId. To workaround this, we attempt to find
878
+ // a networkClientId that matches the chainId. As a fallback, the globally selected
879
+ // network's NonceTracker will be used instead.
880
+ let networkClientId;
881
+ try {
882
+ networkClientId = this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, initialTx.chainId);
883
+ }
884
+ catch (err) {
885
+ (0, logger_1.projectLogger)('failed to find networkClientId from chainId', err);
886
+ }
840
887
  const initialTxAsEthTx = tx_1.TransactionFactory.fromTxData(initialTx, {
841
888
  common,
842
889
  });
@@ -851,7 +898,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
851
898
  const fromAddress = initialTx.from;
852
899
  const requiresNonce = hasNonce !== true;
853
900
  nonceLock = requiresNonce
854
- ? yield this.nonceTracker.getNonceLock(fromAddress)
901
+ ? yield this.getNonceLock(fromAddress, networkClientId)
855
902
  : undefined;
856
903
  const nonce = nonceLock
857
904
  ? (0, ethereumjs_util_1.addHexPrefix)(nonceLock.nextNonce.toString(16))
@@ -861,7 +908,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
861
908
  }
862
909
  rawTransactions = yield Promise.all(listOfTxParams.map((txParams) => {
863
910
  txParams.nonce = nonce;
864
- return this.signExternalTransaction(txParams);
911
+ return this.signExternalTransaction(txParams.chainId, txParams);
865
912
  }));
866
913
  }
867
914
  catch (err) {
@@ -1019,19 +1066,18 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1019
1066
  }
1020
1067
  return filteredTransactions;
1021
1068
  }
1022
- signExternalTransaction(transactionParams) {
1069
+ signExternalTransaction(chainId, transactionParams) {
1023
1070
  return __awaiter(this, void 0, void 0, function* () {
1024
1071
  if (!this.sign) {
1025
1072
  throw new Error('No sign method defined.');
1026
1073
  }
1027
1074
  const normalizedTransactionParams = (0, utils_1.normalizeTxParams)(transactionParams);
1028
- const chainId = this.getChainId();
1029
1075
  const type = (0, utils_1.isEIP1559Transaction)(normalizedTransactionParams)
1030
1076
  ? types_1.TransactionEnvelopeType.feeMarket
1031
1077
  : types_1.TransactionEnvelopeType.legacy;
1032
1078
  const updatedTransactionParams = Object.assign(Object.assign({}, normalizedTransactionParams), { type, gasLimit: normalizedTransactionParams.gas, chainId });
1033
1079
  const { from } = updatedTransactionParams;
1034
- const common = this.getCommonConfiguration();
1080
+ const common = this.getCommonConfiguration(chainId);
1035
1081
  const unsignedTransaction = tx_1.TransactionFactory.fromTxData(updatedTransactionParams, { common });
1036
1082
  const signedTransaction = yield this.sign(unsignedTransaction, from);
1037
1083
  const rawTransaction = (0, ethereumjs_util_1.bufferToHex)(signedTransaction.serialize());
@@ -1069,35 +1115,42 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1069
1115
  }
1070
1116
  updateGasProperties(transactionMeta) {
1071
1117
  return __awaiter(this, void 0, void 0, function* () {
1072
- const isEIP1559Compatible = (yield this.getEIP1559Compatibility()) &&
1118
+ const isEIP1559Compatible = (yield this.getEIP1559Compatibility(transactionMeta.networkClientId)) &&
1073
1119
  transactionMeta.txParams.type !== types_1.TransactionEnvelopeType.legacy;
1074
- const chainId = this.getChainId();
1120
+ const { networkClientId, chainId } = transactionMeta;
1121
+ const isCustomNetwork = networkClientId
1122
+ ? this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.type === network_controller_1.NetworkClientType.Custom
1123
+ : this.getNetworkState().providerConfig.type === controller_utils_1.NetworkType.rpc;
1075
1124
  yield (0, gas_1.updateGas)({
1076
- ethQuery: this.ethQuery,
1077
- providerConfig: this.getNetworkState().providerConfig,
1125
+ ethQuery: __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1126
+ networkClientId,
1127
+ chainId,
1128
+ }),
1129
+ chainId,
1130
+ isCustomNetwork,
1078
1131
  txMeta: transactionMeta,
1079
1132
  });
1080
1133
  yield (0, gas_fees_1.updateGasFees)({
1081
1134
  eip1559: isEIP1559Compatible,
1082
- ethQuery: this.ethQuery,
1083
- getSavedGasFees: this.getSavedGasFees.bind(this, chainId),
1084
- getGasFeeEstimates: this.getGasFeeEstimates.bind(this),
1135
+ ethQuery: __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1136
+ networkClientId,
1137
+ chainId,
1138
+ }),
1139
+ gasFeeFlows: this.gasFeeFlows,
1140
+ getGasFeeEstimates: this.getGasFeeEstimates,
1141
+ getSavedGasFees: this.getSavedGasFees.bind(this),
1085
1142
  txMeta: transactionMeta,
1086
1143
  });
1087
1144
  });
1088
1145
  }
1089
- getCurrentChainTransactionsByStatus(status) {
1090
- const chainId = this.getChainId();
1091
- return this.state.transactions.filter((transaction) => transaction.status === status && transaction.chainId === chainId);
1092
- }
1093
1146
  onBootCleanup() {
1094
1147
  this.submitApprovedTransactions();
1095
1148
  }
1096
1149
  /**
1097
- * Force to submit approved transactions on current chain.
1150
+ * Force submit approved transactions for all chains.
1098
1151
  */
1099
1152
  submitApprovedTransactions() {
1100
- const approvedTransactions = this.getCurrentChainTransactionsByStatus(types_1.TransactionStatus.approved);
1153
+ const approvedTransactions = this.state.transactions.filter((transaction) => transaction.status === types_1.TransactionStatus.approved);
1101
1154
  for (const transactionMeta of approvedTransactions) {
1102
1155
  if (this.beforeApproveOnInit(transactionMeta)) {
1103
1156
  this.approveTransaction(transactionMeta.id).catch((error) => {
@@ -1191,10 +1244,9 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1191
1244
  return __awaiter(this, void 0, void 0, function* () {
1192
1245
  const { transactions } = this.state;
1193
1246
  const releaseLock = yield this.mutex.acquire();
1194
- const chainId = this.getChainId();
1195
1247
  const index = transactions.findIndex(({ id }) => transactionId === id);
1196
1248
  const transactionMeta = transactions[index];
1197
- const { txParams: { from }, } = transactionMeta;
1249
+ const { txParams: { from }, networkClientId, } = transactionMeta;
1198
1250
  let releaseNonceLock;
1199
1251
  try {
1200
1252
  if (!this.sign) {
@@ -1202,7 +1254,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1202
1254
  this.failTransaction(transactionMeta, new Error('No sign method defined.'));
1203
1255
  return;
1204
1256
  }
1205
- else if (!chainId) {
1257
+ else if (!transactionMeta.chainId) {
1206
1258
  releaseLock();
1207
1259
  this.failTransaction(transactionMeta, new Error('No chainId defined.'));
1208
1260
  return;
@@ -1211,11 +1263,11 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1211
1263
  (0, logger_1.projectLogger)('Skipping approval as signing in progress', transactionId);
1212
1264
  return;
1213
1265
  }
1214
- const [nonce, releaseNonce] = yield (0, nonce_1.getNextNonce)(transactionMeta, this.nonceTracker);
1266
+ const [nonce, releaseNonce] = yield (0, nonce_1.getNextNonce)(transactionMeta, (address) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNonceLock(address, networkClientId));
1215
1267
  releaseNonceLock = releaseNonce;
1216
1268
  transactionMeta.status = types_1.TransactionStatus.approved;
1217
1269
  transactionMeta.txParams.nonce = nonce;
1218
- transactionMeta.txParams.chainId = chainId;
1270
+ transactionMeta.txParams.chainId = transactionMeta.chainId;
1219
1271
  const baseTxParams = Object.assign(Object.assign({}, transactionMeta.txParams), { gasLimit: transactionMeta.txParams.gas });
1220
1272
  this.updateTransaction(transactionMeta, 'TransactionController#approveTransaction - Transaction approved');
1221
1273
  this.onTransactionStatusChange(transactionMeta);
@@ -1231,16 +1283,20 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1231
1283
  if (!rawTx) {
1232
1284
  return;
1233
1285
  }
1286
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1287
+ networkClientId: transactionMeta.networkClientId,
1288
+ chainId: transactionMeta.chainId,
1289
+ });
1234
1290
  if (transactionMeta.type === types_1.TransactionType.swap) {
1235
1291
  (0, logger_1.projectLogger)('Determining pre-transaction balance');
1236
- const preTxBalance = yield (0, controller_utils_1.query)(this.ethQuery, 'getBalance', [from]);
1292
+ const preTxBalance = yield (0, controller_utils_1.query)(ethQuery, 'getBalance', [from]);
1237
1293
  transactionMeta.preTxBalance = preTxBalance;
1238
1294
  (0, logger_1.projectLogger)('Updated pre-transaction balance', transactionMeta.preTxBalance);
1239
1295
  }
1240
1296
  (0, logger_1.projectLogger)('Publishing transaction', txParams);
1241
1297
  let { transactionHash: hash } = yield this.publish(transactionMeta, rawTx);
1242
1298
  if (hash === undefined) {
1243
- hash = yield this.publishTransaction(rawTx);
1299
+ hash = yield this.publishTransaction(ethQuery, rawTx);
1244
1300
  }
1245
1301
  (0, logger_1.projectLogger)('Publish successful', hash);
1246
1302
  transactionMeta.hash = hash;
@@ -1266,9 +1322,9 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1266
1322
  }
1267
1323
  });
1268
1324
  }
1269
- publishTransaction(rawTransaction) {
1325
+ publishTransaction(ethQuery, rawTransaction) {
1270
1326
  return __awaiter(this, void 0, void 0, function* () {
1271
- return yield (0, controller_utils_1.query)(this.ethQuery, 'sendRawTransaction', [rawTransaction]);
1327
+ return yield (0, controller_utils_1.query)(ethQuery, 'sendRawTransaction', [rawTransaction]);
1272
1328
  });
1273
1329
  }
1274
1330
  /**
@@ -1384,14 +1440,17 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1384
1440
  const isCompleted = this.isLocalFinalState(transaction.status);
1385
1441
  return { meta: transaction, isCompleted };
1386
1442
  }
1387
- getChainId() {
1443
+ getChainId(networkClientId) {
1444
+ if (networkClientId) {
1445
+ return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.chainId;
1446
+ }
1388
1447
  const { providerConfig } = this.getNetworkState();
1389
1448
  return providerConfig.chainId;
1390
1449
  }
1391
- prepareUnsignedEthTx(txParams) {
1450
+ prepareUnsignedEthTx(chainId, txParams) {
1392
1451
  return tx_1.TransactionFactory.fromTxData(txParams, {
1393
- common: this.getCommonConfiguration(),
1394
1452
  freeze: false,
1453
+ common: this.getCommonConfiguration(chainId),
1395
1454
  });
1396
1455
  }
1397
1456
  /**
@@ -1401,17 +1460,11 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1401
1460
  * specified in txParams, @ethereumjs/tx is able to determine which EIP-2718
1402
1461
  * transaction type to use.
1403
1462
  *
1463
+ * @param chainId - The chainId to use for the configuration.
1404
1464
  * @returns common configuration object
1405
1465
  */
1406
- getCommonConfiguration() {
1407
- const { providerConfig: { type: chain, chainId, nickname: name }, } = this.getNetworkState();
1408
- if (chain !== controller_utils_1.RPC &&
1409
- chain !== controller_utils_1.NetworkType['linea-goerli'] &&
1410
- chain !== controller_utils_1.NetworkType['linea-mainnet']) {
1411
- return new common_1.Common({ chain, hardfork: exports.HARDFORK });
1412
- }
1466
+ getCommonConfiguration(chainId) {
1413
1467
  const customChainParams = {
1414
- name,
1415
1468
  chainId: parseInt(chainId, 16),
1416
1469
  defaultHardfork: exports.HARDFORK,
1417
1470
  };
@@ -1466,7 +1519,7 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1466
1519
  */
1467
1520
  addExternalTransaction(transactionMeta) {
1468
1521
  var _a, _b;
1469
- const chainId = this.getChainId();
1522
+ const { chainId } = transactionMeta;
1470
1523
  const { transactions } = this.state;
1471
1524
  const fromAddress = (_a = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.from;
1472
1525
  const sameFromAndNetworkTransactions = transactions.filter((transaction) => transaction.txParams.from === fromAddress &&
@@ -1493,10 +1546,13 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1493
1546
  */
1494
1547
  markNonceDuplicatesDropped(transactionId) {
1495
1548
  var _a, _b;
1496
- const chainId = this.getChainId();
1497
1549
  const transactionMeta = this.getTransaction(transactionId);
1498
- const nonce = (_a = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.nonce;
1499
- const from = (_b = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.from;
1550
+ if (!transactionMeta) {
1551
+ return;
1552
+ }
1553
+ const nonce = (_a = transactionMeta.txParams) === null || _a === void 0 ? void 0 : _a.nonce;
1554
+ const from = (_b = transactionMeta.txParams) === null || _b === void 0 ? void 0 : _b.from;
1555
+ const { chainId } = transactionMeta;
1500
1556
  const sameNonceTxs = this.state.transactions.filter((transaction) => transaction.id !== transactionId &&
1501
1557
  transaction.txParams.from === from &&
1502
1558
  transaction.txParams.nonce === nonce &&
@@ -1507,8 +1563,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1507
1563
  }
1508
1564
  // Mark all same nonce transactions as dropped and give it a replacedBy hash
1509
1565
  for (const transaction of sameNonceTxs) {
1510
- transaction.replacedBy = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.hash;
1511
- transaction.replacedById = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.id;
1566
+ transaction.replacedBy = transactionMeta.hash;
1567
+ transaction.replacedById = transactionMeta.id;
1512
1568
  // Drop any transaction that wasn't previously failed (off chain failure)
1513
1569
  if (transaction.status !== types_1.TransactionStatus.failed) {
1514
1570
  this.setTransactionStatusDropped(transaction);
@@ -1564,23 +1620,17 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1564
1620
  }
1565
1621
  });
1566
1622
  }
1567
- getEIP1559Compatibility() {
1623
+ getEIP1559Compatibility(networkClientId) {
1568
1624
  return __awaiter(this, void 0, void 0, function* () {
1569
- const currentNetworkIsEIP1559Compatible = yield this.getCurrentNetworkEIP1559Compatibility();
1625
+ const currentNetworkIsEIP1559Compatible = yield this.getCurrentNetworkEIP1559Compatibility(networkClientId);
1570
1626
  const currentAccountIsEIP1559Compatible = yield this.getCurrentAccountEIP1559Compatibility();
1571
1627
  return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
1572
1628
  });
1573
1629
  }
1574
- addPendingTransactionTrackerListeners() {
1575
- this.pendingTransactionTracker.hub.on('transaction-confirmed', this.onConfirmedTransaction.bind(this));
1576
- this.pendingTransactionTracker.hub.on('transaction-dropped', this.setTransactionStatusDropped.bind(this));
1577
- this.pendingTransactionTracker.hub.on('transaction-failed', this.failTransaction.bind(this));
1578
- this.pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
1579
- }
1580
1630
  signTransaction(transactionMeta, txParams) {
1581
1631
  return __awaiter(this, void 0, void 0, function* () {
1582
1632
  (0, logger_1.projectLogger)('Signing transaction', txParams);
1583
- const unsignedEthTx = this.prepareUnsignedEthTx(txParams);
1633
+ const unsignedEthTx = this.prepareUnsignedEthTx(transactionMeta.chainId, txParams);
1584
1634
  this.inProcessOfSigning.add(transactionMeta.id);
1585
1635
  const signedTx = yield new Promise((resolve, reject) => {
1586
1636
  var _a;
@@ -1610,14 +1660,8 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1610
1660
  onTransactionStatusChange(transactionMeta) {
1611
1661
  this.hub.emit('transaction-status-update', { transactionMeta });
1612
1662
  }
1613
- getNonceTrackerPendingTransactions(address) {
1614
- const standardPendingTransactions = this.getNonceTrackerTransactions(types_1.TransactionStatus.submitted, address);
1615
- const externalPendingTransactions = this.getExternalPendingTransactions(address);
1616
- return [...standardPendingTransactions, ...externalPendingTransactions];
1617
- }
1618
- getNonceTrackerTransactions(status, address) {
1619
- const currentChainId = this.getChainId();
1620
- return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(currentChainId, address, status, this.state.transactions);
1663
+ getNonceTrackerTransactions(status, address, chainId = this.getChainId()) {
1664
+ return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address, status, this.state.transactions);
1621
1665
  }
1622
1666
  onConfirmedTransaction(transactionMeta) {
1623
1667
  (0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
@@ -1635,8 +1679,12 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1635
1679
  if (transactionMeta.type !== types_1.TransactionType.swap) {
1636
1680
  return;
1637
1681
  }
1682
+ const ethQuery = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getEthQuery({
1683
+ networkClientId: transactionMeta.networkClientId,
1684
+ chainId: transactionMeta.chainId,
1685
+ });
1638
1686
  const { updatedTransactionMeta, approvalTransactionMeta } = yield (0, swaps_1.updatePostTransactionBalance)(transactionMeta, {
1639
- ethQuery: this.ethQuery,
1687
+ ethQuery,
1640
1688
  getTransaction: this.getTransaction.bind(this),
1641
1689
  updateTransaction: this.updateTransaction.bind(this),
1642
1690
  });
@@ -1651,6 +1699,118 @@ class TransactionController extends base_controller_1.BaseControllerV1 {
1651
1699
  }
1652
1700
  });
1653
1701
  }
1702
+ publishTransactionForRetry(ethQuery, rawTx, transactionMeta) {
1703
+ return __awaiter(this, void 0, void 0, function* () {
1704
+ try {
1705
+ const hash = yield this.publishTransaction(ethQuery, rawTx);
1706
+ return hash;
1707
+ }
1708
+ catch (error) {
1709
+ if (this.isTransactionAlreadyConfirmedError(error)) {
1710
+ yield this.pendingTransactionTracker.forceCheckTransaction(transactionMeta);
1711
+ throw new Error('Previous transaction is already confirmed');
1712
+ }
1713
+ throw error;
1714
+ }
1715
+ });
1716
+ }
1717
+ /**
1718
+ * Ensures that error is a nonce issue
1719
+ *
1720
+ * @param error - The error to check
1721
+ * @returns Whether or not the error is a nonce issue
1722
+ */
1723
+ // TODO: Replace `any` with type
1724
+ // Some networks are returning original error in the data field
1725
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1726
+ isTransactionAlreadyConfirmedError(error) {
1727
+ var _a, _b, _c;
1728
+ return (((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.includes('nonce too low')) ||
1729
+ ((_c = (_b = error === null || error === void 0 ? void 0 : error.data) === null || _b === void 0 ? void 0 : _b.message) === null || _c === void 0 ? void 0 : _c.includes('nonce too low')));
1730
+ }
1654
1731
  }
1655
1732
  exports.TransactionController = TransactionController;
1733
+ _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_multichainTrackingHelper = new WeakMap(), _TransactionController_checkForPendingTransactionAndStartPolling = new WeakMap(), _TransactionController_instances = new WeakSet(), _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
1734
+ return new nonce_tracker_1.NonceTracker({
1735
+ // TODO: Replace `any` with type
1736
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1737
+ provider: provider,
1738
+ blockTracker,
1739
+ getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
1740
+ getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, types_1.TransactionStatus.confirmed),
1741
+ });
1742
+ }, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, etherscanRemoteTransactionSource, chainId, }) {
1743
+ const incomingTransactionHelper = new IncomingTransactionHelper_1.IncomingTransactionHelper({
1744
+ blockTracker,
1745
+ getCurrentAccount: this.getSelectedAddress,
1746
+ getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
1747
+ getChainId: chainId ? () => chainId : this.getChainId.bind(this),
1748
+ isEnabled: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").isEnabled,
1749
+ queryEntireHistory: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").queryEntireHistory,
1750
+ remoteTransactionSource: etherscanRemoteTransactionSource,
1751
+ transactionLimit: this.config.txHistoryLimit,
1752
+ updateTransactions: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").updateTransactions,
1753
+ });
1754
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addIncomingTransactionHelperListeners).call(this, incomingTransactionHelper);
1755
+ return incomingTransactionHelper;
1756
+ }, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, }) {
1757
+ const ethQuery = new eth_query_1.default(provider);
1758
+ const getChainId = chainId ? () => chainId : this.getChainId.bind(this);
1759
+ const pendingTransactionTracker = new PendingTransactionTracker_1.PendingTransactionTracker({
1760
+ approveTransaction: this.approveTransaction.bind(this),
1761
+ blockTracker,
1762
+ getChainId,
1763
+ getEthQuery: () => ethQuery,
1764
+ getTransactions: () => this.state.transactions,
1765
+ isResubmitEnabled: __classPrivateFieldGet(this, _TransactionController_pendingTransactionOptions, "f").isResubmitEnabled,
1766
+ getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
1767
+ chainId: getChainId(),
1768
+ }),
1769
+ publishTransaction: this.publishTransaction.bind(this),
1770
+ hooks: {
1771
+ beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
1772
+ beforePublish: this.beforePublish.bind(this),
1773
+ },
1774
+ });
1775
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
1776
+ return pendingTransactionTracker;
1777
+ }, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
1778
+ this.pendingTransactionTracker.stop();
1779
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).call(this, this.pendingTransactionTracker);
1780
+ this.incomingTransactionHelper.stop();
1781
+ __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).call(this, this.incomingTransactionHelper);
1782
+ __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
1783
+ }, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
1784
+ incomingTransactionHelper.hub.removeAllListeners('transactions');
1785
+ incomingTransactionHelper.hub.removeAllListeners('updatedLastFetchedBlockNumbers');
1786
+ }, _TransactionController_addIncomingTransactionHelperListeners = function _TransactionController_addIncomingTransactionHelperListeners(incomingTransactionHelper) {
1787
+ incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
1788
+ incomingTransactionHelper.hub.on('updatedLastFetchedBlockNumbers', this.onUpdatedLastFetchedBlockNumbers.bind(this));
1789
+ }, _TransactionController_removePendingTransactionTrackerListeners = function _TransactionController_removePendingTransactionTrackerListeners(pendingTransactionTracker) {
1790
+ pendingTransactionTracker.hub.removeAllListeners('transaction-confirmed');
1791
+ pendingTransactionTracker.hub.removeAllListeners('transaction-dropped');
1792
+ pendingTransactionTracker.hub.removeAllListeners('transaction-failed');
1793
+ pendingTransactionTracker.hub.removeAllListeners('transaction-updated');
1794
+ }, _TransactionController_addPendingTransactionTrackerListeners = function _TransactionController_addPendingTransactionTrackerListeners(pendingTransactionTracker) {
1795
+ pendingTransactionTracker.hub.on('transaction-confirmed', this.onConfirmedTransaction.bind(this));
1796
+ pendingTransactionTracker.hub.on('transaction-dropped', this.setTransactionStatusDropped.bind(this));
1797
+ pendingTransactionTracker.hub.on('transaction-failed', this.failTransaction.bind(this));
1798
+ pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
1799
+ }, _TransactionController_getNonceTrackerPendingTransactions = function _TransactionController_getNonceTrackerPendingTransactions(chainId, address) {
1800
+ const standardPendingTransactions = this.getNonceTrackerTransactions(types_1.TransactionStatus.submitted, address, chainId);
1801
+ const externalPendingTransactions = this.getExternalPendingTransactions(address, chainId);
1802
+ return [...standardPendingTransactions, ...externalPendingTransactions];
1803
+ }, _TransactionController_getGasFeeFlows = function _TransactionController_getGasFeeFlows() {
1804
+ return [new LineaGasFeeFlow_1.LineaGasFeeFlow(), new DefaultGasFeeFlow_1.DefaultGasFeeFlow()];
1805
+ }, _TransactionController_updateTransactionInternal = function _TransactionController_updateTransactionInternal(transactionMeta, { note, skipHistory }) {
1806
+ const { transactions } = this.state;
1807
+ transactionMeta.txParams = (0, utils_1.normalizeTxParams)(transactionMeta.txParams);
1808
+ (0, validation_1.validateTxParams)(transactionMeta.txParams);
1809
+ if (skipHistory !== true) {
1810
+ (0, history_1.updateTransactionHistory)(transactionMeta, note !== null && note !== void 0 ? note : 'Transaction updated');
1811
+ }
1812
+ const index = transactions.findIndex(({ id }) => transactionMeta.id === id);
1813
+ transactions[index] = transactionMeta;
1814
+ this.update({ transactions: this.trimTransactionsForState(transactions) });
1815
+ };
1656
1816
  //# sourceMappingURL=TransactionController.js.map