@metamask/transaction-controller 36.0.0 → 37.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -1
- package/dist/TransactionController.cjs +2026 -0
- package/dist/TransactionController.cjs.map +1 -0
- package/dist/{types/TransactionController.d.ts → TransactionController.d.cts} +16 -24
- 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} +6 -7
- 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 -35
- 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-4OYPDGHO.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 +19 -14
- 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-4OYPDGHO.js +0 -201
- package/dist/chunk-4V4XIPCI.mjs +0 -338
- package/dist/chunk-4V4XIPCI.mjs.map +0 -1
- package/dist/chunk-5G6OHAXI.mjs +0 -137
- package/dist/chunk-5G6OHAXI.mjs.map +0 -1
- package/dist/chunk-5HYWLTVQ.js +0 -228
- package/dist/chunk-5HYWLTVQ.js.map +0 -1
- package/dist/chunk-5QVDIVJH.js +0 -68
- package/dist/chunk-5QVDIVJH.js.map +0 -1
- package/dist/chunk-6B5BEO3R.mjs +0 -399
- package/dist/chunk-6B5BEO3R.mjs.map +0 -1
- package/dist/chunk-6DDVVUJC.mjs +0 -50
- package/dist/chunk-6DDVVUJC.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-7NMV2NPM.js +0 -172
- package/dist/chunk-7NMV2NPM.js.map +0 -1
- package/dist/chunk-AWIJZAW3.mjs +0 -112
- package/dist/chunk-AWIJZAW3.mjs.map +0 -1
- package/dist/chunk-BZV72SCF.js +0 -226
- package/dist/chunk-BZV72SCF.js.map +0 -1
- package/dist/chunk-EGQCE3FK.mjs +0 -85
- package/dist/chunk-EGQCE3FK.mjs.map +0 -1
- package/dist/chunk-EHWAY6XU.js +0 -112
- package/dist/chunk-EHWAY6XU.js.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-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-KYRW4BLA.mjs +0 -121
- package/dist/chunk-KYRW4BLA.mjs.map +0 -1
- package/dist/chunk-LFFYCDHB.mjs +0 -92
- package/dist/chunk-LFFYCDHB.mjs.map +0 -1
- package/dist/chunk-NNCUD3QF.js +0 -360
- package/dist/chunk-NNCUD3QF.js.map +0 -1
- package/dist/chunk-NNHSNPT2.mjs +0 -67
- package/dist/chunk-NNHSNPT2.mjs.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-PRUNMTRD.js +0 -50
- package/dist/chunk-PRUNMTRD.js.map +0 -1
- package/dist/chunk-PSZ34BI5.js +0 -92
- package/dist/chunk-PSZ34BI5.js.map +0 -1
- package/dist/chunk-QKV7E5BO.js +0 -257
- package/dist/chunk-QKV7E5BO.js.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-SFFOC25Q.mjs +0 -226
- package/dist/chunk-SFFOC25Q.mjs.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-UHAFIPSL.js +0 -121
- package/dist/chunk-UHAFIPSL.js.map +0 -1
- package/dist/chunk-UHSRHP55.mjs +0 -106
- package/dist/chunk-UHSRHP55.mjs.map +0 -1
- package/dist/chunk-ULD4JC3Q.js +0 -399
- package/dist/chunk-ULD4JC3Q.js.map +0 -1
- package/dist/chunk-UQQWZT6C.mjs +0 -14
- package/dist/chunk-UQQWZT6C.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-VGFPVAKX.mjs +0 -228
- package/dist/chunk-VGFPVAKX.mjs.map +0 -1
- package/dist/chunk-VKWOHNDO.js +0 -2509
- package/dist/chunk-VKWOHNDO.js.map +0 -1
- package/dist/chunk-WR5F34OW.js +0 -23
- package/dist/chunk-WR5F34OW.js.map +0 -1
- package/dist/chunk-X4XSEYPL.mjs +0 -201
- package/dist/chunk-X4XSEYPL.mjs.map +0 -1
- package/dist/chunk-XTMJ25EF.mjs +0 -2509
- package/dist/chunk-XTMJ25EF.mjs.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-YVCX6Z75.js +0 -102
- package/dist/chunk-YVCX6Z75.js.map +0 -1
- package/dist/chunk-YWLMT7XH.js +0 -67
- package/dist/chunk-YWLMT7XH.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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTransactionLayer1GasFee = exports.updateTransactionLayer1GasFee = void 0;
|
|
4
|
+
const utils_1 = require("@metamask/utils");
|
|
5
|
+
const logger_1 = require("../logger.cjs");
|
|
6
|
+
const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'layer-1-gas-fee-flow');
|
|
7
|
+
/**
|
|
8
|
+
* Updates the given transactionMeta with the layer 1 gas fee.
|
|
9
|
+
* @param request - The request to use when getting the layer 1 gas fee.
|
|
10
|
+
* @param request.provider - Provider used to create a new underlying EthQuery instance
|
|
11
|
+
* @param request.transactionMeta - The transaction to get the layer 1 gas fee for.
|
|
12
|
+
* @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.
|
|
13
|
+
*/
|
|
14
|
+
async function updateTransactionLayer1GasFee(request) {
|
|
15
|
+
const layer1GasFee = await getTransactionLayer1GasFee(request);
|
|
16
|
+
if (!layer1GasFee) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const { transactionMeta } = request;
|
|
20
|
+
transactionMeta.layer1GasFee = layer1GasFee;
|
|
21
|
+
log('Updated layer 1 gas fee', layer1GasFee, transactionMeta.id);
|
|
22
|
+
}
|
|
23
|
+
exports.updateTransactionLayer1GasFee = updateTransactionLayer1GasFee;
|
|
24
|
+
/**
|
|
25
|
+
* Get the layer 1 gas fee flow for a transaction.
|
|
26
|
+
* @param transactionMeta - The transaction to get the layer 1 gas fee flow for.
|
|
27
|
+
* @param layer1GasFeeFlows - The layer 1 gas fee flows to search.
|
|
28
|
+
* @returns The layer 1 gas fee flow for the transaction, or undefined if none match.
|
|
29
|
+
*/
|
|
30
|
+
function getLayer1GasFeeFlow(transactionMeta, layer1GasFeeFlows) {
|
|
31
|
+
return layer1GasFeeFlows.find((layer1GasFeeFlow) => layer1GasFeeFlow.matchesTransaction(transactionMeta));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the layer 1 gas fee for a transaction and return the layer1Fee.
|
|
35
|
+
* @param request - The request to use when getting the layer 1 gas fee.
|
|
36
|
+
* @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.
|
|
37
|
+
* @param request.provider - The provider to use to get the layer 1 gas fee.
|
|
38
|
+
* @param request.transactionMeta - The transaction to get the layer 1 gas fee for.
|
|
39
|
+
*/
|
|
40
|
+
async function getTransactionLayer1GasFee({ layer1GasFeeFlows, provider, transactionMeta, }) {
|
|
41
|
+
const layer1GasFeeFlow = getLayer1GasFeeFlow(transactionMeta, layer1GasFeeFlows);
|
|
42
|
+
if (!layer1GasFeeFlow) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
log('Found layer 1 gas fee flow', layer1GasFeeFlow.constructor.name, transactionMeta.id);
|
|
46
|
+
try {
|
|
47
|
+
const { layer1Fee } = await layer1GasFeeFlow.getLayer1Fee({
|
|
48
|
+
provider,
|
|
49
|
+
transactionMeta,
|
|
50
|
+
});
|
|
51
|
+
return layer1Fee;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
log('Failed to get layer 1 gas fee', transactionMeta.id, error);
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.getTransactionLayer1GasFee = getTransactionLayer1GasFee;
|
|
59
|
+
//# sourceMappingURL=layer1-gas-fee-flow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer1-gas-fee-flow.cjs","sourceRoot":"","sources":["../../src/utils/layer1-gas-fee-flow.ts"],"names":[],"mappings":";;;AACA,2CAA+D;AAE/D,0CAA0C;AAG1C,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,sBAAsB,CAAC,CAAC;AAQtE;;;;;;GAMG;AACI,KAAK,UAAU,6BAA6B,CACjD,OAAkC;IAElC,MAAM,YAAY,GAAG,MAAM,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAE/D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;KACR;IAED,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEpC,eAAe,CAAC,YAAY,GAAG,YAAY,CAAC;IAE5C,GAAG,CAAC,yBAAyB,EAAE,YAAY,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC;AAdD,sEAcC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB,CAC1B,eAAgC,EAChC,iBAAqC;IAErC,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE,CACjD,gBAAgB,CAAC,kBAAkB,CAAC,eAAe,CAAC,CACrD,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,0BAA0B,CAAC,EAC/C,iBAAiB,EACjB,QAAQ,EACR,eAAe,GACW;IAC1B,MAAM,gBAAgB,GAAG,mBAAmB,CAC1C,eAAe,EACf,iBAAiB,CAClB,CAAC;IAEF,IAAI,CAAC,gBAAgB,EAAE;QACrB,OAAO,SAAS,CAAC;KAClB;IAED,GAAG,CACD,4BAA4B,EAC5B,gBAAgB,CAAC,WAAW,CAAC,IAAI,EACjC,eAAe,CAAC,EAAE,CACnB,CAAC;IAEF,IAAI;QACF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC;YACxD,QAAQ;YACR,eAAe;SAChB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;KAClB;IAAC,OAAO,KAAK,EAAE;QACd,GAAG,CAAC,+BAA+B,EAAE,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AA9BD,gEA8BC","sourcesContent":["import type { Provider } from '@metamask/network-controller';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type { Layer1GasFeeFlow, TransactionMeta } from '../types';\n\nconst log = createModuleLogger(projectLogger, 'layer-1-gas-fee-flow');\n\nexport type UpdateLayer1GasFeeRequest = {\n layer1GasFeeFlows: Layer1GasFeeFlow[];\n provider: Provider;\n transactionMeta: TransactionMeta;\n};\n\n/**\n * Updates the given transactionMeta with the layer 1 gas fee.\n * @param request - The request to use when getting the layer 1 gas fee.\n * @param request.provider - Provider used to create a new underlying EthQuery instance\n * @param request.transactionMeta - The transaction to get the layer 1 gas fee for.\n * @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.\n */\nexport async function updateTransactionLayer1GasFee(\n request: UpdateLayer1GasFeeRequest,\n) {\n const layer1GasFee = await getTransactionLayer1GasFee(request);\n\n if (!layer1GasFee) {\n return;\n }\n\n const { transactionMeta } = request;\n\n transactionMeta.layer1GasFee = layer1GasFee;\n\n log('Updated layer 1 gas fee', layer1GasFee, transactionMeta.id);\n}\n\n/**\n * Get the layer 1 gas fee flow for a transaction.\n * @param transactionMeta - The transaction to get the layer 1 gas fee flow for.\n * @param layer1GasFeeFlows - The layer 1 gas fee flows to search.\n * @returns The layer 1 gas fee flow for the transaction, or undefined if none match.\n */\nfunction getLayer1GasFeeFlow(\n transactionMeta: TransactionMeta,\n layer1GasFeeFlows: Layer1GasFeeFlow[],\n): Layer1GasFeeFlow | undefined {\n return layer1GasFeeFlows.find((layer1GasFeeFlow) =>\n layer1GasFeeFlow.matchesTransaction(transactionMeta),\n );\n}\n\n/**\n * Get the layer 1 gas fee for a transaction and return the layer1Fee.\n * @param request - The request to use when getting the layer 1 gas fee.\n * @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.\n * @param request.provider - The provider to use to get the layer 1 gas fee.\n * @param request.transactionMeta - The transaction to get the layer 1 gas fee for.\n */\nexport async function getTransactionLayer1GasFee({\n layer1GasFeeFlows,\n provider,\n transactionMeta,\n}: UpdateLayer1GasFeeRequest): Promise<Hex | undefined> {\n const layer1GasFeeFlow = getLayer1GasFeeFlow(\n transactionMeta,\n layer1GasFeeFlows,\n );\n\n if (!layer1GasFeeFlow) {\n return undefined;\n }\n\n log(\n 'Found layer 1 gas fee flow',\n layer1GasFeeFlow.constructor.name,\n transactionMeta.id,\n );\n\n try {\n const { layer1Fee } = await layer1GasFeeFlow.getLayer1Fee({\n provider,\n transactionMeta,\n });\n return layer1Fee;\n } catch (error) {\n log('Failed to get layer 1 gas fee', transactionMeta.id, error);\n return undefined;\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Provider } from
|
|
2
|
-
import { type Hex } from
|
|
3
|
-
import type { Layer1GasFeeFlow, TransactionMeta } from
|
|
1
|
+
import type { Provider } from "@metamask/network-controller";
|
|
2
|
+
import { type Hex } from "@metamask/utils";
|
|
3
|
+
import type { Layer1GasFeeFlow, TransactionMeta } from "../types.cjs";
|
|
4
4
|
export type UpdateLayer1GasFeeRequest = {
|
|
5
5
|
layer1GasFeeFlows: Layer1GasFeeFlow[];
|
|
6
6
|
provider: Provider;
|
|
@@ -22,4 +22,4 @@ export declare function updateTransactionLayer1GasFee(request: UpdateLayer1GasFe
|
|
|
22
22
|
* @param request.transactionMeta - The transaction to get the layer 1 gas fee for.
|
|
23
23
|
*/
|
|
24
24
|
export declare function getTransactionLayer1GasFee({ layer1GasFeeFlows, provider, transactionMeta, }: UpdateLayer1GasFeeRequest): Promise<Hex | undefined>;
|
|
25
|
-
//# sourceMappingURL=layer1-gas-fee-flow.d.
|
|
25
|
+
//# sourceMappingURL=layer1-gas-fee-flow.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer1-gas-fee-flow.d.cts","sourceRoot":"","sources":["../../src/utils/layer1-gas-fee-flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qCAAqC;AAC7D,OAAO,EAAsB,KAAK,GAAG,EAAE,wBAAwB;AAG/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAiB;AAIlE,MAAM,MAAM,yBAAyB,GAAG;IACtC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,yBAAyB,iBAanC;AAiBD;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAAC,EAC/C,iBAAiB,EACjB,QAAQ,EACR,eAAe,GAChB,EAAE,yBAAyB,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CA0BtD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Provider } from "@metamask/network-controller";
|
|
2
|
+
import { type Hex } from "@metamask/utils";
|
|
3
|
+
import type { Layer1GasFeeFlow, TransactionMeta } from "../types.mjs";
|
|
4
|
+
export type UpdateLayer1GasFeeRequest = {
|
|
5
|
+
layer1GasFeeFlows: Layer1GasFeeFlow[];
|
|
6
|
+
provider: Provider;
|
|
7
|
+
transactionMeta: TransactionMeta;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Updates the given transactionMeta with the layer 1 gas fee.
|
|
11
|
+
* @param request - The request to use when getting the layer 1 gas fee.
|
|
12
|
+
* @param request.provider - Provider used to create a new underlying EthQuery instance
|
|
13
|
+
* @param request.transactionMeta - The transaction to get the layer 1 gas fee for.
|
|
14
|
+
* @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.
|
|
15
|
+
*/
|
|
16
|
+
export declare function updateTransactionLayer1GasFee(request: UpdateLayer1GasFeeRequest): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the layer 1 gas fee for a transaction and return the layer1Fee.
|
|
19
|
+
* @param request - The request to use when getting the layer 1 gas fee.
|
|
20
|
+
* @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.
|
|
21
|
+
* @param request.provider - The provider to use to get the layer 1 gas fee.
|
|
22
|
+
* @param request.transactionMeta - The transaction to get the layer 1 gas fee for.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getTransactionLayer1GasFee({ layer1GasFeeFlows, provider, transactionMeta, }: UpdateLayer1GasFeeRequest): Promise<Hex | undefined>;
|
|
25
|
+
//# sourceMappingURL=layer1-gas-fee-flow.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer1-gas-fee-flow.d.mts","sourceRoot":"","sources":["../../src/utils/layer1-gas-fee-flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qCAAqC;AAC7D,OAAO,EAAsB,KAAK,GAAG,EAAE,wBAAwB;AAG/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAiB;AAIlE,MAAM,MAAM,yBAAyB,GAAG;IACtC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,yBAAyB,iBAanC;AAiBD;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAAC,EAC/C,iBAAiB,EACjB,QAAQ,EACR,eAAe,GAChB,EAAE,yBAAyB,GAAG,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,CA0BtD"}
|
|
@@ -1,11 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { createModuleLogger } from "@metamask/utils";
|
|
2
|
+
import { projectLogger } from "../logger.mjs";
|
|
3
|
+
const log = createModuleLogger(projectLogger, 'layer-1-gas-fee-flow');
|
|
4
|
+
/**
|
|
5
|
+
* Updates the given transactionMeta with the layer 1 gas fee.
|
|
6
|
+
* @param request - The request to use when getting the layer 1 gas fee.
|
|
7
|
+
* @param request.provider - Provider used to create a new underlying EthQuery instance
|
|
8
|
+
* @param request.transactionMeta - The transaction to get the layer 1 gas fee for.
|
|
9
|
+
* @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.
|
|
10
|
+
*/
|
|
11
|
+
export async function updateTransactionLayer1GasFee(request) {
|
|
12
|
+
const layer1GasFee = await getTransactionLayer1GasFee(request);
|
|
13
|
+
if (!layer1GasFee) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const { transactionMeta } = request;
|
|
17
|
+
transactionMeta.layer1GasFee = layer1GasFee;
|
|
18
|
+
log('Updated layer 1 gas fee', layer1GasFee, transactionMeta.id);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get the layer 1 gas fee flow for a transaction.
|
|
22
|
+
* @param transactionMeta - The transaction to get the layer 1 gas fee flow for.
|
|
23
|
+
* @param layer1GasFeeFlows - The layer 1 gas fee flows to search.
|
|
24
|
+
* @returns The layer 1 gas fee flow for the transaction, or undefined if none match.
|
|
25
|
+
*/
|
|
26
|
+
function getLayer1GasFeeFlow(transactionMeta, layer1GasFeeFlows) {
|
|
27
|
+
return layer1GasFeeFlows.find((layer1GasFeeFlow) => layer1GasFeeFlow.matchesTransaction(transactionMeta));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the layer 1 gas fee for a transaction and return the layer1Fee.
|
|
31
|
+
* @param request - The request to use when getting the layer 1 gas fee.
|
|
32
|
+
* @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.
|
|
33
|
+
* @param request.provider - The provider to use to get the layer 1 gas fee.
|
|
34
|
+
* @param request.transactionMeta - The transaction to get the layer 1 gas fee for.
|
|
35
|
+
*/
|
|
36
|
+
export async function getTransactionLayer1GasFee({ layer1GasFeeFlows, provider, transactionMeta, }) {
|
|
37
|
+
const layer1GasFeeFlow = getLayer1GasFeeFlow(transactionMeta, layer1GasFeeFlows);
|
|
38
|
+
if (!layer1GasFeeFlow) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
log('Found layer 1 gas fee flow', layer1GasFeeFlow.constructor.name, transactionMeta.id);
|
|
42
|
+
try {
|
|
43
|
+
const { layer1Fee } = await layer1GasFeeFlow.getLayer1Fee({
|
|
44
|
+
provider,
|
|
45
|
+
transactionMeta,
|
|
46
|
+
});
|
|
47
|
+
return layer1Fee;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
log('Failed to get layer 1 gas fee', transactionMeta.id, error);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
11
54
|
//# sourceMappingURL=layer1-gas-fee-flow.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"layer1-gas-fee-flow.mjs","sourceRoot":"","sources":["../../src/utils/layer1-gas-fee-flow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAY,wBAAwB;AAE/D,OAAO,EAAE,aAAa,EAAE,sBAAkB;AAG1C,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC;AAQtE;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,OAAkC;IAElC,MAAM,YAAY,GAAG,MAAM,0BAA0B,CAAC,OAAO,CAAC,CAAC;IAE/D,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;KACR;IAED,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEpC,eAAe,CAAC,YAAY,GAAG,YAAY,CAAC;IAE5C,GAAG,CAAC,yBAAyB,EAAE,YAAY,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB,CAC1B,eAAgC,EAChC,iBAAqC;IAErC,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE,CACjD,gBAAgB,CAAC,kBAAkB,CAAC,eAAe,CAAC,CACrD,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,EAC/C,iBAAiB,EACjB,QAAQ,EACR,eAAe,GACW;IAC1B,MAAM,gBAAgB,GAAG,mBAAmB,CAC1C,eAAe,EACf,iBAAiB,CAClB,CAAC;IAEF,IAAI,CAAC,gBAAgB,EAAE;QACrB,OAAO,SAAS,CAAC;KAClB;IAED,GAAG,CACD,4BAA4B,EAC5B,gBAAgB,CAAC,WAAW,CAAC,IAAI,EACjC,eAAe,CAAC,EAAE,CACnB,CAAC;IAEF,IAAI;QACF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC;YACxD,QAAQ;YACR,eAAe;SAChB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;KAClB;IAAC,OAAO,KAAK,EAAE;QACd,GAAG,CAAC,+BAA+B,EAAE,eAAe,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAChE,OAAO,SAAS,CAAC;KAClB;AACH,CAAC","sourcesContent":["import type { Provider } from '@metamask/network-controller';\nimport { createModuleLogger, type Hex } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type { Layer1GasFeeFlow, TransactionMeta } from '../types';\n\nconst log = createModuleLogger(projectLogger, 'layer-1-gas-fee-flow');\n\nexport type UpdateLayer1GasFeeRequest = {\n layer1GasFeeFlows: Layer1GasFeeFlow[];\n provider: Provider;\n transactionMeta: TransactionMeta;\n};\n\n/**\n * Updates the given transactionMeta with the layer 1 gas fee.\n * @param request - The request to use when getting the layer 1 gas fee.\n * @param request.provider - Provider used to create a new underlying EthQuery instance\n * @param request.transactionMeta - The transaction to get the layer 1 gas fee for.\n * @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.\n */\nexport async function updateTransactionLayer1GasFee(\n request: UpdateLayer1GasFeeRequest,\n) {\n const layer1GasFee = await getTransactionLayer1GasFee(request);\n\n if (!layer1GasFee) {\n return;\n }\n\n const { transactionMeta } = request;\n\n transactionMeta.layer1GasFee = layer1GasFee;\n\n log('Updated layer 1 gas fee', layer1GasFee, transactionMeta.id);\n}\n\n/**\n * Get the layer 1 gas fee flow for a transaction.\n * @param transactionMeta - The transaction to get the layer 1 gas fee flow for.\n * @param layer1GasFeeFlows - The layer 1 gas fee flows to search.\n * @returns The layer 1 gas fee flow for the transaction, or undefined if none match.\n */\nfunction getLayer1GasFeeFlow(\n transactionMeta: TransactionMeta,\n layer1GasFeeFlows: Layer1GasFeeFlow[],\n): Layer1GasFeeFlow | undefined {\n return layer1GasFeeFlows.find((layer1GasFeeFlow) =>\n layer1GasFeeFlow.matchesTransaction(transactionMeta),\n );\n}\n\n/**\n * Get the layer 1 gas fee for a transaction and return the layer1Fee.\n * @param request - The request to use when getting the layer 1 gas fee.\n * @param request.layer1GasFeeFlows - The layer 1 gas fee flows to search.\n * @param request.provider - The provider to use to get the layer 1 gas fee.\n * @param request.transactionMeta - The transaction to get the layer 1 gas fee for.\n */\nexport async function getTransactionLayer1GasFee({\n layer1GasFeeFlows,\n provider,\n transactionMeta,\n}: UpdateLayer1GasFeeRequest): Promise<Hex | undefined> {\n const layer1GasFeeFlow = getLayer1GasFeeFlow(\n transactionMeta,\n layer1GasFeeFlows,\n );\n\n if (!layer1GasFeeFlow) {\n return undefined;\n }\n\n log(\n 'Found layer 1 gas fee flow',\n layer1GasFeeFlow.constructor.name,\n transactionMeta.id,\n );\n\n try {\n const { layer1Fee } = await layer1GasFeeFlow.getLayer1Fee({\n provider,\n transactionMeta,\n });\n return layer1Fee;\n } catch (error) {\n log('Failed to get layer 1 gas fee', transactionMeta.id, error);\n return undefined;\n }\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAndFormatTransactionsForNonceTracker = exports.getNextNonce = void 0;
|
|
4
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
5
|
+
const logger_1 = require("../logger.cjs");
|
|
6
|
+
const log = (0, logger_1.createModuleLogger)(logger_1.projectLogger, 'nonce');
|
|
7
|
+
/**
|
|
8
|
+
* Determine the next nonce to be used for a transaction.
|
|
9
|
+
*
|
|
10
|
+
* @param txMeta - The transaction metadata.
|
|
11
|
+
* @param getNonceLock - An anonymous function that acquires the nonce lock for an address
|
|
12
|
+
* @returns The next hexadecimal nonce to be used for the given transaction, and optionally a function to release the nonce lock.
|
|
13
|
+
*/
|
|
14
|
+
async function getNextNonce(txMeta, getNonceLock) {
|
|
15
|
+
const { customNonceValue, txParams: { from, nonce: existingNonce }, } = txMeta;
|
|
16
|
+
const customNonce = customNonceValue ? (0, controller_utils_1.toHex)(customNonceValue) : undefined;
|
|
17
|
+
if (customNonce) {
|
|
18
|
+
log('Using custom nonce', customNonce);
|
|
19
|
+
return [customNonce, undefined];
|
|
20
|
+
}
|
|
21
|
+
if (existingNonce) {
|
|
22
|
+
log('Using existing nonce', existingNonce);
|
|
23
|
+
return [existingNonce, undefined];
|
|
24
|
+
}
|
|
25
|
+
const nonceLock = await getNonceLock(from);
|
|
26
|
+
const nonce = (0, controller_utils_1.toHex)(nonceLock.nextNonce);
|
|
27
|
+
const releaseLock = nonceLock.releaseLock.bind(nonceLock);
|
|
28
|
+
log('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails);
|
|
29
|
+
return [nonce, releaseLock];
|
|
30
|
+
}
|
|
31
|
+
exports.getNextNonce = getNextNonce;
|
|
32
|
+
/**
|
|
33
|
+
* Filter and format transactions for the nonce tracker.
|
|
34
|
+
*
|
|
35
|
+
* @param currentChainId - Chain ID of the current network.
|
|
36
|
+
* @param fromAddress - Address of the account from which the transactions to filter from are sent.
|
|
37
|
+
* @param transactionStatus - Status of the transactions for which to filter.
|
|
38
|
+
* @param transactions - Array of transactionMeta objects that have been prefiltered.
|
|
39
|
+
* @returns Array of transactions formatted for the nonce tracker.
|
|
40
|
+
*/
|
|
41
|
+
function getAndFormatTransactionsForNonceTracker(currentChainId, fromAddress, transactionStatus, transactions) {
|
|
42
|
+
return transactions
|
|
43
|
+
.filter(({ chainId, isTransfer, isUserOperation, status, txParams: { from } }) => !isTransfer &&
|
|
44
|
+
!isUserOperation &&
|
|
45
|
+
chainId === currentChainId &&
|
|
46
|
+
status === transactionStatus &&
|
|
47
|
+
from.toLowerCase() === fromAddress.toLowerCase())
|
|
48
|
+
.map(({ status, txParams: { from, gas, value, nonce } }) => {
|
|
49
|
+
// the only value we care about is the nonce
|
|
50
|
+
// but we need to return the other values to satisfy the type
|
|
51
|
+
// TODO: refactor nonceTracker to not require this
|
|
52
|
+
/* istanbul ignore next */
|
|
53
|
+
return {
|
|
54
|
+
status,
|
|
55
|
+
history: [{}],
|
|
56
|
+
txParams: {
|
|
57
|
+
from: from ?? '',
|
|
58
|
+
gas: gas ?? '',
|
|
59
|
+
value: value ?? '',
|
|
60
|
+
nonce: nonce ?? '',
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.getAndFormatTransactionsForNonceTracker = getAndFormatTransactionsForNonceTracker;
|
|
66
|
+
//# sourceMappingURL=nonce.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonce.cjs","sourceRoot":"","sources":["../../src/utils/nonce.ts"],"names":[],"mappings":";;;AAAA,iEAAmD;AAMnD,0CAA8D;AAG9D,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,OAAO,CAAC,CAAC;AAEvD;;;;;;GAMG;AACI,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,YAAqD;IAErD,MAAM,EACJ,gBAAgB,EAChB,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GACzC,GAAG,MAAM,CAAC;IAEX,MAAM,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAA,wBAAK,EAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3E,IAAI,WAAW,EAAE;QACf,GAAG,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;QACvC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;KACjC;IAED,IAAI,aAAa,EAAE;QACjB,GAAG,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;QAC3C,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;KACnC;IAED,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAA,wBAAK,EAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE1D,GAAG,CAAC,gCAAgC,EAAE,KAAK,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;IAErE,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC9B,CAAC;AA5BD,oCA4BC;AAED;;;;;;;;GAQG;AACH,SAAgB,uCAAuC,CACrD,cAAsB,EACtB,WAAmB,EACnB,iBAAoC,EACpC,YAA+B;IAE/B,OAAO,YAAY;SAChB,MAAM,CACL,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CACvE,CAAC,UAAU;QACX,CAAC,eAAe;QAChB,OAAO,KAAK,cAAc;QAC1B,MAAM,KAAK,iBAAiB;QAC5B,IAAI,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CACnD;SACA,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QACzD,4CAA4C;QAC5C,6DAA6D;QAC7D,kDAAkD;QAClD,0BAA0B;QAC1B,OAAO;YACL,MAAM;YACN,OAAO,EAAE,CAAC,EAAE,CAAC;YACb,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI,IAAI,EAAE;gBAChB,GAAG,EAAE,GAAG,IAAI,EAAE;gBACd,KAAK,EAAE,KAAK,IAAI,EAAE;gBAClB,KAAK,EAAE,KAAK,IAAI,EAAE;aACnB;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC;AA/BD,0FA+BC","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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { NonceLock, Transaction as NonceTrackerTransaction } from
|
|
2
|
-
import type { TransactionMeta, TransactionStatus } from
|
|
1
|
+
import type { NonceLock, Transaction as NonceTrackerTransaction } from "@metamask/nonce-tracker";
|
|
2
|
+
import type { TransactionMeta, TransactionStatus } from "../types.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Determine the next nonce to be used for a transaction.
|
|
5
5
|
*
|
|
@@ -18,4 +18,4 @@ export declare function getNextNonce(txMeta: TransactionMeta, getNonceLock: (add
|
|
|
18
18
|
* @returns Array of transactions formatted for the nonce tracker.
|
|
19
19
|
*/
|
|
20
20
|
export declare function getAndFormatTransactionsForNonceTracker(currentChainId: string, fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[];
|
|
21
|
-
//# sourceMappingURL=nonce.d.
|
|
21
|
+
//# sourceMappingURL=nonce.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonce.d.cts","sourceRoot":"","sources":["../../src/utils/nonce.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,WAAW,IAAI,uBAAuB,EACvC,gCAAgC;AAGjC,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,qBAAiB;AAInE;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,GACpD,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAyB7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,uCAAuC,CACrD,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,eAAe,EAAE,GAC9B,uBAAuB,EAAE,CA0B3B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NonceLock, Transaction as NonceTrackerTransaction } from "@metamask/nonce-tracker";
|
|
2
|
+
import type { TransactionMeta, TransactionStatus } from "../types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Determine the next nonce to be used for a transaction.
|
|
5
|
+
*
|
|
6
|
+
* @param txMeta - The transaction metadata.
|
|
7
|
+
* @param getNonceLock - An anonymous function that acquires the nonce lock for an address
|
|
8
|
+
* @returns The next hexadecimal nonce to be used for the given transaction, and optionally a function to release the nonce lock.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getNextNonce(txMeta: TransactionMeta, getNonceLock: (address: string) => Promise<NonceLock>): Promise<[string, (() => void) | undefined]>;
|
|
11
|
+
/**
|
|
12
|
+
* Filter and format transactions for the nonce tracker.
|
|
13
|
+
*
|
|
14
|
+
* @param currentChainId - Chain ID of the current network.
|
|
15
|
+
* @param fromAddress - Address of the account from which the transactions to filter from are sent.
|
|
16
|
+
* @param transactionStatus - Status of the transactions for which to filter.
|
|
17
|
+
* @param transactions - Array of transactionMeta objects that have been prefiltered.
|
|
18
|
+
* @returns Array of transactions formatted for the nonce tracker.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getAndFormatTransactionsForNonceTracker(currentChainId: string, fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[]): NonceTrackerTransaction[];
|
|
21
|
+
//# sourceMappingURL=nonce.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonce.d.mts","sourceRoot":"","sources":["../../src/utils/nonce.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,WAAW,IAAI,uBAAuB,EACvC,gCAAgC;AAGjC,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,qBAAiB;AAInE;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,GACpD,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAyB7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,uCAAuC,CACrD,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,eAAe,EAAE,GAC9B,uBAAuB,EAAE,CA0B3B"}
|
package/dist/utils/nonce.mjs
CHANGED
|
@@ -1,11 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { toHex } from "@metamask/controller-utils";
|
|
2
|
+
import { createModuleLogger, projectLogger } from "../logger.mjs";
|
|
3
|
+
const log = createModuleLogger(projectLogger, 'nonce');
|
|
4
|
+
/**
|
|
5
|
+
* Determine the next nonce to be used for a transaction.
|
|
6
|
+
*
|
|
7
|
+
* @param txMeta - The transaction metadata.
|
|
8
|
+
* @param getNonceLock - An anonymous function that acquires the nonce lock for an address
|
|
9
|
+
* @returns The next hexadecimal nonce to be used for the given transaction, and optionally a function to release the nonce lock.
|
|
10
|
+
*/
|
|
11
|
+
export async function getNextNonce(txMeta, getNonceLock) {
|
|
12
|
+
const { customNonceValue, txParams: { from, nonce: existingNonce }, } = txMeta;
|
|
13
|
+
const customNonce = customNonceValue ? toHex(customNonceValue) : undefined;
|
|
14
|
+
if (customNonce) {
|
|
15
|
+
log('Using custom nonce', customNonce);
|
|
16
|
+
return [customNonce, undefined];
|
|
17
|
+
}
|
|
18
|
+
if (existingNonce) {
|
|
19
|
+
log('Using existing nonce', existingNonce);
|
|
20
|
+
return [existingNonce, undefined];
|
|
21
|
+
}
|
|
22
|
+
const nonceLock = await getNonceLock(from);
|
|
23
|
+
const nonce = toHex(nonceLock.nextNonce);
|
|
24
|
+
const releaseLock = nonceLock.releaseLock.bind(nonceLock);
|
|
25
|
+
log('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails);
|
|
26
|
+
return [nonce, releaseLock];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Filter and format transactions for the nonce tracker.
|
|
30
|
+
*
|
|
31
|
+
* @param currentChainId - Chain ID of the current network.
|
|
32
|
+
* @param fromAddress - Address of the account from which the transactions to filter from are sent.
|
|
33
|
+
* @param transactionStatus - Status of the transactions for which to filter.
|
|
34
|
+
* @param transactions - Array of transactionMeta objects that have been prefiltered.
|
|
35
|
+
* @returns Array of transactions formatted for the nonce tracker.
|
|
36
|
+
*/
|
|
37
|
+
export function getAndFormatTransactionsForNonceTracker(currentChainId, fromAddress, transactionStatus, transactions) {
|
|
38
|
+
return transactions
|
|
39
|
+
.filter(({ chainId, isTransfer, isUserOperation, status, txParams: { from } }) => !isTransfer &&
|
|
40
|
+
!isUserOperation &&
|
|
41
|
+
chainId === currentChainId &&
|
|
42
|
+
status === transactionStatus &&
|
|
43
|
+
from.toLowerCase() === fromAddress.toLowerCase())
|
|
44
|
+
.map(({ status, txParams: { from, gas, value, nonce } }) => {
|
|
45
|
+
// the only value we care about is the nonce
|
|
46
|
+
// but we need to return the other values to satisfy the type
|
|
47
|
+
// TODO: refactor nonceTracker to not require this
|
|
48
|
+
/* istanbul ignore next */
|
|
49
|
+
return {
|
|
50
|
+
status,
|
|
51
|
+
history: [{}],
|
|
52
|
+
txParams: {
|
|
53
|
+
from: from ?? '',
|
|
54
|
+
gas: gas ?? '',
|
|
55
|
+
value: value ?? '',
|
|
56
|
+
nonce: nonce ?? '',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
11
61
|
//# sourceMappingURL=nonce.mjs.map
|
package/dist/utils/nonce.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"nonce.mjs","sourceRoot":"","sources":["../../src/utils/nonce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,mCAAmC;AAMnD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,sBAAkB;AAG9D,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAuB,EACvB,YAAqD;IAErD,MAAM,EACJ,gBAAgB,EAChB,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GACzC,GAAG,MAAM,CAAC;IAEX,MAAM,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3E,IAAI,WAAW,EAAE;QACf,GAAG,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;QACvC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;KACjC;IAED,IAAI,aAAa,EAAE;QACjB,GAAG,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;QAC3C,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;KACnC;IAED,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE1D,GAAG,CAAC,gCAAgC,EAAE,KAAK,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;IAErE,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,uCAAuC,CACrD,cAAsB,EACtB,WAAmB,EACnB,iBAAoC,EACpC,YAA+B;IAE/B,OAAO,YAAY;SAChB,MAAM,CACL,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CACvE,CAAC,UAAU;QACX,CAAC,eAAe;QAChB,OAAO,KAAK,cAAc;QAC1B,MAAM,KAAK,iBAAiB;QAC5B,IAAI,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CACnD;SACA,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QACzD,4CAA4C;QAC5C,6DAA6D;QAC7D,kDAAkD;QAClD,0BAA0B;QAC1B,OAAO;YACL,MAAM;YACN,OAAO,EAAE,CAAC,EAAE,CAAC;YACb,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI,IAAI,EAAE;gBAChB,GAAG,EAAE,GAAG,IAAI,EAAE;gBACd,KAAK,EAAE,KAAK,IAAI,EAAE;gBAClB,KAAK,EAAE,KAAK,IAAI,EAAE;aACnB;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC","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"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTransactionParamsWithIncreasedGasFee = void 0;
|
|
4
|
+
const controller_utils_1 = require("@metamask/controller-utils");
|
|
5
|
+
const utils_1 = require("@metamask/utils");
|
|
6
|
+
/**
|
|
7
|
+
* Returns new transaction parameters with increased gas fees.
|
|
8
|
+
* @param originalTransactionParams - The original transaction parameters.
|
|
9
|
+
* @param rate - The rate by which to increase the existing gas fee properties.
|
|
10
|
+
* @param newGasValues - Optional new gas values to use instead of increased the existing values.
|
|
11
|
+
* @returns The new transaction parameters with the increased gas fee properties.
|
|
12
|
+
*/
|
|
13
|
+
function getTransactionParamsWithIncreasedGasFee(originalTransactionParams, rate, newGasValues) {
|
|
14
|
+
const newGasPrice = getIncreasedGasPrice(originalTransactionParams, rate, newGasValues);
|
|
15
|
+
const new1559Values = getIncreased1559Values(originalTransactionParams, rate, newGasValues);
|
|
16
|
+
if (new1559Values) {
|
|
17
|
+
const newTxParams = {
|
|
18
|
+
...originalTransactionParams,
|
|
19
|
+
...new1559Values,
|
|
20
|
+
};
|
|
21
|
+
delete newTxParams.gasPrice;
|
|
22
|
+
return newTxParams;
|
|
23
|
+
}
|
|
24
|
+
if (newGasPrice) {
|
|
25
|
+
const newTxParams = {
|
|
26
|
+
...originalTransactionParams,
|
|
27
|
+
gasPrice: newGasPrice,
|
|
28
|
+
};
|
|
29
|
+
delete newTxParams.maxFeePerGas;
|
|
30
|
+
delete newTxParams.maxPriorityFeePerGas;
|
|
31
|
+
return newTxParams;
|
|
32
|
+
}
|
|
33
|
+
throw new Error('Cannot increase gas fee as no current values and no new values were provided');
|
|
34
|
+
}
|
|
35
|
+
exports.getTransactionParamsWithIncreasedGasFee = getTransactionParamsWithIncreasedGasFee;
|
|
36
|
+
/**
|
|
37
|
+
* Generate the increased EIP-1559 gas properties.
|
|
38
|
+
* @param originalTransactionParams - The original transaction parameters.
|
|
39
|
+
* @param rate - The rate by which to increase the existing gas fee properties.
|
|
40
|
+
* @param newGasValues - Optional new gas values to use instead of increased the existing values.
|
|
41
|
+
* @returns The new EIP-1559 gas properties.
|
|
42
|
+
*/
|
|
43
|
+
function getIncreased1559Values(originalTransactionParams, rate, newGasValues) {
|
|
44
|
+
if (newGasValues &&
|
|
45
|
+
'maxFeePerGas' in newGasValues &&
|
|
46
|
+
'maxPriorityFeePerGas' in newGasValues) {
|
|
47
|
+
return newGasValues;
|
|
48
|
+
}
|
|
49
|
+
const currentMaxFeePerGas = originalTransactionParams.maxFeePerGas;
|
|
50
|
+
const currentMaxPriorityFeePerGas = originalTransactionParams.maxPriorityFeePerGas;
|
|
51
|
+
if (!currentMaxFeePerGas ||
|
|
52
|
+
!currentMaxPriorityFeePerGas ||
|
|
53
|
+
currentMaxFeePerGas === '0x0' ||
|
|
54
|
+
currentMaxPriorityFeePerGas === '0x0') {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const maxFeePerGas = multiplyHex(currentMaxFeePerGas, rate);
|
|
58
|
+
const maxPriorityFeePerGas = multiplyHex(currentMaxPriorityFeePerGas, rate);
|
|
59
|
+
return { maxFeePerGas, maxPriorityFeePerGas };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Generate the increased gas price.
|
|
63
|
+
* @param originalTransactionParams - The original transaction parameters.
|
|
64
|
+
* @param rate - The rate by which to increase the existing gas fee properties.
|
|
65
|
+
* @param newGasValues - Optional new gas values to use instead of increased the existing values.
|
|
66
|
+
* @returns The new gas price.
|
|
67
|
+
*/
|
|
68
|
+
function getIncreasedGasPrice(originalTransactionParams, rate, newGasValues) {
|
|
69
|
+
if (newGasValues && 'gasPrice' in newGasValues) {
|
|
70
|
+
return newGasValues.gasPrice;
|
|
71
|
+
}
|
|
72
|
+
const currentGasPrice = originalTransactionParams.gasPrice;
|
|
73
|
+
if (!currentGasPrice || currentGasPrice === '0x0') {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return multiplyHex(currentGasPrice, rate);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Multiply a hex value by a multiplier.
|
|
80
|
+
* @param value - The hex value to multiply.
|
|
81
|
+
* @param multiplier - The multiplier.
|
|
82
|
+
* @returns The multiplied hex value.
|
|
83
|
+
*/
|
|
84
|
+
function multiplyHex(value, multiplier) {
|
|
85
|
+
const decimalValue = (0, controller_utils_1.convertHexToDecimal)(value);
|
|
86
|
+
const decimalResult = parseInt(`${decimalValue * multiplier}`, 10);
|
|
87
|
+
return (0, utils_1.add0x)(decimalResult.toString(16));
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=retry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.cjs","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":";;;AAAA,iEAAiE;AAEjE,2CAAwC;AAKxC;;;;;;GAMG;AACH,SAAgB,uCAAuC,CACrD,yBAA4C,EAC5C,IAAY,EACZ,YAAqD;IAErD,MAAM,WAAW,GAAG,oBAAoB,CACtC,yBAAyB,EACzB,IAAI,EACJ,YAAY,CACb,CAAC;IAEF,MAAM,aAAa,GAAG,sBAAsB,CAC1C,yBAAyB,EACzB,IAAI,EACJ,YAAY,CACb,CAAC;IAEF,IAAI,aAAa,EAAE;QACjB,MAAM,WAAW,GAAsB;YACrC,GAAG,yBAAyB;YAC5B,GAAG,aAAa;SACjB,CAAC;QAEF,OAAO,WAAW,CAAC,QAAQ,CAAC;QAE5B,OAAO,WAAW,CAAC;KACpB;IAED,IAAI,WAAW,EAAE;QACf,MAAM,WAAW,GAAsB;YACrC,GAAG,yBAAyB;YAC5B,QAAQ,EAAE,WAAW;SACtB,CAAC;QAEF,OAAO,WAAW,CAAC,YAAY,CAAC;QAChC,OAAO,WAAW,CAAC,oBAAoB,CAAC;QAExC,OAAO,WAAW,CAAC;KACpB;IAED,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;AACJ,CAAC;AA3CD,0FA2CC;AAED;;;;;;GAMG;AACH,SAAS,sBAAsB,CAC7B,yBAA4C,EAC5C,IAAY,EACZ,YAAqD;IAErD,IACE,YAAY;QACZ,cAAc,IAAI,YAAY;QAC9B,sBAAsB,IAAI,YAAY,EACtC;QACA,OAAO,YAAY,CAAC;KACrB;IAED,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,YAEzC,CAAC;IAEd,MAAM,2BAA2B,GAC/B,yBAAyB,CAAC,oBAAuC,CAAC;IAEpE,IACE,CAAC,mBAAmB;QACpB,CAAC,2BAA2B;QAC5B,mBAAmB,KAAK,KAAK;QAC7B,2BAA2B,KAAK,KAAK,EACrC;QACA,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,YAAY,GAAG,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;IAC5D,MAAM,oBAAoB,GAAG,WAAW,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;IAE5E,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAChD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,oBAAoB,CAC3B,yBAA4C,EAC5C,IAAY,EACZ,YAAqD;IAErD,IAAI,YAAY,IAAI,UAAU,IAAI,YAAY,EAAE;QAC9C,OAAO,YAAY,CAAC,QAAe,CAAC;KACrC;IAED,MAAM,eAAe,GAAG,yBAAyB,CAAC,QAA2B,CAAC;IAE9E,IAAI,CAAC,eAAe,IAAI,eAAe,KAAK,KAAK,EAAE;QACjD,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,WAAW,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,KAAsB,EAAE,UAAkB;IAC7D,MAAM,YAAY,GAAG,IAAA,sCAAmB,EAAC,KAAK,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,QAAQ,CAAC,GAAG,YAAY,GAAG,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;IAEnE,OAAO,IAAA,aAAK,EAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC","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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FeeMarketEIP1559Values, GasPriceValue } from
|
|
2
|
-
import { type TransactionParams } from
|
|
1
|
+
import type { FeeMarketEIP1559Values, GasPriceValue } from "../types.cjs";
|
|
2
|
+
import { type TransactionParams } from "../types.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Returns new transaction parameters with increased gas fees.
|
|
5
5
|
* @param originalTransactionParams - The original transaction parameters.
|
|
@@ -8,4 +8,4 @@ import { type TransactionParams } from '../types';
|
|
|
8
8
|
* @returns The new transaction parameters with the increased gas fee properties.
|
|
9
9
|
*/
|
|
10
10
|
export declare function getTransactionParamsWithIncreasedGasFee(originalTransactionParams: TransactionParams, rate: number, newGasValues?: GasPriceValue | FeeMarketEIP1559Values): TransactionParams;
|
|
11
|
-
//# sourceMappingURL=retry.d.
|
|
11
|
+
//# sourceMappingURL=retry.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.cts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,qBAAiB;AACtE,OAAO,EAAE,KAAK,iBAAiB,EAAE,qBAAiB;AAElD;;;;;;GAMG;AACH,wBAAgB,uCAAuC,CACrD,yBAAyB,EAAE,iBAAiB,EAC5C,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,aAAa,GAAG,sBAAsB,GACpD,iBAAiB,CAuCnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FeeMarketEIP1559Values, GasPriceValue } from "../types.mjs";
|
|
2
|
+
import { type TransactionParams } from "../types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Returns new transaction parameters with increased gas fees.
|
|
5
|
+
* @param originalTransactionParams - The original transaction parameters.
|
|
6
|
+
* @param rate - The rate by which to increase the existing gas fee properties.
|
|
7
|
+
* @param newGasValues - Optional new gas values to use instead of increased the existing values.
|
|
8
|
+
* @returns The new transaction parameters with the increased gas fee properties.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTransactionParamsWithIncreasedGasFee(originalTransactionParams: TransactionParams, rate: number, newGasValues?: GasPriceValue | FeeMarketEIP1559Values): TransactionParams;
|
|
11
|
+
//# sourceMappingURL=retry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.mts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,qBAAiB;AACtE,OAAO,EAAE,KAAK,iBAAiB,EAAE,qBAAiB;AAElD;;;;;;GAMG;AACH,wBAAgB,uCAAuC,CACrD,yBAAyB,EAAE,iBAAiB,EAC5C,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,aAAa,GAAG,sBAAsB,GACpD,iBAAiB,CAuCnB"}
|