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