@metamask/transaction-controller 36.1.0 → 37.1.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 +47 -1
- package/dist/TransactionController.cjs +2071 -0
- package/dist/TransactionController.cjs.map +1 -0
- package/dist/{types/TransactionController.d.ts → TransactionController.d.cts} +19 -26
- package/dist/TransactionController.d.cts.map +1 -0
- package/dist/TransactionController.d.mts +828 -0
- package/dist/TransactionController.d.mts.map +1 -0
- package/dist/TransactionController.mjs +2072 -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 +327 -0
- package/dist/helpers/PendingTransactionTracker.cjs.map +1 -0
- package/dist/{types/helpers/PendingTransactionTracker.d.ts → helpers/PendingTransactionTracker.d.cts} +7 -8
- 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 +319 -8
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -1
- package/dist/index.cjs +32 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{types/index.d.ts → index.d.cts} +11 -10
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +7 -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} +35 -35
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +1027 -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 +20 -15
- 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
package/dist/chunk-AWIJZAW3.mjs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
gweiDecimalToWeiHex
|
|
3
|
-
} from "./chunk-SFFOC25Q.mjs";
|
|
4
|
-
import {
|
|
5
|
-
projectLogger
|
|
6
|
-
} from "./chunk-UQQWZT6C.mjs";
|
|
7
|
-
import {
|
|
8
|
-
GasFeeEstimateLevel
|
|
9
|
-
} from "./chunk-LFFYCDHB.mjs";
|
|
10
|
-
import {
|
|
11
|
-
__privateAdd,
|
|
12
|
-
__privateMethod
|
|
13
|
-
} from "./chunk-XUI43LEZ.mjs";
|
|
14
|
-
|
|
15
|
-
// src/gas-flows/DefaultGasFeeFlow.ts
|
|
16
|
-
import { GAS_ESTIMATE_TYPES } from "@metamask/gas-fee-controller";
|
|
17
|
-
import { createModuleLogger } from "@metamask/utils";
|
|
18
|
-
var log = createModuleLogger(projectLogger, "default-gas-fee-flow");
|
|
19
|
-
var _getFeeMarkEstimates, getFeeMarkEstimates_fn, _getLegacyEstimates, getLegacyEstimates_fn, _getGasPriceEstimates, getGasPriceEstimates_fn, _getFeeMarketLevel, getFeeMarketLevel_fn, _getLegacyLevel, getLegacyLevel_fn;
|
|
20
|
-
var DefaultGasFeeFlow = class {
|
|
21
|
-
constructor() {
|
|
22
|
-
__privateAdd(this, _getFeeMarkEstimates);
|
|
23
|
-
__privateAdd(this, _getLegacyEstimates);
|
|
24
|
-
__privateAdd(this, _getGasPriceEstimates);
|
|
25
|
-
__privateAdd(this, _getFeeMarketLevel);
|
|
26
|
-
__privateAdd(this, _getLegacyLevel);
|
|
27
|
-
}
|
|
28
|
-
matchesTransaction(_transactionMeta) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
async getGasFees(request) {
|
|
32
|
-
const { gasFeeControllerData } = request;
|
|
33
|
-
const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;
|
|
34
|
-
let response;
|
|
35
|
-
switch (gasEstimateType) {
|
|
36
|
-
case GAS_ESTIMATE_TYPES.FEE_MARKET:
|
|
37
|
-
log("Using fee market estimates", gasFeeEstimates);
|
|
38
|
-
response = __privateMethod(this, _getFeeMarkEstimates, getFeeMarkEstimates_fn).call(this, gasFeeEstimates);
|
|
39
|
-
break;
|
|
40
|
-
case GAS_ESTIMATE_TYPES.LEGACY:
|
|
41
|
-
log("Using legacy estimates", gasFeeEstimates);
|
|
42
|
-
response = __privateMethod(this, _getLegacyEstimates, getLegacyEstimates_fn).call(this, gasFeeEstimates);
|
|
43
|
-
break;
|
|
44
|
-
case GAS_ESTIMATE_TYPES.ETH_GASPRICE:
|
|
45
|
-
log("Using eth_gasPrice estimates", gasFeeEstimates);
|
|
46
|
-
response = __privateMethod(this, _getGasPriceEstimates, getGasPriceEstimates_fn).call(this, gasFeeEstimates);
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
estimates: response
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
_getFeeMarkEstimates = new WeakSet();
|
|
57
|
-
getFeeMarkEstimates_fn = function(gasFeeEstimates) {
|
|
58
|
-
const levels = Object.values(GasFeeEstimateLevel).reduce(
|
|
59
|
-
(result, level) => ({
|
|
60
|
-
...result,
|
|
61
|
-
[level]: __privateMethod(this, _getFeeMarketLevel, getFeeMarketLevel_fn).call(this, gasFeeEstimates, level)
|
|
62
|
-
}),
|
|
63
|
-
{}
|
|
64
|
-
);
|
|
65
|
-
return {
|
|
66
|
-
type: "fee-market" /* FeeMarket */,
|
|
67
|
-
...levels
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
_getLegacyEstimates = new WeakSet();
|
|
71
|
-
getLegacyEstimates_fn = function(gasFeeEstimates) {
|
|
72
|
-
const levels = Object.values(GasFeeEstimateLevel).reduce(
|
|
73
|
-
(result, level) => ({
|
|
74
|
-
...result,
|
|
75
|
-
[level]: __privateMethod(this, _getLegacyLevel, getLegacyLevel_fn).call(this, gasFeeEstimates, level)
|
|
76
|
-
}),
|
|
77
|
-
{}
|
|
78
|
-
);
|
|
79
|
-
return {
|
|
80
|
-
type: "legacy" /* Legacy */,
|
|
81
|
-
...levels
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
_getGasPriceEstimates = new WeakSet();
|
|
85
|
-
getGasPriceEstimates_fn = function(gasFeeEstimates) {
|
|
86
|
-
return {
|
|
87
|
-
type: "eth_gasPrice" /* GasPrice */,
|
|
88
|
-
gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice)
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
_getFeeMarketLevel = new WeakSet();
|
|
92
|
-
getFeeMarketLevel_fn = function(gasFeeEstimates, level) {
|
|
93
|
-
const maxFeePerGas = gweiDecimalToWeiHex(
|
|
94
|
-
gasFeeEstimates[level].suggestedMaxFeePerGas
|
|
95
|
-
);
|
|
96
|
-
const maxPriorityFeePerGas = gweiDecimalToWeiHex(
|
|
97
|
-
gasFeeEstimates[level].suggestedMaxPriorityFeePerGas
|
|
98
|
-
);
|
|
99
|
-
return {
|
|
100
|
-
maxFeePerGas,
|
|
101
|
-
maxPriorityFeePerGas
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
_getLegacyLevel = new WeakSet();
|
|
105
|
-
getLegacyLevel_fn = function(gasFeeEstimates, level) {
|
|
106
|
-
return gweiDecimalToWeiHex(gasFeeEstimates[level]);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export {
|
|
110
|
-
DefaultGasFeeFlow
|
|
111
|
-
};
|
|
112
|
-
//# sourceMappingURL=chunk-AWIJZAW3.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/gas-flows/DefaultGasFeeFlow.ts"],"sourcesContent":["import type {\n LegacyGasPriceEstimate,\n GasFeeEstimates as FeeMarketGasPriceEstimate,\n EthGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n GasPriceGasFeeEstimates,\n LegacyGasFeeEstimates,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\nimport { gweiDecimalToWeiHex } from '../utils/gas-fees';\n\nconst log = createModuleLogger(projectLogger, 'default-gas-fee-flow');\n\n/**\n * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.\n */\nexport class DefaultGasFeeFlow implements GasFeeFlow {\n matchesTransaction(_transactionMeta: TransactionMeta): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n const { gasFeeControllerData } = request;\n const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;\n\n let response: GasFeeEstimates;\n\n switch (gasEstimateType) {\n case GAS_ESTIMATE_TYPES.FEE_MARKET:\n log('Using fee market estimates', gasFeeEstimates);\n response = this.#getFeeMarkEstimates(gasFeeEstimates);\n break;\n case GAS_ESTIMATE_TYPES.LEGACY:\n log('Using legacy estimates', gasFeeEstimates);\n response = this.#getLegacyEstimates(\n gasFeeEstimates as LegacyGasPriceEstimate,\n );\n break;\n case GAS_ESTIMATE_TYPES.ETH_GASPRICE:\n log('Using eth_gasPrice estimates', gasFeeEstimates);\n response = this.#getGasPriceEstimates(\n gasFeeEstimates as EthGasPriceEstimate,\n );\n break;\n default:\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);\n }\n\n return {\n estimates: response,\n };\n }\n\n #getFeeMarkEstimates(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n ): FeeMarketGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getFeeMarketLevel(gasFeeEstimates, level),\n }),\n {} as Omit<FeeMarketGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.FeeMarket,\n ...levels,\n };\n }\n\n #getLegacyEstimates(\n gasFeeEstimates: LegacyGasPriceEstimate,\n ): LegacyGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getLegacyLevel(gasFeeEstimates, level),\n }),\n {} as Omit<LegacyGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.Legacy,\n ...levels,\n };\n }\n\n #getGasPriceEstimates(\n gasFeeEstimates: EthGasPriceEstimate,\n ): GasPriceGasFeeEstimates {\n return {\n type: GasFeeEstimateType.GasPrice,\n gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice),\n };\n }\n\n #getFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): FeeMarketGasFeeEstimateForLevel {\n const maxFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n );\n\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n }\n\n #getLegacyLevel(\n gasFeeEstimates: LegacyGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): Hex {\n return gweiDecimalToWeiHex(gasFeeEstimates[level]);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAKA,SAAS,0BAA0B;AAEnC,SAAS,0BAA0B;AAiBnC,IAAM,MAAM,mBAAmB,eAAe,sBAAsB;AAxBpE;AA6BO,IAAM,oBAAN,MAA8C;AAAA,EAA9C;AAuCL;AAiBA;AAiBA;AASA;AAkBA;AAAA;AAAA,EAnGA,mBAAmB,kBAA4C;AAC7D,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,SAAyD;AACxE,UAAM,EAAE,qBAAqB,IAAI;AACjC,UAAM,EAAE,iBAAiB,gBAAgB,IAAI;AAE7C,QAAI;AAEJ,YAAQ,iBAAiB;AAAA,MACvB,KAAK,mBAAmB;AACtB,YAAI,8BAA8B,eAAe;AACjD,mBAAW,sBAAK,8CAAL,WAA0B;AACrC;AAAA,MACF,KAAK,mBAAmB;AACtB,YAAI,0BAA0B,eAAe;AAC7C,mBAAW,sBAAK,4CAAL,WACT;AAEF;AAAA,MACF,KAAK,mBAAmB;AACtB,YAAI,gCAAgC,eAAe;AACnD,mBAAW,sBAAK,gDAAL,WACT;AAEF;AAAA,MACF;AAGE,cAAM,IAAI,MAAM,kCAAkC,eAAe,EAAE;AAAA,IACvE;AAEA,WAAO;AAAA,MACL,WAAW;AAAA,IACb;AAAA,EACF;AAqEF;AAnEE;AAAA,yBAAoB,SAClB,iBAC0B;AAC1B,QAAM,SAAS,OAAO,OAAO,mBAAmB,EAAE;AAAA,IAChD,CAAC,QAAQ,WAAW;AAAA,MAClB,GAAG;AAAA,MACH,CAAC,KAAK,GAAG,sBAAK,0CAAL,WAAwB,iBAAiB;AAAA,IACpD;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA,GAAG;AAAA,EACL;AACF;AAEA;AAAA,wBAAmB,SACjB,iBACuB;AACvB,QAAM,SAAS,OAAO,OAAO,mBAAmB,EAAE;AAAA,IAChD,CAAC,QAAQ,WAAW;AAAA,MAClB,GAAG;AAAA,MACH,CAAC,KAAK,GAAG,sBAAK,oCAAL,WAAqB,iBAAiB;AAAA,IACjD;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA,GAAG;AAAA,EACL;AACF;AAEA;AAAA,0BAAqB,SACnB,iBACyB;AACzB,SAAO;AAAA,IACL;AAAA,IACA,UAAU,oBAAoB,gBAAgB,QAAQ;AAAA,EACxD;AACF;AAEA;AAAA,uBAAkB,SAChB,iBACA,OACiC;AACjC,QAAM,eAAe;AAAA,IACnB,gBAAgB,KAAK,EAAE;AAAA,EACzB;AAEA,QAAM,uBAAuB;AAAA,IAC3B,gBAAgB,KAAK,EAAE;AAAA,EACzB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEA;AAAA,oBAAe,SACb,iBACA,OACK;AACL,SAAO,oBAAoB,gBAAgB,KAAK,CAAC;AACnD;","names":[]}
|
package/dist/chunk-BZV72SCF.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkQKV7E5BOjs = require('./chunk-QKV7E5BO.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkYWLMT7XHjs = require('./chunk-YWLMT7XH.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
10
|
-
|
|
11
|
-
// src/utils/gas-fees.ts
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _controllerutils = require('@metamask/controller-utils');
|
|
18
|
-
var _utils = require('@metamask/utils');
|
|
19
|
-
var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger, "gas-fees");
|
|
20
|
-
async function updateGasFees(request) {
|
|
21
|
-
const { txMeta } = request;
|
|
22
|
-
const initialParams = { ...txMeta.txParams };
|
|
23
|
-
const isSwap = _chunkQKV7E5BOjs.SWAP_TRANSACTION_TYPES.includes(
|
|
24
|
-
txMeta.type
|
|
25
|
-
);
|
|
26
|
-
const savedGasFees = isSwap ? void 0 : request.getSavedGasFees(txMeta.chainId);
|
|
27
|
-
const suggestedGasFees = await getSuggestedGasFees(request);
|
|
28
|
-
log("Suggested gas fees", suggestedGasFees);
|
|
29
|
-
const getGasFeeRequest = {
|
|
30
|
-
...request,
|
|
31
|
-
initialParams,
|
|
32
|
-
savedGasFees,
|
|
33
|
-
suggestedGasFees
|
|
34
|
-
};
|
|
35
|
-
txMeta.txParams.maxFeePerGas = getMaxFeePerGas(getGasFeeRequest);
|
|
36
|
-
txMeta.txParams.maxPriorityFeePerGas = getMaxPriorityFeePerGas(getGasFeeRequest);
|
|
37
|
-
txMeta.txParams.gasPrice = getGasPrice(getGasFeeRequest);
|
|
38
|
-
txMeta.userFeeLevel = getUserFeeLevel(getGasFeeRequest);
|
|
39
|
-
log("Updated gas fee properties", {
|
|
40
|
-
maxFeePerGas: txMeta.txParams.maxFeePerGas,
|
|
41
|
-
maxPriorityFeePerGas: txMeta.txParams.maxPriorityFeePerGas,
|
|
42
|
-
gasPrice: txMeta.txParams.gasPrice
|
|
43
|
-
});
|
|
44
|
-
if (txMeta.txParams.maxFeePerGas || txMeta.txParams.maxPriorityFeePerGas) {
|
|
45
|
-
delete txMeta.txParams.gasPrice;
|
|
46
|
-
}
|
|
47
|
-
if (txMeta.txParams.gasPrice) {
|
|
48
|
-
delete txMeta.txParams.maxFeePerGas;
|
|
49
|
-
delete txMeta.txParams.maxPriorityFeePerGas;
|
|
50
|
-
}
|
|
51
|
-
updateDefaultGasEstimates(txMeta);
|
|
52
|
-
}
|
|
53
|
-
function gweiDecimalToWeiHex(value) {
|
|
54
|
-
return _controllerutils.toHex.call(void 0, _controllerutils.gweiDecToWEIBN.call(void 0, value));
|
|
55
|
-
}
|
|
56
|
-
function getMaxFeePerGas(request) {
|
|
57
|
-
const { savedGasFees, eip1559, initialParams, suggestedGasFees } = request;
|
|
58
|
-
if (!eip1559) {
|
|
59
|
-
return void 0;
|
|
60
|
-
}
|
|
61
|
-
if (savedGasFees) {
|
|
62
|
-
const maxFeePerGas = gweiDecimalToWeiHex(savedGasFees.maxBaseFee);
|
|
63
|
-
log("Using maxFeePerGas from savedGasFees", maxFeePerGas);
|
|
64
|
-
return maxFeePerGas;
|
|
65
|
-
}
|
|
66
|
-
if (initialParams.maxFeePerGas) {
|
|
67
|
-
log("Using maxFeePerGas from request", initialParams.maxFeePerGas);
|
|
68
|
-
return initialParams.maxFeePerGas;
|
|
69
|
-
}
|
|
70
|
-
if (initialParams.gasPrice && !initialParams.maxPriorityFeePerGas) {
|
|
71
|
-
log(
|
|
72
|
-
"Setting maxFeePerGas to gasPrice from request",
|
|
73
|
-
initialParams.gasPrice
|
|
74
|
-
);
|
|
75
|
-
return initialParams.gasPrice;
|
|
76
|
-
}
|
|
77
|
-
if (suggestedGasFees.maxFeePerGas) {
|
|
78
|
-
log("Using suggested maxFeePerGas", suggestedGasFees.maxFeePerGas);
|
|
79
|
-
return suggestedGasFees.maxFeePerGas;
|
|
80
|
-
}
|
|
81
|
-
if (suggestedGasFees.gasPrice) {
|
|
82
|
-
log(
|
|
83
|
-
"Setting maxFeePerGas to suggested gasPrice",
|
|
84
|
-
suggestedGasFees.gasPrice
|
|
85
|
-
);
|
|
86
|
-
return suggestedGasFees.gasPrice;
|
|
87
|
-
}
|
|
88
|
-
log("maxFeePerGas not set");
|
|
89
|
-
return void 0;
|
|
90
|
-
}
|
|
91
|
-
function getMaxPriorityFeePerGas(request) {
|
|
92
|
-
const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } = request;
|
|
93
|
-
if (!eip1559) {
|
|
94
|
-
return void 0;
|
|
95
|
-
}
|
|
96
|
-
if (savedGasFees) {
|
|
97
|
-
const maxPriorityFeePerGas = gweiDecimalToWeiHex(savedGasFees.priorityFee);
|
|
98
|
-
log(
|
|
99
|
-
"Using maxPriorityFeePerGas from savedGasFees.priorityFee",
|
|
100
|
-
maxPriorityFeePerGas
|
|
101
|
-
);
|
|
102
|
-
return maxPriorityFeePerGas;
|
|
103
|
-
}
|
|
104
|
-
if (initialParams.maxPriorityFeePerGas) {
|
|
105
|
-
log(
|
|
106
|
-
"Using maxPriorityFeePerGas from request",
|
|
107
|
-
initialParams.maxPriorityFeePerGas
|
|
108
|
-
);
|
|
109
|
-
return initialParams.maxPriorityFeePerGas;
|
|
110
|
-
}
|
|
111
|
-
if (initialParams.gasPrice && !initialParams.maxFeePerGas) {
|
|
112
|
-
log(
|
|
113
|
-
"Setting maxPriorityFeePerGas to gasPrice from request",
|
|
114
|
-
initialParams.gasPrice
|
|
115
|
-
);
|
|
116
|
-
return initialParams.gasPrice;
|
|
117
|
-
}
|
|
118
|
-
if (suggestedGasFees.maxPriorityFeePerGas) {
|
|
119
|
-
log(
|
|
120
|
-
"Using suggested maxPriorityFeePerGas",
|
|
121
|
-
suggestedGasFees.maxPriorityFeePerGas
|
|
122
|
-
);
|
|
123
|
-
return suggestedGasFees.maxPriorityFeePerGas;
|
|
124
|
-
}
|
|
125
|
-
if (txMeta.txParams.maxFeePerGas) {
|
|
126
|
-
log(
|
|
127
|
-
"Setting maxPriorityFeePerGas to maxFeePerGas",
|
|
128
|
-
txMeta.txParams.maxFeePerGas
|
|
129
|
-
);
|
|
130
|
-
return txMeta.txParams.maxFeePerGas;
|
|
131
|
-
}
|
|
132
|
-
log("maxPriorityFeePerGas not set");
|
|
133
|
-
return void 0;
|
|
134
|
-
}
|
|
135
|
-
function getGasPrice(request) {
|
|
136
|
-
const { eip1559, initialParams, suggestedGasFees } = request;
|
|
137
|
-
if (eip1559) {
|
|
138
|
-
return void 0;
|
|
139
|
-
}
|
|
140
|
-
if (initialParams.gasPrice) {
|
|
141
|
-
log("Using gasPrice from request", initialParams.gasPrice);
|
|
142
|
-
return initialParams.gasPrice;
|
|
143
|
-
}
|
|
144
|
-
if (suggestedGasFees.maxFeePerGas) {
|
|
145
|
-
log("Using suggested maxFeePerGas", suggestedGasFees.maxFeePerGas);
|
|
146
|
-
return suggestedGasFees.maxFeePerGas;
|
|
147
|
-
}
|
|
148
|
-
if (suggestedGasFees.gasPrice) {
|
|
149
|
-
log("Using suggested gasPrice", suggestedGasFees.gasPrice);
|
|
150
|
-
return suggestedGasFees.gasPrice;
|
|
151
|
-
}
|
|
152
|
-
log("gasPrice not set");
|
|
153
|
-
return void 0;
|
|
154
|
-
}
|
|
155
|
-
function getUserFeeLevel(request) {
|
|
156
|
-
const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } = request;
|
|
157
|
-
if (!eip1559) {
|
|
158
|
-
return void 0;
|
|
159
|
-
}
|
|
160
|
-
if (savedGasFees) {
|
|
161
|
-
return "custom" /* CUSTOM */;
|
|
162
|
-
}
|
|
163
|
-
if (!initialParams.maxFeePerGas && !initialParams.maxPriorityFeePerGas && initialParams.gasPrice) {
|
|
164
|
-
return txMeta.origin === _controllerutils.ORIGIN_METAMASK ? "custom" /* CUSTOM */ : "dappSuggested" /* DAPP_SUGGESTED */;
|
|
165
|
-
}
|
|
166
|
-
if (!initialParams.maxFeePerGas && !initialParams.maxPriorityFeePerGas && suggestedGasFees.maxFeePerGas && suggestedGasFees.maxPriorityFeePerGas) {
|
|
167
|
-
return "medium" /* MEDIUM */;
|
|
168
|
-
}
|
|
169
|
-
if (txMeta.origin === _controllerutils.ORIGIN_METAMASK) {
|
|
170
|
-
return "medium" /* MEDIUM */;
|
|
171
|
-
}
|
|
172
|
-
return "dappSuggested" /* DAPP_SUGGESTED */;
|
|
173
|
-
}
|
|
174
|
-
function updateDefaultGasEstimates(txMeta) {
|
|
175
|
-
if (!txMeta.defaultGasEstimates) {
|
|
176
|
-
txMeta.defaultGasEstimates = {};
|
|
177
|
-
}
|
|
178
|
-
txMeta.defaultGasEstimates.maxFeePerGas = txMeta.txParams.maxFeePerGas;
|
|
179
|
-
txMeta.defaultGasEstimates.maxPriorityFeePerGas = txMeta.txParams.maxPriorityFeePerGas;
|
|
180
|
-
txMeta.defaultGasEstimates.gasPrice = txMeta.txParams.gasPrice;
|
|
181
|
-
txMeta.defaultGasEstimates.estimateType = txMeta.userFeeLevel;
|
|
182
|
-
}
|
|
183
|
-
async function getSuggestedGasFees(request) {
|
|
184
|
-
const { eip1559, ethQuery, gasFeeFlows, getGasFeeEstimates, txMeta } = request;
|
|
185
|
-
const { networkClientId } = txMeta;
|
|
186
|
-
if (!eip1559 && txMeta.txParams.gasPrice || eip1559 && txMeta.txParams.maxFeePerGas && txMeta.txParams.maxPriorityFeePerGas) {
|
|
187
|
-
return {};
|
|
188
|
-
}
|
|
189
|
-
const gasFeeFlow = _chunkYWLMT7XHjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
|
|
190
|
-
try {
|
|
191
|
-
const gasFeeControllerData = await getGasFeeEstimates({ networkClientId });
|
|
192
|
-
const response = await gasFeeFlow.getGasFees({
|
|
193
|
-
ethQuery,
|
|
194
|
-
gasFeeControllerData,
|
|
195
|
-
transactionMeta: txMeta
|
|
196
|
-
});
|
|
197
|
-
const gasFeeEstimateType = response.estimates?.type;
|
|
198
|
-
switch (gasFeeEstimateType) {
|
|
199
|
-
case "fee-market" /* FeeMarket */:
|
|
200
|
-
return response.estimates.medium;
|
|
201
|
-
case "legacy" /* Legacy */:
|
|
202
|
-
return {
|
|
203
|
-
gasPrice: response.estimates.medium
|
|
204
|
-
};
|
|
205
|
-
case "eth_gasPrice" /* GasPrice */:
|
|
206
|
-
return { gasPrice: response.estimates.gasPrice };
|
|
207
|
-
default:
|
|
208
|
-
throw new Error(
|
|
209
|
-
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
|
|
210
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
211
|
-
`Unsupported gas fee estimate type returned from flow: ${gasFeeEstimateType}`
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
} catch (error) {
|
|
215
|
-
log("Failed to get suggested gas fees", error);
|
|
216
|
-
}
|
|
217
|
-
const gasPriceDecimal = await _controllerutils.query.call(void 0, ethQuery, "gasPrice");
|
|
218
|
-
const gasPrice = gasPriceDecimal ? _utils.add0x.call(void 0, gasPriceDecimal.toString(16)) : void 0;
|
|
219
|
-
return { gasPrice };
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
exports.updateGasFees = updateGasFees; exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
|
|
226
|
-
//# sourceMappingURL=chunk-BZV72SCF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/gas-fees.ts"],"names":[],"mappings":"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","sourcesContent":["/* eslint-disable jsdoc/require-jsdoc */\n\nimport {\n ORIGIN_METAMASK,\n gweiDecToWEIBN,\n query,\n toHex,\n} from '@metamask/controller-utils';\nimport type EthQuery from '@metamask/eth-query';\nimport type {\n FetchGasFeeEstimateOptions,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { add0x, createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n SavedGasFees,\n TransactionParams,\n TransactionMeta,\n TransactionType,\n GasFeeFlow,\n} from '../types';\nimport { GasFeeEstimateType, UserFeeLevel } from '../types';\nimport { getGasFeeFlow } from './gas-flow';\nimport { SWAP_TRANSACTION_TYPES } from './swaps';\n\nexport type UpdateGasFeesRequest = {\n eip1559: boolean;\n ethQuery: EthQuery;\n gasFeeFlows: GasFeeFlow[];\n getGasFeeEstimates: (\n options: FetchGasFeeEstimateOptions,\n ) => Promise<GasFeeState>;\n getSavedGasFees: (chainId: Hex) => SavedGasFees | undefined;\n txMeta: TransactionMeta;\n};\n\nexport type GetGasFeeRequest = UpdateGasFeesRequest & {\n initialParams: TransactionParams;\n savedGasFees?: SavedGasFees;\n suggestedGasFees: SuggestedGasFees;\n};\n\ntype SuggestedGasFees = {\n maxFeePerGas?: string;\n maxPriorityFeePerGas?: string;\n gasPrice?: string;\n};\n\nconst log = createModuleLogger(projectLogger, 'gas-fees');\n\nexport async function updateGasFees(request: UpdateGasFeesRequest) {\n const { txMeta } = request;\n const initialParams = { ...txMeta.txParams };\n\n const isSwap = SWAP_TRANSACTION_TYPES.includes(\n txMeta.type as TransactionType,\n );\n const savedGasFees = isSwap\n ? undefined\n : request.getSavedGasFees(txMeta.chainId);\n\n const suggestedGasFees = await getSuggestedGasFees(request);\n\n log('Suggested gas fees', suggestedGasFees);\n\n const getGasFeeRequest: GetGasFeeRequest = {\n ...request,\n initialParams,\n savedGasFees,\n suggestedGasFees,\n };\n\n txMeta.txParams.maxFeePerGas = getMaxFeePerGas(getGasFeeRequest);\n\n txMeta.txParams.maxPriorityFeePerGas =\n getMaxPriorityFeePerGas(getGasFeeRequest);\n\n txMeta.txParams.gasPrice = getGasPrice(getGasFeeRequest);\n txMeta.userFeeLevel = getUserFeeLevel(getGasFeeRequest);\n\n log('Updated gas fee properties', {\n maxFeePerGas: txMeta.txParams.maxFeePerGas,\n maxPriorityFeePerGas: txMeta.txParams.maxPriorityFeePerGas,\n gasPrice: txMeta.txParams.gasPrice,\n });\n\n if (txMeta.txParams.maxFeePerGas || txMeta.txParams.maxPriorityFeePerGas) {\n delete txMeta.txParams.gasPrice;\n }\n\n if (txMeta.txParams.gasPrice) {\n delete txMeta.txParams.maxFeePerGas;\n delete txMeta.txParams.maxPriorityFeePerGas;\n }\n\n updateDefaultGasEstimates(txMeta);\n}\n\nexport function gweiDecimalToWeiHex(value: string) {\n return toHex(gweiDecToWEIBN(value));\n}\n\nfunction getMaxFeePerGas(request: GetGasFeeRequest): string | undefined {\n const { savedGasFees, eip1559, initialParams, suggestedGasFees } = request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n const maxFeePerGas = gweiDecimalToWeiHex(savedGasFees.maxBaseFee as string);\n log('Using maxFeePerGas from savedGasFees', maxFeePerGas);\n return maxFeePerGas;\n }\n\n if (initialParams.maxFeePerGas) {\n log('Using maxFeePerGas from request', initialParams.maxFeePerGas);\n return initialParams.maxFeePerGas;\n }\n\n if (initialParams.gasPrice && !initialParams.maxPriorityFeePerGas) {\n log(\n 'Setting maxFeePerGas to gasPrice from request',\n initialParams.gasPrice,\n );\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxFeePerGas) {\n log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas);\n return suggestedGasFees.maxFeePerGas;\n }\n\n if (suggestedGasFees.gasPrice) {\n log(\n 'Setting maxFeePerGas to suggested gasPrice',\n suggestedGasFees.gasPrice,\n );\n return suggestedGasFees.gasPrice;\n }\n\n log('maxFeePerGas not set');\n return undefined;\n}\n\nfunction getMaxPriorityFeePerGas(\n request: GetGasFeeRequest,\n): string | undefined {\n const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } =\n request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(savedGasFees.priorityFee);\n log(\n 'Using maxPriorityFeePerGas from savedGasFees.priorityFee',\n maxPriorityFeePerGas,\n );\n return maxPriorityFeePerGas;\n }\n\n if (initialParams.maxPriorityFeePerGas) {\n log(\n 'Using maxPriorityFeePerGas from request',\n initialParams.maxPriorityFeePerGas,\n );\n return initialParams.maxPriorityFeePerGas;\n }\n\n if (initialParams.gasPrice && !initialParams.maxFeePerGas) {\n log(\n 'Setting maxPriorityFeePerGas to gasPrice from request',\n initialParams.gasPrice,\n );\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxPriorityFeePerGas) {\n log(\n 'Using suggested maxPriorityFeePerGas',\n suggestedGasFees.maxPriorityFeePerGas,\n );\n return suggestedGasFees.maxPriorityFeePerGas;\n }\n\n if (txMeta.txParams.maxFeePerGas) {\n log(\n 'Setting maxPriorityFeePerGas to maxFeePerGas',\n txMeta.txParams.maxFeePerGas,\n );\n return txMeta.txParams.maxFeePerGas;\n }\n\n log('maxPriorityFeePerGas not set');\n return undefined;\n}\n\nfunction getGasPrice(request: GetGasFeeRequest): string | undefined {\n const { eip1559, initialParams, suggestedGasFees } = request;\n\n if (eip1559) {\n return undefined;\n }\n\n if (initialParams.gasPrice) {\n log('Using gasPrice from request', initialParams.gasPrice);\n return initialParams.gasPrice;\n }\n\n if (suggestedGasFees.maxFeePerGas) {\n log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas);\n return suggestedGasFees.maxFeePerGas;\n }\n\n if (suggestedGasFees.gasPrice) {\n log('Using suggested gasPrice', suggestedGasFees.gasPrice);\n return suggestedGasFees.gasPrice;\n }\n\n log('gasPrice not set');\n return undefined;\n}\n\nfunction getUserFeeLevel(request: GetGasFeeRequest): UserFeeLevel | undefined {\n const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } =\n request;\n\n if (!eip1559) {\n return undefined;\n }\n\n if (savedGasFees) {\n return UserFeeLevel.CUSTOM;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n initialParams.gasPrice\n ) {\n return txMeta.origin === ORIGIN_METAMASK\n ? UserFeeLevel.CUSTOM\n : UserFeeLevel.DAPP_SUGGESTED;\n }\n\n if (\n !initialParams.maxFeePerGas &&\n !initialParams.maxPriorityFeePerGas &&\n suggestedGasFees.maxFeePerGas &&\n suggestedGasFees.maxPriorityFeePerGas\n ) {\n return UserFeeLevel.MEDIUM;\n }\n\n if (txMeta.origin === ORIGIN_METAMASK) {\n return UserFeeLevel.MEDIUM;\n }\n\n return UserFeeLevel.DAPP_SUGGESTED;\n}\n\nfunction updateDefaultGasEstimates(txMeta: TransactionMeta) {\n if (!txMeta.defaultGasEstimates) {\n txMeta.defaultGasEstimates = {};\n }\n\n txMeta.defaultGasEstimates.maxFeePerGas = txMeta.txParams.maxFeePerGas;\n\n txMeta.defaultGasEstimates.maxPriorityFeePerGas =\n txMeta.txParams.maxPriorityFeePerGas;\n\n txMeta.defaultGasEstimates.gasPrice = txMeta.txParams.gasPrice;\n txMeta.defaultGasEstimates.estimateType = txMeta.userFeeLevel;\n}\n\nasync function getSuggestedGasFees(\n request: UpdateGasFeesRequest,\n): Promise<SuggestedGasFees> {\n const { eip1559, ethQuery, gasFeeFlows, getGasFeeEstimates, txMeta } =\n request;\n\n const { networkClientId } = txMeta;\n\n if (\n (!eip1559 && txMeta.txParams.gasPrice) ||\n (eip1559 &&\n txMeta.txParams.maxFeePerGas &&\n txMeta.txParams.maxPriorityFeePerGas)\n ) {\n return {};\n }\n\n const gasFeeFlow = getGasFeeFlow(txMeta, gasFeeFlows) as GasFeeFlow;\n\n try {\n const gasFeeControllerData = await getGasFeeEstimates({ networkClientId });\n\n const response = await gasFeeFlow.getGasFees({\n ethQuery,\n gasFeeControllerData,\n transactionMeta: txMeta,\n });\n\n const gasFeeEstimateType = response.estimates?.type;\n\n switch (gasFeeEstimateType) {\n case GasFeeEstimateType.FeeMarket:\n return response.estimates.medium;\n case GasFeeEstimateType.Legacy:\n return {\n gasPrice: response.estimates.medium,\n };\n case GasFeeEstimateType.GasPrice:\n return { gasPrice: response.estimates.gasPrice };\n default:\n throw new Error(\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n `Unsupported gas fee estimate type returned from flow: ${gasFeeEstimateType}`,\n );\n }\n } catch (error) {\n log('Failed to get suggested gas fees', error);\n }\n\n const gasPriceDecimal = (await query(ethQuery, 'gasPrice')) as number;\n\n const gasPrice = gasPriceDecimal\n ? add0x(gasPriceDecimal.toString(16))\n : undefined;\n\n return { gasPrice };\n}\n"]}
|
package/dist/chunk-EGQCE3FK.mjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ETHERSCAN_SUPPORTED_NETWORKS
|
|
3
|
-
} from "./chunk-O6ZZVIFH.mjs";
|
|
4
|
-
import {
|
|
5
|
-
incomingTransactionsLogger
|
|
6
|
-
} from "./chunk-UQQWZT6C.mjs";
|
|
7
|
-
|
|
8
|
-
// src/utils/etherscan.ts
|
|
9
|
-
import { handleFetch } from "@metamask/controller-utils";
|
|
10
|
-
async function fetchEtherscanTransactions({
|
|
11
|
-
address,
|
|
12
|
-
chainId,
|
|
13
|
-
fromBlock,
|
|
14
|
-
limit
|
|
15
|
-
}) {
|
|
16
|
-
return await fetchTransactions("txlist", {
|
|
17
|
-
address,
|
|
18
|
-
chainId,
|
|
19
|
-
fromBlock,
|
|
20
|
-
limit
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
async function fetchEtherscanTokenTransactions({
|
|
24
|
-
address,
|
|
25
|
-
chainId,
|
|
26
|
-
fromBlock,
|
|
27
|
-
limit
|
|
28
|
-
}) {
|
|
29
|
-
return await fetchTransactions("tokentx", {
|
|
30
|
-
address,
|
|
31
|
-
chainId,
|
|
32
|
-
fromBlock,
|
|
33
|
-
limit
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
async function fetchTransactions(action, {
|
|
37
|
-
address,
|
|
38
|
-
chainId,
|
|
39
|
-
fromBlock,
|
|
40
|
-
limit
|
|
41
|
-
}) {
|
|
42
|
-
const urlParams = {
|
|
43
|
-
module: "account",
|
|
44
|
-
address,
|
|
45
|
-
startBlock: fromBlock?.toString(),
|
|
46
|
-
offset: limit?.toString(),
|
|
47
|
-
sort: "desc"
|
|
48
|
-
};
|
|
49
|
-
const etherscanTxUrl = getEtherscanApiUrl(chainId, {
|
|
50
|
-
...urlParams,
|
|
51
|
-
action
|
|
52
|
-
});
|
|
53
|
-
incomingTransactionsLogger("Sending Etherscan request", etherscanTxUrl);
|
|
54
|
-
const response = await handleFetch(
|
|
55
|
-
etherscanTxUrl
|
|
56
|
-
);
|
|
57
|
-
return response;
|
|
58
|
-
}
|
|
59
|
-
function getEtherscanApiUrl(chainId, urlParams) {
|
|
60
|
-
const apiUrl = getEtherscanApiHost(chainId);
|
|
61
|
-
let url = `${apiUrl}/api?`;
|
|
62
|
-
for (const paramKey of Object.keys(urlParams)) {
|
|
63
|
-
const value = urlParams[paramKey];
|
|
64
|
-
if (!value) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
url += `${paramKey}=${value}&`;
|
|
68
|
-
}
|
|
69
|
-
url += "tag=latest&page=1";
|
|
70
|
-
return url;
|
|
71
|
-
}
|
|
72
|
-
function getEtherscanApiHost(chainId) {
|
|
73
|
-
const networkInfo = ETHERSCAN_SUPPORTED_NETWORKS[chainId];
|
|
74
|
-
if (!networkInfo) {
|
|
75
|
-
throw new Error(`Etherscan does not support chain with ID: ${chainId}`);
|
|
76
|
-
}
|
|
77
|
-
return `https://${networkInfo.subdomain}.${networkInfo.domain}`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export {
|
|
81
|
-
fetchEtherscanTransactions,
|
|
82
|
-
fetchEtherscanTokenTransactions,
|
|
83
|
-
getEtherscanApiHost
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=chunk-EGQCE3FK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/etherscan.ts"],"sourcesContent":["import { handleFetch } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { ETHERSCAN_SUPPORTED_NETWORKS } from '../constants';\nimport { incomingTransactionsLogger as log } from '../logger';\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 EtherscanTransactionMetaBase {\n blockNumber: string;\n blockHash: string;\n confirmations: string;\n contractAddress: string;\n cumulativeGasUsed: string;\n from: string;\n gas: string;\n gasPrice: string;\n gasUsed: string;\n hash: string;\n nonce: string;\n timeStamp: string;\n to: string;\n transactionIndex: string;\n value: 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 EtherscanTransactionMeta extends EtherscanTransactionMetaBase {\n functionName: string;\n input: string;\n isError: string;\n methodId: string;\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 txreceipt_status: 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 EtherscanTokenTransactionMeta\n extends EtherscanTransactionMetaBase {\n tokenDecimal: string;\n tokenName: string;\n tokenSymbol: 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 EtherscanTransactionResponse<\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 T extends EtherscanTransactionMetaBase,\n> {\n status: '0' | '1';\n message?: string;\n result: string | T[];\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 EtherscanTransactionRequest {\n address: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\n}\n\n/**\n * Retrieves transaction data from Etherscan.\n *\n * @param request - Configuration required to fetch transactions.\n * @param request.address - Address to retrieve transactions for.\n * @param request.chainId - Current chain ID used to determine subdomain and domain.\n * @param request.fromBlock - Block number to start fetching transactions from.\n * @param request.limit - Number of transactions to retrieve.\n * @returns An Etherscan response object containing the request status and an array of token transaction data.\n */\nexport async function fetchEtherscanTransactions({\n address,\n chainId,\n fromBlock,\n limit,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse<EtherscanTransactionMeta>\n> {\n return await fetchTransactions('txlist', {\n address,\n chainId,\n fromBlock,\n limit,\n });\n}\n\n/**\n * Retrieves token transaction data from Etherscan.\n *\n * @param request - Configuration required to fetch token transactions.\n * @param request.address - Address to retrieve token transactions for.\n * @param request.chainId - Current chain ID used to determine subdomain and domain.\n * @param request.fromBlock - Block number to start fetching token transactions from.\n * @param request.limit - Number of token transactions to retrieve.\n * @returns An Etherscan response object containing the request status and an array of token transaction data.\n */\nexport async function fetchEtherscanTokenTransactions({\n address,\n chainId,\n fromBlock,\n limit,\n}: EtherscanTransactionRequest): Promise<\n EtherscanTransactionResponse<EtherscanTokenTransactionMeta>\n> {\n return await fetchTransactions('tokentx', {\n address,\n chainId,\n fromBlock,\n limit,\n });\n}\n\n/**\n * Retrieves transaction data from Etherscan from a specific endpoint.\n *\n * @param action - The Etherscan endpoint to use.\n * @param options - Options bag.\n * @param options.address - Address to retrieve transactions for.\n * @param options.chainId - Current chain ID used to determine subdomain and domain.\n * @param options.fromBlock - Block number to start fetching transactions from.\n * @param options.limit - Number of transactions to retrieve.\n * @returns An object containing the request status and an array of transaction data.\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\nasync function fetchTransactions<T extends EtherscanTransactionMetaBase>(\n action: string,\n {\n address,\n chainId,\n fromBlock,\n limit,\n }: {\n address: string;\n chainId: Hex;\n fromBlock?: number;\n limit?: number;\n },\n): Promise<EtherscanTransactionResponse<T>> {\n const urlParams = {\n module: 'account',\n address,\n startBlock: fromBlock?.toString(),\n offset: limit?.toString(),\n sort: 'desc',\n };\n\n const etherscanTxUrl = getEtherscanApiUrl(chainId, {\n ...urlParams,\n action,\n });\n\n log('Sending Etherscan request', etherscanTxUrl);\n\n const response = (await handleFetch(\n etherscanTxUrl,\n )) as EtherscanTransactionResponse<T>;\n\n return response;\n}\n\n/**\n * Return a URL that can be used to fetch data from Etherscan.\n *\n * @param chainId - Current chain ID used to determine subdomain and domain.\n * @param urlParams - The parameters used to construct the URL.\n * @returns URL to access Etherscan data.\n */\nfunction getEtherscanApiUrl(\n chainId: Hex,\n urlParams: Record<string, string | undefined>,\n): string {\n const apiUrl = getEtherscanApiHost(chainId);\n let url = `${apiUrl}/api?`;\n\n for (const paramKey of Object.keys(urlParams)) {\n const value = urlParams[paramKey];\n\n if (!value) {\n continue;\n }\n\n url += `${paramKey}=${value}&`;\n }\n\n url += 'tag=latest&page=1';\n\n return url;\n}\n\n/**\n * Return the host url used to fetch data from Etherscan.\n *\n * @param chainId - Current chain ID used to determine subdomain and domain.\n * @returns host URL to access Etherscan data.\n */\nexport function getEtherscanApiHost(chainId: Hex) {\n // @ts-expect-error We account for `chainId` not being a property below\n const networkInfo = ETHERSCAN_SUPPORTED_NETWORKS[chainId];\n\n if (!networkInfo) {\n throw new Error(`Etherscan does not support chain with ID: ${chainId}`);\n }\n\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `https://${networkInfo.subdomain}.${networkInfo.domain}`;\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,mBAAmB;AAmF5B,eAAsB,2BAA2B;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEE;AACA,SAAO,MAAM,kBAAkB,UAAU;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAYA,eAAsB,gCAAgC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEE;AACA,SAAO,MAAM,kBAAkB,WAAW;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAeA,eAAe,kBACb,QACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAM0C;AAC1C,QAAM,YAAY;AAAA,IAChB,QAAQ;AAAA,IACR;AAAA,IACA,YAAY,WAAW,SAAS;AAAA,IAChC,QAAQ,OAAO,SAAS;AAAA,IACxB,MAAM;AAAA,EACR;AAEA,QAAM,iBAAiB,mBAAmB,SAAS;AAAA,IACjD,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AAED,6BAAI,6BAA6B,cAAc;AAE/C,QAAM,WAAY,MAAM;AAAA,IACtB;AAAA,EACF;AAEA,SAAO;AACT;AASA,SAAS,mBACP,SACA,WACQ;AACR,QAAM,SAAS,oBAAoB,OAAO;AAC1C,MAAI,MAAM,GAAG,MAAM;AAEnB,aAAW,YAAY,OAAO,KAAK,SAAS,GAAG;AAC7C,UAAM,QAAQ,UAAU,QAAQ;AAEhC,QAAI,CAAC,OAAO;AACV;AAAA,IACF;AAEA,WAAO,GAAG,QAAQ,IAAI,KAAK;AAAA,EAC7B;AAEA,SAAO;AAEP,SAAO;AACT;AAQO,SAAS,oBAAoB,SAAc;AAEhD,QAAM,cAAc,6BAA6B,OAAO;AAExD,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,6CAA6C,OAAO,EAAE;AAAA,EACxE;AAIA,SAAO,WAAW,YAAY,SAAS,IAAI,YAAY,MAAM;AAC/D;","names":[]}
|
package/dist/chunk-EHWAY6XU.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
var _chunkBZV72SCFjs = require('./chunk-BZV72SCF.js');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _chunkPSZ34BI5js = require('./chunk-PSZ34BI5.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _chunkZ4BLTVTBjs = require('./chunk-Z4BLTVTB.js');
|
|
14
|
-
|
|
15
|
-
// src/gas-flows/DefaultGasFeeFlow.ts
|
|
16
|
-
var _gasfeecontroller = require('@metamask/gas-fee-controller');
|
|
17
|
-
var _utils = require('@metamask/utils');
|
|
18
|
-
var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger, "default-gas-fee-flow");
|
|
19
|
-
var _getFeeMarkEstimates, getFeeMarkEstimates_fn, _getLegacyEstimates, getLegacyEstimates_fn, _getGasPriceEstimates, getGasPriceEstimates_fn, _getFeeMarketLevel, getFeeMarketLevel_fn, _getLegacyLevel, getLegacyLevel_fn;
|
|
20
|
-
var DefaultGasFeeFlow = class {
|
|
21
|
-
constructor() {
|
|
22
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getFeeMarkEstimates);
|
|
23
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getLegacyEstimates);
|
|
24
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getGasPriceEstimates);
|
|
25
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getFeeMarketLevel);
|
|
26
|
-
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getLegacyLevel);
|
|
27
|
-
}
|
|
28
|
-
matchesTransaction(_transactionMeta) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
async getGasFees(request) {
|
|
32
|
-
const { gasFeeControllerData } = request;
|
|
33
|
-
const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;
|
|
34
|
-
let response;
|
|
35
|
-
switch (gasEstimateType) {
|
|
36
|
-
case _gasfeecontroller.GAS_ESTIMATE_TYPES.FEE_MARKET:
|
|
37
|
-
log("Using fee market estimates", gasFeeEstimates);
|
|
38
|
-
response = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getFeeMarkEstimates, getFeeMarkEstimates_fn).call(this, gasFeeEstimates);
|
|
39
|
-
break;
|
|
40
|
-
case _gasfeecontroller.GAS_ESTIMATE_TYPES.LEGACY:
|
|
41
|
-
log("Using legacy estimates", gasFeeEstimates);
|
|
42
|
-
response = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLegacyEstimates, getLegacyEstimates_fn).call(this, gasFeeEstimates);
|
|
43
|
-
break;
|
|
44
|
-
case _gasfeecontroller.GAS_ESTIMATE_TYPES.ETH_GASPRICE:
|
|
45
|
-
log("Using eth_gasPrice estimates", gasFeeEstimates);
|
|
46
|
-
response = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGasPriceEstimates, getGasPriceEstimates_fn).call(this, gasFeeEstimates);
|
|
47
|
-
break;
|
|
48
|
-
default:
|
|
49
|
-
throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
estimates: response
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
_getFeeMarkEstimates = new WeakSet();
|
|
57
|
-
getFeeMarkEstimates_fn = function(gasFeeEstimates) {
|
|
58
|
-
const levels = Object.values(_chunkPSZ34BI5js.GasFeeEstimateLevel).reduce(
|
|
59
|
-
(result, level) => ({
|
|
60
|
-
...result,
|
|
61
|
-
[level]: _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getFeeMarketLevel, getFeeMarketLevel_fn).call(this, gasFeeEstimates, level)
|
|
62
|
-
}),
|
|
63
|
-
{}
|
|
64
|
-
);
|
|
65
|
-
return {
|
|
66
|
-
type: "fee-market" /* FeeMarket */,
|
|
67
|
-
...levels
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
_getLegacyEstimates = new WeakSet();
|
|
71
|
-
getLegacyEstimates_fn = function(gasFeeEstimates) {
|
|
72
|
-
const levels = Object.values(_chunkPSZ34BI5js.GasFeeEstimateLevel).reduce(
|
|
73
|
-
(result, level) => ({
|
|
74
|
-
...result,
|
|
75
|
-
[level]: _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLegacyLevel, getLegacyLevel_fn).call(this, gasFeeEstimates, level)
|
|
76
|
-
}),
|
|
77
|
-
{}
|
|
78
|
-
);
|
|
79
|
-
return {
|
|
80
|
-
type: "legacy" /* Legacy */,
|
|
81
|
-
...levels
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
_getGasPriceEstimates = new WeakSet();
|
|
85
|
-
getGasPriceEstimates_fn = function(gasFeeEstimates) {
|
|
86
|
-
return {
|
|
87
|
-
type: "eth_gasPrice" /* GasPrice */,
|
|
88
|
-
gasPrice: _chunkBZV72SCFjs.gweiDecimalToWeiHex.call(void 0, gasFeeEstimates.gasPrice)
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
_getFeeMarketLevel = new WeakSet();
|
|
92
|
-
getFeeMarketLevel_fn = function(gasFeeEstimates, level) {
|
|
93
|
-
const maxFeePerGas = _chunkBZV72SCFjs.gweiDecimalToWeiHex.call(void 0,
|
|
94
|
-
gasFeeEstimates[level].suggestedMaxFeePerGas
|
|
95
|
-
);
|
|
96
|
-
const maxPriorityFeePerGas = _chunkBZV72SCFjs.gweiDecimalToWeiHex.call(void 0,
|
|
97
|
-
gasFeeEstimates[level].suggestedMaxPriorityFeePerGas
|
|
98
|
-
);
|
|
99
|
-
return {
|
|
100
|
-
maxFeePerGas,
|
|
101
|
-
maxPriorityFeePerGas
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
_getLegacyLevel = new WeakSet();
|
|
105
|
-
getLegacyLevel_fn = function(gasFeeEstimates, level) {
|
|
106
|
-
return _chunkBZV72SCFjs.gweiDecimalToWeiHex.call(void 0, gasFeeEstimates[level]);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
exports.DefaultGasFeeFlow = DefaultGasFeeFlow;
|
|
112
|
-
//# sourceMappingURL=chunk-EHWAY6XU.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAKA,SAAS,0BAA0B;AAEnC,SAAS,0BAA0B;AAiBnC,IAAM,MAAM,mBAAmB,eAAe,sBAAsB;AAxBpE;AA6BO,IAAM,oBAAN,MAA8C;AAAA,EAA9C;AAuCL;AAiBA;AAiBA;AASA;AAkBA;AAAA;AAAA,EAnGA,mBAAmB,kBAA4C;AAC7D,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,SAAyD;AACxE,UAAM,EAAE,qBAAqB,IAAI;AACjC,UAAM,EAAE,iBAAiB,gBAAgB,IAAI;AAE7C,QAAI;AAEJ,YAAQ,iBAAiB;AAAA,MACvB,KAAK,mBAAmB;AACtB,YAAI,8BAA8B,eAAe;AACjD,mBAAW,sBAAK,8CAAL,WAA0B;AACrC;AAAA,MACF,KAAK,mBAAmB;AACtB,YAAI,0BAA0B,eAAe;AAC7C,mBAAW,sBAAK,4CAAL,WACT;AAEF;AAAA,MACF,KAAK,mBAAmB;AACtB,YAAI,gCAAgC,eAAe;AACnD,mBAAW,sBAAK,gDAAL,WACT;AAEF;AAAA,MACF;AAGE,cAAM,IAAI,MAAM,kCAAkC,eAAe,EAAE;AAAA,IACvE;AAEA,WAAO;AAAA,MACL,WAAW;AAAA,IACb;AAAA,EACF;AAqEF;AAnEE;AAAA,yBAAoB,SAClB,iBAC0B;AAC1B,QAAM,SAAS,OAAO,OAAO,mBAAmB,EAAE;AAAA,IAChD,CAAC,QAAQ,WAAW;AAAA,MAClB,GAAG;AAAA,MACH,CAAC,KAAK,GAAG,sBAAK,0CAAL,WAAwB,iBAAiB;AAAA,IACpD;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA,GAAG;AAAA,EACL;AACF;AAEA;AAAA,wBAAmB,SACjB,iBACuB;AACvB,QAAM,SAAS,OAAO,OAAO,mBAAmB,EAAE;AAAA,IAChD,CAAC,QAAQ,WAAW;AAAA,MAClB,GAAG;AAAA,MACH,CAAC,KAAK,GAAG,sBAAK,oCAAL,WAAqB,iBAAiB;AAAA,IACjD;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA,GAAG;AAAA,EACL;AACF;AAEA;AAAA,0BAAqB,SACnB,iBACyB;AACzB,SAAO;AAAA,IACL;AAAA,IACA,UAAU,oBAAoB,gBAAgB,QAAQ;AAAA,EACxD;AACF;AAEA;AAAA,uBAAkB,SAChB,iBACA,OACiC;AACjC,QAAM,eAAe;AAAA,IACnB,gBAAgB,KAAK,EAAE;AAAA,EACzB;AAEA,QAAM,uBAAuB;AAAA,IAC3B,gBAAgB,KAAK,EAAE;AAAA,EACzB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEA;AAAA,oBAAe,SACb,iBACA,OACK;AACL,SAAO,oBAAoB,gBAAgB,KAAK,CAAC;AACnD","sourcesContent":["import type {\n LegacyGasPriceEstimate,\n GasFeeEstimates as FeeMarketGasPriceEstimate,\n EthGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n FeeMarketGasFeeEstimateForLevel,\n FeeMarketGasFeeEstimates,\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n GasPriceGasFeeEstimates,\n LegacyGasFeeEstimates,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel, GasFeeEstimateType } from '../types';\nimport { gweiDecimalToWeiHex } from '../utils/gas-fees';\n\nconst log = createModuleLogger(projectLogger, 'default-gas-fee-flow');\n\n/**\n * The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.\n */\nexport class DefaultGasFeeFlow implements GasFeeFlow {\n matchesTransaction(_transactionMeta: TransactionMeta): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n const { gasFeeControllerData } = request;\n const { gasEstimateType, gasFeeEstimates } = gasFeeControllerData;\n\n let response: GasFeeEstimates;\n\n switch (gasEstimateType) {\n case GAS_ESTIMATE_TYPES.FEE_MARKET:\n log('Using fee market estimates', gasFeeEstimates);\n response = this.#getFeeMarkEstimates(gasFeeEstimates);\n break;\n case GAS_ESTIMATE_TYPES.LEGACY:\n log('Using legacy estimates', gasFeeEstimates);\n response = this.#getLegacyEstimates(\n gasFeeEstimates as LegacyGasPriceEstimate,\n );\n break;\n case GAS_ESTIMATE_TYPES.ETH_GASPRICE:\n log('Using eth_gasPrice estimates', gasFeeEstimates);\n response = this.#getGasPriceEstimates(\n gasFeeEstimates as EthGasPriceEstimate,\n );\n break;\n default:\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n throw new Error(`Unsupported gas estimate type: ${gasEstimateType}`);\n }\n\n return {\n estimates: response,\n };\n }\n\n #getFeeMarkEstimates(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n ): FeeMarketGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getFeeMarketLevel(gasFeeEstimates, level),\n }),\n {} as Omit<FeeMarketGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.FeeMarket,\n ...levels,\n };\n }\n\n #getLegacyEstimates(\n gasFeeEstimates: LegacyGasPriceEstimate,\n ): LegacyGasFeeEstimates {\n const levels = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getLegacyLevel(gasFeeEstimates, level),\n }),\n {} as Omit<LegacyGasFeeEstimates, 'type'>,\n );\n\n return {\n type: GasFeeEstimateType.Legacy,\n ...levels,\n };\n }\n\n #getGasPriceEstimates(\n gasFeeEstimates: EthGasPriceEstimate,\n ): GasPriceGasFeeEstimates {\n return {\n type: GasFeeEstimateType.GasPrice,\n gasPrice: gweiDecimalToWeiHex(gasFeeEstimates.gasPrice),\n };\n }\n\n #getFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): FeeMarketGasFeeEstimateForLevel {\n const maxFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxFeePerGas,\n );\n\n const maxPriorityFeePerGas = gweiDecimalToWeiHex(\n gasFeeEstimates[level].suggestedMaxPriorityFeePerGas,\n );\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n }\n\n #getLegacyLevel(\n gasFeeEstimates: LegacyGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): Hex {\n return gweiDecimalToWeiHex(gasFeeEstimates[level]);\n }\n}\n"]}
|