@metamask-previews/transaction-controller 52.1.0-preview-35da3ac → 52.1.0-preview-7ecf950
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 +8 -27
- package/dist/TransactionController.cjs +24 -89
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +5 -35
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +5 -35
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +24 -89
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +21 -120
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +21 -120
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/batch.cjs +22 -121
- package/dist/utils/batch.cjs.map +1 -1
- package/dist/utils/batch.d.cts +1 -7
- package/dist/utils/batch.d.cts.map +1 -1
- package/dist/utils/batch.d.mts +1 -7
- package/dist/utils/batch.d.mts.map +1 -1
- package/dist/utils/batch.mjs +22 -121
- package/dist/utils/batch.mjs.map +1 -1
- package/dist/utils/eip7702.cjs +0 -12
- package/dist/utils/eip7702.cjs.map +1 -1
- package/dist/utils/eip7702.d.cts.map +1 -1
- package/dist/utils/eip7702.d.mts.map +1 -1
- package/dist/utils/eip7702.mjs +0 -12
- package/dist/utils/eip7702.mjs.map +1 -1
- package/dist/utils/gas.cjs +3 -7
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.mjs +3 -7
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/nonce.cjs +3 -3
- package/dist/utils/nonce.cjs.map +1 -1
- package/dist/utils/nonce.d.cts +2 -2
- package/dist/utils/nonce.d.cts.map +1 -1
- package/dist/utils/nonce.d.mts +2 -2
- package/dist/utils/nonce.d.mts.map +1 -1
- package/dist/utils/nonce.mjs +3 -3
- package/dist/utils/nonce.mjs.map +1 -1
- package/dist/utils/simulation-api.cjs.map +1 -1
- package/dist/utils/simulation-api.d.cts +0 -37
- package/dist/utils/simulation-api.d.cts.map +1 -1
- package/dist/utils/simulation-api.d.mts +0 -37
- package/dist/utils/simulation-api.d.mts.map +1 -1
- package/dist/utils/simulation-api.mjs.map +1 -1
- package/dist/utils/simulation.cjs +7 -46
- package/dist/utils/simulation.cjs.map +1 -1
- package/dist/utils/simulation.d.cts +2 -6
- package/dist/utils/simulation.d.cts.map +1 -1
- package/dist/utils/simulation.d.mts +2 -6
- package/dist/utils/simulation.d.mts.map +1 -1
- package/dist/utils/simulation.mjs +7 -46
- package/dist/utils/simulation.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/CollectPublishHook.cjs +0 -84
- package/dist/hooks/CollectPublishHook.cjs.map +0 -1
- package/dist/hooks/CollectPublishHook.d.cts +0 -29
- package/dist/hooks/CollectPublishHook.d.cts.map +0 -1
- package/dist/hooks/CollectPublishHook.d.mts +0 -29
- package/dist/hooks/CollectPublishHook.d.mts.map +0 -1
- package/dist/hooks/CollectPublishHook.mjs +0 -80
- package/dist/hooks/CollectPublishHook.mjs.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.cjs +0 -90
- package/dist/hooks/ExtraTransactionsPublishHook.cjs.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.d.cts +0 -18
- package/dist/hooks/ExtraTransactionsPublishHook.d.cts.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts +0 -18
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.mjs +0 -86
- package/dist/hooks/ExtraTransactionsPublishHook.mjs.map +0 -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_methodDataHelper, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions,
|
|
12
|
+
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_publicKeyEIP7702, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_rejectTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_addIncomingTransactionHelperListeners, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_updateFirstTimeInteraction, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_getSelectedAccount, _TransactionController_getInternalAccounts, _TransactionController_updateSubmitHistory, _TransactionController_updateGasEstimate, _TransactionController_deleteTransaction, _TransactionController_isRejectError, _TransactionController_rejectTransactionAndThrow;
|
|
13
13
|
function $importDefault(module) {
|
|
14
14
|
if (module?.__esModule) {
|
|
15
15
|
return module.default;
|
|
@@ -24,6 +24,7 @@ import { NetworkClientType } from "@metamask/network-controller";
|
|
|
24
24
|
import { NonceTracker } from "@metamask/nonce-tracker";
|
|
25
25
|
import { errorCodes, rpcErrors, providerErrors } from "@metamask/rpc-errors";
|
|
26
26
|
import { add0x, hexToNumber } from "@metamask/utils";
|
|
27
|
+
import { Mutex } from "async-mutex";
|
|
27
28
|
// This package purposefully relies on Node's EventEmitter module.
|
|
28
29
|
// eslint-disable-next-line import-x/no-nodejs-modules
|
|
29
30
|
import { EventEmitter } from "events";
|
|
@@ -43,7 +44,6 @@ import { MethodDataHelper } from "./helpers/MethodDataHelper.mjs";
|
|
|
43
44
|
import { MultichainTrackingHelper } from "./helpers/MultichainTrackingHelper.mjs";
|
|
44
45
|
import { PendingTransactionTracker } from "./helpers/PendingTransactionTracker.mjs";
|
|
45
46
|
import { ResimulateHelper, hasSimulationDataChanged, shouldResimulate } from "./helpers/ResimulateHelper.mjs";
|
|
46
|
-
import { ExtraTransactionsPublishHook } from "./hooks/ExtraTransactionsPublishHook.mjs";
|
|
47
47
|
import { projectLogger as log } from "./logger.mjs";
|
|
48
48
|
import { TransactionEnvelopeType, TransactionType, TransactionStatus, SimulationErrorCode } from "./types.mjs";
|
|
49
49
|
import { addTransactionBatch, isAtomicBatchSupported } from "./utils/batch.mjs";
|
|
@@ -172,10 +172,10 @@ export class TransactionController extends BaseController {
|
|
|
172
172
|
_TransactionController_internalEvents.set(this, new EventEmitter());
|
|
173
173
|
this.approvingTransactionIds = new Set();
|
|
174
174
|
_TransactionController_methodDataHelper.set(this, void 0);
|
|
175
|
+
this.mutex = new Mutex();
|
|
175
176
|
_TransactionController_incomingTransactionHelper.set(this, void 0);
|
|
176
177
|
_TransactionController_incomingTransactionOptions.set(this, void 0);
|
|
177
178
|
_TransactionController_pendingTransactionOptions.set(this, void 0);
|
|
178
|
-
_TransactionController_publishBatchHook.set(this, void 0);
|
|
179
179
|
_TransactionController_publicKeyEIP7702.set(this, void 0);
|
|
180
180
|
this.signAbortCallbacks = new Map();
|
|
181
181
|
_TransactionController_trace.set(this, void 0);
|
|
@@ -208,7 +208,6 @@ export class TransactionController extends BaseController {
|
|
|
208
208
|
this.securityProviderRequest = securityProviderRequest;
|
|
209
209
|
__classPrivateFieldSet(this, _TransactionController_incomingTransactionOptions, incomingTransactions, "f");
|
|
210
210
|
__classPrivateFieldSet(this, _TransactionController_pendingTransactionOptions, pendingTransactions, "f");
|
|
211
|
-
__classPrivateFieldSet(this, _TransactionController_publishBatchHook, hooks?.publishBatch, "f");
|
|
212
211
|
__classPrivateFieldSet(this, _TransactionController_publicKeyEIP7702, publicKeyEIP7702, "f");
|
|
213
212
|
__classPrivateFieldSet(this, _TransactionController_transactionHistoryLimit, transactionHistoryLimit, "f");
|
|
214
213
|
this.sign = sign;
|
|
@@ -323,12 +322,9 @@ export class TransactionController extends BaseController {
|
|
|
323
322
|
getChainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).bind(this),
|
|
324
323
|
getEthQuery: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId }),
|
|
325
324
|
getInternalAccounts: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).bind(this),
|
|
326
|
-
getTransaction: (transactionId) => this.getTransactionOrThrow(transactionId),
|
|
327
325
|
messenger: this.messagingSystem,
|
|
328
|
-
publishBatchHook: __classPrivateFieldGet(this, _TransactionController_publishBatchHook, "f"),
|
|
329
326
|
publicKeyEIP7702: __classPrivateFieldGet(this, _TransactionController_publicKeyEIP7702, "f"),
|
|
330
327
|
request,
|
|
331
|
-
updateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).bind(this),
|
|
332
328
|
});
|
|
333
329
|
}
|
|
334
330
|
/**
|
|
@@ -355,11 +351,9 @@ export class TransactionController extends BaseController {
|
|
|
355
351
|
* @param options.actionId - Unique ID to prevent duplicate requests.
|
|
356
352
|
* @param options.batchId - A custom ID for the batch this transaction belongs to.
|
|
357
353
|
* @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
|
|
358
|
-
* @param options.disableGasBuffer - Whether to disable the gas estimation buffer.
|
|
359
354
|
* @param options.method - RPC method that requested the transaction.
|
|
360
355
|
* @param options.nestedTransactions - Params for any nested transactions encoded in the data.
|
|
361
356
|
* @param options.origin - The origin of the transaction request, such as a dApp hostname.
|
|
362
|
-
* @param options.publishHook - Custom logic to publish the transaction.
|
|
363
357
|
* @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
|
|
364
358
|
* @param options.securityAlertResponse - Response from security validator.
|
|
365
359
|
* @param options.sendFlowHistory - The sendFlowHistory entries to add.
|
|
@@ -373,7 +367,7 @@ export class TransactionController extends BaseController {
|
|
|
373
367
|
*/
|
|
374
368
|
async addTransaction(txParams, options) {
|
|
375
369
|
log('Adding transaction', txParams, options);
|
|
376
|
-
const { actionId, batchId, deviceConfirmedOn,
|
|
370
|
+
const { actionId, batchId, deviceConfirmedOn, method, nestedTransactions, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
|
|
377
371
|
txParams = normalizeTransactionParams(txParams);
|
|
378
372
|
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
379
373
|
throw new Error(`Network client not found - ${networkClientId}`);
|
|
@@ -402,7 +396,7 @@ export class TransactionController extends BaseController {
|
|
|
402
396
|
validateTxParams(txParams, isEIP1559Compatible);
|
|
403
397
|
const isDuplicateBatchId = batchId?.length &&
|
|
404
398
|
this.state.transactions.some((tx) => tx.batchId?.toLowerCase() === batchId?.toLowerCase());
|
|
405
|
-
if (isDuplicateBatchId
|
|
399
|
+
if (isDuplicateBatchId) {
|
|
406
400
|
throw rpcErrors.invalidInput('Batch ID already exists');
|
|
407
401
|
}
|
|
408
402
|
const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
|
|
@@ -420,7 +414,6 @@ export class TransactionController extends BaseController {
|
|
|
420
414
|
dappSuggestedGasFees,
|
|
421
415
|
delegationAddress,
|
|
422
416
|
deviceConfirmedOn,
|
|
423
|
-
disableGasBuffer,
|
|
424
417
|
id: random(),
|
|
425
418
|
isFirstTimeInteraction: undefined,
|
|
426
419
|
nestedTransactions,
|
|
@@ -478,10 +471,9 @@ export class TransactionController extends BaseController {
|
|
|
478
471
|
}
|
|
479
472
|
return {
|
|
480
473
|
result: this.processApproval(addedTransactionMeta, {
|
|
481
|
-
actionId,
|
|
482
474
|
isExisting: Boolean(existingTransactionMeta),
|
|
483
|
-
publishHook,
|
|
484
475
|
requireApproval,
|
|
476
|
+
actionId,
|
|
485
477
|
traceContext,
|
|
486
478
|
}),
|
|
487
479
|
transactionMeta: addedTransactionMeta,
|
|
@@ -804,16 +796,14 @@ export class TransactionController extends BaseController {
|
|
|
804
796
|
* @param txId - The ID of the transaction to update.
|
|
805
797
|
* @param params - The editable parameters to update.
|
|
806
798
|
* @param params.data - Data to pass with the transaction.
|
|
807
|
-
* @param params.from - Address to send the transaction from.
|
|
808
799
|
* @param params.gas - Maximum number of units of gas to use for the transaction.
|
|
809
800
|
* @param params.gasPrice - Price per gas for legacy transactions.
|
|
810
|
-
* @param params.
|
|
811
|
-
* @param params.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.
|
|
801
|
+
* @param params.from - Address to send the transaction from.
|
|
812
802
|
* @param params.to - Address to send the transaction to.
|
|
813
803
|
* @param params.value - Value associated with the transaction.
|
|
814
804
|
* @returns The updated transaction metadata.
|
|
815
805
|
*/
|
|
816
|
-
async updateEditableParams(txId, { data,
|
|
806
|
+
async updateEditableParams(txId, { data, gas, gasPrice, from, to, value, }) {
|
|
817
807
|
const transactionMeta = this.getTransaction(txId);
|
|
818
808
|
if (!transactionMeta) {
|
|
819
809
|
throw new Error(`Cannot update editable params as no transaction metadata found`);
|
|
@@ -827,8 +817,6 @@ export class TransactionController extends BaseController {
|
|
|
827
817
|
value,
|
|
828
818
|
gas,
|
|
829
819
|
gasPrice,
|
|
830
|
-
maxFeePerGas,
|
|
831
|
-
maxPriorityFeePerGas,
|
|
832
820
|
},
|
|
833
821
|
};
|
|
834
822
|
editableParams.txParams = pickBy(editableParams.txParams);
|
|
@@ -1181,38 +1169,6 @@ export class TransactionController extends BaseController {
|
|
|
1181
1169
|
});
|
|
1182
1170
|
return updatedTransactionMeta.txParams.data;
|
|
1183
1171
|
}
|
|
1184
|
-
/**
|
|
1185
|
-
* Update the batch transactions associated with a transaction.
|
|
1186
|
-
* These transactions will be submitted with the main transaction as a batch.
|
|
1187
|
-
*
|
|
1188
|
-
* @param request - The request object.
|
|
1189
|
-
* @param request.transactionId - The ID of the transaction to update.
|
|
1190
|
-
* @param request.batchTransactions - The new batch transactions.
|
|
1191
|
-
*/
|
|
1192
|
-
updateBatchTransactions({ transactionId, batchTransactions, }) {
|
|
1193
|
-
log('Updating batch transactions', { transactionId, batchTransactions });
|
|
1194
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1195
|
-
transactionId,
|
|
1196
|
-
note: 'TransactionController#updateBatchTransactions - Batch transactions updated',
|
|
1197
|
-
}, (transactionMeta) => {
|
|
1198
|
-
transactionMeta.batchTransactions = batchTransactions;
|
|
1199
|
-
});
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
* Update the selected gas fee token for a transaction.
|
|
1203
|
-
*
|
|
1204
|
-
* @param transactionId - The ID of the transaction to update.
|
|
1205
|
-
* @param contractAddress - The contract address of the selected gas fee token.
|
|
1206
|
-
*/
|
|
1207
|
-
updateSelectedGasFeeToken(transactionId, contractAddress) {
|
|
1208
|
-
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (transactionMeta) => {
|
|
1209
|
-
const hasMatchingGasFeeToken = transactionMeta.gasFeeTokens?.some((token) => token.tokenAddress.toLowerCase() === contractAddress.toLowerCase());
|
|
1210
|
-
if (!hasMatchingGasFeeToken) {
|
|
1211
|
-
throw new Error(`No matching gas fee token found with address - ${contractAddress}`);
|
|
1212
|
-
}
|
|
1213
|
-
transactionMeta.selectedGasFeeToken = contractAddress;
|
|
1214
|
-
});
|
|
1215
|
-
}
|
|
1216
1172
|
addMetadata(transactionMeta) {
|
|
1217
1173
|
validateTxParams(transactionMeta.txParams);
|
|
1218
1174
|
this.update((state) => {
|
|
@@ -1255,7 +1211,7 @@ export class TransactionController extends BaseController {
|
|
|
1255
1211
|
this.failTransaction(transactionMeta, new Error('Transaction incomplete at startup'));
|
|
1256
1212
|
}
|
|
1257
1213
|
}
|
|
1258
|
-
async processApproval(transactionMeta, {
|
|
1214
|
+
async processApproval(transactionMeta, { isExisting = false, requireApproval, shouldShowRequest = true, actionId, traceContext, }) {
|
|
1259
1215
|
const transactionId = transactionMeta.id;
|
|
1260
1216
|
let resultCallbacks;
|
|
1261
1217
|
const { meta, isCompleted } = this.isTransactionCompleted(transactionId);
|
|
@@ -1282,7 +1238,7 @@ export class TransactionController extends BaseController {
|
|
|
1282
1238
|
}
|
|
1283
1239
|
const { isCompleted: isTxCompleted } = this.isTransactionCompleted(transactionId);
|
|
1284
1240
|
if (!isTxCompleted) {
|
|
1285
|
-
const approvalResult = await this.approveTransaction(transactionId, traceContext
|
|
1241
|
+
const approvalResult = await this.approveTransaction(transactionId, traceContext);
|
|
1286
1242
|
if (approvalResult === ApprovalState.SkippedViaBeforePublishHook &&
|
|
1287
1243
|
resultCallbacks) {
|
|
1288
1244
|
resultCallbacks.success();
|
|
@@ -1330,14 +1286,12 @@ export class TransactionController extends BaseController {
|
|
|
1330
1286
|
*
|
|
1331
1287
|
* @param transactionId - The ID of the transaction to approve.
|
|
1332
1288
|
* @param traceContext - The parent context for any new traces.
|
|
1333
|
-
* @param publishHookOverride - Custom logic to publish the transaction.
|
|
1334
1289
|
* @returns The state of the approval.
|
|
1335
1290
|
*/
|
|
1336
|
-
async approveTransaction(transactionId, traceContext
|
|
1337
|
-
|
|
1338
|
-
|
|
1291
|
+
async approveTransaction(transactionId, traceContext) {
|
|
1292
|
+
const cleanupTasks = new Array();
|
|
1293
|
+
cleanupTasks.push(await this.mutex.acquire());
|
|
1339
1294
|
let transactionMeta = this.getTransactionOrThrow(transactionId);
|
|
1340
|
-
log('Approving transaction', transactionMeta);
|
|
1341
1295
|
try {
|
|
1342
1296
|
if (!this.sign) {
|
|
1343
1297
|
this.failTransaction(transactionMeta, new Error('No sign method defined.'));
|
|
@@ -1352,9 +1306,10 @@ export class TransactionController extends BaseController {
|
|
|
1352
1306
|
return ApprovalState.NotApproved;
|
|
1353
1307
|
}
|
|
1354
1308
|
this.approvingTransactionIds.add(transactionId);
|
|
1355
|
-
|
|
1309
|
+
cleanupTasks.push(() => this.approvingTransactionIds.delete(transactionId));
|
|
1356
1310
|
const [nonce, releaseNonce] = await getNextNonce(transactionMeta, (address) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNonceLock(address, transactionMeta.networkClientId));
|
|
1357
|
-
|
|
1311
|
+
// must set transaction to submitted/failed before releasing lock
|
|
1312
|
+
releaseNonce && cleanupTasks.push(releaseNonce);
|
|
1358
1313
|
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1359
1314
|
transactionId,
|
|
1360
1315
|
note: 'TransactionController#approveTransaction - Transaction approved',
|
|
@@ -1391,19 +1346,8 @@ export class TransactionController extends BaseController {
|
|
|
1391
1346
|
}
|
|
1392
1347
|
log('Publishing transaction', transactionMeta.txParams);
|
|
1393
1348
|
let hash;
|
|
1394
|
-
clearNonceLock?.();
|
|
1395
|
-
clearNonceLock = undefined;
|
|
1396
|
-
if (transactionMeta.batchTransactions?.length) {
|
|
1397
|
-
log('Found batch transactions', transactionMeta.batchTransactions);
|
|
1398
|
-
const extraTransactionsPublishHook = new ExtraTransactionsPublishHook({
|
|
1399
|
-
addTransactionBatch: this.addTransactionBatch.bind(this),
|
|
1400
|
-
transactions: transactionMeta.batchTransactions,
|
|
1401
|
-
});
|
|
1402
|
-
publishHookOverride = extraTransactionsPublishHook.getHook();
|
|
1403
|
-
}
|
|
1404
1349
|
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Publish', parentContext: traceContext }, async () => {
|
|
1405
|
-
|
|
1406
|
-
({ transactionHash: hash } = await publishHook(transactionMeta, rawTx));
|
|
1350
|
+
({ transactionHash: hash } = await this.publish(transactionMeta, rawTx));
|
|
1407
1351
|
if (hash === undefined) {
|
|
1408
1352
|
hash = await this.publishTransaction(ethQuery, {
|
|
1409
1353
|
...transactionMeta,
|
|
@@ -1439,8 +1383,7 @@ export class TransactionController extends BaseController {
|
|
|
1439
1383
|
return ApprovalState.NotApproved;
|
|
1440
1384
|
}
|
|
1441
1385
|
finally {
|
|
1442
|
-
|
|
1443
|
-
clearNonceLock?.();
|
|
1386
|
+
cleanupTasks.forEach((task) => task());
|
|
1444
1387
|
}
|
|
1445
1388
|
}
|
|
1446
1389
|
async publishTransaction(ethQuery, transactionMeta, { skipSubmitHistory } = {}) {
|
|
@@ -1767,8 +1710,8 @@ export class TransactionController extends BaseController {
|
|
|
1767
1710
|
transactionMeta,
|
|
1768
1711
|
});
|
|
1769
1712
|
}
|
|
1770
|
-
getNonceTrackerTransactions(
|
|
1771
|
-
return getAndFormatTransactionsForNonceTracker(chainId, address,
|
|
1713
|
+
getNonceTrackerTransactions(status, address, chainId) {
|
|
1714
|
+
return getAndFormatTransactionsForNonceTracker(chainId, address, status, this.state.transactions);
|
|
1772
1715
|
}
|
|
1773
1716
|
onConfirmedTransaction(transactionMeta) {
|
|
1774
1717
|
log('Processing confirmed transaction', transactionMeta.id);
|
|
@@ -1828,7 +1771,7 @@ export class TransactionController extends BaseController {
|
|
|
1828
1771
|
error?.data?.message?.includes('nonce too low'));
|
|
1829
1772
|
}
|
|
1830
1773
|
}
|
|
1831
|
-
_TransactionController_internalEvents = new WeakMap(), _TransactionController_methodDataHelper = new WeakMap(), _TransactionController_incomingTransactionHelper = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(),
|
|
1774
|
+
_TransactionController_internalEvents = new WeakMap(), _TransactionController_methodDataHelper = new WeakMap(), _TransactionController_incomingTransactionHelper = new WeakMap(), _TransactionController_incomingTransactionOptions = new WeakMap(), _TransactionController_pendingTransactionOptions = new WeakMap(), _TransactionController_publicKeyEIP7702 = 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, }) {
|
|
1832
1775
|
// If transaction is found for same action id, do not create a new transaction.
|
|
1833
1776
|
if (this.getTransactionWithActionId(actionId)) {
|
|
1834
1777
|
return;
|
|
@@ -1936,7 +1879,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1936
1879
|
// TODO: Fix types
|
|
1937
1880
|
blockTracker,
|
|
1938
1881
|
getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
|
|
1939
|
-
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this,
|
|
1882
|
+
getConfirmedTransactions: this.getNonceTrackerTransactions.bind(this, TransactionStatus.confirmed, chainId),
|
|
1940
1883
|
});
|
|
1941
1884
|
}, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ provider, blockTracker, chainId, networkClientId, }) {
|
|
1942
1885
|
const ethQuery = new EthQuery(provider);
|
|
@@ -1975,11 +1918,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1975
1918
|
pendingTransactionTracker.hub.on('transaction-failed', this.failTransaction.bind(this));
|
|
1976
1919
|
pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
|
|
1977
1920
|
}, _TransactionController_getNonceTrackerPendingTransactions = function _TransactionController_getNonceTrackerPendingTransactions(chainId, address) {
|
|
1978
|
-
const standardPendingTransactions = this.getNonceTrackerTransactions(
|
|
1979
|
-
TransactionStatus.approved,
|
|
1980
|
-
TransactionStatus.signed,
|
|
1981
|
-
TransactionStatus.submitted,
|
|
1982
|
-
], address, chainId);
|
|
1921
|
+
const standardPendingTransactions = this.getNonceTrackerTransactions(TransactionStatus.submitted, address, chainId);
|
|
1983
1922
|
const externalPendingTransactions = this.getExternalPendingTransactions(address, chainId);
|
|
1984
1923
|
return [...standardPendingTransactions, ...externalPendingTransactions];
|
|
1985
1924
|
}, _TransactionController_getGasFeeFlows = function _TransactionController_getGasFeeFlows() {
|
|
@@ -2074,9 +2013,8 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2074
2013
|
},
|
|
2075
2014
|
tokenBalanceChanges: [],
|
|
2076
2015
|
};
|
|
2077
|
-
let gasFeeTokens = [];
|
|
2078
2016
|
if (__classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
|
|
2079
|
-
|
|
2017
|
+
simulationData = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => getSimulationData({
|
|
2080
2018
|
chainId,
|
|
2081
2019
|
from: from,
|
|
2082
2020
|
to: to,
|
|
@@ -2085,8 +2023,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2085
2023
|
}, {
|
|
2086
2024
|
blockTime,
|
|
2087
2025
|
}));
|
|
2088
|
-
gasFeeTokens = result?.gasFeeTokens;
|
|
2089
|
-
simulationData = result?.simulationData;
|
|
2090
2026
|
if (blockTime &&
|
|
2091
2027
|
prevSimulationData &&
|
|
2092
2028
|
hasSimulationDataChanged(prevSimulationData, simulationData)) {
|
|
@@ -2107,7 +2043,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2107
2043
|
note: 'TransactionController#updateSimulationData - Update simulation data',
|
|
2108
2044
|
skipResimulateCheck: Boolean(blockTime),
|
|
2109
2045
|
}, (txMeta) => {
|
|
2110
|
-
txMeta.gasFeeTokens = gasFeeTokens;
|
|
2111
2046
|
txMeta.simulationData = simulationData;
|
|
2112
2047
|
});
|
|
2113
2048
|
log('Updated simulation data', transactionId, simulationData);
|