@metamask/transaction-controller 45.0.0 → 46.0.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 +32 -1
- package/dist/TransactionController.cjs +72 -67
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +10 -15
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +10 -15
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +69 -64
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +4 -13
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs +4 -13
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/{utils/resimulate.cjs → helpers/ResimulateHelper.cjs} +93 -4
- package/dist/helpers/ResimulateHelper.cjs.map +1 -0
- package/dist/{utils/resimulate.d.cts → helpers/ResimulateHelper.d.cts} +13 -1
- package/dist/helpers/ResimulateHelper.d.cts.map +1 -0
- package/dist/{utils/resimulate.d.mts → helpers/ResimulateHelper.d.mts} +13 -1
- package/dist/helpers/ResimulateHelper.d.mts.map +1 -0
- package/dist/{utils/resimulate.mjs → helpers/ResimulateHelper.mjs} +93 -5
- package/dist/helpers/ResimulateHelper.mjs.map +1 -0
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +6 -37
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +51 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +51 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +6 -37
- package/dist/types.mjs.map +1 -1
- package/dist/utils/eip7702.cjs +87 -0
- package/dist/utils/eip7702.cjs.map +1 -0
- package/dist/utils/eip7702.d.cts +26 -0
- package/dist/utils/eip7702.d.cts.map +1 -0
- package/dist/utils/eip7702.d.mts +26 -0
- package/dist/utils/eip7702.d.mts.map +1 -0
- package/dist/utils/eip7702.mjs +83 -0
- package/dist/utils/eip7702.mjs.map +1 -0
- package/dist/utils/prepare.cjs +49 -0
- package/dist/utils/prepare.cjs.map +1 -0
- package/dist/utils/prepare.d.cts +21 -0
- package/dist/utils/prepare.d.cts.map +1 -0
- package/dist/utils/prepare.d.mts +21 -0
- package/dist/utils/prepare.d.mts.map +1 -0
- package/dist/utils/prepare.mjs +44 -0
- package/dist/utils/prepare.mjs.map +1 -0
- package/dist/utils/utils.cjs +3 -8
- package/dist/utils/utils.cjs.map +1 -1
- package/dist/utils/utils.d.cts.map +1 -1
- package/dist/utils/utils.d.mts.map +1 -1
- package/dist/utils/utils.mjs +3 -8
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/validation.cjs +91 -31
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts +13 -5
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts +13 -5
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs +92 -32
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +9 -9
- package/dist/utils/resimulate.cjs.map +0 -1
- package/dist/utils/resimulate.d.cts.map +0 -1
- package/dist/utils/resimulate.d.mts.map +0 -1
- package/dist/utils/resimulate.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [46.0.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Adds ability of re-simulating transaction depending on the `isActive` property on `transactionMeta` ([#5189](https://github.com/MetaMask/core/pull/5189))
|
|
15
|
+
- `isActive` property is expected to set by client.
|
|
16
|
+
- Re-simulation of transactions will occur every 3 seconds if `isActive` is `true`.
|
|
17
|
+
- Adds `setTransactionActive` function to update the `isActive` property on `transactionMeta`. ([#5189](https://github.com/MetaMask/core/pull/5189))
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^23.0.0` to `^24.0.0` ([#5318](https://github.com/MetaMask/core/pull/5318))
|
|
22
|
+
|
|
23
|
+
## [45.1.0]
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Add support for EIP-7702 / type 4 transactions ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
28
|
+
- Add `setCode` to `TransactionEnvelopeType`.
|
|
29
|
+
- Add `authorizationList` to `TransactionParams`.
|
|
30
|
+
- Export `Authorization` and `AuthorizationList` types.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- The TransactionController messenger must now allow the `KeyringController:signAuthorization` action ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
35
|
+
- Bump `@metamask/base-controller` from `^7.1.1` to `^8.0.0` ([#5305](https://github.com/MetaMask/core/pull/5305))
|
|
36
|
+
- Bump `ethereumjs/tx` from `^4.2.0` to `^5.4.0` ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
37
|
+
- Bump `ethereumjs/common` from `^3.2.0` to `^4.5.0` ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
38
|
+
|
|
10
39
|
## [45.0.0]
|
|
11
40
|
|
|
12
41
|
### Changed
|
|
@@ -1261,7 +1290,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1261
1290
|
|
|
1262
1291
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
1263
1292
|
|
|
1264
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@
|
|
1293
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@46.0.0...HEAD
|
|
1294
|
+
[46.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.1.0...@metamask/transaction-controller@46.0.0
|
|
1295
|
+
[45.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...@metamask/transaction-controller@45.1.0
|
|
1265
1296
|
[45.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.1.0...@metamask/transaction-controller@45.0.0
|
|
1266
1297
|
[44.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.0.0...@metamask/transaction-controller@44.1.0
|
|
1267
1298
|
[44.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@43.0.0...@metamask/transaction-controller@44.0.0
|
|
@@ -13,12 +13,9 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionChainIds, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _TransactionController_getChainId, _TransactionController_getNetworkClientId, _TransactionController_getEthQuery, _TransactionController_getProvider, _TransactionController_createNonceTracker, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking,
|
|
16
|
+
var _TransactionController_instances, _TransactionController_internalEvents, _TransactionController_methodDataHelper, _TransactionController_incomingTransactionChainIds, _TransactionController_incomingTransactionHelper, _TransactionController_incomingTransactionOptions, _TransactionController_pendingTransactionOptions, _TransactionController_trace, _TransactionController_transactionHistoryLimit, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_testGasFeeFlows, _TransactionController_multichainTrackingHelper, _TransactionController_retryTransaction, _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_updateSubmitHistory;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE =
|
|
19
|
-
const common_1 = require("@ethereumjs/common");
|
|
20
|
-
const tx_1 = require("@ethereumjs/tx");
|
|
21
|
-
const util_1 = require("@ethereumjs/util");
|
|
18
|
+
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
|
|
22
19
|
const base_controller_1 = require("@metamask/base-controller");
|
|
23
20
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
24
21
|
const eth_query_1 = __importDefault(require("@metamask/eth-query"));
|
|
@@ -44,8 +41,10 @@ const IncomingTransactionHelper_1 = require("./helpers/IncomingTransactionHelper
|
|
|
44
41
|
const MethodDataHelper_1 = require("./helpers/MethodDataHelper.cjs");
|
|
45
42
|
const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.cjs");
|
|
46
43
|
const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
|
|
44
|
+
const ResimulateHelper_1 = require("./helpers/ResimulateHelper.cjs");
|
|
47
45
|
const logger_1 = require("./logger.cjs");
|
|
48
46
|
const types_1 = require("./types.cjs");
|
|
47
|
+
const eip7702_1 = require("./utils/eip7702.cjs");
|
|
49
48
|
const external_transactions_1 = require("./utils/external-transactions.cjs");
|
|
50
49
|
const gas_1 = require("./utils/gas.cjs");
|
|
51
50
|
const gas_fees_1 = require("./utils/gas-fees.cjs");
|
|
@@ -53,7 +52,7 @@ const gas_flow_1 = require("./utils/gas-flow.cjs");
|
|
|
53
52
|
const history_1 = require("./utils/history.cjs");
|
|
54
53
|
const layer1_gas_fee_flow_1 = require("./utils/layer1-gas-fee-flow.cjs");
|
|
55
54
|
const nonce_1 = require("./utils/nonce.cjs");
|
|
56
|
-
const
|
|
55
|
+
const prepare_1 = require("./utils/prepare.cjs");
|
|
57
56
|
const retry_1 = require("./utils/retry.cjs");
|
|
58
57
|
const simulation_1 = require("./utils/simulation.cjs");
|
|
59
58
|
const swaps_1 = require("./utils/swaps.cjs");
|
|
@@ -82,7 +81,6 @@ const metadata = {
|
|
|
82
81
|
anonymous: false,
|
|
83
82
|
},
|
|
84
83
|
};
|
|
85
|
-
exports.HARDFORK = common_1.Hardfork.London;
|
|
86
84
|
const SUBMIT_HISTORY_LIMIT = 100;
|
|
87
85
|
/**
|
|
88
86
|
* Multiplier used to determine a transaction's increased gas fee during cancellation
|
|
@@ -304,6 +302,13 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
304
302
|
// when transactionsController state changes
|
|
305
303
|
// check for pending transactions and start polling if there are any
|
|
306
304
|
this.messagingSystem.subscribe('TransactionController:stateChange', __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
|
|
305
|
+
new ResimulateHelper_1.ResimulateHelper({
|
|
306
|
+
simulateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).bind(this),
|
|
307
|
+
onTransactionsUpdate: (listener) => {
|
|
308
|
+
this.messagingSystem.subscribe('TransactionController:stateChange', listener, (controllerState) => controllerState.transactions);
|
|
309
|
+
},
|
|
310
|
+
getTransactions: () => this.state.transactions,
|
|
311
|
+
});
|
|
307
312
|
this.onBootCleanup();
|
|
308
313
|
__classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
|
|
309
314
|
}
|
|
@@ -352,11 +357,19 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
352
357
|
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
353
358
|
throw new Error(`Network client not found - ${networkClientId}`);
|
|
354
359
|
}
|
|
360
|
+
const permittedAddresses = origin === undefined
|
|
361
|
+
? undefined
|
|
362
|
+
: await this.getPermittedAccounts?.(origin);
|
|
363
|
+
const selectedAddress = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address;
|
|
364
|
+
await (0, validation_1.validateTransactionOrigin)({
|
|
365
|
+
from: txParams.from,
|
|
366
|
+
origin,
|
|
367
|
+
permittedAddresses,
|
|
368
|
+
selectedAddress,
|
|
369
|
+
txParams,
|
|
370
|
+
});
|
|
355
371
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
|
|
356
372
|
(0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
|
|
357
|
-
if (origin && this.getPermittedAccounts) {
|
|
358
|
-
await (0, validation_1.validateTransactionOrigin)(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
|
|
359
|
-
}
|
|
360
373
|
const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
|
|
361
374
|
const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
|
|
362
375
|
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
@@ -789,6 +802,27 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
789
802
|
this.updateTransaction(updatedTransaction, `Update Editable Params for ${txId}`);
|
|
790
803
|
return this.getTransaction(txId);
|
|
791
804
|
}
|
|
805
|
+
/**
|
|
806
|
+
* Update the isActive state of a transaction.
|
|
807
|
+
*
|
|
808
|
+
* @param transactionId - The ID of the transaction to update.
|
|
809
|
+
* @param isActive - The active state.
|
|
810
|
+
*/
|
|
811
|
+
setTransactionActive(transactionId, isActive) {
|
|
812
|
+
const transactionMeta = this.getTransaction(transactionId);
|
|
813
|
+
if (!transactionMeta) {
|
|
814
|
+
throw new Error(`Transaction with id ${transactionId} not found`);
|
|
815
|
+
}
|
|
816
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
817
|
+
transactionId,
|
|
818
|
+
note: 'TransactionController#setTransactionActive - Transaction isActive updated',
|
|
819
|
+
skipHistory: true,
|
|
820
|
+
skipValidation: true,
|
|
821
|
+
skipResimulateCheck: true,
|
|
822
|
+
}, (updatedTransactionMeta) => {
|
|
823
|
+
updatedTransactionMeta.isActive = isActive;
|
|
824
|
+
});
|
|
825
|
+
}
|
|
792
826
|
/**
|
|
793
827
|
* Signs and returns the raw transaction data for provided transaction params list.
|
|
794
828
|
*
|
|
@@ -806,12 +840,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
806
840
|
}
|
|
807
841
|
const initialTx = listOfTxParams[0];
|
|
808
842
|
const { chainId } = initialTx;
|
|
809
|
-
const common = this.getCommonConfiguration(chainId);
|
|
810
843
|
const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
|
|
811
|
-
const initialTxAsEthTx =
|
|
812
|
-
|
|
813
|
-
});
|
|
814
|
-
const initialTxAsSerializedHex = (0, util_1.bufferToHex)(initialTxAsEthTx.serialize());
|
|
844
|
+
const initialTxAsEthTx = (0, prepare_1.prepareTransaction)(chainId, initialTx);
|
|
845
|
+
const initialTxAsSerializedHex = (0, prepare_1.serializeTransaction)(initialTxAsEthTx);
|
|
815
846
|
if (this.approvingTransactionIds.has(initialTxAsSerializedHex)) {
|
|
816
847
|
return '';
|
|
817
848
|
}
|
|
@@ -1025,10 +1056,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1025
1056
|
chainId,
|
|
1026
1057
|
};
|
|
1027
1058
|
const { from } = updatedTransactionParams;
|
|
1028
|
-
const
|
|
1029
|
-
const unsignedTransaction = tx_1.TransactionFactory.fromTxData(updatedTransactionParams, { common });
|
|
1059
|
+
const unsignedTransaction = (0, prepare_1.prepareTransaction)(chainId, updatedTransactionParams);
|
|
1030
1060
|
const signedTransaction = await this.sign(unsignedTransaction, from);
|
|
1031
|
-
const rawTransaction = (0,
|
|
1061
|
+
const rawTransaction = (0, prepare_1.serializeTransaction)(signedTransaction);
|
|
1032
1062
|
return rawTransaction;
|
|
1033
1063
|
}
|
|
1034
1064
|
/**
|
|
@@ -1043,6 +1073,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1043
1073
|
/**
|
|
1044
1074
|
* Stop the signing process for a specific transaction.
|
|
1045
1075
|
* Throws an error causing the transaction status to be set to failed.
|
|
1076
|
+
*
|
|
1046
1077
|
* @param transactionId - The ID of the transaction to stop signing.
|
|
1047
1078
|
*/
|
|
1048
1079
|
abortTransactionSigning(transactionId) {
|
|
@@ -1209,17 +1240,15 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1209
1240
|
transactionId,
|
|
1210
1241
|
note: 'TransactionController#approveTransaction - Transaction approved',
|
|
1211
1242
|
}, (draftTxMeta) => {
|
|
1212
|
-
const {
|
|
1243
|
+
const { chainId, txParams } = draftTxMeta;
|
|
1244
|
+
const { gas, type } = txParams;
|
|
1213
1245
|
draftTxMeta.status = types_1.TransactionStatus.approved;
|
|
1214
|
-
draftTxMeta.txParams =
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
type: types_1.TransactionEnvelopeType.feeMarket,
|
|
1221
|
-
}),
|
|
1222
|
-
};
|
|
1246
|
+
draftTxMeta.txParams.chainId = chainId;
|
|
1247
|
+
draftTxMeta.txParams.gasLimit = gas;
|
|
1248
|
+
draftTxMeta.txParams.nonce = nonce;
|
|
1249
|
+
if (!type && (0, utils_2.isEIP1559Transaction)(txParams)) {
|
|
1250
|
+
draftTxMeta.txParams.type = types_1.TransactionEnvelopeType.feeMarket;
|
|
1251
|
+
}
|
|
1223
1252
|
});
|
|
1224
1253
|
this.onTransactionStatusChange(transactionMeta);
|
|
1225
1254
|
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta, transactionMeta.txParams));
|
|
@@ -1313,10 +1342,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1313
1342
|
status: types_1.TransactionStatus.rejected,
|
|
1314
1343
|
};
|
|
1315
1344
|
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1316
|
-
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(
|
|
1317
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
1318
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
1319
|
-
`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1345
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1320
1346
|
this.messagingSystem.publish(`${controllerName}:transactionRejected`, {
|
|
1321
1347
|
transactionMeta: updatedTransactionMeta,
|
|
1322
1348
|
actionId,
|
|
@@ -1344,8 +1370,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1344
1370
|
.filter((tx) => {
|
|
1345
1371
|
const { chainId, status, txParams, time } = tx;
|
|
1346
1372
|
if (txParams) {
|
|
1347
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
1348
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
1349
1373
|
const key = `${String(txParams.nonce)}-${(0, controller_utils_1.convertHexToDecimal)(chainId)}-${new Date(time).toDateString()}`;
|
|
1350
1374
|
if (nonceNetworkSet.has(key)) {
|
|
1351
1375
|
return true;
|
|
@@ -1426,29 +1450,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1426
1450
|
const isCompleted = this.isLocalFinalState(transaction.status);
|
|
1427
1451
|
return { meta: transaction, isCompleted };
|
|
1428
1452
|
}
|
|
1429
|
-
prepareUnsignedEthTx(chainId, txParams) {
|
|
1430
|
-
return tx_1.TransactionFactory.fromTxData(txParams, {
|
|
1431
|
-
freeze: false,
|
|
1432
|
-
common: this.getCommonConfiguration(chainId),
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
/**
|
|
1436
|
-
* `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for
|
|
1437
|
-
* specifying which chain, network, hardfork and EIPs to support for
|
|
1438
|
-
* a transaction. By referencing this configuration, and analyzing the fields
|
|
1439
|
-
* specified in txParams, @ethereumjs/tx is able to determine which EIP-2718
|
|
1440
|
-
* transaction type to use.
|
|
1441
|
-
*
|
|
1442
|
-
* @param chainId - The chainId to use for the configuration.
|
|
1443
|
-
* @returns common configuration object
|
|
1444
|
-
*/
|
|
1445
|
-
getCommonConfiguration(chainId) {
|
|
1446
|
-
const customChainParams = {
|
|
1447
|
-
chainId: parseInt(chainId, 16),
|
|
1448
|
-
defaultHardfork: exports.HARDFORK,
|
|
1449
|
-
};
|
|
1450
|
-
return common_1.Common.custom(customChainParams);
|
|
1451
|
-
}
|
|
1452
1453
|
onIncomingTransactions(transactions) {
|
|
1453
1454
|
if (!transactions.length) {
|
|
1454
1455
|
return;
|
|
@@ -1619,10 +1620,17 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1619
1620
|
}
|
|
1620
1621
|
async signTransaction(transactionMeta, txParams) {
|
|
1621
1622
|
(0, logger_1.projectLogger)('Signing transaction', txParams);
|
|
1622
|
-
const
|
|
1623
|
+
const { authorizationList, from } = txParams;
|
|
1624
|
+
const finalTxParams = { ...txParams };
|
|
1625
|
+
finalTxParams.authorizationList = await (0, eip7702_1.signAuthorizationList)({
|
|
1626
|
+
authorizationList,
|
|
1627
|
+
messenger: this.messagingSystem,
|
|
1628
|
+
transactionMeta,
|
|
1629
|
+
});
|
|
1630
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, finalTxParams);
|
|
1623
1631
|
this.approvingTransactionIds.add(transactionMeta.id);
|
|
1624
1632
|
const signedTx = await new Promise((resolve, reject) => {
|
|
1625
|
-
this.sign?.(unsignedEthTx,
|
|
1633
|
+
this.sign?.(unsignedEthTx, from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
|
|
1626
1634
|
this.signAbortCallbacks.set(transactionMeta.id, () => reject(new Error('Signing aborted by user')));
|
|
1627
1635
|
});
|
|
1628
1636
|
this.signAbortCallbacks.delete(transactionMeta.id);
|
|
@@ -1642,7 +1650,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1642
1650
|
};
|
|
1643
1651
|
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
1644
1652
|
this.onTransactionStatusChange(transactionMetaWithRsv);
|
|
1645
|
-
const rawTx = (0,
|
|
1653
|
+
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1646
1654
|
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
1647
1655
|
rawTx,
|
|
1648
1656
|
});
|
|
@@ -1738,10 +1746,10 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1738
1746
|
}
|
|
1739
1747
|
const newTxParams = (0, retry_1.getTransactionParamsWithIncreasedGasFee)(transactionMeta.txParams, rate, gasValues);
|
|
1740
1748
|
prepareTransactionParams?.(newTxParams);
|
|
1741
|
-
const unsignedEthTx =
|
|
1749
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, newTxParams);
|
|
1742
1750
|
const signedTx = await this.sign(unsignedEthTx, transactionMeta.txParams.from);
|
|
1743
1751
|
const transactionMetaWithRsv = this.updateTransactionMetaRSV(transactionMeta, signedTx);
|
|
1744
|
-
const rawTx = (0,
|
|
1752
|
+
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1745
1753
|
const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
|
|
1746
1754
|
const oldFee = newTxParams.maxFeePerGas
|
|
1747
1755
|
? transactionMetaWithRsv.txParams.maxFeePerGas
|
|
@@ -1832,9 +1840,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1832
1840
|
return pendingTransactionTracker;
|
|
1833
1841
|
}, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
|
|
1834
1842
|
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
|
|
1835
|
-
}, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1836
|
-
incomingTransactionHelper.hub.removeAllListeners('transactions');
|
|
1837
|
-
incomingTransactionHelper.hub.removeAllListeners('updated-last-fetched-timestamp');
|
|
1838
1843
|
}, _TransactionController_addIncomingTransactionHelperListeners = function _TransactionController_addIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1839
1844
|
incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
|
|
1840
1845
|
}, _TransactionController_removePendingTransactionTrackerListeners = function _TransactionController_removePendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
@@ -1870,7 +1875,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1870
1875
|
(0, validation_1.validateTxParams)(transactionMeta.txParams);
|
|
1871
1876
|
}
|
|
1872
1877
|
if (!skipResimulateCheck && __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
|
|
1873
|
-
resimulateResponse = (0,
|
|
1878
|
+
resimulateResponse = (0, ResimulateHelper_1.shouldResimulate)(originalTransactionMeta, transactionMeta);
|
|
1874
1879
|
}
|
|
1875
1880
|
const shouldSkipHistory = this.isHistoryDisabled || skipHistory;
|
|
1876
1881
|
if (!shouldSkipHistory) {
|
|
@@ -1952,7 +1957,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1952
1957
|
}));
|
|
1953
1958
|
if (blockTime &&
|
|
1954
1959
|
prevSimulationData &&
|
|
1955
|
-
(0,
|
|
1960
|
+
(0, ResimulateHelper_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
|
|
1956
1961
|
simulationData = {
|
|
1957
1962
|
...simulationData,
|
|
1958
1963
|
isUpdatedAfterSecurityCheck: true,
|