@metamask-previews/transaction-controller 45.0.0-preview-1adbaffc → 45.1.0-preview-ee98fad1
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 +39 -1
- package/dist/TransactionController.cjs +85 -67
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +22 -17
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +22 -17
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +84 -66
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/abi/IERC7821.cjs +23 -0
- package/dist/abi/IERC7821.cjs.map +1 -0
- package/dist/abi/IERC7821.d.cts +16 -0
- package/dist/abi/IERC7821.d.cts.map +1 -0
- package/dist/abi/IERC7821.d.mts +16 -0
- package/dist/abi/IERC7821.d.mts.map +1 -0
- package/dist/abi/IERC7821.mjs +20 -0
- package/dist/abi/IERC7821.mjs.map +1 -0
- 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/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 +11 -37
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +98 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +98 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +11 -37
- package/dist/types.mjs.map +1 -1
- package/dist/utils/batch.cjs +84 -0
- package/dist/utils/batch.cjs.map +1 -0
- package/dist/utils/batch.d.cts +32 -0
- package/dist/utils/batch.d.cts.map +1 -0
- package/dist/utils/batch.d.mts +32 -0
- package/dist/utils/batch.d.mts.map +1 -0
- package/dist/utils/batch.mjs +79 -0
- package/dist/utils/batch.mjs.map +1 -0
- package/dist/utils/eip7702.cjs +160 -0
- package/dist/utils/eip7702.cjs.map +1 -0
- package/dist/utils/eip7702.d.cts +63 -0
- package/dist/utils/eip7702.d.cts.map +1 -0
- package/dist/utils/eip7702.d.mts +63 -0
- package/dist/utils/eip7702.d.mts.map +1 -0
- package/dist/utils/eip7702.mjs +153 -0
- package/dist/utils/eip7702.mjs.map +1 -0
- package/dist/utils/feature-flags.cjs +53 -0
- package/dist/utils/feature-flags.cjs.map +1 -0
- package/dist/utils/feature-flags.d.cts +34 -0
- package/dist/utils/feature-flags.d.cts.map +1 -0
- package/dist/utils/feature-flags.d.mts +34 -0
- package/dist/utils/feature-flags.d.mts.map +1 -0
- package/dist/utils/feature-flags.mjs +47 -0
- package/dist/utils/feature-flags.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 +102 -31
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts +18 -6
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts +18 -6
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs +103 -32
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +11 -9
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Support atomic batch transactions ([#5306](https://github.com/MetaMask/core/pull/5306))
|
|
13
|
+
- Add methods:
|
|
14
|
+
- `addTransactionBatch`
|
|
15
|
+
- `isAtomicBatchSupported`
|
|
16
|
+
- Add `batch` to `TransactionType`.
|
|
17
|
+
- Add `nestedTransactions` to `TransactionMeta`.
|
|
18
|
+
- Add new types:
|
|
19
|
+
- `BatchTransactionParams`
|
|
20
|
+
- `TransactionBatchSingleRequest`
|
|
21
|
+
- `TransactionBatchRequest`
|
|
22
|
+
- `TransactionBatchResult`
|
|
23
|
+
- Add dependency on `@metamask/remote-feature-flag-controller:^1.4.0`.
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- **BREAKING:** Support atomic batch transactions ([#5306](https://github.com/MetaMask/core/pull/5306))
|
|
28
|
+
- Require `AccountsController:getState` action permission in messenger.
|
|
29
|
+
- Require `RemoteFeatureFlagController:getState` action permission in messenger.
|
|
30
|
+
|
|
31
|
+
## [45.1.0]
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- Add support for EIP-7702 / type 4 transactions ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
36
|
+
- Add `setCode` to `TransactionEnvelopeType`.
|
|
37
|
+
- Add `authorizationList` to `TransactionParams`.
|
|
38
|
+
- Export `Authorization` and `AuthorizationList` types.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- The TransactionController messenger must now allow the `KeyringController:signAuthorization` action ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
43
|
+
- Bump `@metamask/base-controller` from `^7.1.1` to `^8.0.0` ([#5305](https://github.com/MetaMask/core/pull/5305))
|
|
44
|
+
- Bump `ethereumjs/tx` from `^4.2.0` to `^5.4.0` ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
45
|
+
- Bump `ethereumjs/common` from `^3.2.0` to `^4.5.0` ([#5285](https://github.com/MetaMask/core/pull/5285))
|
|
46
|
+
|
|
10
47
|
## [45.0.0]
|
|
11
48
|
|
|
12
49
|
### Changed
|
|
@@ -1261,7 +1298,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1261
1298
|
|
|
1262
1299
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
1263
1300
|
|
|
1264
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.
|
|
1301
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.1.0...HEAD
|
|
1302
|
+
[45.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...@metamask/transaction-controller@45.1.0
|
|
1265
1303
|
[45.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.1.0...@metamask/transaction-controller@45.0.0
|
|
1266
1304
|
[44.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.0.0...@metamask/transaction-controller@44.1.0
|
|
1267
1305
|
[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_getInternalAccounts, _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"));
|
|
@@ -46,6 +43,8 @@ const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.c
|
|
|
46
43
|
const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
|
|
47
44
|
const logger_1 = require("./logger.cjs");
|
|
48
45
|
const types_1 = require("./types.cjs");
|
|
46
|
+
const batch_1 = require("./utils/batch.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,6 +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");
|
|
55
|
+
const prepare_1 = require("./utils/prepare.cjs");
|
|
56
56
|
const resimulate_1 = require("./utils/resimulate.cjs");
|
|
57
57
|
const retry_1 = require("./utils/retry.cjs");
|
|
58
58
|
const simulation_1 = require("./utils/simulation.cjs");
|
|
@@ -82,7 +82,6 @@ const metadata = {
|
|
|
82
82
|
anonymous: false,
|
|
83
83
|
},
|
|
84
84
|
};
|
|
85
|
-
exports.HARDFORK = common_1.Hardfork.London;
|
|
86
85
|
const SUBMIT_HISTORY_LIMIT = 100;
|
|
87
86
|
/**
|
|
88
87
|
* Multiplier used to determine a transaction's increased gas fee during cancellation
|
|
@@ -323,6 +322,34 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
323
322
|
async handleMethodData(fourBytePrefix, networkClientId) {
|
|
324
323
|
return __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").lookup(fourBytePrefix, networkClientId);
|
|
325
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Add a batch of transactions to be submitted after approval.
|
|
327
|
+
*
|
|
328
|
+
* @param request - Request object containing the transactions to add.
|
|
329
|
+
* @returns Result object containing the generated batch ID.
|
|
330
|
+
*/
|
|
331
|
+
async addTransactionBatch(request) {
|
|
332
|
+
return await (0, batch_1.addTransactionBatch)({
|
|
333
|
+
addTransaction: this.addTransaction.bind(this),
|
|
334
|
+
getChainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).bind(this),
|
|
335
|
+
getEthQuery: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId }),
|
|
336
|
+
messenger: this.messagingSystem,
|
|
337
|
+
request,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Determine which chains support atomic batch transactions with the given account address.
|
|
342
|
+
*
|
|
343
|
+
* @param address - The address of the account to check.
|
|
344
|
+
* @returns The supported chain IDs.
|
|
345
|
+
*/
|
|
346
|
+
async isAtomicBatchSupported(address) {
|
|
347
|
+
return (0, batch_1.isAtomicBatchSupported)({
|
|
348
|
+
address,
|
|
349
|
+
getEthQuery: (chainId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { chainId }),
|
|
350
|
+
messenger: this.messagingSystem,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
326
353
|
/**
|
|
327
354
|
* Add a new unapproved transaction to state. Parameters will be validated, a
|
|
328
355
|
* unique transaction id will be generated, and gas and gasPrice will be calculated
|
|
@@ -333,6 +360,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
333
360
|
* @param options.actionId - Unique ID to prevent duplicate requests.
|
|
334
361
|
* @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
|
|
335
362
|
* @param options.method - RPC method that requested the transaction.
|
|
363
|
+
* @param options.nestedTransactions - Params for any nested transactions encoded in the data.
|
|
336
364
|
* @param options.origin - The origin of the transaction request, such as a dApp hostname.
|
|
337
365
|
* @param options.requireApproval - Whether the transaction requires approval by the user, defaults to true unless explicitly disabled.
|
|
338
366
|
* @param options.securityAlertResponse - Response from security validator.
|
|
@@ -347,16 +375,27 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
347
375
|
*/
|
|
348
376
|
async addTransaction(txParams, options) {
|
|
349
377
|
(0, logger_1.projectLogger)('Adding transaction', txParams, options);
|
|
350
|
-
const { actionId, deviceConfirmedOn, method, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
|
|
378
|
+
const { actionId, deviceConfirmedOn, method, nestedTransactions, networkClientId, origin, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
|
|
351
379
|
txParams = (0, utils_2.normalizeTransactionParams)(txParams);
|
|
352
380
|
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
353
381
|
throw new Error(`Network client not found - ${networkClientId}`);
|
|
354
382
|
}
|
|
383
|
+
const permittedAddresses = origin === undefined
|
|
384
|
+
? undefined
|
|
385
|
+
: await this.getPermittedAccounts?.(origin);
|
|
386
|
+
const selectedAddress = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address;
|
|
387
|
+
const internalAccounts = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).call(this);
|
|
388
|
+
await (0, validation_1.validateTransactionOrigin)({
|
|
389
|
+
from: txParams.from,
|
|
390
|
+
internalAccounts,
|
|
391
|
+
origin,
|
|
392
|
+
permittedAddresses,
|
|
393
|
+
selectedAddress,
|
|
394
|
+
txParams,
|
|
395
|
+
type,
|
|
396
|
+
});
|
|
355
397
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
|
|
356
398
|
(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
399
|
const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
|
|
361
400
|
const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
|
|
362
401
|
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
@@ -375,6 +414,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
375
414
|
deviceConfirmedOn,
|
|
376
415
|
id: (0, uuid_1.v1)(),
|
|
377
416
|
isFirstTimeInteraction: undefined,
|
|
417
|
+
nestedTransactions,
|
|
378
418
|
networkClientId,
|
|
379
419
|
origin,
|
|
380
420
|
securityAlertResponse,
|
|
@@ -806,12 +846,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
806
846
|
}
|
|
807
847
|
const initialTx = listOfTxParams[0];
|
|
808
848
|
const { chainId } = initialTx;
|
|
809
|
-
const common = this.getCommonConfiguration(chainId);
|
|
810
849
|
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());
|
|
850
|
+
const initialTxAsEthTx = (0, prepare_1.prepareTransaction)(chainId, initialTx);
|
|
851
|
+
const initialTxAsSerializedHex = (0, prepare_1.serializeTransaction)(initialTxAsEthTx);
|
|
815
852
|
if (this.approvingTransactionIds.has(initialTxAsSerializedHex)) {
|
|
816
853
|
return '';
|
|
817
854
|
}
|
|
@@ -1025,10 +1062,9 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1025
1062
|
chainId,
|
|
1026
1063
|
};
|
|
1027
1064
|
const { from } = updatedTransactionParams;
|
|
1028
|
-
const
|
|
1029
|
-
const unsignedTransaction = tx_1.TransactionFactory.fromTxData(updatedTransactionParams, { common });
|
|
1065
|
+
const unsignedTransaction = (0, prepare_1.prepareTransaction)(chainId, updatedTransactionParams);
|
|
1030
1066
|
const signedTransaction = await this.sign(unsignedTransaction, from);
|
|
1031
|
-
const rawTransaction = (0,
|
|
1067
|
+
const rawTransaction = (0, prepare_1.serializeTransaction)(signedTransaction);
|
|
1032
1068
|
return rawTransaction;
|
|
1033
1069
|
}
|
|
1034
1070
|
/**
|
|
@@ -1043,6 +1079,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1043
1079
|
/**
|
|
1044
1080
|
* Stop the signing process for a specific transaction.
|
|
1045
1081
|
* Throws an error causing the transaction status to be set to failed.
|
|
1082
|
+
*
|
|
1046
1083
|
* @param transactionId - The ID of the transaction to stop signing.
|
|
1047
1084
|
*/
|
|
1048
1085
|
abortTransactionSigning(transactionId) {
|
|
@@ -1209,20 +1246,18 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1209
1246
|
transactionId,
|
|
1210
1247
|
note: 'TransactionController#approveTransaction - Transaction approved',
|
|
1211
1248
|
}, (draftTxMeta) => {
|
|
1212
|
-
const {
|
|
1249
|
+
const { chainId, txParams } = draftTxMeta;
|
|
1250
|
+
const { gas, type } = txParams;
|
|
1213
1251
|
draftTxMeta.status = types_1.TransactionStatus.approved;
|
|
1214
|
-
draftTxMeta.txParams =
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
type: types_1.TransactionEnvelopeType.feeMarket,
|
|
1221
|
-
}),
|
|
1222
|
-
};
|
|
1252
|
+
draftTxMeta.txParams.chainId = chainId;
|
|
1253
|
+
draftTxMeta.txParams.gasLimit = gas;
|
|
1254
|
+
draftTxMeta.txParams.nonce = nonce;
|
|
1255
|
+
if (!type && (0, utils_2.isEIP1559Transaction)(txParams)) {
|
|
1256
|
+
draftTxMeta.txParams.type = types_1.TransactionEnvelopeType.feeMarket;
|
|
1257
|
+
}
|
|
1223
1258
|
});
|
|
1224
1259
|
this.onTransactionStatusChange(transactionMeta);
|
|
1225
|
-
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta
|
|
1260
|
+
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta));
|
|
1226
1261
|
if (!this.beforePublish(transactionMeta)) {
|
|
1227
1262
|
(0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1228
1263
|
this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
@@ -1313,10 +1348,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1313
1348
|
status: types_1.TransactionStatus.rejected,
|
|
1314
1349
|
};
|
|
1315
1350
|
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);
|
|
1351
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1320
1352
|
this.messagingSystem.publish(`${controllerName}:transactionRejected`, {
|
|
1321
1353
|
transactionMeta: updatedTransactionMeta,
|
|
1322
1354
|
actionId,
|
|
@@ -1344,8 +1376,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1344
1376
|
.filter((tx) => {
|
|
1345
1377
|
const { chainId, status, txParams, time } = tx;
|
|
1346
1378
|
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
1379
|
const key = `${String(txParams.nonce)}-${(0, controller_utils_1.convertHexToDecimal)(chainId)}-${new Date(time).toDateString()}`;
|
|
1350
1380
|
if (nonceNetworkSet.has(key)) {
|
|
1351
1381
|
return true;
|
|
@@ -1426,29 +1456,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1426
1456
|
const isCompleted = this.isLocalFinalState(transaction.status);
|
|
1427
1457
|
return { meta: transaction, isCompleted };
|
|
1428
1458
|
}
|
|
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
1459
|
onIncomingTransactions(transactions) {
|
|
1453
1460
|
if (!transactions.length) {
|
|
1454
1461
|
return;
|
|
@@ -1617,12 +1624,20 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1617
1624
|
const currentAccountIsEIP1559Compatible = await this.getCurrentAccountEIP1559Compatibility();
|
|
1618
1625
|
return (currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible);
|
|
1619
1626
|
}
|
|
1620
|
-
async signTransaction(transactionMeta
|
|
1627
|
+
async signTransaction(transactionMeta) {
|
|
1628
|
+
const { txParams } = transactionMeta;
|
|
1621
1629
|
(0, logger_1.projectLogger)('Signing transaction', txParams);
|
|
1622
|
-
const
|
|
1630
|
+
const { authorizationList, from } = txParams;
|
|
1631
|
+
const finalTxParams = { ...txParams };
|
|
1632
|
+
finalTxParams.authorizationList = await (0, eip7702_1.signAuthorizationList)({
|
|
1633
|
+
authorizationList,
|
|
1634
|
+
messenger: this.messagingSystem,
|
|
1635
|
+
transactionMeta,
|
|
1636
|
+
});
|
|
1637
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, finalTxParams);
|
|
1623
1638
|
this.approvingTransactionIds.add(transactionMeta.id);
|
|
1624
1639
|
const signedTx = await new Promise((resolve, reject) => {
|
|
1625
|
-
this.sign?.(unsignedEthTx,
|
|
1640
|
+
this.sign?.(unsignedEthTx, from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
|
|
1626
1641
|
this.signAbortCallbacks.set(transactionMeta.id, () => reject(new Error('Signing aborted by user')));
|
|
1627
1642
|
});
|
|
1628
1643
|
this.signAbortCallbacks.delete(transactionMeta.id);
|
|
@@ -1639,10 +1654,11 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1639
1654
|
const transactionMetaWithRsv = {
|
|
1640
1655
|
...this.updateTransactionMetaRSV(transactionMetaFromHook, signedTx),
|
|
1641
1656
|
status: types_1.TransactionStatus.signed,
|
|
1657
|
+
txParams: finalTxParams,
|
|
1642
1658
|
};
|
|
1643
1659
|
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
1644
1660
|
this.onTransactionStatusChange(transactionMetaWithRsv);
|
|
1645
|
-
const rawTx = (0,
|
|
1661
|
+
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1646
1662
|
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
1647
1663
|
rawTx,
|
|
1648
1664
|
});
|
|
@@ -1738,10 +1754,10 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1738
1754
|
}
|
|
1739
1755
|
const newTxParams = (0, retry_1.getTransactionParamsWithIncreasedGasFee)(transactionMeta.txParams, rate, gasValues);
|
|
1740
1756
|
prepareTransactionParams?.(newTxParams);
|
|
1741
|
-
const unsignedEthTx =
|
|
1757
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, newTxParams);
|
|
1742
1758
|
const signedTx = await this.sign(unsignedEthTx, transactionMeta.txParams.from);
|
|
1743
1759
|
const transactionMetaWithRsv = this.updateTransactionMetaRSV(transactionMeta, signedTx);
|
|
1744
|
-
const rawTx = (0,
|
|
1760
|
+
const rawTx = (0, prepare_1.serializeTransaction)(signedTx);
|
|
1745
1761
|
const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
|
|
1746
1762
|
const oldFee = newTxParams.maxFeePerGas
|
|
1747
1763
|
? transactionMetaWithRsv.txParams.maxFeePerGas
|
|
@@ -1832,9 +1848,6 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1832
1848
|
return pendingTransactionTracker;
|
|
1833
1849
|
}, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
|
|
1834
1850
|
__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
1851
|
}, _TransactionController_addIncomingTransactionHelperListeners = function _TransactionController_addIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1839
1852
|
incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
|
|
1840
1853
|
}, _TransactionController_removePendingTransactionTrackerListeners = function _TransactionController_removePendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
@@ -1987,6 +2000,11 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1987
2000
|
});
|
|
1988
2001
|
}, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
|
|
1989
2002
|
return this.messagingSystem.call('AccountsController:getSelectedAccount');
|
|
2003
|
+
}, _TransactionController_getInternalAccounts = function _TransactionController_getInternalAccounts() {
|
|
2004
|
+
const state = this.messagingSystem.call('AccountsController:getState');
|
|
2005
|
+
return Object.values(state.internalAccounts?.accounts ?? {})
|
|
2006
|
+
.filter((account) => account.type === 'eip155:eoa')
|
|
2007
|
+
.map((account) => account.address);
|
|
1990
2008
|
}, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {
|
|
1991
2009
|
const { chainId, networkClientId, origin, rawTx, txParams } = transactionMeta;
|
|
1992
2010
|
const { networkConfigurationsByChainId } = this.getNetworkState();
|