@metamask-previews/transaction-controller 44.1.0-preview-2a6578b3 → 45.0.0-preview-83e41399
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 -1
- package/dist/TransactionController.cjs +90 -47
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts +27 -5
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts +27 -5
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +89 -46
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +13 -4
- 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 +13 -4
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.cjs +3 -5
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.cts +0 -1
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.mts +0 -1
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +3 -5
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
- package/dist/index.cjs +2 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +37 -6
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -55
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +1 -55
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +37 -6
- package/dist/types.mjs.map +1 -1
- package/dist/utils/utils.cjs +8 -3
- 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 +8 -3
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/validation.cjs +31 -91
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts +5 -13
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts +5 -13
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs +32 -92
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/utils/eip7702.cjs +0 -87
- package/dist/utils/eip7702.cjs.map +0 -1
- package/dist/utils/eip7702.d.cts +0 -26
- package/dist/utils/eip7702.d.cts.map +0 -1
- package/dist/utils/eip7702.d.mts +0 -26
- package/dist/utils/eip7702.d.mts.map +0 -1
- package/dist/utils/eip7702.mjs +0 -83
- package/dist/utils/eip7702.mjs.map +0 -1
- package/dist/utils/prepare.cjs +0 -49
- package/dist/utils/prepare.cjs.map +0 -1
- package/dist/utils/prepare.d.cts +0 -21
- package/dist/utils/prepare.d.cts.map +0 -1
- package/dist/utils/prepare.d.mts +0 -21
- package/dist/utils/prepare.d.mts.map +0 -1
- package/dist/utils/prepare.mjs +0 -44
- package/dist/utils/prepare.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [45.0.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^22.0.0` to `^23.0.0` ([#5292](https://github.com/MetaMask/core/pull/5292))
|
|
15
|
+
|
|
10
16
|
## [44.1.0]
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -1255,7 +1261,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1255
1261
|
|
|
1256
1262
|
All changes listed after this point were applied to this package following the monorepo conversion.
|
|
1257
1263
|
|
|
1258
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@
|
|
1264
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@45.0.0...HEAD
|
|
1265
|
+
[45.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.1.0...@metamask/transaction-controller@45.0.0
|
|
1259
1266
|
[44.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@44.0.0...@metamask/transaction-controller@44.1.0
|
|
1260
1267
|
[44.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@43.0.0...@metamask/transaction-controller@44.0.0
|
|
1261
1268
|
[43.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@42.1.0...@metamask/transaction-controller@43.0.0
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
// FIXME - remove above ignore
|
|
2
4
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
5
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
6
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
@@ -13,9 +15,12 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
13
15
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
16
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
17
|
};
|
|
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;
|
|
18
|
+
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_removeIncomingTransactionHelperListeners, _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
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
|
|
20
|
+
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = exports.HARDFORK = void 0;
|
|
21
|
+
const common_1 = require("@ethereumjs/common");
|
|
22
|
+
const tx_1 = require("@ethereumjs/tx");
|
|
23
|
+
const util_1 = require("@ethereumjs/util");
|
|
19
24
|
const base_controller_1 = require("@metamask/base-controller");
|
|
20
25
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
21
26
|
const eth_query_1 = __importDefault(require("@metamask/eth-query"));
|
|
@@ -43,7 +48,6 @@ const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.c
|
|
|
43
48
|
const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
|
|
44
49
|
const logger_1 = require("./logger.cjs");
|
|
45
50
|
const types_1 = require("./types.cjs");
|
|
46
|
-
const eip7702_1 = require("./utils/eip7702.cjs");
|
|
47
51
|
const external_transactions_1 = require("./utils/external-transactions.cjs");
|
|
48
52
|
const gas_1 = require("./utils/gas.cjs");
|
|
49
53
|
const gas_fees_1 = require("./utils/gas-fees.cjs");
|
|
@@ -51,7 +55,6 @@ const gas_flow_1 = require("./utils/gas-flow.cjs");
|
|
|
51
55
|
const history_1 = require("./utils/history.cjs");
|
|
52
56
|
const layer1_gas_fee_flow_1 = require("./utils/layer1-gas-fee-flow.cjs");
|
|
53
57
|
const nonce_1 = require("./utils/nonce.cjs");
|
|
54
|
-
const prepare_1 = require("./utils/prepare.cjs");
|
|
55
58
|
const resimulate_1 = require("./utils/resimulate.cjs");
|
|
56
59
|
const retry_1 = require("./utils/retry.cjs");
|
|
57
60
|
const simulation_1 = require("./utils/simulation.cjs");
|
|
@@ -81,6 +84,7 @@ const metadata = {
|
|
|
81
84
|
anonymous: false,
|
|
82
85
|
},
|
|
83
86
|
};
|
|
87
|
+
exports.HARDFORK = common_1.Hardfork.London;
|
|
84
88
|
const SUBMIT_HISTORY_LIMIT = 100;
|
|
85
89
|
/**
|
|
86
90
|
* Multiplier used to determine a transaction's increased gas fee during cancellation
|
|
@@ -350,19 +354,11 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
350
354
|
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
351
355
|
throw new Error(`Network client not found - ${networkClientId}`);
|
|
352
356
|
}
|
|
353
|
-
const permittedAddresses = origin === undefined
|
|
354
|
-
? undefined
|
|
355
|
-
: await this.getPermittedAccounts?.(origin);
|
|
356
|
-
const selectedAddress = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address;
|
|
357
|
-
await (0, validation_1.validateTransactionOrigin)({
|
|
358
|
-
from: txParams.from,
|
|
359
|
-
origin,
|
|
360
|
-
permittedAddresses,
|
|
361
|
-
selectedAddress,
|
|
362
|
-
txParams,
|
|
363
|
-
});
|
|
364
357
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(networkClientId);
|
|
365
358
|
(0, validation_1.validateTxParams)(txParams, isEIP1559Compatible);
|
|
359
|
+
if (origin && this.getPermittedAccounts) {
|
|
360
|
+
await (0, validation_1.validateTransactionOrigin)(await this.getPermittedAccounts(origin), __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getSelectedAccount).call(this).address, txParams.from, origin);
|
|
361
|
+
}
|
|
366
362
|
const dappSuggestedGasFees = this.generateDappSuggestedGasFees(txParams, origin);
|
|
367
363
|
const chainId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId);
|
|
368
364
|
const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
|
|
@@ -631,6 +627,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
631
627
|
this.onTransactionStatusChange(updatedTransactionMeta);
|
|
632
628
|
// Intentional given potential duration of process.
|
|
633
629
|
this.updatePostBalance(updatedTransactionMeta).catch((error) => {
|
|
630
|
+
/* istanbul ignore next */
|
|
634
631
|
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
635
632
|
throw error;
|
|
636
633
|
});
|
|
@@ -812,9 +809,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
812
809
|
}
|
|
813
810
|
const initialTx = listOfTxParams[0];
|
|
814
811
|
const { chainId } = initialTx;
|
|
812
|
+
const common = this.getCommonConfiguration(chainId);
|
|
815
813
|
const networkClientId = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNetworkClientId).call(this, { chainId });
|
|
816
|
-
const initialTxAsEthTx =
|
|
817
|
-
|
|
814
|
+
const initialTxAsEthTx = tx_1.TransactionFactory.fromTxData(initialTx, {
|
|
815
|
+
common,
|
|
816
|
+
});
|
|
817
|
+
const initialTxAsSerializedHex = (0, util_1.bufferToHex)(initialTxAsEthTx.serialize());
|
|
818
818
|
if (this.approvingTransactionIds.has(initialTxAsSerializedHex)) {
|
|
819
819
|
return '';
|
|
820
820
|
}
|
|
@@ -858,15 +858,17 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
858
858
|
* @param options.errorMessage - The error message to be assigned in case transaction status update to failed.
|
|
859
859
|
* @param options.hash - The new hash value to be assigned.
|
|
860
860
|
* @param options.status - The new status value to be assigned.
|
|
861
|
+
* @param options.gasLimit - The new gas limit value to be assigned
|
|
862
|
+
* @param options.gasPrice - The new gas price value to be assigned
|
|
863
|
+
* @param options.maxFeePerGas - The new max fee per gas value to be assigned
|
|
864
|
+
* @param options.maxPriorityFeePerGas - The new max priority fee per gas value to be assigned
|
|
865
|
+
* @param options.nonce - The new nonce value to be assigned
|
|
861
866
|
*/
|
|
862
|
-
updateCustodialTransaction(transactionId, { errorMessage, hash, status, }) {
|
|
867
|
+
updateCustodialTransaction(transactionId, { errorMessage, hash, status, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, }) {
|
|
863
868
|
const transactionMeta = this.getTransaction(transactionId);
|
|
864
869
|
if (!transactionMeta) {
|
|
865
870
|
throw new Error(`Cannot update custodial transaction as no transaction metadata found`);
|
|
866
871
|
}
|
|
867
|
-
if (!transactionMeta.custodyId) {
|
|
868
|
-
throw new Error('Transaction must be a custodian transaction');
|
|
869
|
-
}
|
|
870
872
|
if (status &&
|
|
871
873
|
![
|
|
872
874
|
types_1.TransactionStatus.submitted,
|
|
@@ -882,6 +884,22 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
882
884
|
if (updatedTransactionMeta.status === types_1.TransactionStatus.failed) {
|
|
883
885
|
updatedTransactionMeta.error = (0, utils_2.normalizeTxError)(new Error(errorMessage));
|
|
884
886
|
}
|
|
887
|
+
if (gasLimit) {
|
|
888
|
+
updatedTransactionMeta.txParams.gasLimit = gasLimit;
|
|
889
|
+
}
|
|
890
|
+
if (gasPrice) {
|
|
891
|
+
updatedTransactionMeta.txParams.gasPrice = gasPrice;
|
|
892
|
+
}
|
|
893
|
+
if (maxFeePerGas) {
|
|
894
|
+
updatedTransactionMeta.txParams.maxFeePerGas = maxFeePerGas;
|
|
895
|
+
}
|
|
896
|
+
if (maxPriorityFeePerGas) {
|
|
897
|
+
updatedTransactionMeta.txParams.maxPriorityFeePerGas =
|
|
898
|
+
maxPriorityFeePerGas;
|
|
899
|
+
}
|
|
900
|
+
if (nonce) {
|
|
901
|
+
updatedTransactionMeta.txParams.nonce = nonce;
|
|
902
|
+
}
|
|
885
903
|
this.updateTransaction(updatedTransactionMeta, `${controllerName}:updateCustodialTransaction - Custodial transaction updated`);
|
|
886
904
|
if ([types_1.TransactionStatus.submitted, types_1.TransactionStatus.failed].includes(status)) {
|
|
887
905
|
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
@@ -1028,9 +1046,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1028
1046
|
chainId,
|
|
1029
1047
|
};
|
|
1030
1048
|
const { from } = updatedTransactionParams;
|
|
1031
|
-
const
|
|
1049
|
+
const common = this.getCommonConfiguration(chainId);
|
|
1050
|
+
const unsignedTransaction = tx_1.TransactionFactory.fromTxData(updatedTransactionParams, { common });
|
|
1032
1051
|
const signedTransaction = await this.sign(unsignedTransaction, from);
|
|
1033
|
-
const rawTransaction = (0,
|
|
1052
|
+
const rawTransaction = (0, util_1.bufferToHex)(signedTransaction.serialize());
|
|
1034
1053
|
return rawTransaction;
|
|
1035
1054
|
}
|
|
1036
1055
|
/**
|
|
@@ -1045,7 +1064,6 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1045
1064
|
/**
|
|
1046
1065
|
* Stop the signing process for a specific transaction.
|
|
1047
1066
|
* Throws an error causing the transaction status to be set to failed.
|
|
1048
|
-
*
|
|
1049
1067
|
* @param transactionId - The ID of the transaction to stop signing.
|
|
1050
1068
|
*/
|
|
1051
1069
|
abortTransactionSigning(transactionId) {
|
|
@@ -1212,19 +1230,21 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1212
1230
|
transactionId,
|
|
1213
1231
|
note: 'TransactionController#approveTransaction - Transaction approved',
|
|
1214
1232
|
}, (draftTxMeta) => {
|
|
1215
|
-
const {
|
|
1216
|
-
const { gas, type } = txParams;
|
|
1233
|
+
const { txParams, chainId } = draftTxMeta;
|
|
1217
1234
|
draftTxMeta.status = types_1.TransactionStatus.approved;
|
|
1218
|
-
draftTxMeta.txParams
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1235
|
+
draftTxMeta.txParams = {
|
|
1236
|
+
...txParams,
|
|
1237
|
+
nonce,
|
|
1238
|
+
chainId,
|
|
1239
|
+
gasLimit: txParams.gas,
|
|
1240
|
+
...((0, utils_2.isEIP1559Transaction)(txParams) && {
|
|
1241
|
+
type: types_1.TransactionEnvelopeType.feeMarket,
|
|
1242
|
+
}),
|
|
1243
|
+
};
|
|
1224
1244
|
});
|
|
1225
1245
|
this.onTransactionStatusChange(transactionMeta);
|
|
1226
1246
|
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => this.signTransaction(transactionMeta, transactionMeta.txParams));
|
|
1227
|
-
if (!this.beforePublish(transactionMeta)) {
|
|
1247
|
+
if (!this.beforePublish(transactionMeta, rawTx)) {
|
|
1228
1248
|
(0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1229
1249
|
this.messagingSystem.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
1230
1250
|
return ApprovalState.SkippedViaBeforePublishHook;
|
|
@@ -1314,7 +1334,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1314
1334
|
status: types_1.TransactionStatus.rejected,
|
|
1315
1335
|
};
|
|
1316
1336
|
this.messagingSystem.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1317
|
-
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(
|
|
1337
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(
|
|
1338
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
1339
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
1340
|
+
`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1318
1341
|
this.messagingSystem.publish(`${controllerName}:transactionRejected`, {
|
|
1319
1342
|
transactionMeta: updatedTransactionMeta,
|
|
1320
1343
|
actionId,
|
|
@@ -1342,6 +1365,8 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1342
1365
|
.filter((tx) => {
|
|
1343
1366
|
const { chainId, status, txParams, time } = tx;
|
|
1344
1367
|
if (txParams) {
|
|
1368
|
+
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
1369
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
1345
1370
|
const key = `${String(txParams.nonce)}-${(0, controller_utils_1.convertHexToDecimal)(chainId)}-${new Date(time).toDateString()}`;
|
|
1346
1371
|
if (nonceNetworkSet.has(key)) {
|
|
1347
1372
|
return true;
|
|
@@ -1422,6 +1447,29 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1422
1447
|
const isCompleted = this.isLocalFinalState(transaction.status);
|
|
1423
1448
|
return { meta: transaction, isCompleted };
|
|
1424
1449
|
}
|
|
1450
|
+
prepareUnsignedEthTx(chainId, txParams) {
|
|
1451
|
+
return tx_1.TransactionFactory.fromTxData(txParams, {
|
|
1452
|
+
freeze: false,
|
|
1453
|
+
common: this.getCommonConfiguration(chainId),
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* `@ethereumjs/tx` uses `@ethereumjs/common` as a configuration tool for
|
|
1458
|
+
* specifying which chain, network, hardfork and EIPs to support for
|
|
1459
|
+
* a transaction. By referencing this configuration, and analyzing the fields
|
|
1460
|
+
* specified in txParams, @ethereumjs/tx is able to determine which EIP-2718
|
|
1461
|
+
* transaction type to use.
|
|
1462
|
+
*
|
|
1463
|
+
* @param chainId - The chainId to use for the configuration.
|
|
1464
|
+
* @returns common configuration object
|
|
1465
|
+
*/
|
|
1466
|
+
getCommonConfiguration(chainId) {
|
|
1467
|
+
const customChainParams = {
|
|
1468
|
+
chainId: parseInt(chainId, 16),
|
|
1469
|
+
defaultHardfork: exports.HARDFORK,
|
|
1470
|
+
};
|
|
1471
|
+
return common_1.Common.custom(customChainParams);
|
|
1472
|
+
}
|
|
1425
1473
|
onIncomingTransactions(transactions) {
|
|
1426
1474
|
if (!transactions.length) {
|
|
1427
1475
|
return;
|
|
@@ -1592,17 +1640,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1592
1640
|
}
|
|
1593
1641
|
async signTransaction(transactionMeta, txParams) {
|
|
1594
1642
|
(0, logger_1.projectLogger)('Signing transaction', txParams);
|
|
1595
|
-
const
|
|
1596
|
-
const finalTxParams = { ...txParams };
|
|
1597
|
-
finalTxParams.authorizationList = await (0, eip7702_1.signAuthorizationList)({
|
|
1598
|
-
authorizationList,
|
|
1599
|
-
messenger: this.messagingSystem,
|
|
1600
|
-
transactionMeta,
|
|
1601
|
-
});
|
|
1602
|
-
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, finalTxParams);
|
|
1643
|
+
const unsignedEthTx = this.prepareUnsignedEthTx(transactionMeta.chainId, txParams);
|
|
1603
1644
|
this.approvingTransactionIds.add(transactionMeta.id);
|
|
1604
1645
|
const signedTx = await new Promise((resolve, reject) => {
|
|
1605
|
-
this.sign?.(unsignedEthTx, from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
|
|
1646
|
+
this.sign?.(unsignedEthTx, txParams.from, ...this.getAdditionalSignArguments(transactionMeta)).then(resolve, reject);
|
|
1606
1647
|
this.signAbortCallbacks.set(transactionMeta.id, () => reject(new Error('Signing aborted by user')));
|
|
1607
1648
|
});
|
|
1608
1649
|
this.signAbortCallbacks.delete(transactionMeta.id);
|
|
@@ -1622,7 +1663,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1622
1663
|
};
|
|
1623
1664
|
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
1624
1665
|
this.onTransactionStatusChange(transactionMetaWithRsv);
|
|
1625
|
-
const rawTx = (0,
|
|
1666
|
+
const rawTx = (0, util_1.bufferToHex)(signedTx.serialize());
|
|
1626
1667
|
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
1627
1668
|
rawTx,
|
|
1628
1669
|
});
|
|
@@ -1718,10 +1759,10 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1718
1759
|
}
|
|
1719
1760
|
const newTxParams = (0, retry_1.getTransactionParamsWithIncreasedGasFee)(transactionMeta.txParams, rate, gasValues);
|
|
1720
1761
|
prepareTransactionParams?.(newTxParams);
|
|
1721
|
-
const unsignedEthTx =
|
|
1762
|
+
const unsignedEthTx = this.prepareUnsignedEthTx(transactionMeta.chainId, newTxParams);
|
|
1722
1763
|
const signedTx = await this.sign(unsignedEthTx, transactionMeta.txParams.from);
|
|
1723
1764
|
const transactionMetaWithRsv = this.updateTransactionMetaRSV(transactionMeta, signedTx);
|
|
1724
|
-
const rawTx = (0,
|
|
1765
|
+
const rawTx = (0, util_1.bufferToHex)(signedTx.serialize());
|
|
1725
1766
|
const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
|
|
1726
1767
|
const oldFee = newTxParams.maxFeePerGas
|
|
1727
1768
|
? transactionMetaWithRsv.txParams.maxFeePerGas
|
|
@@ -1805,13 +1846,15 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
|
|
|
1805
1846
|
}),
|
|
1806
1847
|
hooks: {
|
|
1807
1848
|
beforeCheckPendingTransaction: this.beforeCheckPendingTransaction.bind(this),
|
|
1808
|
-
beforePublish: this.beforePublish.bind(this),
|
|
1809
1849
|
},
|
|
1810
1850
|
});
|
|
1811
1851
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
|
|
1812
1852
|
return pendingTransactionTracker;
|
|
1813
1853
|
}, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
|
|
1814
1854
|
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
|
|
1855
|
+
}, _TransactionController_removeIncomingTransactionHelperListeners = function _TransactionController_removeIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1856
|
+
incomingTransactionHelper.hub.removeAllListeners('transactions');
|
|
1857
|
+
incomingTransactionHelper.hub.removeAllListeners('updated-last-fetched-timestamp');
|
|
1815
1858
|
}, _TransactionController_addIncomingTransactionHelperListeners = function _TransactionController_addIncomingTransactionHelperListeners(incomingTransactionHelper) {
|
|
1816
1859
|
incomingTransactionHelper.hub.on('transactions', this.onIncomingTransactions.bind(this));
|
|
1817
1860
|
}, _TransactionController_removePendingTransactionTrackerListeners = function _TransactionController_removePendingTransactionTrackerListeners(pendingTransactionTracker) {
|