@metamask-previews/transaction-controller 46.0.0-preview-b8f29301 → 46.0.0-preview-0ae65d9e
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 +1 -0
- package/dist/TransactionController.cjs +41 -26
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +62 -70
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +62 -70
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +42 -27
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/api/accounts-api.cjs +2 -0
- package/dist/api/accounts-api.cjs.map +1 -1
- package/dist/api/accounts-api.d.cts +2 -0
- package/dist/api/accounts-api.d.cts.map +1 -1
- package/dist/api/accounts-api.d.mts +2 -0
- package/dist/api/accounts-api.d.mts.map +1 -1
- package/dist/api/accounts-api.mjs +2 -0
- package/dist/api/accounts-api.mjs.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.cjs +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.mjs +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/helpers/GasFeePoller.cjs +1 -0
- package/dist/helpers/GasFeePoller.cjs.map +1 -1
- package/dist/helpers/GasFeePoller.d.cts +1 -0
- package/dist/helpers/GasFeePoller.d.cts.map +1 -1
- package/dist/helpers/GasFeePoller.d.mts +1 -0
- package/dist/helpers/GasFeePoller.d.mts.map +1 -1
- package/dist/helpers/GasFeePoller.mjs +1 -0
- package/dist/helpers/GasFeePoller.mjs.map +1 -1
- 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.map +1 -1
- package/dist/helpers/MethodDataHelper.cjs.map +1 -1
- package/dist/helpers/MethodDataHelper.d.cts.map +1 -1
- package/dist/helpers/MethodDataHelper.d.mts.map +1 -1
- package/dist/helpers/MethodDataHelper.mjs.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.cjs +1 -21
- package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.mjs +1 -21
- package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
- 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.map +1 -1
- package/dist/helpers/TransactionPoller.cjs +2 -0
- package/dist/helpers/TransactionPoller.cjs.map +1 -1
- package/dist/helpers/TransactionPoller.d.cts +2 -0
- package/dist/helpers/TransactionPoller.d.cts.map +1 -1
- package/dist/helpers/TransactionPoller.d.mts +2 -0
- package/dist/helpers/TransactionPoller.d.mts.map +1 -1
- package/dist/helpers/TransactionPoller.mjs +2 -0
- package/dist/helpers/TransactionPoller.mjs.map +1 -1
- package/dist/utils/eip7702.cjs +1 -1
- package/dist/utils/eip7702.cjs.map +1 -1
- package/dist/utils/eip7702.d.cts +0 -14
- package/dist/utils/eip7702.d.cts.map +1 -1
- package/dist/utils/eip7702.d.mts +0 -14
- package/dist/utils/eip7702.d.mts.map +1 -1
- package/dist/utils/eip7702.mjs +1 -1
- package/dist/utils/eip7702.mjs.map +1 -1
- package/dist/utils/gas-fees.cjs +48 -3
- package/dist/utils/gas-fees.cjs.map +1 -1
- package/dist/utils/gas-fees.d.cts +11 -0
- package/dist/utils/gas-fees.d.cts.map +1 -1
- package/dist/utils/gas-fees.d.mts +11 -0
- package/dist/utils/gas-fees.d.mts.map +1 -1
- package/dist/utils/gas-fees.mjs +48 -3
- package/dist/utils/gas-fees.mjs.map +1 -1
- package/dist/utils/gas-flow.cjs +4 -0
- package/dist/utils/gas-flow.cjs.map +1 -1
- package/dist/utils/gas-flow.d.cts +1 -0
- package/dist/utils/gas-flow.d.cts.map +1 -1
- package/dist/utils/gas-flow.d.mts +1 -0
- package/dist/utils/gas-flow.d.mts.map +1 -1
- package/dist/utils/gas-flow.mjs +4 -0
- package/dist/utils/gas-flow.mjs.map +1 -1
- package/dist/utils/gas.cjs +50 -1
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.d.cts +22 -0
- package/dist/utils/gas.d.cts.map +1 -1
- package/dist/utils/gas.d.mts +22 -0
- package/dist/utils/gas.d.mts.map +1 -1
- package/dist/utils/gas.mjs +50 -1
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.cjs +5 -1
- package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.d.cts +4 -1
- package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.d.mts +4 -1
- package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.mjs +5 -1
- package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -1
- package/dist/utils/retry.cjs +4 -0
- package/dist/utils/retry.cjs.map +1 -1
- package/dist/utils/retry.d.cts +1 -0
- package/dist/utils/retry.d.cts.map +1 -1
- package/dist/utils/retry.d.mts +1 -0
- package/dist/utils/retry.d.mts.map +1 -1
- package/dist/utils/retry.mjs +4 -0
- package/dist/utils/retry.mjs.map +1 -1
- package/dist/utils/simulation-api.cjs +6 -0
- package/dist/utils/simulation-api.cjs.map +1 -1
- package/dist/utils/simulation-api.d.cts +2 -0
- package/dist/utils/simulation-api.d.cts.map +1 -1
- package/dist/utils/simulation-api.d.mts +2 -0
- package/dist/utils/simulation-api.d.mts.map +1 -1
- package/dist/utils/simulation-api.mjs +6 -0
- package/dist/utils/simulation-api.mjs.map +1 -1
- package/dist/utils/simulation.cjs +19 -5
- package/dist/utils/simulation.cjs.map +1 -1
- package/dist/utils/simulation.d.cts +3 -1
- package/dist/utils/simulation.d.cts.map +1 -1
- package/dist/utils/simulation.d.mts +3 -1
- package/dist/utils/simulation.d.mts.map +1 -1
- package/dist/utils/simulation.mjs +19 -5
- package/dist/utils/simulation.mjs.map +1 -1
- package/dist/utils/swaps.cjs +2 -1
- package/dist/utils/swaps.cjs.map +1 -1
- package/dist/utils/swaps.d.cts +1 -0
- package/dist/utils/swaps.d.cts.map +1 -1
- package/dist/utils/swaps.d.mts +1 -0
- package/dist/utils/swaps.d.mts.map +1 -1
- package/dist/utils/swaps.mjs +2 -1
- package/dist/utils/swaps.mjs.map +1 -1
- package/dist/utils/transaction-type.cjs +3 -1
- package/dist/utils/transaction-type.cjs.map +1 -1
- package/dist/utils/transaction-type.mjs +3 -1
- package/dist/utils/transaction-type.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- Add `updateAtomicBatchData` method ([#5380](https://github.com/MetaMask/core/pull/5380))
|
|
12
13
|
- Support atomic batch transactions ([#5306](https://github.com/MetaMask/core/pull/5306))
|
|
13
14
|
- Add methods:
|
|
14
15
|
- `addTransactionBatch`
|
|
@@ -154,31 +154,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
154
154
|
* Constructs a TransactionController.
|
|
155
155
|
*
|
|
156
156
|
* @param options - The controller options.
|
|
157
|
-
* @param options.disableHistory - Whether to disable storing history in transaction metadata.
|
|
158
|
-
* @param options.disableSendFlowHistory - Explicitly disable transaction metadata history.
|
|
159
|
-
* @param options.disableSwaps - Whether to disable additional processing on swaps transactions.
|
|
160
|
-
* @param options.getCurrentAccountEIP1559Compatibility - Whether or not the account supports EIP-1559.
|
|
161
|
-
* @param options.getCurrentNetworkEIP1559Compatibility - Whether or not the network supports EIP-1559.
|
|
162
|
-
* @param options.getExternalPendingTransactions - Callback to retrieve pending transactions from external sources.
|
|
163
|
-
* @param options.getGasFeeEstimates - Callback to retrieve gas fee estimates.
|
|
164
|
-
* @param options.getNetworkClientRegistry - Gets the network client registry.
|
|
165
|
-
* @param options.getNetworkState - Gets the state of the network controller.
|
|
166
|
-
* @param options.getPermittedAccounts - Get accounts that a given origin has permissions for.
|
|
167
|
-
* @param options.getSavedGasFees - Gets the saved gas fee config.
|
|
168
|
-
* @param options.incomingTransactions - Configuration options for incoming transaction support.
|
|
169
|
-
* @param options.isFirstTimeInteractionEnabled - Whether first time interaction checks are enabled.
|
|
170
|
-
* @param options.isSimulationEnabled - Whether new transactions will be automatically simulated.
|
|
171
|
-
* @param options.messenger - The controller messenger.
|
|
172
|
-
* @param options.pendingTransactions - Configuration options for pending transaction support.
|
|
173
|
-
* @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
|
|
174
|
-
* @param options.sign - Function used to sign transactions.
|
|
175
|
-
* @param options.state - Initial state to set on this controller.
|
|
176
|
-
* @param options.testGasFeeFlows - Whether to use the test gas fee flow.
|
|
177
|
-
* @param options.trace - Callback to generate trace information.
|
|
178
|
-
* @param options.transactionHistoryLimit - Transaction history limit.
|
|
179
|
-
* @param options.hooks - The controller hooks.
|
|
180
157
|
*/
|
|
181
|
-
constructor(
|
|
158
|
+
constructor(options) {
|
|
159
|
+
const { disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isFirstTimeInteractionEnabled, isSimulationEnabled, messenger, pendingTransactions = {}, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, } = options;
|
|
182
160
|
super({
|
|
183
161
|
name: controllerName,
|
|
184
162
|
metadata,
|
|
@@ -513,7 +491,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
513
491
|
* @param options.estimatedBaseFee - The estimated base fee of the transaction.
|
|
514
492
|
*/
|
|
515
493
|
async stopTransaction(transactionId, gasValues, { estimatedBaseFee, actionId, } = {}) {
|
|
516
|
-
|
|
494
|
+
await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
|
|
517
495
|
actionId,
|
|
518
496
|
estimatedBaseFee,
|
|
519
497
|
gasValues,
|
|
@@ -542,7 +520,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
542
520
|
* @param options.estimatedBaseFee - The estimated base fee of the transaction.
|
|
543
521
|
*/
|
|
544
522
|
async speedUpTransaction(transactionId, gasValues, { actionId, estimatedBaseFee, } = {}) {
|
|
545
|
-
|
|
523
|
+
await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
|
|
546
524
|
actionId,
|
|
547
525
|
estimatedBaseFee,
|
|
548
526
|
gasValues,
|
|
@@ -575,6 +553,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
575
553
|
* @param transaction - The transaction params to estimate gas for.
|
|
576
554
|
* @param multiplier - The multiplier to use for the gas buffer.
|
|
577
555
|
* @param networkClientId - The network client id to use for the estimate.
|
|
556
|
+
* @returns The buffered estimated gas and whether the estimation failed.
|
|
578
557
|
*/
|
|
579
558
|
async estimateGasBuffered(transaction, multiplier, networkClientId) {
|
|
580
559
|
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
@@ -1061,6 +1040,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1061
1040
|
* @param request.transactionParams - The transaction parameters to estimate the layer 1 gas fee for.
|
|
1062
1041
|
* @param request.chainId - The ID of the chain where the transaction will be executed.
|
|
1063
1042
|
* @param request.networkClientId - The ID of a specific network client to process the transaction.
|
|
1043
|
+
* @returns The layer 1 gas fee.
|
|
1064
1044
|
*/
|
|
1065
1045
|
async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
|
|
1066
1046
|
const provider = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getProvider).call(this, {
|
|
@@ -1123,6 +1103,37 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1123
1103
|
abortCallback();
|
|
1124
1104
|
this.signAbortCallbacks.delete(transactionId);
|
|
1125
1105
|
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Update the transaction data of a single nested transaction within an atomic batch transaction.
|
|
1108
|
+
*
|
|
1109
|
+
* @param options - The options bag.
|
|
1110
|
+
* @param options.transactionId - ID of the atomic batch transaction.
|
|
1111
|
+
* @param options.transactionIndex - Index of the nested transaction within the atomic batch transaction.
|
|
1112
|
+
* @param options.transactionData - New data to set for the nested transaction.
|
|
1113
|
+
* @returns The updated data for the atomic batch transaction.
|
|
1114
|
+
*/
|
|
1115
|
+
updateAtomicBatchData({ transactionId, transactionIndex, transactionData, }) {
|
|
1116
|
+
(0, logger_1.projectLogger)('Updating atomic batch data', {
|
|
1117
|
+
transactionId,
|
|
1118
|
+
transactionIndex,
|
|
1119
|
+
transactionData,
|
|
1120
|
+
});
|
|
1121
|
+
const updatedTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1122
|
+
transactionId,
|
|
1123
|
+
note: 'TransactionController#updateAtomicBatchData - Atomic batch data updated',
|
|
1124
|
+
}, (transactionMeta) => {
|
|
1125
|
+
const { nestedTransactions, txParams } = transactionMeta;
|
|
1126
|
+
const from = txParams.from;
|
|
1127
|
+
const nestedTransaction = nestedTransactions?.[transactionIndex];
|
|
1128
|
+
if (!nestedTransaction) {
|
|
1129
|
+
throw new Error(`Nested transaction not found with index - ${transactionIndex}`);
|
|
1130
|
+
}
|
|
1131
|
+
nestedTransaction.data = transactionData;
|
|
1132
|
+
const batchTransaction = (0, eip7702_1.generateEIP7702BatchTransaction)(from, nestedTransactions);
|
|
1133
|
+
transactionMeta.txParams.data = batchTransaction.data;
|
|
1134
|
+
});
|
|
1135
|
+
return updatedTransactionMeta.txParams.data;
|
|
1136
|
+
}
|
|
1126
1137
|
addMetadata(transactionMeta) {
|
|
1127
1138
|
(0, validation_1.validateTxParams)(transactionMeta.txParams);
|
|
1128
1139
|
this.update((state) => {
|
|
@@ -1251,6 +1262,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1251
1262
|
*
|
|
1252
1263
|
* @param transactionId - The ID of the transaction to approve.
|
|
1253
1264
|
* @param traceContext - The parent context for any new traces.
|
|
1265
|
+
* @returns The state of the approval.
|
|
1254
1266
|
*/
|
|
1255
1267
|
async approveTransaction(transactionId, traceContext) {
|
|
1256
1268
|
const cleanupTasks = new Array();
|
|
@@ -1907,6 +1919,9 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1907
1919
|
let resimulateResponse;
|
|
1908
1920
|
this.update((state) => {
|
|
1909
1921
|
const index = state.transactions.findIndex(({ id }) => id === transactionId);
|
|
1922
|
+
if (index === -1) {
|
|
1923
|
+
throw new Error(`Cannot update transaction as ID not found - ${transactionId}`);
|
|
1924
|
+
}
|
|
1910
1925
|
let transactionMeta = state.transactions[index];
|
|
1911
1926
|
const originalTransactionMeta = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
1912
1927
|
transactionMeta = callback(transactionMeta) ?? transactionMeta;
|