@metamask/transaction-controller 24.0.0 → 25.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 +118 -1
- package/dist/TransactionController.js +38 -1816
- package/dist/TransactionController.js.map +1 -1
- package/dist/TransactionController.mjs +39 -0
- package/dist/TransactionController.mjs.map +1 -0
- package/dist/chunk-2K7J3EY3.mjs +170 -0
- package/dist/chunk-2K7J3EY3.mjs.map +1 -0
- package/dist/chunk-5XBULBP2.js +399 -0
- package/dist/chunk-5XBULBP2.js.map +1 -0
- package/dist/chunk-6MYNWYJK.mjs +158 -0
- package/dist/chunk-6MYNWYJK.mjs.map +1 -0
- package/dist/chunk-7APMBUKB.js +158 -0
- package/dist/chunk-7APMBUKB.js.map +1 -0
- package/dist/chunk-7LXE4KHV.js +40 -0
- package/dist/chunk-7LXE4KHV.js.map +1 -0
- package/dist/chunk-7MZ57ILQ.mjs +62 -0
- package/dist/chunk-7MZ57ILQ.mjs.map +1 -0
- package/dist/chunk-BJEESIBE.js +2313 -0
- package/dist/chunk-BJEESIBE.js.map +1 -0
- package/dist/chunk-C67QD5PV.mjs +320 -0
- package/dist/chunk-C67QD5PV.mjs.map +1 -0
- package/dist/chunk-DE3MZYVY.mjs +2313 -0
- package/dist/chunk-DE3MZYVY.mjs.map +1 -0
- package/dist/chunk-DEKM6PVG.mjs +46 -0
- package/dist/chunk-DEKM6PVG.mjs.map +1 -0
- package/dist/chunk-DQP6X25N.mjs +208 -0
- package/dist/chunk-DQP6X25N.mjs.map +1 -0
- package/dist/chunk-DTDTOMTB.js +238 -0
- package/dist/chunk-DTDTOMTB.js.map +1 -0
- package/dist/chunk-DTEDYRTL.js +242 -0
- package/dist/chunk-DTEDYRTL.js.map +1 -0
- package/dist/chunk-EQ3RRHB7.mjs +211 -0
- package/dist/chunk-EQ3RRHB7.mjs.map +1 -0
- package/dist/chunk-FDJPXQTF.js +46 -0
- package/dist/chunk-FDJPXQTF.js.map +1 -0
- package/dist/chunk-FRKQ3Z2L.mjs +40 -0
- package/dist/chunk-FRKQ3Z2L.mjs.map +1 -0
- package/dist/chunk-FS7FRO7B.mjs +90 -0
- package/dist/chunk-FS7FRO7B.mjs.map +1 -0
- package/dist/chunk-GKTIFXPN.js +170 -0
- package/dist/chunk-GKTIFXPN.js.map +1 -0
- package/dist/chunk-H4M66BA3.js +62 -0
- package/dist/chunk-H4M66BA3.js.map +1 -0
- package/dist/chunk-HPNXIKFY.js +76 -0
- package/dist/chunk-HPNXIKFY.js.map +1 -0
- package/dist/chunk-HS277C77.js +75 -0
- package/dist/chunk-HS277C77.js.map +1 -0
- package/dist/chunk-I5YZ7QUK.js +121 -0
- package/dist/chunk-I5YZ7QUK.js.map +1 -0
- package/dist/chunk-IC233ZQS.js +211 -0
- package/dist/chunk-IC233ZQS.js.map +1 -0
- package/dist/chunk-IUBAETUH.js +137 -0
- package/dist/chunk-IUBAETUH.js.map +1 -0
- package/dist/chunk-J56A7UCK.mjs +123 -0
- package/dist/chunk-J56A7UCK.mjs.map +1 -0
- package/dist/chunk-JR6HDRNV.mjs +242 -0
- package/dist/chunk-JR6HDRNV.mjs.map +1 -0
- package/dist/chunk-JRBREX22.mjs +75 -0
- package/dist/chunk-JRBREX22.mjs.map +1 -0
- package/dist/chunk-JRQHIBG5.mjs +399 -0
- package/dist/chunk-JRQHIBG5.mjs.map +1 -0
- package/dist/chunk-LM4NUNMT.mjs +76 -0
- package/dist/chunk-LM4NUNMT.mjs.map +1 -0
- package/dist/chunk-M7455RU7.js +320 -0
- package/dist/chunk-M7455RU7.js.map +1 -0
- package/dist/chunk-MHM5LRRF.mjs +122 -0
- package/dist/chunk-MHM5LRRF.mjs.map +1 -0
- package/dist/chunk-NHRBO3LU.mjs +50 -0
- package/dist/chunk-NHRBO3LU.mjs.map +1 -0
- package/dist/chunk-NM6OYEPP.mjs +182 -0
- package/dist/chunk-NM6OYEPP.mjs.map +1 -0
- package/dist/chunk-NUOBUW7C.js +85 -0
- package/dist/chunk-NUOBUW7C.js.map +1 -0
- package/dist/chunk-QP75SWIQ.js +53 -0
- package/dist/chunk-QP75SWIQ.js.map +1 -0
- package/dist/chunk-RI6MVJJN.js +122 -0
- package/dist/chunk-RI6MVJJN.js.map +1 -0
- package/dist/chunk-S6VGOPUY.js +14 -0
- package/dist/chunk-S6VGOPUY.js.map +1 -0
- package/dist/chunk-UGFBA4GV.js +123 -0
- package/dist/chunk-UGFBA4GV.js.map +1 -0
- package/dist/chunk-UKYY2RVS.mjs +137 -0
- package/dist/chunk-UKYY2RVS.mjs.map +1 -0
- package/dist/chunk-UM4ORJ5B.mjs +121 -0
- package/dist/chunk-UM4ORJ5B.mjs.map +1 -0
- package/dist/chunk-UQQWZT6C.mjs +14 -0
- package/dist/chunk-UQQWZT6C.mjs.map +1 -0
- package/dist/chunk-VH47Q6TS.js +182 -0
- package/dist/chunk-VH47Q6TS.js.map +1 -0
- package/dist/chunk-XGRAHX6T.mjs +53 -0
- package/dist/chunk-XGRAHX6T.mjs.map +1 -0
- package/dist/chunk-XUI43LEZ.mjs +30 -0
- package/dist/chunk-XUI43LEZ.mjs.map +1 -0
- package/dist/chunk-Y734U4V6.mjs +85 -0
- package/dist/chunk-Y734U4V6.mjs.map +1 -0
- package/dist/chunk-Y7ENNK7L.mjs +238 -0
- package/dist/chunk-Y7ENNK7L.mjs.map +1 -0
- package/dist/chunk-Z4BLTVTB.js +30 -0
- package/dist/chunk-Z4BLTVTB.js.map +1 -0
- package/dist/chunk-ZCQRDZ36.js +208 -0
- package/dist/chunk-ZCQRDZ36.js.map +1 -0
- package/dist/chunk-ZJLZSFOZ.js +90 -0
- package/dist/chunk-ZJLZSFOZ.js.map +1 -0
- package/dist/chunk-ZNZEJDOE.js +50 -0
- package/dist/chunk-ZNZEJDOE.js.map +1 -0
- package/dist/constants.js +15 -110
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +16 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/gas-flows/DefaultGasFeeFlow.js +14 -77
- package/dist/gas-flows/DefaultGasFeeFlow.js.map +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.mjs +15 -0
- package/dist/gas-flows/DefaultGasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/LineaGasFeeFlow.js +15 -110
- package/dist/gas-flows/LineaGasFeeFlow.js.map +1 -1
- package/dist/gas-flows/LineaGasFeeFlow.mjs +16 -0
- package/dist/gas-flows/LineaGasFeeFlow.mjs.map +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.js +11 -145
- package/dist/helpers/EtherscanRemoteTransactionSource.js.map +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +12 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs.map +1 -0
- package/dist/helpers/GasFeePoller.js +10 -143
- package/dist/helpers/GasFeePoller.js.map +1 -1
- package/dist/helpers/GasFeePoller.mjs +11 -0
- package/dist/helpers/GasFeePoller.mjs.map +1 -0
- package/dist/helpers/IncomingTransactionHelper.js +8 -205
- package/dist/helpers/IncomingTransactionHelper.js.map +1 -1
- package/dist/helpers/IncomingTransactionHelper.mjs +9 -0
- package/dist/helpers/IncomingTransactionHelper.mjs.map +1 -0
- package/dist/helpers/MultichainTrackingHelper.js +12 -291
- package/dist/helpers/MultichainTrackingHelper.js.map +1 -1
- package/dist/helpers/MultichainTrackingHelper.mjs +13 -0
- package/dist/helpers/MultichainTrackingHelper.mjs.map +1 -0
- package/dist/helpers/PendingTransactionTracker.js +9 -360
- package/dist/helpers/PendingTransactionTracker.js.map +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +10 -0
- package/dist/helpers/PendingTransactionTracker.mjs.map +1 -0
- package/dist/index.js +56 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger.js +11 -8
- package/dist/logger.js.map +1 -1
- package/dist/logger.mjs +12 -0
- package/dist/logger.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/{TransactionController.d.ts → types/TransactionController.d.ts} +235 -46
- package/dist/types/TransactionController.d.ts.map +1 -0
- package/dist/{constants.d.ts → types/constants.d.ts} +5 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/gas-flows/DefaultGasFeeFlow.d.ts.map +1 -0
- package/dist/types/gas-flows/LineaGasFeeFlow.d.ts.map +1 -0
- package/dist/types/helpers/EtherscanRemoteTransactionSource.d.ts.map +1 -0
- package/dist/types/helpers/GasFeePoller.d.ts.map +1 -0
- package/dist/types/helpers/IncomingTransactionHelper.d.ts.map +1 -0
- package/dist/types/helpers/MultichainTrackingHelper.d.ts.map +1 -0
- package/dist/types/helpers/PendingTransactionTracker.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/{types.d.ts → types/types.d.ts} +63 -65
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/etherscan.d.ts.map +1 -0
- package/dist/types/utils/external-transactions.d.ts.map +1 -0
- package/dist/types/utils/gas-fees.d.ts.map +1 -0
- package/dist/types/utils/gas-flow.d.ts.map +1 -0
- package/dist/types/utils/gas.d.ts.map +1 -0
- package/dist/types/utils/history.d.ts +20 -0
- package/dist/types/utils/history.d.ts.map +1 -0
- package/dist/types/utils/nonce.d.ts.map +1 -0
- package/dist/types/utils/simulation-api.d.ts +99 -0
- package/dist/types/utils/simulation-api.d.ts.map +1 -0
- package/dist/types/utils/simulation.d.ts +21 -0
- package/dist/types/utils/simulation.d.ts.map +1 -0
- package/dist/{utils → types/utils}/swaps.d.ts +8 -5
- package/dist/types/utils/swaps.d.ts.map +1 -0
- package/dist/types/utils/transaction-type.d.ts.map +1 -0
- package/dist/types/utils/utils.d.ts.map +1 -0
- package/dist/types/utils/validation.d.ts.map +1 -0
- package/dist/types.js +19 -170
- package/dist/types.js.map +1 -1
- package/dist/types.mjs +20 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils/etherscan.js +13 -118
- package/dist/utils/etherscan.js.map +1 -1
- package/dist/utils/etherscan.mjs +14 -0
- package/dist/utils/etherscan.mjs.map +1 -0
- package/dist/utils/external-transactions.js +8 -35
- package/dist/utils/external-transactions.js.map +1 -1
- package/dist/utils/external-transactions.mjs +9 -0
- package/dist/utils/external-transactions.mjs.map +1 -0
- package/dist/utils/gas-fees.js +15 -200
- package/dist/utils/gas-fees.js.map +1 -1
- package/dist/utils/gas-fees.mjs +16 -0
- package/dist/utils/gas-fees.mjs.map +1 -0
- package/dist/utils/gas-flow.js +10 -52
- package/dist/utils/gas-flow.js.map +1 -1
- package/dist/utils/gas-flow.mjs +11 -0
- package/dist/utils/gas-flow.mjs.map +1 -0
- package/dist/utils/gas.js +19 -133
- package/dist/utils/gas.js.map +1 -1
- package/dist/utils/gas.mjs +20 -0
- package/dist/utils/gas.mjs.map +1 -0
- package/dist/utils/history.js +9 -83
- package/dist/utils/history.js.map +1 -1
- package/dist/utils/history.mjs +10 -0
- package/dist/utils/history.mjs.map +1 -0
- package/dist/utils/nonce.js +10 -76
- package/dist/utils/nonce.js.map +1 -1
- package/dist/utils/nonce.mjs +11 -0
- package/dist/utils/nonce.mjs.map +1 -0
- package/dist/utils/simulation-api.js +10 -0
- package/dist/utils/simulation-api.js.map +1 -0
- package/dist/utils/simulation-api.mjs +10 -0
- package/dist/utils/simulation-api.mjs.map +1 -0
- package/dist/utils/simulation.js +12 -0
- package/dist/utils/simulation.js.map +1 -0
- package/dist/utils/simulation.mjs +12 -0
- package/dist/utils/simulation.mjs.map +1 -0
- package/dist/utils/swaps.js +23 -256
- package/dist/utils/swaps.js.map +1 -1
- package/dist/utils/swaps.mjs +24 -0
- package/dist/utils/swaps.mjs.map +1 -0
- package/dist/utils/transaction-type.js +10 -120
- package/dist/utils/transaction-type.js.map +1 -1
- package/dist/utils/transaction-type.mjs +11 -0
- package/dist/utils/transaction-type.mjs.map +1 -0
- package/dist/utils/utils.js +32 -160
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/utils.mjs +33 -0
- package/dist/utils/utils.mjs.map +1 -0
- package/dist/utils/validation.js +11 -258
- package/dist/utils/validation.js.map +1 -1
- package/dist/utils/validation.mjs +12 -0
- package/dist/utils/validation.mjs.map +1 -0
- package/package.json +21 -9
- package/dist/TransactionController.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/gas-flows/DefaultGasFeeFlow.d.ts.map +0 -1
- package/dist/gas-flows/LineaGasFeeFlow.d.ts.map +0 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.d.ts.map +0 -1
- package/dist/helpers/GasFeePoller.d.ts.map +0 -1
- package/dist/helpers/IncomingTransactionHelper.d.ts.map +0 -1
- package/dist/helpers/MultichainTrackingHelper.d.ts.map +0 -1
- package/dist/helpers/PendingTransactionTracker.d.ts.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/etherscan.d.ts.map +0 -1
- package/dist/utils/external-transactions.d.ts.map +0 -1
- package/dist/utils/gas-fees.d.ts.map +0 -1
- package/dist/utils/gas-flow.d.ts.map +0 -1
- package/dist/utils/gas.d.ts.map +0 -1
- package/dist/utils/history.d.ts +0 -15
- package/dist/utils/history.d.ts.map +0 -1
- package/dist/utils/nonce.d.ts.map +0 -1
- package/dist/utils/swaps.d.ts.map +0 -1
- package/dist/utils/transaction-type.d.ts.map +0 -1
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- /package/dist/{gas-flows → types/gas-flows}/DefaultGasFeeFlow.d.ts +0 -0
- /package/dist/{gas-flows → types/gas-flows}/LineaGasFeeFlow.d.ts +0 -0
- /package/dist/{helpers → types/helpers}/EtherscanRemoteTransactionSource.d.ts +0 -0
- /package/dist/{helpers → types/helpers}/GasFeePoller.d.ts +0 -0
- /package/dist/{helpers → types/helpers}/IncomingTransactionHelper.d.ts +0 -0
- /package/dist/{helpers → types/helpers}/MultichainTrackingHelper.d.ts +0 -0
- /package/dist/{helpers → types/helpers}/PendingTransactionTracker.d.ts +0 -0
- /package/dist/{logger.d.ts → types/logger.d.ts} +0 -0
- /package/dist/{utils → types/utils}/etherscan.d.ts +0 -0
- /package/dist/{utils → types/utils}/external-transactions.d.ts +0 -0
- /package/dist/{utils → types/utils}/gas-fees.d.ts +0 -0
- /package/dist/{utils → types/utils}/gas-flow.d.ts +0 -0
- /package/dist/{utils → types/utils}/gas.d.ts +0 -0
- /package/dist/{utils → types/utils}/nonce.d.ts +0 -0
- /package/dist/{utils → types/utils}/transaction-type.d.ts +0 -0
- /package/dist/{utils → types/utils}/utils.d.ts +0 -0
- /package/dist/{utils → types/utils}/validation.d.ts +0 -0
package/dist/utils/gas-fees.js
CHANGED
|
@@ -1,201 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const logger_1 = require("../logger");
|
|
17
|
-
const types_1 = require("../types");
|
|
18
|
-
const gas_flow_1 = require("./gas-flow");
|
|
19
|
-
const swaps_1 = require("./swaps");
|
|
20
|
-
const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'gas-fees');
|
|
21
|
-
function updateGasFees(request) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const { txMeta } = request;
|
|
24
|
-
const initialParams = Object.assign({}, txMeta.txParams);
|
|
25
|
-
const isSwap = swaps_1.SWAP_TRANSACTION_TYPES.includes(txMeta.type);
|
|
26
|
-
const savedGasFees = isSwap
|
|
27
|
-
? undefined
|
|
28
|
-
: request.getSavedGasFees(txMeta.chainId);
|
|
29
|
-
const suggestedGasFees = yield getSuggestedGasFees(request);
|
|
30
|
-
log('Suggested gas fees', suggestedGasFees);
|
|
31
|
-
const getGasFeeRequest = Object.assign(Object.assign({}, request), { initialParams,
|
|
32
|
-
savedGasFees,
|
|
33
|
-
suggestedGasFees });
|
|
34
|
-
txMeta.txParams.maxFeePerGas = getMaxFeePerGas(getGasFeeRequest);
|
|
35
|
-
txMeta.txParams.maxPriorityFeePerGas =
|
|
36
|
-
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
|
-
}
|
|
54
|
-
exports.updateGasFees = updateGasFees;
|
|
55
|
-
function gweiDecimalToWeiHex(value) {
|
|
56
|
-
return (0, controller_utils_1.toHex)((0, controller_utils_1.gweiDecToWEIBN)(value));
|
|
57
|
-
}
|
|
58
|
-
exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
|
|
59
|
-
function getMaxFeePerGas(request) {
|
|
60
|
-
const { savedGasFees, eip1559, initialParams, suggestedGasFees } = request;
|
|
61
|
-
if (!eip1559) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
if (savedGasFees) {
|
|
65
|
-
const maxFeePerGas = gweiDecimalToWeiHex(savedGasFees.maxBaseFee);
|
|
66
|
-
log('Using maxFeePerGas from savedGasFees', maxFeePerGas);
|
|
67
|
-
return maxFeePerGas;
|
|
68
|
-
}
|
|
69
|
-
if (initialParams.maxFeePerGas) {
|
|
70
|
-
log('Using maxFeePerGas from request', initialParams.maxFeePerGas);
|
|
71
|
-
return initialParams.maxFeePerGas;
|
|
72
|
-
}
|
|
73
|
-
if (initialParams.gasPrice && !initialParams.maxPriorityFeePerGas) {
|
|
74
|
-
log('Setting maxFeePerGas to gasPrice from request', initialParams.gasPrice);
|
|
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('Setting maxFeePerGas to suggested gasPrice', suggestedGasFees.gasPrice);
|
|
83
|
-
return suggestedGasFees.gasPrice;
|
|
84
|
-
}
|
|
85
|
-
log('maxFeePerGas not set');
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
function getMaxPriorityFeePerGas(request) {
|
|
89
|
-
const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } = request;
|
|
90
|
-
if (!eip1559) {
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
if (savedGasFees) {
|
|
94
|
-
const maxPriorityFeePerGas = gweiDecimalToWeiHex(savedGasFees.priorityFee);
|
|
95
|
-
log('Using maxPriorityFeePerGas from savedGasFees.priorityFee', maxPriorityFeePerGas);
|
|
96
|
-
return maxPriorityFeePerGas;
|
|
97
|
-
}
|
|
98
|
-
if (initialParams.maxPriorityFeePerGas) {
|
|
99
|
-
log('Using maxPriorityFeePerGas from request', initialParams.maxPriorityFeePerGas);
|
|
100
|
-
return initialParams.maxPriorityFeePerGas;
|
|
101
|
-
}
|
|
102
|
-
if (initialParams.gasPrice && !initialParams.maxFeePerGas) {
|
|
103
|
-
log('Setting maxPriorityFeePerGas to gasPrice from request', initialParams.gasPrice);
|
|
104
|
-
return initialParams.gasPrice;
|
|
105
|
-
}
|
|
106
|
-
if (suggestedGasFees.maxPriorityFeePerGas) {
|
|
107
|
-
log('Using suggested maxPriorityFeePerGas', suggestedGasFees.maxPriorityFeePerGas);
|
|
108
|
-
return suggestedGasFees.maxPriorityFeePerGas;
|
|
109
|
-
}
|
|
110
|
-
if (txMeta.txParams.maxFeePerGas) {
|
|
111
|
-
log('Setting maxPriorityFeePerGas to maxFeePerGas', txMeta.txParams.maxFeePerGas);
|
|
112
|
-
return txMeta.txParams.maxFeePerGas;
|
|
113
|
-
}
|
|
114
|
-
log('maxPriorityFeePerGas not set');
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
function getGasPrice(request) {
|
|
118
|
-
const { eip1559, initialParams, suggestedGasFees } = request;
|
|
119
|
-
if (eip1559) {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
if (initialParams.gasPrice) {
|
|
123
|
-
log('Using gasPrice from request', initialParams.gasPrice);
|
|
124
|
-
return initialParams.gasPrice;
|
|
125
|
-
}
|
|
126
|
-
if (suggestedGasFees.maxFeePerGas) {
|
|
127
|
-
log('Using suggested maxFeePerGas', suggestedGasFees.maxFeePerGas);
|
|
128
|
-
return suggestedGasFees.maxFeePerGas;
|
|
129
|
-
}
|
|
130
|
-
if (suggestedGasFees.gasPrice) {
|
|
131
|
-
log('Using suggested gasPrice', suggestedGasFees.gasPrice);
|
|
132
|
-
return suggestedGasFees.gasPrice;
|
|
133
|
-
}
|
|
134
|
-
log('gasPrice not set');
|
|
135
|
-
return undefined;
|
|
136
|
-
}
|
|
137
|
-
function getUserFeeLevel(request) {
|
|
138
|
-
const { eip1559, initialParams, savedGasFees, suggestedGasFees, txMeta } = request;
|
|
139
|
-
if (!eip1559) {
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
if (savedGasFees) {
|
|
143
|
-
return types_1.UserFeeLevel.CUSTOM;
|
|
144
|
-
}
|
|
145
|
-
if (!initialParams.maxFeePerGas &&
|
|
146
|
-
!initialParams.maxPriorityFeePerGas &&
|
|
147
|
-
initialParams.gasPrice) {
|
|
148
|
-
return txMeta.origin === controller_utils_1.ORIGIN_METAMASK
|
|
149
|
-
? types_1.UserFeeLevel.CUSTOM
|
|
150
|
-
: types_1.UserFeeLevel.DAPP_SUGGESTED;
|
|
151
|
-
}
|
|
152
|
-
if (!initialParams.maxFeePerGas &&
|
|
153
|
-
!initialParams.maxPriorityFeePerGas &&
|
|
154
|
-
suggestedGasFees.maxFeePerGas &&
|
|
155
|
-
suggestedGasFees.maxPriorityFeePerGas) {
|
|
156
|
-
return types_1.UserFeeLevel.MEDIUM;
|
|
157
|
-
}
|
|
158
|
-
if (txMeta.origin === controller_utils_1.ORIGIN_METAMASK) {
|
|
159
|
-
return types_1.UserFeeLevel.MEDIUM;
|
|
160
|
-
}
|
|
161
|
-
return types_1.UserFeeLevel.DAPP_SUGGESTED;
|
|
162
|
-
}
|
|
163
|
-
function updateDefaultGasEstimates(txMeta) {
|
|
164
|
-
if (!txMeta.defaultGasEstimates) {
|
|
165
|
-
txMeta.defaultGasEstimates = {};
|
|
166
|
-
}
|
|
167
|
-
txMeta.defaultGasEstimates.maxFeePerGas = txMeta.txParams.maxFeePerGas;
|
|
168
|
-
txMeta.defaultGasEstimates.maxPriorityFeePerGas =
|
|
169
|
-
txMeta.txParams.maxPriorityFeePerGas;
|
|
170
|
-
txMeta.defaultGasEstimates.gasPrice = txMeta.txParams.gasPrice;
|
|
171
|
-
txMeta.defaultGasEstimates.estimateType = txMeta.userFeeLevel;
|
|
172
|
-
}
|
|
173
|
-
function getSuggestedGasFees(request) {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
const { eip1559, ethQuery, gasFeeFlows, getGasFeeEstimates, txMeta } = request;
|
|
176
|
-
if ((!eip1559 && txMeta.txParams.gasPrice) ||
|
|
177
|
-
(eip1559 &&
|
|
178
|
-
txMeta.txParams.maxFeePerGas &&
|
|
179
|
-
txMeta.txParams.maxPriorityFeePerGas)) {
|
|
180
|
-
return {};
|
|
181
|
-
}
|
|
182
|
-
const gasFeeFlow = (0, gas_flow_1.getGasFeeFlow)(txMeta, gasFeeFlows);
|
|
183
|
-
try {
|
|
184
|
-
const response = yield gasFeeFlow.getGasFees({
|
|
185
|
-
ethQuery,
|
|
186
|
-
getGasFeeControllerEstimates: getGasFeeEstimates,
|
|
187
|
-
transactionMeta: txMeta,
|
|
188
|
-
});
|
|
189
|
-
return response.estimates.medium;
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
log('Failed to get suggested gas fees', error);
|
|
193
|
-
}
|
|
194
|
-
const gasPriceDecimal = (yield (0, controller_utils_1.query)(ethQuery, 'gasPrice'));
|
|
195
|
-
const gasPrice = gasPriceDecimal
|
|
196
|
-
? (0, utils_1.add0x)(gasPriceDecimal.toString(16))
|
|
197
|
-
: undefined;
|
|
198
|
-
return { gasPrice };
|
|
199
|
-
});
|
|
200
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkZCQRDZ36js = require('../chunk-ZCQRDZ36.js');
|
|
5
|
+
require('../chunk-IC233ZQS.js');
|
|
6
|
+
require('../chunk-UGFBA4GV.js');
|
|
7
|
+
require('../chunk-H4M66BA3.js');
|
|
8
|
+
require('../chunk-RI6MVJJN.js');
|
|
9
|
+
require('../chunk-S6VGOPUY.js');
|
|
10
|
+
require('../chunk-HPNXIKFY.js');
|
|
11
|
+
require('../chunk-Z4BLTVTB.js');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.gweiDecimalToWeiHex = _chunkZCQRDZ36js.gweiDecimalToWeiHex; exports.updateGasFees = _chunkZCQRDZ36js.updateGasFees;
|
|
201
16
|
//# sourceMappingURL=gas-fees.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas-fees.js","sourceRoot":"","sources":["../../src/utils/gas-fees.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;;;;;;;;;;AAExC,iEAKoC;AAOpC,2CAA4D;AAE5D,sCAA0C;AAQ1C,oCAAwC;AACxC,yCAA2C;AAC3C,mCAAiD;AAyBjD,MAAM,GAAG,GAAG,IAAA,0BAAkB,EAAC,sBAAa,EAAE,UAAU,CAAC,CAAC;AAE1D,SAAsB,aAAa,CAAC,OAA6B;;QAC/D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3B,MAAM,aAAa,qBAAQ,MAAM,CAAC,QAAQ,CAAE,CAAC;QAE7C,MAAM,MAAM,GAAG,8BAAsB,CAAC,QAAQ,CAC5C,MAAM,CAAC,IAAuB,CAC/B,CAAC;QACF,MAAM,YAAY,GAAG,MAAM;YACzB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE5C,MAAM,gBAAgB,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAE5D,GAAG,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;QAE5C,MAAM,gBAAgB,mCACjB,OAAO,KACV,aAAa;YACb,YAAY;YACZ,gBAAgB,GACjB,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAEjE,MAAM,CAAC,QAAQ,CAAC,oBAAoB;YAClC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;QAE5C,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC;QACzD,MAAM,CAAC,YAAY,GAAG,eAAe,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AE,MAAM,EAAE,GAClE,OAAO,CAAC;QAEV,IACE,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACtC,CAAC,OAAO;gBACN,MAAM,CAAC,QAAQ,CAAC,YAAY;gBAC5B,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EACvC;YACA,OAAO,EAAE,CAAC;SACX;QAED,MAAM,UAAU,GAAG,IAAA,wBAAa,EAAC,MAAM,EAAE,WAAW,CAAe,CAAC;QAEpE,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC;gBAC3C,QAAQ;gBACR,4BAA4B,EAAE,kBAAkB;gBAChD,eAAe,EAAE,MAAM;aACxB,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC;SAClC;QAAC,OAAO,KAAK,EAAE;YACd,GAAG,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;SAChD;QAED,MAAM,eAAe,GAAG,CAAC,MAAM,IAAA,wBAAK,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAW,CAAC;QAEtE,MAAM,QAAQ,GAAG,eAAe;YAC9B,CAAC,CAAC,IAAA,aAAK,EAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACrC,CAAC,CAAC,SAAS,CAAC;QAEd,OAAO,EAAE,QAAQ,EAAE,CAAC;IACtB,CAAC;CAAA","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 { 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 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 response = await gasFeeFlow.getGasFees({\n ethQuery,\n getGasFeeControllerEstimates: getGasFeeEstimates,\n transactionMeta: txMeta,\n });\n\n return response.estimates.medium;\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"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
gweiDecimalToWeiHex,
|
|
3
|
+
updateGasFees
|
|
4
|
+
} from "../chunk-DQP6X25N.mjs";
|
|
5
|
+
import "../chunk-EQ3RRHB7.mjs";
|
|
6
|
+
import "../chunk-J56A7UCK.mjs";
|
|
7
|
+
import "../chunk-7MZ57ILQ.mjs";
|
|
8
|
+
import "../chunk-MHM5LRRF.mjs";
|
|
9
|
+
import "../chunk-UQQWZT6C.mjs";
|
|
10
|
+
import "../chunk-LM4NUNMT.mjs";
|
|
11
|
+
import "../chunk-XUI43LEZ.mjs";
|
|
12
|
+
export {
|
|
13
|
+
gweiDecimalToWeiHex,
|
|
14
|
+
updateGasFees
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=gas-fees.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/gas-flow.js
CHANGED
|
@@ -1,53 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* @param gasFeeFlows - The gas fee flows to search.
|
|
12
|
-
* @returns The first gas fee flow that matches the transaction, or undefined if none match.
|
|
13
|
-
*/
|
|
14
|
-
function getGasFeeFlow(transactionMeta, gasFeeFlows) {
|
|
15
|
-
return gasFeeFlows.find((gasFeeFlow) => gasFeeFlow.matchesTransaction(transactionMeta));
|
|
16
|
-
}
|
|
17
|
-
exports.getGasFeeFlow = getGasFeeFlow;
|
|
18
|
-
/**
|
|
19
|
-
* Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction.
|
|
20
|
-
* @param request - Data required to merge gas fee estimates.
|
|
21
|
-
* @param request.gasFeeControllerEstimateType - Gas fee estimate type from the gas fee controller.
|
|
22
|
-
* @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController.
|
|
23
|
-
* @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction.
|
|
24
|
-
* @returns The merged gas fee estimates.
|
|
25
|
-
*/
|
|
26
|
-
function mergeGasFeeEstimates({ gasFeeControllerEstimateType, gasFeeControllerEstimates, transactionGasFeeEstimates, }) {
|
|
27
|
-
if (gasFeeControllerEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) {
|
|
28
|
-
return Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: mergeFeeMarketEstimate(gasFeeControllerEstimates[level], transactionGasFeeEstimates[level]) })), Object.assign({}, gasFeeControllerEstimates));
|
|
29
|
-
}
|
|
30
|
-
if (gasFeeControllerEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.LEGACY) {
|
|
31
|
-
return Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: getLegacyEstimate(transactionGasFeeEstimates[level]) })), {});
|
|
32
|
-
}
|
|
33
|
-
return gasFeeControllerEstimates;
|
|
34
|
-
}
|
|
35
|
-
exports.mergeGasFeeEstimates = mergeGasFeeEstimates;
|
|
36
|
-
/**
|
|
37
|
-
* Merge a specific priority level of EIP-1559 gas fee estimates.
|
|
38
|
-
* @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller.
|
|
39
|
-
* @param transactionGasFeeEstimate - The gas fee estimate from the transaction.
|
|
40
|
-
* @returns The merged gas fee estimate.
|
|
41
|
-
*/
|
|
42
|
-
function mergeFeeMarketEstimate(gasFeeControllerEstimate, transactionGasFeeEstimate) {
|
|
43
|
-
return Object.assign(Object.assign({}, gasFeeControllerEstimate), { suggestedMaxFeePerGas: (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxFeePerGas), suggestedMaxPriorityFeePerGas: (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxPriorityFeePerGas) });
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Generate a specific priority level for a legacy gas fee estimate.
|
|
47
|
-
* @param transactionGasFeeEstimate - The gas fee estimate from the transaction.
|
|
48
|
-
* @returns The legacy gas fee estimate.
|
|
49
|
-
*/
|
|
50
|
-
function getLegacyEstimate(transactionGasFeeEstimate) {
|
|
51
|
-
return (0, controller_utils_1.weiHexToGweiDec)(transactionGasFeeEstimate.maxFeePerGas);
|
|
52
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkH4M66BA3js = require('../chunk-H4M66BA3.js');
|
|
5
|
+
require('../chunk-HPNXIKFY.js');
|
|
6
|
+
require('../chunk-Z4BLTVTB.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.getGasFeeFlow = _chunkH4M66BA3js.getGasFeeFlow; exports.mergeGasFeeEstimates = _chunkH4M66BA3js.mergeGasFeeEstimates;
|
|
53
11
|
//# sourceMappingURL=gas-flow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/gas.js
CHANGED
|
@@ -1,134 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.FIXED_GAS =
|
|
20
|
-
exports.DEFAULT_GAS_MULTIPLIER = 1.5;
|
|
21
|
-
function updateGas(request) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const { txMeta } = request;
|
|
24
|
-
const initialParams = Object.assign({}, txMeta.txParams);
|
|
25
|
-
const [gas, simulationFails] = yield getGas(request);
|
|
26
|
-
txMeta.txParams.gas = gas;
|
|
27
|
-
txMeta.simulationFails = simulationFails;
|
|
28
|
-
if (!initialParams.gas) {
|
|
29
|
-
txMeta.originalGasEstimate = txMeta.txParams.gas;
|
|
30
|
-
}
|
|
31
|
-
if (!txMeta.defaultGasEstimates) {
|
|
32
|
-
txMeta.defaultGasEstimates = {};
|
|
33
|
-
}
|
|
34
|
-
txMeta.defaultGasEstimates.gas = txMeta.txParams.gas;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
exports.updateGas = updateGas;
|
|
38
|
-
function estimateGas(txParams, ethQuery) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const request = Object.assign({}, txParams);
|
|
41
|
-
const { data, value } = request;
|
|
42
|
-
const { gasLimit: gasLimitHex, number: blockNumber } = yield getLatestBlock(ethQuery);
|
|
43
|
-
const gasLimitBN = (0, controller_utils_1.hexToBN)(gasLimitHex);
|
|
44
|
-
request.data = data ? (0, utils_1.add0x)(data) : data;
|
|
45
|
-
request.gas = (0, controller_utils_1.BNToHex)((0, controller_utils_1.fractionBN)(gasLimitBN, 19, 20));
|
|
46
|
-
request.value = value || '0x0';
|
|
47
|
-
let estimatedGas = request.gas;
|
|
48
|
-
let simulationFails;
|
|
49
|
-
try {
|
|
50
|
-
estimatedGas = yield (0, controller_utils_1.query)(ethQuery, 'estimateGas', [request]);
|
|
51
|
-
// TODO: Replace `any` with type
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
simulationFails = {
|
|
56
|
-
reason: error.message,
|
|
57
|
-
errorKey: error.errorKey,
|
|
58
|
-
debug: {
|
|
59
|
-
blockNumber,
|
|
60
|
-
blockGasLimit: gasLimitHex,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
(0, exports.log)('Estimation failed', Object.assign(Object.assign({}, simulationFails), { fallback: estimateGas }));
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
blockGasLimit: gasLimitHex,
|
|
67
|
-
estimatedGas,
|
|
68
|
-
simulationFails,
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
exports.estimateGas = estimateGas;
|
|
73
|
-
function addGasBuffer(estimatedGas, blockGasLimit, multiplier) {
|
|
74
|
-
const estimatedGasBN = (0, controller_utils_1.hexToBN)(estimatedGas);
|
|
75
|
-
const maxGasBN = (0, controller_utils_1.hexToBN)(blockGasLimit).muln(0.9);
|
|
76
|
-
const paddedGasBN = estimatedGasBN.muln(multiplier);
|
|
77
|
-
if (estimatedGasBN.gt(maxGasBN)) {
|
|
78
|
-
const estimatedGasHex = (0, utils_1.add0x)(estimatedGas);
|
|
79
|
-
(0, exports.log)('Using estimated value', estimatedGasHex);
|
|
80
|
-
return estimatedGasHex;
|
|
81
|
-
}
|
|
82
|
-
if (paddedGasBN.lt(maxGasBN)) {
|
|
83
|
-
const paddedHex = (0, utils_1.add0x)((0, controller_utils_1.BNToHex)(paddedGasBN));
|
|
84
|
-
(0, exports.log)('Using padded estimate', paddedHex, multiplier);
|
|
85
|
-
return paddedHex;
|
|
86
|
-
}
|
|
87
|
-
const maxHex = (0, utils_1.add0x)((0, controller_utils_1.BNToHex)(maxGasBN));
|
|
88
|
-
(0, exports.log)('Using 90% of block gas limit', maxHex);
|
|
89
|
-
return maxHex;
|
|
90
|
-
}
|
|
91
|
-
exports.addGasBuffer = addGasBuffer;
|
|
92
|
-
function getGas(request) {
|
|
93
|
-
var _a;
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const { isCustomNetwork, chainId, txMeta } = request;
|
|
96
|
-
if (txMeta.txParams.gas) {
|
|
97
|
-
(0, exports.log)('Using value from request', txMeta.txParams.gas);
|
|
98
|
-
return [txMeta.txParams.gas];
|
|
99
|
-
}
|
|
100
|
-
if (yield requiresFixedGas(request)) {
|
|
101
|
-
(0, exports.log)('Using fixed value', exports.FIXED_GAS);
|
|
102
|
-
return [exports.FIXED_GAS];
|
|
103
|
-
}
|
|
104
|
-
const { blockGasLimit, estimatedGas, simulationFails } = yield estimateGas(txMeta.txParams, request.ethQuery);
|
|
105
|
-
if (isCustomNetwork) {
|
|
106
|
-
(0, exports.log)('Using original estimate as custom network');
|
|
107
|
-
return [estimatedGas, simulationFails];
|
|
108
|
-
}
|
|
109
|
-
const bufferMultiplier = (_a = constants_1.GAS_BUFFER_CHAIN_OVERRIDES[chainId]) !== null && _a !== void 0 ? _a : exports.DEFAULT_GAS_MULTIPLIER;
|
|
110
|
-
const bufferedGas = addGasBuffer(estimatedGas, blockGasLimit, bufferMultiplier);
|
|
111
|
-
return [bufferedGas, simulationFails];
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
function requiresFixedGas({ ethQuery, txMeta, isCustomNetwork, }) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
const { txParams: { to, data }, } = txMeta;
|
|
117
|
-
if (isCustomNetwork || !to || data) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
const code = yield getCode(ethQuery, to);
|
|
121
|
-
return !code || code === '0x';
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function getCode(ethQuery, address) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
return yield (0, controller_utils_1.query)(ethQuery, 'getCode', [address]);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function getLatestBlock(ethQuery) {
|
|
130
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
return yield (0, controller_utils_1.query)(ethQuery, 'getBlockByNumber', ['latest', false]);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkIUBAETUHjs = require('../chunk-IUBAETUH.js');
|
|
9
|
+
require('../chunk-RI6MVJJN.js');
|
|
10
|
+
require('../chunk-S6VGOPUY.js');
|
|
11
|
+
require('../chunk-Z4BLTVTB.js');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.DEFAULT_GAS_MULTIPLIER = _chunkIUBAETUHjs.DEFAULT_GAS_MULTIPLIER; exports.FIXED_GAS = _chunkIUBAETUHjs.FIXED_GAS; exports.addGasBuffer = _chunkIUBAETUHjs.addGasBuffer; exports.estimateGas = _chunkIUBAETUHjs.estimateGas; exports.log = _chunkIUBAETUHjs.log; exports.updateGas = _chunkIUBAETUHjs.updateGas;
|
|
134
20
|
//# sourceMappingURL=gas.js.map
|
package/dist/utils/gas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_GAS_MULTIPLIER,
|
|
3
|
+
FIXED_GAS,
|
|
4
|
+
addGasBuffer,
|
|
5
|
+
estimateGas,
|
|
6
|
+
log,
|
|
7
|
+
updateGas
|
|
8
|
+
} from "../chunk-UKYY2RVS.mjs";
|
|
9
|
+
import "../chunk-MHM5LRRF.mjs";
|
|
10
|
+
import "../chunk-UQQWZT6C.mjs";
|
|
11
|
+
import "../chunk-XUI43LEZ.mjs";
|
|
12
|
+
export {
|
|
13
|
+
DEFAULT_GAS_MULTIPLIER,
|
|
14
|
+
FIXED_GAS,
|
|
15
|
+
addGasBuffer,
|
|
16
|
+
estimateGas,
|
|
17
|
+
log,
|
|
18
|
+
updateGas
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=gas.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|