@metamask-previews/transaction-controller 69.2.1-preview-ec4680201 → 69.2.1-preview-7aad920a3
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 +0 -4
- package/dist/TransactionController-method-action-types.cjs.map +1 -1
- package/dist/TransactionController-method-action-types.d.cts.map +1 -1
- package/dist/TransactionController-method-action-types.d.mts.map +1 -1
- package/dist/TransactionController-method-action-types.mjs.map +1 -1
- package/dist/TransactionController.cjs +205 -205
- package/dist/TransactionController.cjs.map +1 -1
- package/dist/TransactionController.d.cts.map +1 -1
- package/dist/TransactionController.d.mts.map +1 -1
- package/dist/TransactionController.mjs +1 -1
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/api/accounts-api.cjs +5 -5
- package/dist/api/accounts-api.cjs.map +1 -1
- package/dist/api/accounts-api.mjs.map +1 -1
- package/dist/api/simulation-api.cjs +8 -8
- package/dist/api/simulation-api.cjs.map +1 -1
- package/dist/api/simulation-api.d.cts.map +1 -1
- package/dist/api/simulation-api.d.mts.map +1 -1
- package/dist/api/simulation-api.mjs.map +1 -1
- package/dist/errors.cjs +4 -4
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.cjs +13 -13
- package/dist/gas-flows/DefaultGasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.cjs +10 -10
- 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.map +1 -1
- package/dist/gas-flows/MantleLayer1GasFeeFlow.cjs +8 -8
- package/dist/gas-flows/MantleLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/MantleLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +10 -10
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +10 -10
- 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.map +1 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs +13 -13
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +4 -4
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.cjs +2 -2
- package/dist/gas-flows/TestGasFeeFlow.cjs.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.d.cts.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.d.mts.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -1
- package/dist/helpers/GasFeePoller.cjs +22 -22
- package/dist/helpers/GasFeePoller.cjs.map +1 -1
- package/dist/helpers/GasFeePoller.d.cts +2 -2
- package/dist/helpers/GasFeePoller.d.cts.map +1 -1
- package/dist/helpers/GasFeePoller.d.mts +2 -2
- package/dist/helpers/GasFeePoller.d.mts.map +1 -1
- package/dist/helpers/GasFeePoller.mjs.map +1 -1
- package/dist/helpers/MethodDataHelper.cjs +4 -4
- package/dist/helpers/MethodDataHelper.cjs.map +1 -1
- package/dist/helpers/MethodDataHelper.d.cts +2 -2
- package/dist/helpers/MethodDataHelper.d.cts.map +1 -1
- package/dist/helpers/MethodDataHelper.d.mts +2 -2
- package/dist/helpers/MethodDataHelper.d.mts.map +1 -1
- package/dist/helpers/MethodDataHelper.mjs.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.cjs +2 -2
- 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.map +1 -1
- package/dist/helpers/PendingTransactionTracker.cjs +22 -22
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.cts +2 -2
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.d.mts +2 -2
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
- package/dist/helpers/ResimulateHelper.cjs +6 -6
- package/dist/helpers/ResimulateHelper.cjs.map +1 -1
- package/dist/helpers/ResimulateHelper.d.cts.map +1 -1
- package/dist/helpers/ResimulateHelper.d.mts.map +1 -1
- package/dist/helpers/ResimulateHelper.mjs.map +1 -1
- package/dist/helpers/TransactionPoller.cjs +4 -4
- package/dist/helpers/TransactionPoller.cjs.map +1 -1
- package/dist/helpers/TransactionPoller.d.cts.map +1 -1
- package/dist/helpers/TransactionPoller.d.mts.map +1 -1
- package/dist/helpers/TransactionPoller.mjs.map +1 -1
- package/dist/hooks/CollectPublishHook.cjs +2 -2
- package/dist/hooks/CollectPublishHook.cjs.map +1 -1
- package/dist/hooks/CollectPublishHook.d.cts.map +1 -1
- package/dist/hooks/CollectPublishHook.d.mts.map +1 -1
- package/dist/hooks/CollectPublishHook.mjs.map +1 -1
- package/dist/hooks/ExtraTransactionsPublishHook.cjs +2 -2
- package/dist/hooks/ExtraTransactionsPublishHook.cjs.map +1 -1
- package/dist/hooks/ExtraTransactionsPublishHook.d.cts.map +1 -1
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts.map +1 -1
- package/dist/hooks/ExtraTransactionsPublishHook.mjs.map +1 -1
- package/dist/hooks/SequentialPublishBatchHook.cjs +2 -2
- package/dist/hooks/SequentialPublishBatchHook.cjs.map +1 -1
- package/dist/hooks/SequentialPublishBatchHook.d.cts.map +1 -1
- package/dist/hooks/SequentialPublishBatchHook.d.mts.map +1 -1
- package/dist/hooks/SequentialPublishBatchHook.mjs.map +1 -1
- package/dist/index.cjs +33 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/balance-changes.cjs +31 -31
- package/dist/utils/balance-changes.cjs.map +1 -1
- package/dist/utils/balance-changes.d.cts.map +1 -1
- package/dist/utils/balance-changes.d.mts.map +1 -1
- package/dist/utils/balance-changes.mjs.map +1 -1
- package/dist/utils/balance.cjs +2 -2
- package/dist/utils/balance.cjs.map +1 -1
- package/dist/utils/balance.d.cts.map +1 -1
- package/dist/utils/balance.d.mts.map +1 -1
- package/dist/utils/balance.mjs.map +1 -1
- package/dist/utils/batch.cjs +45 -45
- package/dist/utils/batch.cjs.map +1 -1
- package/dist/utils/batch.d.cts +1 -1
- package/dist/utils/batch.d.cts.map +1 -1
- package/dist/utils/batch.d.mts +1 -1
- package/dist/utils/batch.d.mts.map +1 -1
- package/dist/utils/batch.mjs +1 -1
- package/dist/utils/batch.mjs.map +1 -1
- package/dist/utils/eip7702.cjs +9 -9
- package/dist/utils/eip7702.cjs.map +1 -1
- package/dist/utils/eip7702.d.cts.map +1 -1
- package/dist/utils/eip7702.d.mts.map +1 -1
- package/dist/utils/eip7702.mjs.map +1 -1
- package/dist/utils/external-transactions.cjs +2 -2
- package/dist/utils/external-transactions.cjs.map +1 -1
- package/dist/utils/external-transactions.d.cts.map +1 -1
- package/dist/utils/external-transactions.d.mts.map +1 -1
- package/dist/utils/external-transactions.mjs.map +1 -1
- package/dist/utils/feature-flags.cjs +5 -5
- package/dist/utils/feature-flags.cjs.map +1 -1
- package/dist/utils/feature-flags.d.cts.map +1 -1
- package/dist/utils/feature-flags.d.mts.map +1 -1
- package/dist/utils/feature-flags.mjs.map +1 -1
- package/dist/utils/first-time-interaction.cjs +14 -14
- package/dist/utils/first-time-interaction.cjs.map +1 -1
- package/dist/utils/first-time-interaction.d.cts.map +1 -1
- package/dist/utils/first-time-interaction.d.mts.map +1 -1
- package/dist/utils/first-time-interaction.mjs.map +1 -1
- package/dist/utils/gas-fee-tokens.cjs +13 -13
- package/dist/utils/gas-fee-tokens.cjs.map +1 -1
- package/dist/utils/gas-fee-tokens.d.cts.map +1 -1
- package/dist/utils/gas-fee-tokens.d.mts.map +1 -1
- package/dist/utils/gas-fee-tokens.mjs.map +1 -1
- package/dist/utils/gas-fees.cjs +19 -19
- package/dist/utils/gas-fees.cjs.map +1 -1
- package/dist/utils/gas-fees.d.cts.map +1 -1
- package/dist/utils/gas-fees.d.mts.map +1 -1
- package/dist/utils/gas-fees.mjs.map +1 -1
- package/dist/utils/gas-flow.cjs +6 -6
- package/dist/utils/gas-flow.cjs.map +1 -1
- package/dist/utils/gas-flow.d.cts.map +1 -1
- package/dist/utils/gas-flow.d.mts.map +1 -1
- package/dist/utils/gas-flow.mjs.map +1 -1
- package/dist/utils/gas.cjs +27 -27
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.d.cts.map +1 -1
- package/dist/utils/gas.d.mts.map +1 -1
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.cjs +2 -2
- package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -1
- package/dist/utils/nonce.cjs +2 -2
- package/dist/utils/nonce.cjs.map +1 -1
- package/dist/utils/nonce.d.cts.map +1 -1
- package/dist/utils/nonce.d.mts.map +1 -1
- package/dist/utils/nonce.mjs.map +1 -1
- package/dist/utils/prepare.cjs.map +1 -1
- package/dist/utils/prepare.d.cts.map +1 -1
- package/dist/utils/prepare.d.mts.map +1 -1
- package/dist/utils/prepare.mjs.map +1 -1
- package/dist/utils/provider.cjs +2 -2
- package/dist/utils/provider.cjs.map +1 -1
- package/dist/utils/provider.d.cts.map +1 -1
- package/dist/utils/provider.d.mts.map +1 -1
- package/dist/utils/provider.mjs.map +1 -1
- package/dist/utils/retry.cjs.map +1 -1
- package/dist/utils/retry.d.cts.map +1 -1
- package/dist/utils/retry.d.mts.map +1 -1
- package/dist/utils/retry.mjs.map +1 -1
- package/dist/utils/revert-reason.cjs +4 -4
- package/dist/utils/revert-reason.cjs.map +1 -1
- package/dist/utils/revert-reason.d.cts.map +1 -1
- package/dist/utils/revert-reason.d.mts.map +1 -1
- package/dist/utils/revert-reason.mjs.map +1 -1
- package/dist/utils/swaps.cjs +28 -28
- package/dist/utils/swaps.cjs.map +1 -1
- package/dist/utils/swaps.d.cts.map +1 -1
- package/dist/utils/swaps.d.mts.map +1 -1
- package/dist/utils/swaps.mjs.map +1 -1
- package/dist/utils/transaction-type.cjs +14 -14
- package/dist/utils/transaction-type.cjs.map +1 -1
- package/dist/utils/transaction-type.d.cts.map +1 -1
- package/dist/utils/transaction-type.d.mts.map +1 -1
- package/dist/utils/transaction-type.mjs.map +1 -1
- package/dist/utils/utils.cjs +8 -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.map +1 -1
- package/dist/utils/validation.cjs +11 -11
- package/dist/utils/validation.cjs.map +1 -1
- package/dist/utils/validation.d.cts.map +1 -1
- package/dist/utils/validation.d.mts.map +1 -1
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -24,40 +24,40 @@ const utils_1 = require("@metamask/utils");
|
|
|
24
24
|
const events_1 = require("events");
|
|
25
25
|
const lodash_1 = require("lodash");
|
|
26
26
|
const uuid_1 = require("uuid");
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
27
|
+
const DefaultGasFeeFlow_1 = require("./gas-flows/DefaultGasFeeFlow.cjs");
|
|
28
|
+
const LineaGasFeeFlow_1 = require("./gas-flows/LineaGasFeeFlow.cjs");
|
|
29
|
+
const MantleLayer1GasFeeFlow_1 = require("./gas-flows/MantleLayer1GasFeeFlow.cjs");
|
|
30
|
+
const OptimismLayer1GasFeeFlow_1 = require("./gas-flows/OptimismLayer1GasFeeFlow.cjs");
|
|
31
|
+
const RandomisedEstimationsGasFeeFlow_1 = require("./gas-flows/RandomisedEstimationsGasFeeFlow.cjs");
|
|
32
|
+
const ScrollLayer1GasFeeFlow_1 = require("./gas-flows/ScrollLayer1GasFeeFlow.cjs");
|
|
33
|
+
const TestGasFeeFlow_1 = require("./gas-flows/TestGasFeeFlow.cjs");
|
|
34
|
+
const GasFeePoller_1 = require("./helpers/GasFeePoller.cjs");
|
|
35
|
+
const MethodDataHelper_1 = require("./helpers/MethodDataHelper.cjs");
|
|
36
|
+
const MultichainTrackingHelper_1 = require("./helpers/MultichainTrackingHelper.cjs");
|
|
37
|
+
const PendingTransactionTracker_1 = require("./helpers/PendingTransactionTracker.cjs");
|
|
38
|
+
const ResimulateHelper_1 = require("./helpers/ResimulateHelper.cjs");
|
|
39
|
+
const ExtraTransactionsPublishHook_1 = require("./hooks/ExtraTransactionsPublishHook.cjs");
|
|
40
|
+
const logger_1 = require("./logger.cjs");
|
|
41
|
+
const types_1 = require("./types.cjs");
|
|
42
|
+
const balance_changes_1 = require("./utils/balance-changes.cjs");
|
|
43
|
+
const batch_1 = require("./utils/batch.cjs");
|
|
44
|
+
const eip7702_1 = require("./utils/eip7702.cjs");
|
|
45
|
+
const external_transactions_1 = require("./utils/external-transactions.cjs");
|
|
46
|
+
const feature_flags_1 = require("./utils/feature-flags.cjs");
|
|
47
|
+
const first_time_interaction_1 = require("./utils/first-time-interaction.cjs");
|
|
48
|
+
const gas_1 = require("./utils/gas.cjs");
|
|
49
|
+
const gas_fee_tokens_1 = require("./utils/gas-fee-tokens.cjs");
|
|
50
|
+
const gas_fees_1 = require("./utils/gas-fees.cjs");
|
|
51
|
+
const gas_flow_1 = require("./utils/gas-flow.cjs");
|
|
52
|
+
const layer1_gas_fee_flow_1 = require("./utils/layer1-gas-fee-flow.cjs");
|
|
53
|
+
const nonce_1 = require("./utils/nonce.cjs");
|
|
54
|
+
const prepare_1 = require("./utils/prepare.cjs");
|
|
55
|
+
const provider_1 = require("./utils/provider.cjs");
|
|
56
|
+
const retry_1 = require("./utils/retry.cjs");
|
|
57
|
+
const swaps_1 = require("./utils/swaps.cjs");
|
|
58
|
+
const transaction_type_1 = require("./utils/transaction-type.cjs");
|
|
59
|
+
const utils_2 = require("./utils/utils.cjs");
|
|
60
|
+
const validation_1 = require("./utils/validation.cjs");
|
|
61
61
|
/**
|
|
62
62
|
* Metadata for the TransactionController state, describing how to "anonymize"
|
|
63
63
|
* the state and which parts should be persisted.
|
|
@@ -245,7 +245,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
245
245
|
const findNetworkClientIdByChainId = (chainId) => {
|
|
246
246
|
return this.messenger.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
|
|
247
247
|
};
|
|
248
|
-
__classPrivateFieldSet(this, _TransactionController_multichainTrackingHelper, new
|
|
248
|
+
__classPrivateFieldSet(this, _TransactionController_multichainTrackingHelper, new MultichainTrackingHelper_1.MultichainTrackingHelper({
|
|
249
249
|
findNetworkClientIdByChainId,
|
|
250
250
|
getNetworkClientById: ((networkClientId) => {
|
|
251
251
|
return this.messenger.call(`NetworkController:getNetworkClientById`, networkClientId);
|
|
@@ -263,7 +263,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
263
263
|
}), "f");
|
|
264
264
|
__classPrivateFieldSet(this, _TransactionController_gasFeeFlows, __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeFlows).call(this), "f");
|
|
265
265
|
__classPrivateFieldSet(this, _TransactionController_layer1GasFeeFlows, __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getLayer1GasFeeFlows).call(this), "f");
|
|
266
|
-
const gasFeePoller = new
|
|
266
|
+
const gasFeePoller = new GasFeePoller_1.GasFeePoller({
|
|
267
267
|
gasFeeFlows: __classPrivateFieldGet(this, _TransactionController_gasFeeFlows, "f"),
|
|
268
268
|
getGasFeeControllerEstimates: (gasFeeOpts) => this.messenger.call('GasFeeController:fetchGasFeeEstimates', gasFeeOpts),
|
|
269
269
|
getTransactions: () => this.state.transactions,
|
|
@@ -276,7 +276,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
276
276
|
});
|
|
277
277
|
gasFeePoller.hub.on('transaction-updated', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onGasFeePollerTransactionUpdate).bind(this));
|
|
278
278
|
gasFeePoller.hub.on('transaction-batch-updated', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onGasFeePollerTransactionBatchUpdate).bind(this));
|
|
279
|
-
__classPrivateFieldSet(this, _TransactionController_methodDataHelper, new
|
|
279
|
+
__classPrivateFieldSet(this, _TransactionController_methodDataHelper, new MethodDataHelper_1.MethodDataHelper({
|
|
280
280
|
messenger: this.messenger,
|
|
281
281
|
getState: () => this.state.methodData,
|
|
282
282
|
}), "f");
|
|
@@ -289,7 +289,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
289
289
|
// check for pending transactions and start polling if there are any
|
|
290
290
|
this.messenger.subscribe('TransactionController:stateChange', __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
|
|
291
291
|
// eslint-disable-next-line no-new
|
|
292
|
-
new
|
|
292
|
+
new ResimulateHelper_1.ResimulateHelper({
|
|
293
293
|
simulateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).bind(this),
|
|
294
294
|
onTransactionsUpdate: (listener) => {
|
|
295
295
|
this.messenger.subscribe('TransactionController:stateChange', listener, (controllerState) => controllerState.transactions);
|
|
@@ -336,7 +336,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
336
336
|
*/
|
|
337
337
|
async addTransactionBatch(request) {
|
|
338
338
|
const { blockTracker } = this.messenger.call(`NetworkController:getNetworkClientById`, request.networkClientId);
|
|
339
|
-
return await (0,
|
|
339
|
+
return await (0, batch_1.addTransactionBatch)({
|
|
340
340
|
addTransaction: this.addTransaction.bind(this),
|
|
341
341
|
estimateGas: this.estimateGas.bind(this),
|
|
342
342
|
getGasFeeEstimates: (options) => this.messenger.call('GasFeeController:fetchGasFeeEstimates', options),
|
|
@@ -365,7 +365,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
365
365
|
* @returns Result object containing the supported chains and related information.
|
|
366
366
|
*/
|
|
367
367
|
async isAtomicBatchSupported(request) {
|
|
368
|
-
return (0,
|
|
368
|
+
return (0, batch_1.isAtomicBatchSupported)({
|
|
369
369
|
...request,
|
|
370
370
|
messenger: this.messenger,
|
|
371
371
|
publicKeyEIP7702: __classPrivateFieldGet(this, _TransactionController_publicKeyEIP7702, "f"),
|
|
@@ -381,19 +381,19 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
381
381
|
* @returns Object containing a promise resolving to the transaction hash if approved.
|
|
382
382
|
*/
|
|
383
383
|
async addTransaction(txParams, options) {
|
|
384
|
-
(0,
|
|
384
|
+
(0, logger_1.projectLogger)('Adding transaction', txParams, options);
|
|
385
385
|
const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, gasFeeToken, excludeNativeTokenForFee, isGasFeeIncluded, isGasFeeSponsored, isInternal = false, isStateOnly, nestedTransactions, networkClientId, origin, publishHook, requestId, requiredAssets, requireApproval, securityAlertResponse, skipInitialGasEstimate, swaps = {}, traceContext, type, } = options;
|
|
386
386
|
// eslint-disable-next-line no-param-reassign
|
|
387
|
-
txParams = (0,
|
|
387
|
+
txParams = (0, utils_2.normalizeTransactionParams)(txParams);
|
|
388
388
|
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
389
389
|
throw new Error(`Network client not found - ${networkClientId}`);
|
|
390
390
|
}
|
|
391
|
-
const chainId = (0,
|
|
391
|
+
const chainId = (0, provider_1.getChainId)({ messenger: this.messenger, networkClientId });
|
|
392
392
|
const permittedAddresses = origin === undefined
|
|
393
393
|
? undefined
|
|
394
394
|
: await __classPrivateFieldGet(this, _TransactionController_getPermittedAccounts, "f")?.call(this, origin);
|
|
395
395
|
const internalAccounts = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).call(this);
|
|
396
|
-
await (0,
|
|
396
|
+
await (0, validation_1.validateTransactionOrigin)({
|
|
397
397
|
data: txParams.data,
|
|
398
398
|
from: txParams.from,
|
|
399
399
|
internalAccounts,
|
|
@@ -403,21 +403,21 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
403
403
|
txParams,
|
|
404
404
|
type,
|
|
405
405
|
});
|
|
406
|
-
const delegationAddressPromise = (0,
|
|
406
|
+
const delegationAddressPromise = (0, eip7702_1.getDelegationAddress)(txParams.from, this.messenger, networkClientId).catch(() => undefined);
|
|
407
407
|
const isEIP1559Compatible = await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEIP1559Compatibility).call(this, networkClientId);
|
|
408
|
-
(0,
|
|
408
|
+
(0, validation_1.validateTxParams)(txParams, isEIP1559Compatible, chainId);
|
|
409
409
|
if (!txParams.type) {
|
|
410
410
|
// Determine transaction type based on transaction parameters and network compatibility
|
|
411
|
-
(0,
|
|
411
|
+
(0, utils_2.setEnvelopeType)(txParams, isEIP1559Compatible);
|
|
412
412
|
}
|
|
413
413
|
const isDuplicateBatchId = batchId?.length &&
|
|
414
414
|
this.state.transactions.some((tx) => tx.batchId?.toLowerCase() === batchId?.toLowerCase());
|
|
415
415
|
if (isDuplicateBatchId && !isInternal) {
|
|
416
|
-
throw new rpc_errors_1.JsonRpcError(
|
|
416
|
+
throw new rpc_errors_1.JsonRpcError(validation_1.ErrorCode.DuplicateBundleId, 'Batch ID already exists');
|
|
417
417
|
}
|
|
418
418
|
const dappSuggestedGasFees = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_generateDappSuggestedGasFees).call(this, txParams, origin, isInternal);
|
|
419
419
|
const transactionType = type ??
|
|
420
|
-
(await (0,
|
|
420
|
+
(await (0, transaction_type_1.determineTransactionType)(txParams, {
|
|
421
421
|
messenger: this.messenger,
|
|
422
422
|
networkClientId,
|
|
423
423
|
})).type;
|
|
@@ -454,7 +454,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
454
454
|
requiredAssets,
|
|
455
455
|
securityAlertResponse,
|
|
456
456
|
selectedGasFeeToken: gasFeeToken,
|
|
457
|
-
status:
|
|
457
|
+
status: types_1.TransactionStatus.unapproved,
|
|
458
458
|
time: Date.now(),
|
|
459
459
|
txParams,
|
|
460
460
|
type: transactionType,
|
|
@@ -465,7 +465,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
465
465
|
transactionMeta: addedTransactionMeta,
|
|
466
466
|
});
|
|
467
467
|
if (updateTransaction) {
|
|
468
|
-
(0,
|
|
468
|
+
(0, logger_1.projectLogger)('Updating transaction using afterAdd hook');
|
|
469
469
|
addedTransactionMeta.txParamsOriginal = (0, lodash_1.cloneDeep)(addedTransactionMeta.txParams);
|
|
470
470
|
updateTransaction(addedTransactionMeta);
|
|
471
471
|
}
|
|
@@ -495,7 +495,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
495
495
|
})
|
|
496
496
|
.catch(lodash_1.noop);
|
|
497
497
|
}
|
|
498
|
-
addedTransactionMeta = (0,
|
|
498
|
+
addedTransactionMeta = (0, swaps_1.updateSwapsTransaction)(addedTransactionMeta, transactionType, swaps, {
|
|
499
499
|
isSwapsDisabled: __classPrivateFieldGet(this, _TransactionController_isSwapsDisabled, "f"),
|
|
500
500
|
cancelTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_rejectTransaction).bind(this),
|
|
501
501
|
messenger: this.messenger,
|
|
@@ -517,10 +517,10 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
517
517
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).call(this, addedTransactionMeta, {
|
|
518
518
|
traceContext,
|
|
519
519
|
}).catch((error) => {
|
|
520
|
-
(0,
|
|
520
|
+
(0, logger_1.projectLogger)('Error while updating simulation data', error);
|
|
521
521
|
throw error;
|
|
522
522
|
});
|
|
523
|
-
(0,
|
|
523
|
+
(0, first_time_interaction_1.updateFirstTimeInteraction)({
|
|
524
524
|
existingTransactions: this.state.transactions,
|
|
525
525
|
getTransaction: (transactionId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId),
|
|
526
526
|
isFirstTimeInteractionEnabled: __classPrivateFieldGet(this, _TransactionController_isFirstTimeInteractionEnabled, "f"),
|
|
@@ -529,11 +529,11 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
529
529
|
transactionMeta: addedTransactionMeta,
|
|
530
530
|
updateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).bind(this),
|
|
531
531
|
}).catch((error) => {
|
|
532
|
-
(0,
|
|
532
|
+
(0, logger_1.projectLogger)('Error while updating first interaction properties', error);
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
535
|
else {
|
|
536
|
-
(0,
|
|
536
|
+
(0, logger_1.projectLogger)('Skipping simulation & first interaction update as approval not required');
|
|
537
537
|
}
|
|
538
538
|
this.messenger.publish(`${controllerName}:unapprovedTransactionAdded`, addedTransactionMeta);
|
|
539
539
|
return {
|
|
@@ -564,7 +564,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
564
564
|
label: 'cancel',
|
|
565
565
|
rate: exports.CANCEL_RATE,
|
|
566
566
|
transactionId,
|
|
567
|
-
transactionType:
|
|
567
|
+
transactionType: types_1.TransactionType.cancel,
|
|
568
568
|
prepareTransactionParams: (txParams) => {
|
|
569
569
|
delete txParams.data;
|
|
570
570
|
txParams.to = txParams.from;
|
|
@@ -593,7 +593,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
593
593
|
label: 'speed up',
|
|
594
594
|
rate: exports.SPEED_UP_RATE,
|
|
595
595
|
transactionId,
|
|
596
|
-
transactionType:
|
|
596
|
+
transactionType: types_1.TransactionType.retry,
|
|
597
597
|
afterSubmit: (newTransactionMeta) => {
|
|
598
598
|
this.messenger.publish(`${controllerName}:speedupTransactionAdded`, newTransactionMeta);
|
|
599
599
|
},
|
|
@@ -609,7 +609,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
609
609
|
* @returns The gas and gas price.
|
|
610
610
|
*/
|
|
611
611
|
async estimateGas(transaction, networkClientId, { ignoreDelegationSignatures, } = {}) {
|
|
612
|
-
const { estimatedGas, simulationFails } = await (0,
|
|
612
|
+
const { estimatedGas, simulationFails } = await (0, gas_1.estimateGas)({
|
|
613
613
|
ignoreDelegationSignatures,
|
|
614
614
|
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
|
|
615
615
|
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
@@ -629,12 +629,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
629
629
|
* @returns Object containing the gas limit.
|
|
630
630
|
*/
|
|
631
631
|
async estimateGasBatch({ chainId, from, transactions, }) {
|
|
632
|
-
return (0,
|
|
632
|
+
return (0, gas_1.estimateGasBatch)({
|
|
633
633
|
from,
|
|
634
634
|
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
635
635
|
isAtomicBatchSupported: this.isAtomicBatchSupported.bind(this),
|
|
636
636
|
messenger: this.messenger,
|
|
637
|
-
networkClientId: (0,
|
|
637
|
+
networkClientId: (0, provider_1.getNetworkClientId)({
|
|
638
638
|
messenger: this.messenger,
|
|
639
639
|
chainId,
|
|
640
640
|
}),
|
|
@@ -650,14 +650,14 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
650
650
|
* @returns The buffered estimated gas and whether the estimation failed.
|
|
651
651
|
*/
|
|
652
652
|
async estimateGasBuffered(transaction, multiplier, networkClientId) {
|
|
653
|
-
const { blockGasLimit, estimatedGas, simulationFails } = await (0,
|
|
653
|
+
const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_1.estimateGas)({
|
|
654
654
|
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
|
|
655
655
|
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
656
656
|
messenger: this.messenger,
|
|
657
657
|
networkClientId,
|
|
658
658
|
txParams: transaction,
|
|
659
659
|
});
|
|
660
|
-
const gas = (0,
|
|
660
|
+
const gas = (0, gas_1.addGasBuffer)(estimatedGas, blockGasLimit, multiplier);
|
|
661
661
|
return {
|
|
662
662
|
gas,
|
|
663
663
|
simulationFails,
|
|
@@ -674,7 +674,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
674
674
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, () => ({
|
|
675
675
|
...transactionMeta,
|
|
676
676
|
}));
|
|
677
|
-
(0,
|
|
677
|
+
(0, logger_1.projectLogger)('Transaction updated', { transactionId, note });
|
|
678
678
|
}
|
|
679
679
|
/**
|
|
680
680
|
* Mark a transaction as failed, transitioning it through the standard failure
|
|
@@ -735,7 +735,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
735
735
|
}
|
|
736
736
|
const isMatchingAddress = !address ||
|
|
737
737
|
txParams.from?.toLowerCase() === address.toLowerCase() ||
|
|
738
|
-
(type ===
|
|
738
|
+
(type === types_1.TransactionType.incoming &&
|
|
739
739
|
txParams.to?.toLowerCase() === address.toLowerCase());
|
|
740
740
|
return !isMatchingAddress;
|
|
741
741
|
});
|
|
@@ -769,7 +769,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
769
769
|
// Make sure status is confirmed and define gasUsed as in receipt.
|
|
770
770
|
const updatedTransactionMeta = {
|
|
771
771
|
...newTransactionMeta,
|
|
772
|
-
status:
|
|
772
|
+
status: types_1.TransactionStatus.confirmed,
|
|
773
773
|
txReceipt: transactionReceipt,
|
|
774
774
|
};
|
|
775
775
|
if (baseFeePerGas) {
|
|
@@ -783,7 +783,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
783
783
|
// Intentional given potential duration of process.
|
|
784
784
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updatePostBalance).call(this, updatedTransactionMeta).catch((error) => {
|
|
785
785
|
/* istanbul ignore next */
|
|
786
|
-
(0,
|
|
786
|
+
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
787
787
|
throw error;
|
|
788
788
|
});
|
|
789
789
|
this.messenger.publish(`${controllerName}:transactionConfirmed`, updatedTransactionMeta);
|
|
@@ -815,17 +815,17 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
815
815
|
if (!transactionMeta) {
|
|
816
816
|
throw new Error(`Cannot update transaction as no transaction metadata found`);
|
|
817
817
|
}
|
|
818
|
-
(0,
|
|
818
|
+
(0, utils_2.validateIfTransactionUnapprovedOrSubmitted)(transactionMeta, 'updateTransactionGasFees');
|
|
819
819
|
const clonedTransactionMeta = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
820
820
|
const isTransactionGasFeeEstimatesExists = transactionMeta.gasFeeEstimates;
|
|
821
821
|
const isAutomaticGasFeeUpdateEnabled = __classPrivateFieldGet(this, _TransactionController_isAutomaticGasFeeUpdateEnabled, "f").call(this, transactionMeta);
|
|
822
822
|
const userFeeLevel = userFeeLevelParam;
|
|
823
|
-
const isOneOfFeeLevelSelected = Object.values(
|
|
823
|
+
const isOneOfFeeLevelSelected = Object.values(types_1.GasFeeEstimateLevel).includes(userFeeLevel);
|
|
824
824
|
const shouldUpdateTxParamsGasFees = isTransactionGasFeeEstimatesExists &&
|
|
825
825
|
isAutomaticGasFeeUpdateEnabled &&
|
|
826
826
|
isOneOfFeeLevelSelected;
|
|
827
827
|
if (shouldUpdateTxParamsGasFees) {
|
|
828
|
-
(0,
|
|
828
|
+
(0, GasFeePoller_1.updateTransactionGasEstimates)({
|
|
829
829
|
txMeta: clonedTransactionMeta,
|
|
830
830
|
userFeeLevel,
|
|
831
831
|
});
|
|
@@ -886,7 +886,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
886
886
|
if (!transactionMeta) {
|
|
887
887
|
throw new Error(`Cannot update transaction as no transaction metadata found`);
|
|
888
888
|
}
|
|
889
|
-
(0,
|
|
889
|
+
(0, utils_2.validateIfTransactionUnapprovedOrSubmitted)(transactionMeta, 'updatePreviousGasParams');
|
|
890
890
|
const transactionPreviousGas = {
|
|
891
891
|
previousGas: {
|
|
892
892
|
gasLimit,
|
|
@@ -936,7 +936,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
936
936
|
if (!transactionMeta) {
|
|
937
937
|
throw new Error(`Cannot update editable params as no transaction metadata found`);
|
|
938
938
|
}
|
|
939
|
-
(0,
|
|
939
|
+
(0, utils_2.validateIfTransactionUnapproved)(transactionMeta, 'updateEditableParams');
|
|
940
940
|
const editableParams = {
|
|
941
941
|
txParams: {
|
|
942
942
|
data,
|
|
@@ -953,7 +953,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
953
953
|
const updatedTransaction = (0, lodash_1.merge)({}, transactionMeta, editableParams);
|
|
954
954
|
const { networkClientId } = transactionMeta;
|
|
955
955
|
if (updateType !== false) {
|
|
956
|
-
const { type } = await (0,
|
|
956
|
+
const { type } = await (0, transaction_type_1.determineTransactionType)(updatedTransaction.txParams, {
|
|
957
957
|
messenger: this.messenger,
|
|
958
958
|
networkClientId,
|
|
959
959
|
});
|
|
@@ -966,7 +966,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
966
966
|
updatedTransaction.txParamsOriginal = (0, lodash_1.cloneDeep)(transactionMeta.txParams);
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
|
-
await (0,
|
|
969
|
+
await (0, layer1_gas_fee_flow_1.updateTransactionLayer1GasFee)({
|
|
970
970
|
layer1GasFeeFlows: __classPrivateFieldGet(this, _TransactionController_layer1GasFeeFlows, "f"),
|
|
971
971
|
messenger: this.messenger,
|
|
972
972
|
transactionMeta: updatedTransaction,
|
|
@@ -1002,7 +1002,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1002
1002
|
* @returns The raw transactions.
|
|
1003
1003
|
*/
|
|
1004
1004
|
async approveTransactionsWithSameNonce(listOfTxParams = [], { hasNonce } = {}) {
|
|
1005
|
-
(0,
|
|
1005
|
+
(0, logger_1.projectLogger)('Approving transactions with same nonce', {
|
|
1006
1006
|
transactions: listOfTxParams,
|
|
1007
1007
|
});
|
|
1008
1008
|
if (listOfTxParams.length === 0) {
|
|
@@ -1010,12 +1010,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
const initialTx = listOfTxParams[0];
|
|
1012
1012
|
const { chainId } = initialTx;
|
|
1013
|
-
const networkClientId = (0,
|
|
1013
|
+
const networkClientId = (0, provider_1.getNetworkClientId)({
|
|
1014
1014
|
messenger: this.messenger,
|
|
1015
1015
|
chainId,
|
|
1016
1016
|
});
|
|
1017
|
-
const initialTxAsEthTx = (0,
|
|
1018
|
-
const initialTxAsSerializedHex = (0,
|
|
1017
|
+
const initialTxAsEthTx = (0, prepare_1.prepareTransaction)(chainId, initialTx);
|
|
1018
|
+
const initialTxAsSerializedHex = (0, prepare_1.serializeTransaction)(chainId, initialTxAsEthTx);
|
|
1019
1019
|
if (__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").has(initialTxAsSerializedHex)) {
|
|
1020
1020
|
return '';
|
|
1021
1021
|
}
|
|
@@ -1032,7 +1032,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1032
1032
|
? (0, utils_1.add0x)(nonceLock.nextNonce.toString(16))
|
|
1033
1033
|
: initialTx.nonce;
|
|
1034
1034
|
if (nonceLock) {
|
|
1035
|
-
(0,
|
|
1035
|
+
(0, logger_1.projectLogger)('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails);
|
|
1036
1036
|
}
|
|
1037
1037
|
rawTransactions = await Promise.all(listOfTxParams.map((txParams) => {
|
|
1038
1038
|
txParams.nonce = nonce;
|
|
@@ -1040,7 +1040,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1040
1040
|
}));
|
|
1041
1041
|
}
|
|
1042
1042
|
catch (error) {
|
|
1043
|
-
(0,
|
|
1043
|
+
(0, logger_1.projectLogger)('Error while signing transactions with same nonce', error);
|
|
1044
1044
|
// Must set transaction to submitted/failed before releasing lock
|
|
1045
1045
|
// continue with error chain
|
|
1046
1046
|
throw error;
|
|
@@ -1066,18 +1066,18 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1066
1066
|
}
|
|
1067
1067
|
if (status &&
|
|
1068
1068
|
![
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1069
|
+
types_1.TransactionStatus.submitted,
|
|
1070
|
+
types_1.TransactionStatus.signed,
|
|
1071
|
+
types_1.TransactionStatus.failed,
|
|
1072
1072
|
].includes(status)) {
|
|
1073
1073
|
throw new Error(`Cannot update custodial transaction with status: ${status}`);
|
|
1074
1074
|
}
|
|
1075
1075
|
const updatedTransactionMeta = (0, lodash_1.merge)({}, transactionMeta, (0, lodash_1.pickBy)({ hash, status }));
|
|
1076
|
-
if (updatedTransactionMeta.status ===
|
|
1076
|
+
if (updatedTransactionMeta.status === types_1.TransactionStatus.submitted) {
|
|
1077
1077
|
updatedTransactionMeta.submittedTime = new Date().getTime();
|
|
1078
1078
|
}
|
|
1079
|
-
if (updatedTransactionMeta.status ===
|
|
1080
|
-
updatedTransactionMeta.error = (0,
|
|
1079
|
+
if (updatedTransactionMeta.status === types_1.TransactionStatus.failed) {
|
|
1080
|
+
updatedTransactionMeta.error = (0, utils_2.normalizeTxError)(new Error(errorMessage));
|
|
1081
1081
|
}
|
|
1082
1082
|
// Update txParams properties with a single pickBy operation
|
|
1083
1083
|
updatedTransactionMeta.txParams = (0, lodash_1.merge)({}, updatedTransactionMeta.txParams, (0, lodash_1.pickBy)({
|
|
@@ -1089,13 +1089,13 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1089
1089
|
type,
|
|
1090
1090
|
}));
|
|
1091
1091
|
// Special case for type change to legacy
|
|
1092
|
-
if (type ===
|
|
1092
|
+
if (type === types_1.TransactionEnvelopeType.legacy) {
|
|
1093
1093
|
delete updatedTransactionMeta.txParams.maxFeePerGas;
|
|
1094
1094
|
delete updatedTransactionMeta.txParams.maxPriorityFeePerGas;
|
|
1095
1095
|
}
|
|
1096
1096
|
this.updateTransaction(updatedTransactionMeta, `${controllerName}:updateCustodialTransaction - Custodial transaction updated`);
|
|
1097
1097
|
if (status &&
|
|
1098
|
-
[
|
|
1098
|
+
[types_1.TransactionStatus.submitted, types_1.TransactionStatus.failed].includes(status)) {
|
|
1099
1099
|
this.messenger.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1100
1100
|
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${updatedTransactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1101
1101
|
}
|
|
@@ -1202,7 +1202,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1202
1202
|
networkClientId,
|
|
1203
1203
|
};
|
|
1204
1204
|
// Guaranteed as the default gas fee flow matches all transactions.
|
|
1205
|
-
const gasFeeFlow = (0,
|
|
1205
|
+
const gasFeeFlow = (0, gas_flow_1.getGasFeeFlow)(transactionMeta, __classPrivateFieldGet(this, _TransactionController_gasFeeFlows, "f"), this.messenger);
|
|
1206
1206
|
const gasFeeControllerData = await this.messenger.call('GasFeeController:fetchGasFeeEstimates', { networkClientId });
|
|
1207
1207
|
return gasFeeFlow.getGasFees({
|
|
1208
1208
|
gasFeeControllerData,
|
|
@@ -1220,12 +1220,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1220
1220
|
* @returns The layer 1 gas fee.
|
|
1221
1221
|
*/
|
|
1222
1222
|
async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
|
|
1223
|
-
const resolvedNetworkClientId = (0,
|
|
1223
|
+
const resolvedNetworkClientId = (0, provider_1.getNetworkClientId)({
|
|
1224
1224
|
messenger: this.messenger,
|
|
1225
1225
|
chainId,
|
|
1226
1226
|
networkClientId,
|
|
1227
1227
|
});
|
|
1228
|
-
return await (0,
|
|
1228
|
+
return await (0, layer1_gas_fee_flow_1.getTransactionLayer1GasFee)({
|
|
1229
1229
|
layer1GasFeeFlows: __classPrivateFieldGet(this, _TransactionController_layer1GasFeeFlows, "f"),
|
|
1230
1230
|
messenger: this.messenger,
|
|
1231
1231
|
transactionMeta: {
|
|
@@ -1239,7 +1239,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1239
1239
|
* Removes unapproved transactions from state.
|
|
1240
1240
|
*/
|
|
1241
1241
|
clearUnapprovedTransactions() {
|
|
1242
|
-
const transactions = this.state.transactions.filter(({ status }) => status !==
|
|
1242
|
+
const transactions = this.state.transactions.filter(({ status }) => status !== types_1.TransactionStatus.unapproved);
|
|
1243
1243
|
this.update((state) => {
|
|
1244
1244
|
state.transactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_trimTransactionsForState).call(this, transactions);
|
|
1245
1245
|
});
|
|
@@ -1272,7 +1272,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1272
1272
|
* @returns The updated data for the atomic batch transaction.
|
|
1273
1273
|
*/
|
|
1274
1274
|
async updateAtomicBatchData({ transactionId, transactionIndex, transactionData, }) {
|
|
1275
|
-
(0,
|
|
1275
|
+
(0, logger_1.projectLogger)('Updating atomic batch data', {
|
|
1276
1276
|
transactionId,
|
|
1277
1277
|
transactionIndex,
|
|
1278
1278
|
transactionData,
|
|
@@ -1287,7 +1287,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1287
1287
|
throw new Error(`Nested transaction not found with index - ${transactionIndex}`);
|
|
1288
1288
|
}
|
|
1289
1289
|
nestedTransaction.data = transactionData;
|
|
1290
|
-
const batchTransaction = (0,
|
|
1290
|
+
const batchTransaction = (0, eip7702_1.generateEIP7702BatchTransaction)(from, nestedTransactions);
|
|
1291
1291
|
transactionMeta.txParams.data = batchTransaction.data;
|
|
1292
1292
|
});
|
|
1293
1293
|
const draftTransaction = (0, lodash_1.cloneDeep)({
|
|
@@ -1324,7 +1324,7 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1324
1324
|
* @param request.batchTransactions - The new batch transactions.
|
|
1325
1325
|
*/
|
|
1326
1326
|
updateBatchTransactions({ transactionId, batchTransactions, }) {
|
|
1327
|
-
(0,
|
|
1327
|
+
(0, logger_1.projectLogger)('Updating batch transactions', { transactionId, batchTransactions });
|
|
1328
1328
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1329
1329
|
transactionId,
|
|
1330
1330
|
}, (transactionMeta) => {
|
|
@@ -1373,12 +1373,12 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1373
1373
|
if (!transactionMeta) {
|
|
1374
1374
|
return;
|
|
1375
1375
|
}
|
|
1376
|
-
if (transactionMeta.type ===
|
|
1376
|
+
if (transactionMeta.type === types_1.TransactionType.swap) {
|
|
1377
1377
|
this.messenger.publish('TransactionController:transactionNewSwap', {
|
|
1378
1378
|
transactionMeta,
|
|
1379
1379
|
});
|
|
1380
1380
|
}
|
|
1381
|
-
else if (transactionMeta.type ===
|
|
1381
|
+
else if (transactionMeta.type === types_1.TransactionType.swapApproval) {
|
|
1382
1382
|
this.messenger.publish('TransactionController:transactionNewSwapApproval', { transactionMeta });
|
|
1383
1383
|
}
|
|
1384
1384
|
}
|
|
@@ -1415,11 +1415,11 @@ class TransactionController extends base_controller_1.BaseController {
|
|
|
1415
1415
|
*/
|
|
1416
1416
|
async getGasFeeTokens(request) {
|
|
1417
1417
|
const { chainId, data, from, to, value } = request;
|
|
1418
|
-
const networkClientId = (0,
|
|
1418
|
+
const networkClientId = (0, provider_1.getNetworkClientId)({
|
|
1419
1419
|
messenger: this.messenger,
|
|
1420
1420
|
chainId,
|
|
1421
1421
|
});
|
|
1422
|
-
const delegationAddress = await (0,
|
|
1422
|
+
const delegationAddress = await (0, eip7702_1.getDelegationAddress)(from, this.messenger, networkClientId);
|
|
1423
1423
|
const transaction = {
|
|
1424
1424
|
chainId,
|
|
1425
1425
|
delegationAddress,
|
|
@@ -1440,26 +1440,26 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1440
1440
|
if (gasValues) {
|
|
1441
1441
|
// Not good practice to reassign a parameter but temporarily avoiding a larger refactor.
|
|
1442
1442
|
// eslint-disable-next-line no-param-reassign
|
|
1443
|
-
gasValues = (0,
|
|
1444
|
-
(0,
|
|
1443
|
+
gasValues = (0, utils_2.normalizeGasFeeValues)(gasValues);
|
|
1444
|
+
(0, utils_2.validateGasValues)(gasValues);
|
|
1445
1445
|
}
|
|
1446
|
-
(0,
|
|
1446
|
+
(0, logger_1.projectLogger)(`Creating ${label} transaction`, transactionId, gasValues);
|
|
1447
1447
|
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1448
1448
|
/* istanbul ignore next */
|
|
1449
1449
|
if (!transactionMeta) {
|
|
1450
1450
|
return;
|
|
1451
1451
|
}
|
|
1452
|
-
const newTxParams = (0,
|
|
1452
|
+
const newTxParams = (0, retry_1.getTransactionParamsWithIncreasedGasFee)(transactionMeta.txParams, rate, gasValues);
|
|
1453
1453
|
prepareTransactionParams?.(newTxParams);
|
|
1454
|
-
const unsignedEthTx = (0,
|
|
1454
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(transactionMeta.chainId, newTxParams);
|
|
1455
1455
|
const signedTxData = await this.messenger.call('KeyringController:signTransaction', unsignedEthTx, transactionMeta.txParams.from);
|
|
1456
1456
|
const transactionMetaWithRsv = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionMetaRSV).call(this, transactionMeta, signedTxData);
|
|
1457
|
-
const rawTx = (0,
|
|
1457
|
+
const rawTx = (0, prepare_1.serializeTransaction)(transactionMeta.chainId, signedTxData);
|
|
1458
1458
|
const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
|
|
1459
1459
|
const oldFee = newTxParams.maxFeePerGas
|
|
1460
1460
|
? transactionMetaWithRsv.txParams.maxFeePerGas
|
|
1461
1461
|
: transactionMetaWithRsv.txParams.gasPrice;
|
|
1462
|
-
(0,
|
|
1462
|
+
(0, logger_1.projectLogger)(`Submitting ${label} transaction`, {
|
|
1463
1463
|
oldFee,
|
|
1464
1464
|
newFee,
|
|
1465
1465
|
txParams: newTxParams,
|
|
@@ -1493,10 +1493,10 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1493
1493
|
});
|
|
1494
1494
|
afterSubmit?.(newTransactionMeta);
|
|
1495
1495
|
}, _TransactionController_signExternalTransaction = async function _TransactionController_signExternalTransaction(chainId, transactionParams) {
|
|
1496
|
-
const normalizedTransactionParams = (0,
|
|
1497
|
-
const type = (0,
|
|
1498
|
-
?
|
|
1499
|
-
:
|
|
1496
|
+
const normalizedTransactionParams = (0, utils_2.normalizeTransactionParams)(transactionParams);
|
|
1497
|
+
const type = (0, utils_2.isEIP1559Transaction)(normalizedTransactionParams)
|
|
1498
|
+
? types_1.TransactionEnvelopeType.feeMarket
|
|
1499
|
+
: types_1.TransactionEnvelopeType.legacy;
|
|
1500
1500
|
const updatedTransactionParams = {
|
|
1501
1501
|
...normalizedTransactionParams,
|
|
1502
1502
|
type,
|
|
@@ -1504,12 +1504,12 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1504
1504
|
chainId,
|
|
1505
1505
|
};
|
|
1506
1506
|
const { from } = updatedTransactionParams;
|
|
1507
|
-
const unsignedTransaction = (0,
|
|
1507
|
+
const unsignedTransaction = (0, prepare_1.prepareTransaction)(chainId, updatedTransactionParams);
|
|
1508
1508
|
const signedTxData = await this.messenger.call('KeyringController:signTransaction', unsignedTransaction, from);
|
|
1509
|
-
const rawTransaction = (0,
|
|
1509
|
+
const rawTransaction = (0, prepare_1.serializeTransaction)(chainId, signedTxData);
|
|
1510
1510
|
return rawTransaction;
|
|
1511
1511
|
}, _TransactionController_addMetadata = function _TransactionController_addMetadata(transactionMeta) {
|
|
1512
|
-
(0,
|
|
1512
|
+
(0, validation_1.validateTxParams)(transactionMeta.txParams);
|
|
1513
1513
|
this.update((state) => {
|
|
1514
1514
|
state.transactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_trimTransactionsForState).call(this, [
|
|
1515
1515
|
...state.transactions,
|
|
@@ -1517,12 +1517,12 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1517
1517
|
]);
|
|
1518
1518
|
});
|
|
1519
1519
|
}, _TransactionController_updateGasProperties = async function _TransactionController_updateGasProperties(transactionMeta, { traceContext } = {}) {
|
|
1520
|
-
const isEIP1559Compatible = transactionMeta.txParams.type !==
|
|
1520
|
+
const isEIP1559Compatible = transactionMeta.txParams.type !== types_1.TransactionEnvelopeType.legacy &&
|
|
1521
1521
|
(await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEIP1559Compatibility).call(this, transactionMeta.networkClientId));
|
|
1522
1522
|
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
|
|
1523
1523
|
await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasEstimate).call(this, transactionMeta);
|
|
1524
1524
|
});
|
|
1525
|
-
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas Fees', parentContext: traceContext }, async () => await (0,
|
|
1525
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas Fees', parentContext: traceContext }, async () => await (0, gas_fees_1.updateGasFees)({
|
|
1526
1526
|
eip1559: isEIP1559Compatible,
|
|
1527
1527
|
gasFeeFlows: __classPrivateFieldGet(this, _TransactionController_gasFeeFlows, "f"),
|
|
1528
1528
|
getGasFeeEstimates: (options) => this.messenger.call('GasFeeController:fetchGasFeeEstimates', options),
|
|
@@ -1530,7 +1530,7 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1530
1530
|
messenger: this.messenger,
|
|
1531
1531
|
txMeta: transactionMeta,
|
|
1532
1532
|
}));
|
|
1533
|
-
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Layer 1 Gas Fees', parentContext: traceContext }, async () => await (0,
|
|
1533
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Layer 1 Gas Fees', parentContext: traceContext }, async () => await (0, layer1_gas_fee_flow_1.updateTransactionLayer1GasFee)({
|
|
1534
1534
|
layer1GasFeeFlows: __classPrivateFieldGet(this, _TransactionController_layer1GasFeeFlows, "f"),
|
|
1535
1535
|
messenger: this.messenger,
|
|
1536
1536
|
transactionMeta,
|
|
@@ -1539,13 +1539,13 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1539
1539
|
this.clearUnapprovedTransactions();
|
|
1540
1540
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failIncompleteTransactions).call(this);
|
|
1541
1541
|
}, _TransactionController_failIncompleteTransactions = function _TransactionController_failIncompleteTransactions() {
|
|
1542
|
-
const incompleteTransactions = this.state.transactions.filter((transaction) => [
|
|
1542
|
+
const incompleteTransactions = this.state.transactions.filter((transaction) => [types_1.TransactionStatus.approved, types_1.TransactionStatus.signed].includes(transaction.status));
|
|
1543
1543
|
for (const transactionMeta of incompleteTransactions) {
|
|
1544
1544
|
const requiredTransactionIds = transactionMeta.requiredTransactionIds ?? [];
|
|
1545
1545
|
const allRequiredConfirmed = requiredTransactionIds.length > 0 &&
|
|
1546
1546
|
requiredTransactionIds.every((id) => {
|
|
1547
1547
|
const tx = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, id);
|
|
1548
|
-
return tx?.status ===
|
|
1548
|
+
return tx?.status === types_1.TransactionStatus.confirmed;
|
|
1549
1549
|
});
|
|
1550
1550
|
const message = allRequiredConfirmed
|
|
1551
1551
|
? 'Transaction incomplete at startup with all required transactions confirmed'
|
|
@@ -1564,7 +1564,7 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1564
1564
|
const { id: transactionId, isStateOnly } = transactionMeta;
|
|
1565
1565
|
if (isStateOnly) {
|
|
1566
1566
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId, skipValidation: true }, (tx) => {
|
|
1567
|
-
tx.status =
|
|
1567
|
+
tx.status = types_1.TransactionStatus.submitted;
|
|
1568
1568
|
tx.submittedTime = new Date().getTime();
|
|
1569
1569
|
});
|
|
1570
1570
|
return '';
|
|
@@ -1585,7 +1585,7 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1585
1585
|
const approvalValue = acceptResult.value;
|
|
1586
1586
|
const updatedTransaction = approvalValue?.txMeta;
|
|
1587
1587
|
if (updatedTransaction) {
|
|
1588
|
-
(0,
|
|
1588
|
+
(0, logger_1.projectLogger)('Updating transaction with approval data', {
|
|
1589
1589
|
customNonce: updatedTransaction.customNonceValue,
|
|
1590
1590
|
params: updatedTransaction.txParams,
|
|
1591
1591
|
});
|
|
@@ -1626,12 +1626,12 @@ _TransactionController_afterAdd = new WeakMap(), _TransactionController_approvin
|
|
|
1626
1626
|
}
|
|
1627
1627
|
const finalMeta = await finishedPromise;
|
|
1628
1628
|
switch (finalMeta?.status) {
|
|
1629
|
-
case
|
|
1629
|
+
case types_1.TransactionStatus.failed: {
|
|
1630
1630
|
const error = finalMeta.error;
|
|
1631
1631
|
resultCallbacks?.error(error);
|
|
1632
1632
|
throw rpc_errors_1.rpcErrors.internal(error.message);
|
|
1633
1633
|
}
|
|
1634
|
-
case
|
|
1634
|
+
case types_1.TransactionStatus.submitted:
|
|
1635
1635
|
resultCallbacks?.success();
|
|
1636
1636
|
return finalMeta.hash;
|
|
1637
1637
|
default: {
|
|
@@ -1656,20 +1656,20 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1656
1656
|
let clearApprovingTransactionId;
|
|
1657
1657
|
let clearNonceLock;
|
|
1658
1658
|
let transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
1659
|
-
(0,
|
|
1659
|
+
(0, logger_1.projectLogger)('Approving transaction', transactionMeta);
|
|
1660
1660
|
try {
|
|
1661
1661
|
if (!transactionMeta.chainId) {
|
|
1662
1662
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failTransaction).call(this, transactionMeta, new Error('No chainId defined.'));
|
|
1663
1663
|
return ApprovalState.NotApproved;
|
|
1664
1664
|
}
|
|
1665
1665
|
if (__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").has(transactionId)) {
|
|
1666
|
-
(0,
|
|
1666
|
+
(0, logger_1.projectLogger)('Skipping approval as signing in progress', transactionId);
|
|
1667
1667
|
return ApprovalState.NotApproved;
|
|
1668
1668
|
}
|
|
1669
1669
|
__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").add(transactionId);
|
|
1670
1670
|
clearApprovingTransactionId = () => __classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").delete(transactionId);
|
|
1671
1671
|
const { networkClientId } = transactionMeta;
|
|
1672
|
-
const [nonce, releaseNonce] = await (0,
|
|
1672
|
+
const [nonce, releaseNonce] = await (0, nonce_1.getNextNonce)(transactionMeta, (address) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNonceLock(address, transactionMeta.networkClientId));
|
|
1673
1673
|
clearNonceLock = releaseNonce;
|
|
1674
1674
|
// eslint-disable-next-line require-atomic-updates
|
|
1675
1675
|
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
@@ -1677,12 +1677,12 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1677
1677
|
}, (draftTxMeta) => {
|
|
1678
1678
|
const { chainId, txParams } = draftTxMeta;
|
|
1679
1679
|
const { gas, type } = txParams;
|
|
1680
|
-
draftTxMeta.status =
|
|
1680
|
+
draftTxMeta.status = types_1.TransactionStatus.approved;
|
|
1681
1681
|
draftTxMeta.txParams.chainId = chainId;
|
|
1682
1682
|
draftTxMeta.txParams.gasLimit = gas;
|
|
1683
1683
|
draftTxMeta.txParams.nonce = nonce;
|
|
1684
|
-
if (!type && (0,
|
|
1685
|
-
draftTxMeta.txParams.type =
|
|
1684
|
+
if (!type && (0, utils_2.isEIP1559Transaction)(txParams)) {
|
|
1685
|
+
draftTxMeta.txParams.type = types_1.TransactionEnvelopeType.feeMarket;
|
|
1686
1686
|
}
|
|
1687
1687
|
});
|
|
1688
1688
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, transactionMeta);
|
|
@@ -1690,7 +1690,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1690
1690
|
// eslint-disable-next-line require-atomic-updates
|
|
1691
1691
|
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
1692
1692
|
if (!(await __classPrivateFieldGet(this, _TransactionController_beforePublish, "f").call(this, transactionMeta))) {
|
|
1693
|
-
(0,
|
|
1693
|
+
(0, logger_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1694
1694
|
this.messenger.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
1695
1695
|
return ApprovalState.SkippedViaBeforePublishHook;
|
|
1696
1696
|
}
|
|
@@ -1698,17 +1698,17 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1698
1698
|
return ApprovalState.NotApproved;
|
|
1699
1699
|
}
|
|
1700
1700
|
let preTxBalance;
|
|
1701
|
-
const shouldUpdatePreTxBalance = transactionMeta.type ===
|
|
1701
|
+
const shouldUpdatePreTxBalance = transactionMeta.type === types_1.TransactionType.swap;
|
|
1702
1702
|
if (shouldUpdatePreTxBalance) {
|
|
1703
|
-
(0,
|
|
1704
|
-
preTxBalance = (await (0,
|
|
1703
|
+
(0, logger_1.projectLogger)('Determining pre-transaction balance');
|
|
1704
|
+
preTxBalance = (await (0, provider_1.rpcRequest)({
|
|
1705
1705
|
messenger: this.messenger,
|
|
1706
1706
|
networkClientId,
|
|
1707
1707
|
method: 'eth_getBalance',
|
|
1708
1708
|
params: [transactionMeta.txParams.from, 'latest'],
|
|
1709
1709
|
}));
|
|
1710
1710
|
}
|
|
1711
|
-
(0,
|
|
1711
|
+
(0, logger_1.projectLogger)('Publishing transaction', transactionMeta.txParams);
|
|
1712
1712
|
clearNonceLock?.();
|
|
1713
1713
|
clearNonceLock = undefined;
|
|
1714
1714
|
let publishHook = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_defaultPublishHook).bind(this, {
|
|
@@ -1717,8 +1717,8 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1717
1717
|
traceContext,
|
|
1718
1718
|
});
|
|
1719
1719
|
if (transactionMeta.batchTransactions?.length) {
|
|
1720
|
-
(0,
|
|
1721
|
-
const extraTransactionsPublishHook = new
|
|
1720
|
+
(0, logger_1.projectLogger)('Found batch transactions', transactionMeta.batchTransactions);
|
|
1721
|
+
const extraTransactionsPublishHook = new ExtraTransactionsPublishHook_1.ExtraTransactionsPublishHook({
|
|
1722
1722
|
addTransactionBatch: this.addTransactionBatch.bind(this),
|
|
1723
1723
|
getTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).bind(this),
|
|
1724
1724
|
originalPublishHook: publishHook,
|
|
@@ -1731,11 +1731,11 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1731
1731
|
transactionId,
|
|
1732
1732
|
}, (draftTxMeta) => {
|
|
1733
1733
|
draftTxMeta.hash = hash;
|
|
1734
|
-
draftTxMeta.status =
|
|
1734
|
+
draftTxMeta.status = types_1.TransactionStatus.submitted;
|
|
1735
1735
|
draftTxMeta.submittedTime ?? (draftTxMeta.submittedTime = new Date().getTime());
|
|
1736
1736
|
if (shouldUpdatePreTxBalance) {
|
|
1737
1737
|
draftTxMeta.preTxBalance = preTxBalance;
|
|
1738
|
-
(0,
|
|
1738
|
+
(0, logger_1.projectLogger)('Updated pre-transaction balance', preTxBalance);
|
|
1739
1739
|
}
|
|
1740
1740
|
});
|
|
1741
1741
|
this.messenger.publish(`${controllerName}:transactionSubmitted`, {
|
|
@@ -1761,7 +1761,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1761
1761
|
if (!rawTx) {
|
|
1762
1762
|
throw new Error('Missing raw transaction');
|
|
1763
1763
|
}
|
|
1764
|
-
const transactionHash = (await (0,
|
|
1764
|
+
const transactionHash = (await (0, provider_1.rpcRequest)({
|
|
1765
1765
|
messenger: this.messenger,
|
|
1766
1766
|
networkClientId,
|
|
1767
1767
|
method: 'eth_sendRawTransaction',
|
|
@@ -1779,8 +1779,8 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1779
1779
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_deleteTransaction).call(this, transactionId);
|
|
1780
1780
|
const updatedTransactionMeta = {
|
|
1781
1781
|
...transactionMeta,
|
|
1782
|
-
status:
|
|
1783
|
-
error: (0,
|
|
1782
|
+
status: types_1.TransactionStatus.rejected,
|
|
1783
|
+
error: (0, utils_2.normalizeTxError)(error ?? rpc_errors_1.providerErrors.userRejectedRequest()),
|
|
1784
1784
|
};
|
|
1785
1785
|
this.messenger.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1786
1786
|
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
@@ -1790,7 +1790,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1790
1790
|
});
|
|
1791
1791
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, updatedTransactionMeta);
|
|
1792
1792
|
}, _TransactionController_trimTransactionsForState = function _TransactionController_trimTransactionsForState(transactions) {
|
|
1793
|
-
const transactionHistoryLimit = (0,
|
|
1793
|
+
const transactionHistoryLimit = (0, feature_flags_1.getTransactionHistoryLimit)(this.messenger);
|
|
1794
1794
|
if (transactionHistoryLimit === undefined) {
|
|
1795
1795
|
return transactions;
|
|
1796
1796
|
}
|
|
@@ -1815,16 +1815,16 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1815
1815
|
txsToKeep.reverse(); // Ascending time order
|
|
1816
1816
|
return txsToKeep;
|
|
1817
1817
|
}, _TransactionController_isFinalState = function _TransactionController_isFinalState(status) {
|
|
1818
|
-
return (status ===
|
|
1819
|
-
status ===
|
|
1820
|
-
status ===
|
|
1821
|
-
status ===
|
|
1818
|
+
return (status === types_1.TransactionStatus.rejected ||
|
|
1819
|
+
status === types_1.TransactionStatus.confirmed ||
|
|
1820
|
+
status === types_1.TransactionStatus.failed ||
|
|
1821
|
+
status === types_1.TransactionStatus.dropped);
|
|
1822
1822
|
}, _TransactionController_isLocalFinalState = function _TransactionController_isLocalFinalState(status) {
|
|
1823
1823
|
return [
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1824
|
+
types_1.TransactionStatus.confirmed,
|
|
1825
|
+
types_1.TransactionStatus.failed,
|
|
1826
|
+
types_1.TransactionStatus.rejected,
|
|
1827
|
+
types_1.TransactionStatus.submitted,
|
|
1828
1828
|
].includes(status);
|
|
1829
1829
|
}, _TransactionController_requestApproval = async function _TransactionController_requestApproval(txMeta, { shouldShowRequest, traceContext, }) {
|
|
1830
1830
|
const id = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getApprovalId).call(this, txMeta);
|
|
@@ -1891,9 +1891,9 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1891
1891
|
const fromAddress = transactionMeta?.txParams?.from;
|
|
1892
1892
|
const sameFromAndNetworkTransactions = transactions.filter((transaction) => transaction.txParams.from === fromAddress &&
|
|
1893
1893
|
transaction.chainId === chainId);
|
|
1894
|
-
const confirmedTxs = sameFromAndNetworkTransactions.filter((transaction) => transaction.status ===
|
|
1895
|
-
const pendingTxs = sameFromAndNetworkTransactions.filter((transaction) => transaction.status ===
|
|
1896
|
-
(0,
|
|
1894
|
+
const confirmedTxs = sameFromAndNetworkTransactions.filter((transaction) => transaction.status === types_1.TransactionStatus.confirmed);
|
|
1895
|
+
const pendingTxs = sameFromAndNetworkTransactions.filter((transaction) => transaction.status === types_1.TransactionStatus.submitted);
|
|
1896
|
+
(0, external_transactions_1.validateConfirmedExternalTransaction)(transactionMeta, confirmedTxs, pendingTxs);
|
|
1897
1897
|
this.update((state) => {
|
|
1898
1898
|
state.transactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_trimTransactionsForState).call(this, [
|
|
1899
1899
|
...state.transactions,
|
|
@@ -1914,7 +1914,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1914
1914
|
nonce &&
|
|
1915
1915
|
transaction.txParams.nonce === nonce &&
|
|
1916
1916
|
transaction.chainId === chainId &&
|
|
1917
|
-
transaction.type !==
|
|
1917
|
+
transaction.type !== types_1.TransactionType.incoming &&
|
|
1918
1918
|
transaction.isTransfer === undefined);
|
|
1919
1919
|
const sameNonceTransactionIds = sameNonceTransactions.map((transaction) => transaction.id);
|
|
1920
1920
|
if (sameNonceTransactions.length === 0) {
|
|
@@ -1930,14 +1930,14 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1930
1930
|
});
|
|
1931
1931
|
for (const transaction of this.state.transactions) {
|
|
1932
1932
|
if (sameNonceTransactionIds.includes(transaction.id) &&
|
|
1933
|
-
transaction.status !==
|
|
1933
|
+
transaction.status !== types_1.TransactionStatus.failed) {
|
|
1934
1934
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_setTransactionStatusDropped).call(this, transaction);
|
|
1935
1935
|
}
|
|
1936
1936
|
}
|
|
1937
1937
|
}, _TransactionController_setTransactionStatusDropped = function _TransactionController_setTransactionStatusDropped(transactionMeta) {
|
|
1938
1938
|
const updatedTransactionMeta = {
|
|
1939
1939
|
...transactionMeta,
|
|
1940
|
-
status:
|
|
1940
|
+
status: types_1.TransactionStatus.dropped,
|
|
1941
1941
|
};
|
|
1942
1942
|
this.messenger.publish(`${controllerName}:transactionDropped`, {
|
|
1943
1943
|
transactionMeta: updatedTransactionMeta,
|
|
@@ -1965,15 +1965,15 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1965
1965
|
}, _TransactionController_signTransaction = async function _TransactionController_signTransaction(originalTransactionMeta) {
|
|
1966
1966
|
let transactionMeta = originalTransactionMeta;
|
|
1967
1967
|
const { id: transactionId } = transactionMeta;
|
|
1968
|
-
(0,
|
|
1968
|
+
(0, logger_1.projectLogger)('Calling before sign hook', transactionMeta);
|
|
1969
1969
|
const { updateTransaction } = (await __classPrivateFieldGet(this, _TransactionController_beforeSign, "f").call(this, { transactionMeta })) ?? {};
|
|
1970
1970
|
if (updateTransaction) {
|
|
1971
1971
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId, skipResimulateCheck: true }, updateTransaction);
|
|
1972
|
-
(0,
|
|
1972
|
+
(0, logger_1.projectLogger)('Updated transaction after before sign hook');
|
|
1973
1973
|
}
|
|
1974
1974
|
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
1975
1975
|
const { networkClientId } = transactionMeta;
|
|
1976
|
-
await (0,
|
|
1976
|
+
await (0, gas_fee_tokens_1.checkGasFeeTokenBeforePublish)({
|
|
1977
1977
|
messenger: this.messenger,
|
|
1978
1978
|
networkClientId,
|
|
1979
1979
|
fetchGasFeeTokens: async (tx) => (await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeTokens).call(this, tx)).gasFeeTokens,
|
|
@@ -1983,11 +1983,11 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
1983
1983
|
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
1984
1984
|
const { chainId, isExternalSign, txParams } = transactionMeta;
|
|
1985
1985
|
if (isExternalSign) {
|
|
1986
|
-
(0,
|
|
1986
|
+
(0, logger_1.projectLogger)('Skipping sign as signed externally');
|
|
1987
1987
|
return undefined;
|
|
1988
1988
|
}
|
|
1989
1989
|
const { authorizationList, from } = txParams;
|
|
1990
|
-
const signedAuthorizationList = await (0,
|
|
1990
|
+
const signedAuthorizationList = await (0, eip7702_1.signAuthorizationList)({
|
|
1991
1991
|
authorizationList,
|
|
1992
1992
|
messenger: this.messenger,
|
|
1993
1993
|
transactionMeta,
|
|
@@ -2000,9 +2000,9 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2000
2000
|
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
2001
2001
|
const finalTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
2002
2002
|
const { txParams: finalTxParams } = finalTransactionMeta;
|
|
2003
|
-
const unsignedEthTx = (0,
|
|
2003
|
+
const unsignedEthTx = (0, prepare_1.prepareTransaction)(chainId, finalTxParams);
|
|
2004
2004
|
__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").add(transactionId);
|
|
2005
|
-
(0,
|
|
2005
|
+
(0, logger_1.projectLogger)('Signing transaction', finalTxParams);
|
|
2006
2006
|
const signedTxData = await new Promise((resolve, reject) => {
|
|
2007
2007
|
// eslint-disable-next-line promise/catch-or-return
|
|
2008
2008
|
this.messenger
|
|
@@ -2014,12 +2014,12 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2014
2014
|
const transactionMetaFromHook = (0, lodash_1.cloneDeep)(finalTransactionMeta);
|
|
2015
2015
|
const transactionMetaWithRsv = {
|
|
2016
2016
|
...__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionMetaRSV).call(this, transactionMetaFromHook, signedTxData),
|
|
2017
|
-
status:
|
|
2017
|
+
status: types_1.TransactionStatus.signed,
|
|
2018
2018
|
txParams: finalTxParams,
|
|
2019
2019
|
};
|
|
2020
2020
|
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
2021
2021
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, transactionMetaWithRsv);
|
|
2022
|
-
const rawTx = (0,
|
|
2022
|
+
const rawTx = (0, prepare_1.serializeTransaction)(chainId, signedTxData);
|
|
2023
2023
|
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
2024
2024
|
rawTx,
|
|
2025
2025
|
});
|
|
@@ -2030,24 +2030,24 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2030
2030
|
transactionMeta,
|
|
2031
2031
|
});
|
|
2032
2032
|
}, _TransactionController_getNonceTrackerTransactions = function _TransactionController_getNonceTrackerTransactions(statuses, address, chainId) {
|
|
2033
|
-
return (0,
|
|
2033
|
+
return (0, nonce_1.getAndFormatTransactionsForNonceTracker)(chainId, address, statuses, this.state.transactions);
|
|
2034
2034
|
}, _TransactionController_onConfirmedTransaction = function _TransactionController_onConfirmedTransaction(transactionMeta) {
|
|
2035
|
-
(0,
|
|
2035
|
+
(0, logger_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
|
|
2036
2036
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_markNonceDuplicatesDropped).call(this, transactionMeta.id);
|
|
2037
2037
|
this.messenger.publish(`${controllerName}:transactionConfirmed`, transactionMeta);
|
|
2038
2038
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, transactionMeta);
|
|
2039
2039
|
// Intentional given potential duration of process.
|
|
2040
2040
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updatePostBalance).call(this, transactionMeta).catch((error) => {
|
|
2041
|
-
(0,
|
|
2041
|
+
(0, logger_1.projectLogger)('Error while updating post balance', error);
|
|
2042
2042
|
throw error;
|
|
2043
2043
|
});
|
|
2044
2044
|
}, _TransactionController_updatePostBalance = async function _TransactionController_updatePostBalance(transactionMeta) {
|
|
2045
2045
|
try {
|
|
2046
2046
|
const { networkClientId, type } = transactionMeta;
|
|
2047
|
-
if (type !==
|
|
2047
|
+
if (type !== types_1.TransactionType.swap) {
|
|
2048
2048
|
return;
|
|
2049
2049
|
}
|
|
2050
|
-
const { updatedTransactionMeta, approvalTransactionMeta } = await (0,
|
|
2050
|
+
const { updatedTransactionMeta, approvalTransactionMeta } = await (0, swaps_1.updatePostTransactionBalance)(transactionMeta, {
|
|
2051
2051
|
messenger: this.messenger,
|
|
2052
2052
|
networkClientId,
|
|
2053
2053
|
getTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).bind(this),
|
|
@@ -2060,7 +2060,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2060
2060
|
}
|
|
2061
2061
|
catch (error) {
|
|
2062
2062
|
/* istanbul ignore next */
|
|
2063
|
-
(0,
|
|
2063
|
+
(0, logger_1.projectLogger)('Error while updating post transaction balance', error);
|
|
2064
2064
|
}
|
|
2065
2065
|
}, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
|
|
2066
2066
|
return new nonce_tracker_1.NonceTracker({
|
|
@@ -2070,11 +2070,11 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2070
2070
|
// TODO: Fix types
|
|
2071
2071
|
blockTracker,
|
|
2072
2072
|
getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
|
|
2073
|
-
getConfirmedTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerTransactions).bind(this, [
|
|
2073
|
+
getConfirmedTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerTransactions).bind(this, [types_1.TransactionStatus.confirmed], chainId),
|
|
2074
2074
|
});
|
|
2075
2075
|
}, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ blockTracker, networkClientId, }) {
|
|
2076
|
-
const chainId = (0,
|
|
2077
|
-
const pendingTransactionTracker = new
|
|
2076
|
+
const chainId = (0, provider_1.getChainId)({ messenger: this.messenger, networkClientId });
|
|
2077
|
+
const pendingTransactionTracker = new PendingTransactionTracker_1.PendingTransactionTracker({
|
|
2078
2078
|
blockTracker,
|
|
2079
2079
|
getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
|
|
2080
2080
|
chainId,
|
|
@@ -2103,9 +2103,9 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2103
2103
|
pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
|
|
2104
2104
|
}, _TransactionController_getNonceTrackerPendingTransactions = function _TransactionController_getNonceTrackerPendingTransactions(chainId, address) {
|
|
2105
2105
|
const standardPendingTransactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerTransactions).call(this, [
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2106
|
+
types_1.TransactionStatus.approved,
|
|
2107
|
+
types_1.TransactionStatus.signed,
|
|
2108
|
+
types_1.TransactionStatus.submitted,
|
|
2109
2109
|
], address, chainId);
|
|
2110
2110
|
return standardPendingTransactions;
|
|
2111
2111
|
}, _TransactionController_publishTransactionForRetry = async function _TransactionController_publishTransactionForRetry(transactionMeta) {
|
|
@@ -2123,18 +2123,18 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2123
2123
|
Boolean(error?.data?.message?.includes('nonce too low')));
|
|
2124
2124
|
}, _TransactionController_getGasFeeFlows = function _TransactionController_getGasFeeFlows() {
|
|
2125
2125
|
if (__classPrivateFieldGet(this, _TransactionController_testGasFeeFlows, "f")) {
|
|
2126
|
-
return [new
|
|
2126
|
+
return [new TestGasFeeFlow_1.TestGasFeeFlow()];
|
|
2127
2127
|
}
|
|
2128
2128
|
return [
|
|
2129
|
-
new
|
|
2130
|
-
new
|
|
2131
|
-
new
|
|
2129
|
+
new RandomisedEstimationsGasFeeFlow_1.RandomisedEstimationsGasFeeFlow(),
|
|
2130
|
+
new LineaGasFeeFlow_1.LineaGasFeeFlow(),
|
|
2131
|
+
new DefaultGasFeeFlow_1.DefaultGasFeeFlow(),
|
|
2132
2132
|
];
|
|
2133
2133
|
}, _TransactionController_getLayer1GasFeeFlows = function _TransactionController_getLayer1GasFeeFlows() {
|
|
2134
2134
|
return [
|
|
2135
|
-
new
|
|
2136
|
-
new
|
|
2137
|
-
new
|
|
2135
|
+
new MantleLayer1GasFeeFlow_1.MantleLayer1GasFeeFlow(),
|
|
2136
|
+
new OptimismLayer1GasFeeFlow_1.OptimismLayer1GasFeeFlow(),
|
|
2137
|
+
new ScrollLayer1GasFeeFlow_1.ScrollLayer1GasFeeFlow(),
|
|
2138
2138
|
];
|
|
2139
2139
|
}, _TransactionController_updateTransactionInternal = function _TransactionController_updateTransactionInternal({ transactionId, skipValidation, skipResimulateCheck, }, callback) {
|
|
2140
2140
|
let resimulateResponse;
|
|
@@ -2147,11 +2147,11 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2147
2147
|
const originalTransactionMeta = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
2148
2148
|
transactionMeta = callback(transactionMeta) ?? transactionMeta;
|
|
2149
2149
|
if (skipValidation !== true) {
|
|
2150
|
-
transactionMeta.txParams = (0,
|
|
2151
|
-
(0,
|
|
2150
|
+
transactionMeta.txParams = (0, utils_2.normalizeTransactionParams)(transactionMeta.txParams);
|
|
2151
|
+
(0, validation_1.validateTxParams)(transactionMeta.txParams);
|
|
2152
2152
|
}
|
|
2153
2153
|
if (!skipResimulateCheck && __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this)) {
|
|
2154
|
-
resimulateResponse = (0,
|
|
2154
|
+
resimulateResponse = (0, ResimulateHelper_1.shouldResimulate)(originalTransactionMeta, transactionMeta);
|
|
2155
2155
|
}
|
|
2156
2156
|
state.transactions[index] = transactionMeta;
|
|
2157
2157
|
});
|
|
@@ -2160,19 +2160,19 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2160
2160
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).call(this, transactionMeta, {
|
|
2161
2161
|
blockTime: resimulateResponse.blockTime,
|
|
2162
2162
|
}).catch((error) => {
|
|
2163
|
-
(0,
|
|
2163
|
+
(0, logger_1.projectLogger)('Error during re-simulation', error);
|
|
2164
2164
|
throw error;
|
|
2165
2165
|
});
|
|
2166
2166
|
}
|
|
2167
2167
|
return transactionMeta;
|
|
2168
2168
|
}, _TransactionController_isBalanceChangesSkipped = function _TransactionController_isBalanceChangesSkipped(transactionMeta) {
|
|
2169
2169
|
return (__classPrivateFieldGet(this, _TransactionController_skipSimulationTransactionIds, "f").has(transactionMeta.id) ||
|
|
2170
|
-
transactionMeta.containerTypes?.includes(
|
|
2170
|
+
transactionMeta.containerTypes?.includes(types_1.TransactionContainerType.EnforcedSimulations) === true);
|
|
2171
2171
|
}, _TransactionController_updateSimulationData = async function _TransactionController_updateSimulationData(transactionMeta, { blockTime, traceContext, } = {}) {
|
|
2172
2172
|
const { chainId, id: transactionId, nestedTransactions, networkClientId, simulationData: prevSimulationData, txParams, } = transactionMeta;
|
|
2173
2173
|
let simulationData = {
|
|
2174
2174
|
error: {
|
|
2175
|
-
code:
|
|
2175
|
+
code: types_1.SimulationErrorCode.Disabled,
|
|
2176
2176
|
message: 'Simulation disabled',
|
|
2177
2177
|
},
|
|
2178
2178
|
tokenBalanceChanges: [],
|
|
@@ -2183,7 +2183,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2183
2183
|
let simulationRevert;
|
|
2184
2184
|
const isBalanceChangesSkipped = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isBalanceChangesSkipped).call(this, transactionMeta);
|
|
2185
2185
|
if (__classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this) && !isBalanceChangesSkipped) {
|
|
2186
|
-
const balanceChangesResult = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => (0,
|
|
2186
|
+
const balanceChangesResult = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => (0, balance_changes_1.getBalanceChanges)({
|
|
2187
2187
|
blockTime,
|
|
2188
2188
|
chainId,
|
|
2189
2189
|
messenger: this.messenger,
|
|
@@ -2202,7 +2202,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2202
2202
|
simulationRevert = balanceChangesResult.simulationRevert;
|
|
2203
2203
|
if (blockTime &&
|
|
2204
2204
|
prevSimulationData &&
|
|
2205
|
-
(0,
|
|
2205
|
+
(0, ResimulateHelper_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
|
|
2206
2206
|
simulationData = {
|
|
2207
2207
|
...simulationData,
|
|
2208
2208
|
isUpdatedAfterSecurityCheck: true,
|
|
@@ -2215,7 +2215,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2215
2215
|
const latestTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
2216
2216
|
/* istanbul ignore if */
|
|
2217
2217
|
if (!latestTransactionMeta) {
|
|
2218
|
-
(0,
|
|
2218
|
+
(0, logger_1.projectLogger)('Cannot update simulation data as transaction not found', transactionId, simulationData);
|
|
2219
2219
|
return;
|
|
2220
2220
|
}
|
|
2221
2221
|
const updatedTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
@@ -2239,10 +2239,10 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2239
2239
|
}
|
|
2240
2240
|
}
|
|
2241
2241
|
});
|
|
2242
|
-
(0,
|
|
2242
|
+
(0, logger_1.projectLogger)('Updated simulation data', transactionId, updatedTransactionMeta);
|
|
2243
2243
|
}, _TransactionController_onGasFeePollerTransactionUpdate = function _TransactionController_onGasFeePollerTransactionUpdate({ transactionId, gasFeeEstimates, gasFeeEstimatesLoaded, layer1GasFee, }) {
|
|
2244
2244
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (txMeta) => {
|
|
2245
|
-
(0,
|
|
2245
|
+
(0, GasFeePoller_1.updateTransactionGasProperties)({
|
|
2246
2246
|
txMeta,
|
|
2247
2247
|
gasFeeEstimates,
|
|
2248
2248
|
gasFeeEstimatesLoaded,
|
|
@@ -2286,8 +2286,8 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2286
2286
|
time: Date.now(),
|
|
2287
2287
|
transaction: txParams,
|
|
2288
2288
|
};
|
|
2289
|
-
(0,
|
|
2290
|
-
const submitHistoryLimit = (0,
|
|
2289
|
+
(0, logger_1.projectLogger)('Updating submit history', submitHistoryEntry);
|
|
2290
|
+
const submitHistoryLimit = (0, feature_flags_1.getSubmitHistoryLimit)(this.messenger);
|
|
2291
2291
|
this.update((state) => {
|
|
2292
2292
|
const { submitHistory } = state;
|
|
2293
2293
|
if (submitHistory.length >= submitHistoryLimit) {
|
|
@@ -2299,7 +2299,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2299
2299
|
const { networkClientId } = transactionMeta;
|
|
2300
2300
|
const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
|
|
2301
2301
|
.configuration.type === network_controller_1.NetworkClientType.Custom;
|
|
2302
|
-
await (0,
|
|
2302
|
+
await (0, gas_1.updateGas)({
|
|
2303
2303
|
isCustomNetwork,
|
|
2304
2304
|
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
|
|
2305
2305
|
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
@@ -2316,7 +2316,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2316
2316
|
}, _TransactionController_isRejectError = function _TransactionController_isRejectError(error) {
|
|
2317
2317
|
return [
|
|
2318
2318
|
rpc_errors_1.errorCodes.provider.userRejectedRequest,
|
|
2319
|
-
|
|
2319
|
+
validation_1.ErrorCode.RejectedUpgrade,
|
|
2320
2320
|
].includes(error.code);
|
|
2321
2321
|
}, _TransactionController_rejectTransactionAndThrow = function _TransactionController_rejectTransactionAndThrow(transactionId, actionId, error) {
|
|
2322
2322
|
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_rejectTransaction).call(this, transactionId, actionId, error);
|
|
@@ -2335,8 +2335,8 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2335
2335
|
transactionId: transactionMeta.id,
|
|
2336
2336
|
skipValidation: true,
|
|
2337
2337
|
}, (draftTransactionMeta) => {
|
|
2338
|
-
draftTransactionMeta.status =
|
|
2339
|
-
draftTransactionMeta.error = (0,
|
|
2338
|
+
draftTransactionMeta.status = types_1.TransactionStatus.failed;
|
|
2339
|
+
draftTransactionMeta.error = (0, utils_2.normalizeTxError)(error);
|
|
2340
2340
|
if (receiptRevert === undefined) {
|
|
2341
2341
|
return;
|
|
2342
2342
|
}
|
|
@@ -2347,11 +2347,11 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2347
2347
|
});
|
|
2348
2348
|
}
|
|
2349
2349
|
catch (caughtError) {
|
|
2350
|
-
(0,
|
|
2350
|
+
(0, logger_1.projectLogger)('Failed to mark transaction as failed', caughtError);
|
|
2351
2351
|
newTransactionMeta = {
|
|
2352
2352
|
...transactionMeta,
|
|
2353
|
-
status:
|
|
2354
|
-
error: (0,
|
|
2353
|
+
status: types_1.TransactionStatus.failed,
|
|
2354
|
+
error: (0, utils_2.normalizeTxError)(error),
|
|
2355
2355
|
...(receiptRevert === undefined
|
|
2356
2356
|
? {}
|
|
2357
2357
|
: {
|
|
@@ -2382,11 +2382,11 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
|
|
|
2382
2382
|
rawTx: signedTx,
|
|
2383
2383
|
}));
|
|
2384
2384
|
});
|
|
2385
|
-
(0,
|
|
2385
|
+
(0, logger_1.projectLogger)('Publish successful', transactionHash);
|
|
2386
2386
|
return { transactionHash };
|
|
2387
2387
|
}, _TransactionController_getGasFeeTokens = async function _TransactionController_getGasFeeTokens(transaction) {
|
|
2388
2388
|
const { chainId } = transaction;
|
|
2389
|
-
return await (0,
|
|
2389
|
+
return await (0, gas_fee_tokens_1.getGasFeeTokens)({
|
|
2390
2390
|
chainId,
|
|
2391
2391
|
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
2392
2392
|
isEIP7702GasFeeTokensEnabled: __classPrivateFieldGet(this, _TransactionController_isEIP7702GasFeeTokensEnabled, "f"),
|