@metamask-previews/transaction-controller 36.1.0-preview-367cb1da → 36.1.0-preview-cf09c0a
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/dist/TransactionController.cjs +2026 -0
- package/dist/TransactionController.cjs.map +1 -0
- package/dist/{types/TransactionController.d.ts → TransactionController.d.cts} +15 -15
- package/dist/TransactionController.d.cts.map +1 -0
- package/dist/TransactionController.d.mts +827 -0
- package/dist/TransactionController.d.mts.map +1 -0
- package/dist/TransactionController.mjs +2027 -44
- package/dist/TransactionController.mjs.map +1 -1
- package/dist/constants.cjs +170 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/{types/constants.d.ts → constants.d.cts} +1 -1
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +143 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +165 -18
- package/dist/constants.mjs.map +1 -1
- package/dist/errors.cjs +30 -0
- package/dist/{chunk-HMOSP33F.js.map → errors.cjs.map} +1 -1
- package/dist/{types/errors.d.ts → errors.d.cts} +2 -2
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +15 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +22 -14
- package/dist/errors.mjs.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.cjs +87 -0
- package/dist/gas-flows/DefaultGasFeeFlow.cjs.map +1 -0
- package/dist/{types/gas-flows/DefaultGasFeeFlow.d.ts → gas-flows/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.mjs +81 -13
- package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.cjs +102 -0
- package/dist/gas-flows/LineaGasFeeFlow.cjs.map +1 -0
- package/dist/{types/gas-flows/LineaGasFeeFlow.d.ts → gas-flows/LineaGasFeeFlow.d.cts} +2 -2
- package/dist/gas-flows/LineaGasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/LineaGasFeeFlow.d.mts +12 -0
- package/dist/gas-flows/LineaGasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/LineaGasFeeFlow.mjs +96 -14
- package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs +29 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/{types/gas-flows/OptimismLayer1GasFeeFlow.d.ts → gas-flows/OptimismLayer1GasFeeFlow.d.cts} +3 -3
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts +10 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +24 -10
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs +92 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/{types/gas-flows/OracleLayer1GasFeeFlow.d.ts → gas-flows/OracleLayer1GasFeeFlow.d.cts} +3 -3
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts +12 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs +88 -7
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs +21 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.cjs.map +1 -0
- package/dist/{types/gas-flows/ScrollLayer1GasFeeFlow.d.ts → gas-flows/ScrollLayer1GasFeeFlow.d.cts} +3 -3
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.cts.map +1 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts +10 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.d.mts.map +1 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs +16 -10
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -1
- package/dist/gas-flows/TestGasFeeFlow.cjs +73 -0
- package/dist/{chunk-FMRLPVFZ.mjs.map → gas-flows/TestGasFeeFlow.cjs.map} +1 -1
- package/dist/{types/gas-flows/TestGasFeeFlow.d.ts → gas-flows/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.mjs +67 -7
- package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.cjs +149 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.cjs.map +1 -0
- package/dist/{types/helpers/EtherscanRemoteTransactionSource.d.ts → helpers/EtherscanRemoteTransactionSource.d.cts} +3 -3
- package/dist/helpers/EtherscanRemoteTransactionSource.d.cts.map +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.d.mts +15 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.d.mts.map +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +147 -10
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +1 -1
- package/dist/helpers/GasFeePoller.cjs +185 -0
- package/dist/helpers/GasFeePoller.cjs.map +1 -0
- package/dist/{types/helpers/GasFeePoller.d.ts → helpers/GasFeePoller.d.cts} +7 -7
- package/dist/helpers/GasFeePoller.d.cts.map +1 -0
- package/dist/helpers/GasFeePoller.d.mts +35 -0
- package/dist/helpers/GasFeePoller.d.mts.map +1 -0
- package/dist/helpers/GasFeePoller.mjs +183 -10
- package/dist/helpers/GasFeePoller.mjs.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.cjs +199 -0
- package/dist/helpers/IncomingTransactionHelper.cjs.map +1 -0
- package/dist/{types/helpers/IncomingTransactionHelper.d.ts → helpers/IncomingTransactionHelper.d.cts} +6 -6
- package/dist/helpers/IncomingTransactionHelper.d.cts.map +1 -0
- package/dist/helpers/IncomingTransactionHelper.d.mts +40 -0
- package/dist/helpers/IncomingTransactionHelper.d.mts.map +1 -0
- package/dist/helpers/IncomingTransactionHelper.mjs +190 -7
- package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.cjs +284 -0
- package/dist/helpers/MultichainTrackingHelper.cjs.map +1 -0
- package/dist/{types/helpers/MultichainTrackingHelper.d.ts → helpers/MultichainTrackingHelper.d.cts} +8 -8
- package/dist/helpers/MultichainTrackingHelper.d.cts.map +1 -0
- package/dist/helpers/MultichainTrackingHelper.d.mts +76 -0
- package/dist/helpers/MultichainTrackingHelper.d.mts.map +1 -0
- package/dist/helpers/MultichainTrackingHelper.mjs +282 -11
- package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -1
- package/dist/helpers/PendingTransactionTracker.cjs +328 -0
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -0
- package/dist/{types/helpers/PendingTransactionTracker.d.ts → helpers/PendingTransactionTracker.d.cts} +5 -5
- package/dist/helpers/PendingTransactionTracker.d.cts.map +1 -0
- package/dist/helpers/PendingTransactionTracker.d.mts +42 -0
- package/dist/helpers/PendingTransactionTracker.d.mts.map +1 -0
- package/dist/helpers/PendingTransactionTracker.mjs +320 -8
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{types/index.d.ts → index.d.cts} +10 -10
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +6 -76
- package/dist/index.mjs.map +1 -1
- package/dist/logger.cjs +9 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/{types/logger.d.ts → logger.d.cts} +2 -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.mjs +5 -11
- package/dist/logger.mjs.map +1 -1
- package/dist/types.cjs +308 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types/types.d.ts → types.d.cts} +7 -7
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +999 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +304 -23
- package/dist/types.mjs.map +1 -1
- package/dist/utils/etherscan.cjs +111 -0
- package/dist/utils/etherscan.cjs.map +1 -0
- package/dist/{types/utils/etherscan.d.ts → utils/etherscan.d.cts} +2 -2
- package/dist/utils/etherscan.d.cts.map +1 -0
- package/dist/utils/etherscan.d.mts +71 -0
- package/dist/utils/etherscan.d.mts.map +1 -0
- package/dist/utils/etherscan.mjs +104 -13
- package/dist/utils/etherscan.mjs.map +1 -1
- package/dist/utils/external-transactions.cjs +36 -0
- package/dist/utils/external-transactions.cjs.map +1 -0
- package/dist/{types/utils/external-transactions.d.ts → utils/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.mjs +31 -8
- package/dist/utils/external-transactions.mjs.map +1 -1
- package/dist/utils/gas-fees.cjs +208 -0
- package/dist/utils/gas-fees.cjs.map +1 -0
- package/dist/{types/utils/gas-fees.d.ts → utils/gas-fees.d.cts} +5 -5
- package/dist/utils/gas-fees.d.cts.map +1 -0
- package/dist/utils/gas-fees.d.mts +26 -0
- package/dist/utils/gas-fees.d.mts.map +1 -0
- package/dist/utils/gas-fees.mjs +202 -15
- package/dist/utils/gas-fees.mjs.map +1 -1
- package/dist/utils/gas-flow.cjs +76 -0
- package/dist/utils/gas-flow.cjs.map +1 -0
- package/dist/{types/utils/gas-flow.d.ts → utils/gas-flow.d.cts} +5 -5
- package/dist/utils/gas-flow.d.cts.map +1 -0
- package/dist/utils/gas-flow.d.mts +26 -0
- package/dist/utils/gas-flow.d.mts.map +1 -0
- package/dist/utils/gas-flow.mjs +70 -10
- package/dist/utils/gas-flow.mjs.map +1 -1
- package/dist/utils/gas.cjs +112 -0
- package/dist/utils/gas.cjs.map +1 -0
- package/dist/{types/utils/gas.d.ts → utils/gas.d.cts} +4 -4
- package/dist/utils/gas.d.cts.map +1 -0
- package/dist/utils/gas.d.mts +28 -0
- package/dist/utils/gas.d.mts.map +1 -0
- package/dist/utils/gas.mjs +105 -19
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/history.cjs +164 -0
- package/dist/utils/history.cjs.map +1 -0
- package/dist/{types/utils/history.d.ts → utils/history.d.cts} +2 -2
- package/dist/utils/history.d.cts.map +1 -0
- package/dist/utils/history.d.mts +29 -0
- package/dist/utils/history.d.mts.map +1 -0
- package/dist/utils/history.mjs +163 -13
- package/dist/utils/history.mjs.map +1 -1
- package/dist/utils/layer1-gas-fee-flow.cjs +59 -0
- package/dist/utils/layer1-gas-fee-flow.cjs.map +1 -0
- package/dist/{types/utils/layer1-gas-fee-flow.d.ts → utils/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 +25 -0
- package/dist/utils/layer1-gas-fee-flow.d.mts.map +1 -0
- package/dist/utils/layer1-gas-fee-flow.mjs +53 -10
- package/dist/utils/layer1-gas-fee-flow.mjs.map +1 -1
- package/dist/utils/nonce.cjs +66 -0
- package/dist/utils/nonce.cjs.map +1 -0
- package/dist/{types/utils/nonce.d.ts → utils/nonce.d.cts} +3 -3
- package/dist/utils/nonce.d.cts.map +1 -0
- package/dist/utils/nonce.d.mts +21 -0
- package/dist/utils/nonce.d.mts.map +1 -0
- package/dist/utils/nonce.mjs +60 -10
- package/dist/utils/nonce.mjs.map +1 -1
- package/dist/utils/retry.cjs +89 -0
- package/dist/utils/retry.cjs.map +1 -0
- package/dist/{types/utils/retry.d.ts → utils/retry.d.cts} +3 -3
- 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.mjs +84 -7
- package/dist/utils/retry.mjs.map +1 -1
- package/dist/utils/simulation-api.cjs +72 -0
- package/dist/utils/simulation-api.cjs.map +1 -0
- package/dist/{types/utils/simulation-api.d.ts → utils/simulation-api.d.cts} +2 -2
- package/dist/utils/simulation-api.d.cts.map +1 -0
- package/dist/utils/simulation-api.d.mts +107 -0
- package/dist/utils/simulation-api.d.mts.map +1 -0
- package/dist/utils/simulation-api.mjs +67 -10
- package/dist/utils/simulation-api.mjs.map +1 -1
- package/dist/utils/simulation.cjs +443 -0
- package/dist/utils/simulation.cjs.map +1 -0
- package/dist/{types/utils/simulation.d.ts → utils/simulation.d.cts} +6 -6
- package/dist/utils/simulation.d.cts.map +1 -0
- package/dist/utils/simulation.d.mts +46 -0
- package/dist/utils/simulation.d.mts.map +1 -0
- package/dist/utils/simulation.mjs +436 -15
- package/dist/utils/simulation.mjs.map +1 -1
- package/dist/utils/swaps.cjs +309 -0
- package/dist/utils/swaps.cjs.map +1 -0
- package/dist/{types/utils/swaps.d.ts → utils/swaps.d.cts} +5 -5
- package/dist/utils/swaps.d.cts.map +1 -0
- package/dist/utils/swaps.d.mts +84 -0
- package/dist/utils/swaps.d.mts.map +1 -0
- package/dist/utils/swaps.mjs +303 -22
- package/dist/utils/swaps.mjs.map +1 -1
- package/dist/utils/transaction-type.cjs +115 -0
- package/dist/utils/transaction-type.cjs.map +1 -0
- package/dist/{types/utils/transaction-type.d.ts → utils/transaction-type.d.cts} +3 -3
- package/dist/utils/transaction-type.d.cts.map +1 -0
- package/dist/utils/transaction-type.d.mts +14 -0
- package/dist/utils/transaction-type.d.mts.map +1 -0
- package/dist/utils/transaction-type.mjs +110 -10
- package/dist/utils/transaction-type.mjs.map +1 -1
- package/dist/utils/utils.cjs +151 -0
- package/dist/utils/utils.cjs.map +1 -0
- package/dist/{types/utils/utils.d.ts → utils/utils.d.cts} +2 -2
- package/dist/utils/utils.d.cts.map +1 -0
- package/dist/utils/utils.d.mts +52 -0
- package/dist/utils/utils.d.mts.map +1 -0
- package/dist/utils/utils.mjs +139 -21
- package/dist/utils/utils.mjs.map +1 -1
- package/dist/utils/validation.cjs +267 -0
- package/dist/{chunk-DIPBZJ5G.js.map → utils/validation.cjs.map} +1 -1
- package/dist/{types/utils/validation.d.ts → utils/validation.d.cts} +2 -2
- package/dist/utils/validation.d.cts.map +1 -0
- package/dist/utils/validation.d.mts +20 -0
- package/dist/utils/validation.d.mts.map +1 -0
- package/dist/utils/validation.mjs +261 -11
- package/dist/utils/validation.mjs.map +1 -1
- package/package.json +12 -7
- package/dist/TransactionController.js +0 -46
- package/dist/TransactionController.js.map +0 -1
- package/dist/chunk-2XKEAKQG.js +0 -55
- package/dist/chunk-2XKEAKQG.js.map +0 -1
- package/dist/chunk-3AVRGHUO.mjs +0 -360
- package/dist/chunk-3AVRGHUO.mjs.map +0 -1
- package/dist/chunk-3ZV5YEUV.mjs +0 -239
- package/dist/chunk-3ZV5YEUV.mjs.map +0 -1
- package/dist/chunk-4SYKJQLR.js +0 -228
- package/dist/chunk-4SYKJQLR.js.map +0 -1
- package/dist/chunk-4V4XIPCI.mjs +0 -338
- package/dist/chunk-4V4XIPCI.mjs.map +0 -1
- package/dist/chunk-4ZOE2ACZ.js +0 -67
- package/dist/chunk-4ZOE2ACZ.js.map +0 -1
- package/dist/chunk-5G6OHAXI.mjs +0 -137
- package/dist/chunk-5G6OHAXI.mjs.map +0 -1
- package/dist/chunk-5QVDIVJH.js +0 -68
- package/dist/chunk-5QVDIVJH.js.map +0 -1
- package/dist/chunk-6DDVVUJC.mjs +0 -50
- package/dist/chunk-6DDVVUJC.mjs.map +0 -1
- package/dist/chunk-6DODV6OV.js +0 -390
- package/dist/chunk-6DODV6OV.js.map +0 -1
- package/dist/chunk-6JO6EU6Z.mjs +0 -67
- package/dist/chunk-6JO6EU6Z.mjs.map +0 -1
- package/dist/chunk-6OLJWLKK.js +0 -338
- package/dist/chunk-6OLJWLKK.js.map +0 -1
- package/dist/chunk-7LXE4KHV.js +0 -40
- package/dist/chunk-7LXE4KHV.js.map +0 -1
- package/dist/chunk-7M2R5AHC.mjs +0 -390
- package/dist/chunk-7M2R5AHC.mjs.map +0 -1
- package/dist/chunk-7NMV2NPM.js +0 -172
- package/dist/chunk-7NMV2NPM.js.map +0 -1
- package/dist/chunk-ASTXVFGJ.mjs +0 -92
- package/dist/chunk-ASTXVFGJ.mjs.map +0 -1
- package/dist/chunk-CKRPGICI.js +0 -2499
- package/dist/chunk-CKRPGICI.js.map +0 -1
- package/dist/chunk-DIPBZJ5G.js +0 -201
- package/dist/chunk-EGQCE3FK.mjs +0 -85
- package/dist/chunk-EGQCE3FK.mjs.map +0 -1
- package/dist/chunk-EHIRNR33.mjs +0 -228
- package/dist/chunk-EHIRNR33.mjs.map +0 -1
- package/dist/chunk-EKJXGERC.mjs +0 -172
- package/dist/chunk-EKJXGERC.mjs.map +0 -1
- package/dist/chunk-FG74Z3F5.mjs +0 -102
- package/dist/chunk-FG74Z3F5.mjs.map +0 -1
- package/dist/chunk-FMRLPVFZ.mjs +0 -66
- package/dist/chunk-FRKQ3Z2L.mjs +0 -40
- package/dist/chunk-FRKQ3Z2L.mjs.map +0 -1
- package/dist/chunk-H5MYUJHR.js +0 -92
- package/dist/chunk-H5MYUJHR.js.map +0 -1
- package/dist/chunk-HAW3IWCX.mjs +0 -201
- package/dist/chunk-HAW3IWCX.mjs.map +0 -1
- package/dist/chunk-HMOSP33F.js +0 -36
- package/dist/chunk-HQSNKCXI.mjs +0 -36
- package/dist/chunk-HQSNKCXI.mjs.map +0 -1
- package/dist/chunk-JIFPK37W.mjs +0 -257
- package/dist/chunk-JIFPK37W.mjs.map +0 -1
- package/dist/chunk-JOQK7A5G.mjs +0 -68
- package/dist/chunk-JOQK7A5G.mjs.map +0 -1
- package/dist/chunk-K4KOSAGM.mjs +0 -61
- package/dist/chunk-K4KOSAGM.mjs.map +0 -1
- package/dist/chunk-KG4UW4K4.mjs +0 -88
- package/dist/chunk-KG4UW4K4.mjs.map +0 -1
- package/dist/chunk-KT6UAKBB.js +0 -61
- package/dist/chunk-KT6UAKBB.js.map +0 -1
- package/dist/chunk-KTGMNUTQ.js +0 -106
- package/dist/chunk-KTGMNUTQ.js.map +0 -1
- package/dist/chunk-NNCUD3QF.js +0 -360
- package/dist/chunk-NNCUD3QF.js.map +0 -1
- package/dist/chunk-NOHEXQ7Y.mjs +0 -55
- package/dist/chunk-NOHEXQ7Y.mjs.map +0 -1
- package/dist/chunk-NYKRCWBG.js +0 -31
- package/dist/chunk-NYKRCWBG.js.map +0 -1
- package/dist/chunk-O6ZZVIFH.mjs +0 -176
- package/dist/chunk-O6ZZVIFH.mjs.map +0 -1
- package/dist/chunk-ORWR5LSG.js +0 -112
- package/dist/chunk-ORWR5LSG.js.map +0 -1
- package/dist/chunk-PRUNMTRD.js +0 -50
- package/dist/chunk-PRUNMTRD.js.map +0 -1
- package/dist/chunk-Q44JQKVP.mjs +0 -112
- package/dist/chunk-Q44JQKVP.mjs.map +0 -1
- package/dist/chunk-QKV7E5BO.js +0 -257
- package/dist/chunk-QKV7E5BO.js.map +0 -1
- package/dist/chunk-REFVF44I.mjs +0 -2499
- package/dist/chunk-REFVF44I.mjs.map +0 -1
- package/dist/chunk-RGWMNCTE.mjs +0 -121
- package/dist/chunk-RGWMNCTE.mjs.map +0 -1
- package/dist/chunk-RHDPOIS4.js +0 -239
- package/dist/chunk-RHDPOIS4.js.map +0 -1
- package/dist/chunk-S6VGOPUY.js +0 -14
- package/dist/chunk-S6VGOPUY.js.map +0 -1
- package/dist/chunk-SD6CWFDF.js +0 -88
- package/dist/chunk-SD6CWFDF.js.map +0 -1
- package/dist/chunk-SMC5Q6ZH.mjs +0 -120
- package/dist/chunk-SMC5Q6ZH.mjs.map +0 -1
- package/dist/chunk-TIE3CPF7.js +0 -120
- package/dist/chunk-TIE3CPF7.js.map +0 -1
- package/dist/chunk-TJMQEH57.js +0 -66
- package/dist/chunk-TJMQEH57.js.map +0 -1
- package/dist/chunk-UGN7PBON.js +0 -176
- package/dist/chunk-UGN7PBON.js.map +0 -1
- package/dist/chunk-UHSRHP55.mjs +0 -106
- package/dist/chunk-UHSRHP55.mjs.map +0 -1
- package/dist/chunk-UQQWZT6C.mjs +0 -14
- package/dist/chunk-UQQWZT6C.mjs.map +0 -1
- package/dist/chunk-V2OWJ7RY.mjs +0 -226
- package/dist/chunk-V2OWJ7RY.mjs.map +0 -1
- package/dist/chunk-V72C4MCR.js +0 -137
- package/dist/chunk-V72C4MCR.js.map +0 -1
- package/dist/chunk-VEVVBHP3.mjs +0 -31
- package/dist/chunk-VEVVBHP3.mjs.map +0 -1
- package/dist/chunk-WFRHYZIO.js +0 -226
- package/dist/chunk-WFRHYZIO.js.map +0 -1
- package/dist/chunk-WR5F34OW.js +0 -23
- package/dist/chunk-WR5F34OW.js.map +0 -1
- package/dist/chunk-XUI43LEZ.mjs +0 -30
- package/dist/chunk-XUI43LEZ.mjs.map +0 -1
- package/dist/chunk-XVYXRCRL.js +0 -85
- package/dist/chunk-XVYXRCRL.js.map +0 -1
- package/dist/chunk-YAFENU6Y.js +0 -121
- package/dist/chunk-YAFENU6Y.js.map +0 -1
- package/dist/chunk-YVCX6Z75.js +0 -102
- package/dist/chunk-YVCX6Z75.js.map +0 -1
- package/dist/chunk-Z4BLTVTB.js +0 -30
- package/dist/chunk-Z4BLTVTB.js.map +0 -1
- package/dist/chunk-Z4GV3YQQ.mjs +0 -23
- package/dist/chunk-Z4GV3YQQ.mjs.map +0 -1
- package/dist/constants.js +0 -20
- package/dist/constants.js.map +0 -1
- package/dist/errors.js +0 -15
- package/dist/errors.js.map +0 -1
- package/dist/gas-flows/DefaultGasFeeFlow.js +0 -15
- package/dist/gas-flows/DefaultGasFeeFlow.js.map +0 -1
- package/dist/gas-flows/LineaGasFeeFlow.js +0 -16
- package/dist/gas-flows/LineaGasFeeFlow.js.map +0 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js +0 -11
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/OracleLayer1GasFeeFlow.js +0 -9
- package/dist/gas-flows/OracleLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.js +0 -11
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/TestGasFeeFlow.js +0 -9
- package/dist/gas-flows/TestGasFeeFlow.js.map +0 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.js +0 -12
- package/dist/helpers/EtherscanRemoteTransactionSource.js.map +0 -1
- package/dist/helpers/GasFeePoller.js +0 -12
- package/dist/helpers/GasFeePoller.js.map +0 -1
- package/dist/helpers/IncomingTransactionHelper.js +0 -9
- package/dist/helpers/IncomingTransactionHelper.js.map +0 -1
- package/dist/helpers/MultichainTrackingHelper.js +0 -13
- package/dist/helpers/MultichainTrackingHelper.js.map +0 -1
- package/dist/helpers/PendingTransactionTracker.js +0 -10
- package/dist/helpers/PendingTransactionTracker.js.map +0 -1
- package/dist/index.js +0 -77
- package/dist/index.js.map +0 -1
- package/dist/logger.js +0 -12
- package/dist/logger.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/TransactionController.d.ts.map +0 -1
- package/dist/types/constants.d.ts.map +0 -1
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/gas-flows/DefaultGasFeeFlow.d.ts.map +0 -1
- package/dist/types/gas-flows/LineaGasFeeFlow.d.ts.map +0 -1
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/types/gas-flows/OracleLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/types/gas-flows/ScrollLayer1GasFeeFlow.d.ts.map +0 -1
- package/dist/types/gas-flows/TestGasFeeFlow.d.ts.map +0 -1
- package/dist/types/helpers/EtherscanRemoteTransactionSource.d.ts.map +0 -1
- package/dist/types/helpers/GasFeePoller.d.ts.map +0 -1
- package/dist/types/helpers/IncomingTransactionHelper.d.ts.map +0 -1
- package/dist/types/helpers/MultichainTrackingHelper.d.ts.map +0 -1
- package/dist/types/helpers/PendingTransactionTracker.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/logger.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils/etherscan.d.ts.map +0 -1
- package/dist/types/utils/external-transactions.d.ts.map +0 -1
- package/dist/types/utils/gas-fees.d.ts.map +0 -1
- package/dist/types/utils/gas-flow.d.ts.map +0 -1
- package/dist/types/utils/gas.d.ts.map +0 -1
- package/dist/types/utils/history.d.ts.map +0 -1
- package/dist/types/utils/layer1-gas-fee-flow.d.ts.map +0 -1
- package/dist/types/utils/nonce.d.ts.map +0 -1
- package/dist/types/utils/retry.d.ts.map +0 -1
- package/dist/types/utils/simulation-api.d.ts.map +0 -1
- package/dist/types/utils/simulation.d.ts.map +0 -1
- package/dist/types/utils/swaps.d.ts.map +0 -1
- package/dist/types/utils/transaction-type.d.ts.map +0 -1
- package/dist/types/utils/utils.d.ts.map +0 -1
- package/dist/types/utils/validation.d.ts.map +0 -1
- package/dist/types.js +0 -24
- package/dist/types.js.map +0 -1
- package/dist/utils/etherscan.js +0 -14
- package/dist/utils/etherscan.js.map +0 -1
- package/dist/utils/external-transactions.js +0 -9
- package/dist/utils/external-transactions.js.map +0 -1
- package/dist/utils/gas-fees.js +0 -16
- package/dist/utils/gas-fees.js.map +0 -1
- package/dist/utils/gas-flow.js +0 -11
- package/dist/utils/gas-flow.js.map +0 -1
- package/dist/utils/gas.js +0 -20
- package/dist/utils/gas.js.map +0 -1
- package/dist/utils/history.js +0 -14
- package/dist/utils/history.js.map +0 -1
- package/dist/utils/layer1-gas-fee-flow.js +0 -11
- package/dist/utils/layer1-gas-fee-flow.js.map +0 -1
- package/dist/utils/nonce.js +0 -11
- package/dist/utils/nonce.js.map +0 -1
- package/dist/utils/retry.js +0 -8
- package/dist/utils/retry.js.map +0 -1
- package/dist/utils/simulation-api.js +0 -11
- package/dist/utils/simulation-api.js.map +0 -1
- package/dist/utils/simulation.js +0 -17
- package/dist/utils/simulation.js.map +0 -1
- package/dist/utils/swaps.js +0 -24
- package/dist/utils/swaps.js.map +0 -1
- package/dist/utils/transaction-type.js +0 -11
- package/dist/utils/transaction-type.js.map +0 -1
- package/dist/utils/utils.js +0 -23
- package/dist/utils/utils.js.map +0 -1
- package/dist/utils/validation.js +0 -12
- package/dist/utils/validation.js.map +0 -1
package/dist/chunk-5QVDIVJH.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/retry.ts
|
|
2
|
-
var _controllerutils = require('@metamask/controller-utils');
|
|
3
|
-
var _utils = require('@metamask/utils');
|
|
4
|
-
function getTransactionParamsWithIncreasedGasFee(originalTransactionParams, rate, newGasValues) {
|
|
5
|
-
const newGasPrice = getIncreasedGasPrice(
|
|
6
|
-
originalTransactionParams,
|
|
7
|
-
rate,
|
|
8
|
-
newGasValues
|
|
9
|
-
);
|
|
10
|
-
const new1559Values = getIncreased1559Values(
|
|
11
|
-
originalTransactionParams,
|
|
12
|
-
rate,
|
|
13
|
-
newGasValues
|
|
14
|
-
);
|
|
15
|
-
if (new1559Values) {
|
|
16
|
-
const newTxParams = {
|
|
17
|
-
...originalTransactionParams,
|
|
18
|
-
...new1559Values
|
|
19
|
-
};
|
|
20
|
-
delete newTxParams.gasPrice;
|
|
21
|
-
return newTxParams;
|
|
22
|
-
}
|
|
23
|
-
if (newGasPrice) {
|
|
24
|
-
const newTxParams = {
|
|
25
|
-
...originalTransactionParams,
|
|
26
|
-
gasPrice: newGasPrice
|
|
27
|
-
};
|
|
28
|
-
delete newTxParams.maxFeePerGas;
|
|
29
|
-
delete newTxParams.maxPriorityFeePerGas;
|
|
30
|
-
return newTxParams;
|
|
31
|
-
}
|
|
32
|
-
throw new Error(
|
|
33
|
-
"Cannot increase gas fee as no current values and no new values were provided"
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
function getIncreased1559Values(originalTransactionParams, rate, newGasValues) {
|
|
37
|
-
if (newGasValues && "maxFeePerGas" in newGasValues && "maxPriorityFeePerGas" in newGasValues) {
|
|
38
|
-
return newGasValues;
|
|
39
|
-
}
|
|
40
|
-
const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas;
|
|
41
|
-
const currentMaxPriorityFeePerGas = originalTransactionParams.maxPriorityFeePerGas;
|
|
42
|
-
if (!currentMaxFeePerGas || !currentMaxPriorityFeePerGas || currentMaxFeePerGas === "0x0" || currentMaxPriorityFeePerGas === "0x0") {
|
|
43
|
-
return void 0;
|
|
44
|
-
}
|
|
45
|
-
const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);
|
|
46
|
-
const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);
|
|
47
|
-
return { maxFeePerGas, maxPriorityFeePerGas };
|
|
48
|
-
}
|
|
49
|
-
function getIncreasedGasPrice(originalTransactionParams, rate, newGasValues) {
|
|
50
|
-
if (newGasValues && "gasPrice" in newGasValues) {
|
|
51
|
-
return newGasValues.gasPrice;
|
|
52
|
-
}
|
|
53
|
-
const currentGasPrice = originalTransactionParams.gasPrice;
|
|
54
|
-
if (!currentGasPrice || currentGasPrice === "0x0") {
|
|
55
|
-
return void 0;
|
|
56
|
-
}
|
|
57
|
-
return multiplyHex(currentGasPrice, rate);
|
|
58
|
-
}
|
|
59
|
-
function multiplyHex(value, multiplier) {
|
|
60
|
-
const decimalValue = _controllerutils.convertHexToDecimal.call(void 0, value);
|
|
61
|
-
const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);
|
|
62
|
-
return _utils.add0x.call(void 0, decimalResult.toString(16));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
exports.getTransactionParamsWithIncreasedGasFee = getTransactionParamsWithIncreasedGasFee;
|
|
68
|
-
//# sourceMappingURL=chunk-5QVDIVJH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/retry.ts"],"names":[],"mappings":";AAAA,SAAS,2BAA2B;AAEpC,SAAS,aAAa;AAYf,SAAS,wCACd,2BACA,MACA,cACmB;AACnB,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,eAAe;AACjB,UAAM,cAAiC;AAAA,MACrC,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAEA,WAAO,YAAY;AAEnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa;AACf,UAAM,cAAiC;AAAA,MACrC,GAAG;AAAA,MACH,UAAU;AAAA,IACZ;AAEA,WAAO,YAAY;AACnB,WAAO,YAAY;AAEnB,WAAO;AAAA,EACT;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AASA,SAAS,uBACP,2BACA,MACA,cACoC;AACpC,MACE,gBACA,kBAAkB,gBAClB,0BAA0B,cAC1B;AACA,WAAO;AAAA,EACT;AAEA,QAAM,sBAAsB,0BAA0B;AAItD,QAAM,8BACJ,0BAA0B;AAE5B,MACE,CAAC,uBACD,CAAC,+BACD,wBAAwB,SACxB,gCAAgC,OAChC;AACA,WAAO;AAAA,EACT;AAEA,QAAM,eAAe,YAAY,qBAAqB,IAAI;AAC1D,QAAM,uBAAuB,YAAY,6BAA6B,IAAI;AAE1E,SAAO,EAAE,cAAc,qBAAqB;AAC9C;AASA,SAAS,qBACP,2BACA,MACA,cACiB;AACjB,MAAI,gBAAgB,cAAc,cAAc;AAC9C,WAAO,aAAa;AAAA,EACtB;AAEA,QAAM,kBAAkB,0BAA0B;AAElD,MAAI,CAAC,mBAAmB,oBAAoB,OAAO;AACjD,WAAO;AAAA,EACT;AAEA,SAAO,YAAY,iBAAiB,IAAI;AAC1C;AAQA,SAAS,YAAY,OAAwB,YAAyB;AACpE,QAAM,eAAe,oBAAoB,KAAK;AAC9C,QAAM,gBAAgB,SAAS,GAAG,eAAe,UAAU,IAAI,EAAE;AAEjE,SAAO,MAAM,cAAc,SAAS,EAAE,CAAC;AACzC","sourcesContent":["import { convertHexToDecimal } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\nimport { add0x } from '@metamask/utils';\n\nimport type { FeeMarketEIP1559Values, GasPriceValue } from '../types';\nimport { type TransactionParams } from '../types';\n\n/**\n * Returns new transaction parameters with increased gas fees.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new transaction parameters with the increased gas fee properties.\n */\nexport function getTransactionParamsWithIncreasedGasFee(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): TransactionParams {\n const newGasPrice = getIncreasedGasPrice(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n const new1559Values = getIncreased1559Values(\n originalTransactionParams,\n rate,\n newGasValues,\n );\n\n if (new1559Values) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n ...new1559Values,\n };\n\n delete newTxParams.gasPrice;\n\n return newTxParams;\n }\n\n if (newGasPrice) {\n const newTxParams: TransactionParams = {\n ...originalTransactionParams,\n gasPrice: newGasPrice,\n };\n\n delete newTxParams.maxFeePerGas;\n delete newTxParams.maxPriorityFeePerGas;\n\n return newTxParams;\n }\n\n throw new Error(\n 'Cannot increase gas fee as no current values and no new values were provided',\n );\n}\n\n/**\n * Generate the increased EIP-1559 gas properties.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new EIP-1559 gas properties.\n */\nfunction getIncreased1559Values(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): FeeMarketEIP1559Values | undefined {\n if (\n newGasValues &&\n 'maxFeePerGas' in newGasValues &&\n 'maxPriorityFeePerGas' in newGasValues\n ) {\n return newGasValues;\n }\n\n const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas as\n | Hex\n | undefined;\n\n const currentMaxPriorityFeePerGas =\n originalTransactionParams.maxPriorityFeePerGas as Hex | undefined;\n\n if (\n !currentMaxFeePerGas ||\n !currentMaxPriorityFeePerGas ||\n currentMaxFeePerGas === '0x0' ||\n currentMaxPriorityFeePerGas === '0x0'\n ) {\n return undefined;\n }\n\n const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);\n const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);\n\n return { maxFeePerGas, maxPriorityFeePerGas };\n}\n\n/**\n * Generate the increased gas price.\n * @param originalTransactionParams - The original transaction parameters.\n * @param rate - The rate by which to increase the existing gas fee properties.\n * @param newGasValues - Optional new gas values to use instead of increased the existing values.\n * @returns The new gas price.\n */\nfunction getIncreasedGasPrice(\n originalTransactionParams: TransactionParams,\n rate: number,\n newGasValues?: GasPriceValue | FeeMarketEIP1559Values,\n): Hex | undefined {\n if (newGasValues && 'gasPrice' in newGasValues) {\n return newGasValues.gasPrice as Hex;\n }\n\n const currentGasPrice = originalTransactionParams.gasPrice as Hex | undefined;\n\n if (!currentGasPrice || currentGasPrice === '0x0') {\n return undefined;\n }\n\n return multiplyHex(currentGasPrice, rate);\n}\n\n/**\n * Multiply a hex value by a multiplier.\n * @param value - The hex value to multiply.\n * @param multiplier - The multiplier.\n * @returns The multiplied hex value.\n */\nfunction multiplyHex(value: Hex | undefined, multiplier: number): Hex {\n const decimalValue = convertHexToDecimal(value);\n const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);\n\n return add0x(decimalResult.toString(16));\n}\n"]}
|
package/dist/chunk-6DDVVUJC.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createModuleLogger,
|
|
3
|
-
projectLogger
|
|
4
|
-
} from "./chunk-UQQWZT6C.mjs";
|
|
5
|
-
|
|
6
|
-
// src/utils/nonce.ts
|
|
7
|
-
import { toHex } from "@metamask/controller-utils";
|
|
8
|
-
var log = createModuleLogger(projectLogger, "nonce");
|
|
9
|
-
async function getNextNonce(txMeta, getNonceLock) {
|
|
10
|
-
const {
|
|
11
|
-
customNonceValue,
|
|
12
|
-
txParams: { from, nonce: existingNonce }
|
|
13
|
-
} = txMeta;
|
|
14
|
-
const customNonce = customNonceValue ? toHex(customNonceValue) : void 0;
|
|
15
|
-
if (customNonce) {
|
|
16
|
-
log("Using custom nonce", customNonce);
|
|
17
|
-
return [customNonce, void 0];
|
|
18
|
-
}
|
|
19
|
-
if (existingNonce) {
|
|
20
|
-
log("Using existing nonce", existingNonce);
|
|
21
|
-
return [existingNonce, void 0];
|
|
22
|
-
}
|
|
23
|
-
const nonceLock = await getNonceLock(from);
|
|
24
|
-
const nonce = toHex(nonceLock.nextNonce);
|
|
25
|
-
const releaseLock = nonceLock.releaseLock.bind(nonceLock);
|
|
26
|
-
log("Using nonce from nonce tracker", nonce, nonceLock.nonceDetails);
|
|
27
|
-
return [nonce, releaseLock];
|
|
28
|
-
}
|
|
29
|
-
function getAndFormatTransactionsForNonceTracker(currentChainId, fromAddress, transactionStatus, transactions) {
|
|
30
|
-
return transactions.filter(
|
|
31
|
-
({ chainId, isTransfer, isUserOperation, status, txParams: { from } }) => !isTransfer && !isUserOperation && chainId === currentChainId && status === transactionStatus && from.toLowerCase() === fromAddress.toLowerCase()
|
|
32
|
-
).map(({ status, txParams: { from, gas, value, nonce } }) => {
|
|
33
|
-
return {
|
|
34
|
-
status,
|
|
35
|
-
history: [{}],
|
|
36
|
-
txParams: {
|
|
37
|
-
from: from ?? "",
|
|
38
|
-
gas: gas ?? "",
|
|
39
|
-
value: value ?? "",
|
|
40
|
-
nonce: nonce ?? ""
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export {
|
|
47
|
-
getNextNonce,
|
|
48
|
-
getAndFormatTransactionsForNonceTracker
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=chunk-6DDVVUJC.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/nonce.ts"],"sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport type {\n NonceLock,\n Transaction as NonceTrackerTransaction,\n} from '@metamask/nonce-tracker';\n\nimport { createModuleLogger, projectLogger } from '../logger';\nimport type { TransactionMeta, TransactionStatus } from '../types';\n\nconst log = createModuleLogger(projectLogger, 'nonce');\n\n/**\n * Determine the next nonce to be used for a transaction.\n *\n * @param txMeta - The transaction metadata.\n * @param getNonceLock - An anonymous function that acquires the nonce lock for an address\n * @returns The next hexadecimal nonce to be used for the given transaction, and optionally a function to release the nonce lock.\n */\nexport async function getNextNonce(\n txMeta: TransactionMeta,\n getNonceLock: (address: string) => Promise<NonceLock>,\n): Promise<[string, (() => void) | undefined]> {\n const {\n customNonceValue,\n txParams: { from, nonce: existingNonce },\n } = txMeta;\n\n const customNonce = customNonceValue ? toHex(customNonceValue) : undefined;\n\n if (customNonce) {\n log('Using custom nonce', customNonce);\n return [customNonce, undefined];\n }\n\n if (existingNonce) {\n log('Using existing nonce', existingNonce);\n return [existingNonce, undefined];\n }\n\n const nonceLock = await getNonceLock(from);\n const nonce = toHex(nonceLock.nextNonce);\n const releaseLock = nonceLock.releaseLock.bind(nonceLock);\n\n log('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails);\n\n return [nonce, releaseLock];\n}\n\n/**\n * Filter and format transactions for the nonce tracker.\n *\n * @param currentChainId - Chain ID of the current network.\n * @param fromAddress - Address of the account from which the transactions to filter from are sent.\n * @param transactionStatus - Status of the transactions for which to filter.\n * @param transactions - Array of transactionMeta objects that have been prefiltered.\n * @returns Array of transactions formatted for the nonce tracker.\n */\nexport function getAndFormatTransactionsForNonceTracker(\n currentChainId: string,\n fromAddress: string,\n transactionStatus: TransactionStatus,\n transactions: TransactionMeta[],\n): NonceTrackerTransaction[] {\n return transactions\n .filter(\n ({ chainId, isTransfer, isUserOperation, status, txParams: { from } }) =>\n !isTransfer &&\n !isUserOperation &&\n chainId === currentChainId &&\n status === transactionStatus &&\n from.toLowerCase() === fromAddress.toLowerCase(),\n )\n .map(({ status, txParams: { from, gas, value, nonce } }) => {\n // the only value we care about is the nonce\n // but we need to return the other values to satisfy the type\n // TODO: refactor nonceTracker to not require this\n /* istanbul ignore next */\n return {\n status,\n history: [{}],\n txParams: {\n from: from ?? '',\n gas: gas ?? '',\n value: value ?? '',\n nonce: nonce ?? '',\n },\n };\n });\n}\n"],"mappings":";;;;;;AAAA,SAAS,aAAa;AAStB,IAAM,MAAM,mBAAmB,eAAe,OAAO;AASrD,eAAsB,aACpB,QACA,cAC6C;AAC7C,QAAM;AAAA,IACJ;AAAA,IACA,UAAU,EAAE,MAAM,OAAO,cAAc;AAAA,EACzC,IAAI;AAEJ,QAAM,cAAc,mBAAmB,MAAM,gBAAgB,IAAI;AAEjE,MAAI,aAAa;AACf,QAAI,sBAAsB,WAAW;AACrC,WAAO,CAAC,aAAa,MAAS;AAAA,EAChC;AAEA,MAAI,eAAe;AACjB,QAAI,wBAAwB,aAAa;AACzC,WAAO,CAAC,eAAe,MAAS;AAAA,EAClC;AAEA,QAAM,YAAY,MAAM,aAAa,IAAI;AACzC,QAAM,QAAQ,MAAM,UAAU,SAAS;AACvC,QAAM,cAAc,UAAU,YAAY,KAAK,SAAS;AAExD,MAAI,kCAAkC,OAAO,UAAU,YAAY;AAEnE,SAAO,CAAC,OAAO,WAAW;AAC5B;AAWO,SAAS,wCACd,gBACA,aACA,mBACA,cAC2B;AAC3B,SAAO,aACJ;AAAA,IACC,CAAC,EAAE,SAAS,YAAY,iBAAiB,QAAQ,UAAU,EAAE,KAAK,EAAE,MAClE,CAAC,cACD,CAAC,mBACD,YAAY,kBACZ,WAAW,qBACX,KAAK,YAAY,MAAM,YAAY,YAAY;AAAA,EACnD,EACC,IAAI,CAAC,EAAE,QAAQ,UAAU,EAAE,MAAM,KAAK,OAAO,MAAM,EAAE,MAAM;AAK1D,WAAO;AAAA,MACL;AAAA,MACA,SAAS,CAAC,CAAC,CAAC;AAAA,MACZ,UAAU;AAAA,QACR,MAAM,QAAQ;AAAA,QACd,KAAK,OAAO;AAAA,QACZ,OAAO,SAAS;AAAA,QAChB,OAAO,SAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF,CAAC;AACL;","names":[]}
|
package/dist/chunk-6DODV6OV.js
DELETED
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _chunkZ4BLTVTBjs = require('./chunk-Z4BLTVTB.js');
|
|
11
|
-
|
|
12
|
-
// src/helpers/PendingTransactionTracker.ts
|
|
13
|
-
var _controllerutils = require('@metamask/controller-utils');
|
|
14
|
-
var _events = require('events'); var _events2 = _interopRequireDefault(_events);
|
|
15
|
-
var _lodash = require('lodash');
|
|
16
|
-
var DROPPED_BLOCK_COUNT = 3;
|
|
17
|
-
var RECEIPT_STATUS_SUCCESS = "0x1";
|
|
18
|
-
var RECEIPT_STATUS_FAILURE = "0x0";
|
|
19
|
-
var MAX_RETRY_BLOCK_DISTANCE = 50;
|
|
20
|
-
var KNOWN_TRANSACTION_ERRORS = [
|
|
21
|
-
"replacement transaction underpriced",
|
|
22
|
-
"known transaction",
|
|
23
|
-
"gas price too low to replace",
|
|
24
|
-
"transaction with the same hash was already imported",
|
|
25
|
-
"gateway timeout",
|
|
26
|
-
"nonce too low"
|
|
27
|
-
];
|
|
28
|
-
var log = _chunkS6VGOPUYjs.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger, "pending-transactions");
|
|
29
|
-
var _blockTracker, _droppedBlockCountByHash, _getChainId, _getEthQuery, _getTransactions, _isResubmitEnabled, _listener, _getGlobalLock, _publishTransaction, _running, _beforeCheckPendingTransaction, _beforePublish, _start, start_fn, _onLatestBlock, onLatestBlock_fn, _checkTransactions, checkTransactions_fn, _resubmitTransactions, resubmitTransactions_fn, _isKnownTransactionError, isKnownTransactionError_fn, _resubmitTransaction, resubmitTransaction_fn, _isResubmitDue, isResubmitDue_fn, _checkTransaction, checkTransaction_fn, _onTransactionConfirmed, onTransactionConfirmed_fn, _isTransactionDropped, isTransactionDropped_fn, _isNonceTaken, isNonceTaken_fn, _getPendingTransactions, getPendingTransactions_fn, _warnTransaction, warnTransaction_fn, _failTransaction, failTransaction_fn, _dropTransaction, dropTransaction_fn, _updateTransaction, updateTransaction_fn, _getTransactionReceipt, getTransactionReceipt_fn, _getBlockByHash, getBlockByHash_fn, _getNetworkTransactionCount, getNetworkTransactionCount_fn, _getCurrentChainTransactions, getCurrentChainTransactions_fn;
|
|
30
|
-
var PendingTransactionTracker = class {
|
|
31
|
-
constructor({
|
|
32
|
-
blockTracker,
|
|
33
|
-
getChainId,
|
|
34
|
-
getEthQuery,
|
|
35
|
-
getTransactions,
|
|
36
|
-
isResubmitEnabled,
|
|
37
|
-
getGlobalLock,
|
|
38
|
-
publishTransaction,
|
|
39
|
-
hooks
|
|
40
|
-
}) {
|
|
41
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _start);
|
|
42
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _onLatestBlock);
|
|
43
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _checkTransactions);
|
|
44
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _resubmitTransactions);
|
|
45
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _isKnownTransactionError);
|
|
46
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _resubmitTransaction);
|
|
47
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _isResubmitDue);
|
|
48
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _checkTransaction);
|
|
49
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _onTransactionConfirmed);
|
|
50
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _isTransactionDropped);
|
|
51
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _isNonceTaken);
|
|
52
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getPendingTransactions);
|
|
53
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _warnTransaction);
|
|
54
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _failTransaction);
|
|
55
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _dropTransaction);
|
|
56
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateTransaction);
|
|
57
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getTransactionReceipt);
|
|
58
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getBlockByHash);
|
|
59
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getNetworkTransactionCount);
|
|
60
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getCurrentChainTransactions);
|
|
61
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _blockTracker, void 0);
|
|
62
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _droppedBlockCountByHash, void 0);
|
|
63
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getChainId, void 0);
|
|
64
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getEthQuery, void 0);
|
|
65
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getTransactions, void 0);
|
|
66
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _isResubmitEnabled, void 0);
|
|
67
|
-
// TODO: Replace `any` with type
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _listener, void 0);
|
|
70
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getGlobalLock, void 0);
|
|
71
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _publishTransaction, void 0);
|
|
72
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _running, void 0);
|
|
73
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _beforeCheckPendingTransaction, void 0);
|
|
74
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _beforePublish, void 0);
|
|
75
|
-
this.startIfPendingTransactions = () => {
|
|
76
|
-
const pendingTransactions = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getPendingTransactions, getPendingTransactions_fn).call(this);
|
|
77
|
-
if (pendingTransactions.length) {
|
|
78
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _start, start_fn).call(this);
|
|
79
|
-
} else {
|
|
80
|
-
this.stop();
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
this.hub = new (0, _events2.default)();
|
|
84
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _blockTracker, blockTracker);
|
|
85
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _droppedBlockCountByHash, /* @__PURE__ */ new Map());
|
|
86
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getChainId, getChainId);
|
|
87
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getEthQuery, getEthQuery);
|
|
88
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getTransactions, getTransactions);
|
|
89
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _isResubmitEnabled, isResubmitEnabled ?? (() => true));
|
|
90
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _listener, _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _onLatestBlock, onLatestBlock_fn).bind(this));
|
|
91
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _getGlobalLock, getGlobalLock);
|
|
92
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _publishTransaction, publishTransaction);
|
|
93
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _running, false);
|
|
94
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _beforePublish, hooks?.beforePublish ?? (() => true));
|
|
95
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _beforeCheckPendingTransaction, hooks?.beforeCheckPendingTransaction ?? (() => true));
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Force checks the network if the given transaction is confirmed and updates it's status.
|
|
99
|
-
*
|
|
100
|
-
* @param txMeta - The transaction to check
|
|
101
|
-
*/
|
|
102
|
-
async forceCheckTransaction(txMeta) {
|
|
103
|
-
const releaseLock = await _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getGlobalLock).call(this);
|
|
104
|
-
try {
|
|
105
|
-
await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _checkTransaction, checkTransaction_fn).call(this, txMeta);
|
|
106
|
-
} catch (error) {
|
|
107
|
-
log("Failed to check transaction", error);
|
|
108
|
-
} finally {
|
|
109
|
-
releaseLock();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
stop() {
|
|
113
|
-
if (!_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _running)) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _blockTracker).removeListener("latest", _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _listener));
|
|
117
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _running, false);
|
|
118
|
-
log("Stopped polling");
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
_blockTracker = new WeakMap();
|
|
122
|
-
_droppedBlockCountByHash = new WeakMap();
|
|
123
|
-
_getChainId = new WeakMap();
|
|
124
|
-
_getEthQuery = new WeakMap();
|
|
125
|
-
_getTransactions = new WeakMap();
|
|
126
|
-
_isResubmitEnabled = new WeakMap();
|
|
127
|
-
_listener = new WeakMap();
|
|
128
|
-
_getGlobalLock = new WeakMap();
|
|
129
|
-
_publishTransaction = new WeakMap();
|
|
130
|
-
_running = new WeakMap();
|
|
131
|
-
_beforeCheckPendingTransaction = new WeakMap();
|
|
132
|
-
_beforePublish = new WeakMap();
|
|
133
|
-
_start = new WeakSet();
|
|
134
|
-
start_fn = function() {
|
|
135
|
-
if (_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _running)) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _blockTracker).on("latest", _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _listener));
|
|
139
|
-
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _running, true);
|
|
140
|
-
log("Started polling");
|
|
141
|
-
};
|
|
142
|
-
_onLatestBlock = new WeakSet();
|
|
143
|
-
onLatestBlock_fn = async function(latestBlockNumber) {
|
|
144
|
-
const releaseLock = await _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getGlobalLock).call(this);
|
|
145
|
-
try {
|
|
146
|
-
await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _checkTransactions, checkTransactions_fn).call(this);
|
|
147
|
-
} catch (error) {
|
|
148
|
-
log("Failed to check transactions", error);
|
|
149
|
-
} finally {
|
|
150
|
-
releaseLock();
|
|
151
|
-
}
|
|
152
|
-
try {
|
|
153
|
-
await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _resubmitTransactions, resubmitTransactions_fn).call(this, latestBlockNumber);
|
|
154
|
-
} catch (error) {
|
|
155
|
-
log("Failed to resubmit transactions", error);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
_checkTransactions = new WeakSet();
|
|
159
|
-
checkTransactions_fn = async function() {
|
|
160
|
-
log("Checking transactions");
|
|
161
|
-
const pendingTransactions = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getPendingTransactions, getPendingTransactions_fn).call(this);
|
|
162
|
-
if (!pendingTransactions.length) {
|
|
163
|
-
log("No pending transactions to check");
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
log("Found pending transactions to check", {
|
|
167
|
-
count: pendingTransactions.length,
|
|
168
|
-
ids: pendingTransactions.map((tx) => tx.id)
|
|
169
|
-
});
|
|
170
|
-
await Promise.all(
|
|
171
|
-
pendingTransactions.map((tx) => _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _checkTransaction, checkTransaction_fn).call(this, tx))
|
|
172
|
-
);
|
|
173
|
-
};
|
|
174
|
-
_resubmitTransactions = new WeakSet();
|
|
175
|
-
resubmitTransactions_fn = async function(latestBlockNumber) {
|
|
176
|
-
if (!_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _isResubmitEnabled).call(this) || !_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _running)) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
log("Resubmitting transactions");
|
|
180
|
-
const pendingTransactions = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getPendingTransactions, getPendingTransactions_fn).call(this);
|
|
181
|
-
if (!pendingTransactions.length) {
|
|
182
|
-
log("No pending transactions to resubmit");
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
log("Found pending transactions to resubmit", {
|
|
186
|
-
count: pendingTransactions.length,
|
|
187
|
-
ids: pendingTransactions.map((tx) => tx.id)
|
|
188
|
-
});
|
|
189
|
-
for (const txMeta of pendingTransactions) {
|
|
190
|
-
try {
|
|
191
|
-
await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _resubmitTransaction, resubmitTransaction_fn).call(this, txMeta, latestBlockNumber);
|
|
192
|
-
} catch (error) {
|
|
193
|
-
const errorMessage = error.value?.message?.toLowerCase() || error.message?.toLowerCase() || String(error);
|
|
194
|
-
if (_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _isKnownTransactionError, isKnownTransactionError_fn).call(this, errorMessage)) {
|
|
195
|
-
log("Ignoring known transaction error", errorMessage);
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _warnTransaction, warnTransaction_fn).call(this, txMeta, error.message, "There was an error when resubmitting this transaction.");
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
_isKnownTransactionError = new WeakSet();
|
|
203
|
-
isKnownTransactionError_fn = function(errorMessage) {
|
|
204
|
-
return KNOWN_TRANSACTION_ERRORS.some(
|
|
205
|
-
(knownError) => errorMessage.includes(knownError)
|
|
206
|
-
);
|
|
207
|
-
};
|
|
208
|
-
_resubmitTransaction = new WeakSet();
|
|
209
|
-
resubmitTransaction_fn = async function(txMeta, latestBlockNumber) {
|
|
210
|
-
if (!_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _isResubmitDue, isResubmitDue_fn).call(this, txMeta, latestBlockNumber)) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
const { rawTx } = txMeta;
|
|
214
|
-
if (!_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _beforePublish).call(this, txMeta)) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
const ethQuery = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getEthQuery).call(this, txMeta.networkClientId);
|
|
218
|
-
await _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _publishTransaction).call(this, ethQuery, rawTx);
|
|
219
|
-
const retryCount = (txMeta.retryCount ?? 0) + 1;
|
|
220
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransaction, updateTransaction_fn).call(this, _lodash.merge.call(void 0, {}, txMeta, { retryCount }), "PendingTransactionTracker:transaction-retry - Retry count increased");
|
|
221
|
-
};
|
|
222
|
-
_isResubmitDue = new WeakSet();
|
|
223
|
-
isResubmitDue_fn = function(txMeta, latestBlockNumber) {
|
|
224
|
-
const txMetaWithFirstRetryBlockNumber = _lodash.cloneDeep.call(void 0, txMeta);
|
|
225
|
-
if (!txMetaWithFirstRetryBlockNumber.firstRetryBlockNumber) {
|
|
226
|
-
txMetaWithFirstRetryBlockNumber.firstRetryBlockNumber = latestBlockNumber;
|
|
227
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransaction, updateTransaction_fn).call(this, txMetaWithFirstRetryBlockNumber, "PendingTransactionTracker:#isResubmitDue - First retry block number set");
|
|
228
|
-
}
|
|
229
|
-
const { firstRetryBlockNumber } = txMetaWithFirstRetryBlockNumber;
|
|
230
|
-
const blocksSinceFirstRetry = Number.parseInt(latestBlockNumber, 16) - Number.parseInt(firstRetryBlockNumber, 16);
|
|
231
|
-
const retryCount = txMeta.retryCount || 0;
|
|
232
|
-
const requiredBlocksSinceFirstRetry = Math.min(
|
|
233
|
-
MAX_RETRY_BLOCK_DISTANCE,
|
|
234
|
-
Math.pow(2, retryCount)
|
|
235
|
-
);
|
|
236
|
-
return blocksSinceFirstRetry >= requiredBlocksSinceFirstRetry;
|
|
237
|
-
};
|
|
238
|
-
_checkTransaction = new WeakSet();
|
|
239
|
-
checkTransaction_fn = async function(txMeta) {
|
|
240
|
-
const { hash, id } = txMeta;
|
|
241
|
-
if (!hash && _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _beforeCheckPendingTransaction).call(this, txMeta)) {
|
|
242
|
-
const error = new Error(
|
|
243
|
-
"We had an error while submitting this transaction, please try again."
|
|
244
|
-
);
|
|
245
|
-
error.name = "NoTxHashError";
|
|
246
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _failTransaction, failTransaction_fn).call(this, txMeta, error);
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
if (_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _isNonceTaken, isNonceTaken_fn).call(this, txMeta)) {
|
|
250
|
-
log("Nonce already taken", id);
|
|
251
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _dropTransaction, dropTransaction_fn).call(this, txMeta);
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
try {
|
|
255
|
-
const receipt = await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getTransactionReceipt, getTransactionReceipt_fn).call(this, hash);
|
|
256
|
-
const isSuccess = receipt?.status === RECEIPT_STATUS_SUCCESS;
|
|
257
|
-
const isFailure = receipt?.status === RECEIPT_STATUS_FAILURE;
|
|
258
|
-
if (isFailure) {
|
|
259
|
-
log("Transaction receipt has failed status");
|
|
260
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _failTransaction, failTransaction_fn).call(this, txMeta, new Error("Transaction dropped or replaced"));
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
const { blockNumber, blockHash } = receipt || {};
|
|
264
|
-
if (isSuccess && blockNumber && blockHash) {
|
|
265
|
-
await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _onTransactionConfirmed, onTransactionConfirmed_fn).call(this, txMeta, {
|
|
266
|
-
...receipt,
|
|
267
|
-
blockNumber,
|
|
268
|
-
blockHash
|
|
269
|
-
});
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
} catch (error) {
|
|
273
|
-
log("Failed to check transaction", id, error);
|
|
274
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _warnTransaction, warnTransaction_fn).call(this, txMeta, error.message, "There was a problem loading this transaction.");
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
if (await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _isTransactionDropped, isTransactionDropped_fn).call(this, txMeta)) {
|
|
278
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _dropTransaction, dropTransaction_fn).call(this, txMeta);
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
_onTransactionConfirmed = new WeakSet();
|
|
282
|
-
onTransactionConfirmed_fn = async function(txMeta, receipt) {
|
|
283
|
-
const { id } = txMeta;
|
|
284
|
-
const { blockHash } = receipt;
|
|
285
|
-
log("Transaction confirmed", id);
|
|
286
|
-
const { baseFeePerGas, timestamp: blockTimestamp } = await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getBlockByHash, getBlockByHash_fn).call(this, blockHash, false);
|
|
287
|
-
const updatedTxMeta = _lodash.cloneDeep.call(void 0, txMeta);
|
|
288
|
-
updatedTxMeta.baseFeePerGas = baseFeePerGas;
|
|
289
|
-
updatedTxMeta.blockTimestamp = blockTimestamp;
|
|
290
|
-
updatedTxMeta.status = "confirmed" /* confirmed */;
|
|
291
|
-
updatedTxMeta.txParams = {
|
|
292
|
-
...updatedTxMeta.txParams,
|
|
293
|
-
gasUsed: receipt.gasUsed
|
|
294
|
-
};
|
|
295
|
-
updatedTxMeta.txReceipt = receipt;
|
|
296
|
-
updatedTxMeta.verifiedOnBlockchain = true;
|
|
297
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransaction, updateTransaction_fn).call(this, updatedTxMeta, "PendingTransactionTracker:#onTransactionConfirmed - Transaction confirmed");
|
|
298
|
-
this.hub.emit("transaction-confirmed", updatedTxMeta);
|
|
299
|
-
};
|
|
300
|
-
_isTransactionDropped = new WeakSet();
|
|
301
|
-
isTransactionDropped_fn = async function(txMeta) {
|
|
302
|
-
const {
|
|
303
|
-
hash,
|
|
304
|
-
id,
|
|
305
|
-
txParams: { nonce, from }
|
|
306
|
-
} = txMeta;
|
|
307
|
-
if (!nonce || !hash) {
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
const networkNextNonceHex = await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getNetworkTransactionCount, getNetworkTransactionCount_fn).call(this, from);
|
|
311
|
-
const networkNextNonceNumber = parseInt(networkNextNonceHex, 16);
|
|
312
|
-
const nonceNumber = parseInt(nonce, 16);
|
|
313
|
-
if (nonceNumber >= networkNextNonceNumber) {
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
316
|
-
let droppedBlockCount = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _droppedBlockCountByHash).get(hash);
|
|
317
|
-
if (droppedBlockCount === void 0) {
|
|
318
|
-
droppedBlockCount = 0;
|
|
319
|
-
_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _droppedBlockCountByHash).set(hash, droppedBlockCount);
|
|
320
|
-
}
|
|
321
|
-
if (droppedBlockCount < DROPPED_BLOCK_COUNT) {
|
|
322
|
-
log("Incrementing dropped block count", { id, droppedBlockCount });
|
|
323
|
-
_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _droppedBlockCountByHash).set(hash, droppedBlockCount + 1);
|
|
324
|
-
return false;
|
|
325
|
-
}
|
|
326
|
-
log("Hit dropped block count", id);
|
|
327
|
-
_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _droppedBlockCountByHash).delete(hash);
|
|
328
|
-
return true;
|
|
329
|
-
};
|
|
330
|
-
_isNonceTaken = new WeakSet();
|
|
331
|
-
isNonceTaken_fn = function(txMeta) {
|
|
332
|
-
const { id, txParams } = txMeta;
|
|
333
|
-
return _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getCurrentChainTransactions, getCurrentChainTransactions_fn).call(this).some(
|
|
334
|
-
(tx) => tx.id !== id && tx.txParams.from === txParams.from && tx.status === "confirmed" /* confirmed */ && tx.txParams.nonce === txParams.nonce && tx.type !== "incoming" /* incoming */
|
|
335
|
-
);
|
|
336
|
-
};
|
|
337
|
-
_getPendingTransactions = new WeakSet();
|
|
338
|
-
getPendingTransactions_fn = function() {
|
|
339
|
-
return _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getCurrentChainTransactions, getCurrentChainTransactions_fn).call(this).filter(
|
|
340
|
-
(tx) => tx.status === "submitted" /* submitted */ && !tx.verifiedOnBlockchain && !tx.isUserOperation
|
|
341
|
-
);
|
|
342
|
-
};
|
|
343
|
-
_warnTransaction = new WeakSet();
|
|
344
|
-
warnTransaction_fn = function(txMeta, error, message) {
|
|
345
|
-
_chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _updateTransaction, updateTransaction_fn).call(this, {
|
|
346
|
-
...txMeta,
|
|
347
|
-
warning: { error, message }
|
|
348
|
-
}, "PendingTransactionTracker:#warnTransaction - Warning added");
|
|
349
|
-
};
|
|
350
|
-
_failTransaction = new WeakSet();
|
|
351
|
-
failTransaction_fn = function(txMeta, error) {
|
|
352
|
-
log("Transaction failed", txMeta.id, error);
|
|
353
|
-
this.hub.emit("transaction-failed", txMeta, error);
|
|
354
|
-
};
|
|
355
|
-
_dropTransaction = new WeakSet();
|
|
356
|
-
dropTransaction_fn = function(txMeta) {
|
|
357
|
-
log("Transaction dropped", txMeta.id);
|
|
358
|
-
this.hub.emit("transaction-dropped", txMeta);
|
|
359
|
-
};
|
|
360
|
-
_updateTransaction = new WeakSet();
|
|
361
|
-
updateTransaction_fn = function(txMeta, note) {
|
|
362
|
-
this.hub.emit("transaction-updated", txMeta, note);
|
|
363
|
-
};
|
|
364
|
-
_getTransactionReceipt = new WeakSet();
|
|
365
|
-
getTransactionReceipt_fn = async function(txHash) {
|
|
366
|
-
return await _controllerutils.query.call(void 0, _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getEthQuery).call(this), "getTransactionReceipt", [txHash]);
|
|
367
|
-
};
|
|
368
|
-
_getBlockByHash = new WeakSet();
|
|
369
|
-
getBlockByHash_fn = async function(blockHash, includeTransactionDetails) {
|
|
370
|
-
return await _controllerutils.query.call(void 0, _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getEthQuery).call(this), "getBlockByHash", [
|
|
371
|
-
blockHash,
|
|
372
|
-
includeTransactionDetails
|
|
373
|
-
]);
|
|
374
|
-
};
|
|
375
|
-
_getNetworkTransactionCount = new WeakSet();
|
|
376
|
-
getNetworkTransactionCount_fn = async function(address) {
|
|
377
|
-
return await _controllerutils.query.call(void 0, _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getEthQuery).call(this), "getTransactionCount", [address]);
|
|
378
|
-
};
|
|
379
|
-
_getCurrentChainTransactions = new WeakSet();
|
|
380
|
-
getCurrentChainTransactions_fn = function() {
|
|
381
|
-
const currentChainId = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getChainId).call(this);
|
|
382
|
-
return _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _getTransactions).call(this).filter(
|
|
383
|
-
(tx) => tx.chainId === currentChainId
|
|
384
|
-
);
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
exports.PendingTransactionTracker = PendingTransactionTracker;
|
|
390
|
-
//# sourceMappingURL=chunk-6DODV6OV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/PendingTransactionTracker.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,SAAS,aAAa;AAMtB,OAAO,kBAAkB;AACzB,SAAS,WAAW,aAAa;AAUjC,IAAM,sBAAsB;AAE5B,IAA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AAAA,oBAAe,eACnB,WACA,2BAGc;AACd,SAAO,MAAM,MAAM,mBAAK,cAAL,YAAqB,kBAAkB;AAAA,IACxD;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEM;AAAA,gCAA2B,eAAC,SAAkC;AAClE,SAAO,MAAM,MAAM,mBAAK,cAAL,YAAqB,uBAAuB,CAAC,OAAO,CAAC;AAC1E;AAEA;AAAA,iCAA4B,WAAsB;AAChD,QAAM,iBAAiB,mBAAK,aAAL;AAEvB,SAAO,mBAAK,kBAAL,WAAwB;AAAA,IAC7B,CAAC,OAAO,GAAG,YAAY;AAAA,EACzB;AACF","sourcesContent":["import { query } from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type {\n BlockTracker,\n NetworkClientId,\n} from '@metamask/network-controller';\nimport EventEmitter from 'events';\nimport { cloneDeep, merge } from 'lodash';\n\nimport { createModuleLogger, projectLogger } from '../logger';\nimport type { TransactionMeta, TransactionReceipt } from '../types';\nimport { TransactionStatus, TransactionType } from '../types';\n\n/**\n * We wait this many blocks before emitting a 'transaction-dropped' event\n * This is because we could be talking to a node that is out of sync\n */\nconst DROPPED_BLOCK_COUNT = 3;\n\nconst RECEIPT_STATUS_SUCCESS = '0x1';\nconst RECEIPT_STATUS_FAILURE = '0x0';\nconst MAX_RETRY_BLOCK_DISTANCE = 50;\n\nconst KNOWN_TRANSACTION_ERRORS = [\n 'replacement transaction underpriced',\n 'known transaction',\n 'gas price too low to replace',\n 'transaction with the same hash was already imported',\n 'gateway timeout',\n 'nonce too low',\n];\n\nconst log = createModuleLogger(projectLogger, 'pending-transactions');\n\ntype SuccessfulTransactionReceipt = TransactionReceipt & {\n blockNumber: string;\n blockHash: string;\n};\n\ntype Events = {\n 'transaction-confirmed': [txMeta: TransactionMeta];\n 'transaction-dropped': [txMeta: TransactionMeta];\n 'transaction-failed': [txMeta: TransactionMeta, error: Error];\n 'transaction-updated': [txMeta: TransactionMeta, note: string];\n};\n\n// This interface was created before this ESLint rule was added.\n// Convert to a `type` in a future major version.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface PendingTransactionTrackerEventEmitter extends EventEmitter {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n on<T extends keyof Events>(\n eventName: T,\n listener: (...args: Events[T]) => void,\n ): this;\n\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n emit<T extends keyof Events>(eventName: T, ...args: Events[T]): boolean;\n}\n\nexport class PendingTransactionTracker {\n hub: PendingTransactionTrackerEventEmitter;\n\n #blockTracker: BlockTracker;\n\n #droppedBlockCountByHash: Map<string, number>;\n\n #getChainId: () => string;\n\n #getEthQuery: (networkClientId?: NetworkClientId) => EthQuery;\n\n #getTransactions: () => TransactionMeta[];\n\n #isResubmitEnabled: () => boolean;\n\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #listener: any;\n\n #getGlobalLock: () => Promise<() => void>;\n\n #publishTransaction: (ethQuery: EthQuery, rawTx: string) => Promise<string>;\n\n #running: boolean;\n\n #beforeCheckPendingTransaction: (transactionMeta: TransactionMeta) => boolean;\n\n #beforePublish: (transactionMeta: TransactionMeta) => boolean;\n\n constructor({\n blockTracker,\n getChainId,\n getEthQuery,\n getTransactions,\n isResubmitEnabled,\n getGlobalLock,\n publishTransaction,\n hooks,\n }: {\n blockTracker: BlockTracker;\n getChainId: () => string;\n getEthQuery: (networkClientId?: NetworkClientId) => EthQuery;\n getTransactions: () => TransactionMeta[];\n isResubmitEnabled?: () => boolean;\n getGlobalLock: () => Promise<() => void>;\n publishTransaction: (ethQuery: EthQuery, rawTx: string) => Promise<string>;\n hooks?: {\n beforeCheckPendingTransaction?: (\n transactionMeta: TransactionMeta,\n ) => boolean;\n beforePublish?: (transactionMeta: TransactionMeta) => boolean;\n };\n }) {\n this.hub = new EventEmitter() as PendingTransactionTrackerEventEmitter;\n\n this.#blockTracker = blockTracker;\n this.#droppedBlockCountByHash = new Map();\n this.#getChainId = getChainId;\n this.#getEthQuery = getEthQuery;\n this.#getTransactions = getTransactions;\n this.#isResubmitEnabled = isResubmitEnabled ?? (() => true);\n this.#listener = this.#onLatestBlock.bind(this);\n this.#getGlobalLock = getGlobalLock;\n this.#publishTransaction = publishTransaction;\n this.#running = false;\n this.#beforePublish = hooks?.beforePublish ?? (() => true);\n this.#beforeCheckPendingTransaction =\n hooks?.beforeCheckPendingTransaction ?? (() => true);\n }\n\n startIfPendingTransactions = () => {\n const pendingTransactions = this.#getPendingTransactions();\n\n if (pendingTransactions.length) {\n this.#start();\n } else {\n this.stop();\n }\n };\n\n /**\n * Force checks the network if the given transaction is confirmed and updates it's status.\n *\n * @param txMeta - The transaction to check\n */\n async forceCheckTransaction(txMeta: TransactionMeta) {\n const releaseLock = await this.#getGlobalLock();\n\n try {\n await this.#checkTransaction(txMeta);\n } catch (error) {\n /* istanbul ignore next */\n log('Failed to check transaction', error);\n } finally {\n releaseLock();\n }\n }\n\n #start() {\n if (this.#running) {\n return;\n }\n\n this.#blockTracker.on('latest', this.#listener);\n this.#running = true;\n\n log('Started polling');\n }\n\n stop() {\n if (!this.#running) {\n return;\n }\n\n this.#blockTracker.removeListener('latest', this.#listener);\n this.#running = false;\n\n log('Stopped polling');\n }\n\n async #onLatestBlock(latestBlockNumber: string) {\n const releaseLock = await this.#getGlobalLock();\n\n try {\n await this.#checkTransactions();\n } catch (error) {\n /* istanbul ignore next */\n log('Failed to check transactions', error);\n } finally {\n releaseLock();\n }\n\n try {\n await this.#resubmitTransactions(latestBlockNumber);\n } catch (error) {\n /* istanbul ignore next */\n log('Failed to resubmit transactions', error);\n }\n }\n\n async #checkTransactions() {\n log('Checking transactions');\n\n const pendingTransactions = this.#getPendingTransactions();\n\n if (!pendingTransactions.length) {\n log('No pending transactions to check');\n return;\n }\n\n log('Found pending transactions to check', {\n count: pendingTransactions.length,\n ids: pendingTransactions.map((tx) => tx.id),\n });\n\n await Promise.all(\n pendingTransactions.map((tx) => this.#checkTransaction(tx)),\n );\n }\n\n async #resubmitTransactions(latestBlockNumber: string) {\n if (!this.#isResubmitEnabled() || !this.#running) {\n return;\n }\n\n log('Resubmitting transactions');\n\n const pendingTransactions = this.#getPendingTransactions();\n\n if (!pendingTransactions.length) {\n log('No pending transactions to resubmit');\n return;\n }\n\n log('Found pending transactions to resubmit', {\n count: pendingTransactions.length,\n ids: pendingTransactions.map((tx) => tx.id),\n });\n\n for (const txMeta of pendingTransactions) {\n try {\n await this.#resubmitTransaction(txMeta, latestBlockNumber);\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n /* istanbul ignore next */\n const errorMessage =\n error.value?.message?.toLowerCase() ||\n error.message?.toLowerCase() ||\n String(error);\n\n if (this.#isKnownTransactionError(errorMessage)) {\n log('Ignoring known transaction error', errorMessage);\n continue;\n }\n\n this.#warnTransaction(\n txMeta,\n error.message,\n 'There was an error when resubmitting this transaction.',\n );\n }\n }\n }\n\n #isKnownTransactionError(errorMessage: string) {\n return KNOWN_TRANSACTION_ERRORS.some((knownError) =>\n errorMessage.includes(knownError),\n );\n }\n\n async #resubmitTransaction(\n txMeta: TransactionMeta,\n latestBlockNumber: string,\n ) {\n if (!this.#isResubmitDue(txMeta, latestBlockNumber)) {\n return;\n }\n\n const { rawTx } = txMeta;\n\n if (!this.#beforePublish(txMeta)) {\n return;\n }\n\n const ethQuery = this.#getEthQuery(txMeta.networkClientId);\n await this.#publishTransaction(ethQuery, rawTx as string);\n\n const retryCount = (txMeta.retryCount ?? 0) + 1;\n\n this.#updateTransaction(\n merge({}, txMeta, { retryCount }),\n 'PendingTransactionTracker:transaction-retry - Retry count increased',\n );\n }\n\n #isResubmitDue(txMeta: TransactionMeta, latestBlockNumber: string): boolean {\n const txMetaWithFirstRetryBlockNumber = cloneDeep(txMeta);\n\n if (!txMetaWithFirstRetryBlockNumber.firstRetryBlockNumber) {\n txMetaWithFirstRetryBlockNumber.firstRetryBlockNumber = latestBlockNumber;\n\n this.#updateTransaction(\n txMetaWithFirstRetryBlockNumber,\n 'PendingTransactionTracker:#isResubmitDue - First retry block number set',\n );\n }\n\n const { firstRetryBlockNumber } = txMetaWithFirstRetryBlockNumber;\n\n const blocksSinceFirstRetry =\n Number.parseInt(latestBlockNumber, 16) -\n Number.parseInt(firstRetryBlockNumber, 16);\n\n const retryCount = txMeta.retryCount || 0;\n\n // Exponential backoff to limit retries at publishing\n // Capped at ~15 minutes between retries\n const requiredBlocksSinceFirstRetry = Math.min(\n MAX_RETRY_BLOCK_DISTANCE,\n Math.pow(2, retryCount),\n );\n\n return blocksSinceFirstRetry >= requiredBlocksSinceFirstRetry;\n }\n\n async #checkTransaction(txMeta: TransactionMeta) {\n const { hash, id } = txMeta;\n\n if (!hash && this.#beforeCheckPendingTransaction(txMeta)) {\n const error = new Error(\n 'We had an error while submitting this transaction, please try again.',\n );\n\n error.name = 'NoTxHashError';\n\n this.#failTransaction(txMeta, error);\n\n return;\n }\n\n if (this.#isNonceTaken(txMeta)) {\n log('Nonce already taken', id);\n this.#dropTransaction(txMeta);\n return;\n }\n\n try {\n const receipt = await this.#getTransactionReceipt(hash);\n const isSuccess = receipt?.status === RECEIPT_STATUS_SUCCESS;\n const isFailure = receipt?.status === RECEIPT_STATUS_FAILURE;\n\n if (isFailure) {\n log('Transaction receipt has failed status');\n\n this.#failTransaction(\n txMeta,\n new Error('Transaction dropped or replaced'),\n );\n\n return;\n }\n\n const { blockNumber, blockHash } = receipt || {};\n\n if (isSuccess && blockNumber && blockHash) {\n await this.#onTransactionConfirmed(txMeta, {\n ...receipt,\n blockNumber,\n blockHash,\n });\n\n return;\n }\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n log('Failed to check transaction', id, error);\n\n this.#warnTransaction(\n txMeta,\n error.message,\n 'There was a problem loading this transaction.',\n );\n\n return;\n }\n\n if (await this.#isTransactionDropped(txMeta)) {\n this.#dropTransaction(txMeta);\n }\n }\n\n async #onTransactionConfirmed(\n txMeta: TransactionMeta,\n receipt: SuccessfulTransactionReceipt,\n ) {\n const { id } = txMeta;\n const { blockHash } = receipt;\n\n log('Transaction confirmed', id);\n\n const { baseFeePerGas, timestamp: blockTimestamp } =\n await this.#getBlockByHash(blockHash, false);\n\n const updatedTxMeta = cloneDeep(txMeta);\n updatedTxMeta.baseFeePerGas = baseFeePerGas;\n updatedTxMeta.blockTimestamp = blockTimestamp;\n updatedTxMeta.status = TransactionStatus.confirmed;\n updatedTxMeta.txParams = {\n ...updatedTxMeta.txParams,\n gasUsed: receipt.gasUsed,\n };\n updatedTxMeta.txReceipt = receipt;\n updatedTxMeta.verifiedOnBlockchain = true;\n\n this.#updateTransaction(\n updatedTxMeta,\n 'PendingTransactionTracker:#onTransactionConfirmed - Transaction confirmed',\n );\n\n this.hub.emit('transaction-confirmed', updatedTxMeta);\n }\n\n async #isTransactionDropped(txMeta: TransactionMeta) {\n const {\n hash,\n id,\n txParams: { nonce, from },\n } = txMeta;\n\n /* istanbul ignore next */\n if (!nonce || !hash) {\n return false;\n }\n\n const networkNextNonceHex = await this.#getNetworkTransactionCount(from);\n const networkNextNonceNumber = parseInt(networkNextNonceHex, 16);\n const nonceNumber = parseInt(nonce, 16);\n\n if (nonceNumber >= networkNextNonceNumber) {\n return false;\n }\n\n let droppedBlockCount = this.#droppedBlockCountByHash.get(hash);\n\n if (droppedBlockCount === undefined) {\n droppedBlockCount = 0;\n this.#droppedBlockCountByHash.set(hash, droppedBlockCount);\n }\n\n if (droppedBlockCount < DROPPED_BLOCK_COUNT) {\n log('Incrementing dropped block count', { id, droppedBlockCount });\n this.#droppedBlockCountByHash.set(hash, droppedBlockCount + 1);\n return false;\n }\n\n log('Hit dropped block count', id);\n\n this.#droppedBlockCountByHash.delete(hash);\n return true;\n }\n\n #isNonceTaken(txMeta: TransactionMeta): boolean {\n const { id, txParams } = txMeta;\n\n return this.#getCurrentChainTransactions().some(\n (tx) =>\n tx.id !== id &&\n tx.txParams.from === txParams.from &&\n tx.status === TransactionStatus.confirmed &&\n tx.txParams.nonce === txParams.nonce &&\n tx.type !== TransactionType.incoming,\n );\n }\n\n #getPendingTransactions(): TransactionMeta[] {\n return this.#getCurrentChainTransactions().filter(\n (tx) =>\n tx.status === TransactionStatus.submitted &&\n !tx.verifiedOnBlockchain &&\n !tx.isUserOperation,\n );\n }\n\n #warnTransaction(txMeta: TransactionMeta, error: string, message: string) {\n this.#updateTransaction(\n {\n ...txMeta,\n warning: { error, message },\n },\n 'PendingTransactionTracker:#warnTransaction - Warning added',\n );\n }\n\n #failTransaction(txMeta: TransactionMeta, error: Error) {\n log('Transaction failed', txMeta.id, error);\n this.hub.emit('transaction-failed', txMeta, error);\n }\n\n #dropTransaction(txMeta: TransactionMeta) {\n log('Transaction dropped', txMeta.id);\n this.hub.emit('transaction-dropped', txMeta);\n }\n\n #updateTransaction(txMeta: TransactionMeta, note: string) {\n this.hub.emit('transaction-updated', txMeta, note);\n }\n\n async #getTransactionReceipt(\n txHash?: string,\n ): Promise<TransactionReceipt | undefined> {\n return await query(this.#getEthQuery(), 'getTransactionReceipt', [txHash]);\n }\n\n async #getBlockByHash(\n blockHash: string,\n includeTransactionDetails: boolean,\n // TODO: Replace `any` with type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<any> {\n return await query(this.#getEthQuery(), 'getBlockByHash', [\n blockHash,\n includeTransactionDetails,\n ]);\n }\n\n async #getNetworkTransactionCount(address: string): Promise<string> {\n return await query(this.#getEthQuery(), 'getTransactionCount', [address]);\n }\n\n #getCurrentChainTransactions(): TransactionMeta[] {\n const currentChainId = this.#getChainId();\n\n return this.#getTransactions().filter(\n (tx) => tx.chainId === currentChainId,\n );\n }\n}\n"]}
|
package/dist/chunk-6JO6EU6Z.mjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GasFeeEstimateLevel
|
|
3
|
-
} from "./chunk-ASTXVFGJ.mjs";
|
|
4
|
-
|
|
5
|
-
// src/utils/gas-flow.ts
|
|
6
|
-
import { weiHexToGweiDec } from "@metamask/controller-utils";
|
|
7
|
-
function getGasFeeFlow(transactionMeta, gasFeeFlows) {
|
|
8
|
-
return gasFeeFlows.find(
|
|
9
|
-
(gasFeeFlow) => gasFeeFlow.matchesTransaction(transactionMeta)
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
function mergeGasFeeEstimates({
|
|
13
|
-
gasFeeControllerEstimates,
|
|
14
|
-
transactionGasFeeEstimates
|
|
15
|
-
}) {
|
|
16
|
-
const transactionEstimateType = transactionGasFeeEstimates.type;
|
|
17
|
-
if (transactionEstimateType === "fee-market" /* FeeMarket */) {
|
|
18
|
-
return Object.values(GasFeeEstimateLevel).reduce(
|
|
19
|
-
(result, level) => ({
|
|
20
|
-
...result,
|
|
21
|
-
[level]: mergeFeeMarketEstimate(
|
|
22
|
-
gasFeeControllerEstimates?.[level],
|
|
23
|
-
transactionGasFeeEstimates[level]
|
|
24
|
-
)
|
|
25
|
-
}),
|
|
26
|
-
{ ...gasFeeControllerEstimates }
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
if (transactionEstimateType === "legacy" /* Legacy */) {
|
|
30
|
-
return Object.values(GasFeeEstimateLevel).reduce(
|
|
31
|
-
(result, level) => ({
|
|
32
|
-
...result,
|
|
33
|
-
[level]: getLegacyEstimate(transactionGasFeeEstimates, level)
|
|
34
|
-
}),
|
|
35
|
-
{}
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
if (transactionEstimateType === "eth_gasPrice" /* GasPrice */) {
|
|
39
|
-
return {
|
|
40
|
-
gasPrice: getGasPriceEstimate(transactionGasFeeEstimates)
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return gasFeeControllerEstimates;
|
|
44
|
-
}
|
|
45
|
-
function mergeFeeMarketEstimate(gasFeeControllerEstimate, transactionGasFeeEstimate) {
|
|
46
|
-
return {
|
|
47
|
-
...gasFeeControllerEstimate,
|
|
48
|
-
suggestedMaxFeePerGas: weiHexToGweiDec(
|
|
49
|
-
transactionGasFeeEstimate.maxFeePerGas
|
|
50
|
-
),
|
|
51
|
-
suggestedMaxPriorityFeePerGas: weiHexToGweiDec(
|
|
52
|
-
transactionGasFeeEstimate.maxPriorityFeePerGas
|
|
53
|
-
)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function getLegacyEstimate(transactionGasFeeEstimate, level) {
|
|
57
|
-
return weiHexToGweiDec(transactionGasFeeEstimate[level]);
|
|
58
|
-
}
|
|
59
|
-
function getGasPriceEstimate(transactionGasFeeEstimate) {
|
|
60
|
-
return weiHexToGweiDec(transactionGasFeeEstimate.gasPrice);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export {
|
|
64
|
-
getGasFeeFlow,
|
|
65
|
-
mergeGasFeeEstimates
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=chunk-6JO6EU6Z.mjs.map
|