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