@metamask/transaction-controller 56.0.0 → 56.1.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 +19 -1
- package/dist/TransactionController.cjs +56 -18
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +10 -2
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +10 -2
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +58 -20
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/api/accounts-api.cjs +3 -2
- package/dist/api/accounts-api.cjs.map +1 -1
- package/dist/api/accounts-api.d.cts +1 -0
- package/dist/api/accounts-api.d.cts.map +1 -1
- package/dist/api/accounts-api.d.mts +1 -0
- package/dist/api/accounts-api.d.mts.map +1 -1
- package/dist/api/accounts-api.mjs +3 -2
- package/dist/api/accounts-api.mjs.map +1 -1
- package/dist/helpers/AccountsApiRemoteTransactionSource.cjs +2 -1
- package/dist/helpers/AccountsApiRemoteTransactionSource.cjs.map +1 -1
- package/dist/helpers/AccountsApiRemoteTransactionSource.d.cts.map +1 -1
- package/dist/helpers/AccountsApiRemoteTransactionSource.d.mts.map +1 -1
- package/dist/helpers/AccountsApiRemoteTransactionSource.mjs +2 -1
- package/dist/helpers/AccountsApiRemoteTransactionSource.mjs.map +1 -1
- package/dist/helpers/GasFeePoller.cjs +76 -48
- package/dist/helpers/GasFeePoller.cjs.map +1 -1
- package/dist/helpers/GasFeePoller.d.cts +15 -3
- package/dist/helpers/GasFeePoller.d.cts.map +1 -1
- package/dist/helpers/GasFeePoller.d.mts +15 -3
- package/dist/helpers/GasFeePoller.d.mts.map +1 -1
- package/dist/helpers/GasFeePoller.mjs +73 -46
- package/dist/helpers/GasFeePoller.mjs.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.cjs +22 -4
- package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.d.cts +5 -2
- package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.d.mts +5 -2
- package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.mjs +22 -4
- package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +4 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +4 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/validation.cjs +1 -0
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts +2 -1
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts +2 -1
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs +1 -0
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [56.1.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Automatically update gas fee properties in `txParams` when `updateTransactionGasFees` method is called with `userFeeLevel` ([#5800](https://github.com/MetaMask/core/pull/5800))
|
|
15
|
+
- Support additional debug of incoming transaction requests ([#5803](https://github.com/MetaMask/core/pull/5803))
|
|
16
|
+
- Add optional `incomingTransactions.client` constructor property.
|
|
17
|
+
- Add optional `tags` property to `updateIncomingTransactions` method.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Bump `@metamask/controller-utils` to `^11.9.0` ([#5812](https://github.com/MetaMask/core/pull/5812))
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Throw correct error code if upgrade rejected ([#5814](https://github.com/MetaMask/core/pull/5814))
|
|
26
|
+
|
|
10
27
|
## [56.0.0]
|
|
11
28
|
|
|
12
29
|
### Changed
|
|
@@ -1584,7 +1601,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1584
1601
|
|
|
1585
1602
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
1586
1603
|
|
|
1587
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@56.
|
|
1604
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@56.1.0...HEAD
|
|
1605
|
+
[56.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@56.0.0...@metamask/transaction-controller@56.1.0
|
|
1588
1606
|
[56.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@55.0.2...@metamask/transaction-controller@56.0.0
|
|
1589
1607
|
[55.0.2]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@55.0.1...@metamask/transaction-controller@55.0.2
|
|
1590
1608
|
[55.0.1]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@55.0.0...@metamask/transaction-controller@55.0.1
|
|
@@ -259,6 +259,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
259
259
|
});
|
|
260
260
|
};
|
|
261
261
|
__classPrivateFieldSet(this, _TransactionController_incomingTransactionHelper, new IncomingTransactionHelper_1.IncomingTransactionHelper({
|
|
262
|
+
client: __classPrivateFieldGet(this, _TransactionController_incomingTransactionOptions, "f").client,
|
|
262
263
|
getCache: () => this.state.lastFetchedBlockNumbers,
|
|
263
264
|
getCurrentAccount: () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this),
|
|
264
265
|
getLocalTransactions: () => this.state.transactions,
|
|
@@ -494,8 +495,14 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
494
495
|
stopIncomingTransactionPolling() {
|
|
495
496
|
__classPrivateFieldGet(this, _TransactionController_incomingTransactionHelper, "f").stop();
|
|
496
497
|
}
|
|
497
|
-
|
|
498
|
-
|
|
498
|
+
/**
|
|
499
|
+
* Update the incoming transactions by polling the remote transaction source.
|
|
500
|
+
*
|
|
501
|
+
* @param request - Request object.
|
|
502
|
+
* @param request.tags - Additional tags to identify the source of the request.
|
|
503
|
+
*/
|
|
504
|
+
async updateIncomingTransactions({ tags } = {}) {
|
|
505
|
+
await __classPrivateFieldGet(this, _TransactionController_incomingTransactionHelper, "f").update({ tags });
|
|
499
506
|
}
|
|
500
507
|
/**
|
|
501
508
|
* Attempts to cancel a transaction based on its ID by setting its status to "rejected"
|
|
@@ -736,35 +743,66 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
736
743
|
* @param gasValues.userFeeLevel - Estimate level user selected.
|
|
737
744
|
* @returns The updated transactionMeta.
|
|
738
745
|
*/
|
|
739
|
-
updateTransactionGasFees(transactionId, { defaultGasEstimates, estimateUsed, estimateSuggested, gas, gasLimit, gasPrice, maxPriorityFeePerGas, maxFeePerGas, originalGasEstimate, userEditedGasLimit, userFeeLevel, }) {
|
|
746
|
+
updateTransactionGasFees(transactionId, { defaultGasEstimates, estimateUsed, estimateSuggested, gas, gasLimit, gasPrice, maxPriorityFeePerGas, maxFeePerGas, originalGasEstimate, userEditedGasLimit, userFeeLevel: userFeeLevelParam, }) {
|
|
740
747
|
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
741
748
|
if (!transactionMeta) {
|
|
742
749
|
throw new Error(`Cannot update transaction as no transaction metadata found`);
|
|
743
750
|
}
|
|
744
751
|
(0, utils_2.validateIfTransactionUnapproved)(transactionMeta, 'updateTransactionGasFees');
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
752
|
+
const clonedTransactionMeta = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
753
|
+
const isTransactionGasFeeEstimatesExists = transactionMeta.gasFeeEstimates;
|
|
754
|
+
const isAutomaticGasFeeUpdateEnabled = __classPrivateFieldGet(this, _TransactionController_isAutomaticGasFeeUpdateEnabled, "f").call(this, transactionMeta);
|
|
755
|
+
const userFeeLevel = userFeeLevelParam;
|
|
756
|
+
const isOneOfFeeLevelSelected = Object.values(types_1.GasFeeEstimateLevel).includes(userFeeLevel);
|
|
757
|
+
const shouldUpdateTxParamsGasFees = isTransactionGasFeeEstimatesExists &&
|
|
758
|
+
isAutomaticGasFeeUpdateEnabled &&
|
|
759
|
+
isOneOfFeeLevelSelected;
|
|
760
|
+
if (shouldUpdateTxParamsGasFees) {
|
|
761
|
+
(0, GasFeePoller_1.updateTransactionGasEstimates)({
|
|
762
|
+
txMeta: clonedTransactionMeta,
|
|
763
|
+
userFeeLevel,
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
const txParamsUpdate = {
|
|
767
|
+
gas,
|
|
768
|
+
gasLimit,
|
|
769
|
+
};
|
|
770
|
+
if (shouldUpdateTxParamsGasFees) {
|
|
771
|
+
// Get updated values from clonedTransactionMeta if we're using automated fee updates
|
|
772
|
+
Object.assign(txParamsUpdate, {
|
|
773
|
+
gasPrice: clonedTransactionMeta.txParams.gasPrice,
|
|
774
|
+
maxPriorityFeePerGas: clonedTransactionMeta.txParams.maxPriorityFeePerGas,
|
|
775
|
+
maxFeePerGas: clonedTransactionMeta.txParams.maxFeePerGas,
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
Object.assign(txParamsUpdate, {
|
|
749
780
|
gasPrice,
|
|
750
781
|
maxPriorityFeePerGas,
|
|
751
782
|
maxFeePerGas,
|
|
752
|
-
}
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
const transactionGasFees = {
|
|
786
|
+
txParams: (0, lodash_1.pickBy)(txParamsUpdate),
|
|
753
787
|
defaultGasEstimates,
|
|
754
788
|
estimateUsed,
|
|
755
789
|
estimateSuggested,
|
|
756
790
|
originalGasEstimate,
|
|
757
791
|
userEditedGasLimit,
|
|
758
792
|
userFeeLevel,
|
|
759
|
-
// TODO: Replace `any` with type
|
|
760
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
761
793
|
};
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
794
|
+
const filteredTransactionGasFees = (0, lodash_1.pickBy)(transactionGasFees);
|
|
795
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
796
|
+
transactionId,
|
|
797
|
+
note: `${controllerName}:updateTransactionGasFees - gas values updated`,
|
|
798
|
+
skipResimulateCheck: true,
|
|
799
|
+
}, (draftTxMeta) => {
|
|
800
|
+
const { txParams, ...otherProps } = filteredTransactionGasFees;
|
|
801
|
+
Object.assign(draftTxMeta, otherProps);
|
|
802
|
+
if (txParams) {
|
|
803
|
+
Object.assign(draftTxMeta.txParams, txParams);
|
|
804
|
+
}
|
|
805
|
+
});
|
|
768
806
|
return __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
769
807
|
}
|
|
770
808
|
/**
|
|
@@ -2042,7 +2080,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2042
2080
|
(0, logger_1.projectLogger)('Updated simulation data', transactionId, simulationData);
|
|
2043
2081
|
}, _TransactionController_onGasFeePollerTransactionUpdate = function _TransactionController_onGasFeePollerTransactionUpdate({ transactionId, gasFeeEstimates, gasFeeEstimatesLoaded, layer1GasFee, }) {
|
|
2044
2082
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId, skipHistory: true }, (txMeta) => {
|
|
2045
|
-
(0, GasFeePoller_1.
|
|
2083
|
+
(0, GasFeePoller_1.updateTransactionGasProperties)({
|
|
2046
2084
|
txMeta,
|
|
2047
2085
|
gasFeeEstimates,
|
|
2048
2086
|
gasFeeEstimatesLoaded,
|
|
@@ -2105,7 +2143,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2105
2143
|
}, _TransactionController_isRejectError = function _TransactionController_isRejectError(error) {
|
|
2106
2144
|
return [
|
|
2107
2145
|
rpc_errors_1.errorCodes.provider.userRejectedRequest,
|
|
2108
|
-
|
|
2146
|
+
validation_1.ErrorCode.RejectedUpgrade,
|
|
2109
2147
|
].includes(error.code);
|
|
2110
2148
|
}, _TransactionController_rejectTransactionAndThrow = function _TransactionController_rejectTransactionAndThrow(transactionId, actionId, error) {
|
|
2111
2149
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_rejectTransaction).call(this, transactionId, actionId, error);
|