@metamask/transaction-controller 23.1.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 +134 -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 -25
- 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} +8 -3
- 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/{utils → types/utils}/utils.d.ts +9 -1
- 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 -146
- 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}/validation.d.ts +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkZCQRDZ36js = require('./chunk-ZCQRDZ36.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkHPNXIKFYjs = require('./chunk-HPNXIKFY.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 _getEstimateLevel, getEstimateLevel_fn, _getFeeMarketLevel, getFeeMarketLevel_fn, _getLegacyLevel, getLegacyLevel_fn;
|
|
20
|
+
var DefaultGasFeeFlow = class {
|
|
21
|
+
constructor() {
|
|
22
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getEstimateLevel);
|
|
23
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getFeeMarketLevel);
|
|
24
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getLegacyLevel);
|
|
25
|
+
}
|
|
26
|
+
matchesTransaction(_transactionMeta) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
async getGasFees(request) {
|
|
30
|
+
const { getGasFeeControllerEstimates, transactionMeta } = request;
|
|
31
|
+
const { networkClientId } = transactionMeta;
|
|
32
|
+
const { gasEstimateType, gasFeeEstimates } = await getGasFeeControllerEstimates({ networkClientId });
|
|
33
|
+
if (gasEstimateType === _gasfeecontroller.GAS_ESTIMATE_TYPES.FEE_MARKET) {
|
|
34
|
+
log("Using fee market estimates", gasFeeEstimates);
|
|
35
|
+
} else if (gasEstimateType === _gasfeecontroller.GAS_ESTIMATE_TYPES.LEGACY) {
|
|
36
|
+
log("Using legacy estimates", gasFeeEstimates);
|
|
37
|
+
} else {
|
|
38
|
+
throw new Error(`'No gas fee estimates available`);
|
|
39
|
+
}
|
|
40
|
+
const estimates = Object.values(_chunkHPNXIKFYjs.GasFeeEstimateLevel).reduce(
|
|
41
|
+
(result, level) => ({
|
|
42
|
+
...result,
|
|
43
|
+
[level]: _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getEstimateLevel, getEstimateLevel_fn).call(this, {
|
|
44
|
+
gasEstimateType,
|
|
45
|
+
gasFeeEstimates,
|
|
46
|
+
level
|
|
47
|
+
})
|
|
48
|
+
}),
|
|
49
|
+
{}
|
|
50
|
+
);
|
|
51
|
+
return { estimates };
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
_getEstimateLevel = new WeakSet();
|
|
55
|
+
getEstimateLevel_fn = function({
|
|
56
|
+
gasEstimateType,
|
|
57
|
+
gasFeeEstimates,
|
|
58
|
+
level
|
|
59
|
+
}) {
|
|
60
|
+
if (gasEstimateType === _gasfeecontroller.GAS_ESTIMATE_TYPES.FEE_MARKET) {
|
|
61
|
+
return _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getFeeMarketLevel, getFeeMarketLevel_fn).call(this, gasFeeEstimates, level);
|
|
62
|
+
}
|
|
63
|
+
return _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLegacyLevel, getLegacyLevel_fn).call(this, gasFeeEstimates, level);
|
|
64
|
+
};
|
|
65
|
+
_getFeeMarketLevel = new WeakSet();
|
|
66
|
+
getFeeMarketLevel_fn = function(gasFeeEstimates, level) {
|
|
67
|
+
const maxFeePerGas = _chunkZCQRDZ36js.gweiDecimalToWeiHex.call(void 0,
|
|
68
|
+
gasFeeEstimates[level].suggestedMaxFeePerGas
|
|
69
|
+
);
|
|
70
|
+
const maxPriorityFeePerGas = _chunkZCQRDZ36js.gweiDecimalToWeiHex.call(void 0,
|
|
71
|
+
gasFeeEstimates[level].suggestedMaxPriorityFeePerGas
|
|
72
|
+
);
|
|
73
|
+
return {
|
|
74
|
+
maxFeePerGas,
|
|
75
|
+
maxPriorityFeePerGas
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
_getLegacyLevel = new WeakSet();
|
|
79
|
+
getLegacyLevel_fn = function(gasFeeEstimates, level) {
|
|
80
|
+
const gasPrice = _chunkZCQRDZ36js.gweiDecimalToWeiHex.call(void 0, gasFeeEstimates[level]);
|
|
81
|
+
return {
|
|
82
|
+
maxFeePerGas: gasPrice,
|
|
83
|
+
maxPriorityFeePerGas: gasPrice
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
exports.DefaultGasFeeFlow = DefaultGasFeeFlow;
|
|
90
|
+
//# sourceMappingURL=chunk-ZJLZSFOZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/gas-flows/DefaultGasFeeFlow.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AAcnC,IAAM,MAAM,mBAAmB,eAAe,sBAAsB;AAnBpE;AAoCO,IAAM,oBAAN,MAA8C;AAAA,EAA9C;AAmCL;AAcA;AAkBA;AAAA;AAAA,EAlEA,mBAAmB,kBAA4C;AAC7D,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,WAAW,SAAyD;AACxE,UAAM,EAAE,8BAA8B,gBAAgB,IAAI;AAC1D,UAAM,EAAE,gBAAgB,IAAI;AAE5B,UAAM,EAAE,iBAAiB,gBAAgB,IACvC,MAAM,6BAA6B,EAAE,gBAAgB,CAAC;AAExD,QAAI,oBAAoB,mBAAmB,YAAY;AACrD,UAAI,8BAA8B,eAAe;AAAA,IACnD,WAAW,oBAAoB,mBAAmB,QAAQ;AACxD,UAAI,0BAA0B,eAAe;AAAA,IAC/C,OAAO;AACL,YAAM,IAAI,MAAM,iCAAiC;AAAA,IACnD;AAEA,UAAM,YAAY,OAAO,OAAO,mBAAmB,EAAE;AAAA,MACnD,CAAC,QAAQ,WAAW;AAAA,QAClB,GAAG;AAAA,QACH,CAAC,KAAK,GAAG,sBAAK,wCAAL,WAAuB;AAAA,UAC9B;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,MACA,CAAC;AAAA,IACH;AAEA,WAAO,EAAE,UAAU;AAAA,EACrB;AA6CF;AA3CE;AAAA,sBAAiB,SAAC;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAE4D;AAC1D,MAAI,oBAAoB,mBAAmB,YAAY;AACrD,WAAO,sBAAK,0CAAL,WAAwB,iBAAiB;AAAA,EAClD;AAEA,SAAO,sBAAK,oCAAL,WAAqB,iBAAiB;AAC/C;AAEA;AAAA,uBAAkB,SAChB,iBACA,OACyB;AACzB,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,OACyB;AACzB,QAAM,WAAW,oBAAoB,gBAAgB,KAAK,CAAC;AAE3D,SAAO;AAAA,IACL,cAAc;AAAA,IACd,sBAAsB;AAAA,EACxB;AACF","sourcesContent":["import type {\n LegacyGasPriceEstimate,\n GasFeeEstimates as FeeMarketGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { GAS_ESTIMATE_TYPES } from '@metamask/gas-fee-controller';\nimport { createModuleLogger } from '@metamask/utils';\n\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeEstimatesForLevel,\n GasFeeFlow,\n GasFeeFlowRequest,\n GasFeeFlowResponse,\n TransactionMeta,\n} from '../types';\nimport { GasFeeEstimateLevel } from '../types';\nimport { gweiDecimalToWeiHex } from '../utils/gas-fees';\n\nconst log = createModuleLogger(projectLogger, 'default-gas-fee-flow');\n\ntype FeeMarketGetEstimateLevelRequest = {\n gasEstimateType: 'fee-market';\n gasFeeEstimates: FeeMarketGasPriceEstimate;\n level: GasFeeEstimateLevel;\n};\n\ntype LegacyGetEstimateLevelRequest = {\n gasEstimateType: 'legacy';\n gasFeeEstimates: LegacyGasPriceEstimate;\n level: GasFeeEstimateLevel;\n};\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 { getGasFeeControllerEstimates, transactionMeta } = request;\n const { networkClientId } = transactionMeta;\n\n const { gasEstimateType, gasFeeEstimates } =\n await getGasFeeControllerEstimates({ networkClientId });\n\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n log('Using fee market estimates', gasFeeEstimates);\n } else if (gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY) {\n log('Using legacy estimates', gasFeeEstimates);\n } else {\n throw new Error(`'No gas fee estimates available`);\n }\n\n const estimates = Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: this.#getEstimateLevel({\n gasEstimateType,\n gasFeeEstimates,\n level,\n } as FeeMarketGetEstimateLevelRequest | LegacyGetEstimateLevelRequest),\n }),\n {} as GasFeeEstimates,\n );\n\n return { estimates };\n }\n\n #getEstimateLevel({\n gasEstimateType,\n gasFeeEstimates,\n level,\n }:\n | FeeMarketGetEstimateLevelRequest\n | LegacyGetEstimateLevelRequest): GasFeeEstimatesForLevel {\n if (gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET) {\n return this.#getFeeMarketLevel(gasFeeEstimates, level);\n }\n\n return this.#getLegacyLevel(gasFeeEstimates, level);\n }\n\n #getFeeMarketLevel(\n gasFeeEstimates: FeeMarketGasPriceEstimate,\n level: GasFeeEstimateLevel,\n ): GasFeeEstimatesForLevel {\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 ): GasFeeEstimatesForLevel {\n const gasPrice = gweiDecimalToWeiHex(gasFeeEstimates[level]);\n\n return {\n maxFeePerGas: gasPrice,\n maxPriorityFeePerGas: gasPrice,\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
5
|
+
|
|
6
|
+
// src/utils/nonce.ts
|
|
7
|
+
var _controllerutils = require('@metamask/controller-utils');
|
|
8
|
+
var log = _chunkS6VGOPUYjs.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger, "nonce");
|
|
9
|
+
async function getNextNonce(txMeta, getNonceLock) {
|
|
10
|
+
const {
|
|
11
|
+
customNonceValue,
|
|
12
|
+
txParams: { from, nonce: existingNonce }
|
|
13
|
+
} = txMeta;
|
|
14
|
+
const customNonce = customNonceValue ? _controllerutils.toHex.call(void 0, customNonceValue) : void 0;
|
|
15
|
+
if (customNonce) {
|
|
16
|
+
log("Using custom nonce", customNonce);
|
|
17
|
+
return [customNonce, void 0];
|
|
18
|
+
}
|
|
19
|
+
if (existingNonce) {
|
|
20
|
+
log("Using existing nonce", existingNonce);
|
|
21
|
+
return [existingNonce, void 0];
|
|
22
|
+
}
|
|
23
|
+
const nonceLock = await getNonceLock(from);
|
|
24
|
+
const nonce = _controllerutils.toHex.call(void 0, nonceLock.nextNonce);
|
|
25
|
+
const releaseLock = nonceLock.releaseLock.bind(nonceLock);
|
|
26
|
+
log("Using nonce from nonce tracker", nonce, nonceLock.nonceDetails);
|
|
27
|
+
return [nonce, releaseLock];
|
|
28
|
+
}
|
|
29
|
+
function getAndFormatTransactionsForNonceTracker(currentChainId, fromAddress, transactionStatus, transactions) {
|
|
30
|
+
return transactions.filter(
|
|
31
|
+
({ chainId, isTransfer, isUserOperation, status, txParams: { from } }) => !isTransfer && !isUserOperation && chainId === currentChainId && status === transactionStatus && from.toLowerCase() === fromAddress.toLowerCase()
|
|
32
|
+
).map(({ status, txParams: { from, gas, value, nonce } }) => {
|
|
33
|
+
return {
|
|
34
|
+
status,
|
|
35
|
+
history: [{}],
|
|
36
|
+
txParams: {
|
|
37
|
+
from: from ?? "",
|
|
38
|
+
gas: gas ?? "",
|
|
39
|
+
value: value ?? "",
|
|
40
|
+
nonce: nonce ?? ""
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
exports.getNextNonce = getNextNonce; exports.getAndFormatTransactionsForNonceTracker = getAndFormatTransactionsForNonceTracker;
|
|
50
|
+
//# sourceMappingURL=chunk-ZNZEJDOE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/nonce.ts"],"names":[],"mappings":";;;;;;AAAA,SAAS,aAAa;AAStB,IAAM,MAAM,mBAAmB,eAAe,OAAO;AASrD,eAAsB,aACpB,QACA,cAC6C;AAC7C,QAAM;AAAA,IACJ;AAAA,IACA,UAAU,EAAE,MAAM,OAAO,cAAc;AAAA,EACzC,IAAI;AAEJ,QAAM,cAAc,mBAAmB,MAAM,gBAAgB,IAAI;AAEjE,MAAI,aAAa;AACf,QAAI,sBAAsB,WAAW;AACrC,WAAO,CAAC,aAAa,MAAS;AAAA,EAChC;AAEA,MAAI,eAAe;AACjB,QAAI,wBAAwB,aAAa;AACzC,WAAO,CAAC,eAAe,MAAS;AAAA,EAClC;AAEA,QAAM,YAAY,MAAM,aAAa,IAAI;AACzC,QAAM,QAAQ,MAAM,UAAU,SAAS;AACvC,QAAM,cAAc,UAAU,YAAY,KAAK,SAAS;AAExD,MAAI,kCAAkC,OAAO,UAAU,YAAY;AAEnE,SAAO,CAAC,OAAO,WAAW;AAC5B;AAWO,SAAS,wCACd,gBACA,aACA,mBACA,cAC2B;AAC3B,SAAO,aACJ;AAAA,IACC,CAAC,EAAE,SAAS,YAAY,iBAAiB,QAAQ,UAAU,EAAE,KAAK,EAAE,MAClE,CAAC,cACD,CAAC,mBACD,YAAY,kBACZ,WAAW,qBACX,KAAK,YAAY,MAAM,YAAY,YAAY;AAAA,EACnD,EACC,IAAI,CAAC,EAAE,QAAQ,UAAU,EAAE,MAAM,KAAK,OAAO,MAAM,EAAE,MAAM;AAK1D,WAAO;AAAA,MACL;AAAA,MACA,SAAS,CAAC,CAAC,CAAC;AAAA,MACZ,UAAU;AAAA,QACR,MAAM,QAAQ;AAAA,QACd,KAAK,OAAO;AAAA,QACZ,OAAO,SAAS;AAAA,QAChB,OAAO,SAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF,CAAC;AACL","sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport type {\n NonceLock,\n Transaction as NonceTrackerTransaction,\n} from 'nonce-tracker';\n\nimport { createModuleLogger, projectLogger } from '../logger';\nimport type { TransactionMeta, TransactionStatus } from '../types';\n\nconst log = createModuleLogger(projectLogger, 'nonce');\n\n/**\n * Determine the next nonce to be used for a transaction.\n *\n * @param txMeta - The transaction metadata.\n * @param getNonceLock - An anonymous function that acquires the nonce lock for an address\n * @returns The next hexadecimal nonce to be used for the given transaction, and optionally a function to release the nonce lock.\n */\nexport async function getNextNonce(\n txMeta: TransactionMeta,\n getNonceLock: (address: string) => Promise<NonceLock>,\n): Promise<[string, (() => void) | undefined]> {\n const {\n customNonceValue,\n txParams: { from, nonce: existingNonce },\n } = txMeta;\n\n const customNonce = customNonceValue ? toHex(customNonceValue) : undefined;\n\n if (customNonce) {\n log('Using custom nonce', customNonce);\n return [customNonce, undefined];\n }\n\n if (existingNonce) {\n log('Using existing nonce', existingNonce);\n return [existingNonce, undefined];\n }\n\n const nonceLock = await getNonceLock(from);\n const nonce = toHex(nonceLock.nextNonce);\n const releaseLock = nonceLock.releaseLock.bind(nonceLock);\n\n log('Using nonce from nonce tracker', nonce, nonceLock.nonceDetails);\n\n return [nonce, releaseLock];\n}\n\n/**\n * Filter and format transactions for the nonce tracker.\n *\n * @param currentChainId - Chain ID of the current network.\n * @param fromAddress - Address of the account from which the transactions to filter from are sent.\n * @param transactionStatus - Status of the transactions for which to filter.\n * @param transactions - Array of transactionMeta objects that have been prefiltered.\n * @returns Array of transactions formatted for the nonce tracker.\n */\nexport function getAndFormatTransactionsForNonceTracker(\n currentChainId: string,\n fromAddress: string,\n transactionStatus: TransactionStatus,\n transactions: TransactionMeta[],\n): NonceTrackerTransaction[] {\n return transactions\n .filter(\n ({ chainId, isTransfer, isUserOperation, status, txParams: { from } }) =>\n !isTransfer &&\n !isUserOperation &&\n chainId === currentChainId &&\n status === transactionStatus &&\n from.toLowerCase() === fromAddress.toLowerCase(),\n )\n .map(({ status, txParams: { from, gas, value, nonce } }) => {\n // the only value we care about is the nonce\n // but we need to return the other values to satisfy the type\n // TODO: refactor nonceTracker to not require this\n /* istanbul ignore next */\n return {\n status,\n history: [{}],\n txParams: {\n from: from ?? '',\n gas: gas ?? '',\n value: value ?? '',\n nonce: nonce ?? '',\n },\n };\n });\n}\n"]}
|
package/dist/constants.js
CHANGED
|
@@ -1,111 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
FANTOM_TESTNET: '0xfa2',
|
|
17
|
-
SEPOLIA: '0xaa36a7',
|
|
18
|
-
LINEA_GOERLI: '0xe704',
|
|
19
|
-
LINEA_MAINNET: '0xe708',
|
|
20
|
-
MOONBEAM: '0x504',
|
|
21
|
-
MOONBEAM_TESTNET: '0x507',
|
|
22
|
-
MOONRIVER: '0x505',
|
|
23
|
-
GNOSIS: '0x64',
|
|
24
|
-
ARBITRUM: '0xa4b1',
|
|
25
|
-
ZKSYNC_ERA: '0x144',
|
|
26
|
-
};
|
|
27
|
-
exports.DEFAULT_ETHERSCAN_DOMAIN = 'etherscan.io';
|
|
28
|
-
exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = 'api';
|
|
29
|
-
exports.ETHERSCAN_SUPPORTED_NETWORKS = {
|
|
30
|
-
[exports.CHAIN_IDS.GOERLI]: {
|
|
31
|
-
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
32
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,
|
|
33
|
-
},
|
|
34
|
-
[exports.CHAIN_IDS.MAINNET]: {
|
|
35
|
-
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
36
|
-
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
37
|
-
},
|
|
38
|
-
[exports.CHAIN_IDS.SEPOLIA]: {
|
|
39
|
-
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
40
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia`,
|
|
41
|
-
},
|
|
42
|
-
[exports.CHAIN_IDS.LINEA_GOERLI]: {
|
|
43
|
-
domain: 'lineascan.build',
|
|
44
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli`,
|
|
45
|
-
},
|
|
46
|
-
[exports.CHAIN_IDS.LINEA_MAINNET]: {
|
|
47
|
-
domain: 'lineascan.build',
|
|
48
|
-
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
49
|
-
},
|
|
50
|
-
[exports.CHAIN_IDS.BSC]: {
|
|
51
|
-
domain: 'bscscan.com',
|
|
52
|
-
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
53
|
-
},
|
|
54
|
-
[exports.CHAIN_IDS.BSC_TESTNET]: {
|
|
55
|
-
domain: 'bscscan.com',
|
|
56
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,
|
|
57
|
-
},
|
|
58
|
-
[exports.CHAIN_IDS.OPTIMISM]: {
|
|
59
|
-
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
60
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`,
|
|
61
|
-
},
|
|
62
|
-
[exports.CHAIN_IDS.OPTIMISM_TESTNET]: {
|
|
63
|
-
domain: exports.DEFAULT_ETHERSCAN_DOMAIN,
|
|
64
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`,
|
|
65
|
-
},
|
|
66
|
-
[exports.CHAIN_IDS.POLYGON]: {
|
|
67
|
-
domain: 'polygonscan.com',
|
|
68
|
-
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
69
|
-
},
|
|
70
|
-
[exports.CHAIN_IDS.POLYGON_TESTNET]: {
|
|
71
|
-
domain: 'polygonscan.com',
|
|
72
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-mumbai`,
|
|
73
|
-
},
|
|
74
|
-
[exports.CHAIN_IDS.AVALANCHE]: {
|
|
75
|
-
domain: 'snowtrace.io',
|
|
76
|
-
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
77
|
-
},
|
|
78
|
-
[exports.CHAIN_IDS.AVALANCHE_TESTNET]: {
|
|
79
|
-
domain: 'snowtrace.io',
|
|
80
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,
|
|
81
|
-
},
|
|
82
|
-
[exports.CHAIN_IDS.FANTOM]: {
|
|
83
|
-
domain: 'ftmscan.com',
|
|
84
|
-
subdomain: exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
85
|
-
},
|
|
86
|
-
[exports.CHAIN_IDS.FANTOM_TESTNET]: {
|
|
87
|
-
domain: 'ftmscan.com',
|
|
88
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-testnet`,
|
|
89
|
-
},
|
|
90
|
-
[exports.CHAIN_IDS.MOONBEAM]: {
|
|
91
|
-
domain: 'moonscan.io',
|
|
92
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbeam`,
|
|
93
|
-
},
|
|
94
|
-
[exports.CHAIN_IDS.MOONBEAM_TESTNET]: {
|
|
95
|
-
domain: 'moonscan.io',
|
|
96
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonbase`,
|
|
97
|
-
},
|
|
98
|
-
[exports.CHAIN_IDS.MOONRIVER]: {
|
|
99
|
-
domain: 'moonscan.io',
|
|
100
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-moonriver`,
|
|
101
|
-
},
|
|
102
|
-
[exports.CHAIN_IDS.GNOSIS]: {
|
|
103
|
-
domain: 'gnosisscan.io',
|
|
104
|
-
subdomain: `${exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-gnosis`,
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
exports.GAS_BUFFER_CHAIN_OVERRIDES = {
|
|
108
|
-
[exports.CHAIN_IDS.OPTIMISM]: 1,
|
|
109
|
-
[exports.CHAIN_IDS.OPTIMISM_TESTNET]: 1,
|
|
110
|
-
};
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkRI6MVJJNjs = require('./chunk-RI6MVJJN.js');
|
|
8
|
+
require('./chunk-Z4BLTVTB.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.CHAIN_IDS = _chunkRI6MVJJNjs.CHAIN_IDS; exports.DEFAULT_ETHERSCAN_DOMAIN = _chunkRI6MVJJNjs.DEFAULT_ETHERSCAN_DOMAIN; exports.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX = _chunkRI6MVJJNjs.DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX; exports.ETHERSCAN_SUPPORTED_NETWORKS = _chunkRI6MVJJNjs.ETHERSCAN_SUPPORTED_NETWORKS; exports.GAS_BUFFER_CHAIN_OVERRIDES = _chunkRI6MVJJNjs.GAS_BUFFER_CHAIN_OVERRIDES;
|
|
111
16
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHAIN_IDS,
|
|
3
|
+
DEFAULT_ETHERSCAN_DOMAIN,
|
|
4
|
+
DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
5
|
+
ETHERSCAN_SUPPORTED_NETWORKS,
|
|
6
|
+
GAS_BUFFER_CHAIN_OVERRIDES
|
|
7
|
+
} from "./chunk-MHM5LRRF.mjs";
|
|
8
|
+
import "./chunk-XUI43LEZ.mjs";
|
|
9
|
+
export {
|
|
10
|
+
CHAIN_IDS,
|
|
11
|
+
DEFAULT_ETHERSCAN_DOMAIN,
|
|
12
|
+
DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX,
|
|
13
|
+
ETHERSCAN_SUPPORTED_NETWORKS,
|
|
14
|
+
GAS_BUFFER_CHAIN_OVERRIDES
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,78 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
var _DefaultGasFeeFlow_instances, _DefaultGasFeeFlow_getEstimateLevel, _DefaultGasFeeFlow_getFeeMarketLevel, _DefaultGasFeeFlow_getLegacyLevel;
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.DefaultGasFeeFlow = void 0;
|
|
19
|
-
const gas_fee_controller_1 = require("@metamask/gas-fee-controller");
|
|
20
|
-
const utils_1 = require("@metamask/utils");
|
|
21
|
-
const logger_1 = require("../logger");
|
|
22
|
-
const types_1 = require("../types");
|
|
23
|
-
const gas_fees_1 = require("../utils/gas-fees");
|
|
24
|
-
const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'default-gas-fee-flow');
|
|
25
|
-
/**
|
|
26
|
-
* The standard implementation of a gas fee flow that obtains gas fee estimates using only the GasFeeController.
|
|
27
|
-
*/
|
|
28
|
-
class DefaultGasFeeFlow {
|
|
29
|
-
constructor() {
|
|
30
|
-
_DefaultGasFeeFlow_instances.add(this);
|
|
31
|
-
}
|
|
32
|
-
matchesTransaction(_transactionMeta) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
getGasFees(request) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const { getGasFeeControllerEstimates, transactionMeta } = request;
|
|
38
|
-
const { networkClientId } = transactionMeta;
|
|
39
|
-
const { gasEstimateType, gasFeeEstimates } = yield getGasFeeControllerEstimates({ networkClientId });
|
|
40
|
-
if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) {
|
|
41
|
-
log('Using fee market estimates', gasFeeEstimates);
|
|
42
|
-
}
|
|
43
|
-
else if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.LEGACY) {
|
|
44
|
-
log('Using legacy estimates', gasFeeEstimates);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
throw new Error(`'No gas fee estimates available`);
|
|
48
|
-
}
|
|
49
|
-
const estimates = Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getEstimateLevel).call(this, {
|
|
50
|
-
gasEstimateType,
|
|
51
|
-
gasFeeEstimates,
|
|
52
|
-
level,
|
|
53
|
-
}) })), {});
|
|
54
|
-
return { estimates };
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.DefaultGasFeeFlow = DefaultGasFeeFlow;
|
|
59
|
-
_DefaultGasFeeFlow_instances = new WeakSet(), _DefaultGasFeeFlow_getEstimateLevel = function _DefaultGasFeeFlow_getEstimateLevel({ gasEstimateType, gasFeeEstimates, level, }) {
|
|
60
|
-
if (gasEstimateType === gas_fee_controller_1.GAS_ESTIMATE_TYPES.FEE_MARKET) {
|
|
61
|
-
return __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getFeeMarketLevel).call(this, gasFeeEstimates, level);
|
|
62
|
-
}
|
|
63
|
-
return __classPrivateFieldGet(this, _DefaultGasFeeFlow_instances, "m", _DefaultGasFeeFlow_getLegacyLevel).call(this, gasFeeEstimates, level);
|
|
64
|
-
}, _DefaultGasFeeFlow_getFeeMarketLevel = function _DefaultGasFeeFlow_getFeeMarketLevel(gasFeeEstimates, level) {
|
|
65
|
-
const maxFeePerGas = (0, gas_fees_1.gweiDecimalToWeiHex)(gasFeeEstimates[level].suggestedMaxFeePerGas);
|
|
66
|
-
const maxPriorityFeePerGas = (0, gas_fees_1.gweiDecimalToWeiHex)(gasFeeEstimates[level].suggestedMaxPriorityFeePerGas);
|
|
67
|
-
return {
|
|
68
|
-
maxFeePerGas,
|
|
69
|
-
maxPriorityFeePerGas,
|
|
70
|
-
};
|
|
71
|
-
}, _DefaultGasFeeFlow_getLegacyLevel = function _DefaultGasFeeFlow_getLegacyLevel(gasFeeEstimates, level) {
|
|
72
|
-
const gasPrice = (0, gas_fees_1.gweiDecimalToWeiHex)(gasFeeEstimates[level]);
|
|
73
|
-
return {
|
|
74
|
-
maxFeePerGas: gasPrice,
|
|
75
|
-
maxPriorityFeePerGas: gasPrice,
|
|
76
|
-
};
|
|
77
|
-
};
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkZJLZSFOZjs = require('../chunk-ZJLZSFOZ.js');
|
|
4
|
+
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
|
+
exports.DefaultGasFeeFlow = _chunkZJLZSFOZjs.DefaultGasFeeFlow;
|
|
78
15
|
//# sourceMappingURL=DefaultGasFeeFlow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DefaultGasFeeFlow
|
|
3
|
+
} from "../chunk-FS7FRO7B.mjs";
|
|
4
|
+
import "../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
|
+
DefaultGasFeeFlow
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=DefaultGasFeeFlow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,111 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _LineaGasFeeFlow_instances, _LineaGasFeeFlow_getLineaGasFees, _LineaGasFeeFlow_getLineaResponse, _LineaGasFeeFlow_getValuesFromMultipliers, _LineaGasFeeFlow_getMaxFees, _LineaGasFeeFlow_feesToString;
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.LineaGasFeeFlow = void 0;
|
|
19
|
-
const controller_utils_1 = require("@metamask/controller-utils");
|
|
20
|
-
const utils_1 = require("@metamask/utils");
|
|
21
|
-
const logger_1 = require("../logger");
|
|
22
|
-
const types_1 = require("../types");
|
|
23
|
-
const DefaultGasFeeFlow_1 = require("./DefaultGasFeeFlow");
|
|
24
|
-
const log = (0, utils_1.createModuleLogger)(logger_1.projectLogger, 'linea-gas-fee-flow');
|
|
25
|
-
const LINEA_CHAIN_IDS = [
|
|
26
|
-
controller_utils_1.ChainId['linea-mainnet'],
|
|
27
|
-
controller_utils_1.ChainId['linea-goerli'],
|
|
28
|
-
];
|
|
29
|
-
const BASE_FEE_MULTIPLIERS = {
|
|
30
|
-
low: 1,
|
|
31
|
-
medium: 1.35,
|
|
32
|
-
high: 1.7,
|
|
33
|
-
};
|
|
34
|
-
const PRIORITY_FEE_MULTIPLIERS = {
|
|
35
|
-
low: 1,
|
|
36
|
-
medium: 1.05,
|
|
37
|
-
high: 1.1,
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Implementation of a gas fee flow specific to Linea networks that obtains gas fee estimates using:
|
|
41
|
-
* - The `linea_estimateGas` RPC method to obtain the base fee and lowest priority fee.
|
|
42
|
-
* - Static multipliers to increase the base and priority fees.
|
|
43
|
-
*/
|
|
44
|
-
class LineaGasFeeFlow {
|
|
45
|
-
constructor() {
|
|
46
|
-
_LineaGasFeeFlow_instances.add(this);
|
|
47
|
-
}
|
|
48
|
-
matchesTransaction(transactionMeta) {
|
|
49
|
-
return LINEA_CHAIN_IDS.includes(transactionMeta.chainId);
|
|
50
|
-
}
|
|
51
|
-
getGasFees(request) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
try {
|
|
54
|
-
return yield __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaGasFees).call(this, request);
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
log('Using default flow as fallback due to error', error);
|
|
58
|
-
return new DefaultGasFeeFlow_1.DefaultGasFeeFlow().getGasFees(request);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.LineaGasFeeFlow = LineaGasFeeFlow;
|
|
64
|
-
_LineaGasFeeFlow_instances = new WeakSet(), _LineaGasFeeFlow_getLineaGasFees = function _LineaGasFeeFlow_getLineaGasFees(request) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const { ethQuery, transactionMeta } = request;
|
|
67
|
-
const lineaResponse = yield __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getLineaResponse).call(this, transactionMeta, ethQuery);
|
|
68
|
-
log('Received Linea response', lineaResponse);
|
|
69
|
-
const baseFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.baseFeePerGas, BASE_FEE_MULTIPLIERS);
|
|
70
|
-
log('Generated base fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, baseFees));
|
|
71
|
-
const priorityFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getValuesFromMultipliers).call(this, lineaResponse.priorityFeePerGas, PRIORITY_FEE_MULTIPLIERS);
|
|
72
|
-
log('Generated priority fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, priorityFees));
|
|
73
|
-
const maxFees = __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_getMaxFees).call(this, baseFees, priorityFees);
|
|
74
|
-
log('Generated max fees', __classPrivateFieldGet(this, _LineaGasFeeFlow_instances, "m", _LineaGasFeeFlow_feesToString).call(this, maxFees));
|
|
75
|
-
const estimates = Object.values(types_1.GasFeeEstimateLevel).reduce((result, level) => (Object.assign(Object.assign({}, result), { [level]: {
|
|
76
|
-
maxFeePerGas: (0, controller_utils_1.toHex)(maxFees[level]),
|
|
77
|
-
maxPriorityFeePerGas: (0, controller_utils_1.toHex)(priorityFees[level]),
|
|
78
|
-
} })), {});
|
|
79
|
-
return { estimates };
|
|
80
|
-
});
|
|
81
|
-
}, _LineaGasFeeFlow_getLineaResponse = function _LineaGasFeeFlow_getLineaResponse(transactionMeta, ethQuery) {
|
|
82
|
-
return (0, controller_utils_1.query)(ethQuery, 'linea_estimateGas', [
|
|
83
|
-
{
|
|
84
|
-
from: transactionMeta.txParams.from,
|
|
85
|
-
to: transactionMeta.txParams.to,
|
|
86
|
-
value: transactionMeta.txParams.value,
|
|
87
|
-
input: transactionMeta.txParams.data,
|
|
88
|
-
// Required in request but no impact on response.
|
|
89
|
-
gasPrice: '0x100000000',
|
|
90
|
-
},
|
|
91
|
-
]);
|
|
92
|
-
}, _LineaGasFeeFlow_getValuesFromMultipliers = function _LineaGasFeeFlow_getValuesFromMultipliers(value, multipliers) {
|
|
93
|
-
const base = (0, controller_utils_1.hexToBN)(value);
|
|
94
|
-
const low = base.muln(multipliers.low);
|
|
95
|
-
const medium = base.muln(multipliers.medium);
|
|
96
|
-
const high = base.muln(multipliers.high);
|
|
97
|
-
return {
|
|
98
|
-
low,
|
|
99
|
-
medium,
|
|
100
|
-
high,
|
|
101
|
-
};
|
|
102
|
-
}, _LineaGasFeeFlow_getMaxFees = function _LineaGasFeeFlow_getMaxFees(baseFees, priorityFees) {
|
|
103
|
-
return {
|
|
104
|
-
low: baseFees.low.add(priorityFees.low),
|
|
105
|
-
medium: baseFees.medium.add(priorityFees.medium),
|
|
106
|
-
high: baseFees.high.add(priorityFees.high),
|
|
107
|
-
};
|
|
108
|
-
}, _LineaGasFeeFlow_feesToString = function _LineaGasFeeFlow_feesToString(fees) {
|
|
109
|
-
return Object.values(types_1.GasFeeEstimateLevel).map((level) => fees[level].toString(10));
|
|
110
|
-
};
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkI5YZ7QUKjs = require('../chunk-I5YZ7QUK.js');
|
|
4
|
+
require('../chunk-ZJLZSFOZ.js');
|
|
5
|
+
require('../chunk-ZCQRDZ36.js');
|
|
6
|
+
require('../chunk-IC233ZQS.js');
|
|
7
|
+
require('../chunk-UGFBA4GV.js');
|
|
8
|
+
require('../chunk-H4M66BA3.js');
|
|
9
|
+
require('../chunk-RI6MVJJN.js');
|
|
10
|
+
require('../chunk-S6VGOPUY.js');
|
|
11
|
+
require('../chunk-HPNXIKFY.js');
|
|
12
|
+
require('../chunk-Z4BLTVTB.js');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.LineaGasFeeFlow = _chunkI5YZ7QUKjs.LineaGasFeeFlow;
|
|
111
16
|
//# sourceMappingURL=LineaGasFeeFlow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LineaGasFeeFlow
|
|
3
|
+
} from "../chunk-UM4ORJ5B.mjs";
|
|
4
|
+
import "../chunk-FS7FRO7B.mjs";
|
|
5
|
+
import "../chunk-DQP6X25N.mjs";
|
|
6
|
+
import "../chunk-EQ3RRHB7.mjs";
|
|
7
|
+
import "../chunk-J56A7UCK.mjs";
|
|
8
|
+
import "../chunk-7MZ57ILQ.mjs";
|
|
9
|
+
import "../chunk-MHM5LRRF.mjs";
|
|
10
|
+
import "../chunk-UQQWZT6C.mjs";
|
|
11
|
+
import "../chunk-LM4NUNMT.mjs";
|
|
12
|
+
import "../chunk-XUI43LEZ.mjs";
|
|
13
|
+
export {
|
|
14
|
+
LineaGasFeeFlow
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=LineaGasFeeFlow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|