@metamask-previews/transaction-controller 39.0.0-preview-e23a91fa → 39.0.0-preview-913113cf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/TransactionController.cjs +104 -219
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +34 -52
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +34 -52
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +105 -220
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.cjs +1 -0
- 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 +1 -0
- 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 +12 -5
- 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 +13 -6
- 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 +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 +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
|
@@ -9,7 +9,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_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,
|
|
12
|
+
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createRemoteTransactionSource, _TransactionController_createIncomingTransactionHelper, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removeIncomingTransactionHelperListeners, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getSelectedAccount, _TransactionController_updateSubmitHistory;
|
|
13
13
|
function $importDefault(module) {
|
|
14
14
|
if (module?.__esModule) {
|
|
15
15
|
return module.default;
|
|
@@ -22,7 +22,7 @@ import { TransactionFactory } from "@ethereumjs/tx";
|
|
|
22
22
|
import $ethereumjsutil from "@ethereumjs/util";
|
|
23
23
|
const { bufferToHex } = $ethereumjsutil;
|
|
24
24
|
import { BaseController } from "@metamask/base-controller";
|
|
25
|
-
import { query, ApprovalType, ORIGIN_METAMASK, convertHexToDecimal
|
|
25
|
+
import { query, ApprovalType, ORIGIN_METAMASK, convertHexToDecimal } from "@metamask/controller-utils";
|
|
26
26
|
import $EthQuery from "@metamask/eth-query";
|
|
27
27
|
const EthQuery = $importDefault($EthQuery);
|
|
28
28
|
import { NetworkClientType } from "@metamask/network-controller";
|
|
@@ -30,7 +30,6 @@ import { NonceTracker } from "@metamask/nonce-tracker";
|
|
|
30
30
|
import { errorCodes, rpcErrors, providerErrors } from "@metamask/rpc-errors";
|
|
31
31
|
import { add0x } from "@metamask/utils";
|
|
32
32
|
import { Mutex } from "async-mutex";
|
|
33
|
-
import { MethodRegistry } from "eth-method-registry";
|
|
34
33
|
import { EventEmitter } from "events";
|
|
35
34
|
import $lodash from "lodash";
|
|
36
35
|
const { cloneDeep, mapValues, merge, pickBy, sortBy } = $lodash;
|
|
@@ -43,6 +42,7 @@ import { TestGasFeeFlow } from "./gas-flows/TestGasFeeFlow.mjs";
|
|
|
43
42
|
import { EtherscanRemoteTransactionSource } from "./helpers/EtherscanRemoteTransactionSource.mjs";
|
|
44
43
|
import { GasFeePoller } from "./helpers/GasFeePoller.mjs";
|
|
45
44
|
import { IncomingTransactionHelper } from "./helpers/IncomingTransactionHelper.mjs";
|
|
45
|
+
import { MethodDataHelper } from "./helpers/MethodDataHelper.mjs";
|
|
46
46
|
import { MultichainTrackingHelper } from "./helpers/MultichainTrackingHelper.mjs";
|
|
47
47
|
import { PendingTransactionTracker } from "./helpers/PendingTransactionTracker.mjs";
|
|
48
48
|
import { projectLogger as log } from "./logger.mjs";
|
|
@@ -152,22 +152,10 @@ export class TransactionController extends BaseController {
|
|
|
152
152
|
this.messagingSystem.publish(`${controllerName}:transactionFinished`, newTransactionMeta);
|
|
153
153
|
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, newTransactionMeta);
|
|
154
154
|
}
|
|
155
|
-
async registryLookup(fourBytePrefix) {
|
|
156
|
-
const registryMethod = await this.registry.lookup(fourBytePrefix);
|
|
157
|
-
if (!registryMethod) {
|
|
158
|
-
return {
|
|
159
|
-
registryMethod: '',
|
|
160
|
-
parsedRegistryMethod: { name: undefined, args: undefined },
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
const parsedRegistryMethod = this.registry.parse(registryMethod);
|
|
164
|
-
return { registryMethod, parsedRegistryMethod };
|
|
165
|
-
}
|
|
166
155
|
/**
|
|
167
156
|
* Constructs a TransactionController.
|
|
168
157
|
*
|
|
169
158
|
* @param options - The controller options.
|
|
170
|
-
* @param options.blockTracker - The block tracker used to poll for new blocks data.
|
|
171
159
|
* @param options.disableHistory - Whether to disable storing history in transaction metadata.
|
|
172
160
|
* @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
|
|
173
161
|
* @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
|
|
@@ -180,12 +168,9 @@ export class TransactionController extends BaseController {
|
|
|
180
168
|
* @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
|
|
181
169
|
* @param options.getSavedGasFees - Gets the saved gas fee config.
|
|
182
170
|
* @param options.incomingTransactions - Configuration options for incoming transaction support.
|
|
183
|
-
* @param options.isMultichainEnabled - Enable multichain support.
|
|
184
171
|
* @param options.isSimulationEnabled - Whether new transactions will be automatically simulated.
|
|
185
172
|
* @param options.messenger - The controller messenger.
|
|
186
|
-
* @param options.onNetworkStateChange - Allows subscribing to network controller state changes.
|
|
187
173
|
* @param options.pendingTransactions - Configuration options for pending transaction support.
|
|
188
|
-
* @param options.provider - The provider used to create the underlying EthQuery instance.
|
|
189
174
|
* @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
|
|
190
175
|
* @param options.sign - Function used to sign transactions.
|
|
191
176
|
* @param options.state - Initial state to set on this controller.
|
|
@@ -194,7 +179,7 @@ export class TransactionController extends BaseController {
|
|
|
194
179
|
* @param options.transactionHistoryLimit - Transaction history limit.
|
|
195
180
|
* @param options.hooks - The controller hooks.
|
|
196
181
|
*/
|
|
197
|
-
constructor({
|
|
182
|
+
constructor({ disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isSimulationEnabled, messenger, pendingTransactions = {}, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, }) {
|
|
198
183
|
super({
|
|
199
184
|
name: controllerName,
|
|
200
185
|
metadata,
|
|
@@ -207,6 +192,7 @@ export class TransactionController extends BaseController {
|
|
|
207
192
|
_TransactionController_instances.add(this);
|
|
208
193
|
_TransactionController_internalEvents.set(this, new EventEmitter());
|
|
209
194
|
this.approvingTransactionIds = new Set();
|
|
195
|
+
_TransactionController_methodDataHelper.set(this, void 0);
|
|
210
196
|
this.mutex = new Mutex();
|
|
211
197
|
_TransactionController_incomingTransactionOptions.set(this, void 0);
|
|
212
198
|
_TransactionController_pendingTransactionOptions.set(this, void 0);
|
|
@@ -217,8 +203,6 @@ export class TransactionController extends BaseController {
|
|
|
217
203
|
_TransactionController_testGasFeeFlows.set(this, void 0);
|
|
218
204
|
_TransactionController_multichainTrackingHelper.set(this, void 0);
|
|
219
205
|
_TransactionController_checkForPendingTransactionAndStartPolling.set(this, () => {
|
|
220
|
-
// PendingTransactionTracker reads state through its getTransactions hook
|
|
221
|
-
this.pendingTransactionTracker.startIfPendingTransactions();
|
|
222
206
|
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
|
|
223
207
|
});
|
|
224
208
|
this.messagingSystem = messenger;
|
|
@@ -227,8 +211,6 @@ export class TransactionController extends BaseController {
|
|
|
227
211
|
this.isHistoryDisabled = disableHistory ?? false;
|
|
228
212
|
this.isSwapsDisabled = disableSwaps ?? false;
|
|
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 MethodRegistry({ provider });
|
|
232
214
|
this.getSavedGasFees = getSavedGasFees ?? ((_chainId) => undefined);
|
|
233
215
|
this.getCurrentAccountEIP1559Compatibility =
|
|
234
216
|
getCurrentAccountEIP1559Compatibility ?? (() => Promise.resolve(true));
|
|
@@ -256,18 +238,10 @@ export class TransactionController extends 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({
|
|
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 @@ export class TransactionController extends 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({
|
|
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({
|
|
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 @@ export class TransactionController extends 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({
|
|
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
|
-
log('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 @@ export class TransactionController extends 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 @@ export class TransactionController extends 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
|
-
log('Adding transaction', txParams);
|
|
328
|
+
async addTransaction(txParams, options) {
|
|
329
|
+
log('Adding transaction', txParams, options);
|
|
330
|
+
const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
|
|
381
331
|
txParams = 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
|
validateTxParams(txParams, isEIP1559Compatible);
|
|
389
337
|
if (origin && this.getPermittedAccounts) {
|
|
390
338
|
await 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 determineTransactionType(txParams, ethQuery)).type;
|
|
399
346
|
const existingTransactionMeta = this.getTransactionWithActionId(actionId);
|
|
@@ -464,29 +411,13 @@ export class TransactionController extends BaseController {
|
|
|
464
411
|
transactionMeta: addedTransactionMeta,
|
|
465
412
|
};
|
|
466
413
|
}
|
|
467
|
-
startIncomingTransactionPolling(networkClientIds
|
|
468
|
-
if (networkClientIds.length === 0) {
|
|
469
|
-
this.incomingTransactionHelper.start();
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
414
|
+
startIncomingTransactionPolling(networkClientIds) {
|
|
472
415
|
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").startIncomingTransactionPolling(networkClientIds);
|
|
473
416
|
}
|
|
474
|
-
stopIncomingTransactionPolling(networkClientIds
|
|
475
|
-
if (networkClientIds.length === 0) {
|
|
476
|
-
this.incomingTransactionHelper.stop();
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
417
|
+
stopIncomingTransactionPolling(networkClientIds) {
|
|
479
418
|
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopIncomingTransactionPolling(networkClientIds);
|
|
480
419
|
}
|
|
481
|
-
stopAllIncomingTransactionPolling() {
|
|
482
|
-
this.incomingTransactionHelper.stop();
|
|
483
|
-
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllIncomingTransactionPolling();
|
|
484
|
-
}
|
|
485
420
|
async updateIncomingTransactions(networkClientIds = []) {
|
|
486
|
-
if (networkClientIds.length === 0) {
|
|
487
|
-
await this.incomingTransactionHelper.update();
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
421
|
await __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").updateIncomingTransactions(networkClientIds);
|
|
491
422
|
}
|
|
492
423
|
/**
|
|
@@ -550,7 +481,7 @@ export class TransactionController extends BaseController {
|
|
|
550
481
|
* @returns The gas and gas price.
|
|
551
482
|
*/
|
|
552
483
|
async estimateGas(transaction, networkClientId) {
|
|
553
|
-
const ethQuery = __classPrivateFieldGet(this,
|
|
484
|
+
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
554
485
|
networkClientId,
|
|
555
486
|
});
|
|
556
487
|
const { estimatedGas, simulationFails } = await estimateGas(transaction, ethQuery);
|
|
@@ -564,7 +495,7 @@ export class TransactionController extends BaseController {
|
|
|
564
495
|
* @param networkClientId - The network client id to use for the estimate.
|
|
565
496
|
*/
|
|
566
497
|
async estimateGasBuffered(transaction, multiplier, networkClientId) {
|
|
567
|
-
const ethQuery = __classPrivateFieldGet(this,
|
|
498
|
+
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
568
499
|
networkClientId,
|
|
569
500
|
});
|
|
570
501
|
const { blockGasLimit, estimatedGas, simulationFails } = await estimateGas(transaction, ethQuery);
|
|
@@ -607,24 +538,21 @@ export class TransactionController extends BaseController {
|
|
|
607
538
|
this.updateTransaction(updatedTransactionMeta, `${controllerName}:updatesecurityAlertResponse - securityAlertResponse updated`);
|
|
608
539
|
}
|
|
609
540
|
/**
|
|
610
|
-
*
|
|
541
|
+
* Remove transactions from state.
|
|
611
542
|
*
|
|
612
|
-
* @param
|
|
613
|
-
*
|
|
614
|
-
* @param
|
|
615
|
-
* wiped on current network.
|
|
543
|
+
* @param options - The options bag.
|
|
544
|
+
* @param options.address - Remove transactions from this account only. Defaults to all accounts.
|
|
545
|
+
* @param options.chainId - Remove transactions for the specified chain only. Defaults to all chains.
|
|
616
546
|
*/
|
|
617
|
-
wipeTransactions(
|
|
618
|
-
|
|
619
|
-
if (ignoreNetwork && !address) {
|
|
547
|
+
wipeTransactions({ address, chainId, } = {}) {
|
|
548
|
+
if (!chainId && !address) {
|
|
620
549
|
this.update((state) => {
|
|
621
550
|
state.transactions = [];
|
|
622
551
|
});
|
|
623
552
|
return;
|
|
624
553
|
}
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
const isMatchingNetwork = ignoreNetwork || chainId === currentChainId;
|
|
554
|
+
const newTransactions = this.state.transactions.filter(({ chainId: txChainId, txParams }) => {
|
|
555
|
+
const isMatchingNetwork = !chainId || chainId === txChainId;
|
|
628
556
|
if (!isMatchingNetwork) {
|
|
629
557
|
return true;
|
|
630
558
|
}
|
|
@@ -814,10 +742,8 @@ export class TransactionController extends BaseController {
|
|
|
814
742
|
};
|
|
815
743
|
editableParams.txParams = pickBy(editableParams.txParams);
|
|
816
744
|
const updatedTransaction = merge({}, transactionMeta, editableParams);
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
networkClientId: transactionMeta.networkClientId,
|
|
820
|
-
});
|
|
745
|
+
const { networkClientId } = transactionMeta;
|
|
746
|
+
const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
|
|
821
747
|
const ethQuery = new EthQuery(provider);
|
|
822
748
|
const { type } = await determineTransactionType(updatedTransaction.txParams, ethQuery);
|
|
823
749
|
updatedTransaction.type = type;
|
|
@@ -845,19 +771,9 @@ export class TransactionController extends BaseController {
|
|
|
845
771
|
return '';
|
|
846
772
|
}
|
|
847
773
|
const initialTx = listOfTxParams[0];
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
// NonceTrackers are keyed by networkClientId. To workaround this, we attempt to find
|
|
852
|
-
// a networkClientId that matches the chainId. As a fallback, the globally selected
|
|
853
|
-
// network's NonceTracker will be used instead.
|
|
854
|
-
let networkClientId;
|
|
855
|
-
try {
|
|
856
|
-
networkClientId = this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, initialTx.chainId);
|
|
857
|
-
}
|
|
858
|
-
catch (err) {
|
|
859
|
-
log('failed to find networkClientId from chainId', err);
|
|
860
|
-
}
|
|
774
|
+
const { chainId } = initialTx;
|
|
775
|
+
const common = this.getCommonConfiguration(chainId);
|
|
776
|
+
const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
|
|
861
777
|
const initialTxAsEthTx = TransactionFactory.fromTxData(initialTx, {
|
|
862
778
|
common,
|
|
863
779
|
});
|
|
@@ -939,14 +855,12 @@ export class TransactionController extends BaseController {
|
|
|
939
855
|
* Search transaction metadata for matching entries.
|
|
940
856
|
*
|
|
941
857
|
* @param opts - Options bag.
|
|
942
|
-
* @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
|
|
943
858
|
* @param opts.initialList - The transactions to search. Defaults to the current state.
|
|
944
|
-
* @param opts.filterToCurrentNetwork - Whether to filter the results to the current network. Defaults to true.
|
|
945
859
|
* @param opts.limit - The maximum number of transactions to return. No limit by default.
|
|
860
|
+
* @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
|
|
946
861
|
* @returns An array of transactions matching the provided options.
|
|
947
862
|
*/
|
|
948
|
-
getTransactions({
|
|
949
|
-
const chainId = this.getChainId();
|
|
863
|
+
getTransactions({ initialList, limit, searchCriteria = {}, } = {}) {
|
|
950
864
|
// searchCriteria is an object that might have values that aren't predicate
|
|
951
865
|
// methods. When providing any other value type (string, number, etc), we
|
|
952
866
|
// consider this shorthand for "check the value at key for strict equality
|
|
@@ -964,9 +878,6 @@ export class TransactionController extends BaseController {
|
|
|
964
878
|
// Combine sortBy and pickBy to transform our state object into an array of
|
|
965
879
|
// matching transactions that are sorted by time.
|
|
966
880
|
const filteredTransactions = sortBy(pickBy(transactionsToFilter, (transaction) => {
|
|
967
|
-
if (filterToCurrentNetwork && transaction.chainId !== chainId) {
|
|
968
|
-
return false;
|
|
969
|
-
}
|
|
970
881
|
// iterate over the predicateMethods keys to check if the transaction
|
|
971
882
|
// matches the searchCriteria
|
|
972
883
|
for (const [key, predicate] of Object.entries(predicateMethods)) {
|
|
@@ -1022,9 +933,9 @@ export class TransactionController extends BaseController {
|
|
|
1022
933
|
return filteredTransactions;
|
|
1023
934
|
}
|
|
1024
935
|
async estimateGasFee({ transactionParams, chainId, networkClientId: requestNetworkClientId, }) {
|
|
1025
|
-
const networkClientId = __classPrivateFieldGet(this,
|
|
1026
|
-
networkClientId: requestNetworkClientId,
|
|
936
|
+
const { id: networkClientId, provider } = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
|
|
1027
937
|
chainId,
|
|
938
|
+
networkClientId: requestNetworkClientId,
|
|
1028
939
|
});
|
|
1029
940
|
const transactionMeta = {
|
|
1030
941
|
txParams: transactionParams,
|
|
@@ -1033,10 +944,7 @@ export class TransactionController extends BaseController {
|
|
|
1033
944
|
};
|
|
1034
945
|
// Guaranteed as the default gas fee flow matches all transactions.
|
|
1035
946
|
const gasFeeFlow = getGasFeeFlow(transactionMeta, this.gasFeeFlows);
|
|
1036
|
-
const ethQuery =
|
|
1037
|
-
networkClientId,
|
|
1038
|
-
chainId,
|
|
1039
|
-
});
|
|
947
|
+
const ethQuery = new EthQuery(provider);
|
|
1040
948
|
const gasFeeControllerData = await this.getGasFeeEstimates({
|
|
1041
949
|
networkClientId,
|
|
1042
950
|
});
|
|
@@ -1055,9 +963,9 @@ export class TransactionController extends BaseController {
|
|
|
1055
963
|
* @param request.networkClientId - The ID of a specific network client to process the transaction.
|
|
1056
964
|
*/
|
|
1057
965
|
async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
|
|
1058
|
-
const provider = __classPrivateFieldGet(this,
|
|
1059
|
-
networkClientId,
|
|
966
|
+
const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, {
|
|
1060
967
|
chainId,
|
|
968
|
+
networkClientId,
|
|
1061
969
|
});
|
|
1062
970
|
return await getTransactionLayer1GasFee({
|
|
1063
971
|
layer1GasFeeFlows: this.layer1GasFeeFlows,
|
|
@@ -1128,15 +1036,10 @@ export class TransactionController extends BaseController {
|
|
|
1128
1036
|
const isEIP1559Compatible = transactionMeta.txParams.type !== TransactionEnvelopeType.legacy &&
|
|
1129
1037
|
(await this.getEIP1559Compatibility(transactionMeta.networkClientId));
|
|
1130
1038
|
const { networkClientId, chainId } = transactionMeta;
|
|
1131
|
-
const isCustomNetwork = __classPrivateFieldGet(this,
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
});
|
|
1136
|
-
const provider = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getProvider({
|
|
1137
|
-
networkClientId,
|
|
1138
|
-
chainId,
|
|
1139
|
-
});
|
|
1039
|
+
const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
|
|
1040
|
+
.configuration.type === NetworkClientType.Custom;
|
|
1041
|
+
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
|
|
1042
|
+
const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { networkClientId });
|
|
1140
1043
|
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
|
|
1141
1044
|
await updateGas({
|
|
1142
1045
|
ethQuery,
|
|
@@ -1294,10 +1197,8 @@ export class TransactionController extends BaseController {
|
|
|
1294
1197
|
if (!rawTx) {
|
|
1295
1198
|
return ApprovalState.NotApproved;
|
|
1296
1199
|
}
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1299
|
-
chainId: transactionMeta.chainId,
|
|
1300
|
-
});
|
|
1200
|
+
const { networkClientId } = transactionMeta;
|
|
1201
|
+
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
|
|
1301
1202
|
let preTxBalance;
|
|
1302
1203
|
const shouldUpdatePreTxBalance = transactionMeta.type === TransactionType.swap;
|
|
1303
1204
|
if (shouldUpdatePreTxBalance) {
|
|
@@ -1491,14 +1392,6 @@ export class TransactionController extends BaseController {
|
|
|
1491
1392
|
const isCompleted = this.isLocalFinalState(transaction.status);
|
|
1492
1393
|
return { meta: transaction, isCompleted };
|
|
1493
1394
|
}
|
|
1494
|
-
getChainId(networkClientId) {
|
|
1495
|
-
const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
|
|
1496
|
-
const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
|
|
1497
|
-
if (!networkClientId || networkClientId === globalNetworkClientId) {
|
|
1498
|
-
return globalChainId;
|
|
1499
|
-
}
|
|
1500
|
-
return this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.chainId;
|
|
1501
|
-
}
|
|
1502
1395
|
prepareUnsignedEthTx(chainId, txParams) {
|
|
1503
1396
|
return TransactionFactory.fromTxData(txParams, {
|
|
1504
1397
|
freeze: false,
|
|
@@ -1724,7 +1617,7 @@ export class TransactionController extends BaseController {
|
|
|
1724
1617
|
transactionMeta,
|
|
1725
1618
|
});
|
|
1726
1619
|
}
|
|
1727
|
-
getNonceTrackerTransactions(status, address, chainId
|
|
1620
|
+
getNonceTrackerTransactions(status, address, chainId) {
|
|
1728
1621
|
return getAndFormatTransactionsForNonceTracker(chainId, address, status, this.state.transactions);
|
|
1729
1622
|
}
|
|
1730
1623
|
onConfirmedTransaction(transactionMeta) {
|
|
@@ -1740,13 +1633,11 @@ export class TransactionController extends BaseController {
|
|
|
1740
1633
|
}
|
|
1741
1634
|
async updatePostBalance(transactionMeta) {
|
|
1742
1635
|
try {
|
|
1743
|
-
|
|
1636
|
+
const { networkClientId, type } = transactionMeta;
|
|
1637
|
+
if (type !== TransactionType.swap) {
|
|
1744
1638
|
return;
|
|
1745
1639
|
}
|
|
1746
|
-
const ethQuery = __classPrivateFieldGet(this,
|
|
1747
|
-
networkClientId: transactionMeta.networkClientId,
|
|
1748
|
-
chainId: transactionMeta.chainId,
|
|
1749
|
-
});
|
|
1640
|
+
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
|
|
1750
1641
|
const { updatedTransactionMeta, approvalTransactionMeta } = await updatePostTransactionBalance(transactionMeta, {
|
|
1751
1642
|
ethQuery,
|
|
1752
1643
|
getTransaction: this.getTransaction.bind(this),
|
|
@@ -1768,7 +1659,6 @@ export class TransactionController extends BaseController {
|
|
|
1768
1659
|
}
|
|
1769
1660
|
catch (error) {
|
|
1770
1661
|
if (this.isTransactionAlreadyConfirmedError(error)) {
|
|
1771
|
-
await this.pendingTransactionTracker.forceCheckTransaction(transactionMeta);
|
|
1772
1662
|
throw new Error('Previous transaction is already confirmed');
|
|
1773
1663
|
}
|
|
1774
1664
|
throw error;
|
|
@@ -1788,7 +1678,7 @@ export class TransactionController extends BaseController {
|
|
|
1788
1678
|
error?.data?.message?.includes('nonce too low'));
|
|
1789
1679
|
}
|
|
1790
1680
|
}
|
|
1791
|
-
_TransactionController_internalEvents = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_trace = new WeakMap(), _TransactionController_transactionHistoryLimit = new WeakMap(), _TransactionController_isSimulationEnabled = new WeakMap(), _TransactionController_testGasFeeFlows = new WeakMap(), _TransactionController_multichainTrackingHelper = new WeakMap(), _TransactionController_checkForPendingTransactionAndStartPolling = new WeakMap(), _TransactionController_instances = new WeakSet(), _TransactionController_retryTransaction = async function _TransactionController_retryTransaction({ actionId, afterSubmit, estimatedBaseFee, gasValues, label, prepareTransactionParams, rate, transactionId, transactionType, }) {
|
|
1681
|
+
_TransactionController_internalEvents = new WeakMap(), _TransactionController_methodDataHelper = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_trace = new WeakMap(), _TransactionController_transactionHistoryLimit = new WeakMap(), _TransactionController_isSimulationEnabled = new WeakMap(), _TransactionController_testGasFeeFlows = new WeakMap(), _TransactionController_multichainTrackingHelper = new WeakMap(), _TransactionController_checkForPendingTransactionAndStartPolling = new WeakMap(), _TransactionController_instances = new WeakSet(), _TransactionController_retryTransaction = async function _TransactionController_retryTransaction({ actionId, afterSubmit, estimatedBaseFee, gasValues, label, prepareTransactionParams, rate, transactionId, transactionType, }) {
|
|
1792
1682
|
// If transaction is found for same action id, do not create a new transaction.
|
|
1793
1683
|
if (this.getTransactionWithActionId(actionId)) {
|
|
1794
1684
|
return;
|
|
@@ -1823,10 +1713,8 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1823
1713
|
newFee,
|
|
1824
1714
|
txParams: newTxParams,
|
|
1825
1715
|
});
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1828
|
-
chainId: transactionMeta.chainId,
|
|
1829
|
-
});
|
|
1716
|
+
const { networkClientId } = transactionMeta;
|
|
1717
|
+
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId });
|
|
1830
1718
|
const newTransactionMeta = {
|
|
1831
1719
|
...transactionMetaWithRsv,
|
|
1832
1720
|
actionId,
|
|
@@ -1855,6 +1743,23 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1855
1743
|
actionId,
|
|
1856
1744
|
});
|
|
1857
1745
|
afterSubmit?.(newTransactionMeta);
|
|
1746
|
+
}, _TransactionController_getChainId = function _TransactionController_getChainId(networkClientId) {
|
|
1747
|
+
return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
|
|
1748
|
+
.configuration.chainId;
|
|
1749
|
+
}, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ chainId, networkClientId, }) {
|
|
1750
|
+
if (networkClientId) {
|
|
1751
|
+
return networkClientId;
|
|
1752
|
+
}
|
|
1753
|
+
return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
|
|
1754
|
+
chainId,
|
|
1755
|
+
}).id;
|
|
1756
|
+
}, _TransactionController_getEthQuery = function _TransactionController_getEthQuery({ chainId, networkClientId, }) {
|
|
1757
|
+
return new EthQuery(__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, { chainId, networkClientId }));
|
|
1758
|
+
}, _TransactionController_getProvider = function _TransactionController_getProvider({ chainId, networkClientId, }) {
|
|
1759
|
+
return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
|
|
1760
|
+
chainId,
|
|
1761
|
+
networkClientId,
|
|
1762
|
+
}).provider;
|
|
1858
1763
|
}, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
|
|
1859
1764
|
return new NonceTracker({
|
|
1860
1765
|
// TODO: Fix types
|
|
@@ -1863,18 +1768,23 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1863
1768
|
// TODO: Fix types
|
|
1864
1769
|
blockTracker,
|
|
1865
1770
|
getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
|
|
1866
|
-
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, TransactionStatus.confirmed),
|
|
1771
|
+
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, TransactionStatus.confirmed, chainId),
|
|
1867
1772
|
});
|
|
1868
|
-
},
|
|
1773
|
+
}, _TransactionController_createRemoteTransactionSource = function _TransactionController_createRemoteTransactionSource() {
|
|
1774
|
+
return new EtherscanRemoteTransactionSource({
|
|
1775
|
+
apiKeysByChainId: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").etherscanApiKeysByChainId,
|
|
1776
|
+
includeTokenTransfers: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").includeTokenTransfers,
|
|
1777
|
+
});
|
|
1778
|
+
}, _TransactionController_createIncomingTransactionHelper = function _TransactionController_createIncomingTransactionHelper({ blockTracker, remoteTransactionSource, chainId, }) {
|
|
1869
1779
|
const incomingTransactionHelper = new IncomingTransactionHelper({
|
|
1870
1780
|
blockTracker,
|
|
1871
1781
|
getCurrentAccount: () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this),
|
|
1872
1782
|
getLastFetchedBlockNumbers: () => this.state.lastFetchedBlockNumbers,
|
|
1873
1783
|
getLocalTransactions: () => this.state.transactions,
|
|
1874
|
-
getChainId:
|
|
1784
|
+
getChainId: () => chainId,
|
|
1875
1785
|
isEnabled: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").isEnabled,
|
|
1876
1786
|
queryEntireHistory: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").queryEntireHistory,
|
|
1877
|
-
remoteTransactionSource
|
|
1787
|
+
remoteTransactionSource,
|
|
1878
1788
|
transactionLimit: __classPrivateFieldGet(this, _TransactionController_transactionHistoryLimit, "f"),
|
|
1879
1789
|
updateTransactions: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").updateTransactions,
|
|
1880
1790
|
});
|
|
@@ -1882,15 +1792,14 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1882
1792
|
return incomingTransactionHelper;
|
|
1883
1793
|
}, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, }) {
|
|
1884
1794
|
const ethQuery = new EthQuery(provider);
|
|
1885
|
-
const getChainId = chainId ? () => chainId : this.getChainId.bind(this);
|
|
1886
1795
|
const pendingTransactionTracker = new PendingTransactionTracker({
|
|
1887
1796
|
blockTracker,
|
|
1888
|
-
getChainId,
|
|
1797
|
+
getChainId: () => chainId,
|
|
1889
1798
|
getEthQuery: () => ethQuery,
|
|
1890
1799
|
getTransactions: () => this.state.transactions,
|
|
1891
1800
|
isResubmitEnabled: __classPrivateFieldGet(this, _TransactionController_pendingTransactionOptions, "f").isResubmitEnabled,
|
|
1892
1801
|
getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
|
|
1893
|
-
chainId
|
|
1802
|
+
chainId,
|
|
1894
1803
|
}),
|
|
1895
1804
|
publishTransaction: (_ethQuery, transactionMeta) => this.publishTransaction(_ethQuery, transactionMeta, {
|
|
1896
1805
|
skipSubmitHistory: true,
|
|
@@ -1903,10 +1812,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
1903
1812
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
|
|
1904
1813
|
return pendingTransactionTracker;
|
|
1905
1814
|
}, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
|
|
1906
|
-
this.pendingTransactionTracker.stop();
|
|
1907
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).call(this, this.pendingTransactionTracker);
|
|
1908
|
-
this.incomingTransactionHelper.stop();
|
|
1909
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removeIncomingTransactionHelperListeners).call(this, this.incomingTransactionHelper);
|
|
1910
1815
|
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
|
|
1911
1816
|
}, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1912
1817
|
incomingTransactionHelper.hub.removeAllListeners('transactions');
|
|
@@ -2021,26 +1926,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_in
|
|
|
2021
1926
|
txMeta.layer1GasFee = layer1GasFee;
|
|
2022
1927
|
}
|
|
2023
1928
|
});
|
|
2024
|
-
}, _TransactionController_getNetworkClientId = function _TransactionController_getNetworkClientId({ networkClientId: requestNetworkClientId, chainId, }) {
|
|
2025
|
-
const globalChainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalChainId).call(this);
|
|
2026
|
-
const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
|
|
2027
|
-
if (requestNetworkClientId) {
|
|
2028
|
-
return requestNetworkClientId;
|
|
2029
|
-
}
|
|
2030
|
-
if (!chainId || chainId === globalChainId) {
|
|
2031
|
-
return globalNetworkClientId;
|
|
2032
|
-
}
|
|
2033
|
-
return this.messagingSystem.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
|
|
2034
|
-
}, _TransactionController_getGlobalNetworkClientId = function _TransactionController_getGlobalNetworkClientId() {
|
|
2035
|
-
return this.getNetworkState().selectedNetworkClientId;
|
|
2036
|
-
}, _TransactionController_getGlobalChainId = function _TransactionController_getGlobalChainId() {
|
|
2037
|
-
return this.messagingSystem.call(`NetworkController:getNetworkClientById`, this.getNetworkState().selectedNetworkClientId).configuration.chainId;
|
|
2038
|
-
}, _TransactionController_isCustomNetwork = function _TransactionController_isCustomNetwork(networkClientId) {
|
|
2039
|
-
const globalNetworkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGlobalNetworkClientId).call(this);
|
|
2040
|
-
if (!networkClientId || networkClientId === globalNetworkClientId) {
|
|
2041
|
-
return !isInfuraNetworkType(this.getNetworkState().selectedNetworkClientId);
|
|
2042
|
-
}
|
|
2043
|
-
return (this.messagingSystem.call(`NetworkController:getNetworkClientById`, networkClientId).configuration.type === NetworkClientType.Custom);
|
|
2044
1929
|
}, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
|
|
2045
1930
|
return this.messagingSystem.call('AccountsController:getSelectedAccount');
|
|
2046
1931
|
}, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {
|