@metamask-previews/transaction-controller 52.0.0-preview-e3c959f → 52.0.0-preview-e56c504a
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 -5
- package/dist/TransactionController.cjs +22 -14
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +7 -0
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +7 -0
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +22 -14
- 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 +30 -0
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +30 -0
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/feature-flags.cjs +2 -2
- package/dist/utils/feature-flags.cjs.map +1 -1
- package/dist/utils/feature-flags.d.cts +2 -2
- package/dist/utils/feature-flags.d.mts +2 -2
- package/dist/utils/feature-flags.mjs +2 -2
- package/dist/utils/feature-flags.mjs.map +1 -1
- package/dist/utils/gas.cjs +8 -108
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.d.cts +5 -16
- package/dist/utils/gas.d.cts.map +1 -1
- package/dist/utils/gas.d.mts +5 -16
- package/dist/utils/gas.d.mts.map +1 -1
- package/dist/utils/gas.mjs +8 -108
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/simulation-api.cjs.map +1 -1
- package/dist/utils/simulation-api.d.cts +37 -7
- package/dist/utils/simulation-api.d.cts.map +1 -1
- package/dist/utils/simulation-api.d.mts +37 -7
- package/dist/utils/simulation-api.d.mts.map +1 -1
- package/dist/utils/simulation-api.mjs.map +1 -1
- package/dist/utils/simulation.cjs +43 -5
- package/dist/utils/simulation.cjs.map +1 -1
- package/dist/utils/simulation.d.cts +6 -2
- package/dist/utils/simulation.d.cts.map +1 -1
- package/dist/utils/simulation.d.mts +6 -2
- package/dist/utils/simulation.d.mts.map +1 -1
- package/dist/utils/simulation.mjs +43 -5
- package/dist/utils/simulation.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
###
|
|
10
|
+
### Added
|
|
11
11
|
|
|
12
|
-
-
|
|
12
|
+
- Add `gasFeeTokens` to `TransactionMeta` ([#5524](https://github.com/MetaMask/core/pull/5524))
|
|
13
|
+
- Add `GasFeeToken` type.
|
|
14
|
+
- Add `selectedGasFeeToken` to `TransactionMeta`.
|
|
15
|
+
- Add `updateSelectedGasFeeToken` method.
|
|
13
16
|
|
|
14
17
|
## [52.0.0]
|
|
15
18
|
|
|
@@ -33,7 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
33
36
|
### Added
|
|
34
37
|
|
|
35
38
|
- Add additional metadata for batch metrics ([#5488](https://github.com/MetaMask/core/pull/5488))
|
|
36
|
-
- Add `delegationAddress` to `
|
|
39
|
+
- Add `delegationAddress` to `TransactionMeta`.
|
|
37
40
|
- Add `NestedTransactionMetadata` type containing `BatchTransactionParams` and `type`.
|
|
38
41
|
- Add optional `type` to `TransactionBatchSingleRequest`.
|
|
39
42
|
- Verify EIP-7702 contract address using signatures ([#5472](https://github.com/MetaMask/core/pull/5472))
|
|
@@ -44,8 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
44
47
|
|
|
45
48
|
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency to `^26.1.0` ([#5481](https://github.com/MetaMask/core/pull/5481))
|
|
46
49
|
- **BREAKING:** Add additional metadata for batch metrics ([#5488](https://github.com/MetaMask/core/pull/5488))
|
|
47
|
-
- Change `error` in `
|
|
48
|
-
- Change `nestedTransactions` in `
|
|
50
|
+
- Change `error` in `TransactionMeta` to optional for all statuses.
|
|
51
|
+
- Change `nestedTransactions` in `TransactionMeta` to array of `NestedTransactionMetadata`.
|
|
49
52
|
- Throw if `addTransactionBatch` called with external origin and size limit exceeded ([#5489](https://github.com/MetaMask/core/pull/5489))
|
|
50
53
|
- Verify EIP-7702 contract address using signatures ([#5472](https://github.com/MetaMask/core/pull/5472))
|
|
51
54
|
- Use new `contracts` property from feature flags instead of `contractAddresses`.
|
|
@@ -549,12 +549,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
549
549
|
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
550
550
|
networkClientId,
|
|
551
551
|
});
|
|
552
|
-
const { estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(
|
|
553
|
-
chainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId),
|
|
554
|
-
ethQuery,
|
|
555
|
-
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
|
|
556
|
-
txParams: transaction,
|
|
557
|
-
});
|
|
552
|
+
const { estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
|
|
558
553
|
return { gas: estimatedGas, simulationFails };
|
|
559
554
|
}
|
|
560
555
|
/**
|
|
@@ -569,12 +564,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
569
564
|
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
570
565
|
networkClientId,
|
|
571
566
|
});
|
|
572
|
-
const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(
|
|
573
|
-
chainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId),
|
|
574
|
-
ethQuery,
|
|
575
|
-
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
|
|
576
|
-
txParams: transaction,
|
|
577
|
-
});
|
|
567
|
+
const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
|
|
578
568
|
const gas = (0, gas_1.addGasBuffer)(estimatedGas, blockGasLimit, multiplier);
|
|
579
569
|
return {
|
|
580
570
|
gas,
|
|
@@ -1166,6 +1156,21 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1166
1156
|
});
|
|
1167
1157
|
return updatedTransactionMeta.txParams.data;
|
|
1168
1158
|
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Update the selected gas fee token for a transaction.
|
|
1161
|
+
*
|
|
1162
|
+
* @param transactionId - The ID of the transaction to update.
|
|
1163
|
+
* @param contractAddress - The contract address of the selected gas fee token.
|
|
1164
|
+
*/
|
|
1165
|
+
updateSelectedGasFeeToken(transactionId, contractAddress) {
|
|
1166
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (transactionMeta) => {
|
|
1167
|
+
const hasMatchingGasFeeToken = transactionMeta.gasFeeTokens?.some((token) => token.tokenAddress.toLowerCase() === contractAddress.toLowerCase());
|
|
1168
|
+
if (!hasMatchingGasFeeToken) {
|
|
1169
|
+
throw new Error(`No matching gas fee token found with address - ${contractAddress}`);
|
|
1170
|
+
}
|
|
1171
|
+
transactionMeta.selectedGasFeeToken = contractAddress;
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1169
1174
|
addMetadata(transactionMeta) {
|
|
1170
1175
|
(0, validation_1.validateTxParams)(transactionMeta.txParams);
|
|
1171
1176
|
this.update((state) => {
|
|
@@ -2011,8 +2016,9 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2011
2016
|
},
|
|
2012
2017
|
tokenBalanceChanges: [],
|
|
2013
2018
|
};
|
|
2019
|
+
let gasFeeTokens = [];
|
|
2014
2020
|
if (__classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
|
|
2015
|
-
|
|
2021
|
+
const result = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => (0, simulation_1.getSimulationData)({
|
|
2016
2022
|
chainId,
|
|
2017
2023
|
from: from,
|
|
2018
2024
|
to: to,
|
|
@@ -2021,6 +2027,8 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2021
2027
|
}, {
|
|
2022
2028
|
blockTime,
|
|
2023
2029
|
}));
|
|
2030
|
+
gasFeeTokens = result?.gasFeeTokens;
|
|
2031
|
+
simulationData = result?.simulationData;
|
|
2024
2032
|
if (blockTime &&
|
|
2025
2033
|
prevSimulationData &&
|
|
2026
2034
|
(0, ResimulateHelper_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
|
|
@@ -2041,6 +2049,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2041
2049
|
note: 'TransactionController#updateSimulationData - Update simulation data',
|
|
2042
2050
|
skipResimulateCheck: Boolean(blockTime),
|
|
2043
2051
|
}, (txMeta) => {
|
|
2052
|
+
txMeta.gasFeeTokens = gasFeeTokens;
|
|
2044
2053
|
txMeta.simulationData = simulationData;
|
|
2045
2054
|
});
|
|
2046
2055
|
(0, logger_1.projectLogger)('Updated simulation data', transactionId, simulationData);
|
|
@@ -2097,7 +2106,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
2097
2106
|
chainId,
|
|
2098
2107
|
ethQuery,
|
|
2099
2108
|
isCustomNetwork,
|
|
2100
|
-
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
|
|
2101
2109
|
txMeta: transactionMeta,
|
|
2102
2110
|
});
|
|
2103
2111
|
}, _TransactionController_deleteTransaction = function _TransactionController_deleteTransaction(transactionId) {
|