@metamask/transaction-controller 28.1.1 → 29.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 +28 -1
- package/dist/TransactionController.js +11 -10
- package/dist/TransactionController.mjs +10 -9
- package/dist/{chunk-LDXTSESK.mjs → chunk-4M7FHI4S.mjs} +20 -4
- package/dist/chunk-4M7FHI4S.mjs.map +1 -0
- package/dist/{chunk-FK7AP6SH.js → chunk-5C3CSQAD.js} +12 -5
- package/dist/{chunk-YEJJKWT2.mjs.map → chunk-5C3CSQAD.js.map} +1 -1
- package/dist/{chunk-V6UIRCOF.js → chunk-7DJO6UZA.js} +48 -13
- package/dist/chunk-7DJO6UZA.js.map +1 -0
- package/dist/{chunk-HQAADNXH.mjs → chunk-7TPXSDXL.mjs} +120 -34
- package/dist/chunk-7TPXSDXL.mjs.map +1 -0
- package/dist/{chunk-TWND5SFD.mjs → chunk-AGJNOOBN.mjs} +17 -12
- package/dist/chunk-AGJNOOBN.mjs.map +1 -0
- package/dist/{chunk-LNX4JTOL.js → chunk-DUFOYA4D.js} +7 -7
- package/dist/chunk-DUFOYA4D.js.map +1 -0
- package/dist/{chunk-UH7FNVKS.js → chunk-EMDU4XLM.js} +19 -14
- package/dist/chunk-EMDU4XLM.js.map +1 -0
- package/dist/chunk-FMRLPVFZ.mjs +66 -0
- package/dist/chunk-FMRLPVFZ.mjs.map +1 -0
- package/dist/{chunk-EQNKFFTM.js → chunk-KNYSD4JP.js} +21 -5
- package/dist/chunk-KNYSD4JP.js.map +1 -0
- package/dist/{chunk-FMCTVRU2.js → chunk-N55SEKK7.js} +123 -37
- package/dist/chunk-N55SEKK7.js.map +1 -0
- package/dist/{chunk-YEJJKWT2.mjs → chunk-N6JXPWLY.mjs} +11 -4
- package/dist/chunk-N6JXPWLY.mjs.map +1 -0
- package/dist/chunk-REOG6YD4.mjs +112 -0
- package/dist/chunk-REOG6YD4.mjs.map +1 -0
- package/dist/{chunk-HHK4QSNF.mjs → chunk-SL3GHHKG.mjs} +47 -12
- package/dist/chunk-SL3GHHKG.mjs.map +1 -0
- package/dist/chunk-TJMQEH57.js +66 -0
- package/dist/chunk-TJMQEH57.js.map +1 -0
- package/dist/chunk-VJYFB7BM.js +112 -0
- package/dist/chunk-VJYFB7BM.js.map +1 -0
- package/dist/{chunk-NCRWKI6Y.mjs → chunk-XL3HBKDE.mjs} +4 -4
- package/dist/chunk-XL3HBKDE.mjs.map +1 -0
- package/dist/errors.js +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.js +5 -5
- package/dist/gas-flows/DefaultGasFeeFlow.mjs +4 -4
- package/dist/gas-flows/LineaGasFeeFlow.js +6 -6
- package/dist/gas-flows/LineaGasFeeFlow.mjs +5 -5
- package/dist/gas-flows/TestGasFeeFlow.js +9 -0
- package/dist/gas-flows/TestGasFeeFlow.js.map +1 -0
- package/dist/gas-flows/TestGasFeeFlow.mjs +9 -0
- package/dist/gas-flows/TestGasFeeFlow.mjs.map +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.js +1 -1
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +1 -1
- package/dist/helpers/GasFeePoller.js +4 -4
- package/dist/helpers/GasFeePoller.mjs +3 -3
- package/dist/helpers/MultichainTrackingHelper.js +1 -1
- package/dist/helpers/MultichainTrackingHelper.mjs +1 -1
- package/dist/helpers/PendingTransactionTracker.js +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +1 -1
- package/dist/index.js +15 -10
- package/dist/index.mjs +14 -9
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/TransactionController.d.ts +12 -5
- package/dist/types/TransactionController.d.ts.map +1 -1
- package/dist/types/gas-flows/DefaultGasFeeFlow.d.ts.map +1 -1
- package/dist/types/gas-flows/TestGasFeeFlow.d.ts +12 -0
- package/dist/types/gas-flows/TestGasFeeFlow.d.ts.map +1 -0
- package/dist/types/helpers/GasFeePoller.d.ts +5 -3
- package/dist/types/helpers/GasFeePoller.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +36 -18
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/gas-flow.d.ts +8 -14
- package/dist/types/utils/gas-flow.d.ts.map +1 -1
- package/dist/types.js +4 -2
- package/dist/types.mjs +3 -1
- package/dist/utils/external-transactions.js +1 -1
- package/dist/utils/external-transactions.mjs +1 -1
- package/dist/utils/gas-fees.js +4 -4
- package/dist/utils/gas-fees.mjs +3 -3
- package/dist/utils/gas-flow.js +3 -3
- package/dist/utils/gas-flow.mjs +2 -2
- package/dist/utils/simulation-api.js +1 -1
- package/dist/utils/simulation-api.mjs +1 -1
- package/dist/utils/simulation.js +1 -1
- package/dist/utils/simulation.mjs +1 -1
- package/dist/utils/swaps.js +1 -1
- package/dist/utils/swaps.mjs +1 -1
- package/dist/utils/transaction-type.js +1 -1
- package/dist/utils/transaction-type.mjs +1 -1
- package/dist/utils/utils.js +1 -1
- package/dist/utils/utils.mjs +1 -1
- package/dist/utils/validation.js +1 -1
- package/dist/utils/validation.mjs +1 -1
- package/package.json +4 -4
- package/dist/chunk-4RJXBKSR.js +0 -90
- package/dist/chunk-4RJXBKSR.js.map +0 -1
- package/dist/chunk-EQNKFFTM.js.map +0 -1
- package/dist/chunk-FK7AP6SH.js.map +0 -1
- package/dist/chunk-FMCTVRU2.js.map +0 -1
- package/dist/chunk-HHK4QSNF.mjs.map +0 -1
- package/dist/chunk-HQAADNXH.mjs.map +0 -1
- package/dist/chunk-LDXTSESK.mjs.map +0 -1
- package/dist/chunk-LNX4JTOL.js.map +0 -1
- package/dist/chunk-NCRWKI6Y.mjs.map +0 -1
- package/dist/chunk-NPEXNXSY.mjs +0 -90
- package/dist/chunk-NPEXNXSY.mjs.map +0 -1
- package/dist/chunk-TWND5SFD.mjs.map +0 -1
- package/dist/chunk-UH7FNVKS.js.map +0 -1
- package/dist/chunk-V6UIRCOF.js.map +0 -1
|
@@ -1,43 +1,45 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5C3CSQADjs = require('./chunk-5C3CSQAD.js');
|
|
4
4
|
|
|
5
5
|
// src/utils/gas-flow.ts
|
|
6
6
|
var _controllerutils = require('@metamask/controller-utils');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _gasfeecontroller = require('@metamask/gas-fee-controller');
|
|
10
7
|
function getGasFeeFlow(transactionMeta, gasFeeFlows) {
|
|
11
8
|
return gasFeeFlows.find(
|
|
12
9
|
(gasFeeFlow) => gasFeeFlow.matchesTransaction(transactionMeta)
|
|
13
10
|
);
|
|
14
11
|
}
|
|
15
12
|
function mergeGasFeeEstimates({
|
|
16
|
-
gasFeeControllerEstimateType,
|
|
17
13
|
gasFeeControllerEstimates,
|
|
18
14
|
transactionGasFeeEstimates
|
|
19
15
|
}) {
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const transactionEstimateType = transactionGasFeeEstimates.type;
|
|
17
|
+
if (transactionEstimateType === "fee-market" /* FeeMarket */) {
|
|
18
|
+
return Object.values(_chunk5C3CSQADjs.GasFeeEstimateLevel).reduce(
|
|
22
19
|
(result, level) => ({
|
|
23
20
|
...result,
|
|
24
21
|
[level]: mergeFeeMarketEstimate(
|
|
25
|
-
gasFeeControllerEstimates[level],
|
|
22
|
+
gasFeeControllerEstimates?.[level],
|
|
26
23
|
transactionGasFeeEstimates[level]
|
|
27
24
|
)
|
|
28
25
|
}),
|
|
29
26
|
{ ...gasFeeControllerEstimates }
|
|
30
27
|
);
|
|
31
28
|
}
|
|
32
|
-
if (
|
|
33
|
-
return Object.values(
|
|
29
|
+
if (transactionEstimateType === "legacy" /* Legacy */) {
|
|
30
|
+
return Object.values(_chunk5C3CSQADjs.GasFeeEstimateLevel).reduce(
|
|
34
31
|
(result, level) => ({
|
|
35
32
|
...result,
|
|
36
|
-
[level]: getLegacyEstimate(transactionGasFeeEstimates
|
|
33
|
+
[level]: getLegacyEstimate(transactionGasFeeEstimates, level)
|
|
37
34
|
}),
|
|
38
35
|
{}
|
|
39
36
|
);
|
|
40
37
|
}
|
|
38
|
+
if (transactionEstimateType === "eth_gasPrice" /* GasPrice */) {
|
|
39
|
+
return {
|
|
40
|
+
gasPrice: getGasPriceEstimate(transactionGasFeeEstimates)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
41
43
|
return gasFeeControllerEstimates;
|
|
42
44
|
}
|
|
43
45
|
function mergeFeeMarketEstimate(gasFeeControllerEstimate, transactionGasFeeEstimate) {
|
|
@@ -51,12 +53,15 @@ function mergeFeeMarketEstimate(gasFeeControllerEstimate, transactionGasFeeEstim
|
|
|
51
53
|
)
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
|
-
function getLegacyEstimate(transactionGasFeeEstimate) {
|
|
55
|
-
return _controllerutils.weiHexToGweiDec.call(void 0, transactionGasFeeEstimate
|
|
56
|
+
function getLegacyEstimate(transactionGasFeeEstimate, level) {
|
|
57
|
+
return _controllerutils.weiHexToGweiDec.call(void 0, transactionGasFeeEstimate[level]);
|
|
58
|
+
}
|
|
59
|
+
function getGasPriceEstimate(transactionGasFeeEstimate) {
|
|
60
|
+
return _controllerutils.weiHexToGweiDec.call(void 0, transactionGasFeeEstimate.gasPrice);
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
|
|
59
64
|
|
|
60
65
|
|
|
61
66
|
exports.getGasFeeFlow = getGasFeeFlow; exports.mergeGasFeeEstimates = mergeGasFeeEstimates;
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
67
|
+
//# sourceMappingURL=chunk-EMDU4XLM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/gas-flow.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,uBAAuB;AAwCzB,SAAS,cACd,iBACA,aACwB;AACxB,SAAO,YAAY;AAAA,IAAK,CAAC,eACvB,WAAW,mBAAmB,eAAe;AAAA,EAC/C;AACF;AASO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AACF,GAAgE;AAC9D,QAAM,0BAA0B,2BAA2B;AAE3D,MAAI,0DAA0D;AAC5D,WAAO,OAAO,OAAO,mBAAmB,EAAE;AAAA,MACxC,CAAC,QAAQ,WAAW;AAAA,QAClB,GAAG;AAAA,QACH,CAAC,KAAK,GAAG;AAAA,UACN,4BAAgD,KAAK;AAAA,UACtD,2BAA2B,KAAK;AAAA,QAClC;AAAA,MACF;AAAA,MACA,EAAE,GAAG,0BAA0B;AAAA,IACjC;AAAA,EACF;AAEA,MAAI,mDAAuD;AACzD,WAAO,OAAO,OAAO,mBAAmB,EAAE;AAAA,MACxC,CAAC,QAAQ,WAAW;AAAA,QAClB,GAAG;AAAA,QACH,CAAC,KAAK,GAAG,kBAAkB,4BAA4B,KAAK;AAAA,MAC9D;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,2DAAyD;AAC3D,WAAO;AAAA,MACL,UAAU,oBAAoB,0BAA0B;AAAA,IAC1D;AAAA,EACF;AAEA,SAAO;AACT;AAQA,SAAS,uBACP,0BACA,2BACe;AACf,SAAO;AAAA,IACL,GAAG;AAAA,IACH,uBAAuB;AAAA,MACrB,0BAA0B;AAAA,IAC5B;AAAA,IACA,+BAA+B;AAAA,MAC7B,0BAA0B;AAAA,IAC5B;AAAA,EACF;AACF;AAQA,SAAS,kBACP,2BACA,OACQ;AACR,SAAO,gBAAgB,0BAA0B,KAAK,CAAC;AACzD;AAOA,SAAS,oBACP,2BACQ;AACR,SAAO,gBAAgB,0BAA0B,QAAQ;AAC3D","sourcesContent":["import { weiHexToGweiDec } from '@metamask/controller-utils';\nimport type {\n Eip1559GasFee,\n EthGasPriceEstimate,\n GasFeeEstimates,\n LegacyGasPriceEstimate,\n} from '@metamask/gas-fee-controller';\nimport { type GasFeeState } from '@metamask/gas-fee-controller';\n\nimport type {\n FeeMarketGasFeeEstimates,\n GasPriceGasFeeEstimates,\n LegacyGasFeeEstimates,\n} from '../types';\nimport {\n type GasFeeFlow,\n type TransactionMeta,\n type FeeMarketGasFeeEstimateForLevel,\n GasFeeEstimateLevel,\n GasFeeEstimateType,\n} from '../types';\n\ntype MergeGasFeeEstimatesRequest = {\n gasFeeControllerEstimates:\n | GasFeeEstimates\n | LegacyGasPriceEstimate\n | EthGasPriceEstimate;\n transactionGasFeeEstimates:\n | FeeMarketGasFeeEstimates\n | LegacyGasFeeEstimates\n | GasPriceGasFeeEstimates;\n};\n\n/**\n * Returns the first gas fee flow that matches the transaction.\n *\n * @param transactionMeta - The transaction metadata to find a gas fee flow for.\n * @param gasFeeFlows - The gas fee flows to search.\n * @returns The first gas fee flow that matches the transaction, or undefined if none match.\n */\nexport function getGasFeeFlow(\n transactionMeta: TransactionMeta,\n gasFeeFlows: GasFeeFlow[],\n): GasFeeFlow | undefined {\n return gasFeeFlows.find((gasFeeFlow) =>\n gasFeeFlow.matchesTransaction(transactionMeta),\n );\n}\n\n/**\n * Merge the gas fee estimates from the gas fee controller with the gas fee estimates from a transaction.\n * @param request - Data required to merge gas fee estimates.\n * @param request.gasFeeControllerEstimates - Gas fee estimates from the GasFeeController.\n * @param request.transactionGasFeeEstimates - Gas fee estimates from the transaction.\n * @returns The merged gas fee estimates.\n */\nexport function mergeGasFeeEstimates({\n gasFeeControllerEstimates,\n transactionGasFeeEstimates,\n}: MergeGasFeeEstimatesRequest): GasFeeState['gasFeeEstimates'] {\n const transactionEstimateType = transactionGasFeeEstimates.type;\n\n if (transactionEstimateType === GasFeeEstimateType.FeeMarket) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: mergeFeeMarketEstimate(\n (gasFeeControllerEstimates as GasFeeEstimates)?.[level],\n transactionGasFeeEstimates[level],\n ),\n }),\n { ...gasFeeControllerEstimates } as GasFeeEstimates,\n );\n }\n\n if (transactionEstimateType === GasFeeEstimateType.Legacy) {\n return Object.values(GasFeeEstimateLevel).reduce(\n (result, level) => ({\n ...result,\n [level]: getLegacyEstimate(transactionGasFeeEstimates, level),\n }),\n {} as LegacyGasPriceEstimate,\n );\n }\n\n if (transactionEstimateType === GasFeeEstimateType.GasPrice) {\n return {\n gasPrice: getGasPriceEstimate(transactionGasFeeEstimates),\n };\n }\n\n return gasFeeControllerEstimates;\n}\n\n/**\n * Merge a specific priority level of EIP-1559 gas fee estimates.\n * @param gasFeeControllerEstimate - The gas fee estimate from the gas fee controller.\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The merged gas fee estimate.\n */\nfunction mergeFeeMarketEstimate(\n gasFeeControllerEstimate: Eip1559GasFee | undefined,\n transactionGasFeeEstimate: FeeMarketGasFeeEstimateForLevel,\n): Eip1559GasFee {\n return {\n ...gasFeeControllerEstimate,\n suggestedMaxFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxFeePerGas,\n ),\n suggestedMaxPriorityFeePerGas: weiHexToGweiDec(\n transactionGasFeeEstimate.maxPriorityFeePerGas,\n ),\n } as Eip1559GasFee;\n}\n\n/**\n * Generate a specific priority level for a legacy gas fee estimate.\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @param level - The gas fee estimate level.\n * @returns The legacy gas fee estimate.\n */\nfunction getLegacyEstimate(\n transactionGasFeeEstimate: LegacyGasFeeEstimates,\n level: GasFeeEstimateLevel,\n): string {\n return weiHexToGweiDec(transactionGasFeeEstimate[level]);\n}\n\n/**\n * Generate the value for a gas price gas fee estimate.\n * @param transactionGasFeeEstimate - The gas fee estimate from the transaction.\n * @returns The legacy gas fee estimate.\n */\nfunction getGasPriceEstimate(\n transactionGasFeeEstimate: GasPriceGasFeeEstimates,\n): string {\n return weiHexToGweiDec(transactionGasFeeEstimate.gasPrice);\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__privateAdd,
|
|
3
|
+
__privateGet,
|
|
4
|
+
__privateMethod,
|
|
5
|
+
__privateSet
|
|
6
|
+
} from "./chunk-XUI43LEZ.mjs";
|
|
7
|
+
|
|
8
|
+
// src/gas-flows/TestGasFeeFlow.ts
|
|
9
|
+
import { toHex } from "@metamask/controller-utils";
|
|
10
|
+
var INCREMENT = 1e15;
|
|
11
|
+
var LEVEL_DIFFERENCE = 0.5;
|
|
12
|
+
var _counter, _getValueForTotalFee, getValueForTotalFee_fn;
|
|
13
|
+
var TestGasFeeFlow = class {
|
|
14
|
+
constructor() {
|
|
15
|
+
__privateAdd(this, _getValueForTotalFee);
|
|
16
|
+
__privateAdd(this, _counter, 1);
|
|
17
|
+
}
|
|
18
|
+
matchesTransaction(_transactionMeta) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
async getGasFees(request) {
|
|
22
|
+
const { transactionMeta } = request;
|
|
23
|
+
const { txParams } = transactionMeta;
|
|
24
|
+
const { gas: gasHex } = txParams;
|
|
25
|
+
if (!gasHex) {
|
|
26
|
+
throw new Error("Cannot estimate fee without gas value");
|
|
27
|
+
}
|
|
28
|
+
const gasDecimal = parseInt(gasHex, 16);
|
|
29
|
+
const difference = INCREMENT * LEVEL_DIFFERENCE;
|
|
30
|
+
const mediumMaxTarget = (__privateGet(this, _counter) + 1) * INCREMENT;
|
|
31
|
+
const mediumPriorityTarget = __privateGet(this, _counter) * INCREMENT;
|
|
32
|
+
const lowMaxTarget = mediumMaxTarget - difference;
|
|
33
|
+
const lowPriorityTarget = mediumPriorityTarget - difference;
|
|
34
|
+
const highMaxTarget = mediumMaxTarget + difference;
|
|
35
|
+
const highPriorityTarget = mediumPriorityTarget + difference;
|
|
36
|
+
__privateSet(this, _counter, __privateGet(this, _counter) + 1);
|
|
37
|
+
return {
|
|
38
|
+
estimates: {
|
|
39
|
+
type: "fee-market" /* FeeMarket */,
|
|
40
|
+
low: {
|
|
41
|
+
maxFeePerGas: __privateMethod(this, _getValueForTotalFee, getValueForTotalFee_fn).call(this, lowMaxTarget, gasDecimal),
|
|
42
|
+
maxPriorityFeePerGas: __privateMethod(this, _getValueForTotalFee, getValueForTotalFee_fn).call(this, lowPriorityTarget, gasDecimal)
|
|
43
|
+
},
|
|
44
|
+
medium: {
|
|
45
|
+
maxFeePerGas: __privateMethod(this, _getValueForTotalFee, getValueForTotalFee_fn).call(this, mediumMaxTarget, gasDecimal),
|
|
46
|
+
maxPriorityFeePerGas: __privateMethod(this, _getValueForTotalFee, getValueForTotalFee_fn).call(this, mediumPriorityTarget, gasDecimal)
|
|
47
|
+
},
|
|
48
|
+
high: {
|
|
49
|
+
maxFeePerGas: __privateMethod(this, _getValueForTotalFee, getValueForTotalFee_fn).call(this, highMaxTarget, gasDecimal),
|
|
50
|
+
maxPriorityFeePerGas: __privateMethod(this, _getValueForTotalFee, getValueForTotalFee_fn).call(this, highPriorityTarget, gasDecimal)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
_counter = new WeakMap();
|
|
57
|
+
_getValueForTotalFee = new WeakSet();
|
|
58
|
+
getValueForTotalFee_fn = function(totalFee, gas) {
|
|
59
|
+
const feeDecimal = Math.ceil(totalFee / gas);
|
|
60
|
+
return toHex(feeDecimal);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
TestGasFeeFlow
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=chunk-FMRLPVFZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/gas-flows/TestGasFeeFlow.ts"],"sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport {\n GasFeeEstimateType,\n type GasFeeFlow,\n type GasFeeFlowRequest,\n type GasFeeFlowResponse,\n type TransactionMeta,\n} from '../types';\n\nconst INCREMENT = 1e15; // 0.001 ETH\nconst LEVEL_DIFFERENCE = 0.5;\n\n/**\n * A gas fee flow to facilitate testing in the clients.\n * Increments the total gas fee by a fixed amount each time it is called.\n * Relies on the transaction's gas value to generate a distinct total fee in the UI.\n */\nexport class TestGasFeeFlow implements GasFeeFlow {\n #counter = 1;\n\n matchesTransaction(_transactionMeta: TransactionMeta): boolean {\n return true;\n }\n\n async getGasFees(request: GasFeeFlowRequest): Promise<GasFeeFlowResponse> {\n const { transactionMeta } = request;\n const { txParams } = transactionMeta;\n const { gas: gasHex } = txParams;\n\n if (!gasHex) {\n throw new Error('Cannot estimate fee without gas value');\n }\n\n const gasDecimal = parseInt(gasHex, 16);\n const difference = INCREMENT * LEVEL_DIFFERENCE;\n\n const mediumMaxTarget = (this.#counter + 1) * INCREMENT;\n const mediumPriorityTarget = this.#counter * INCREMENT;\n\n const lowMaxTarget = mediumMaxTarget - difference;\n const lowPriorityTarget = mediumPriorityTarget - difference;\n\n const highMaxTarget = mediumMaxTarget + difference;\n const highPriorityTarget = mediumPriorityTarget + difference;\n\n this.#counter += 1;\n\n return {\n estimates: {\n type: GasFeeEstimateType.FeeMarket,\n low: {\n maxFeePerGas: this.#getValueForTotalFee(lowMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n lowPriorityTarget,\n gasDecimal,\n ),\n },\n medium: {\n maxFeePerGas: this.#getValueForTotalFee(mediumMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n mediumPriorityTarget,\n gasDecimal,\n ),\n },\n high: {\n maxFeePerGas: this.#getValueForTotalFee(highMaxTarget, gasDecimal),\n maxPriorityFeePerGas: this.#getValueForTotalFee(\n highPriorityTarget,\n gasDecimal,\n ),\n },\n },\n };\n }\n\n #getValueForTotalFee(totalFee: number, gas: number): Hex {\n const feeDecimal = Math.ceil(totalFee / gas);\n return toHex(feeDecimal);\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,aAAa;AAWtB,IAAM,YAAY;AAClB,IAAM,mBAAmB;AAZzB;AAmBO,IAAM,iBAAN,MAA2C;A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.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkEMDU4XLMjs = require('./chunk-EMDU4XLM.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -182,17 +182,33 @@ function updateDefaultGasEstimates(txMeta) {
|
|
|
182
182
|
}
|
|
183
183
|
async function getSuggestedGasFees(request) {
|
|
184
184
|
const { eip1559, ethQuery, gasFeeFlows, getGasFeeEstimates, txMeta } = request;
|
|
185
|
+
const { networkClientId } = txMeta;
|
|
185
186
|
if (!eip1559 && txMeta.txParams.gasPrice || eip1559 && txMeta.txParams.maxFeePerGas && txMeta.txParams.maxPriorityFeePerGas) {
|
|
186
187
|
return {};
|
|
187
188
|
}
|
|
188
|
-
const gasFeeFlow =
|
|
189
|
+
const gasFeeFlow = _chunkEMDU4XLMjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
|
|
189
190
|
try {
|
|
191
|
+
const gasFeeControllerData = await getGasFeeEstimates({ networkClientId });
|
|
190
192
|
const response = await gasFeeFlow.getGasFees({
|
|
191
193
|
ethQuery,
|
|
192
|
-
|
|
194
|
+
gasFeeControllerData,
|
|
193
195
|
transactionMeta: txMeta
|
|
194
196
|
});
|
|
195
|
-
|
|
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
|
+
`Unsupported gas fee estimate type returned from flow: ${gasFeeEstimateType}`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
196
212
|
} catch (error) {
|
|
197
213
|
log("Failed to get suggested gas fees", error);
|
|
198
214
|
}
|
|
@@ -205,4 +221,4 @@ async function getSuggestedGasFees(request) {
|
|
|
205
221
|
|
|
206
222
|
|
|
207
223
|
exports.updateGasFees = updateGasFees; exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
224
|
+
//# sourceMappingURL=chunk-KNYSD4JP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/gas-fees.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,SAAS,OAAO,0BAA0B;AAqC1C,IAAM,MAAM,mBAAmB,eAAe,UAAU;AAExD,eAAsB,cAAc,SAA+B;AACjE,QAAM,EAAE,OAAO,IAAI;AACnB,QAAM,gBAAgB,EAAE,GAAG,OAAO,SAAS;AAE3C,QAAM,SAAS,uBAAuB;AAAA,IACpC,OAAO;AAAA,EACT;AACA,QAAM,eAAe,SACjB,SACA,QAAQ,gBAAgB,OAAO,OAAO;AAE1C,QAAM,mBAAmB,MAAM,oBAAoB,OAAO;AAE1D,MAAI,sBAAsB,gBAAgB;AAE1C,QAAM,mBAAqC;AAAA,IACzC,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,SAAS,eAAe,gBAAgB,gBAAgB;AAE/D,SAAO,SAAS,uBACd,wBAAwB,gBAAgB;AAE1C,SAAO,SAAS,WAAW,YAAY,gBAAgB;AACvD,SAAO,eAAe,gBAAgB,gBAAgB;AAEtD,MAAI,8BAA8B;AAAA,IAChC,cAAc,OAAO,SAAS;AAAA,IAC9B,sBAAsB,OAAO,SAAS;AAAA,IACtC,UAAU,OAAO,SAAS;AAAA,EAC5B,CAAC;AAED,MAAI,OAAO,SAAS,gBAAgB,OAAO,SAAS,sBAAsB;AACxE,WAAO,OAA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N_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 `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"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
var _chunkZNZEJDOEjs = require('./chunk-ZNZEJDOE.js');
|
|
5
|
+
|
|
6
|
+
|
|
3
7
|
var _chunkX3KACH5Pjs = require('./chunk-X3KACH5P.js');
|
|
4
8
|
|
|
5
9
|
|
|
@@ -10,6 +14,9 @@ var _chunkSD6CWFDFjs = require('./chunk-SD6CWFDF.js');
|
|
|
10
14
|
var _chunkVH47Q6TSjs = require('./chunk-VH47Q6TS.js');
|
|
11
15
|
|
|
12
16
|
|
|
17
|
+
var _chunk5KMU2IATjs = require('./chunk-5KMU2IAT.js');
|
|
18
|
+
|
|
19
|
+
|
|
13
20
|
var _chunk7LXE4KHVjs = require('./chunk-7LXE4KHV.js');
|
|
14
21
|
|
|
15
22
|
|
|
@@ -22,17 +29,16 @@ var _chunkV72C4MCRjs = require('./chunk-V72C4MCR.js');
|
|
|
22
29
|
var _chunkQP75SWIQjs = require('./chunk-QP75SWIQ.js');
|
|
23
30
|
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
var _chunkZNZEJDOEjs = require('./chunk-ZNZEJDOE.js');
|
|
27
|
-
|
|
28
|
-
|
|
29
32
|
var _chunkNYKRCWBGjs = require('./chunk-NYKRCWBG.js');
|
|
30
33
|
|
|
31
34
|
|
|
32
35
|
var _chunkWR5F34OWjs = require('./chunk-WR5F34OW.js');
|
|
33
36
|
|
|
34
37
|
|
|
35
|
-
var
|
|
38
|
+
var _chunkTJMQEH57js = require('./chunk-TJMQEH57.js');
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
var _chunk7DJO6UZAjs = require('./chunk-7DJO6UZA.js');
|
|
36
42
|
|
|
37
43
|
|
|
38
44
|
|
|
@@ -48,16 +54,13 @@ var _chunk5XQ2KRYLjs = require('./chunk-5XQ2KRYL.js');
|
|
|
48
54
|
var _chunkEQT25RSPjs = require('./chunk-EQT25RSP.js');
|
|
49
55
|
|
|
50
56
|
|
|
51
|
-
var
|
|
52
|
-
|
|
57
|
+
var _chunkDUFOYA4Djs = require('./chunk-DUFOYA4D.js');
|
|
53
58
|
|
|
54
|
-
var _chunkLNX4JTOLjs = require('./chunk-LNX4JTOL.js');
|
|
55
59
|
|
|
60
|
+
var _chunkVJYFB7BMjs = require('./chunk-VJYFB7BM.js');
|
|
56
61
|
|
|
57
|
-
var _chunk4RJXBKSRjs = require('./chunk-4RJXBKSR.js');
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
var _chunkEQNKFFTMjs = require('./chunk-EQNKFFTM.js');
|
|
63
|
+
var _chunkKNYSD4JPjs = require('./chunk-KNYSD4JP.js');
|
|
61
64
|
|
|
62
65
|
|
|
63
66
|
|
|
@@ -76,6 +79,9 @@ var _chunkC2LNDHP4js = require('./chunk-C2LNDHP4.js');
|
|
|
76
79
|
var _chunkUGFBA4GVjs = require('./chunk-UGFBA4GV.js');
|
|
77
80
|
|
|
78
81
|
|
|
82
|
+
var _chunkEMDU4XLMjs = require('./chunk-EMDU4XLM.js');
|
|
83
|
+
|
|
84
|
+
|
|
79
85
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
80
86
|
|
|
81
87
|
|
|
@@ -137,7 +143,7 @@ function getDefaultTransactionControllerState() {
|
|
|
137
143
|
lastFetchedBlockNumbers: {}
|
|
138
144
|
};
|
|
139
145
|
}
|
|
140
|
-
var _internalEvents, _incomingTransactionOptions, _pendingTransactionOptions, _transactionHistoryLimit, _isSimulationEnabled, _multichainTrackingHelper, _createNonceTracker, createNonceTracker_fn, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn, _createPendingTransactionTracker, createPendingTransactionTracker_fn, _checkForPendingTransactionAndStartPolling, _stopAllTracking, stopAllTracking_fn, _removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners_fn, _addIncomingTransactionHelperListeners, addIncomingTransactionHelperListeners_fn, _removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners_fn, _addPendingTransactionTrackerListeners, addPendingTransactionTrackerListeners_fn, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn, _getGasFeeFlows, getGasFeeFlows_fn, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn, _updateTransactionInternal, updateTransactionInternal_fn, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn, _updateSimulationData, updateSimulationData_fn, _onGasFeePollerTransactionUpdate, onGasFeePollerTransactionUpdate_fn;
|
|
146
|
+
var _internalEvents, _incomingTransactionOptions, _pendingTransactionOptions, _transactionHistoryLimit, _isSimulationEnabled, _testGasFeeFlows, _multichainTrackingHelper, _createNonceTracker, createNonceTracker_fn, _createIncomingTransactionHelper, createIncomingTransactionHelper_fn, _createPendingTransactionTracker, createPendingTransactionTracker_fn, _checkForPendingTransactionAndStartPolling, _stopAllTracking, stopAllTracking_fn, _removeIncomingTransactionHelperListeners, removeIncomingTransactionHelperListeners_fn, _addIncomingTransactionHelperListeners, addIncomingTransactionHelperListeners_fn, _removePendingTransactionTrackerListeners, removePendingTransactionTrackerListeners_fn, _addPendingTransactionTrackerListeners, addPendingTransactionTrackerListeners_fn, _getNonceTrackerPendingTransactions, getNonceTrackerPendingTransactions_fn, _getGasFeeFlows, getGasFeeFlows_fn, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn, _updateTransactionInternal, updateTransactionInternal_fn, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn, _updateSimulationData, updateSimulationData_fn, _onGasFeePollerTransactionUpdate, onGasFeePollerTransactionUpdate_fn, _getNetworkClientId, getNetworkClientId_fn, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn, _getGlobalChainId, getGlobalChainId_fn, _isCustomNetwork, isCustomNetwork_fn;
|
|
141
147
|
var TransactionController = class extends _basecontroller.BaseController {
|
|
142
148
|
/**
|
|
143
149
|
* Constructs a TransactionController.
|
|
@@ -166,6 +172,7 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
166
172
|
* @param options.securityProviderRequest - A function for verifying a transaction, whether it is malicious or not.
|
|
167
173
|
* @param options.sign - Function used to sign transactions.
|
|
168
174
|
* @param options.state - Initial state to set on this controller.
|
|
175
|
+
* @param options.testGasFeeFlows - Whether to use the test gas fee flow.
|
|
169
176
|
* @param options.transactionHistoryLimit - Transaction history limit.
|
|
170
177
|
* @param options.hooks - The controller hooks.
|
|
171
178
|
*/
|
|
@@ -193,6 +200,7 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
193
200
|
securityProviderRequest,
|
|
194
201
|
sign,
|
|
195
202
|
state,
|
|
203
|
+
testGasFeeFlows,
|
|
196
204
|
transactionHistoryLimit = 40,
|
|
197
205
|
hooks
|
|
198
206
|
}) {
|
|
@@ -221,6 +229,10 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
221
229
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _onTransactionParamsUpdated);
|
|
222
230
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _updateSimulationData);
|
|
223
231
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _onGasFeePollerTransactionUpdate);
|
|
232
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getNetworkClientId);
|
|
233
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getGlobalNetworkClientId);
|
|
234
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _getGlobalChainId);
|
|
235
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _isCustomNetwork);
|
|
224
236
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _internalEvents, new (0, _events.EventEmitter)());
|
|
225
237
|
this.inProcessOfSigning = /* @__PURE__ */ new Set();
|
|
226
238
|
this.mutex = new (0, _asyncmutex.Mutex)();
|
|
@@ -229,6 +241,7 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
229
241
|
this.signAbortCallbacks = /* @__PURE__ */ new Map();
|
|
230
242
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _transactionHistoryLimit, void 0);
|
|
231
243
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _isSimulationEnabled, void 0);
|
|
244
|
+
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _testGasFeeFlows, void 0);
|
|
232
245
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _multichainTrackingHelper, void 0);
|
|
233
246
|
_chunkZ4BLTVTBjs.__privateAdd.call(void 0, this, _checkForPendingTransactionAndStartPolling, () => {
|
|
234
247
|
this.pendingTransactionTracker.startIfPendingTransactions();
|
|
@@ -253,6 +266,7 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
253
266
|
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _pendingTransactionOptions, pendingTransactions);
|
|
254
267
|
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _transactionHistoryLimit, transactionHistoryLimit);
|
|
255
268
|
this.sign = sign;
|
|
269
|
+
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _testGasFeeFlows, testGasFeeFlows === true);
|
|
256
270
|
this.afterSign = hooks?.afterSign ?? (() => true);
|
|
257
271
|
this.beforeApproveOnInit = hooks?.beforeApproveOnInit ?? (() => true);
|
|
258
272
|
this.beforeCheckPendingTransaction = hooks?.beforeCheckPendingTransaction ?? /* istanbul ignore next */
|
|
@@ -264,17 +278,18 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
264
278
|
provider,
|
|
265
279
|
blockTracker
|
|
266
280
|
});
|
|
281
|
+
const findNetworkClientIdByChainId = (chainId) => {
|
|
282
|
+
return this.messagingSystem.call(
|
|
283
|
+
`NetworkController:findNetworkClientIdByChainId`,
|
|
284
|
+
chainId
|
|
285
|
+
);
|
|
286
|
+
};
|
|
267
287
|
_chunkZ4BLTVTBjs.__privateSet.call(void 0, this, _multichainTrackingHelper, new (0, _chunk5XQ2KRYLjs.MultichainTrackingHelper)({
|
|
268
288
|
isMultichainEnabled,
|
|
269
289
|
provider,
|
|
270
290
|
nonceTracker: this.nonceTracker,
|
|
271
291
|
incomingTransactionOptions: incomingTransactions,
|
|
272
|
-
findNetworkClientIdByChainId
|
|
273
|
-
return this.messagingSystem.call(
|
|
274
|
-
`NetworkController:findNetworkClientIdByChainId`,
|
|
275
|
-
chainId
|
|
276
|
-
);
|
|
277
|
-
},
|
|
292
|
+
findNetworkClientIdByChainId,
|
|
278
293
|
getNetworkClientById: (networkClientId) => {
|
|
279
294
|
return this.messagingSystem.call(
|
|
280
295
|
`NetworkController:getNetworkClientById`,
|
|
@@ -308,9 +323,9 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
308
323
|
});
|
|
309
324
|
this.gasFeeFlows = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGasFeeFlows, getGasFeeFlows_fn).call(this);
|
|
310
325
|
this.layer1GasFeeFlows = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLayer1GasFeeFlows, getLayer1GasFeeFlows_fn).call(this);
|
|
311
|
-
const gasFeePoller = new (0,
|
|
312
|
-
|
|
313
|
-
gasFeeFlows: this.gasFeeFlows
|
|
326
|
+
const gasFeePoller = new (0, _chunk7DJO6UZAjs.GasFeePoller)({
|
|
327
|
+
findNetworkClientIdByChainId,
|
|
328
|
+
gasFeeFlows: this.gasFeeFlows,
|
|
314
329
|
getGasFeeControllerEstimates: this.getGasFeeEstimates,
|
|
315
330
|
getProvider: (chainId, networkClientId) => _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).getProvider({
|
|
316
331
|
networkClientId,
|
|
@@ -438,15 +453,16 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
438
453
|
sendFlowHistory,
|
|
439
454
|
swaps = {},
|
|
440
455
|
type,
|
|
441
|
-
networkClientId
|
|
456
|
+
networkClientId: requestNetworkClientId
|
|
442
457
|
} = {}) {
|
|
443
458
|
_chunkS6VGOPUYjs.projectLogger.call(void 0, "Adding transaction", txParams);
|
|
444
459
|
txParams = _chunkUGFBA4GVjs.normalizeTransactionParams.call(void 0, txParams);
|
|
445
|
-
if (
|
|
460
|
+
if (requestNetworkClientId && !_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).has(requestNetworkClientId)) {
|
|
446
461
|
throw new Error(
|
|
447
462
|
"The networkClientId for this transaction could not be found"
|
|
448
463
|
);
|
|
449
464
|
}
|
|
465
|
+
const networkClientId = requestNetworkClientId ?? _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn).call(this);
|
|
450
466
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(
|
|
451
467
|
networkClientId
|
|
452
468
|
);
|
|
@@ -1368,6 +1384,37 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
1368
1384
|
}
|
|
1369
1385
|
return filteredTransactions;
|
|
1370
1386
|
}
|
|
1387
|
+
async estimateGasFee({
|
|
1388
|
+
transactionParams,
|
|
1389
|
+
chainId,
|
|
1390
|
+
networkClientId: requestNetworkClientId
|
|
1391
|
+
}) {
|
|
1392
|
+
const networkClientId = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getNetworkClientId, getNetworkClientId_fn).call(this, {
|
|
1393
|
+
networkClientId: requestNetworkClientId,
|
|
1394
|
+
chainId
|
|
1395
|
+
});
|
|
1396
|
+
const transactionMeta = {
|
|
1397
|
+
txParams: transactionParams,
|
|
1398
|
+
chainId,
|
|
1399
|
+
networkClientId
|
|
1400
|
+
};
|
|
1401
|
+
const gasFeeFlow = _chunkEMDU4XLMjs.getGasFeeFlow.call(void 0,
|
|
1402
|
+
transactionMeta,
|
|
1403
|
+
this.gasFeeFlows
|
|
1404
|
+
);
|
|
1405
|
+
const ethQuery = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).getEthQuery({
|
|
1406
|
+
networkClientId,
|
|
1407
|
+
chainId
|
|
1408
|
+
});
|
|
1409
|
+
const gasFeeControllerData = await this.getGasFeeEstimates({
|
|
1410
|
+
networkClientId
|
|
1411
|
+
});
|
|
1412
|
+
return gasFeeFlow.getGasFees({
|
|
1413
|
+
ethQuery,
|
|
1414
|
+
gasFeeControllerData,
|
|
1415
|
+
transactionMeta
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1371
1418
|
/**
|
|
1372
1419
|
* Determine the layer 1 gas fee for the given transaction parameters.
|
|
1373
1420
|
*
|
|
@@ -1457,10 +1504,7 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
1457
1504
|
async updateGasProperties(transactionMeta) {
|
|
1458
1505
|
const isEIP1559Compatible = await this.getEIP1559Compatibility(transactionMeta.networkClientId) && transactionMeta.txParams.type !== "0x0" /* legacy */;
|
|
1459
1506
|
const { networkClientId, chainId } = transactionMeta;
|
|
1460
|
-
const isCustomNetwork =
|
|
1461
|
-
`NetworkController:getNetworkClientById`,
|
|
1462
|
-
networkClientId
|
|
1463
|
-
).configuration.type === _networkcontroller.NetworkClientType.Custom : this.getNetworkState().providerConfig.type === _controllerutils.NetworkType.rpc;
|
|
1507
|
+
const isCustomNetwork = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _isCustomNetwork, isCustomNetwork_fn).call(this, networkClientId);
|
|
1464
1508
|
const ethQuery = _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _multichainTrackingHelper).getEthQuery({
|
|
1465
1509
|
networkClientId,
|
|
1466
1510
|
chainId
|
|
@@ -1475,7 +1519,7 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
1475
1519
|
isCustomNetwork,
|
|
1476
1520
|
txMeta: transactionMeta
|
|
1477
1521
|
});
|
|
1478
|
-
await
|
|
1522
|
+
await _chunkKNYSD4JPjs.updateGasFees.call(void 0, {
|
|
1479
1523
|
eip1559: isEIP1559Compatible,
|
|
1480
1524
|
ethQuery,
|
|
1481
1525
|
gasFeeFlows: this.gasFeeFlows,
|
|
@@ -1845,14 +1889,15 @@ var TransactionController = class extends _basecontroller.BaseController {
|
|
|
1845
1889
|
return { meta: transaction, isCompleted };
|
|
1846
1890
|
}
|
|
1847
1891
|
getChainId(networkClientId) {
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
).configuration.chainId;
|
|
1892
|
+
const globalChainId = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGlobalChainId, getGlobalChainId_fn).call(this);
|
|
1893
|
+
const globalNetworkClientId = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn).call(this);
|
|
1894
|
+
if (!networkClientId || networkClientId === globalNetworkClientId) {
|
|
1895
|
+
return globalChainId;
|
|
1853
1896
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1897
|
+
return this.messagingSystem.call(
|
|
1898
|
+
`NetworkController:getNetworkClientById`,
|
|
1899
|
+
networkClientId
|
|
1900
|
+
).configuration.chainId;
|
|
1856
1901
|
}
|
|
1857
1902
|
prepareUnsignedEthTx(chainId, txParams) {
|
|
1858
1903
|
return _tx.TransactionFactory.fromTxData(txParams, {
|
|
@@ -2187,6 +2232,7 @@ _incomingTransactionOptions = new WeakMap();
|
|
|
2187
2232
|
_pendingTransactionOptions = new WeakMap();
|
|
2188
2233
|
_transactionHistoryLimit = new WeakMap();
|
|
2189
2234
|
_isSimulationEnabled = new WeakMap();
|
|
2235
|
+
_testGasFeeFlows = new WeakMap();
|
|
2190
2236
|
_multichainTrackingHelper = new WeakMap();
|
|
2191
2237
|
_createNonceTracker = new WeakSet();
|
|
2192
2238
|
createNonceTracker_fn = function({
|
|
@@ -2326,7 +2372,10 @@ getNonceTrackerPendingTransactions_fn = function(chainId, address) {
|
|
|
2326
2372
|
};
|
|
2327
2373
|
_getGasFeeFlows = new WeakSet();
|
|
2328
2374
|
getGasFeeFlows_fn = function() {
|
|
2329
|
-
|
|
2375
|
+
if (_chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _testGasFeeFlows)) {
|
|
2376
|
+
return [new (0, _chunkTJMQEH57js.TestGasFeeFlow)()];
|
|
2377
|
+
}
|
|
2378
|
+
return [new (0, _chunkDUFOYA4Djs.LineaGasFeeFlow)(), new (0, _chunkVJYFB7BMjs.DefaultGasFeeFlow)()];
|
|
2330
2379
|
};
|
|
2331
2380
|
_getLayer1GasFeeFlows = new WeakSet();
|
|
2332
2381
|
getLayer1GasFeeFlows_fn = function() {
|
|
@@ -2453,6 +2502,43 @@ onGasFeePollerTransactionUpdate_fn = function({
|
|
|
2453
2502
|
}
|
|
2454
2503
|
});
|
|
2455
2504
|
};
|
|
2505
|
+
_getNetworkClientId = new WeakSet();
|
|
2506
|
+
getNetworkClientId_fn = function({
|
|
2507
|
+
networkClientId: requestNetworkClientId,
|
|
2508
|
+
chainId
|
|
2509
|
+
}) {
|
|
2510
|
+
const globalChainId = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGlobalChainId, getGlobalChainId_fn).call(this);
|
|
2511
|
+
const globalNetworkClientId = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn).call(this);
|
|
2512
|
+
if (requestNetworkClientId) {
|
|
2513
|
+
return requestNetworkClientId;
|
|
2514
|
+
}
|
|
2515
|
+
if (!chainId || chainId === globalChainId) {
|
|
2516
|
+
return globalNetworkClientId;
|
|
2517
|
+
}
|
|
2518
|
+
return this.messagingSystem.call(
|
|
2519
|
+
`NetworkController:findNetworkClientIdByChainId`,
|
|
2520
|
+
chainId
|
|
2521
|
+
);
|
|
2522
|
+
};
|
|
2523
|
+
_getGlobalNetworkClientId = new WeakSet();
|
|
2524
|
+
getGlobalNetworkClientId_fn = function() {
|
|
2525
|
+
return this.getNetworkState().selectedNetworkClientId;
|
|
2526
|
+
};
|
|
2527
|
+
_getGlobalChainId = new WeakSet();
|
|
2528
|
+
getGlobalChainId_fn = function() {
|
|
2529
|
+
return this.getNetworkState().providerConfig.chainId;
|
|
2530
|
+
};
|
|
2531
|
+
_isCustomNetwork = new WeakSet();
|
|
2532
|
+
isCustomNetwork_fn = function(networkClientId) {
|
|
2533
|
+
const globalNetworkClientId = _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getGlobalNetworkClientId, getGlobalNetworkClientId_fn).call(this);
|
|
2534
|
+
if (!networkClientId || networkClientId === globalNetworkClientId) {
|
|
2535
|
+
return this.getNetworkState().providerConfig.type === _controllerutils.NetworkType.rpc;
|
|
2536
|
+
}
|
|
2537
|
+
return this.messagingSystem.call(
|
|
2538
|
+
`NetworkController:getNetworkClientById`,
|
|
2539
|
+
networkClientId
|
|
2540
|
+
).configuration.type === _networkcontroller.NetworkClientType.Custom;
|
|
2541
|
+
};
|
|
2456
2542
|
|
|
2457
2543
|
|
|
2458
2544
|
|
|
@@ -2461,4 +2547,4 @@ onGasFeePollerTransactionUpdate_fn = function({
|
|
|
2461
2547
|
|
|
2462
2548
|
|
|
2463
2549
|
exports.HARDFORK = HARDFORK; exports.CANCEL_RATE = CANCEL_RATE; exports.SPEED_UP_RATE = SPEED_UP_RATE; exports.ApprovalState = ApprovalState; exports.TransactionController = TransactionController;
|
|
2464
|
-
//# sourceMappingURL=chunk-
|
|
2550
|
+
//# sourceMappingURL=chunk-N55SEKK7.js.map
|