@metamask-previews/transaction-controller 69.6.1-preview-4f4c98e → 69.6.1-preview-eb263b0ee
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 -5
- package/dist/TransactionController-method-action-types.cjs +7 -0
- package/dist/TransactionController-method-action-types.cjs.map +1 -0
- package/dist/{TransactionController-method-action-types.d.ts → TransactionController-method-action-types.d.cts} +2 -2
- package/dist/TransactionController-method-action-types.d.cts.map +1 -0
- package/dist/TransactionController-method-action-types.d.mts +413 -0
- package/dist/TransactionController-method-action-types.d.mts.map +1 -0
- package/dist/{TransactionController-method-action-types.js → TransactionController-method-action-types.mjs} +1 -1
- package/dist/TransactionController-method-action-types.mjs.map +1 -0
- package/dist/TransactionController.cjs +2444 -0
- package/dist/TransactionController.cjs.map +1 -0
- package/dist/{TransactionController.d.ts → TransactionController.d.cts} +18 -18
- package/dist/TransactionController.d.cts.map +1 -0
- package/dist/TransactionController.d.mts +751 -0
- package/dist/TransactionController.d.mts.map +1 -0
- package/dist/{TransactionController.js → TransactionController.mjs} +50 -49
- package/dist/TransactionController.mjs.map +1 -0
- package/dist/api/accounts-api.cjs +57 -0
- package/dist/api/accounts-api.cjs.map +1 -0
- package/dist/api/{accounts-api.d.ts → accounts-api.d.cts} +1 -1
- package/dist/api/accounts-api.d.cts.map +1 -0
- package/dist/api/accounts-api.d.mts +44 -0
- package/dist/api/accounts-api.d.mts.map +1 -0
- package/dist/api/{accounts-api.js → accounts-api.mjs} +5 -5
- package/dist/api/accounts-api.mjs.map +1 -0
- package/dist/api/simulation-api.cjs +116 -0
- package/dist/api/simulation-api.cjs.map +1 -0
- package/dist/api/{simulation-api.d.ts → simulation-api.d.cts} +3 -3
- package/dist/api/simulation-api.d.cts.map +1 -0
- package/dist/api/simulation-api.d.mts +196 -0
- package/dist/api/simulation-api.d.mts.map +1 -0
- package/dist/api/{simulation-api.js → simulation-api.mjs} +8 -7
- package/dist/api/simulation-api.mjs.map +1 -0
- package/dist/constants.cjs +111 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{constants.d.ts → constants.d.cts} +37 -37
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +78 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/{constants.js → constants.mjs} +1 -1
- package/dist/constants.mjs.map +1 -0
- package/dist/errors.cjs +37 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{errors.d.ts → errors.d.cts} +2 -2
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +19 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/{errors.js → errors.mjs} +2 -2
- package/dist/errors.mjs.map +1 -0
- package/dist/gas-flows/DefaultGasFeeFlow.cjs +85 -0
- package/dist/gas-flows/{DefaultGasFeeFlow.js.map → DefaultGasFeeFlow.cjs.map} +1 -1
- package/dist/gas-flows/{DefaultGasFeeFlow.d.ts → DefaultGasFeeFlow.d.cts} +2 -2
- package/dist/gas-flows/DefaultGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/DefaultGasFeeFlow.d.mts +10 -0
- package/dist/gas-flows/DefaultGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{DefaultGasFeeFlow.js → DefaultGasFeeFlow.mjs} +6 -6
- package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/LineaGasFeeFlow.cjs +111 -0
- package/dist/gas-flows/LineaGasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{LineaGasFeeFlow.d.ts → LineaGasFeeFlow.d.cts} +3 -3
- package/dist/gas-flows/LineaGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/LineaGasFeeFlow.d.mts +16 -0
- package/dist/gas-flows/LineaGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{LineaGasFeeFlow.js → LineaGasFeeFlow.mjs} +7 -7
- package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/MantleLayer1GasFeeFlow.cjs +66 -0
- package/dist/gas-flows/MantleLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{MantleLayer1GasFeeFlow.d.ts → MantleLayer1GasFeeFlow.d.cts} +5 -5
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.mts +21 -0
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{MantleLayer1GasFeeFlow.js → MantleLayer1GasFeeFlow.mjs} +6 -6
- package/dist/gas-flows/MantleLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +59 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{OptimismLayer1GasFeeFlow.d.ts → OptimismLayer1GasFeeFlow.d.cts} +4 -4
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts +14 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{OptimismLayer1GasFeeFlow.js → OptimismLayer1GasFeeFlow.mjs} +5 -5
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +201 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{OracleLayer1GasFeeFlow.d.ts → OracleLayer1GasFeeFlow.d.cts} +5 -5
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts +57 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{OracleLayer1GasFeeFlow.js → OracleLayer1GasFeeFlow.mjs} +15 -8
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs +123 -0
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{RandomisedEstimationsGasFeeFlow.d.ts → RandomisedEstimationsGasFeeFlow.d.cts} +4 -4
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts +28 -0
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{RandomisedEstimationsGasFeeFlow.js → RandomisedEstimationsGasFeeFlow.mjs} +8 -8
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +24 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{ScrollLayer1GasFeeFlow.d.ts → ScrollLayer1GasFeeFlow.d.cts} +5 -5
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts +16 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{ScrollLayer1GasFeeFlow.js → ScrollLayer1GasFeeFlow.mjs} +3 -3
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/TestGasFeeFlow.cjs +73 -0
- package/dist/gas-flows/TestGasFeeFlow.cjs.map +1 -0
- package/dist/gas-flows/{TestGasFeeFlow.d.ts → TestGasFeeFlow.d.cts} +2 -2
- package/dist/gas-flows/TestGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/TestGasFeeFlow.d.mts +12 -0
- package/dist/gas-flows/TestGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/{TestGasFeeFlow.js → TestGasFeeFlow.mjs} +3 -3
- package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -0
- package/dist/helpers/GasFeePoller.cjs +334 -0
- package/dist/helpers/GasFeePoller.cjs.map +1 -0
- package/dist/helpers/{GasFeePoller.d.ts → GasFeePoller.d.cts} +10 -7
- package/dist/helpers/GasFeePoller.d.cts.map +1 -0
- package/dist/helpers/GasFeePoller.d.mts +66 -0
- package/dist/helpers/GasFeePoller.d.mts.map +1 -0
- package/dist/helpers/{GasFeePoller.js → GasFeePoller.mjs} +9 -9
- package/dist/helpers/GasFeePoller.mjs.map +1 -0
- package/dist/helpers/MethodDataHelper.cjs +84 -0
- package/dist/helpers/MethodDataHelper.cjs.map +1 -0
- package/dist/helpers/{MethodDataHelper.d.ts → MethodDataHelper.d.cts} +7 -4
- package/dist/helpers/MethodDataHelper.d.cts.map +1 -0
- package/dist/helpers/MethodDataHelper.d.mts +16 -0
- package/dist/helpers/MethodDataHelper.d.mts.map +1 -0
- package/dist/helpers/{MethodDataHelper.js → MethodDataHelper.mjs} +7 -7
- package/dist/helpers/MethodDataHelper.mjs.map +1 -0
- package/dist/helpers/MultichainTrackingHelper.cjs +231 -0
- package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -0
- package/dist/helpers/{MultichainTrackingHelper.d.ts → MultichainTrackingHelper.d.cts} +5 -5
- package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -0
- package/dist/helpers/MultichainTrackingHelper.d.mts +56 -0
- package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -0
- package/dist/helpers/{MultichainTrackingHelper.js → MultichainTrackingHelper.mjs} +8 -8
- package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -0
- package/dist/helpers/PendingTransactionTracker.cjs +407 -0
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -0
- package/dist/helpers/{PendingTransactionTracker.d.ts → PendingTransactionTracker.d.cts} +8 -5
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -0
- package/dist/helpers/PendingTransactionTracker.d.mts +54 -0
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -0
- package/dist/helpers/{PendingTransactionTracker.js → PendingTransactionTracker.mjs} +15 -14
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -0
- package/dist/helpers/ResimulateHelper.cjs +274 -0
- package/dist/helpers/ResimulateHelper.cjs.map +1 -0
- package/dist/helpers/{ResimulateHelper.d.ts → ResimulateHelper.d.cts} +3 -3
- package/dist/helpers/ResimulateHelper.d.cts.map +1 -0
- package/dist/helpers/ResimulateHelper.d.mts +36 -0
- package/dist/helpers/ResimulateHelper.d.mts.map +1 -0
- package/dist/helpers/{ResimulateHelper.js → ResimulateHelper.mjs} +8 -7
- package/dist/helpers/ResimulateHelper.mjs.map +1 -0
- package/dist/helpers/TransactionPoller.cjs +175 -0
- package/dist/helpers/TransactionPoller.cjs.map +1 -0
- package/dist/helpers/{TransactionPoller.d.ts → TransactionPoller.d.cts} +5 -5
- package/dist/helpers/TransactionPoller.d.cts.map +1 -0
- package/dist/helpers/TransactionPoller.d.mts +37 -0
- package/dist/helpers/TransactionPoller.d.mts.map +1 -0
- package/dist/helpers/{TransactionPoller.js → TransactionPoller.mjs} +11 -10
- package/dist/helpers/TransactionPoller.mjs.map +1 -0
- package/dist/hooks/CollectPublishHook.cjs +94 -0
- package/dist/hooks/CollectPublishHook.cjs.map +1 -0
- package/dist/hooks/{CollectPublishHook.d.ts → CollectPublishHook.d.cts} +3 -3
- package/dist/hooks/CollectPublishHook.d.cts.map +1 -0
- package/dist/hooks/CollectPublishHook.d.mts +29 -0
- package/dist/hooks/CollectPublishHook.d.mts.map +1 -0
- package/dist/hooks/{CollectPublishHook.js → CollectPublishHook.mjs} +5 -4
- package/dist/hooks/CollectPublishHook.mjs.map +1 -0
- package/dist/hooks/ExtraTransactionsPublishHook.cjs +126 -0
- package/dist/hooks/ExtraTransactionsPublishHook.cjs.map +1 -0
- package/dist/hooks/{ExtraTransactionsPublishHook.d.ts → ExtraTransactionsPublishHook.d.cts} +3 -3
- package/dist/hooks/ExtraTransactionsPublishHook.d.cts.map +1 -0
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts +19 -0
- package/dist/hooks/ExtraTransactionsPublishHook.d.mts.map +1 -0
- package/dist/hooks/{ExtraTransactionsPublishHook.js → ExtraTransactionsPublishHook.mjs} +3 -3
- package/dist/hooks/ExtraTransactionsPublishHook.mjs.map +1 -0
- package/dist/hooks/SequentialPublishBatchHook.cjs +112 -0
- package/dist/hooks/SequentialPublishBatchHook.cjs.map +1 -0
- package/dist/hooks/{SequentialPublishBatchHook.d.ts → SequentialPublishBatchHook.d.cts} +4 -4
- package/dist/hooks/SequentialPublishBatchHook.d.cts.map +1 -0
- package/dist/hooks/SequentialPublishBatchHook.d.mts +22 -0
- package/dist/hooks/SequentialPublishBatchHook.d.mts.map +1 -0
- package/dist/hooks/{SequentialPublishBatchHook.js → SequentialPublishBatchHook.mjs} +4 -4
- package/dist/hooks/SequentialPublishBatchHook.mjs.map +1 -0
- package/dist/index.cjs +40 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.ts → index.d.cts} +16 -16
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger.cjs +9 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/{logger.d.ts → logger.d.cts} +3 -2
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +6 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/{logger.js → logger.mjs} +2 -2
- package/dist/logger.mjs.map +1 -0
- package/dist/types.cjs +382 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +8 -8
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +1887 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/{types.js → types.mjs} +1 -1
- package/dist/types.mjs.map +1 -0
- package/dist/utils/balance-changes.cjs +592 -0
- package/dist/utils/balance-changes.cjs.map +1 -0
- package/dist/utils/{balance-changes.d.ts → balance-changes.d.cts} +5 -5
- package/dist/utils/balance-changes.d.cts.map +1 -0
- package/dist/utils/balance-changes.d.mts +38 -0
- package/dist/utils/balance-changes.d.mts.map +1 -0
- package/dist/utils/{balance-changes.js → balance-changes.mjs} +20 -13
- package/dist/utils/balance-changes.mjs.map +1 -0
- package/dist/utils/balance.cjs +44 -0
- package/dist/utils/balance.cjs.map +1 -0
- package/dist/utils/{balance.d.ts → balance.d.cts} +5 -5
- package/dist/utils/balance.d.cts.map +1 -0
- package/dist/utils/balance.d.mts +26 -0
- package/dist/utils/balance.d.mts.map +1 -0
- package/dist/utils/{balance.js → balance.mjs} +3 -3
- package/dist/utils/balance.mjs.map +1 -0
- package/dist/utils/batch.cjs +712 -0
- package/dist/utils/batch.cjs.map +1 -0
- package/dist/utils/{batch.d.ts → batch.d.cts} +8 -8
- package/dist/utils/batch.d.cts.map +1 -0
- package/dist/utils/batch.d.mts +58 -0
- package/dist/utils/batch.d.mts.map +1 -0
- package/dist/utils/{batch.js → batch.mjs} +18 -18
- package/dist/utils/batch.mjs.map +1 -0
- package/dist/utils/eip7702.cjs +354 -0
- package/dist/utils/eip7702.cjs.map +1 -0
- package/dist/utils/{eip7702.d.ts → eip7702.d.cts} +5 -5
- package/dist/utils/eip7702.d.cts.map +1 -0
- package/dist/utils/eip7702.d.mts +137 -0
- package/dist/utils/eip7702.d.mts.map +1 -0
- package/dist/utils/{eip7702.js → eip7702.mjs} +12 -12
- package/dist/utils/eip7702.mjs.map +1 -0
- package/dist/utils/external-transactions.cjs +36 -0
- package/dist/utils/external-transactions.cjs.map +1 -0
- package/dist/utils/{external-transactions.d.ts → external-transactions.d.cts} +2 -2
- package/dist/utils/external-transactions.d.cts.map +1 -0
- package/dist/utils/external-transactions.d.mts +10 -0
- package/dist/utils/external-transactions.d.mts.map +1 -0
- package/dist/utils/{external-transactions.js → external-transactions.mjs} +3 -3
- package/dist/utils/external-transactions.mjs.map +1 -0
- package/dist/utils/feature-flags.cjs +255 -0
- package/dist/utils/feature-flags.cjs.map +1 -0
- package/dist/utils/{feature-flags.d.ts → feature-flags.d.cts} +3 -3
- package/dist/utils/feature-flags.d.cts.map +1 -0
- package/dist/utils/feature-flags.d.mts +313 -0
- package/dist/utils/feature-flags.d.mts.map +1 -0
- package/dist/utils/{feature-flags.js → feature-flags.mjs} +5 -5
- package/dist/utils/feature-flags.mjs.map +1 -0
- package/dist/utils/first-time-interaction.cjs +69 -0
- package/dist/utils/first-time-interaction.cjs.map +1 -0
- package/dist/utils/{first-time-interaction.d.ts → first-time-interaction.d.cts} +3 -3
- package/dist/utils/first-time-interaction.d.cts.map +1 -0
- package/dist/utils/first-time-interaction.d.mts +30 -0
- package/dist/utils/first-time-interaction.d.mts.map +1 -0
- package/dist/utils/{first-time-interaction.js → first-time-interaction.mjs} +6 -6
- package/dist/utils/first-time-interaction.mjs.map +1 -0
- package/dist/utils/gas-fee-tokens.cjs +174 -0
- package/dist/utils/gas-fee-tokens.cjs.map +1 -0
- package/dist/utils/{gas-fee-tokens.d.ts → gas-fee-tokens.d.cts} +5 -5
- package/dist/utils/gas-fee-tokens.d.cts.map +1 -0
- package/dist/utils/gas-fee-tokens.d.mts +46 -0
- package/dist/utils/gas-fee-tokens.d.mts.map +1 -0
- package/dist/utils/{gas-fee-tokens.js → gas-fee-tokens.mjs} +9 -9
- package/dist/utils/gas-fee-tokens.mjs.map +1 -0
- package/dist/utils/gas-fees.cjs +424 -0
- package/dist/utils/gas-fees.cjs.map +1 -0
- package/dist/utils/{gas-fees.d.ts → gas-fees.d.cts} +5 -5
- package/dist/utils/gas-fees.d.cts.map +1 -0
- package/dist/utils/gas-fees.d.mts +57 -0
- package/dist/utils/gas-fees.d.mts.map +1 -0
- package/dist/utils/{gas-fees.js → gas-fees.mjs} +9 -9
- package/dist/utils/gas-fees.mjs.map +1 -0
- package/dist/utils/gas-flow.cjs +81 -0
- package/dist/utils/gas-flow.cjs.map +1 -0
- package/dist/utils/{gas-flow.d.ts → gas-flow.d.cts} +6 -6
- package/dist/utils/gas-flow.d.cts.map +1 -0
- package/dist/utils/gas-flow.d.mts +29 -0
- package/dist/utils/gas-flow.d.mts.map +1 -0
- package/dist/utils/{gas-flow.js → gas-flow.mjs} +3 -3
- package/dist/utils/gas-flow.mjs.map +1 -0
- package/dist/utils/gas.cjs +545 -0
- package/dist/utils/gas.cjs.map +1 -0
- package/dist/utils/{gas.d.ts → gas.d.cts} +6 -5
- package/dist/utils/gas.d.cts.map +1 -0
- package/dist/utils/gas.d.mts +116 -0
- package/dist/utils/gas.d.mts.map +1 -0
- package/dist/utils/{gas.js → gas.mjs} +11 -11
- package/dist/utils/gas.mjs.map +1 -0
- package/dist/utils/layer1-gas-fee-flow.cjs +73 -0
- package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -0
- package/dist/utils/{layer1-gas-fee-flow.d.ts → layer1-gas-fee-flow.d.cts} +4 -4
- package/dist/utils/layer1-gas-fee-flow.d.cts.map +1 -0
- package/dist/utils/layer1-gas-fee-flow.d.mts +28 -0
- package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -0
- package/dist/utils/{layer1-gas-fee-flow.js → layer1-gas-fee-flow.mjs} +3 -3
- package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -0
- package/dist/utils/nonce.cjs +93 -0
- package/dist/utils/nonce.cjs.map +1 -0
- package/dist/utils/{nonce.d.ts → nonce.d.cts} +3 -3
- package/dist/utils/nonce.d.cts.map +1 -0
- package/dist/utils/nonce.d.mts +26 -0
- package/dist/utils/nonce.d.mts.map +1 -0
- package/dist/utils/{nonce.js → nonce.mjs} +4 -4
- package/dist/utils/nonce.mjs.map +1 -0
- package/dist/utils/prepare.cjs +97 -0
- package/dist/utils/prepare.cjs.map +1 -0
- package/dist/utils/{prepare.d.ts → prepare.d.cts} +5 -5
- package/dist/utils/prepare.d.cts.map +1 -0
- package/dist/utils/prepare.d.mts +22 -0
- package/dist/utils/prepare.d.mts.map +1 -0
- package/dist/utils/{prepare.js → prepare.mjs} +6 -5
- package/dist/utils/prepare.mjs.map +1 -0
- package/dist/utils/provider.cjs +106 -0
- package/dist/utils/provider.cjs.map +1 -0
- package/dist/utils/{provider.d.ts → provider.d.cts} +4 -4
- package/dist/utils/provider.d.cts.map +1 -0
- package/dist/utils/provider.d.mts +65 -0
- package/dist/utils/provider.d.mts.map +1 -0
- package/dist/utils/{provider.js → provider.mjs} +3 -3
- package/dist/utils/provider.mjs.map +1 -0
- package/dist/utils/recipient.cjs +31 -0
- package/dist/utils/recipient.cjs.map +1 -0
- package/dist/utils/{recipient.d.ts → recipient.d.cts} +2 -2
- package/dist/utils/recipient.d.cts.map +1 -0
- package/dist/utils/recipient.d.mts +13 -0
- package/dist/utils/recipient.d.mts.map +1 -0
- package/dist/utils/{recipient.js → recipient.mjs} +3 -3
- package/dist/utils/recipient.mjs.map +1 -0
- package/dist/utils/retry.cjs +93 -0
- package/dist/utils/retry.cjs.map +1 -0
- package/dist/utils/{retry.d.ts → retry.d.cts} +2 -2
- package/dist/utils/retry.d.cts.map +1 -0
- package/dist/utils/retry.d.mts +11 -0
- package/dist/utils/retry.d.mts.map +1 -0
- package/dist/utils/{retry.js → retry.mjs} +3 -3
- package/dist/utils/retry.mjs.map +1 -0
- package/dist/utils/revert-reason.cjs +192 -0
- package/dist/utils/revert-reason.cjs.map +1 -0
- package/dist/utils/{revert-reason.d.ts → revert-reason.d.cts} +5 -5
- package/dist/utils/revert-reason.d.cts.map +1 -0
- package/dist/utils/revert-reason.d.mts +57 -0
- package/dist/utils/revert-reason.d.mts.map +1 -0
- package/dist/utils/{revert-reason.js → revert-reason.mjs} +4 -4
- package/dist/utils/revert-reason.mjs.map +1 -0
- package/dist/utils/signature.cjs +26 -0
- package/dist/utils/signature.cjs.map +1 -0
- package/dist/utils/{signature.d.ts → signature.d.cts} +2 -2
- package/dist/utils/signature.d.cts.map +1 -0
- package/dist/utils/signature.d.mts +11 -0
- package/dist/utils/signature.d.mts.map +1 -0
- package/dist/utils/{signature.js → signature.mjs} +3 -3
- package/dist/utils/signature.mjs.map +1 -0
- package/dist/utils/swaps.cjs +332 -0
- package/dist/utils/swaps.cjs.map +1 -0
- package/dist/utils/{swaps.d.ts → swaps.d.cts} +5 -5
- package/dist/utils/swaps.d.cts.map +1 -0
- package/dist/utils/swaps.d.mts +90 -0
- package/dist/utils/swaps.d.mts.map +1 -0
- package/dist/utils/{swaps.js → swaps.mjs} +8 -7
- package/dist/utils/swaps.mjs.map +1 -0
- package/dist/utils/transaction-type.cjs +159 -0
- package/dist/utils/transaction-type.cjs.map +1 -0
- package/dist/utils/{transaction-type.d.ts → transaction-type.d.cts} +6 -6
- package/dist/utils/transaction-type.d.cts.map +1 -0
- package/dist/utils/transaction-type.d.mts +44 -0
- package/dist/utils/transaction-type.d.mts.map +1 -0
- package/dist/utils/{transaction-type.js → transaction-type.mjs} +6 -6
- package/dist/utils/transaction-type.mjs.map +1 -0
- package/dist/utils/utils.cjs +287 -0
- package/dist/utils/utils.cjs.map +1 -0
- package/dist/utils/{utils.d.ts → utils.d.cts} +4 -4
- package/dist/utils/utils.d.cts.map +1 -0
- package/dist/utils/utils.d.mts +101 -0
- package/dist/utils/utils.d.mts.map +1 -0
- package/dist/utils/{utils.js → utils.mjs} +12 -5
- package/dist/utils/utils.mjs.map +1 -0
- package/dist/utils/validation.cjs +389 -0
- package/dist/utils/validation.cjs.map +1 -0
- package/dist/utils/{validation.d.ts → validation.d.cts} +4 -4
- package/dist/utils/validation.d.cts.map +1 -0
- package/dist/utils/validation.d.mts +66 -0
- package/dist/utils/validation.d.mts.map +1 -0
- package/dist/utils/{validation.js → validation.mjs} +8 -8
- package/dist/utils/validation.mjs.map +1 -0
- package/package.json +19 -15
- package/dist/TransactionController-method-action-types.d.ts.map +0 -1
- package/dist/TransactionController-method-action-types.js.map +0 -1
- package/dist/TransactionController.d.ts.map +0 -1
- package/dist/TransactionController.js.map +0 -1
- package/dist/api/accounts-api.d.ts.map +0 -1
- package/dist/api/accounts-api.js.map +0 -1
- package/dist/api/simulation-api.d.ts.map +0 -1
- package/dist/api/simulation-api.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/gas-flows/DefaultGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/LineaGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/LineaGasFeeFlow.js.map +0 -1
- package/dist/gas-flows/MantleLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/MantleLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/RandomisedEstimationsGasFeeFlow.js.map +0 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/TestGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/TestGasFeeFlow.js.map +0 -1
- package/dist/helpers/GasFeePoller.d.ts.map +0 -1
- package/dist/helpers/GasFeePoller.js.map +0 -1
- package/dist/helpers/MethodDataHelper.d.ts.map +0 -1
- package/dist/helpers/MethodDataHelper.js.map +0 -1
- package/dist/helpers/MultichainTrackingHelper.d.ts.map +0 -1
- package/dist/helpers/MultichainTrackingHelper.js.map +0 -1
- package/dist/helpers/PendingTransactionTracker.d.ts.map +0 -1
- package/dist/helpers/PendingTransactionTracker.js.map +0 -1
- package/dist/helpers/ResimulateHelper.d.ts.map +0 -1
- package/dist/helpers/ResimulateHelper.js.map +0 -1
- package/dist/helpers/TransactionPoller.d.ts.map +0 -1
- package/dist/helpers/TransactionPoller.js.map +0 -1
- package/dist/hooks/CollectPublishHook.d.ts.map +0 -1
- package/dist/hooks/CollectPublishHook.js.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.d.ts.map +0 -1
- package/dist/hooks/ExtraTransactionsPublishHook.js.map +0 -1
- package/dist/hooks/SequentialPublishBatchHook.d.ts.map +0 -1
- package/dist/hooks/SequentialPublishBatchHook.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/balance-changes.d.ts.map +0 -1
- package/dist/utils/balance-changes.js.map +0 -1
- package/dist/utils/balance.d.ts.map +0 -1
- package/dist/utils/balance.js.map +0 -1
- package/dist/utils/batch.d.ts.map +0 -1
- package/dist/utils/batch.js.map +0 -1
- package/dist/utils/eip7702.d.ts.map +0 -1
- package/dist/utils/eip7702.js.map +0 -1
- package/dist/utils/external-transactions.d.ts.map +0 -1
- package/dist/utils/external-transactions.js.map +0 -1
- package/dist/utils/feature-flags.d.ts.map +0 -1
- package/dist/utils/feature-flags.js.map +0 -1
- package/dist/utils/first-time-interaction.d.ts.map +0 -1
- package/dist/utils/first-time-interaction.js.map +0 -1
- package/dist/utils/gas-fee-tokens.d.ts.map +0 -1
- package/dist/utils/gas-fee-tokens.js.map +0 -1
- package/dist/utils/gas-fees.d.ts.map +0 -1
- package/dist/utils/gas-fees.js.map +0 -1
- package/dist/utils/gas-flow.d.ts.map +0 -1
- package/dist/utils/gas-flow.js.map +0 -1
- package/dist/utils/gas.d.ts.map +0 -1
- package/dist/utils/gas.js.map +0 -1
- package/dist/utils/layer1-gas-fee-flow.d.ts.map +0 -1
- package/dist/utils/layer1-gas-fee-flow.js.map +0 -1
- package/dist/utils/nonce.d.ts.map +0 -1
- package/dist/utils/nonce.js.map +0 -1
- package/dist/utils/prepare.d.ts.map +0 -1
- package/dist/utils/prepare.js.map +0 -1
- package/dist/utils/provider.d.ts.map +0 -1
- package/dist/utils/provider.js.map +0 -1
- package/dist/utils/recipient.d.ts.map +0 -1
- package/dist/utils/recipient.js.map +0 -1
- package/dist/utils/retry.d.ts.map +0 -1
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/revert-reason.d.ts.map +0 -1
- package/dist/utils/revert-reason.js.map +0 -1
- package/dist/utils/signature.d.ts.map +0 -1
- package/dist/utils/signature.js.map +0 -1
- package/dist/utils/swaps.d.ts.map +0 -1
- package/dist/utils/swaps.js.map +0 -1
- package/dist/utils/transaction-type.d.ts.map +0 -1
- package/dist/utils/transaction-type.js.map +0 -1
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js.map +0 -1
|
@@ -0,0 +1,2444 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _TransactionController_instances, _TransactionController_afterAdd, _TransactionController_approvingTransactionIds, _TransactionController_beforeCheckPendingTransaction, _TransactionController_beforePublish, _TransactionController_beforeSign, _TransactionController_gasFeeFlows, _TransactionController_getPermittedAccounts, _TransactionController_getSavedGasFees, _TransactionController_getSimulationConfig, _TransactionController_internalEvents, _TransactionController_isAutomaticGasFeeUpdateEnabled, _TransactionController_isEIP7702GasFeeTokensEnabled, _TransactionController_isFirstTimeInteractionEnabled, _TransactionController_isSimulationEnabled, _TransactionController_isSwapsDisabled, _TransactionController_isTimeoutEnabled, _TransactionController_layer1GasFeeFlows, _TransactionController_methodDataHelper, _TransactionController_multichainTrackingHelper, _TransactionController_publicKeyEIP7702, _TransactionController_publish, _TransactionController_publishBatchHook, _TransactionController_signAbortCallbacks, _TransactionController_skipSimulationTransactionIds, _TransactionController_simulationRequestTokens, _TransactionController_testGasFeeFlows, _TransactionController_trace, _TransactionController_retryTransaction, _TransactionController_signExternalTransaction, _TransactionController_addMetadata, _TransactionController_updateGasProperties, _TransactionController_onBootCleanup, _TransactionController_failIncompleteTransactions, _TransactionController_processApproval, _TransactionController_approveTransaction, _TransactionController_publishTransaction, _TransactionController_rejectTransaction, _TransactionController_trimTransactionsForState, _TransactionController_isFinalState, _TransactionController_isLocalFinalState, _TransactionController_requestApproval, _TransactionController_getTransaction, _TransactionController_getTransactionOrThrow, _TransactionController_getApprovalId, _TransactionController_isTransactionCompleted, _TransactionController_generateDappSuggestedGasFees, _TransactionController_addExternalTransaction, _TransactionController_markNonceDuplicatesDropped, _TransactionController_setTransactionStatusDropped, _TransactionController_waitForTransactionFinished, _TransactionController_updateTransactionMetaRSV, _TransactionController_getEIP1559Compatibility, _TransactionController_signTransaction, _TransactionController_onTransactionStatusChange, _TransactionController_getNonceTrackerTransactions, _TransactionController_onConfirmedTransaction, _TransactionController_updatePostBalance, _TransactionController_createNonceTracker, _TransactionController_createPendingTransactionTracker, _TransactionController_checkForPendingTransactionAndStartPolling, _TransactionController_stopAllTracking, _TransactionController_removePendingTransactionTrackerListeners, _TransactionController_addPendingTransactionTrackerListeners, _TransactionController_getNonceTrackerPendingTransactions, _TransactionController_publishTransactionForRetry, _TransactionController_isTransactionAlreadyConfirmedError, _TransactionController_getGasFeeFlows, _TransactionController_getLayer1GasFeeFlows, _TransactionController_updateTransactionInternal, _TransactionController_isBalanceChangesSkipped, _TransactionController_updateSimulationData, _TransactionController_onGasFeePollerTransactionUpdate, _TransactionController_onGasFeePollerTransactionBatchUpdate, _TransactionController_updateTransactionBatch, _TransactionController_getInternalAccounts, _TransactionController_updateSubmitHistory, _TransactionController_updateGasEstimate, _TransactionController_registerActionHandlers, _TransactionController_deleteTransaction, _TransactionController_isRejectError, _TransactionController_rejectTransactionAndThrow, _TransactionController_failTransaction, _TransactionController_defaultPublishHook, _TransactionController_getGasFeeTokens;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TransactionController = exports.ApprovalState = exports.SPEED_UP_RATE = exports.CANCEL_RATE = void 0;
|
|
16
|
+
const base_controller_1 = require("@metamask/base-controller");
|
|
17
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
18
|
+
const network_controller_1 = require("@metamask/network-controller");
|
|
19
|
+
const nonce_tracker_1 = require("@metamask/nonce-tracker");
|
|
20
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
21
|
+
const utils_1 = require("@metamask/utils");
|
|
22
|
+
// This package purposefully relies on Node's EventEmitter module.
|
|
23
|
+
// eslint-disable-next-line import-x/no-nodejs-modules
|
|
24
|
+
const events_1 = require("events");
|
|
25
|
+
const lodash_1 = require("lodash");
|
|
26
|
+
const uuid_1 = require("uuid");
|
|
27
|
+
const DefaultGasFeeFlow_js_1 = require("./gas-flows/DefaultGasFeeFlow.cjs");
|
|
28
|
+
const LineaGasFeeFlow_js_1 = require("./gas-flows/LineaGasFeeFlow.cjs");
|
|
29
|
+
const MantleLayer1GasFeeFlow_js_1 = require("./gas-flows/MantleLayer1GasFeeFlow.cjs");
|
|
30
|
+
const OptimismLayer1GasFeeFlow_js_1 = require("./gas-flows/OptimismLayer1GasFeeFlow.cjs");
|
|
31
|
+
const RandomisedEstimationsGasFeeFlow_js_1 = require("./gas-flows/RandomisedEstimationsGasFeeFlow.cjs");
|
|
32
|
+
const ScrollLayer1GasFeeFlow_js_1 = require("./gas-flows/ScrollLayer1GasFeeFlow.cjs");
|
|
33
|
+
const TestGasFeeFlow_js_1 = require("./gas-flows/TestGasFeeFlow.cjs");
|
|
34
|
+
const GasFeePoller_js_1 = require("./helpers/GasFeePoller.cjs");
|
|
35
|
+
const MethodDataHelper_js_1 = require("./helpers/MethodDataHelper.cjs");
|
|
36
|
+
const MultichainTrackingHelper_js_1 = require("./helpers/MultichainTrackingHelper.cjs");
|
|
37
|
+
const PendingTransactionTracker_js_1 = require("./helpers/PendingTransactionTracker.cjs");
|
|
38
|
+
const ResimulateHelper_js_1 = require("./helpers/ResimulateHelper.cjs");
|
|
39
|
+
const ExtraTransactionsPublishHook_js_1 = require("./hooks/ExtraTransactionsPublishHook.cjs");
|
|
40
|
+
const logger_js_1 = require("./logger.cjs");
|
|
41
|
+
const types_js_1 = require("./types.cjs");
|
|
42
|
+
const balance_changes_js_1 = require("./utils/balance-changes.cjs");
|
|
43
|
+
const batch_js_1 = require("./utils/batch.cjs");
|
|
44
|
+
const eip7702_js_1 = require("./utils/eip7702.cjs");
|
|
45
|
+
const external_transactions_js_1 = require("./utils/external-transactions.cjs");
|
|
46
|
+
const feature_flags_js_1 = require("./utils/feature-flags.cjs");
|
|
47
|
+
const first_time_interaction_js_1 = require("./utils/first-time-interaction.cjs");
|
|
48
|
+
const gas_fee_tokens_js_1 = require("./utils/gas-fee-tokens.cjs");
|
|
49
|
+
const gas_fees_js_1 = require("./utils/gas-fees.cjs");
|
|
50
|
+
const gas_flow_js_1 = require("./utils/gas-flow.cjs");
|
|
51
|
+
const gas_js_1 = require("./utils/gas.cjs");
|
|
52
|
+
const layer1_gas_fee_flow_js_1 = require("./utils/layer1-gas-fee-flow.cjs");
|
|
53
|
+
const nonce_js_1 = require("./utils/nonce.cjs");
|
|
54
|
+
const prepare_js_1 = require("./utils/prepare.cjs");
|
|
55
|
+
const provider_js_1 = require("./utils/provider.cjs");
|
|
56
|
+
const retry_js_1 = require("./utils/retry.cjs");
|
|
57
|
+
const swaps_js_1 = require("./utils/swaps.cjs");
|
|
58
|
+
const transaction_type_js_1 = require("./utils/transaction-type.cjs");
|
|
59
|
+
const utils_js_1 = require("./utils/utils.cjs");
|
|
60
|
+
const validation_js_1 = require("./utils/validation.cjs");
|
|
61
|
+
/**
|
|
62
|
+
* Metadata for the TransactionController state, describing how to "anonymize"
|
|
63
|
+
* the state and which parts should be persisted.
|
|
64
|
+
*/
|
|
65
|
+
const metadata = {
|
|
66
|
+
transactions: {
|
|
67
|
+
includeInStateLogs: true,
|
|
68
|
+
persist: true,
|
|
69
|
+
includeInDebugSnapshot: false,
|
|
70
|
+
usedInUi: true,
|
|
71
|
+
},
|
|
72
|
+
transactionBatches: {
|
|
73
|
+
includeInStateLogs: true,
|
|
74
|
+
persist: true,
|
|
75
|
+
includeInDebugSnapshot: false,
|
|
76
|
+
usedInUi: true,
|
|
77
|
+
},
|
|
78
|
+
methodData: {
|
|
79
|
+
includeInStateLogs: true,
|
|
80
|
+
persist: true,
|
|
81
|
+
includeInDebugSnapshot: false,
|
|
82
|
+
usedInUi: true,
|
|
83
|
+
},
|
|
84
|
+
lastFetchedBlockNumbers: {
|
|
85
|
+
includeInStateLogs: true,
|
|
86
|
+
persist: true,
|
|
87
|
+
includeInDebugSnapshot: false,
|
|
88
|
+
usedInUi: false,
|
|
89
|
+
},
|
|
90
|
+
submitHistory: {
|
|
91
|
+
includeInStateLogs: true,
|
|
92
|
+
persist: true,
|
|
93
|
+
includeInDebugSnapshot: false,
|
|
94
|
+
usedInUi: false,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Multiplier used to determine a transaction's increased gas fee during cancellation
|
|
99
|
+
*/
|
|
100
|
+
exports.CANCEL_RATE = 1.1;
|
|
101
|
+
/**
|
|
102
|
+
* Multiplier used to determine a transaction's increased gas fee during speed up
|
|
103
|
+
*/
|
|
104
|
+
exports.SPEED_UP_RATE = 1.1;
|
|
105
|
+
/**
|
|
106
|
+
* The name of the {@link TransactionController}.
|
|
107
|
+
*/
|
|
108
|
+
const controllerName = 'TransactionController';
|
|
109
|
+
/**
|
|
110
|
+
* Possible states of the approve transaction step.
|
|
111
|
+
*/
|
|
112
|
+
var ApprovalState;
|
|
113
|
+
(function (ApprovalState) {
|
|
114
|
+
ApprovalState["Approved"] = "approved";
|
|
115
|
+
ApprovalState["NotApproved"] = "not-approved";
|
|
116
|
+
ApprovalState["SkippedViaBeforePublishHook"] = "skipped-via-before-publish-hook";
|
|
117
|
+
})(ApprovalState || (exports.ApprovalState = ApprovalState = {}));
|
|
118
|
+
/**
|
|
119
|
+
* Get the default TransactionsController state.
|
|
120
|
+
*
|
|
121
|
+
* @returns The default TransactionsController state.
|
|
122
|
+
*/
|
|
123
|
+
function getDefaultTransactionControllerState() {
|
|
124
|
+
return {
|
|
125
|
+
methodData: {},
|
|
126
|
+
transactions: [],
|
|
127
|
+
transactionBatches: [],
|
|
128
|
+
lastFetchedBlockNumbers: {},
|
|
129
|
+
submitHistory: [],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// === MESSENGER ===
|
|
133
|
+
const MESSENGER_EXPOSED_METHODS = [
|
|
134
|
+
'abortTransactionSigning',
|
|
135
|
+
'addTransaction',
|
|
136
|
+
'addTransactionBatch',
|
|
137
|
+
'approveTransactionsWithSameNonce',
|
|
138
|
+
'clearUnapprovedTransactions',
|
|
139
|
+
'confirmExternalTransaction',
|
|
140
|
+
'emulateNewTransaction',
|
|
141
|
+
'emulateTransactionUpdate',
|
|
142
|
+
'estimateGas',
|
|
143
|
+
'estimateGasBatch',
|
|
144
|
+
'estimateGasBuffered',
|
|
145
|
+
'estimateGasFee',
|
|
146
|
+
'failTransaction',
|
|
147
|
+
'getGasFeeTokens',
|
|
148
|
+
'getLayer1GasFee',
|
|
149
|
+
'getNonceLock',
|
|
150
|
+
'getTransactions',
|
|
151
|
+
'handleMethodData',
|
|
152
|
+
'isAtomicBatchSupported',
|
|
153
|
+
'setTransactionActive',
|
|
154
|
+
'speedUpTransaction',
|
|
155
|
+
'stopTransaction',
|
|
156
|
+
'updateAtomicBatchData',
|
|
157
|
+
'updateCustodialTransaction',
|
|
158
|
+
'updateEditableParams',
|
|
159
|
+
'updatePreviousGasParams',
|
|
160
|
+
'updateRequiredTransactionIds',
|
|
161
|
+
'updateSecurityAlertResponse',
|
|
162
|
+
'updateSelectedGasFeeToken',
|
|
163
|
+
'updateTransaction',
|
|
164
|
+
'updateTransactionMetadata',
|
|
165
|
+
'updateTransactionGasFees',
|
|
166
|
+
'wipeTransactions',
|
|
167
|
+
];
|
|
168
|
+
/**
|
|
169
|
+
* Controller responsible for submitting and managing transactions.
|
|
170
|
+
*/
|
|
171
|
+
class TransactionController extends base_controller_1.BaseController {
|
|
172
|
+
/**
|
|
173
|
+
* Constructs a TransactionController.
|
|
174
|
+
*
|
|
175
|
+
* @param options - The controller options.
|
|
176
|
+
*/
|
|
177
|
+
constructor(options) {
|
|
178
|
+
const { disableSwaps, getPermittedAccounts, getSavedGasFees, getSimulationConfig, hooks, isAutomaticGasFeeUpdateEnabled, isEIP7702GasFeeTokensEnabled, isFirstTimeInteractionEnabled, isSimulationEnabled, isTimeoutEnabled, messenger, publicKeyEIP7702, state, testGasFeeFlows, trace, } = options;
|
|
179
|
+
super({
|
|
180
|
+
name: controllerName,
|
|
181
|
+
metadata,
|
|
182
|
+
messenger,
|
|
183
|
+
state: {
|
|
184
|
+
...getDefaultTransactionControllerState(),
|
|
185
|
+
...state,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
_TransactionController_instances.add(this);
|
|
189
|
+
_TransactionController_afterAdd.set(this, void 0);
|
|
190
|
+
_TransactionController_approvingTransactionIds.set(this, new Set());
|
|
191
|
+
_TransactionController_beforeCheckPendingTransaction.set(this, void 0);
|
|
192
|
+
_TransactionController_beforePublish.set(this, void 0);
|
|
193
|
+
_TransactionController_beforeSign.set(this, void 0);
|
|
194
|
+
_TransactionController_gasFeeFlows.set(this, void 0);
|
|
195
|
+
_TransactionController_getPermittedAccounts.set(this, void 0);
|
|
196
|
+
_TransactionController_getSavedGasFees.set(this, void 0);
|
|
197
|
+
_TransactionController_getSimulationConfig.set(this, void 0);
|
|
198
|
+
_TransactionController_internalEvents.set(this, new events_1.EventEmitter());
|
|
199
|
+
_TransactionController_isAutomaticGasFeeUpdateEnabled.set(this, void 0);
|
|
200
|
+
_TransactionController_isEIP7702GasFeeTokensEnabled.set(this, void 0);
|
|
201
|
+
_TransactionController_isFirstTimeInteractionEnabled.set(this, void 0);
|
|
202
|
+
_TransactionController_isSimulationEnabled.set(this, void 0);
|
|
203
|
+
_TransactionController_isSwapsDisabled.set(this, void 0);
|
|
204
|
+
_TransactionController_isTimeoutEnabled.set(this, void 0);
|
|
205
|
+
_TransactionController_layer1GasFeeFlows.set(this, void 0);
|
|
206
|
+
_TransactionController_methodDataHelper.set(this, void 0);
|
|
207
|
+
_TransactionController_multichainTrackingHelper.set(this, void 0);
|
|
208
|
+
_TransactionController_publicKeyEIP7702.set(this, void 0);
|
|
209
|
+
_TransactionController_publish.set(this, void 0);
|
|
210
|
+
_TransactionController_publishBatchHook.set(this, void 0);
|
|
211
|
+
_TransactionController_signAbortCallbacks.set(this, new Map());
|
|
212
|
+
_TransactionController_skipSimulationTransactionIds.set(this, new Set());
|
|
213
|
+
_TransactionController_simulationRequestTokens.set(this, new Map());
|
|
214
|
+
_TransactionController_testGasFeeFlows.set(this, void 0);
|
|
215
|
+
_TransactionController_trace.set(this, void 0);
|
|
216
|
+
_TransactionController_checkForPendingTransactionAndStartPolling.set(this, () => {
|
|
217
|
+
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
|
|
218
|
+
});
|
|
219
|
+
this.messenger = messenger;
|
|
220
|
+
__classPrivateFieldSet(this, _TransactionController_afterAdd, hooks?.afterAdd ?? (() => Promise.resolve({})), "f");
|
|
221
|
+
__classPrivateFieldSet(this, _TransactionController_beforeCheckPendingTransaction,
|
|
222
|
+
/* istanbul ignore next */
|
|
223
|
+
hooks?.beforeCheckPendingTransaction ??
|
|
224
|
+
(() => Promise.resolve(true)), "f");
|
|
225
|
+
__classPrivateFieldSet(this, _TransactionController_beforePublish, hooks?.beforePublish ?? (() => Promise.resolve(true)), "f");
|
|
226
|
+
__classPrivateFieldSet(this, _TransactionController_beforeSign, hooks?.beforeSign ??
|
|
227
|
+
(() => Promise.resolve({})), "f");
|
|
228
|
+
__classPrivateFieldSet(this, _TransactionController_getPermittedAccounts, getPermittedAccounts, "f");
|
|
229
|
+
__classPrivateFieldSet(this, _TransactionController_getSavedGasFees, getSavedGasFees ??
|
|
230
|
+
((_transactionMeta) => undefined), "f");
|
|
231
|
+
__classPrivateFieldSet(this, _TransactionController_getSimulationConfig, getSimulationConfig ??
|
|
232
|
+
(() => Promise.resolve({})), "f");
|
|
233
|
+
__classPrivateFieldSet(this, _TransactionController_isAutomaticGasFeeUpdateEnabled, isAutomaticGasFeeUpdateEnabled ??
|
|
234
|
+
((_txMeta) => false), "f");
|
|
235
|
+
__classPrivateFieldSet(this, _TransactionController_isEIP7702GasFeeTokensEnabled, isEIP7702GasFeeTokensEnabled ??
|
|
236
|
+
(() => Promise.resolve(false)), "f");
|
|
237
|
+
__classPrivateFieldSet(this, _TransactionController_isFirstTimeInteractionEnabled, isFirstTimeInteractionEnabled ?? (() => true), "f");
|
|
238
|
+
__classPrivateFieldSet(this, _TransactionController_isSimulationEnabled, isSimulationEnabled ?? (() => true), "f");
|
|
239
|
+
__classPrivateFieldSet(this, _TransactionController_isSwapsDisabled, disableSwaps ?? false, "f");
|
|
240
|
+
__classPrivateFieldSet(this, _TransactionController_isTimeoutEnabled, isTimeoutEnabled ?? (() => true), "f");
|
|
241
|
+
__classPrivateFieldSet(this, _TransactionController_publicKeyEIP7702, publicKeyEIP7702, "f");
|
|
242
|
+
__classPrivateFieldSet(this, _TransactionController_publish, hooks?.publish ??
|
|
243
|
+
(() => Promise.resolve({ transactionHash: undefined })), "f");
|
|
244
|
+
__classPrivateFieldSet(this, _TransactionController_publishBatchHook, hooks?.publishBatch, "f");
|
|
245
|
+
__classPrivateFieldSet(this, _TransactionController_testGasFeeFlows, testGasFeeFlows === true, "f");
|
|
246
|
+
__classPrivateFieldSet(this, _TransactionController_trace, trace ?? ((_request, fn) => fn?.()), "f");
|
|
247
|
+
const findNetworkClientIdByChainId = (chainId) => {
|
|
248
|
+
return this.messenger.call(`NetworkController:findNetworkClientIdByChainId`, chainId);
|
|
249
|
+
};
|
|
250
|
+
__classPrivateFieldSet(this, _TransactionController_multichainTrackingHelper, new MultichainTrackingHelper_js_1.MultichainTrackingHelper({
|
|
251
|
+
findNetworkClientIdByChainId,
|
|
252
|
+
getNetworkClientById: ((networkClientId) => {
|
|
253
|
+
return this.messenger.call(`NetworkController:getNetworkClientById`, networkClientId);
|
|
254
|
+
}),
|
|
255
|
+
getNetworkClientRegistry: (() => this.messenger.call('NetworkController:getNetworkClientRegistry')),
|
|
256
|
+
removePendingTransactionTrackerListeners: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_removePendingTransactionTrackerListeners).bind(this),
|
|
257
|
+
createNonceTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createNonceTracker).bind(this),
|
|
258
|
+
createPendingTransactionTracker: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).bind(this),
|
|
259
|
+
onNetworkStateChange: (listener) => {
|
|
260
|
+
this.messenger.subscribe('NetworkController:stateChange', listener);
|
|
261
|
+
},
|
|
262
|
+
onInitialized: () => {
|
|
263
|
+
__classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
|
|
264
|
+
},
|
|
265
|
+
}), "f");
|
|
266
|
+
__classPrivateFieldSet(this, _TransactionController_gasFeeFlows, __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeFlows).call(this), "f");
|
|
267
|
+
__classPrivateFieldSet(this, _TransactionController_layer1GasFeeFlows, __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getLayer1GasFeeFlows).call(this), "f");
|
|
268
|
+
const gasFeePoller = new GasFeePoller_js_1.GasFeePoller({
|
|
269
|
+
gasFeeFlows: __classPrivateFieldGet(this, _TransactionController_gasFeeFlows, "f"),
|
|
270
|
+
getGasFeeControllerEstimates: (gasFeeOpts) => this.messenger.call('GasFeeController:fetchGasFeeEstimates', gasFeeOpts),
|
|
271
|
+
getTransactions: () => this.state.transactions,
|
|
272
|
+
getTransactionBatches: () => this.state.transactionBatches,
|
|
273
|
+
layer1GasFeeFlows: __classPrivateFieldGet(this, _TransactionController_layer1GasFeeFlows, "f"),
|
|
274
|
+
messenger: this.messenger,
|
|
275
|
+
onStateChange: (listener) => {
|
|
276
|
+
this.messenger.subscribe('TransactionController:stateChange', listener);
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
gasFeePoller.hub.on('transaction-updated', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onGasFeePollerTransactionUpdate).bind(this));
|
|
280
|
+
gasFeePoller.hub.on('transaction-batch-updated', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onGasFeePollerTransactionBatchUpdate).bind(this));
|
|
281
|
+
__classPrivateFieldSet(this, _TransactionController_methodDataHelper, new MethodDataHelper_js_1.MethodDataHelper({
|
|
282
|
+
messenger: this.messenger,
|
|
283
|
+
getState: () => this.state.methodData,
|
|
284
|
+
}), "f");
|
|
285
|
+
__classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").hub.on('update', ({ fourBytePrefix, methodData }) => {
|
|
286
|
+
this.update((_state) => {
|
|
287
|
+
_state.methodData[fourBytePrefix] = methodData;
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
// when transactionsController state changes
|
|
291
|
+
// check for pending transactions and start polling if there are any
|
|
292
|
+
this.messenger.subscribe('TransactionController:stateChange', __classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f"));
|
|
293
|
+
// eslint-disable-next-line no-new
|
|
294
|
+
new ResimulateHelper_js_1.ResimulateHelper({
|
|
295
|
+
simulateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).bind(this),
|
|
296
|
+
onTransactionsUpdate: (listener) => {
|
|
297
|
+
this.messenger.subscribe('TransactionController:stateChange', listener, (controllerState) => controllerState.transactions);
|
|
298
|
+
},
|
|
299
|
+
getTransactions: () => this.state.transactions,
|
|
300
|
+
});
|
|
301
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onBootCleanup).call(this);
|
|
302
|
+
__classPrivateFieldGet(this, _TransactionController_checkForPendingTransactionAndStartPolling, "f").call(this);
|
|
303
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_registerActionHandlers).call(this);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Stops polling and removes listeners to prepare the controller for garbage collection.
|
|
307
|
+
*/
|
|
308
|
+
destroy() {
|
|
309
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_stopAllTracking).call(this);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* @deprecated Incoming transaction support has been removed. This method is retained as a no-op for backwards compatibility.
|
|
313
|
+
*/
|
|
314
|
+
startIncomingTransactionPolling() {
|
|
315
|
+
(0, lodash_1.noop)();
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @deprecated Incoming transaction support has been removed. This method is retained as a no-op for backwards compatibility.
|
|
319
|
+
*/
|
|
320
|
+
stopIncomingTransactionPolling() {
|
|
321
|
+
(0, lodash_1.noop)();
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Handle new method data request.
|
|
325
|
+
*
|
|
326
|
+
* @param fourBytePrefix - The method prefix.
|
|
327
|
+
* @param networkClientId - The ID of the network client used to fetch the method data.
|
|
328
|
+
* @returns The method data object corresponding to the given signature prefix.
|
|
329
|
+
*/
|
|
330
|
+
async handleMethodData(fourBytePrefix, networkClientId) {
|
|
331
|
+
return __classPrivateFieldGet(this, _TransactionController_methodDataHelper, "f").lookup(fourBytePrefix, networkClientId);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Add a batch of transactions to be submitted after approval.
|
|
335
|
+
*
|
|
336
|
+
* @param request - Request object containing the transactions to add.
|
|
337
|
+
* @returns Result object containing the generated batch ID.
|
|
338
|
+
*/
|
|
339
|
+
async addTransactionBatch(request) {
|
|
340
|
+
const { blockTracker } = this.messenger.call(`NetworkController:getNetworkClientById`, request.networkClientId);
|
|
341
|
+
return await (0, batch_js_1.addTransactionBatch)({
|
|
342
|
+
addTransaction: this.addTransaction.bind(this),
|
|
343
|
+
estimateGas: this.estimateGas.bind(this),
|
|
344
|
+
getGasFeeEstimates: (options) => this.messenger.call('GasFeeController:fetchGasFeeEstimates', options),
|
|
345
|
+
getInternalAccounts: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).bind(this),
|
|
346
|
+
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f").bind(this),
|
|
347
|
+
getPendingTransactionTracker: (networkClientId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_createPendingTransactionTracker).call(this, {
|
|
348
|
+
blockTracker,
|
|
349
|
+
networkClientId,
|
|
350
|
+
}),
|
|
351
|
+
getTransaction: (transactionId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId),
|
|
352
|
+
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f"),
|
|
353
|
+
messenger: this.messenger,
|
|
354
|
+
publishBatchHook: __classPrivateFieldGet(this, _TransactionController_publishBatchHook, "f"),
|
|
355
|
+
publicKeyEIP7702: __classPrivateFieldGet(this, _TransactionController_publicKeyEIP7702, "f"),
|
|
356
|
+
publishTransaction: (transactionMeta) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_publishTransaction).call(this, transactionMeta),
|
|
357
|
+
request,
|
|
358
|
+
signTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_signTransaction).bind(this),
|
|
359
|
+
update: this.update.bind(this),
|
|
360
|
+
updateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).bind(this),
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Determine which chains support atomic batch transactions with the given account address.
|
|
365
|
+
*
|
|
366
|
+
* @param request - Request object containing the account address and other parameters.
|
|
367
|
+
* @returns Result object containing the supported chains and related information.
|
|
368
|
+
*/
|
|
369
|
+
async isAtomicBatchSupported(request) {
|
|
370
|
+
return (0, batch_js_1.isAtomicBatchSupported)({
|
|
371
|
+
...request,
|
|
372
|
+
messenger: this.messenger,
|
|
373
|
+
publicKeyEIP7702: __classPrivateFieldGet(this, _TransactionController_publicKeyEIP7702, "f"),
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Add a new unapproved transaction to state. Parameters will be validated, a
|
|
378
|
+
* unique transaction ID will be generated, and `gas` and `gasPrice` will be calculated
|
|
379
|
+
* if not provided. A `<tx.id>:unapproved` hub event will be emitted once added.
|
|
380
|
+
*
|
|
381
|
+
* @param txParams - Standard parameters for an Ethereum transaction.
|
|
382
|
+
* @param options - Additional options to control how the transaction is added.
|
|
383
|
+
* @returns Object containing a promise resolving to the transaction hash if approved.
|
|
384
|
+
*/
|
|
385
|
+
async addTransaction(txParams, options) {
|
|
386
|
+
(0, logger_js_1.projectLogger)('Adding transaction', txParams, options);
|
|
387
|
+
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;
|
|
388
|
+
// eslint-disable-next-line no-param-reassign
|
|
389
|
+
txParams = (0, utils_js_1.normalizeTransactionParams)(txParams);
|
|
390
|
+
if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
|
|
391
|
+
throw new Error(`Network client not found - ${networkClientId}`);
|
|
392
|
+
}
|
|
393
|
+
const chainId = (0, provider_js_1.getChainId)({ messenger: this.messenger, networkClientId });
|
|
394
|
+
const permittedAddresses = origin === undefined
|
|
395
|
+
? undefined
|
|
396
|
+
: await __classPrivateFieldGet(this, _TransactionController_getPermittedAccounts, "f")?.call(this, origin);
|
|
397
|
+
const internalAccounts = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getInternalAccounts).call(this);
|
|
398
|
+
await (0, validation_js_1.validateTransactionOrigin)({
|
|
399
|
+
data: txParams.data,
|
|
400
|
+
from: txParams.from,
|
|
401
|
+
internalAccounts,
|
|
402
|
+
isInternal,
|
|
403
|
+
origin,
|
|
404
|
+
permittedAddresses,
|
|
405
|
+
txParams,
|
|
406
|
+
type,
|
|
407
|
+
});
|
|
408
|
+
const delegationAddressPromise = (0, eip7702_js_1.getDelegationAddress)(txParams.from, this.messenger, networkClientId).catch(() => undefined);
|
|
409
|
+
const isEIP1559Compatible = await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEIP1559Compatibility).call(this, networkClientId);
|
|
410
|
+
(0, validation_js_1.validateTxParams)(txParams, isEIP1559Compatible, chainId);
|
|
411
|
+
if (!txParams.type) {
|
|
412
|
+
// Determine transaction type based on transaction parameters and network compatibility
|
|
413
|
+
(0, utils_js_1.setEnvelopeType)(txParams, isEIP1559Compatible);
|
|
414
|
+
}
|
|
415
|
+
const isDuplicateBatchId = batchId?.length &&
|
|
416
|
+
this.state.transactions.some((tx) => tx.batchId?.toLowerCase() === batchId?.toLowerCase());
|
|
417
|
+
if (isDuplicateBatchId && !isInternal) {
|
|
418
|
+
throw new rpc_errors_1.JsonRpcError(validation_js_1.ErrorCode.DuplicateBundleId, 'Batch ID already exists');
|
|
419
|
+
}
|
|
420
|
+
const dappSuggestedGasFees = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_generateDappSuggestedGasFees).call(this, txParams, origin, isInternal);
|
|
421
|
+
const transactionType = type ??
|
|
422
|
+
(await (0, transaction_type_js_1.determineTransactionType)(txParams, {
|
|
423
|
+
messenger: this.messenger,
|
|
424
|
+
networkClientId,
|
|
425
|
+
})).type;
|
|
426
|
+
/**
|
|
427
|
+
* Original behavior was that this was set to 'true' whenever a gasFeeToken was passed.
|
|
428
|
+
* 'excludeNativeTokenForFee' optionally overrides this behavior to prevent native token from
|
|
429
|
+
* being used when another gasFeeToken is set.
|
|
430
|
+
*/
|
|
431
|
+
const isGasFeeTokenIgnoredIfBalance = Boolean(gasFeeToken) && !excludeNativeTokenForFee;
|
|
432
|
+
let addedTransactionMeta = {
|
|
433
|
+
actionId,
|
|
434
|
+
assetsFiatValues,
|
|
435
|
+
batchId,
|
|
436
|
+
chainId,
|
|
437
|
+
dappSuggestedGasFees,
|
|
438
|
+
deviceConfirmedOn,
|
|
439
|
+
disableGasBuffer,
|
|
440
|
+
id: (0, uuid_1.v1)(),
|
|
441
|
+
isGasFeeTokenIgnoredIfBalance,
|
|
442
|
+
isGasFeeIncluded,
|
|
443
|
+
isGasFeeSponsored,
|
|
444
|
+
...(isGasFeeSponsored ? { isExternalSign: true } : {}),
|
|
445
|
+
// To avoid the property to be set as undefined.
|
|
446
|
+
...(excludeNativeTokenForFee === undefined
|
|
447
|
+
? {}
|
|
448
|
+
: { excludeNativeTokenForFee }),
|
|
449
|
+
isFirstTimeInteraction: undefined,
|
|
450
|
+
isInternal,
|
|
451
|
+
isStateOnly,
|
|
452
|
+
nestedTransactions,
|
|
453
|
+
networkClientId,
|
|
454
|
+
origin,
|
|
455
|
+
requestId,
|
|
456
|
+
requiredAssets,
|
|
457
|
+
securityAlertResponse,
|
|
458
|
+
selectedGasFeeToken: gasFeeToken,
|
|
459
|
+
status: types_js_1.TransactionStatus.unapproved,
|
|
460
|
+
time: Date.now(),
|
|
461
|
+
txParams,
|
|
462
|
+
type: transactionType,
|
|
463
|
+
userEditedGasLimit: false,
|
|
464
|
+
verifiedOnBlockchain: false,
|
|
465
|
+
};
|
|
466
|
+
const { updateTransaction } = await __classPrivateFieldGet(this, _TransactionController_afterAdd, "f").call(this, {
|
|
467
|
+
transactionMeta: addedTransactionMeta,
|
|
468
|
+
});
|
|
469
|
+
if (updateTransaction) {
|
|
470
|
+
(0, logger_js_1.projectLogger)('Updating transaction using afterAdd hook');
|
|
471
|
+
addedTransactionMeta.txParamsOriginal = (0, lodash_1.cloneDeep)(addedTransactionMeta.txParams);
|
|
472
|
+
updateTransaction(addedTransactionMeta);
|
|
473
|
+
}
|
|
474
|
+
// eslint-disable-next-line no-negated-condition
|
|
475
|
+
if (!skipInitialGasEstimate) {
|
|
476
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Estimate Gas Properties', parentContext: traceContext }, (context) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasProperties).call(this, addedTransactionMeta, {
|
|
477
|
+
traceContext: context,
|
|
478
|
+
}));
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
const newTransactionMeta = (0, lodash_1.cloneDeep)(addedTransactionMeta);
|
|
482
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasProperties).call(this, newTransactionMeta)
|
|
483
|
+
.then(() => {
|
|
484
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
485
|
+
transactionId: newTransactionMeta.id,
|
|
486
|
+
skipResimulateCheck: true,
|
|
487
|
+
skipValidation: true,
|
|
488
|
+
}, (tx) => {
|
|
489
|
+
tx.txParams.gas = newTransactionMeta.txParams.gas;
|
|
490
|
+
tx.txParams.gasPrice = newTransactionMeta.txParams.gasPrice;
|
|
491
|
+
tx.txParams.maxFeePerGas =
|
|
492
|
+
newTransactionMeta.txParams.maxFeePerGas;
|
|
493
|
+
tx.txParams.maxPriorityFeePerGas =
|
|
494
|
+
newTransactionMeta.txParams.maxPriorityFeePerGas;
|
|
495
|
+
});
|
|
496
|
+
return undefined;
|
|
497
|
+
})
|
|
498
|
+
.catch(lodash_1.noop);
|
|
499
|
+
}
|
|
500
|
+
addedTransactionMeta = (0, swaps_js_1.updateSwapsTransaction)(addedTransactionMeta, transactionType, swaps, {
|
|
501
|
+
isSwapsDisabled: __classPrivateFieldGet(this, _TransactionController_isSwapsDisabled, "f"),
|
|
502
|
+
cancelTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_rejectTransaction).bind(this),
|
|
503
|
+
messenger: this.messenger,
|
|
504
|
+
});
|
|
505
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addMetadata).call(this, addedTransactionMeta);
|
|
506
|
+
delegationAddressPromise
|
|
507
|
+
.then((delegationAddress) => {
|
|
508
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
509
|
+
transactionId: addedTransactionMeta.id,
|
|
510
|
+
skipResimulateCheck: true,
|
|
511
|
+
skipValidation: true,
|
|
512
|
+
}, (tx) => {
|
|
513
|
+
tx.delegationAddress = delegationAddress;
|
|
514
|
+
});
|
|
515
|
+
return undefined;
|
|
516
|
+
})
|
|
517
|
+
.catch(lodash_1.noop);
|
|
518
|
+
if (requireApproval !== false && !isStateOnly) {
|
|
519
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).call(this, addedTransactionMeta, {
|
|
520
|
+
traceContext,
|
|
521
|
+
}).catch((error) => {
|
|
522
|
+
(0, logger_js_1.projectLogger)('Error while updating simulation data', error);
|
|
523
|
+
throw error;
|
|
524
|
+
});
|
|
525
|
+
(0, first_time_interaction_js_1.updateFirstTimeInteraction)({
|
|
526
|
+
existingTransactions: this.state.transactions,
|
|
527
|
+
getTransaction: (transactionId) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId),
|
|
528
|
+
isFirstTimeInteractionEnabled: __classPrivateFieldGet(this, _TransactionController_isFirstTimeInteractionEnabled, "f"),
|
|
529
|
+
trace: __classPrivateFieldGet(this, _TransactionController_trace, "f"),
|
|
530
|
+
traceContext,
|
|
531
|
+
transactionMeta: addedTransactionMeta,
|
|
532
|
+
updateTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).bind(this),
|
|
533
|
+
}).catch((error) => {
|
|
534
|
+
(0, logger_js_1.projectLogger)('Error while updating first interaction properties', error);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
(0, logger_js_1.projectLogger)('Skipping simulation & first interaction update as approval not required');
|
|
539
|
+
}
|
|
540
|
+
this.messenger.publish(`${controllerName}:unapprovedTransactionAdded`, addedTransactionMeta);
|
|
541
|
+
return {
|
|
542
|
+
result: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_processApproval).call(this, addedTransactionMeta, {
|
|
543
|
+
actionId,
|
|
544
|
+
publishHook,
|
|
545
|
+
requireApproval,
|
|
546
|
+
traceContext,
|
|
547
|
+
}),
|
|
548
|
+
transactionMeta: addedTransactionMeta,
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Attempts to cancel a transaction based on its ID by setting its status to "rejected"
|
|
553
|
+
* and emitting a `<tx.id>:finished` hub event.
|
|
554
|
+
*
|
|
555
|
+
* @param transactionId - The ID of the transaction to cancel.
|
|
556
|
+
* @param gasValues - The gas values to use for the cancellation transaction.
|
|
557
|
+
* @param options - The options for the cancellation transaction.
|
|
558
|
+
* @param options.actionId - Unique ID persisted on transaction metadata.
|
|
559
|
+
* @param options.estimatedBaseFee - The estimated base fee of the transaction.
|
|
560
|
+
*/
|
|
561
|
+
async stopTransaction(transactionId, gasValues, { estimatedBaseFee, actionId, } = {}) {
|
|
562
|
+
await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
|
|
563
|
+
actionId,
|
|
564
|
+
estimatedBaseFee,
|
|
565
|
+
gasValues,
|
|
566
|
+
label: 'cancel',
|
|
567
|
+
rate: exports.CANCEL_RATE,
|
|
568
|
+
transactionId,
|
|
569
|
+
transactionType: types_js_1.TransactionType.cancel,
|
|
570
|
+
prepareTransactionParams: (txParams) => {
|
|
571
|
+
delete txParams.data;
|
|
572
|
+
txParams.to = txParams.from;
|
|
573
|
+
txParams.value = '0x0';
|
|
574
|
+
},
|
|
575
|
+
afterSubmit: (newTransactionMeta) => {
|
|
576
|
+
this.messenger.publish(`${controllerName}:transactionFinished`, newTransactionMeta);
|
|
577
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${newTransactionMeta.id}:finished`, newTransactionMeta);
|
|
578
|
+
},
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Attempts to speed up a transaction increasing transaction gasPrice by ten percent.
|
|
583
|
+
*
|
|
584
|
+
* @param transactionId - The ID of the transaction to speed up.
|
|
585
|
+
* @param gasValues - The gas values to use for the speed up transaction.
|
|
586
|
+
* @param options - The options for the speed up transaction.
|
|
587
|
+
* @param options.actionId - Unique ID persisted on transaction metadata.
|
|
588
|
+
* @param options.estimatedBaseFee - The estimated base fee of the transaction.
|
|
589
|
+
*/
|
|
590
|
+
async speedUpTransaction(transactionId, gasValues, { actionId, estimatedBaseFee, } = {}) {
|
|
591
|
+
await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_retryTransaction).call(this, {
|
|
592
|
+
actionId,
|
|
593
|
+
estimatedBaseFee,
|
|
594
|
+
gasValues,
|
|
595
|
+
label: 'speed up',
|
|
596
|
+
rate: exports.SPEED_UP_RATE,
|
|
597
|
+
transactionId,
|
|
598
|
+
transactionType: types_js_1.TransactionType.retry,
|
|
599
|
+
afterSubmit: (newTransactionMeta) => {
|
|
600
|
+
this.messenger.publish(`${controllerName}:speedupTransactionAdded`, newTransactionMeta);
|
|
601
|
+
},
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Estimates required gas for a given transaction.
|
|
606
|
+
*
|
|
607
|
+
* @param transaction - The transaction to estimate gas for.
|
|
608
|
+
* @param networkClientId - The network client id to use for the estimate.
|
|
609
|
+
* @param options - Additional options for the estimate.
|
|
610
|
+
* @param options.ignoreDelegationSignatures - Ignore signature errors if submitting delegations to the DelegationManager.
|
|
611
|
+
* @returns The gas and gas price.
|
|
612
|
+
*/
|
|
613
|
+
async estimateGas(transaction, networkClientId, { ignoreDelegationSignatures, } = {}) {
|
|
614
|
+
const { estimatedGas, simulationFails } = await (0, gas_js_1.estimateGas)({
|
|
615
|
+
ignoreDelegationSignatures,
|
|
616
|
+
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
|
|
617
|
+
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
618
|
+
messenger: this.messenger,
|
|
619
|
+
networkClientId,
|
|
620
|
+
txParams: transaction,
|
|
621
|
+
});
|
|
622
|
+
return { gas: estimatedGas, simulationFails };
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Estimates required gas for a batch of transactions.
|
|
626
|
+
*
|
|
627
|
+
* @param request - Request object.
|
|
628
|
+
* @param request.chainId - Chain ID of the transactions.
|
|
629
|
+
* @param request.from - Address of the sender.
|
|
630
|
+
* @param request.transactions - Array of transactions within a batch request.
|
|
631
|
+
* @returns Object containing the gas limit.
|
|
632
|
+
*/
|
|
633
|
+
async estimateGasBatch({ chainId, from, transactions, }) {
|
|
634
|
+
return (0, gas_js_1.estimateGasBatch)({
|
|
635
|
+
from,
|
|
636
|
+
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
637
|
+
isAtomicBatchSupported: this.isAtomicBatchSupported.bind(this),
|
|
638
|
+
messenger: this.messenger,
|
|
639
|
+
networkClientId: (0, provider_js_1.getNetworkClientId)({
|
|
640
|
+
messenger: this.messenger,
|
|
641
|
+
chainId,
|
|
642
|
+
}),
|
|
643
|
+
transactions,
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Estimates required gas for a given transaction and add additional gas buffer with the given multiplier.
|
|
648
|
+
*
|
|
649
|
+
* @param transaction - The transaction params to estimate gas for.
|
|
650
|
+
* @param multiplier - The multiplier to use for the gas buffer.
|
|
651
|
+
* @param networkClientId - The network client id to use for the estimate.
|
|
652
|
+
* @returns The buffered estimated gas and whether the estimation failed.
|
|
653
|
+
*/
|
|
654
|
+
async estimateGasBuffered(transaction, multiplier, networkClientId) {
|
|
655
|
+
const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_js_1.estimateGas)({
|
|
656
|
+
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
|
|
657
|
+
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
658
|
+
messenger: this.messenger,
|
|
659
|
+
networkClientId,
|
|
660
|
+
txParams: transaction,
|
|
661
|
+
});
|
|
662
|
+
const gas = (0, gas_js_1.addGasBuffer)(estimatedGas, blockGasLimit, multiplier);
|
|
663
|
+
return {
|
|
664
|
+
gas,
|
|
665
|
+
simulationFails,
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Updates an existing transaction in state.
|
|
670
|
+
*
|
|
671
|
+
* @param transactionMeta - The new transaction to store in state.
|
|
672
|
+
* @param note - A note or update reason to be logged.
|
|
673
|
+
*/
|
|
674
|
+
updateTransaction(transactionMeta, note) {
|
|
675
|
+
const { id: transactionId } = transactionMeta;
|
|
676
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, () => ({
|
|
677
|
+
...transactionMeta,
|
|
678
|
+
}));
|
|
679
|
+
(0, logger_js_1.projectLogger)('Transaction updated', { transactionId, note });
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Updates transaction metadata.
|
|
683
|
+
*
|
|
684
|
+
* @param options - Update options.
|
|
685
|
+
* @param options.transactionId - ID of the transaction to update.
|
|
686
|
+
* @param options.callback - Function that mutates the transaction metadata.
|
|
687
|
+
* @param options.skipResimulate - Whether to skip automatic re-simulation.
|
|
688
|
+
* @returns The updated transaction metadata.
|
|
689
|
+
*/
|
|
690
|
+
updateTransactionMetadata({ transactionId, callback, skipResimulate = false, }) {
|
|
691
|
+
return __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId, skipResimulateCheck: skipResimulate }, (transactionMeta) => {
|
|
692
|
+
callback(transactionMeta);
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Mark a transaction as failed, transitioning it through the standard failure
|
|
697
|
+
* path.
|
|
698
|
+
*
|
|
699
|
+
* Unlike `updateTransaction`, this emits the transaction lifecycle events
|
|
700
|
+
* (`transactionFailed`, `transactionStatusUpdated`, `transactionFinished`), so
|
|
701
|
+
* downstream subscribers such as the bridge status controller and metrics are
|
|
702
|
+
* notified. Intended for callers that finalize a transaction out-of-band, for
|
|
703
|
+
* example the smart transactions controller when the relay cancels a smart
|
|
704
|
+
* transaction that never landed on chain.
|
|
705
|
+
*
|
|
706
|
+
* @param transactionId - The ID of the transaction to mark as failed.
|
|
707
|
+
* @param error - The error describing why the transaction failed.
|
|
708
|
+
*/
|
|
709
|
+
failTransaction(transactionId, error) {
|
|
710
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
711
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failTransaction).call(this, transactionMeta, error);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Update the security alert response for a transaction.
|
|
715
|
+
*
|
|
716
|
+
* @param transactionId - ID of the transaction.
|
|
717
|
+
* @param securityAlertResponse - The new security alert response for the transaction.
|
|
718
|
+
*/
|
|
719
|
+
updateSecurityAlertResponse(transactionId, securityAlertResponse) {
|
|
720
|
+
if (!securityAlertResponse) {
|
|
721
|
+
throw new Error('updateSecurityAlertResponse: securityAlertResponse should not be null');
|
|
722
|
+
}
|
|
723
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
724
|
+
if (!transactionMeta) {
|
|
725
|
+
throw new Error(`Cannot update security alert response as no transaction metadata found`);
|
|
726
|
+
}
|
|
727
|
+
const updatedTransactionMeta = {
|
|
728
|
+
...transactionMeta,
|
|
729
|
+
securityAlertResponse,
|
|
730
|
+
};
|
|
731
|
+
this.updateTransaction(updatedTransactionMeta, `${controllerName}:updatesecurityAlertResponse - securityAlertResponse updated`);
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Remove transactions from state.
|
|
735
|
+
*
|
|
736
|
+
* @param options - The options bag.
|
|
737
|
+
* @param options.address - Remove transactions from this account only. Defaults to all accounts.
|
|
738
|
+
* @param options.chainId - Remove transactions for the specified chain only. Defaults to all chains.
|
|
739
|
+
*/
|
|
740
|
+
wipeTransactions({ address, chainId, } = {}) {
|
|
741
|
+
if (!chainId && !address) {
|
|
742
|
+
this.update((state) => {
|
|
743
|
+
state.transactions = [];
|
|
744
|
+
});
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
const newTransactions = this.state.transactions.filter(({ chainId: txChainId, txParams, type }) => {
|
|
748
|
+
const isMatchingNetwork = !chainId || chainId === txChainId;
|
|
749
|
+
if (!isMatchingNetwork) {
|
|
750
|
+
return true;
|
|
751
|
+
}
|
|
752
|
+
const isMatchingAddress = !address ||
|
|
753
|
+
txParams.from?.toLowerCase() === address.toLowerCase() ||
|
|
754
|
+
(type === types_js_1.TransactionType.incoming &&
|
|
755
|
+
txParams.to?.toLowerCase() === address.toLowerCase());
|
|
756
|
+
return !isMatchingAddress;
|
|
757
|
+
});
|
|
758
|
+
this.update((state) => {
|
|
759
|
+
state.transactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_trimTransactionsForState).call(this, newTransactions);
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* @deprecated No longer used. Kept only to avoid breaking changes. It now performs no operations.
|
|
764
|
+
* @param transactionID - The ID of the transaction to update.
|
|
765
|
+
* @param _currentSendFlowHistoryLength - The length of the current sendFlowHistory array.
|
|
766
|
+
* @param _sendFlowHistoryToAdd - The sendFlowHistory entries to add.
|
|
767
|
+
* @returns The transactionMeta.
|
|
768
|
+
*/
|
|
769
|
+
updateTransactionSendFlowHistory(transactionID, _currentSendFlowHistoryLength, _sendFlowHistoryToAdd) {
|
|
770
|
+
// Return the transaction unchanged
|
|
771
|
+
return __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionID);
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Adds external provided transaction to state as confirmed transaction.
|
|
775
|
+
*
|
|
776
|
+
* @param transactionMeta - TransactionMeta to add transactions.
|
|
777
|
+
* @param transactionReceipt - TransactionReceipt of the external transaction.
|
|
778
|
+
* @param baseFeePerGas - Base fee per gas of the external transaction.
|
|
779
|
+
*/
|
|
780
|
+
async confirmExternalTransaction(transactionMeta, transactionReceipt, baseFeePerGas) {
|
|
781
|
+
// Run validation and add external transaction to state.
|
|
782
|
+
const newTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addExternalTransaction).call(this, transactionMeta);
|
|
783
|
+
try {
|
|
784
|
+
const transactionId = newTransactionMeta.id;
|
|
785
|
+
// Make sure status is confirmed and define gasUsed as in receipt.
|
|
786
|
+
const updatedTransactionMeta = {
|
|
787
|
+
...newTransactionMeta,
|
|
788
|
+
status: types_js_1.TransactionStatus.confirmed,
|
|
789
|
+
txReceipt: transactionReceipt,
|
|
790
|
+
};
|
|
791
|
+
if (baseFeePerGas) {
|
|
792
|
+
updatedTransactionMeta.baseFeePerGas = baseFeePerGas;
|
|
793
|
+
}
|
|
794
|
+
// Update same nonce local transactions as dropped and define replacedBy properties.
|
|
795
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_markNonceDuplicatesDropped).call(this, transactionId);
|
|
796
|
+
// Update external provided transaction with updated gas values and confirmed status.
|
|
797
|
+
this.updateTransaction(updatedTransactionMeta, `${controllerName}:confirmExternalTransaction - Add external transaction`);
|
|
798
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, updatedTransactionMeta);
|
|
799
|
+
// Intentional given potential duration of process.
|
|
800
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updatePostBalance).call(this, updatedTransactionMeta).catch((error) => {
|
|
801
|
+
/* istanbul ignore next */
|
|
802
|
+
(0, logger_js_1.projectLogger)('Error while updating post balance', error);
|
|
803
|
+
throw error;
|
|
804
|
+
});
|
|
805
|
+
this.messenger.publish(`${controllerName}:transactionConfirmed`, updatedTransactionMeta);
|
|
806
|
+
}
|
|
807
|
+
catch (error) {
|
|
808
|
+
console.error('Failed to confirm external transaction', error);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Update the gas values of a transaction.
|
|
813
|
+
*
|
|
814
|
+
* @param transactionId - The ID of the transaction to update.
|
|
815
|
+
* @param gasValues - Gas values to update.
|
|
816
|
+
* @param gasValues.gas - Same as transaction.gasLimit.
|
|
817
|
+
* @param gasValues.gasLimit - Maxmimum number of units of gas to use for this transaction.
|
|
818
|
+
* @param gasValues.gasPrice - Price per gas for legacy transactions.
|
|
819
|
+
* @param gasValues.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.
|
|
820
|
+
* @param gasValues.maxFeePerGas - Maximum amount per gas to pay for the transaction, including the priority fee.
|
|
821
|
+
* @param gasValues.estimateUsed - Which estimate level was used.
|
|
822
|
+
* @param gasValues.estimateSuggested - Which estimate level that the API suggested.
|
|
823
|
+
* @param gasValues.defaultGasEstimates - The default estimate for gas.
|
|
824
|
+
* @param gasValues.originalGasEstimate - Original estimate for gas.
|
|
825
|
+
* @param gasValues.userEditedGasLimit - The gas limit supplied by user.
|
|
826
|
+
* @param gasValues.userFeeLevel - Estimate level user selected.
|
|
827
|
+
* @returns The updated transactionMeta.
|
|
828
|
+
*/
|
|
829
|
+
updateTransactionGasFees(transactionId, { defaultGasEstimates, estimateUsed, estimateSuggested, gas, gasLimit, gasPrice, maxPriorityFeePerGas, maxFeePerGas, originalGasEstimate, userEditedGasLimit, userFeeLevel: userFeeLevelParam, }) {
|
|
830
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
831
|
+
if (!transactionMeta) {
|
|
832
|
+
throw new Error(`Cannot update transaction as no transaction metadata found`);
|
|
833
|
+
}
|
|
834
|
+
(0, utils_js_1.validateIfTransactionUnapprovedOrSubmitted)(transactionMeta, 'updateTransactionGasFees');
|
|
835
|
+
const clonedTransactionMeta = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
836
|
+
const isTransactionGasFeeEstimatesExists = transactionMeta.gasFeeEstimates;
|
|
837
|
+
const isAutomaticGasFeeUpdateEnabled = __classPrivateFieldGet(this, _TransactionController_isAutomaticGasFeeUpdateEnabled, "f").call(this, transactionMeta);
|
|
838
|
+
const userFeeLevel = userFeeLevelParam;
|
|
839
|
+
const isOneOfFeeLevelSelected = Object.values(types_js_1.GasFeeEstimateLevel).includes(userFeeLevel);
|
|
840
|
+
const shouldUpdateTxParamsGasFees = isTransactionGasFeeEstimatesExists &&
|
|
841
|
+
isAutomaticGasFeeUpdateEnabled &&
|
|
842
|
+
isOneOfFeeLevelSelected;
|
|
843
|
+
if (shouldUpdateTxParamsGasFees) {
|
|
844
|
+
(0, GasFeePoller_js_1.updateTransactionGasEstimates)({
|
|
845
|
+
txMeta: clonedTransactionMeta,
|
|
846
|
+
userFeeLevel,
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
const txParamsUpdate = {
|
|
850
|
+
gas,
|
|
851
|
+
gasLimit,
|
|
852
|
+
};
|
|
853
|
+
if (shouldUpdateTxParamsGasFees) {
|
|
854
|
+
// Get updated values from clonedTransactionMeta if we're using automated fee updates
|
|
855
|
+
Object.assign(txParamsUpdate, {
|
|
856
|
+
gasPrice: clonedTransactionMeta.txParams.gasPrice,
|
|
857
|
+
maxPriorityFeePerGas: clonedTransactionMeta.txParams.maxPriorityFeePerGas,
|
|
858
|
+
maxFeePerGas: clonedTransactionMeta.txParams.maxFeePerGas,
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
Object.assign(txParamsUpdate, {
|
|
863
|
+
gasPrice,
|
|
864
|
+
maxPriorityFeePerGas,
|
|
865
|
+
maxFeePerGas,
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
const transactionGasFees = {
|
|
869
|
+
txParams: (0, lodash_1.pickBy)(txParamsUpdate),
|
|
870
|
+
defaultGasEstimates,
|
|
871
|
+
estimateUsed,
|
|
872
|
+
estimateSuggested,
|
|
873
|
+
originalGasEstimate,
|
|
874
|
+
userEditedGasLimit,
|
|
875
|
+
userFeeLevel,
|
|
876
|
+
};
|
|
877
|
+
const filteredTransactionGasFees = (0, lodash_1.pickBy)(transactionGasFees);
|
|
878
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
879
|
+
transactionId,
|
|
880
|
+
skipResimulateCheck: true,
|
|
881
|
+
}, (draftTxMeta) => {
|
|
882
|
+
const { txParams, ...otherProps } = filteredTransactionGasFees;
|
|
883
|
+
Object.assign(draftTxMeta, otherProps);
|
|
884
|
+
if (txParams) {
|
|
885
|
+
Object.assign(draftTxMeta.txParams, txParams);
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
return __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Update the previous gas values of a transaction.
|
|
892
|
+
*
|
|
893
|
+
* @param transactionId - The ID of the transaction to update.
|
|
894
|
+
* @param previousGas - Previous gas values to update.
|
|
895
|
+
* @param previousGas.gasLimit - Maximum number of units of gas to use for this transaction.
|
|
896
|
+
* @param previousGas.maxFeePerGas - Maximum amount per gas to pay for the transaction, including the priority fee.
|
|
897
|
+
* @param previousGas.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.
|
|
898
|
+
* @returns The updated transactionMeta.
|
|
899
|
+
*/
|
|
900
|
+
updatePreviousGasParams(transactionId, { gasLimit, maxFeePerGas, maxPriorityFeePerGas, }) {
|
|
901
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
902
|
+
if (!transactionMeta) {
|
|
903
|
+
throw new Error(`Cannot update transaction as no transaction metadata found`);
|
|
904
|
+
}
|
|
905
|
+
(0, utils_js_1.validateIfTransactionUnapprovedOrSubmitted)(transactionMeta, 'updatePreviousGasParams');
|
|
906
|
+
const transactionPreviousGas = {
|
|
907
|
+
previousGas: {
|
|
908
|
+
gasLimit,
|
|
909
|
+
maxFeePerGas,
|
|
910
|
+
maxPriorityFeePerGas,
|
|
911
|
+
},
|
|
912
|
+
// TODO: Replace `any` with type
|
|
913
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
914
|
+
};
|
|
915
|
+
// only update what is defined
|
|
916
|
+
transactionPreviousGas.previousGas = (0, lodash_1.pickBy)(transactionPreviousGas.previousGas);
|
|
917
|
+
// merge updated previous gas values with existing transaction meta
|
|
918
|
+
const updatedMeta = (0, lodash_1.merge)({}, transactionMeta, transactionPreviousGas);
|
|
919
|
+
this.updateTransaction(updatedMeta, `${controllerName}:updatePreviousGasParams - Previous gas values updated`);
|
|
920
|
+
return __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Acquires a nonce lock for the given address on the specified network,
|
|
924
|
+
* ensuring that nonces are assigned sequentially without conflicts.
|
|
925
|
+
*
|
|
926
|
+
* @param address - The account address for which to acquire the nonce lock.
|
|
927
|
+
* @param networkClientId - The ID of the network client to use.
|
|
928
|
+
* @returns A promise that resolves to a nonce lock containing the next nonce and a release function.
|
|
929
|
+
*/
|
|
930
|
+
async getNonceLock(address, networkClientId) {
|
|
931
|
+
return __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNonceLock(address, networkClientId);
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Updates the editable parameters of a transaction.
|
|
935
|
+
*
|
|
936
|
+
* @param txId - The ID of the transaction to update.
|
|
937
|
+
* @param params - The editable parameters to update.
|
|
938
|
+
* @param params.containerTypes - Container types applied to the parameters.
|
|
939
|
+
* @param params.data - Data to pass with the transaction.
|
|
940
|
+
* @param params.from - Address to send the transaction from.
|
|
941
|
+
* @param params.gas - Maximum number of units of gas to use for the transaction.
|
|
942
|
+
* @param params.gasPrice - Price per gas for legacy transactions.
|
|
943
|
+
* @param params.maxFeePerGas - Maximum amount per gas to pay for the transaction, including the priority fee.
|
|
944
|
+
* @param params.maxPriorityFeePerGas - Maximum amount per gas to give to validator as incentive.
|
|
945
|
+
* @param params.updateType - Whether to update the transaction type. Defaults to `true`.
|
|
946
|
+
* @param params.to - Address to send the transaction to.
|
|
947
|
+
* @param params.value - Value associated with the transaction.
|
|
948
|
+
* @returns The updated transaction metadata.
|
|
949
|
+
*/
|
|
950
|
+
async updateEditableParams(txId, { containerTypes, data, from, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to, updateType, value, }) {
|
|
951
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, txId);
|
|
952
|
+
if (!transactionMeta) {
|
|
953
|
+
throw new Error(`Cannot update editable params as no transaction metadata found`);
|
|
954
|
+
}
|
|
955
|
+
(0, utils_js_1.validateIfTransactionUnapproved)(transactionMeta, 'updateEditableParams');
|
|
956
|
+
const editableParams = {
|
|
957
|
+
txParams: {
|
|
958
|
+
data,
|
|
959
|
+
from,
|
|
960
|
+
to,
|
|
961
|
+
value,
|
|
962
|
+
gas,
|
|
963
|
+
gasPrice,
|
|
964
|
+
maxFeePerGas,
|
|
965
|
+
maxPriorityFeePerGas,
|
|
966
|
+
},
|
|
967
|
+
};
|
|
968
|
+
editableParams.txParams = (0, lodash_1.pickBy)(editableParams.txParams);
|
|
969
|
+
const updatedTransaction = (0, lodash_1.merge)({}, transactionMeta, editableParams);
|
|
970
|
+
const { networkClientId } = transactionMeta;
|
|
971
|
+
if (updateType !== false) {
|
|
972
|
+
const { type } = await (0, transaction_type_js_1.determineTransactionType)(updatedTransaction.txParams, {
|
|
973
|
+
messenger: this.messenger,
|
|
974
|
+
networkClientId,
|
|
975
|
+
});
|
|
976
|
+
updatedTransaction.type = type;
|
|
977
|
+
}
|
|
978
|
+
if (containerTypes) {
|
|
979
|
+
updatedTransaction.containerTypes = containerTypes;
|
|
980
|
+
const isNewlyWrapped = containerTypes.length && !transactionMeta.containerTypes?.length;
|
|
981
|
+
if (isNewlyWrapped && !transactionMeta.txParamsOriginal) {
|
|
982
|
+
updatedTransaction.txParamsOriginal = (0, lodash_1.cloneDeep)(transactionMeta.txParams);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
await (0, layer1_gas_fee_flow_js_1.updateTransactionLayer1GasFee)({
|
|
986
|
+
layer1GasFeeFlows: __classPrivateFieldGet(this, _TransactionController_layer1GasFeeFlows, "f"),
|
|
987
|
+
messenger: this.messenger,
|
|
988
|
+
transactionMeta: updatedTransaction,
|
|
989
|
+
});
|
|
990
|
+
this.updateTransaction(updatedTransaction, `Update Editable Params for ${txId}`);
|
|
991
|
+
return __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, txId);
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Update the isActive state of a transaction.
|
|
995
|
+
*
|
|
996
|
+
* @param transactionId - The ID of the transaction to update.
|
|
997
|
+
* @param isActive - The active state.
|
|
998
|
+
*/
|
|
999
|
+
setTransactionActive(transactionId, isActive) {
|
|
1000
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1001
|
+
if (!transactionMeta) {
|
|
1002
|
+
throw new Error(`Transaction with id ${transactionId} not found`);
|
|
1003
|
+
}
|
|
1004
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1005
|
+
transactionId,
|
|
1006
|
+
skipValidation: true,
|
|
1007
|
+
skipResimulateCheck: true,
|
|
1008
|
+
}, (updatedTransactionMeta) => {
|
|
1009
|
+
updatedTransactionMeta.isActive = isActive;
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Signs and returns the raw transaction data for provided transaction params list.
|
|
1014
|
+
*
|
|
1015
|
+
* @param listOfTxParams - The list of transaction params to approve.
|
|
1016
|
+
* @param opts - Options bag.
|
|
1017
|
+
* @param opts.hasNonce - Whether the transactions already have a nonce.
|
|
1018
|
+
* @returns The raw transactions.
|
|
1019
|
+
*/
|
|
1020
|
+
async approveTransactionsWithSameNonce(listOfTxParams = [], { hasNonce } = {}) {
|
|
1021
|
+
(0, logger_js_1.projectLogger)('Approving transactions with same nonce', {
|
|
1022
|
+
transactions: listOfTxParams,
|
|
1023
|
+
});
|
|
1024
|
+
if (listOfTxParams.length === 0) {
|
|
1025
|
+
return '';
|
|
1026
|
+
}
|
|
1027
|
+
const initialTx = listOfTxParams[0];
|
|
1028
|
+
const { chainId } = initialTx;
|
|
1029
|
+
const networkClientId = (0, provider_js_1.getNetworkClientId)({
|
|
1030
|
+
messenger: this.messenger,
|
|
1031
|
+
chainId,
|
|
1032
|
+
});
|
|
1033
|
+
const initialTxAsEthTx = (0, prepare_js_1.prepareTransaction)(chainId, initialTx);
|
|
1034
|
+
const initialTxAsSerializedHex = (0, prepare_js_1.serializeTransaction)(chainId, initialTxAsEthTx);
|
|
1035
|
+
if (__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").has(initialTxAsSerializedHex)) {
|
|
1036
|
+
return '';
|
|
1037
|
+
}
|
|
1038
|
+
__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").add(initialTxAsSerializedHex);
|
|
1039
|
+
let rawTransactions, nonceLock;
|
|
1040
|
+
try {
|
|
1041
|
+
// TODO: we should add a check to verify that all transactions have the same from address
|
|
1042
|
+
const fromAddress = initialTx.from;
|
|
1043
|
+
const requiresNonce = hasNonce !== true;
|
|
1044
|
+
nonceLock = requiresNonce
|
|
1045
|
+
? await this.getNonceLock(fromAddress, networkClientId)
|
|
1046
|
+
: undefined;
|
|
1047
|
+
const nonce = nonceLock
|
|
1048
|
+
? (0, utils_1.add0x)(nonceLock.nextNonce.toString(16))
|
|
1049
|
+
: initialTx.nonce;
|
|
1050
|
+
if (nonceLock) {
|
|
1051
|
+
(0, logger_js_1.projectLogger)('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails);
|
|
1052
|
+
}
|
|
1053
|
+
rawTransactions = await Promise.all(listOfTxParams.map((txParams) => {
|
|
1054
|
+
txParams.nonce = nonce;
|
|
1055
|
+
return __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_signExternalTransaction).call(this, txParams.chainId, txParams);
|
|
1056
|
+
}));
|
|
1057
|
+
}
|
|
1058
|
+
catch (error) {
|
|
1059
|
+
(0, logger_js_1.projectLogger)('Error while signing transactions with same nonce', error);
|
|
1060
|
+
// Must set transaction to submitted/failed before releasing lock
|
|
1061
|
+
// continue with error chain
|
|
1062
|
+
throw error;
|
|
1063
|
+
}
|
|
1064
|
+
finally {
|
|
1065
|
+
nonceLock?.releaseLock();
|
|
1066
|
+
__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").delete(initialTxAsSerializedHex);
|
|
1067
|
+
}
|
|
1068
|
+
return rawTransactions;
|
|
1069
|
+
}
|
|
1070
|
+
/**
|
|
1071
|
+
* Update a custodial transaction.
|
|
1072
|
+
*
|
|
1073
|
+
* @param request - The custodial transaction update request.
|
|
1074
|
+
*
|
|
1075
|
+
* @returns The updated transaction metadata.
|
|
1076
|
+
*/
|
|
1077
|
+
updateCustodialTransaction(request) {
|
|
1078
|
+
const { transactionId, errorMessage, hash, status, gasLimit, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, type, } = request;
|
|
1079
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1080
|
+
if (!transactionMeta) {
|
|
1081
|
+
throw new Error(`Cannot update custodial transaction as no transaction metadata found`);
|
|
1082
|
+
}
|
|
1083
|
+
if (status &&
|
|
1084
|
+
![
|
|
1085
|
+
types_js_1.TransactionStatus.submitted,
|
|
1086
|
+
types_js_1.TransactionStatus.signed,
|
|
1087
|
+
types_js_1.TransactionStatus.failed,
|
|
1088
|
+
].includes(status)) {
|
|
1089
|
+
throw new Error(`Cannot update custodial transaction with status: ${status}`);
|
|
1090
|
+
}
|
|
1091
|
+
const updatedTransactionMeta = (0, lodash_1.merge)({}, transactionMeta, (0, lodash_1.pickBy)({ hash, status }));
|
|
1092
|
+
if (updatedTransactionMeta.status === types_js_1.TransactionStatus.submitted) {
|
|
1093
|
+
updatedTransactionMeta.submittedTime = new Date().getTime();
|
|
1094
|
+
}
|
|
1095
|
+
if (updatedTransactionMeta.status === types_js_1.TransactionStatus.failed) {
|
|
1096
|
+
updatedTransactionMeta.error = (0, utils_js_1.normalizeTxError)(new Error(errorMessage));
|
|
1097
|
+
}
|
|
1098
|
+
// Update txParams properties with a single pickBy operation
|
|
1099
|
+
updatedTransactionMeta.txParams = (0, lodash_1.merge)({}, updatedTransactionMeta.txParams, (0, lodash_1.pickBy)({
|
|
1100
|
+
gasLimit,
|
|
1101
|
+
gasPrice,
|
|
1102
|
+
maxFeePerGas,
|
|
1103
|
+
maxPriorityFeePerGas,
|
|
1104
|
+
nonce,
|
|
1105
|
+
type,
|
|
1106
|
+
}));
|
|
1107
|
+
// Special case for type change to legacy
|
|
1108
|
+
if (type === types_js_1.TransactionEnvelopeType.legacy) {
|
|
1109
|
+
delete updatedTransactionMeta.txParams.maxFeePerGas;
|
|
1110
|
+
delete updatedTransactionMeta.txParams.maxPriorityFeePerGas;
|
|
1111
|
+
}
|
|
1112
|
+
this.updateTransaction(updatedTransactionMeta, `${controllerName}:updateCustodialTransaction - Custodial transaction updated`);
|
|
1113
|
+
if (status &&
|
|
1114
|
+
[types_js_1.TransactionStatus.submitted, types_js_1.TransactionStatus.failed].includes(status)) {
|
|
1115
|
+
this.messenger.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1116
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${updatedTransactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1117
|
+
}
|
|
1118
|
+
return updatedTransactionMeta;
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
* Search transaction metadata for matching entries.
|
|
1122
|
+
*
|
|
1123
|
+
* @param opts - Options bag.
|
|
1124
|
+
* @param opts.initialList - The transactions to search. Defaults to the current state.
|
|
1125
|
+
* @param opts.limit - The maximum number of transactions to return. No limit by default.
|
|
1126
|
+
* @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with.
|
|
1127
|
+
* @returns An array of transactions matching the provided options.
|
|
1128
|
+
*/
|
|
1129
|
+
getTransactions({ initialList, limit, searchCriteria = {}, } = {}) {
|
|
1130
|
+
// searchCriteria is an object that might have values that aren't predicate
|
|
1131
|
+
// methods. When providing any other value type (string, number, etc), we
|
|
1132
|
+
// consider this shorthand for "check the value at key for strict equality
|
|
1133
|
+
// with the provided value". To conform this object to be only methods, we
|
|
1134
|
+
// mapValues (lodash) such that every value on the object is a method that
|
|
1135
|
+
// returns a boolean.
|
|
1136
|
+
const predicateMethods = (0, lodash_1.mapValues)(searchCriteria, (predicate) => {
|
|
1137
|
+
return typeof predicate === 'function'
|
|
1138
|
+
? predicate
|
|
1139
|
+
: // TODO: Replace `any` with type
|
|
1140
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1141
|
+
(value) => value === predicate;
|
|
1142
|
+
});
|
|
1143
|
+
const transactionsToFilter = initialList ?? this.state.transactions;
|
|
1144
|
+
// Combine sortBy and pickBy to transform our state object into an array of
|
|
1145
|
+
// matching transactions that are sorted by time.
|
|
1146
|
+
const filteredTransactions = (0, lodash_1.sortBy)((0, lodash_1.pickBy)(transactionsToFilter, (transaction) => {
|
|
1147
|
+
// iterate over the predicateMethods keys to check if the transaction
|
|
1148
|
+
// matches the searchCriteria
|
|
1149
|
+
for (const [key, predicate] of Object.entries(predicateMethods)) {
|
|
1150
|
+
// We return false early as soon as we know that one of the specified
|
|
1151
|
+
// search criteria do not match the transaction. This prevents
|
|
1152
|
+
// needlessly checking all criteria when we already know the criteria
|
|
1153
|
+
// are not fully satisfied. We check both txParams and the base
|
|
1154
|
+
// object as predicate keys can be either.
|
|
1155
|
+
if (key in transaction.txParams) {
|
|
1156
|
+
// TODO: Replace `any` with type
|
|
1157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1158
|
+
if (predicate(transaction.txParams[key]) === false) {
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
// TODO: Replace `any` with type
|
|
1162
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1163
|
+
}
|
|
1164
|
+
else if (predicate(transaction[key]) === false) {
|
|
1165
|
+
return false;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
return true;
|
|
1169
|
+
}), 'time');
|
|
1170
|
+
if (limit !== undefined) {
|
|
1171
|
+
// We need to have all transactions of a given nonce in order to display
|
|
1172
|
+
// necessary details in the UI. We use the size of this set to determine
|
|
1173
|
+
// whether we have reached the limit provided, thus ensuring that all
|
|
1174
|
+
// transactions of nonces we include will be sent to the UI.
|
|
1175
|
+
const nonces = new Set();
|
|
1176
|
+
const txs = [];
|
|
1177
|
+
// By default, the transaction list we filter from is sorted by time ASC.
|
|
1178
|
+
// To ensure that filtered results prefers the newest transactions we
|
|
1179
|
+
// iterate from right to left, inserting transactions into front of a new
|
|
1180
|
+
// array. The original order is preserved, but we ensure that newest txs
|
|
1181
|
+
// are preferred.
|
|
1182
|
+
for (let i = filteredTransactions.length - 1; i > -1; i--) {
|
|
1183
|
+
const txMeta = filteredTransactions[i];
|
|
1184
|
+
const { nonce } = txMeta.txParams;
|
|
1185
|
+
if (!nonces.has(nonce)) {
|
|
1186
|
+
if (nonces.size < limit) {
|
|
1187
|
+
nonces.add(nonce);
|
|
1188
|
+
}
|
|
1189
|
+
else {
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
// Push transaction into the beginning of our array to ensure the
|
|
1194
|
+
// original order is preserved.
|
|
1195
|
+
txs.unshift(txMeta);
|
|
1196
|
+
}
|
|
1197
|
+
return txs;
|
|
1198
|
+
}
|
|
1199
|
+
return filteredTransactions;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Estimates the gas fees for a transaction.
|
|
1203
|
+
*
|
|
1204
|
+
* @param args - The arguments for estimating gas fees.
|
|
1205
|
+
* @param args.transactionParams - The transaction parameters to estimate fees for.
|
|
1206
|
+
* @param args.chainId - The chain ID to use. If not provided, the network client ID is used to determine the chain.
|
|
1207
|
+
* @param args.networkClientId - The network client ID to use for the estimation.
|
|
1208
|
+
* @returns A promise that resolves to the estimated gas fee response.
|
|
1209
|
+
*/
|
|
1210
|
+
async estimateGasFee({ transactionParams, chainId, networkClientId: requestNetworkClientId, }) {
|
|
1211
|
+
const { id: networkClientId } = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({
|
|
1212
|
+
chainId,
|
|
1213
|
+
networkClientId: requestNetworkClientId,
|
|
1214
|
+
});
|
|
1215
|
+
const transactionMeta = {
|
|
1216
|
+
txParams: transactionParams,
|
|
1217
|
+
chainId,
|
|
1218
|
+
networkClientId,
|
|
1219
|
+
};
|
|
1220
|
+
// Guaranteed as the default gas fee flow matches all transactions.
|
|
1221
|
+
const gasFeeFlow = (0, gas_flow_js_1.getGasFeeFlow)(transactionMeta, __classPrivateFieldGet(this, _TransactionController_gasFeeFlows, "f"), this.messenger);
|
|
1222
|
+
const gasFeeControllerData = await this.messenger.call('GasFeeController:fetchGasFeeEstimates', { networkClientId });
|
|
1223
|
+
return gasFeeFlow.getGasFees({
|
|
1224
|
+
gasFeeControllerData,
|
|
1225
|
+
messenger: this.messenger,
|
|
1226
|
+
transactionMeta,
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Determine the layer 1 gas fee for the given transaction parameters.
|
|
1231
|
+
*
|
|
1232
|
+
* @param request - The request object.
|
|
1233
|
+
* @param request.transactionParams - The transaction parameters to estimate the layer 1 gas fee for.
|
|
1234
|
+
* @param request.chainId - The ID of the chain where the transaction will be executed.
|
|
1235
|
+
* @param request.networkClientId - The ID of a specific network client to process the transaction.
|
|
1236
|
+
* @returns The layer 1 gas fee.
|
|
1237
|
+
*/
|
|
1238
|
+
async getLayer1GasFee({ transactionParams, chainId, networkClientId, }) {
|
|
1239
|
+
const resolvedNetworkClientId = (0, provider_js_1.getNetworkClientId)({
|
|
1240
|
+
messenger: this.messenger,
|
|
1241
|
+
chainId,
|
|
1242
|
+
networkClientId,
|
|
1243
|
+
});
|
|
1244
|
+
return await (0, layer1_gas_fee_flow_js_1.getTransactionLayer1GasFee)({
|
|
1245
|
+
layer1GasFeeFlows: __classPrivateFieldGet(this, _TransactionController_layer1GasFeeFlows, "f"),
|
|
1246
|
+
messenger: this.messenger,
|
|
1247
|
+
transactionMeta: {
|
|
1248
|
+
txParams: transactionParams,
|
|
1249
|
+
chainId,
|
|
1250
|
+
networkClientId: resolvedNetworkClientId,
|
|
1251
|
+
},
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Removes unapproved transactions from state.
|
|
1256
|
+
*/
|
|
1257
|
+
clearUnapprovedTransactions() {
|
|
1258
|
+
const transactions = this.state.transactions.filter(({ status }) => status !== types_js_1.TransactionStatus.unapproved);
|
|
1259
|
+
this.update((state) => {
|
|
1260
|
+
state.transactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_trimTransactionsForState).call(this, transactions);
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Stop the signing process for a specific transaction.
|
|
1265
|
+
* Throws an error causing the transaction status to be set to failed.
|
|
1266
|
+
*
|
|
1267
|
+
* @param transactionId - The ID of the transaction to stop signing.
|
|
1268
|
+
*/
|
|
1269
|
+
abortTransactionSigning(transactionId) {
|
|
1270
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1271
|
+
if (!transactionMeta) {
|
|
1272
|
+
throw new Error(`Cannot abort signing as no transaction metadata found`);
|
|
1273
|
+
}
|
|
1274
|
+
const abortCallback = __classPrivateFieldGet(this, _TransactionController_signAbortCallbacks, "f").get(transactionId);
|
|
1275
|
+
if (!abortCallback) {
|
|
1276
|
+
throw new Error(`Cannot abort signing as transaction is not waiting for signing`);
|
|
1277
|
+
}
|
|
1278
|
+
abortCallback();
|
|
1279
|
+
__classPrivateFieldGet(this, _TransactionController_signAbortCallbacks, "f").delete(transactionId);
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Update the transaction data of a single nested transaction within an atomic batch transaction.
|
|
1283
|
+
*
|
|
1284
|
+
* @param options - The options bag.
|
|
1285
|
+
* @param options.transactionId - ID of the atomic batch transaction.
|
|
1286
|
+
* @param options.transactionIndex - Index of the nested transaction within the atomic batch transaction.
|
|
1287
|
+
* @param options.transactionData - New data to set for the nested transaction.
|
|
1288
|
+
* @returns The updated data for the atomic batch transaction.
|
|
1289
|
+
*/
|
|
1290
|
+
async updateAtomicBatchData({ transactionId, transactionIndex, transactionData, }) {
|
|
1291
|
+
(0, logger_js_1.projectLogger)('Updating atomic batch data', {
|
|
1292
|
+
transactionId,
|
|
1293
|
+
transactionIndex,
|
|
1294
|
+
transactionData,
|
|
1295
|
+
});
|
|
1296
|
+
const currentTransaction = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1297
|
+
if (!currentTransaction) {
|
|
1298
|
+
throw new Error(`Cannot update transaction as ID not found - ${transactionId}`);
|
|
1299
|
+
}
|
|
1300
|
+
const { nestedTransactions, transactionData: updatedTransactionData } = (0, eip7702_js_1.updateEIP7702BatchData)({
|
|
1301
|
+
from: currentTransaction.txParams.from,
|
|
1302
|
+
transactions: currentTransaction.nestedTransactions ?? [],
|
|
1303
|
+
updates: [{ transactionIndex, transactionData }],
|
|
1304
|
+
});
|
|
1305
|
+
const updatedTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (transactionMeta) => {
|
|
1306
|
+
transactionMeta.nestedTransactions = nestedTransactions;
|
|
1307
|
+
transactionMeta.txParams.data = updatedTransactionData;
|
|
1308
|
+
transactionMeta.txParams.gas = undefined;
|
|
1309
|
+
transactionMeta.gasLimitNoBuffer = undefined;
|
|
1310
|
+
transactionMeta.gasUsed = undefined;
|
|
1311
|
+
transactionMeta.securityAlertResponse = undefined;
|
|
1312
|
+
transactionMeta.simulationData = undefined;
|
|
1313
|
+
transactionMeta.simulationFails = undefined;
|
|
1314
|
+
if (transactionMeta.revert) {
|
|
1315
|
+
delete transactionMeta.revert.gas;
|
|
1316
|
+
if (!transactionMeta.revert.simulation &&
|
|
1317
|
+
!transactionMeta.revert.receipt) {
|
|
1318
|
+
transactionMeta.revert = undefined;
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
const draftTransaction = (0, lodash_1.cloneDeep)({
|
|
1323
|
+
...updatedTransactionMeta,
|
|
1324
|
+
txParams: {
|
|
1325
|
+
...updatedTransactionMeta.txParams,
|
|
1326
|
+
// Clear existing gas to force estimation.
|
|
1327
|
+
gas: undefined,
|
|
1328
|
+
},
|
|
1329
|
+
});
|
|
1330
|
+
await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasEstimate).call(this, draftTransaction);
|
|
1331
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (transactionMeta) => {
|
|
1332
|
+
transactionMeta.txParams.gas = draftTransaction.txParams.gas;
|
|
1333
|
+
transactionMeta.simulationFails = draftTransaction.simulationFails;
|
|
1334
|
+
transactionMeta.gasLimitNoBuffer = draftTransaction.gasLimitNoBuffer;
|
|
1335
|
+
const draftGasRevert = draftTransaction.revert?.gas;
|
|
1336
|
+
if (draftGasRevert) {
|
|
1337
|
+
transactionMeta.revert = {
|
|
1338
|
+
...transactionMeta.revert,
|
|
1339
|
+
gas: draftGasRevert,
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
return updatedTransactionData;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Update the batch transactions associated with a transaction.
|
|
1347
|
+
* These transactions will be submitted with the main transaction as a batch.
|
|
1348
|
+
*
|
|
1349
|
+
* @param request - The request object.
|
|
1350
|
+
* @param request.transactionId - The ID of the transaction to update.
|
|
1351
|
+
* @param request.batchTransactions - The new batch transactions.
|
|
1352
|
+
*/
|
|
1353
|
+
updateBatchTransactions({ transactionId, batchTransactions, }) {
|
|
1354
|
+
(0, logger_js_1.projectLogger)('Updating batch transactions', { transactionId, batchTransactions });
|
|
1355
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1356
|
+
transactionId,
|
|
1357
|
+
}, (transactionMeta) => {
|
|
1358
|
+
transactionMeta.batchTransactions = batchTransactions;
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Update the selected gas fee token for a transaction.
|
|
1363
|
+
*
|
|
1364
|
+
* @param transactionId - The ID of the transaction to update.
|
|
1365
|
+
* @param contractAddress - The contract address of the selected gas fee token.
|
|
1366
|
+
*/
|
|
1367
|
+
updateSelectedGasFeeToken(transactionId, contractAddress) {
|
|
1368
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (transactionMeta) => {
|
|
1369
|
+
const hasMatchingGasFeeToken = transactionMeta.gasFeeTokens?.some((token) => token.tokenAddress.toLowerCase() === contractAddress?.toLowerCase());
|
|
1370
|
+
if (contractAddress && !hasMatchingGasFeeToken) {
|
|
1371
|
+
throw new Error(`No matching gas fee token found with address - ${contractAddress}`);
|
|
1372
|
+
}
|
|
1373
|
+
transactionMeta.selectedGasFeeToken = contractAddress;
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Update the required transaction IDs for a transaction.
|
|
1378
|
+
*
|
|
1379
|
+
* @param request - The request object.
|
|
1380
|
+
* @param request.transactionId - The ID of the transaction to update.
|
|
1381
|
+
* @param request.requiredTransactionIds - The additional required transaction IDs.
|
|
1382
|
+
* @param request.append - Whether to append the IDs to any existing values. Defaults to true.
|
|
1383
|
+
*/
|
|
1384
|
+
updateRequiredTransactionIds({ transactionId, requiredTransactionIds, append, }) {
|
|
1385
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (transactionMeta) => {
|
|
1386
|
+
const { requiredTransactionIds: existing } = transactionMeta;
|
|
1387
|
+
transactionMeta.requiredTransactionIds = [
|
|
1388
|
+
...(existing && append !== false ? existing : []),
|
|
1389
|
+
...requiredTransactionIds,
|
|
1390
|
+
];
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Emulate a new transaction.
|
|
1395
|
+
*
|
|
1396
|
+
* @param transactionId - The transaction ID.
|
|
1397
|
+
*/
|
|
1398
|
+
emulateNewTransaction(transactionId) {
|
|
1399
|
+
const transactionMeta = this.state.transactions.find((tx) => tx.id === transactionId);
|
|
1400
|
+
if (!transactionMeta) {
|
|
1401
|
+
return;
|
|
1402
|
+
}
|
|
1403
|
+
if (transactionMeta.type === types_js_1.TransactionType.swap) {
|
|
1404
|
+
this.messenger.publish('TransactionController:transactionNewSwap', {
|
|
1405
|
+
transactionMeta,
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
else if (transactionMeta.type === types_js_1.TransactionType.swapApproval) {
|
|
1409
|
+
this.messenger.publish('TransactionController:transactionNewSwapApproval', { transactionMeta });
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Emulate a transaction update.
|
|
1414
|
+
*
|
|
1415
|
+
* @param transactionMeta - Transaction metadata.
|
|
1416
|
+
*/
|
|
1417
|
+
emulateTransactionUpdate(transactionMeta) {
|
|
1418
|
+
const updatedTransactionMeta = {
|
|
1419
|
+
...transactionMeta,
|
|
1420
|
+
txParams: {
|
|
1421
|
+
...transactionMeta.txParams,
|
|
1422
|
+
from: this.messenger.call('AccountsController:getSelectedAccount')
|
|
1423
|
+
.address,
|
|
1424
|
+
},
|
|
1425
|
+
};
|
|
1426
|
+
const transactionExists = this.state.transactions.some((tx) => tx.id === updatedTransactionMeta.id);
|
|
1427
|
+
if (!transactionExists) {
|
|
1428
|
+
this.update((state) => {
|
|
1429
|
+
state.transactions.push(updatedTransactionMeta);
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
this.updateTransaction(updatedTransactionMeta, 'Generated from user operation');
|
|
1433
|
+
this.messenger.publish('TransactionController:transactionStatusUpdated', {
|
|
1434
|
+
transactionMeta: updatedTransactionMeta,
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Retrieve available gas fee tokens for a transaction.
|
|
1439
|
+
*
|
|
1440
|
+
* @param request - The request object containing transaction details.
|
|
1441
|
+
* @returns The list of available gas fee tokens.
|
|
1442
|
+
*/
|
|
1443
|
+
async getGasFeeTokens(request) {
|
|
1444
|
+
const { chainId, data, from, to, value } = request;
|
|
1445
|
+
const networkClientId = (0, provider_js_1.getNetworkClientId)({
|
|
1446
|
+
messenger: this.messenger,
|
|
1447
|
+
chainId,
|
|
1448
|
+
});
|
|
1449
|
+
const delegationAddress = await (0, eip7702_js_1.getDelegationAddress)(from, this.messenger, networkClientId);
|
|
1450
|
+
const transaction = {
|
|
1451
|
+
chainId,
|
|
1452
|
+
delegationAddress,
|
|
1453
|
+
isExternalSign: true,
|
|
1454
|
+
txParams: {
|
|
1455
|
+
data,
|
|
1456
|
+
from,
|
|
1457
|
+
to,
|
|
1458
|
+
value,
|
|
1459
|
+
},
|
|
1460
|
+
};
|
|
1461
|
+
const result = await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeTokens).call(this, transaction);
|
|
1462
|
+
return result.gasFeeTokens;
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
exports.TransactionController = TransactionController;
|
|
1466
|
+
_TransactionController_afterAdd = new WeakMap(), _TransactionController_approvingTransactionIds = new WeakMap(), _TransactionController_beforeCheckPendingTransaction = new WeakMap(), _TransactionController_beforePublish = new WeakMap(), _TransactionController_beforeSign = new WeakMap(), _TransactionController_gasFeeFlows = new WeakMap(), _TransactionController_getPermittedAccounts = new WeakMap(), _TransactionController_getSavedGasFees = new WeakMap(), _TransactionController_getSimulationConfig = new WeakMap(), _TransactionController_internalEvents = new WeakMap(), _TransactionController_isAutomaticGasFeeUpdateEnabled = new WeakMap(), _TransactionController_isEIP7702GasFeeTokensEnabled = new WeakMap(), _TransactionController_isFirstTimeInteractionEnabled = new WeakMap(), _TransactionController_isSimulationEnabled = new WeakMap(), _TransactionController_isSwapsDisabled = new WeakMap(), _TransactionController_isTimeoutEnabled = new WeakMap(), _TransactionController_layer1GasFeeFlows = new WeakMap(), _TransactionController_methodDataHelper = new WeakMap(), _TransactionController_multichainTrackingHelper = new WeakMap(), _TransactionController_publicKeyEIP7702 = new WeakMap(), _TransactionController_publish = new WeakMap(), _TransactionController_publishBatchHook = new WeakMap(), _TransactionController_signAbortCallbacks = new WeakMap(), _TransactionController_skipSimulationTransactionIds = new WeakMap(), _TransactionController_simulationRequestTokens = new WeakMap(), _TransactionController_testGasFeeFlows = new WeakMap(), _TransactionController_trace = new WeakMap(), _TransactionController_checkForPendingTransactionAndStartPolling = new WeakMap(), _TransactionController_instances = new WeakSet(), _TransactionController_retryTransaction = async function _TransactionController_retryTransaction({ actionId, afterSubmit, estimatedBaseFee, gasValues, label, prepareTransactionParams, rate, transactionId, transactionType, }) {
|
|
1467
|
+
if (gasValues) {
|
|
1468
|
+
// Not good practice to reassign a parameter but temporarily avoiding a larger refactor.
|
|
1469
|
+
// eslint-disable-next-line no-param-reassign
|
|
1470
|
+
gasValues = (0, utils_js_1.normalizeGasFeeValues)(gasValues);
|
|
1471
|
+
(0, utils_js_1.validateGasValues)(gasValues);
|
|
1472
|
+
}
|
|
1473
|
+
(0, logger_js_1.projectLogger)(`Creating ${label} transaction`, transactionId, gasValues);
|
|
1474
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1475
|
+
/* istanbul ignore next */
|
|
1476
|
+
if (!transactionMeta) {
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
const newTxParams = (0, retry_js_1.getTransactionParamsWithIncreasedGasFee)(transactionMeta.txParams, rate, gasValues);
|
|
1480
|
+
prepareTransactionParams?.(newTxParams);
|
|
1481
|
+
const unsignedEthTx = (0, prepare_js_1.prepareTransaction)(transactionMeta.chainId, newTxParams);
|
|
1482
|
+
const signedTxData = await this.messenger.call('KeyringController:signTransaction', unsignedEthTx, transactionMeta.txParams.from);
|
|
1483
|
+
const transactionMetaWithRsv = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionMetaRSV).call(this, transactionMeta, signedTxData);
|
|
1484
|
+
const rawTx = (0, prepare_js_1.serializeTransaction)(transactionMeta.chainId, signedTxData);
|
|
1485
|
+
const newFee = newTxParams.maxFeePerGas ?? newTxParams.gasPrice;
|
|
1486
|
+
const oldFee = newTxParams.maxFeePerGas
|
|
1487
|
+
? transactionMetaWithRsv.txParams.maxFeePerGas
|
|
1488
|
+
: transactionMetaWithRsv.txParams.gasPrice;
|
|
1489
|
+
(0, logger_js_1.projectLogger)(`Submitting ${label} transaction`, {
|
|
1490
|
+
oldFee,
|
|
1491
|
+
newFee,
|
|
1492
|
+
txParams: newTxParams,
|
|
1493
|
+
});
|
|
1494
|
+
const newTransactionMeta = {
|
|
1495
|
+
...transactionMetaWithRsv,
|
|
1496
|
+
actionId,
|
|
1497
|
+
estimatedBaseFee,
|
|
1498
|
+
id: (0, uuid_1.v1)(),
|
|
1499
|
+
originalGasEstimate: transactionMeta.txParams.gas,
|
|
1500
|
+
originalType: transactionMeta.type,
|
|
1501
|
+
rawTx,
|
|
1502
|
+
time: Date.now(),
|
|
1503
|
+
txParams: newTxParams,
|
|
1504
|
+
type: transactionType,
|
|
1505
|
+
};
|
|
1506
|
+
const hash = await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_publishTransactionForRetry).call(this, {
|
|
1507
|
+
...newTransactionMeta,
|
|
1508
|
+
origin: label,
|
|
1509
|
+
});
|
|
1510
|
+
newTransactionMeta.hash = hash;
|
|
1511
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addMetadata).call(this, newTransactionMeta);
|
|
1512
|
+
// speedUpTransaction has no approval request, so we assume the user has already approved the transaction
|
|
1513
|
+
this.messenger.publish(`${controllerName}:transactionApproved`, {
|
|
1514
|
+
transactionMeta: newTransactionMeta,
|
|
1515
|
+
actionId,
|
|
1516
|
+
});
|
|
1517
|
+
this.messenger.publish(`${controllerName}:transactionSubmitted`, {
|
|
1518
|
+
transactionMeta: newTransactionMeta,
|
|
1519
|
+
actionId,
|
|
1520
|
+
});
|
|
1521
|
+
afterSubmit?.(newTransactionMeta);
|
|
1522
|
+
}, _TransactionController_signExternalTransaction = async function _TransactionController_signExternalTransaction(chainId, transactionParams) {
|
|
1523
|
+
const normalizedTransactionParams = (0, utils_js_1.normalizeTransactionParams)(transactionParams);
|
|
1524
|
+
const type = (0, utils_js_1.isEIP1559Transaction)(normalizedTransactionParams)
|
|
1525
|
+
? types_js_1.TransactionEnvelopeType.feeMarket
|
|
1526
|
+
: types_js_1.TransactionEnvelopeType.legacy;
|
|
1527
|
+
const updatedTransactionParams = {
|
|
1528
|
+
...normalizedTransactionParams,
|
|
1529
|
+
type,
|
|
1530
|
+
gasLimit: normalizedTransactionParams.gas,
|
|
1531
|
+
chainId,
|
|
1532
|
+
};
|
|
1533
|
+
const { from } = updatedTransactionParams;
|
|
1534
|
+
const unsignedTransaction = (0, prepare_js_1.prepareTransaction)(chainId, updatedTransactionParams);
|
|
1535
|
+
const signedTxData = await this.messenger.call('KeyringController:signTransaction', unsignedTransaction, from);
|
|
1536
|
+
const rawTransaction = (0, prepare_js_1.serializeTransaction)(chainId, signedTxData);
|
|
1537
|
+
return rawTransaction;
|
|
1538
|
+
}, _TransactionController_addMetadata = function _TransactionController_addMetadata(transactionMeta) {
|
|
1539
|
+
(0, validation_js_1.validateTxParams)(transactionMeta.txParams);
|
|
1540
|
+
this.update((state) => {
|
|
1541
|
+
state.transactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_trimTransactionsForState).call(this, [
|
|
1542
|
+
...state.transactions,
|
|
1543
|
+
transactionMeta,
|
|
1544
|
+
]);
|
|
1545
|
+
});
|
|
1546
|
+
}, _TransactionController_updateGasProperties = async function _TransactionController_updateGasProperties(transactionMeta, { traceContext } = {}) {
|
|
1547
|
+
const isEIP1559Compatible = transactionMeta.txParams.type !== types_js_1.TransactionEnvelopeType.legacy &&
|
|
1548
|
+
(await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEIP1559Compatibility).call(this, transactionMeta.networkClientId));
|
|
1549
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas', parentContext: traceContext }, async () => {
|
|
1550
|
+
await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateGasEstimate).call(this, transactionMeta);
|
|
1551
|
+
});
|
|
1552
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Gas Fees', parentContext: traceContext }, async () => await (0, gas_fees_js_1.updateGasFees)({
|
|
1553
|
+
eip1559: isEIP1559Compatible,
|
|
1554
|
+
gasFeeFlows: __classPrivateFieldGet(this, _TransactionController_gasFeeFlows, "f"),
|
|
1555
|
+
getGasFeeEstimates: (options) => this.messenger.call('GasFeeController:fetchGasFeeEstimates', options),
|
|
1556
|
+
getSavedGasFees: __classPrivateFieldGet(this, _TransactionController_getSavedGasFees, "f").bind(this),
|
|
1557
|
+
messenger: this.messenger,
|
|
1558
|
+
txMeta: transactionMeta,
|
|
1559
|
+
}));
|
|
1560
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Update Layer 1 Gas Fees', parentContext: traceContext }, async () => await (0, layer1_gas_fee_flow_js_1.updateTransactionLayer1GasFee)({
|
|
1561
|
+
layer1GasFeeFlows: __classPrivateFieldGet(this, _TransactionController_layer1GasFeeFlows, "f"),
|
|
1562
|
+
messenger: this.messenger,
|
|
1563
|
+
transactionMeta,
|
|
1564
|
+
}));
|
|
1565
|
+
}, _TransactionController_onBootCleanup = function _TransactionController_onBootCleanup() {
|
|
1566
|
+
this.clearUnapprovedTransactions();
|
|
1567
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failIncompleteTransactions).call(this);
|
|
1568
|
+
}, _TransactionController_failIncompleteTransactions = function _TransactionController_failIncompleteTransactions() {
|
|
1569
|
+
const incompleteTransactions = this.state.transactions.filter((transaction) => [types_js_1.TransactionStatus.approved, types_js_1.TransactionStatus.signed].includes(transaction.status));
|
|
1570
|
+
for (const transactionMeta of incompleteTransactions) {
|
|
1571
|
+
const requiredTransactionIds = transactionMeta.requiredTransactionIds ?? [];
|
|
1572
|
+
const allRequiredConfirmed = requiredTransactionIds.length > 0 &&
|
|
1573
|
+
requiredTransactionIds.every((id) => {
|
|
1574
|
+
const tx = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, id);
|
|
1575
|
+
return tx?.status === types_js_1.TransactionStatus.confirmed;
|
|
1576
|
+
});
|
|
1577
|
+
const message = allRequiredConfirmed
|
|
1578
|
+
? 'Transaction incomplete at startup with all required transactions confirmed'
|
|
1579
|
+
: 'Transaction incomplete at startup';
|
|
1580
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failTransaction).call(this, transactionMeta, new Error(message));
|
|
1581
|
+
for (const requiredTransactionId of requiredTransactionIds) {
|
|
1582
|
+
const requiredTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, requiredTransactionId);
|
|
1583
|
+
if (!requiredTransactionMeta ||
|
|
1584
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isFinalState).call(this, requiredTransactionMeta.status)) {
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1587
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failTransaction).call(this, requiredTransactionMeta, new Error('Parent transaction incomplete at startup'));
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
}, _TransactionController_processApproval = async function _TransactionController_processApproval(transactionMeta, { actionId, publishHook, requireApproval, shouldShowRequest = true, traceContext, }) {
|
|
1591
|
+
const { id: transactionId, isStateOnly } = transactionMeta;
|
|
1592
|
+
if (isStateOnly) {
|
|
1593
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId, skipValidation: true }, (tx) => {
|
|
1594
|
+
tx.status = types_js_1.TransactionStatus.submitted;
|
|
1595
|
+
tx.submittedTime = new Date().getTime();
|
|
1596
|
+
});
|
|
1597
|
+
return '';
|
|
1598
|
+
}
|
|
1599
|
+
let resultCallbacks;
|
|
1600
|
+
const { meta, isCompleted } = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isTransactionCompleted).call(this, transactionId);
|
|
1601
|
+
const finishedPromise = isCompleted
|
|
1602
|
+
? Promise.resolve(meta)
|
|
1603
|
+
: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_waitForTransactionFinished).call(this, transactionId);
|
|
1604
|
+
if (meta && !isCompleted) {
|
|
1605
|
+
try {
|
|
1606
|
+
if (requireApproval !== false) {
|
|
1607
|
+
const acceptResult = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Await Approval', parentContext: traceContext }, (context) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_requestApproval).call(this, transactionMeta, {
|
|
1608
|
+
shouldShowRequest,
|
|
1609
|
+
traceContext: context,
|
|
1610
|
+
}));
|
|
1611
|
+
resultCallbacks = acceptResult.resultCallbacks;
|
|
1612
|
+
const approvalValue = acceptResult.value;
|
|
1613
|
+
const updatedTransaction = approvalValue?.txMeta;
|
|
1614
|
+
if (updatedTransaction) {
|
|
1615
|
+
(0, logger_js_1.projectLogger)('Updating transaction with approval data', {
|
|
1616
|
+
customNonce: updatedTransaction.customNonceValue,
|
|
1617
|
+
params: updatedTransaction.txParams,
|
|
1618
|
+
});
|
|
1619
|
+
this.updateTransaction(updatedTransaction, 'TransactionController#processApproval - Updated with approval data');
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
const { isCompleted: isTxCompleted } = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isTransactionCompleted).call(this, transactionId);
|
|
1623
|
+
if (!isTxCompleted) {
|
|
1624
|
+
const approvalResult = await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_approveTransaction).call(this, transactionId, traceContext, publishHook);
|
|
1625
|
+
if (approvalResult === ApprovalState.SkippedViaBeforePublishHook &&
|
|
1626
|
+
resultCallbacks) {
|
|
1627
|
+
resultCallbacks.success();
|
|
1628
|
+
}
|
|
1629
|
+
const updatedTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1630
|
+
if (approvalResult === ApprovalState.Approved) {
|
|
1631
|
+
this.messenger.publish(`${controllerName}:transactionApproved`, {
|
|
1632
|
+
transactionMeta: updatedTransactionMeta,
|
|
1633
|
+
actionId,
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
catch (rawError) {
|
|
1639
|
+
const error = rawError;
|
|
1640
|
+
const { isCompleted: isTxCompleted } = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isTransactionCompleted).call(this, transactionId);
|
|
1641
|
+
if (!isTxCompleted) {
|
|
1642
|
+
if (__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isRejectError).call(this, error)) {
|
|
1643
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_rejectTransactionAndThrow).call(this, transactionId, actionId, error);
|
|
1644
|
+
}
|
|
1645
|
+
else {
|
|
1646
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failTransaction).call(this, meta, error, actionId);
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
finally {
|
|
1651
|
+
__classPrivateFieldGet(this, _TransactionController_skipSimulationTransactionIds, "f").delete(transactionId);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
const finalMeta = await finishedPromise;
|
|
1655
|
+
switch (finalMeta?.status) {
|
|
1656
|
+
case types_js_1.TransactionStatus.failed: {
|
|
1657
|
+
const error = finalMeta.error;
|
|
1658
|
+
resultCallbacks?.error(error);
|
|
1659
|
+
throw rpc_errors_1.rpcErrors.internal(error.message);
|
|
1660
|
+
}
|
|
1661
|
+
case types_js_1.TransactionStatus.submitted:
|
|
1662
|
+
resultCallbacks?.success();
|
|
1663
|
+
return finalMeta.hash;
|
|
1664
|
+
default: {
|
|
1665
|
+
const internalError = rpc_errors_1.rpcErrors.internal(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finalMeta ?? transactionId)}`);
|
|
1666
|
+
resultCallbacks?.error(internalError);
|
|
1667
|
+
throw internalError;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
}, _TransactionController_approveTransaction =
|
|
1671
|
+
/**
|
|
1672
|
+
* Approves a transaction and updates it's status in state. If this is not a
|
|
1673
|
+
* retry transaction, a nonce will be generated. The transaction is signed
|
|
1674
|
+
* using the sign configuration property, then published to the blockchain.
|
|
1675
|
+
* A `<tx.id>:finished` hub event is fired after success or failure.
|
|
1676
|
+
*
|
|
1677
|
+
* @param transactionId - The ID of the transaction to approve.
|
|
1678
|
+
* @param traceContext - The parent context for any new traces.
|
|
1679
|
+
* @param publishHookOverride - Custom logic to publish the transaction.
|
|
1680
|
+
* @returns The state of the approval.
|
|
1681
|
+
*/
|
|
1682
|
+
async function _TransactionController_approveTransaction(transactionId, traceContext, publishHookOverride) {
|
|
1683
|
+
let clearApprovingTransactionId;
|
|
1684
|
+
let clearNonceLock;
|
|
1685
|
+
let transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
1686
|
+
(0, logger_js_1.projectLogger)('Approving transaction', transactionMeta);
|
|
1687
|
+
try {
|
|
1688
|
+
if (!transactionMeta.chainId) {
|
|
1689
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failTransaction).call(this, transactionMeta, new Error('No chainId defined.'));
|
|
1690
|
+
return ApprovalState.NotApproved;
|
|
1691
|
+
}
|
|
1692
|
+
if (__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").has(transactionId)) {
|
|
1693
|
+
(0, logger_js_1.projectLogger)('Skipping approval as signing in progress', transactionId);
|
|
1694
|
+
return ApprovalState.NotApproved;
|
|
1695
|
+
}
|
|
1696
|
+
__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").add(transactionId);
|
|
1697
|
+
clearApprovingTransactionId = () => __classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").delete(transactionId);
|
|
1698
|
+
const { networkClientId } = transactionMeta;
|
|
1699
|
+
const [nonce, releaseNonce] = await (0, nonce_js_1.getNextNonce)(transactionMeta, (address) => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNonceLock(address, transactionMeta.networkClientId));
|
|
1700
|
+
clearNonceLock = releaseNonce;
|
|
1701
|
+
// eslint-disable-next-line require-atomic-updates
|
|
1702
|
+
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1703
|
+
transactionId,
|
|
1704
|
+
}, (draftTxMeta) => {
|
|
1705
|
+
const { chainId, txParams } = draftTxMeta;
|
|
1706
|
+
const { gas, type } = txParams;
|
|
1707
|
+
draftTxMeta.status = types_js_1.TransactionStatus.approved;
|
|
1708
|
+
draftTxMeta.txParams.chainId = chainId;
|
|
1709
|
+
draftTxMeta.txParams.gasLimit = gas;
|
|
1710
|
+
draftTxMeta.txParams.nonce = nonce;
|
|
1711
|
+
if (!type && (0, utils_js_1.isEIP1559Transaction)(txParams)) {
|
|
1712
|
+
draftTxMeta.txParams.type = types_js_1.TransactionEnvelopeType.feeMarket;
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, transactionMeta);
|
|
1716
|
+
const rawTx = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Sign', parentContext: traceContext }, () => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_signTransaction).call(this, transactionMeta));
|
|
1717
|
+
// eslint-disable-next-line require-atomic-updates
|
|
1718
|
+
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
1719
|
+
if (!(await __classPrivateFieldGet(this, _TransactionController_beforePublish, "f").call(this, transactionMeta))) {
|
|
1720
|
+
(0, logger_js_1.projectLogger)('Skipping publishing transaction based on hook');
|
|
1721
|
+
this.messenger.publish(`${controllerName}:transactionPublishingSkipped`, transactionMeta);
|
|
1722
|
+
return ApprovalState.SkippedViaBeforePublishHook;
|
|
1723
|
+
}
|
|
1724
|
+
if (!rawTx && !transactionMeta.isExternalSign) {
|
|
1725
|
+
return ApprovalState.NotApproved;
|
|
1726
|
+
}
|
|
1727
|
+
let preTxBalance;
|
|
1728
|
+
const shouldUpdatePreTxBalance = transactionMeta.type === types_js_1.TransactionType.swap;
|
|
1729
|
+
if (shouldUpdatePreTxBalance) {
|
|
1730
|
+
(0, logger_js_1.projectLogger)('Determining pre-transaction balance');
|
|
1731
|
+
preTxBalance = (await (0, provider_js_1.rpcRequest)({
|
|
1732
|
+
messenger: this.messenger,
|
|
1733
|
+
networkClientId,
|
|
1734
|
+
method: 'eth_getBalance',
|
|
1735
|
+
params: [transactionMeta.txParams.from, 'latest'],
|
|
1736
|
+
}));
|
|
1737
|
+
}
|
|
1738
|
+
(0, logger_js_1.projectLogger)('Publishing transaction', transactionMeta.txParams);
|
|
1739
|
+
clearNonceLock?.();
|
|
1740
|
+
clearNonceLock = undefined;
|
|
1741
|
+
let publishHook = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_defaultPublishHook).bind(this, {
|
|
1742
|
+
networkClientId,
|
|
1743
|
+
publishHookOverride,
|
|
1744
|
+
traceContext,
|
|
1745
|
+
});
|
|
1746
|
+
if (transactionMeta.batchTransactions?.length) {
|
|
1747
|
+
(0, logger_js_1.projectLogger)('Found batch transactions', transactionMeta.batchTransactions);
|
|
1748
|
+
const extraTransactionsPublishHook = new ExtraTransactionsPublishHook_js_1.ExtraTransactionsPublishHook({
|
|
1749
|
+
addTransactionBatch: this.addTransactionBatch.bind(this),
|
|
1750
|
+
getTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).bind(this),
|
|
1751
|
+
originalPublishHook: publishHook,
|
|
1752
|
+
});
|
|
1753
|
+
publishHook = extraTransactionsPublishHook.getHook();
|
|
1754
|
+
}
|
|
1755
|
+
const { transactionHash: hash } = await publishHook(transactionMeta, rawTx ?? '0x');
|
|
1756
|
+
// eslint-disable-next-line require-atomic-updates
|
|
1757
|
+
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
1758
|
+
transactionId,
|
|
1759
|
+
}, (draftTxMeta) => {
|
|
1760
|
+
draftTxMeta.hash = hash;
|
|
1761
|
+
draftTxMeta.status = types_js_1.TransactionStatus.submitted;
|
|
1762
|
+
draftTxMeta.submittedTime ?? (draftTxMeta.submittedTime = new Date().getTime());
|
|
1763
|
+
if (shouldUpdatePreTxBalance) {
|
|
1764
|
+
draftTxMeta.preTxBalance = preTxBalance;
|
|
1765
|
+
(0, logger_js_1.projectLogger)('Updated pre-transaction balance', preTxBalance);
|
|
1766
|
+
}
|
|
1767
|
+
});
|
|
1768
|
+
this.messenger.publish(`${controllerName}:transactionSubmitted`, {
|
|
1769
|
+
transactionMeta,
|
|
1770
|
+
});
|
|
1771
|
+
this.messenger.publish(`${controllerName}:transactionFinished`, transactionMeta);
|
|
1772
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionId}:finished`, transactionMeta);
|
|
1773
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, transactionMeta);
|
|
1774
|
+
return ApprovalState.Approved;
|
|
1775
|
+
// TODO: Replace `any` with type
|
|
1776
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1777
|
+
}
|
|
1778
|
+
catch (error) {
|
|
1779
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failTransaction).call(this, transactionMeta, error);
|
|
1780
|
+
return ApprovalState.NotApproved;
|
|
1781
|
+
}
|
|
1782
|
+
finally {
|
|
1783
|
+
clearApprovingTransactionId?.();
|
|
1784
|
+
clearNonceLock?.();
|
|
1785
|
+
}
|
|
1786
|
+
}, _TransactionController_publishTransaction = async function _TransactionController_publishTransaction(transactionMeta, { skipSubmitHistory } = {}) {
|
|
1787
|
+
const { networkClientId, rawTx } = transactionMeta;
|
|
1788
|
+
if (!rawTx) {
|
|
1789
|
+
throw new Error('Missing raw transaction');
|
|
1790
|
+
}
|
|
1791
|
+
const transactionHash = (await (0, provider_js_1.rpcRequest)({
|
|
1792
|
+
messenger: this.messenger,
|
|
1793
|
+
networkClientId,
|
|
1794
|
+
method: 'eth_sendRawTransaction',
|
|
1795
|
+
params: [rawTx],
|
|
1796
|
+
}));
|
|
1797
|
+
if (skipSubmitHistory !== true) {
|
|
1798
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSubmitHistory).call(this, transactionMeta, transactionHash);
|
|
1799
|
+
}
|
|
1800
|
+
return transactionHash;
|
|
1801
|
+
}, _TransactionController_rejectTransaction = function _TransactionController_rejectTransaction(transactionId, actionId, error) {
|
|
1802
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1803
|
+
if (!transactionMeta) {
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1806
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_deleteTransaction).call(this, transactionId);
|
|
1807
|
+
const updatedTransactionMeta = {
|
|
1808
|
+
...transactionMeta,
|
|
1809
|
+
status: types_js_1.TransactionStatus.rejected,
|
|
1810
|
+
error: (0, utils_js_1.normalizeTxError)(error ?? rpc_errors_1.providerErrors.userRejectedRequest()),
|
|
1811
|
+
};
|
|
1812
|
+
this.messenger.publish(`${controllerName}:transactionFinished`, updatedTransactionMeta);
|
|
1813
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, updatedTransactionMeta);
|
|
1814
|
+
this.messenger.publish(`${controllerName}:transactionRejected`, {
|
|
1815
|
+
transactionMeta: updatedTransactionMeta,
|
|
1816
|
+
actionId,
|
|
1817
|
+
});
|
|
1818
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, updatedTransactionMeta);
|
|
1819
|
+
}, _TransactionController_trimTransactionsForState = function _TransactionController_trimTransactionsForState(transactions) {
|
|
1820
|
+
const transactionHistoryLimit = (0, feature_flags_js_1.getTransactionHistoryLimit)(this.messenger);
|
|
1821
|
+
if (transactionHistoryLimit === undefined) {
|
|
1822
|
+
return transactions;
|
|
1823
|
+
}
|
|
1824
|
+
const nonceNetworkSet = new Set();
|
|
1825
|
+
const txsToKeep = [...transactions]
|
|
1826
|
+
.sort((a, b) => (a.time > b.time ? -1 : 1)) // Descending time order
|
|
1827
|
+
.filter((tx) => {
|
|
1828
|
+
const { chainId, status, txParams, time } = tx;
|
|
1829
|
+
if (txParams) {
|
|
1830
|
+
const key = `${String(txParams.nonce)}-${(0, controller_utils_1.convertHexToDecimal)(chainId)}-${new Date(time).toDateString()}`;
|
|
1831
|
+
if (nonceNetworkSet.has(key)) {
|
|
1832
|
+
return true;
|
|
1833
|
+
}
|
|
1834
|
+
else if (nonceNetworkSet.size < transactionHistoryLimit ||
|
|
1835
|
+
!__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isFinalState).call(this, status)) {
|
|
1836
|
+
nonceNetworkSet.add(key);
|
|
1837
|
+
return true;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
return false;
|
|
1841
|
+
});
|
|
1842
|
+
txsToKeep.reverse(); // Ascending time order
|
|
1843
|
+
return txsToKeep;
|
|
1844
|
+
}, _TransactionController_isFinalState = function _TransactionController_isFinalState(status) {
|
|
1845
|
+
return (status === types_js_1.TransactionStatus.rejected ||
|
|
1846
|
+
status === types_js_1.TransactionStatus.confirmed ||
|
|
1847
|
+
status === types_js_1.TransactionStatus.failed ||
|
|
1848
|
+
status === types_js_1.TransactionStatus.dropped);
|
|
1849
|
+
}, _TransactionController_isLocalFinalState = function _TransactionController_isLocalFinalState(status) {
|
|
1850
|
+
return [
|
|
1851
|
+
types_js_1.TransactionStatus.confirmed,
|
|
1852
|
+
types_js_1.TransactionStatus.failed,
|
|
1853
|
+
types_js_1.TransactionStatus.rejected,
|
|
1854
|
+
types_js_1.TransactionStatus.submitted,
|
|
1855
|
+
].includes(status);
|
|
1856
|
+
}, _TransactionController_requestApproval = async function _TransactionController_requestApproval(txMeta, { shouldShowRequest, traceContext, }) {
|
|
1857
|
+
const id = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getApprovalId).call(this, txMeta);
|
|
1858
|
+
const { origin } = txMeta;
|
|
1859
|
+
const type = controller_utils_1.ApprovalType.Transaction;
|
|
1860
|
+
const requestData = { txId: txMeta.id };
|
|
1861
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, {
|
|
1862
|
+
name: 'Notification Display',
|
|
1863
|
+
id,
|
|
1864
|
+
parentContext: traceContext,
|
|
1865
|
+
});
|
|
1866
|
+
return (await this.messenger.call('ApprovalController:addRequest', {
|
|
1867
|
+
id,
|
|
1868
|
+
origin: origin ?? controller_utils_1.ORIGIN_METAMASK,
|
|
1869
|
+
type,
|
|
1870
|
+
requestData,
|
|
1871
|
+
expectsResult: true,
|
|
1872
|
+
}, shouldShowRequest));
|
|
1873
|
+
}, _TransactionController_getTransaction = function _TransactionController_getTransaction(transactionId) {
|
|
1874
|
+
const { transactions } = this.state;
|
|
1875
|
+
return transactions.find(({ id }) => id === transactionId);
|
|
1876
|
+
}, _TransactionController_getTransactionOrThrow = function _TransactionController_getTransactionOrThrow(transactionId, errorMessagePrefix = 'TransactionController') {
|
|
1877
|
+
const txMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1878
|
+
if (!txMeta) {
|
|
1879
|
+
throw new Error(`${errorMessagePrefix}: No transaction found with id ${transactionId}`);
|
|
1880
|
+
}
|
|
1881
|
+
return txMeta;
|
|
1882
|
+
}, _TransactionController_getApprovalId = function _TransactionController_getApprovalId(txMeta) {
|
|
1883
|
+
return String(txMeta.id);
|
|
1884
|
+
}, _TransactionController_isTransactionCompleted = function _TransactionController_isTransactionCompleted(transactionId) {
|
|
1885
|
+
const transaction = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1886
|
+
if (!transaction) {
|
|
1887
|
+
return { meta: undefined, isCompleted: false };
|
|
1888
|
+
}
|
|
1889
|
+
const isCompleted = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isLocalFinalState).call(this, transaction.status);
|
|
1890
|
+
return { meta: transaction, isCompleted };
|
|
1891
|
+
}, _TransactionController_generateDappSuggestedGasFees = function _TransactionController_generateDappSuggestedGasFees(txParams, origin, isInternal) {
|
|
1892
|
+
if (isInternal || !origin) {
|
|
1893
|
+
return undefined;
|
|
1894
|
+
}
|
|
1895
|
+
const { gasPrice, maxFeePerGas, maxPriorityFeePerGas, gas } = txParams;
|
|
1896
|
+
if (gasPrice === undefined &&
|
|
1897
|
+
maxFeePerGas === undefined &&
|
|
1898
|
+
maxPriorityFeePerGas === undefined &&
|
|
1899
|
+
gas === undefined) {
|
|
1900
|
+
return undefined;
|
|
1901
|
+
}
|
|
1902
|
+
const dappSuggestedGasFees = {};
|
|
1903
|
+
if (gasPrice !== undefined) {
|
|
1904
|
+
dappSuggestedGasFees.gasPrice = gasPrice;
|
|
1905
|
+
}
|
|
1906
|
+
else if (maxFeePerGas !== undefined ||
|
|
1907
|
+
maxPriorityFeePerGas !== undefined) {
|
|
1908
|
+
dappSuggestedGasFees.maxFeePerGas = maxFeePerGas;
|
|
1909
|
+
dappSuggestedGasFees.maxPriorityFeePerGas = maxPriorityFeePerGas;
|
|
1910
|
+
}
|
|
1911
|
+
if (gas !== undefined) {
|
|
1912
|
+
dappSuggestedGasFees.gas = gas;
|
|
1913
|
+
}
|
|
1914
|
+
return dappSuggestedGasFees;
|
|
1915
|
+
}, _TransactionController_addExternalTransaction = function _TransactionController_addExternalTransaction(transactionMeta) {
|
|
1916
|
+
const { chainId } = transactionMeta;
|
|
1917
|
+
const { transactions } = this.state;
|
|
1918
|
+
const fromAddress = transactionMeta?.txParams?.from;
|
|
1919
|
+
const sameFromAndNetworkTransactions = transactions.filter((transaction) => transaction.txParams.from === fromAddress &&
|
|
1920
|
+
transaction.chainId === chainId);
|
|
1921
|
+
const confirmedTxs = sameFromAndNetworkTransactions.filter((transaction) => transaction.status === types_js_1.TransactionStatus.confirmed);
|
|
1922
|
+
const pendingTxs = sameFromAndNetworkTransactions.filter((transaction) => transaction.status === types_js_1.TransactionStatus.submitted);
|
|
1923
|
+
(0, external_transactions_js_1.validateConfirmedExternalTransaction)(transactionMeta, confirmedTxs, pendingTxs);
|
|
1924
|
+
this.update((state) => {
|
|
1925
|
+
state.transactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_trimTransactionsForState).call(this, [
|
|
1926
|
+
...state.transactions,
|
|
1927
|
+
transactionMeta,
|
|
1928
|
+
]);
|
|
1929
|
+
});
|
|
1930
|
+
return transactionMeta;
|
|
1931
|
+
}, _TransactionController_markNonceDuplicatesDropped = function _TransactionController_markNonceDuplicatesDropped(transactionId) {
|
|
1932
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
1933
|
+
if (!transactionMeta) {
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
const nonce = transactionMeta.txParams?.nonce;
|
|
1937
|
+
const from = transactionMeta.txParams?.from;
|
|
1938
|
+
const { chainId } = transactionMeta;
|
|
1939
|
+
const sameNonceTransactions = this.state.transactions.filter((transaction) => transaction.id !== transactionId &&
|
|
1940
|
+
transaction.txParams.from === from &&
|
|
1941
|
+
nonce &&
|
|
1942
|
+
transaction.txParams.nonce === nonce &&
|
|
1943
|
+
transaction.chainId === chainId &&
|
|
1944
|
+
transaction.type !== types_js_1.TransactionType.incoming &&
|
|
1945
|
+
transaction.isTransfer === undefined);
|
|
1946
|
+
const sameNonceTransactionIds = sameNonceTransactions.map((transaction) => transaction.id);
|
|
1947
|
+
if (sameNonceTransactions.length === 0) {
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
this.update((state) => {
|
|
1951
|
+
for (const transaction of state.transactions) {
|
|
1952
|
+
if (sameNonceTransactionIds.includes(transaction.id)) {
|
|
1953
|
+
transaction.replacedBy = transactionMeta?.hash;
|
|
1954
|
+
transaction.replacedById = transactionMeta?.id;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
});
|
|
1958
|
+
for (const transaction of this.state.transactions) {
|
|
1959
|
+
if (sameNonceTransactionIds.includes(transaction.id) &&
|
|
1960
|
+
transaction.status !== types_js_1.TransactionStatus.failed) {
|
|
1961
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_setTransactionStatusDropped).call(this, transaction);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}, _TransactionController_setTransactionStatusDropped = function _TransactionController_setTransactionStatusDropped(transactionMeta) {
|
|
1965
|
+
const updatedTransactionMeta = {
|
|
1966
|
+
...transactionMeta,
|
|
1967
|
+
status: types_js_1.TransactionStatus.dropped,
|
|
1968
|
+
};
|
|
1969
|
+
this.messenger.publish(`${controllerName}:transactionDropped`, {
|
|
1970
|
+
transactionMeta: updatedTransactionMeta,
|
|
1971
|
+
});
|
|
1972
|
+
this.updateTransaction(updatedTransactionMeta, 'TransactionController#setTransactionStatusDropped - Transaction dropped');
|
|
1973
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, updatedTransactionMeta);
|
|
1974
|
+
}, _TransactionController_waitForTransactionFinished = async function _TransactionController_waitForTransactionFinished(transactionId) {
|
|
1975
|
+
return new Promise((resolve) => {
|
|
1976
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").once(`${transactionId}:finished`, (txMeta) => {
|
|
1977
|
+
resolve(txMeta);
|
|
1978
|
+
});
|
|
1979
|
+
});
|
|
1980
|
+
}, _TransactionController_updateTransactionMetaRSV = function _TransactionController_updateTransactionMetaRSV(transactionMeta, signedTx) {
|
|
1981
|
+
const transactionMetaWithRsv = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
1982
|
+
for (const key of ['r', 's', 'v']) {
|
|
1983
|
+
const value = signedTx[key];
|
|
1984
|
+
if (value === undefined || value === null) {
|
|
1985
|
+
continue;
|
|
1986
|
+
}
|
|
1987
|
+
transactionMetaWithRsv[key] = (0, utils_1.add0x)(BigInt(value).toString(16));
|
|
1988
|
+
}
|
|
1989
|
+
return transactionMetaWithRsv;
|
|
1990
|
+
}, _TransactionController_getEIP1559Compatibility = async function _TransactionController_getEIP1559Compatibility(networkClientId) {
|
|
1991
|
+
return ((await this.messenger.call('NetworkController:getEIP1559Compatibility', networkClientId)) ?? false);
|
|
1992
|
+
}, _TransactionController_signTransaction = async function _TransactionController_signTransaction(originalTransactionMeta) {
|
|
1993
|
+
let transactionMeta = originalTransactionMeta;
|
|
1994
|
+
const { id: transactionId } = transactionMeta;
|
|
1995
|
+
(0, logger_js_1.projectLogger)('Calling before sign hook', transactionMeta);
|
|
1996
|
+
const { updateTransaction } = (await __classPrivateFieldGet(this, _TransactionController_beforeSign, "f").call(this, { transactionMeta })) ?? {};
|
|
1997
|
+
if (updateTransaction) {
|
|
1998
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId, skipResimulateCheck: true }, updateTransaction);
|
|
1999
|
+
(0, logger_js_1.projectLogger)('Updated transaction after before sign hook');
|
|
2000
|
+
}
|
|
2001
|
+
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
2002
|
+
const { networkClientId } = transactionMeta;
|
|
2003
|
+
await (0, gas_fee_tokens_js_1.checkGasFeeTokenBeforePublish)({
|
|
2004
|
+
messenger: this.messenger,
|
|
2005
|
+
networkClientId,
|
|
2006
|
+
fetchGasFeeTokens: async (tx) => (await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeTokens).call(this, tx)).gasFeeTokens,
|
|
2007
|
+
transaction: transactionMeta,
|
|
2008
|
+
updateTransaction: (txId, fn) => __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId: txId }, fn),
|
|
2009
|
+
});
|
|
2010
|
+
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
2011
|
+
const { chainId, isExternalSign, txParams } = transactionMeta;
|
|
2012
|
+
if (isExternalSign) {
|
|
2013
|
+
(0, logger_js_1.projectLogger)('Skipping sign as signed externally');
|
|
2014
|
+
return undefined;
|
|
2015
|
+
}
|
|
2016
|
+
const { authorizationList, from } = txParams;
|
|
2017
|
+
const signedAuthorizationList = await (0, eip7702_js_1.signAuthorizationList)({
|
|
2018
|
+
authorizationList,
|
|
2019
|
+
messenger: this.messenger,
|
|
2020
|
+
transactionMeta,
|
|
2021
|
+
});
|
|
2022
|
+
if (signedAuthorizationList) {
|
|
2023
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (txMeta) => {
|
|
2024
|
+
txMeta.txParams.authorizationList = signedAuthorizationList;
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
2028
|
+
const finalTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionOrThrow).call(this, transactionId);
|
|
2029
|
+
const { txParams: finalTxParams } = finalTransactionMeta;
|
|
2030
|
+
const unsignedEthTx = (0, prepare_js_1.prepareTransaction)(chainId, finalTxParams);
|
|
2031
|
+
__classPrivateFieldGet(this, _TransactionController_approvingTransactionIds, "f").add(transactionId);
|
|
2032
|
+
(0, logger_js_1.projectLogger)('Signing transaction', finalTxParams);
|
|
2033
|
+
const signedTxData = await new Promise((resolve, reject) => {
|
|
2034
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
2035
|
+
this.messenger
|
|
2036
|
+
.call('KeyringController:signTransaction', unsignedEthTx, from)
|
|
2037
|
+
.then(resolve, reject);
|
|
2038
|
+
__classPrivateFieldGet(this, _TransactionController_signAbortCallbacks, "f").set(transactionId, () => reject(new Error('Signing aborted by user')));
|
|
2039
|
+
});
|
|
2040
|
+
__classPrivateFieldGet(this, _TransactionController_signAbortCallbacks, "f").delete(transactionId);
|
|
2041
|
+
const transactionMetaFromHook = (0, lodash_1.cloneDeep)(finalTransactionMeta);
|
|
2042
|
+
const transactionMetaWithRsv = {
|
|
2043
|
+
...__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionMetaRSV).call(this, transactionMetaFromHook, signedTxData),
|
|
2044
|
+
status: types_js_1.TransactionStatus.signed,
|
|
2045
|
+
txParams: finalTxParams,
|
|
2046
|
+
};
|
|
2047
|
+
this.updateTransaction(transactionMetaWithRsv, 'TransactionController#approveTransaction - Transaction signed');
|
|
2048
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, transactionMetaWithRsv);
|
|
2049
|
+
const rawTx = (0, prepare_js_1.serializeTransaction)(chainId, signedTxData);
|
|
2050
|
+
const transactionMetaWithRawTx = (0, lodash_1.merge)({}, transactionMetaWithRsv, {
|
|
2051
|
+
rawTx,
|
|
2052
|
+
});
|
|
2053
|
+
this.updateTransaction(transactionMetaWithRawTx, 'TransactionController#approveTransaction - RawTransaction added');
|
|
2054
|
+
return rawTx;
|
|
2055
|
+
}, _TransactionController_onTransactionStatusChange = function _TransactionController_onTransactionStatusChange(transactionMeta) {
|
|
2056
|
+
this.messenger.publish(`${controllerName}:transactionStatusUpdated`, {
|
|
2057
|
+
transactionMeta,
|
|
2058
|
+
});
|
|
2059
|
+
}, _TransactionController_getNonceTrackerTransactions = function _TransactionController_getNonceTrackerTransactions(statuses, address, chainId) {
|
|
2060
|
+
return (0, nonce_js_1.getAndFormatTransactionsForNonceTracker)(chainId, address, statuses, this.state.transactions);
|
|
2061
|
+
}, _TransactionController_onConfirmedTransaction = function _TransactionController_onConfirmedTransaction(transactionMeta) {
|
|
2062
|
+
(0, logger_js_1.projectLogger)('Processing confirmed transaction', transactionMeta.id);
|
|
2063
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_markNonceDuplicatesDropped).call(this, transactionMeta.id);
|
|
2064
|
+
this.messenger.publish(`${controllerName}:transactionConfirmed`, transactionMeta);
|
|
2065
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, transactionMeta);
|
|
2066
|
+
// Intentional given potential duration of process.
|
|
2067
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updatePostBalance).call(this, transactionMeta).catch((error) => {
|
|
2068
|
+
(0, logger_js_1.projectLogger)('Error while updating post balance', error);
|
|
2069
|
+
throw error;
|
|
2070
|
+
});
|
|
2071
|
+
}, _TransactionController_updatePostBalance = async function _TransactionController_updatePostBalance(transactionMeta) {
|
|
2072
|
+
try {
|
|
2073
|
+
const { networkClientId, type } = transactionMeta;
|
|
2074
|
+
if (type !== types_js_1.TransactionType.swap) {
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
const { updatedTransactionMeta, approvalTransactionMeta } = await (0, swaps_js_1.updatePostTransactionBalance)(transactionMeta, {
|
|
2078
|
+
messenger: this.messenger,
|
|
2079
|
+
networkClientId,
|
|
2080
|
+
getTransaction: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).bind(this),
|
|
2081
|
+
updateTransaction: this.updateTransaction.bind(this),
|
|
2082
|
+
});
|
|
2083
|
+
this.messenger.publish(`${controllerName}:postTransactionBalanceUpdated`, {
|
|
2084
|
+
transactionMeta: updatedTransactionMeta,
|
|
2085
|
+
approvalTransactionMeta,
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
catch (error) {
|
|
2089
|
+
/* istanbul ignore next */
|
|
2090
|
+
(0, logger_js_1.projectLogger)('Error while updating post transaction balance', error);
|
|
2091
|
+
}
|
|
2092
|
+
}, _TransactionController_createNonceTracker = function _TransactionController_createNonceTracker({ provider, blockTracker, chainId, }) {
|
|
2093
|
+
return new nonce_tracker_1.NonceTracker({
|
|
2094
|
+
// TODO: Fix types
|
|
2095
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2096
|
+
provider: provider,
|
|
2097
|
+
// TODO: Fix types
|
|
2098
|
+
blockTracker,
|
|
2099
|
+
getPendingTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerPendingTransactions).bind(this, chainId),
|
|
2100
|
+
getConfirmedTransactions: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerTransactions).bind(this, [types_js_1.TransactionStatus.confirmed], chainId),
|
|
2101
|
+
});
|
|
2102
|
+
}, _TransactionController_createPendingTransactionTracker = function _TransactionController_createPendingTransactionTracker({ blockTracker, networkClientId, }) {
|
|
2103
|
+
const chainId = (0, provider_js_1.getChainId)({ messenger: this.messenger, networkClientId });
|
|
2104
|
+
const pendingTransactionTracker = new PendingTransactionTracker_js_1.PendingTransactionTracker({
|
|
2105
|
+
blockTracker,
|
|
2106
|
+
getGlobalLock: () => __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").acquireNonceLockForChainIdKey({
|
|
2107
|
+
chainId,
|
|
2108
|
+
}),
|
|
2109
|
+
getTransactions: () => this.state.transactions,
|
|
2110
|
+
hooks: {
|
|
2111
|
+
beforeCheckPendingTransaction: __classPrivateFieldGet(this, _TransactionController_beforeCheckPendingTransaction, "f").bind(this),
|
|
2112
|
+
},
|
|
2113
|
+
isTimeoutEnabled: __classPrivateFieldGet(this, _TransactionController_isTimeoutEnabled, "f"),
|
|
2114
|
+
messenger: this.messenger,
|
|
2115
|
+
networkClientId,
|
|
2116
|
+
});
|
|
2117
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_addPendingTransactionTrackerListeners).call(this, pendingTransactionTracker);
|
|
2118
|
+
return pendingTransactionTracker;
|
|
2119
|
+
}, _TransactionController_stopAllTracking = function _TransactionController_stopAllTracking() {
|
|
2120
|
+
__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").stopAllTracking();
|
|
2121
|
+
}, _TransactionController_removePendingTransactionTrackerListeners = function _TransactionController_removePendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
2122
|
+
pendingTransactionTracker.hub.removeAllListeners('transaction-confirmed');
|
|
2123
|
+
pendingTransactionTracker.hub.removeAllListeners('transaction-dropped');
|
|
2124
|
+
pendingTransactionTracker.hub.removeAllListeners('transaction-failed');
|
|
2125
|
+
pendingTransactionTracker.hub.removeAllListeners('transaction-updated');
|
|
2126
|
+
}, _TransactionController_addPendingTransactionTrackerListeners = function _TransactionController_addPendingTransactionTrackerListeners(pendingTransactionTracker) {
|
|
2127
|
+
pendingTransactionTracker.hub.on('transaction-confirmed', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onConfirmedTransaction).bind(this));
|
|
2128
|
+
pendingTransactionTracker.hub.on('transaction-dropped', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_setTransactionStatusDropped).bind(this));
|
|
2129
|
+
pendingTransactionTracker.hub.on('transaction-failed', __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_failTransaction).bind(this));
|
|
2130
|
+
pendingTransactionTracker.hub.on('transaction-updated', this.updateTransaction.bind(this));
|
|
2131
|
+
}, _TransactionController_getNonceTrackerPendingTransactions = function _TransactionController_getNonceTrackerPendingTransactions(chainId, address) {
|
|
2132
|
+
const standardPendingTransactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getNonceTrackerTransactions).call(this, [
|
|
2133
|
+
types_js_1.TransactionStatus.approved,
|
|
2134
|
+
types_js_1.TransactionStatus.signed,
|
|
2135
|
+
types_js_1.TransactionStatus.submitted,
|
|
2136
|
+
], address, chainId);
|
|
2137
|
+
return standardPendingTransactions;
|
|
2138
|
+
}, _TransactionController_publishTransactionForRetry = async function _TransactionController_publishTransactionForRetry(transactionMeta) {
|
|
2139
|
+
try {
|
|
2140
|
+
return await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_publishTransaction).call(this, transactionMeta);
|
|
2141
|
+
}
|
|
2142
|
+
catch (error) {
|
|
2143
|
+
if (__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isTransactionAlreadyConfirmedError).call(this, error)) {
|
|
2144
|
+
throw new Error('Previous transaction is already confirmed');
|
|
2145
|
+
}
|
|
2146
|
+
throw error;
|
|
2147
|
+
}
|
|
2148
|
+
}, _TransactionController_isTransactionAlreadyConfirmedError = function _TransactionController_isTransactionAlreadyConfirmedError(error) {
|
|
2149
|
+
return (Boolean(error?.message?.includes('nonce too low')) ||
|
|
2150
|
+
Boolean(error?.data?.message?.includes('nonce too low')));
|
|
2151
|
+
}, _TransactionController_getGasFeeFlows = function _TransactionController_getGasFeeFlows() {
|
|
2152
|
+
if (__classPrivateFieldGet(this, _TransactionController_testGasFeeFlows, "f")) {
|
|
2153
|
+
return [new TestGasFeeFlow_js_1.TestGasFeeFlow()];
|
|
2154
|
+
}
|
|
2155
|
+
return [
|
|
2156
|
+
new RandomisedEstimationsGasFeeFlow_js_1.RandomisedEstimationsGasFeeFlow(),
|
|
2157
|
+
new LineaGasFeeFlow_js_1.LineaGasFeeFlow(),
|
|
2158
|
+
new DefaultGasFeeFlow_js_1.DefaultGasFeeFlow(),
|
|
2159
|
+
];
|
|
2160
|
+
}, _TransactionController_getLayer1GasFeeFlows = function _TransactionController_getLayer1GasFeeFlows() {
|
|
2161
|
+
return [
|
|
2162
|
+
new MantleLayer1GasFeeFlow_js_1.MantleLayer1GasFeeFlow(),
|
|
2163
|
+
new OptimismLayer1GasFeeFlow_js_1.OptimismLayer1GasFeeFlow(),
|
|
2164
|
+
new ScrollLayer1GasFeeFlow_js_1.ScrollLayer1GasFeeFlow(),
|
|
2165
|
+
];
|
|
2166
|
+
}, _TransactionController_updateTransactionInternal = function _TransactionController_updateTransactionInternal({ transactionId, skipValidation, skipResimulateCheck, }, callback) {
|
|
2167
|
+
let resimulateResponse;
|
|
2168
|
+
this.update((state) => {
|
|
2169
|
+
const index = state.transactions.findIndex(({ id }) => id === transactionId);
|
|
2170
|
+
if (index === -1) {
|
|
2171
|
+
throw new Error(`Cannot update transaction as ID not found - ${transactionId}`);
|
|
2172
|
+
}
|
|
2173
|
+
let transactionMeta = state.transactions[index];
|
|
2174
|
+
const originalTransactionMeta = (0, lodash_1.cloneDeep)(transactionMeta);
|
|
2175
|
+
transactionMeta = callback(transactionMeta) ?? transactionMeta;
|
|
2176
|
+
if (skipValidation !== true) {
|
|
2177
|
+
transactionMeta.txParams = (0, utils_js_1.normalizeTransactionParams)(transactionMeta.txParams);
|
|
2178
|
+
(0, validation_js_1.validateTxParams)(transactionMeta.txParams);
|
|
2179
|
+
}
|
|
2180
|
+
if (!skipResimulateCheck && __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this, transactionMeta)) {
|
|
2181
|
+
resimulateResponse = (0, ResimulateHelper_js_1.shouldResimulate)(originalTransactionMeta, transactionMeta);
|
|
2182
|
+
}
|
|
2183
|
+
state.transactions[index] = transactionMeta;
|
|
2184
|
+
});
|
|
2185
|
+
const transactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
2186
|
+
if (resimulateResponse?.resimulate) {
|
|
2187
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateSimulationData).call(this, transactionMeta, {
|
|
2188
|
+
blockTime: resimulateResponse.blockTime,
|
|
2189
|
+
}).catch((error) => {
|
|
2190
|
+
(0, logger_js_1.projectLogger)('Error during re-simulation', error);
|
|
2191
|
+
throw error;
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
return transactionMeta;
|
|
2195
|
+
}, _TransactionController_isBalanceChangesSkipped = function _TransactionController_isBalanceChangesSkipped(transactionMeta) {
|
|
2196
|
+
return (__classPrivateFieldGet(this, _TransactionController_skipSimulationTransactionIds, "f").has(transactionMeta.id) ||
|
|
2197
|
+
transactionMeta.containerTypes?.includes(types_js_1.TransactionContainerType.EnforcedSimulations) === true);
|
|
2198
|
+
}, _TransactionController_updateSimulationData = async function _TransactionController_updateSimulationData(transactionMeta, { blockTime, traceContext, } = {}) {
|
|
2199
|
+
const { chainId, id: transactionId, nestedTransactions, networkClientId, simulationData: prevSimulationData, txParams, } = transactionMeta;
|
|
2200
|
+
let simulationData = {
|
|
2201
|
+
error: {
|
|
2202
|
+
code: types_js_1.SimulationErrorCode.Disabled,
|
|
2203
|
+
message: 'Simulation disabled',
|
|
2204
|
+
},
|
|
2205
|
+
tokenBalanceChanges: [],
|
|
2206
|
+
};
|
|
2207
|
+
let gasUsed;
|
|
2208
|
+
let gasFeeTokens = [];
|
|
2209
|
+
let isGasFeeSponsored = false;
|
|
2210
|
+
let simulationRevert;
|
|
2211
|
+
const simulationRequestToken = Symbol(transactionId);
|
|
2212
|
+
__classPrivateFieldGet(this, _TransactionController_simulationRequestTokens, "f").set(transactionId, simulationRequestToken);
|
|
2213
|
+
try {
|
|
2214
|
+
const isSimulationEnabled = __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this, transactionMeta);
|
|
2215
|
+
const isBalanceChangesSkipped = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isBalanceChangesSkipped).call(this, transactionMeta);
|
|
2216
|
+
if (isSimulationEnabled && !isBalanceChangesSkipped) {
|
|
2217
|
+
const balanceChangesResult = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => (0, balance_changes_js_1.getBalanceChanges)({
|
|
2218
|
+
blockTime,
|
|
2219
|
+
chainId,
|
|
2220
|
+
messenger: this.messenger,
|
|
2221
|
+
networkClientId,
|
|
2222
|
+
getSimulationConfig: (url, opts) => {
|
|
2223
|
+
return __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f").call(this, url, {
|
|
2224
|
+
txMeta: transactionMeta,
|
|
2225
|
+
...opts,
|
|
2226
|
+
});
|
|
2227
|
+
},
|
|
2228
|
+
nestedTransactions,
|
|
2229
|
+
txParams,
|
|
2230
|
+
}));
|
|
2231
|
+
simulationData = balanceChangesResult.simulationData;
|
|
2232
|
+
gasUsed = balanceChangesResult.gasUsed;
|
|
2233
|
+
simulationRevert = balanceChangesResult.simulationRevert;
|
|
2234
|
+
if (blockTime &&
|
|
2235
|
+
prevSimulationData &&
|
|
2236
|
+
(0, ResimulateHelper_js_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
|
|
2237
|
+
simulationData = {
|
|
2238
|
+
...simulationData,
|
|
2239
|
+
isUpdatedAfterSecurityCheck: true,
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
if (isSimulationEnabled) {
|
|
2244
|
+
const gasFeeTokensResponse = await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getGasFeeTokens).call(this, transactionMeta);
|
|
2245
|
+
gasFeeTokens = gasFeeTokensResponse?.gasFeeTokens ?? [];
|
|
2246
|
+
isGasFeeSponsored = gasFeeTokensResponse?.isGasFeeSponsored ?? false;
|
|
2247
|
+
}
|
|
2248
|
+
if (__classPrivateFieldGet(this, _TransactionController_simulationRequestTokens, "f").get(transactionId) !==
|
|
2249
|
+
simulationRequestToken) {
|
|
2250
|
+
(0, logger_js_1.projectLogger)('Ignoring stale simulation data', transactionId);
|
|
2251
|
+
return;
|
|
2252
|
+
}
|
|
2253
|
+
const latestTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransaction).call(this, transactionId);
|
|
2254
|
+
/* istanbul ignore if */
|
|
2255
|
+
if (!latestTransactionMeta) {
|
|
2256
|
+
(0, logger_js_1.projectLogger)('Cannot update simulation data as transaction not found', transactionId, simulationData);
|
|
2257
|
+
return;
|
|
2258
|
+
}
|
|
2259
|
+
const updatedTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
2260
|
+
transactionId,
|
|
2261
|
+
skipResimulateCheck: Boolean(blockTime),
|
|
2262
|
+
}, (txMeta) => {
|
|
2263
|
+
txMeta.gasFeeTokens = gasFeeTokens;
|
|
2264
|
+
txMeta.isGasFeeSponsored =
|
|
2265
|
+
txMeta.isGasFeeSponsored ?? isGasFeeSponsored;
|
|
2266
|
+
if (txMeta.isGasFeeSponsored) {
|
|
2267
|
+
txMeta.isExternalSign = true;
|
|
2268
|
+
}
|
|
2269
|
+
if (!__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_isBalanceChangesSkipped).call(this, txMeta)) {
|
|
2270
|
+
txMeta.gasUsed = gasUsed;
|
|
2271
|
+
txMeta.simulationData = simulationData;
|
|
2272
|
+
if (simulationRevert) {
|
|
2273
|
+
txMeta.revert = {
|
|
2274
|
+
...txMeta.revert,
|
|
2275
|
+
simulation: simulationRevert,
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
(0, logger_js_1.projectLogger)('Updated simulation data', transactionId, updatedTransactionMeta);
|
|
2281
|
+
}
|
|
2282
|
+
finally {
|
|
2283
|
+
if (__classPrivateFieldGet(this, _TransactionController_simulationRequestTokens, "f").get(transactionId) ===
|
|
2284
|
+
simulationRequestToken) {
|
|
2285
|
+
__classPrivateFieldGet(this, _TransactionController_simulationRequestTokens, "f").delete(transactionId);
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
}, _TransactionController_onGasFeePollerTransactionUpdate = function _TransactionController_onGasFeePollerTransactionUpdate({ transactionId, gasFeeEstimates, gasFeeEstimatesLoaded, layer1GasFee, }) {
|
|
2289
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId }, (txMeta) => {
|
|
2290
|
+
(0, GasFeePoller_js_1.updateTransactionGasProperties)({
|
|
2291
|
+
txMeta,
|
|
2292
|
+
gasFeeEstimates,
|
|
2293
|
+
gasFeeEstimatesLoaded,
|
|
2294
|
+
isTxParamsGasFeeUpdatesEnabled: __classPrivateFieldGet(this, _TransactionController_isAutomaticGasFeeUpdateEnabled, "f"),
|
|
2295
|
+
layer1GasFee,
|
|
2296
|
+
});
|
|
2297
|
+
});
|
|
2298
|
+
}, _TransactionController_onGasFeePollerTransactionBatchUpdate = function _TransactionController_onGasFeePollerTransactionBatchUpdate({ transactionBatchId, gasFeeEstimates, }) {
|
|
2299
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionBatch).call(this, transactionBatchId, (batch) => {
|
|
2300
|
+
return { ...batch, gasFeeEstimates };
|
|
2301
|
+
});
|
|
2302
|
+
}, _TransactionController_updateTransactionBatch = function _TransactionController_updateTransactionBatch(batchId, callback) {
|
|
2303
|
+
this.update((state) => {
|
|
2304
|
+
const index = state.transactionBatches.findIndex((b) => b.id === batchId);
|
|
2305
|
+
if (index === -1) {
|
|
2306
|
+
throw new Error(`Cannot update batch, ID not found - ${batchId}`);
|
|
2307
|
+
}
|
|
2308
|
+
const batch = state.transactionBatches[index];
|
|
2309
|
+
const updated = callback(batch);
|
|
2310
|
+
state.transactionBatches[index] = updated ?? batch;
|
|
2311
|
+
});
|
|
2312
|
+
}, _TransactionController_getInternalAccounts = function _TransactionController_getInternalAccounts() {
|
|
2313
|
+
const state = this.messenger.call('AccountsController:getState');
|
|
2314
|
+
return Object.values(state.internalAccounts?.accounts ?? {})
|
|
2315
|
+
.filter((account) => account.type === 'eip155:eoa')
|
|
2316
|
+
.map((account) => account.address);
|
|
2317
|
+
}, _TransactionController_updateSubmitHistory = function _TransactionController_updateSubmitHistory(transactionMeta, hash) {
|
|
2318
|
+
const { chainId, networkClientId, origin, rawTx, txParams } = transactionMeta;
|
|
2319
|
+
const { networkConfigurationsByChainId } = this.messenger.call('NetworkController:getState');
|
|
2320
|
+
const networkConfiguration = networkConfigurationsByChainId[chainId];
|
|
2321
|
+
const endpoint = networkConfiguration?.rpcEndpoints.find((currentEndpoint) => currentEndpoint.networkClientId === networkClientId);
|
|
2322
|
+
const networkUrl = endpoint?.url;
|
|
2323
|
+
const networkType = endpoint?.name ?? networkClientId;
|
|
2324
|
+
const submitHistoryEntry = {
|
|
2325
|
+
chainId,
|
|
2326
|
+
hash,
|
|
2327
|
+
networkType,
|
|
2328
|
+
networkUrl,
|
|
2329
|
+
origin,
|
|
2330
|
+
rawTransaction: rawTx,
|
|
2331
|
+
time: Date.now(),
|
|
2332
|
+
transaction: txParams,
|
|
2333
|
+
};
|
|
2334
|
+
(0, logger_js_1.projectLogger)('Updating submit history', submitHistoryEntry);
|
|
2335
|
+
const submitHistoryLimit = (0, feature_flags_js_1.getSubmitHistoryLimit)(this.messenger);
|
|
2336
|
+
this.update((state) => {
|
|
2337
|
+
const { submitHistory } = state;
|
|
2338
|
+
if (submitHistory.length >= submitHistoryLimit) {
|
|
2339
|
+
submitHistory.pop();
|
|
2340
|
+
}
|
|
2341
|
+
submitHistory.unshift(submitHistoryEntry);
|
|
2342
|
+
});
|
|
2343
|
+
}, _TransactionController_updateGasEstimate = async function _TransactionController_updateGasEstimate(transactionMeta) {
|
|
2344
|
+
const { networkClientId } = transactionMeta;
|
|
2345
|
+
const isCustomNetwork = __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").getNetworkClient({ networkClientId })
|
|
2346
|
+
.configuration.type === network_controller_1.NetworkClientType.Custom;
|
|
2347
|
+
await (0, gas_js_1.updateGas)({
|
|
2348
|
+
isCustomNetwork,
|
|
2349
|
+
isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this, transactionMeta),
|
|
2350
|
+
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
2351
|
+
messenger: this.messenger,
|
|
2352
|
+
txMeta: transactionMeta,
|
|
2353
|
+
});
|
|
2354
|
+
}, _TransactionController_registerActionHandlers = function _TransactionController_registerActionHandlers() {
|
|
2355
|
+
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
2356
|
+
}, _TransactionController_deleteTransaction = function _TransactionController_deleteTransaction(transactionId) {
|
|
2357
|
+
this.update((state) => {
|
|
2358
|
+
const transactions = state.transactions.filter(({ id }) => id !== transactionId);
|
|
2359
|
+
state.transactions = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_trimTransactionsForState).call(this, transactions);
|
|
2360
|
+
});
|
|
2361
|
+
}, _TransactionController_isRejectError = function _TransactionController_isRejectError(error) {
|
|
2362
|
+
return [
|
|
2363
|
+
rpc_errors_1.errorCodes.provider.userRejectedRequest,
|
|
2364
|
+
validation_js_1.ErrorCode.RejectedUpgrade,
|
|
2365
|
+
].includes(error.code);
|
|
2366
|
+
}, _TransactionController_rejectTransactionAndThrow = function _TransactionController_rejectTransactionAndThrow(transactionId, actionId, error) {
|
|
2367
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_rejectTransaction).call(this, transactionId, actionId, error);
|
|
2368
|
+
if (error.code === rpc_errors_1.errorCodes.provider.userRejectedRequest) {
|
|
2369
|
+
throw rpc_errors_1.providerErrors.userRejectedRequest({
|
|
2370
|
+
message: 'MetaMask Tx Signature: User denied transaction signature.',
|
|
2371
|
+
data: error?.data,
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
throw error;
|
|
2375
|
+
}, _TransactionController_failTransaction = function _TransactionController_failTransaction(transactionMeta, error, actionId) {
|
|
2376
|
+
let newTransactionMeta;
|
|
2377
|
+
const { revert: receiptRevert } = error;
|
|
2378
|
+
try {
|
|
2379
|
+
newTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, {
|
|
2380
|
+
transactionId: transactionMeta.id,
|
|
2381
|
+
skipValidation: true,
|
|
2382
|
+
skipResimulateCheck: true,
|
|
2383
|
+
}, (draftTransactionMeta) => {
|
|
2384
|
+
draftTransactionMeta.status = types_js_1.TransactionStatus.failed;
|
|
2385
|
+
draftTransactionMeta.error = (0, utils_js_1.normalizeTxError)(error);
|
|
2386
|
+
if (receiptRevert === undefined) {
|
|
2387
|
+
return;
|
|
2388
|
+
}
|
|
2389
|
+
draftTransactionMeta.revert = {
|
|
2390
|
+
...draftTransactionMeta.revert,
|
|
2391
|
+
receipt: receiptRevert,
|
|
2392
|
+
};
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
catch (caughtError) {
|
|
2396
|
+
(0, logger_js_1.projectLogger)('Failed to mark transaction as failed', caughtError);
|
|
2397
|
+
newTransactionMeta = {
|
|
2398
|
+
...transactionMeta,
|
|
2399
|
+
status: types_js_1.TransactionStatus.failed,
|
|
2400
|
+
error: (0, utils_js_1.normalizeTxError)(error),
|
|
2401
|
+
...(receiptRevert === undefined
|
|
2402
|
+
? {}
|
|
2403
|
+
: {
|
|
2404
|
+
revert: {
|
|
2405
|
+
...transactionMeta.revert,
|
|
2406
|
+
receipt: receiptRevert,
|
|
2407
|
+
},
|
|
2408
|
+
}),
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
this.messenger.publish(`${controllerName}:transactionFailed`, {
|
|
2412
|
+
actionId,
|
|
2413
|
+
error: error.message,
|
|
2414
|
+
transactionMeta: newTransactionMeta,
|
|
2415
|
+
});
|
|
2416
|
+
__classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_onTransactionStatusChange).call(this, newTransactionMeta);
|
|
2417
|
+
this.messenger.publish(`${controllerName}:transactionFinished`, newTransactionMeta);
|
|
2418
|
+
__classPrivateFieldGet(this, _TransactionController_internalEvents, "f").emit(`${transactionMeta.id}:finished`, newTransactionMeta);
|
|
2419
|
+
}, _TransactionController_defaultPublishHook = async function _TransactionController_defaultPublishHook({ networkClientId, publishHookOverride, traceContext, }, transactionMeta, signedTx) {
|
|
2420
|
+
let transactionHash;
|
|
2421
|
+
await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Publish', parentContext: traceContext }, async () => {
|
|
2422
|
+
const publishHook = publishHookOverride ?? __classPrivateFieldGet(this, _TransactionController_publish, "f");
|
|
2423
|
+
({ transactionHash } = await publishHook(transactionMeta, signedTx));
|
|
2424
|
+
// eslint-disable-next-line require-atomic-updates
|
|
2425
|
+
transactionHash ?? (transactionHash = await __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_publishTransaction).call(this, {
|
|
2426
|
+
...transactionMeta,
|
|
2427
|
+
networkClientId,
|
|
2428
|
+
rawTx: signedTx,
|
|
2429
|
+
}));
|
|
2430
|
+
});
|
|
2431
|
+
(0, logger_js_1.projectLogger)('Publish successful', transactionHash);
|
|
2432
|
+
return { transactionHash };
|
|
2433
|
+
}, _TransactionController_getGasFeeTokens = async function _TransactionController_getGasFeeTokens(transaction) {
|
|
2434
|
+
const { chainId } = transaction;
|
|
2435
|
+
return await (0, gas_fee_tokens_js_1.getGasFeeTokens)({
|
|
2436
|
+
chainId,
|
|
2437
|
+
getSimulationConfig: __classPrivateFieldGet(this, _TransactionController_getSimulationConfig, "f"),
|
|
2438
|
+
isEIP7702GasFeeTokensEnabled: __classPrivateFieldGet(this, _TransactionController_isEIP7702GasFeeTokensEnabled, "f"),
|
|
2439
|
+
messenger: this.messenger,
|
|
2440
|
+
publicKeyEIP7702: __classPrivateFieldGet(this, _TransactionController_publicKeyEIP7702, "f"),
|
|
2441
|
+
transactionMeta: transaction,
|
|
2442
|
+
});
|
|
2443
|
+
};
|
|
2444
|
+
//# sourceMappingURL=TransactionController.cjs.map
|