@metamask-previews/transaction-controller 62.0.0-preview-e3eb8eca → 62.0.0-preview-e0caebb
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 +6 -0
- package/dist/TransactionController.cjs +55 -10
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +56 -11
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +6 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +6 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/batch.cjs +19 -9
- package/dist/utils/batch.cjs.map +1 -1
- package/dist/utils/batch.mjs +19 -9
- package/dist/utils/batch.mjs.map +1 -1
- package/dist/utils/first-time-interaction.cjs +7 -2
- package/dist/utils/first-time-interaction.cjs.map +1 -1
- package/dist/utils/first-time-interaction.d.cts +1 -1
- package/dist/utils/first-time-interaction.d.cts.map +1 -1
- package/dist/utils/first-time-interaction.d.mts +1 -1
- package/dist/utils/first-time-interaction.d.mts.map +1 -1
- package/dist/utils/first-time-interaction.mjs +7 -2
- package/dist/utils/first-time-interaction.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Performance optimisations in `addTransaction` and `addTransactionBatch` methods ([#7205](https://github.com/MetaMask/core/pull/7205))
|
|
13
|
+
- Add `skipInitialGasEstimate` option to `addTransaction` and `addTransactionBatch` methods.
|
|
14
|
+
- Add `disableUpgrade` option to `addTransactionBatch` method.
|
|
15
|
+
|
|
10
16
|
## [62.0.0]
|
|
11
17
|
|
|
12
18
|
### Added
|
|
@@ -378,7 +378,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
378
378
|
*/
|
|
379
379
|
async addTransaction(txParams, options) {
|
|
380
380
|
(0, logger_1.projectLogger)('Adding transaction', txParams, options);
|
|
381
|
-
const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, gasFeeToken, isGasFeeIncluded, isGasFeeSponsored, method, nestedTransactions, networkClientId, origin, publishHook, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
|
|
381
|
+
const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, gasFeeToken, isGasFeeIncluded, isGasFeeSponsored, method, nestedTransactions, networkClientId, origin, publishHook, requireApproval, securityAlertResponse, sendFlowHistory, skipInitialGasEstimate, swaps = {}, traceContext, type, } = options;
|
|
382
382
|
txParams = (0, utils_2.normalizeTransactionParams)(txParams);
|
|
383
383
|
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
384
384
|
throw new Error(`Network client not found - ${networkClientId}`);
|
|
@@ -414,7 +414,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
414
414
|
}
|
|
415
415
|
const dappSuggestedGasFees = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_generateDappSuggestedGasFees).call(this, txParams, origin);
|
|
416
416
|
const transactionType = type ?? (await (0, transaction_type_1.determineTransactionType)(txParams, ethQuery)).type;
|
|
417
|
-
const delegationAddress = await delegationAddressPromise;
|
|
418
417
|
const existingTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionWithActionId).call(this, actionId);
|
|
419
418
|
// If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.
|
|
420
419
|
let addedTransactionMeta = existingTransactionMeta
|
|
@@ -426,7 +425,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
426
425
|
batchId,
|
|
427
426
|
chainId,
|
|
428
427
|
dappSuggestedGasFees,
|
|
429
|
-
delegationAddress,
|
|
430
428
|
deviceConfirmedOn,
|
|
431
429
|
disableGasBuffer,
|
|
432
430
|
id: (0, uuid_1.v1)(),
|
|
@@ -454,9 +452,32 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
454
452
|
addedTransactionMeta.txParamsOriginal = (0, lodash_1.cloneDeep)(addedTransactionMeta.txParams);
|
|
455
453
|
updateTransaction(addedTransactionMeta);
|
|
456
454
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
455
|
+
if (!skipInitialGasEstimate) {
|
|
456
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Estimate Gas Properties', parentContext: traceContext }, (context) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasProperties).call(this, addedTransactionMeta, {
|
|
457
|
+
traceContext: context,
|
|
458
|
+
}));
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
const newTransactionMeta = (0, lodash_1.cloneDeep)(addedTransactionMeta);
|
|
462
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasProperties).call(this, newTransactionMeta)
|
|
463
|
+
.then(() => {
|
|
464
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
465
|
+
transactionId: newTransactionMeta.id,
|
|
466
|
+
skipHistory: true,
|
|
467
|
+
skipResimulateCheck: true,
|
|
468
|
+
skipValidation: true,
|
|
469
|
+
}, (tx) => {
|
|
470
|
+
tx.txParams.gas = newTransactionMeta.txParams.gas;
|
|
471
|
+
tx.txParams.gasPrice = newTransactionMeta.txParams.gasPrice;
|
|
472
|
+
tx.txParams.maxFeePerGas =
|
|
473
|
+
newTransactionMeta.txParams.maxFeePerGas;
|
|
474
|
+
tx.txParams.maxPriorityFeePerGas =
|
|
475
|
+
newTransactionMeta.txParams.maxPriorityFeePerGas;
|
|
476
|
+
});
|
|
477
|
+
return undefined;
|
|
478
|
+
})
|
|
479
|
+
.catch(lodash_1.noop);
|
|
480
|
+
}
|
|
460
481
|
// Checks if a transaction already exists with a given actionId
|
|
461
482
|
if (!existingTransactionMeta) {
|
|
462
483
|
// Set security provider response
|
|
@@ -478,6 +499,19 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
478
499
|
messenger: this.messenger,
|
|
479
500
|
});
|
|
480
501
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addMetadata).call(this, addedTransactionMeta);
|
|
502
|
+
delegationAddressPromise
|
|
503
|
+
.then((delegationAddress) => {
|
|
504
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
505
|
+
transactionId: addedTransactionMeta.id,
|
|
506
|
+
skipHistory: true,
|
|
507
|
+
skipResimulateCheck: true,
|
|
508
|
+
skipValidation: true,
|
|
509
|
+
}, (tx) => {
|
|
510
|
+
tx.delegationAddress = delegationAddress;
|
|
511
|
+
});
|
|
512
|
+
return undefined;
|
|
513
|
+
})
|
|
514
|
+
.catch(lodash_1.noop);
|
|
481
515
|
if (requireApproval !== false) {
|
|
482
516
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).call(this, addedTransactionMeta, {
|
|
483
517
|
traceContext,
|
|
@@ -1509,10 +1543,21 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_afterSig
|
|
|
1509
1543
|
resultCallbacks.success();
|
|
1510
1544
|
}
|
|
1511
1545
|
const updatedTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1546
|
+
// need to check status of updatedTransactionMeta to see if it is approved
|
|
1547
|
+
// for special case like user reject request in hardware wallet, the transactionMeta is failed with error "user rejected request"
|
|
1548
|
+
if (updatedTransactionMeta.status === types_1.TransactionStatus.failed) {
|
|
1549
|
+
this.messenger.publish(`${controllerName}:transactionFailed`, {
|
|
1550
|
+
transactionMeta: updatedTransactionMeta,
|
|
1551
|
+
actionId,
|
|
1552
|
+
error: updatedTransactionMeta?.error?.message ?? 'Unknown error',
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
else {
|
|
1556
|
+
this.messenger.publish(`${controllerName}:transactionApproved`, {
|
|
1557
|
+
transactionMeta: updatedTransactionMeta,
|
|
1558
|
+
actionId,
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1516
1561
|
}
|
|
1517
1562
|
}
|
|
1518
1563
|
catch (rawError) {
|