@metamask-previews/transaction-controller 25.1.0-preview-68beceb0 → 25.1.0-preview-97731c3
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/dist/TransactionController.js +18 -19
- package/dist/TransactionController.mjs +17 -18
- package/dist/{chunk-TJXPMOA6.mjs → chunk-3D3SA6PY.mjs} +2 -2
- package/dist/{chunk-G4743H5H.js → chunk-5IHLDAOF.js} +5 -5
- package/dist/{chunk-QTQSCTQA.js → chunk-5OQ373JS.js} +10 -10
- package/dist/{chunk-WBE2B3XJ.mjs → chunk-5UL3VDFT.mjs} +8 -13
- package/dist/chunk-5UL3VDFT.mjs.map +1 -0
- package/dist/{chunk-TVDU7LVX.mjs → chunk-6ANFIDWC.mjs} +93 -79
- package/dist/chunk-6ANFIDWC.mjs.map +1 -0
- package/dist/{chunk-N6STPA6E.mjs → chunk-A63EOB5B.mjs} +30 -7
- package/dist/chunk-A63EOB5B.mjs.map +1 -0
- package/dist/chunk-CRFAUS5P.js +59 -0
- package/dist/chunk-CRFAUS5P.js.map +1 -0
- package/dist/{chunk-VP2DBWOT.js → chunk-CXXGL43K.js} +3 -3
- package/dist/{chunk-BTYBFMZN.js → chunk-DTXRT653.js} +103 -89
- package/dist/chunk-DTXRT653.js.map +1 -0
- package/dist/{chunk-6KYPLIXG.mjs → chunk-DWHMMJOW.mjs} +2 -2
- package/dist/{chunk-C3UHJPYJ.js → chunk-F3CMU2DM.js} +6 -6
- package/dist/{chunk-2YQGET5U.js → chunk-FHG5GY6F.js} +7 -7
- package/dist/{chunk-JZFJUM6S.mjs → chunk-IK55QTGO.mjs} +3 -3
- package/dist/{chunk-WIZVJM2B.js → chunk-ITDY6AIZ.js} +2 -3
- package/dist/chunk-ITDY6AIZ.js.map +1 -0
- package/dist/{chunk-RU6NJIUD.mjs → chunk-IZI7FQIN.mjs} +3 -3
- package/dist/chunk-KFL2GGZC.mjs +48 -0
- package/dist/chunk-KFL2GGZC.mjs.map +1 -0
- package/dist/{chunk-NT3WVB4P.js → chunk-LVC2VSLJ.js} +32 -9
- package/dist/chunk-LVC2VSLJ.js.map +1 -0
- package/dist/{chunk-PJV3XYKW.js → chunk-NRWEI43Q.js} +20 -45
- package/dist/chunk-NRWEI43Q.js.map +1 -0
- package/dist/{chunk-I6HCML4F.js → chunk-PF3UOCRW.js} +8 -8
- package/dist/{chunk-2MSXAOTK.mjs → chunk-PGTV7236.mjs} +5 -5
- package/dist/{chunk-JCGCPGGI.js → chunk-QEX3QMSL.js} +8 -13
- package/dist/chunk-QEX3QMSL.js.map +1 -0
- package/dist/{chunk-3HE3FT67.mjs → chunk-QRSTF45Q.mjs} +5 -5
- package/dist/chunk-R7NJVDWN.js +48 -0
- package/dist/chunk-R7NJVDWN.js.map +1 -0
- package/dist/{chunk-GRQB2ARK.js → chunk-RQKICZYP.js} +3 -3
- package/dist/{chunk-2MMWLJXS.js → chunk-TZTP4JVA.js} +4 -4
- package/dist/{chunk-TUW3M44L.js → chunk-VEJ3MIZG.js} +1 -1
- package/dist/chunk-VEJ3MIZG.js.map +1 -0
- package/dist/{chunk-RIYIJTEU.mjs → chunk-VEREDMI2.mjs} +2 -2
- package/dist/{chunk-T6W4OUJD.mjs → chunk-VNXLR7E3.mjs} +20 -7
- package/dist/chunk-VNXLR7E3.mjs.map +1 -0
- package/dist/{chunk-XOIPXDGX.mjs → chunk-W57BD6NX.mjs} +1 -1
- package/dist/chunk-W57BD6NX.mjs.map +1 -0
- package/dist/{chunk-HLG525BC.mjs → chunk-XKNFL657.mjs} +2 -2
- package/dist/{chunk-DTMKGTYC.mjs → chunk-Z3HHSD5I.mjs} +2 -3
- package/dist/chunk-Z3HHSD5I.mjs.map +1 -0
- package/dist/{chunk-ZM6E4LZJ.mjs → chunk-ZQFMTLZJ.mjs} +19 -44
- package/dist/chunk-ZQFMTLZJ.mjs.map +1 -0
- package/dist/constants.js +2 -2
- package/dist/constants.mjs +1 -1
- package/dist/gas-flows/DefaultGasFeeFlow.js +7 -7
- package/dist/gas-flows/DefaultGasFeeFlow.mjs +6 -6
- package/dist/gas-flows/LineaGasFeeFlow.js +8 -8
- package/dist/gas-flows/LineaGasFeeFlow.mjs +7 -7
- package/dist/helpers/EtherscanRemoteTransactionSource.js +5 -5
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +4 -4
- package/dist/helpers/GasFeePoller.js +5 -5
- package/dist/helpers/GasFeePoller.mjs +4 -4
- package/dist/helpers/MultichainTrackingHelper.js +6 -6
- package/dist/helpers/MultichainTrackingHelper.mjs +5 -5
- package/dist/helpers/PendingTransactionTracker.js +1 -1
- package/dist/helpers/PendingTransactionTracker.mjs +1 -1
- package/dist/index.js +23 -22
- package/dist/index.mjs +22 -21
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/TransactionController.d.ts +0 -8
- package/dist/types/TransactionController.d.ts.map +1 -1
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/helpers/GasFeePoller.d.ts +2 -4
- package/dist/types/helpers/GasFeePoller.d.ts.map +1 -1
- package/dist/types/helpers/MultichainTrackingHelper.d.ts +0 -4
- package/dist/types/helpers/MultichainTrackingHelper.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 +14 -3
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/layer1-gas-fee-flow.d.ts +2 -18
- package/dist/types/utils/layer1-gas-fee-flow.d.ts.map +1 -1
- package/dist/types/utils/simulation-api.d.ts +14 -6
- package/dist/types/utils/simulation-api.d.ts.map +1 -1
- package/dist/types/utils/simulation.d.ts +1 -1
- package/dist/types/utils/simulation.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.mjs +1 -1
- package/dist/utils/etherscan.js +3 -3
- package/dist/utils/etherscan.mjs +2 -2
- package/dist/utils/external-transactions.js +1 -1
- package/dist/utils/external-transactions.mjs +1 -1
- package/dist/utils/gas-fees.js +6 -6
- package/dist/utils/gas-fees.mjs +5 -5
- package/dist/utils/gas-flow.js +3 -3
- package/dist/utils/gas-flow.mjs +2 -2
- package/dist/utils/gas.js +3 -3
- package/dist/utils/gas.mjs +2 -2
- package/dist/utils/layer1-gas-fee-flow.js +2 -6
- package/dist/utils/layer1-gas-fee-flow.mjs +1 -5
- package/dist/utils/simulation-api.js +3 -3
- package/dist/utils/simulation-api.mjs +2 -2
- package/dist/utils/simulation.js +5 -5
- package/dist/utils/simulation.mjs +4 -4
- package/dist/utils/swaps.js +4 -4
- package/dist/utils/swaps.mjs +3 -3
- 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 +1 -3
- package/dist/chunk-BTYBFMZN.js.map +0 -1
- package/dist/chunk-DTMKGTYC.mjs.map +0 -1
- package/dist/chunk-IFNKPDIB.js +0 -46
- package/dist/chunk-IFNKPDIB.js.map +0 -1
- package/dist/chunk-JCGCPGGI.js.map +0 -1
- package/dist/chunk-N6STPA6E.mjs.map +0 -1
- package/dist/chunk-NT3WVB4P.js.map +0 -1
- package/dist/chunk-OXRUL7JF.mjs +0 -74
- package/dist/chunk-OXRUL7JF.mjs.map +0 -1
- package/dist/chunk-PJV3XYKW.js.map +0 -1
- package/dist/chunk-PM22KPVX.mjs +0 -75
- package/dist/chunk-PM22KPVX.mjs.map +0 -1
- package/dist/chunk-R5LEPJW3.js +0 -75
- package/dist/chunk-R5LEPJW3.js.map +0 -1
- package/dist/chunk-S222HWGT.js +0 -74
- package/dist/chunk-S222HWGT.js.map +0 -1
- package/dist/chunk-T6W4OUJD.mjs.map +0 -1
- package/dist/chunk-TUW3M44L.js.map +0 -1
- package/dist/chunk-TVDU7LVX.mjs.map +0 -1
- package/dist/chunk-WBE2B3XJ.mjs.map +0 -1
- package/dist/chunk-WIZVJM2B.js.map +0 -1
- package/dist/chunk-XOIPXDGX.mjs.map +0 -1
- package/dist/chunk-ZM6E4LZJ.mjs.map +0 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js +0 -11
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.js.map +0 -1
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +0 -11
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs.map +0 -1
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts +0 -10
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +0 -1
- /package/dist/{chunk-TJXPMOA6.mjs.map → chunk-3D3SA6PY.mjs.map} +0 -0
- /package/dist/{chunk-G4743H5H.js.map → chunk-5IHLDAOF.js.map} +0 -0
- /package/dist/{chunk-QTQSCTQA.js.map → chunk-5OQ373JS.js.map} +0 -0
- /package/dist/{chunk-VP2DBWOT.js.map → chunk-CXXGL43K.js.map} +0 -0
- /package/dist/{chunk-6KYPLIXG.mjs.map → chunk-DWHMMJOW.mjs.map} +0 -0
- /package/dist/{chunk-C3UHJPYJ.js.map → chunk-F3CMU2DM.js.map} +0 -0
- /package/dist/{chunk-2YQGET5U.js.map → chunk-FHG5GY6F.js.map} +0 -0
- /package/dist/{chunk-JZFJUM6S.mjs.map → chunk-IK55QTGO.mjs.map} +0 -0
- /package/dist/{chunk-RU6NJIUD.mjs.map → chunk-IZI7FQIN.mjs.map} +0 -0
- /package/dist/{chunk-I6HCML4F.js.map → chunk-PF3UOCRW.js.map} +0 -0
- /package/dist/{chunk-2MSXAOTK.mjs.map → chunk-PGTV7236.mjs.map} +0 -0
- /package/dist/{chunk-3HE3FT67.mjs.map → chunk-QRSTF45Q.mjs.map} +0 -0
- /package/dist/{chunk-GRQB2ARK.js.map → chunk-RQKICZYP.js.map} +0 -0
- /package/dist/{chunk-2MMWLJXS.js.map → chunk-TZTP4JVA.js.map} +0 -0
- /package/dist/{chunk-RIYIJTEU.mjs.map → chunk-VEREDMI2.mjs.map} +0 -0
- /package/dist/{chunk-HLG525BC.mjs.map → chunk-XKNFL657.mjs.map} +0 -0
|
@@ -4,32 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-HS277C77.js');
|
|
7
|
+
var _chunkDTXRT653js = require('./chunk-DTXRT653.js');
|
|
9
8
|
require('./chunk-VH47Q6TS.js');
|
|
10
|
-
require('./chunk-
|
|
9
|
+
require('./chunk-RQKICZYP.js');
|
|
11
10
|
require('./chunk-QP75SWIQ.js');
|
|
12
11
|
require('./chunk-ZNZEJDOE.js');
|
|
13
|
-
require('./chunk-
|
|
14
|
-
require('./chunk-
|
|
15
|
-
require('./chunk-
|
|
12
|
+
require('./chunk-LVC2VSLJ.js');
|
|
13
|
+
require('./chunk-CRFAUS5P.js');
|
|
14
|
+
require('./chunk-HS277C77.js');
|
|
15
|
+
require('./chunk-QEX3QMSL.js');
|
|
16
|
+
require('./chunk-R7NJVDWN.js');
|
|
16
17
|
require('./chunk-DTDTOMTB.js');
|
|
17
|
-
require('./chunk-
|
|
18
|
-
require('./chunk-C3UHJPYJ.js');
|
|
18
|
+
require('./chunk-NRWEI43Q.js');
|
|
19
19
|
require('./chunk-5XBULBP2.js');
|
|
20
|
-
require('./chunk-VP2DBWOT.js');
|
|
21
20
|
require('./chunk-7LXE4KHV.js');
|
|
22
|
-
require('./chunk-
|
|
23
|
-
require('./chunk-
|
|
24
|
-
require('./chunk-
|
|
25
|
-
require('./chunk-
|
|
21
|
+
require('./chunk-FHG5GY6F.js');
|
|
22
|
+
require('./chunk-PF3UOCRW.js');
|
|
23
|
+
require('./chunk-5IHLDAOF.js');
|
|
24
|
+
require('./chunk-5OQ373JS.js');
|
|
26
25
|
require('./chunk-UGFBA4GV.js');
|
|
27
|
-
require('./chunk-
|
|
28
|
-
require('./chunk-
|
|
29
|
-
require('./chunk-
|
|
30
|
-
require('./chunk-
|
|
31
|
-
require('./chunk-WIZVJM2B.js');
|
|
26
|
+
require('./chunk-TZTP4JVA.js');
|
|
27
|
+
require('./chunk-F3CMU2DM.js');
|
|
28
|
+
require('./chunk-CXXGL43K.js');
|
|
29
|
+
require('./chunk-ITDY6AIZ.js');
|
|
32
30
|
require('./chunk-S6VGOPUY.js');
|
|
31
|
+
require('./chunk-VEJ3MIZG.js');
|
|
33
32
|
require('./chunk-Z4BLTVTB.js');
|
|
34
33
|
|
|
35
34
|
|
|
@@ -37,5 +36,5 @@ require('./chunk-Z4BLTVTB.js');
|
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
|
|
40
|
-
exports.ApprovalState =
|
|
39
|
+
exports.ApprovalState = _chunkDTXRT653js.ApprovalState; exports.CANCEL_RATE = _chunkDTXRT653js.CANCEL_RATE; exports.HARDFORK = _chunkDTXRT653js.HARDFORK; exports.SPEED_UP_RATE = _chunkDTXRT653js.SPEED_UP_RATE; exports.TransactionController = _chunkDTXRT653js.TransactionController;
|
|
41
40
|
//# sourceMappingURL=TransactionController.js.map
|
|
@@ -4,32 +4,31 @@ import {
|
|
|
4
4
|
HARDFORK,
|
|
5
5
|
SPEED_UP_RATE,
|
|
6
6
|
TransactionController
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-JRBREX22.mjs";
|
|
7
|
+
} from "./chunk-6ANFIDWC.mjs";
|
|
9
8
|
import "./chunk-NM6OYEPP.mjs";
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-XKNFL657.mjs";
|
|
11
10
|
import "./chunk-XGRAHX6T.mjs";
|
|
12
11
|
import "./chunk-NHRBO3LU.mjs";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-A63EOB5B.mjs";
|
|
13
|
+
import "./chunk-VNXLR7E3.mjs";
|
|
14
|
+
import "./chunk-JRBREX22.mjs";
|
|
15
|
+
import "./chunk-5UL3VDFT.mjs";
|
|
16
|
+
import "./chunk-KFL2GGZC.mjs";
|
|
16
17
|
import "./chunk-Y7ENNK7L.mjs";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-RU6NJIUD.mjs";
|
|
18
|
+
import "./chunk-ZQFMTLZJ.mjs";
|
|
19
19
|
import "./chunk-JRQHIBG5.mjs";
|
|
20
|
-
import "./chunk-RIYIJTEU.mjs";
|
|
21
20
|
import "./chunk-FRKQ3Z2L.mjs";
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-PGTV7236.mjs";
|
|
22
|
+
import "./chunk-QRSTF45Q.mjs";
|
|
23
|
+
import "./chunk-IK55QTGO.mjs";
|
|
24
|
+
import "./chunk-3D3SA6PY.mjs";
|
|
26
25
|
import "./chunk-J56A7UCK.mjs";
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-DTMKGTYC.mjs";
|
|
26
|
+
import "./chunk-DWHMMJOW.mjs";
|
|
27
|
+
import "./chunk-IZI7FQIN.mjs";
|
|
28
|
+
import "./chunk-VEREDMI2.mjs";
|
|
29
|
+
import "./chunk-Z3HHSD5I.mjs";
|
|
32
30
|
import "./chunk-UQQWZT6C.mjs";
|
|
31
|
+
import "./chunk-W57BD6NX.mjs";
|
|
33
32
|
import "./chunk-XUI43LEZ.mjs";
|
|
34
33
|
export {
|
|
35
34
|
ApprovalState,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-J56A7UCK.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CHAIN_IDS
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Z3HHSD5I.mjs";
|
|
7
7
|
import {
|
|
8
8
|
createModuleLogger,
|
|
9
9
|
projectLogger
|
|
@@ -208,4 +208,4 @@ export {
|
|
|
208
208
|
updateSwapsTransaction,
|
|
209
209
|
updatePostTransactionBalance
|
|
210
210
|
};
|
|
211
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-3D3SA6PY.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5OQ373JSjs = require('./chunk-5OQ373JS.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkTZTP4JVAjs = require('./chunk-TZTP4JVA.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -20,7 +20,7 @@ var log = _utils.createModuleLogger.call(void 0, _chunkS6VGOPUYjs.projectLogger,
|
|
|
20
20
|
async function updateGasFees(request) {
|
|
21
21
|
const { txMeta } = request;
|
|
22
22
|
const initialParams = { ...txMeta.txParams };
|
|
23
|
-
const isSwap =
|
|
23
|
+
const isSwap = _chunk5OQ373JSjs.SWAP_TRANSACTION_TYPES.includes(
|
|
24
24
|
txMeta.type
|
|
25
25
|
);
|
|
26
26
|
const savedGasFees = isSwap ? void 0 : request.getSavedGasFees(txMeta.chainId);
|
|
@@ -185,7 +185,7 @@ async function getSuggestedGasFees(request) {
|
|
|
185
185
|
if (!eip1559 && txMeta.txParams.gasPrice || eip1559 && txMeta.txParams.maxFeePerGas && txMeta.txParams.maxPriorityFeePerGas) {
|
|
186
186
|
return {};
|
|
187
187
|
}
|
|
188
|
-
const gasFeeFlow =
|
|
188
|
+
const gasFeeFlow = _chunkTZTP4JVAjs.getGasFeeFlow.call(void 0, txMeta, gasFeeFlows);
|
|
189
189
|
try {
|
|
190
190
|
const response = await gasFeeFlow.getGasFees({
|
|
191
191
|
ethQuery,
|
|
@@ -205,4 +205,4 @@ async function getSuggestedGasFees(request) {
|
|
|
205
205
|
|
|
206
206
|
|
|
207
207
|
exports.updateGasFees = updateGasFees; exports.gweiDecimalToWeiHex = gweiDecimalToWeiHex;
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-5IHLDAOF.js.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkUGFBA4GVjs = require('./chunk-UGFBA4GV.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkITDY6AIZjs = require('./chunk-ITDY6AIZ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -57,15 +57,15 @@ var ZKSYNC_ERA_SWAPS_TOKEN_OBJECT = {
|
|
|
57
57
|
...ETH_SWAPS_TOKEN_OBJECT
|
|
58
58
|
};
|
|
59
59
|
var SWAPS_CHAINID_DEFAULT_TOKEN_MAP = {
|
|
60
|
-
[
|
|
60
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.MAINNET]: ETH_SWAPS_TOKEN_OBJECT,
|
|
61
61
|
[SWAPS_TESTNET_CHAIN_ID]: TEST_ETH_SWAPS_TOKEN_OBJECT,
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
62
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.BSC]: BNB_SWAPS_TOKEN_OBJECT,
|
|
63
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.POLYGON]: MATIC_SWAPS_TOKEN_OBJECT,
|
|
64
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.GOERLI]: GOERLI_SWAPS_TOKEN_OBJECT,
|
|
65
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.AVALANCHE]: AVAX_SWAPS_TOKEN_OBJECT,
|
|
66
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.OPTIMISM]: OPTIMISM_SWAPS_TOKEN_OBJECT,
|
|
67
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.ARBITRUM]: ARBITRUM_SWAPS_TOKEN_OBJECT,
|
|
68
|
+
[_chunkITDY6AIZjs.CHAIN_IDS.ZKSYNC_ERA]: ZKSYNC_ERA_SWAPS_TOKEN_OBJECT
|
|
69
69
|
};
|
|
70
70
|
var SWAP_TRANSACTION_TYPES = [
|
|
71
71
|
"swap" /* swap */,
|
|
@@ -208,4 +208,4 @@ function sleep(ms) {
|
|
|
208
208
|
|
|
209
209
|
|
|
210
210
|
exports.UPDATE_POST_TX_BALANCE_TIMEOUT = UPDATE_POST_TX_BALANCE_TIMEOUT; exports.UPDATE_POST_TX_BALANCE_ATTEMPTS = UPDATE_POST_TX_BALANCE_ATTEMPTS; exports.DEFAULT_TOKEN_ADDRESS = DEFAULT_TOKEN_ADDRESS; exports.SWAPS_CHAINID_DEFAULT_TOKEN_MAP = SWAPS_CHAINID_DEFAULT_TOKEN_MAP; exports.SWAP_TRANSACTION_TYPES = SWAP_TRANSACTION_TYPES; exports.updateSwapsTransaction = updateSwapsTransaction; exports.updatePostTransactionBalance = updatePostTransactionBalance;
|
|
211
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-5OQ373JS.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getGasFeeFlow
|
|
3
|
-
} from "./chunk-6KYPLIXG.mjs";
|
|
4
1
|
import {
|
|
5
2
|
updateTransactionLayer1GasFee
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KFL2GGZC.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getGasFeeFlow
|
|
6
|
+
} from "./chunk-DWHMMJOW.mjs";
|
|
7
7
|
import {
|
|
8
8
|
projectLogger
|
|
9
9
|
} from "./chunk-UQQWZT6C.mjs";
|
|
@@ -19,7 +19,7 @@ import { createModuleLogger } from "@metamask/utils";
|
|
|
19
19
|
import EventEmitter from "events";
|
|
20
20
|
var log = createModuleLogger(projectLogger, "gas-fee-poller");
|
|
21
21
|
var INTERVAL_MILLISECONDS = 1e4;
|
|
22
|
-
var _gasFeeFlows, _getEthQuery, _getGasFeeControllerEstimates,
|
|
22
|
+
var _gasFeeFlows, _getEthQuery, _getGasFeeControllerEstimates, _getTransactions, _layer1GasFeeFlows, _timeout, _running, _start, start_fn, _stop, stop_fn, _onTimeout, onTimeout_fn, _updateTransactionGasFeeEstimates, updateTransactionGasFeeEstimates_fn, _updateTransactionSuggestedFees, updateTransactionSuggestedFees_fn, _updateTransactionLayer1GasFee, updateTransactionLayer1GasFee_fn, _getUnapprovedTransactions, getUnapprovedTransactions_fn;
|
|
23
23
|
var GasFeePoller = class {
|
|
24
24
|
/**
|
|
25
25
|
* Constructs a new instance of the GasFeePoller.
|
|
@@ -27,7 +27,6 @@ var GasFeePoller = class {
|
|
|
27
27
|
* @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees.
|
|
28
28
|
* @param options.getEthQuery - Callback to obtain an EthQuery instance.
|
|
29
29
|
* @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates.
|
|
30
|
-
* @param options.getProvider - Callback to obtain a provider instance.
|
|
31
30
|
* @param options.getTransactions - Callback to obtain the transaction data.
|
|
32
31
|
* @param options.layer1GasFeeFlows - The layer 1 gas fee flows to use to obtain suitable layer 1 gas fees.
|
|
33
32
|
* @param options.onStateChange - Callback to register a listener for controller state changes.
|
|
@@ -36,7 +35,6 @@ var GasFeePoller = class {
|
|
|
36
35
|
gasFeeFlows,
|
|
37
36
|
getEthQuery,
|
|
38
37
|
getGasFeeControllerEstimates,
|
|
39
|
-
getProvider,
|
|
40
38
|
getTransactions,
|
|
41
39
|
layer1GasFeeFlows,
|
|
42
40
|
onStateChange
|
|
@@ -52,7 +50,6 @@ var GasFeePoller = class {
|
|
|
52
50
|
__privateAdd(this, _gasFeeFlows, void 0);
|
|
53
51
|
__privateAdd(this, _getEthQuery, void 0);
|
|
54
52
|
__privateAdd(this, _getGasFeeControllerEstimates, void 0);
|
|
55
|
-
__privateAdd(this, _getProvider, void 0);
|
|
56
53
|
__privateAdd(this, _getTransactions, void 0);
|
|
57
54
|
__privateAdd(this, _layer1GasFeeFlows, void 0);
|
|
58
55
|
__privateAdd(this, _timeout, void 0);
|
|
@@ -61,7 +58,6 @@ var GasFeePoller = class {
|
|
|
61
58
|
__privateSet(this, _layer1GasFeeFlows, layer1GasFeeFlows);
|
|
62
59
|
__privateSet(this, _getEthQuery, getEthQuery);
|
|
63
60
|
__privateSet(this, _getGasFeeControllerEstimates, getGasFeeControllerEstimates);
|
|
64
|
-
__privateSet(this, _getProvider, getProvider);
|
|
65
61
|
__privateSet(this, _getTransactions, getTransactions);
|
|
66
62
|
onStateChange(() => {
|
|
67
63
|
const unapprovedTransactions = __privateMethod(this, _getUnapprovedTransactions, getUnapprovedTransactions_fn).call(this);
|
|
@@ -76,7 +72,6 @@ var GasFeePoller = class {
|
|
|
76
72
|
_gasFeeFlows = new WeakMap();
|
|
77
73
|
_getEthQuery = new WeakMap();
|
|
78
74
|
_getGasFeeControllerEstimates = new WeakMap();
|
|
79
|
-
_getProvider = new WeakMap();
|
|
80
75
|
_getTransactions = new WeakMap();
|
|
81
76
|
_layer1GasFeeFlows = new WeakMap();
|
|
82
77
|
_timeout = new WeakMap();
|
|
@@ -163,9 +158,9 @@ updateTransactionSuggestedFees_fn = async function(transactionMeta) {
|
|
|
163
158
|
_updateTransactionLayer1GasFee = new WeakSet();
|
|
164
159
|
updateTransactionLayer1GasFee_fn = async function(transactionMeta) {
|
|
165
160
|
const { chainId, networkClientId } = transactionMeta;
|
|
166
|
-
const
|
|
161
|
+
const ethQuery = __privateGet(this, _getEthQuery).call(this, chainId, networkClientId);
|
|
167
162
|
await updateTransactionLayer1GasFee({
|
|
168
|
-
|
|
163
|
+
ethQuery,
|
|
169
164
|
layer1GasFeeFlows: __privateGet(this, _layer1GasFeeFlows),
|
|
170
165
|
transactionMeta
|
|
171
166
|
});
|
|
@@ -184,4 +179,4 @@ getUnapprovedTransactions_fn = function() {
|
|
|
184
179
|
export {
|
|
185
180
|
GasFeePoller
|
|
186
181
|
};
|
|
187
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-5UL3VDFT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/GasFeePoller.ts"],"sourcesContent":["import type EthQuery from '@metamask/eth-query';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport type { Hex } from '@metamask/utils';\nimport { createModuleLogger } from '@metamask/utils';\nimport EventEmitter from 'events';\n\nimport { projectLogger } from '../logger';\nimport type {\n GasFeeEstimates,\n GasFeeFlow,\n GasFeeFlowRequest,\n Layer1GasFeeFlow,\n} from '../types';\nimport { TransactionStatus, type TransactionMeta } from '../types';\nimport { getGasFeeFlow } from '../utils/gas-flow';\nimport { updateTransactionLayer1GasFee } from '../utils/layer1-gas-fee-flow';\n\nconst log = createModuleLogger(projectLogger, 'gas-fee-poller');\n\nconst INTERVAL_MILLISECONDS = 10000;\n\n/**\n * Automatically polls and updates suggested gas fees on unapproved transactions.\n */\nexport class GasFeePoller {\n hub: EventEmitter = new EventEmitter();\n\n #gasFeeFlows: GasFeeFlow[];\n\n #getEthQuery: (chainId: Hex, networkClientId?: NetworkClientId) => EthQuery;\n\n #getGasFeeControllerEstimates: () => Promise<GasFeeState>;\n\n #getTransactions: () => TransactionMeta[];\n\n #layer1GasFeeFlows: Layer1GasFeeFlow[];\n\n #timeout: ReturnType<typeof setTimeout> | undefined;\n\n #running = false;\n\n /**\n * Constructs a new instance of the GasFeePoller.\n * @param options - The options for this instance.\n * @param options.gasFeeFlows - The gas fee flows to use to obtain suitable gas fees.\n * @param options.getEthQuery - Callback to obtain an EthQuery instance.\n * @param options.getGasFeeControllerEstimates - Callback to obtain the default fee estimates.\n * @param options.getTransactions - Callback to obtain the transaction data.\n * @param options.layer1GasFeeFlows - The layer 1 gas fee flows to use to obtain suitable layer 1 gas fees.\n * @param options.onStateChange - Callback to register a listener for controller state changes.\n */\n constructor({\n gasFeeFlows,\n getEthQuery,\n getGasFeeControllerEstimates,\n getTransactions,\n layer1GasFeeFlows,\n onStateChange,\n }: {\n gasFeeFlows: GasFeeFlow[];\n getEthQuery: (chainId: Hex, networkClientId?: NetworkClientId) => EthQuery;\n getGasFeeControllerEstimates: () => Promise<GasFeeState>;\n getTransactions: () => TransactionMeta[];\n layer1GasFeeFlows: Layer1GasFeeFlow[];\n onStateChange: (listener: () => void) => void;\n }) {\n this.#gasFeeFlows = gasFeeFlows;\n this.#layer1GasFeeFlows = layer1GasFeeFlows;\n this.#getEthQuery = getEthQuery;\n this.#getGasFeeControllerEstimates = getGasFeeControllerEstimates;\n this.#getTransactions = getTransactions;\n\n onStateChange(() => {\n const unapprovedTransactions = this.#getUnapprovedTransactions();\n\n if (unapprovedTransactions.length) {\n this.#start();\n } else {\n this.#stop();\n }\n });\n }\n\n #start() {\n if (this.#running) {\n return;\n }\n\n // Intentionally not awaiting since this starts the timeout chain.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#onTimeout();\n\n this.#running = true;\n\n log('Started polling');\n }\n\n #stop() {\n if (!this.#running) {\n return;\n }\n\n clearTimeout(this.#timeout);\n\n this.#timeout = undefined;\n this.#running = false;\n\n log('Stopped polling');\n }\n\n async #onTimeout() {\n await this.#updateTransactionGasFeeEstimates();\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.#timeout = setTimeout(() => this.#onTimeout(), INTERVAL_MILLISECONDS);\n }\n\n async #updateTransactionGasFeeEstimates() {\n const unapprovedTransactions = this.#getUnapprovedTransactions();\n\n log('Found unapproved transactions', {\n count: unapprovedTransactions.length,\n });\n\n await Promise.all(\n unapprovedTransactions.flatMap((tx) => [\n this.#updateTransactionSuggestedFees(tx),\n this.#updateTransactionLayer1GasFee(tx),\n ]),\n );\n }\n\n async #updateTransactionSuggestedFees(transactionMeta: TransactionMeta) {\n const { chainId, networkClientId } = transactionMeta;\n\n const ethQuery = this.#getEthQuery(chainId, networkClientId);\n const gasFeeFlow = getGasFeeFlow(transactionMeta, this.#gasFeeFlows);\n\n if (!gasFeeFlow) {\n log('No gas fee flow found', transactionMeta.id);\n } else {\n log(\n 'Found gas fee flow',\n gasFeeFlow.constructor.name,\n transactionMeta.id,\n );\n }\n\n const request: GasFeeFlowRequest = {\n ethQuery,\n getGasFeeControllerEstimates: this.#getGasFeeControllerEstimates,\n transactionMeta,\n };\n\n let gasFeeEstimates: GasFeeEstimates | undefined;\n\n if (gasFeeFlow) {\n try {\n const response = await gasFeeFlow.getGasFees(request);\n gasFeeEstimates = response.estimates;\n } catch (error) {\n log('Failed to get suggested gas fees', transactionMeta.id, error);\n }\n }\n\n if (!gasFeeEstimates && transactionMeta.gasFeeEstimatesLoaded) {\n return;\n }\n\n const updatedTransactionMeta: TransactionMeta = {\n ...transactionMeta,\n gasFeeEstimates,\n gasFeeEstimatesLoaded: true,\n };\n\n this.hub.emit('transaction-updated', updatedTransactionMeta);\n\n log('Updated suggested gas fees', {\n gasFeeEstimates: updatedTransactionMeta.gasFeeEstimates,\n transaction: updatedTransactionMeta.id,\n });\n }\n\n async #updateTransactionLayer1GasFee(transactionMeta: TransactionMeta) {\n const { chainId, networkClientId } = transactionMeta;\n const ethQuery = this.#getEthQuery(chainId, networkClientId);\n\n await updateTransactionLayer1GasFee({\n ethQuery,\n layer1GasFeeFlows: this.#layer1GasFeeFlows,\n transactionMeta,\n });\n\n if (transactionMeta.layer1GasFee === undefined) {\n return;\n }\n\n this.hub.emit('transaction-updated', transactionMeta);\n }\n\n #getUnapprovedTransactions() {\n return this.#getTransactions().filter(\n (tx) => tx.status === TransactionStatus.unapproved,\n );\n }\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
determineTransactionType
|
|
3
|
-
} from "./chunk-JRBREX22.mjs";
|
|
4
1
|
import {
|
|
5
2
|
validateTransactionOrigin,
|
|
6
3
|
validateTxParams
|
|
@@ -9,7 +6,7 @@ import {
|
|
|
9
6
|
addGasBuffer,
|
|
10
7
|
estimateGas,
|
|
11
8
|
updateGas
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XKNFL657.mjs";
|
|
13
10
|
import {
|
|
14
11
|
addInitialHistorySnapshot,
|
|
15
12
|
updateTransactionHistory
|
|
@@ -20,19 +17,22 @@ import {
|
|
|
20
17
|
} from "./chunk-NHRBO3LU.mjs";
|
|
21
18
|
import {
|
|
22
19
|
getSimulationData
|
|
23
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-A63EOB5B.mjs";
|
|
21
|
+
import {
|
|
22
|
+
determineTransactionType
|
|
23
|
+
} from "./chunk-JRBREX22.mjs";
|
|
24
24
|
import {
|
|
25
25
|
GasFeePoller
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-5UL3VDFT.mjs";
|
|
27
|
+
import {
|
|
28
|
+
updateTransactionLayer1GasFee
|
|
29
|
+
} from "./chunk-KFL2GGZC.mjs";
|
|
27
30
|
import {
|
|
28
31
|
IncomingTransactionHelper
|
|
29
32
|
} from "./chunk-Y7ENNK7L.mjs";
|
|
30
33
|
import {
|
|
31
34
|
MultichainTrackingHelper
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import {
|
|
34
|
-
EtherscanRemoteTransactionSource
|
|
35
|
-
} from "./chunk-RU6NJIUD.mjs";
|
|
35
|
+
} from "./chunk-ZQFMTLZJ.mjs";
|
|
36
36
|
import {
|
|
37
37
|
PendingTransactionTracker
|
|
38
38
|
} from "./chunk-JRQHIBG5.mjs";
|
|
@@ -41,17 +41,17 @@ import {
|
|
|
41
41
|
} from "./chunk-FRKQ3Z2L.mjs";
|
|
42
42
|
import {
|
|
43
43
|
LineaGasFeeFlow
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-PGTV7236.mjs";
|
|
45
45
|
import {
|
|
46
46
|
DefaultGasFeeFlow
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-QRSTF45Q.mjs";
|
|
48
48
|
import {
|
|
49
49
|
updateGasFees
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-IK55QTGO.mjs";
|
|
51
51
|
import {
|
|
52
52
|
updatePostTransactionBalance,
|
|
53
53
|
updateSwapsTransaction
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-3D3SA6PY.mjs";
|
|
55
55
|
import {
|
|
56
56
|
getIncreasedPriceFromExisting,
|
|
57
57
|
isEIP1559Transaction,
|
|
@@ -65,12 +65,8 @@ import {
|
|
|
65
65
|
validateMinimumIncrease
|
|
66
66
|
} from "./chunk-J56A7UCK.mjs";
|
|
67
67
|
import {
|
|
68
|
-
|
|
69
|
-
} from "./chunk-
|
|
70
|
-
import {
|
|
71
|
-
getTransactionLayer1GasFee,
|
|
72
|
-
updateTransactionLayer1GasFee
|
|
73
|
-
} from "./chunk-OXRUL7JF.mjs";
|
|
68
|
+
EtherscanRemoteTransactionSource
|
|
69
|
+
} from "./chunk-IZI7FQIN.mjs";
|
|
74
70
|
import {
|
|
75
71
|
projectLogger
|
|
76
72
|
} from "./chunk-UQQWZT6C.mjs";
|
|
@@ -100,7 +96,7 @@ import { add0x } from "@metamask/utils";
|
|
|
100
96
|
import { Mutex } from "async-mutex";
|
|
101
97
|
import { MethodRegistry } from "eth-method-registry";
|
|
102
98
|
import { EventEmitter } from "events";
|
|
103
|
-
import { cloneDeep, mapValues, merge, pickBy, sortBy } from "lodash";
|
|
99
|
+
import { cloneDeep, mapValues, merge, pickBy, sortBy, isEqual } from "lodash";
|
|
104
100
|
import { NonceTracker } from "nonce-tracker";
|
|
105
101
|
import { v1 as random } from "uuid";
|
|
106
102
|
var metadata = {
|
|
@@ -134,7 +130,7 @@ function getDefaultTransactionControllerState() {
|
|
|
134
130
|
lastFetchedBlockNumbers: {}
|
|
135
131
|
};
|
|
136
132
|
}
|
|
137
|
-
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,
|
|
133
|
+
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;
|
|
138
134
|
var TransactionController = class extends BaseController {
|
|
139
135
|
/**
|
|
140
136
|
* Constructs a TransactionController.
|
|
@@ -214,7 +210,9 @@ var TransactionController = class extends BaseController {
|
|
|
214
210
|
__privateAdd(this, _getGasFeeFlows);
|
|
215
211
|
__privateAdd(this, _getLayer1GasFeeFlows);
|
|
216
212
|
__privateAdd(this, _updateTransactionInternal);
|
|
217
|
-
__privateAdd(this,
|
|
213
|
+
__privateAdd(this, _checkIfTransactionParamsUpdated);
|
|
214
|
+
__privateAdd(this, _onTransactionParamsUpdated);
|
|
215
|
+
__privateAdd(this, _updateSimulationData);
|
|
218
216
|
__privateAdd(this, _internalEvents, new EventEmitter());
|
|
219
217
|
this.inProcessOfSigning = /* @__PURE__ */ new Set();
|
|
220
218
|
this.mutex = new Mutex();
|
|
@@ -310,10 +308,6 @@ var TransactionController = class extends BaseController {
|
|
|
310
308
|
chainId
|
|
311
309
|
}),
|
|
312
310
|
getGasFeeControllerEstimates: this.getGasFeeEstimates,
|
|
313
|
-
getProvider: (chainId, networkClientId) => __privateGet(this, _multichainTrackingHelper).getProvider({
|
|
314
|
-
networkClientId,
|
|
315
|
-
chainId
|
|
316
|
-
}),
|
|
317
311
|
getTransactions: () => this.state.transactions,
|
|
318
312
|
layer1GasFeeFlows: this.layer1GasFeeFlows,
|
|
319
313
|
onStateChange: (listener) => {
|
|
@@ -484,10 +478,7 @@ var TransactionController = class extends BaseController {
|
|
|
484
478
|
type: transactionType,
|
|
485
479
|
networkClientId
|
|
486
480
|
};
|
|
487
|
-
await
|
|
488
|
-
this.updateGasProperties(addedTransactionMeta),
|
|
489
|
-
__privateMethod(this, _simulateTransaction, simulateTransaction_fn).call(this, addedTransactionMeta)
|
|
490
|
-
]);
|
|
481
|
+
await this.updateGasProperties(addedTransactionMeta);
|
|
491
482
|
if (!existingTransactionMeta) {
|
|
492
483
|
if (method && this.securityProviderRequest) {
|
|
493
484
|
const securityProviderResponse = await this.securityProviderRequest(
|
|
@@ -513,6 +504,7 @@ var TransactionController = class extends BaseController {
|
|
|
513
504
|
}
|
|
514
505
|
);
|
|
515
506
|
this.addMetadata(addedTransactionMeta);
|
|
507
|
+
__privateMethod(this, _updateSimulationData, updateSimulationData_fn).call(this, addedTransactionMeta);
|
|
516
508
|
this.messagingSystem.publish(
|
|
517
509
|
`${controllerName}:unapprovedTransactionAdded`,
|
|
518
510
|
addedTransactionMeta
|
|
@@ -1149,18 +1141,14 @@ var TransactionController = class extends BaseController {
|
|
|
1149
1141
|
networkClientId: transactionMeta.networkClientId,
|
|
1150
1142
|
chainId: transactionMeta.chainId
|
|
1151
1143
|
});
|
|
1152
|
-
const provider = __privateGet(this, _multichainTrackingHelper).getProvider({
|
|
1153
|
-
chainId: transactionMeta.chainId,
|
|
1154
|
-
networkClientId: transactionMeta.networkClientId
|
|
1155
|
-
});
|
|
1156
1144
|
const { type } = await determineTransactionType(
|
|
1157
1145
|
updatedTransaction.txParams,
|
|
1158
1146
|
ethQuery
|
|
1159
1147
|
);
|
|
1160
1148
|
updatedTransaction.type = type;
|
|
1161
1149
|
await updateTransactionLayer1GasFee({
|
|
1150
|
+
ethQuery,
|
|
1162
1151
|
layer1GasFeeFlows: this.layer1GasFeeFlows,
|
|
1163
|
-
provider,
|
|
1164
1152
|
transactionMeta: updatedTransaction
|
|
1165
1153
|
});
|
|
1166
1154
|
this.updateTransaction(
|
|
@@ -1364,28 +1352,6 @@ var TransactionController = class extends BaseController {
|
|
|
1364
1352
|
}
|
|
1365
1353
|
return filteredTransactions;
|
|
1366
1354
|
}
|
|
1367
|
-
/**
|
|
1368
|
-
* Utility method to get the layer 1 gas fee for given transaction params.
|
|
1369
|
-
*
|
|
1370
|
-
* @param chainId - Estimated transaction chainId.
|
|
1371
|
-
* @param networkClientId - Estimated transaction networkClientId.
|
|
1372
|
-
* @param transactionParams - The transaction params to estimate layer 1 gas fee for.
|
|
1373
|
-
*/
|
|
1374
|
-
async getLayer1GasFee(chainId, networkClientId, transactionParams) {
|
|
1375
|
-
const provider = __privateGet(this, _multichainTrackingHelper).getProvider({
|
|
1376
|
-
networkClientId,
|
|
1377
|
-
chainId
|
|
1378
|
-
});
|
|
1379
|
-
const layer1GasFee = await getTransactionLayer1GasFee({
|
|
1380
|
-
layer1GasFeeFlows: this.layer1GasFeeFlows,
|
|
1381
|
-
provider,
|
|
1382
|
-
transactionMeta: {
|
|
1383
|
-
txParams: transactionParams,
|
|
1384
|
-
chainId
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1387
|
-
return layer1GasFee;
|
|
1388
|
-
}
|
|
1389
1355
|
async signExternalTransaction(chainId, transactionParams) {
|
|
1390
1356
|
if (!this.sign) {
|
|
1391
1357
|
throw new Error("No sign method defined.");
|
|
@@ -1457,10 +1423,6 @@ var TransactionController = class extends BaseController {
|
|
|
1457
1423
|
networkClientId,
|
|
1458
1424
|
chainId
|
|
1459
1425
|
});
|
|
1460
|
-
const provider = __privateGet(this, _multichainTrackingHelper).getProvider({
|
|
1461
|
-
networkClientId,
|
|
1462
|
-
chainId
|
|
1463
|
-
});
|
|
1464
1426
|
await updateGas({
|
|
1465
1427
|
ethQuery,
|
|
1466
1428
|
chainId,
|
|
@@ -1476,8 +1438,8 @@ var TransactionController = class extends BaseController {
|
|
|
1476
1438
|
txMeta: transactionMeta
|
|
1477
1439
|
});
|
|
1478
1440
|
await updateTransactionLayer1GasFee({
|
|
1441
|
+
ethQuery,
|
|
1479
1442
|
layer1GasFeeFlows: this.layer1GasFeeFlows,
|
|
1480
|
-
provider,
|
|
1481
1443
|
transactionMeta
|
|
1482
1444
|
});
|
|
1483
1445
|
}
|
|
@@ -2322,7 +2284,7 @@ getGasFeeFlows_fn = function() {
|
|
|
2322
2284
|
};
|
|
2323
2285
|
_getLayer1GasFeeFlows = new WeakSet();
|
|
2324
2286
|
getLayer1GasFeeFlows_fn = function() {
|
|
2325
|
-
return [
|
|
2287
|
+
return [];
|
|
2326
2288
|
};
|
|
2327
2289
|
_updateTransactionInternal = new WeakSet();
|
|
2328
2290
|
updateTransactionInternal_fn = function(transactionMeta, { note, skipHistory }) {
|
|
@@ -2331,6 +2293,7 @@ updateTransactionInternal_fn = function(transactionMeta, { note, skipHistory })
|
|
|
2331
2293
|
txParams: normalizeTransactionParams(transactionMeta.txParams)
|
|
2332
2294
|
};
|
|
2333
2295
|
validateTxParams(normalizedTransaction.txParams);
|
|
2296
|
+
const updatedTransactionParams = __privateMethod(this, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn).call(this, normalizedTransaction);
|
|
2334
2297
|
const transactionWithUpdatedHistory = skipHistory === true ? normalizedTransaction : updateTransactionHistory(
|
|
2335
2298
|
normalizedTransaction,
|
|
2336
2299
|
note ?? "Transaction updated"
|
|
@@ -2341,23 +2304,74 @@ updateTransactionInternal_fn = function(transactionMeta, { note, skipHistory })
|
|
|
2341
2304
|
);
|
|
2342
2305
|
state.transactions[index] = transactionWithUpdatedHistory;
|
|
2343
2306
|
});
|
|
2307
|
+
if (updatedTransactionParams.length > 0) {
|
|
2308
|
+
__privateMethod(this, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn).call(this, normalizedTransaction, updatedTransactionParams);
|
|
2309
|
+
}
|
|
2344
2310
|
};
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2311
|
+
_checkIfTransactionParamsUpdated = new WeakSet();
|
|
2312
|
+
checkIfTransactionParamsUpdated_fn = function(newTransactionMeta) {
|
|
2313
|
+
const { id: transactionId, txParams: newParams } = newTransactionMeta;
|
|
2314
|
+
const originalParams = this.getTransaction(transactionId)?.txParams;
|
|
2315
|
+
if (!originalParams || isEqual(originalParams, newParams)) {
|
|
2316
|
+
return [];
|
|
2317
|
+
}
|
|
2318
|
+
const params = Object.keys(newParams);
|
|
2319
|
+
const updatedProperties = params.filter(
|
|
2320
|
+
(param) => newParams[param] !== originalParams[param]
|
|
2321
|
+
);
|
|
2322
|
+
projectLogger(
|
|
2323
|
+
"Transaction parameters have been updated",
|
|
2324
|
+
transactionId,
|
|
2325
|
+
updatedProperties,
|
|
2326
|
+
originalParams,
|
|
2327
|
+
newParams
|
|
2328
|
+
);
|
|
2329
|
+
return updatedProperties;
|
|
2330
|
+
};
|
|
2331
|
+
_onTransactionParamsUpdated = new WeakSet();
|
|
2332
|
+
onTransactionParamsUpdated_fn = function(transactionMeta, updatedParams) {
|
|
2333
|
+
if (["to", "value", "data"].some(
|
|
2334
|
+
(param) => updatedParams.includes(param)
|
|
2335
|
+
)) {
|
|
2336
|
+
projectLogger("Updating simulation data due to transaction parameter update");
|
|
2337
|
+
__privateMethod(this, _updateSimulationData, updateSimulationData_fn).call(this, transactionMeta);
|
|
2350
2338
|
}
|
|
2351
|
-
|
|
2339
|
+
};
|
|
2340
|
+
_updateSimulationData = new WeakSet();
|
|
2341
|
+
updateSimulationData_fn = async function(transactionMeta) {
|
|
2342
|
+
const { id, chainId, txParams } = transactionMeta;
|
|
2352
2343
|
const { from, to, value, data } = txParams;
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
}
|
|
2360
|
-
|
|
2344
|
+
let simulationData = {
|
|
2345
|
+
error: {
|
|
2346
|
+
message: "Simulation disabled",
|
|
2347
|
+
isReverted: false
|
|
2348
|
+
},
|
|
2349
|
+
tokenBalanceChanges: []
|
|
2350
|
+
};
|
|
2351
|
+
if (__privateGet(this, _isSimulationEnabled).call(this)) {
|
|
2352
|
+
__privateMethod(this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, { ...transactionMeta, simulationData: void 0 }, { skipHistory: true });
|
|
2353
|
+
simulationData = await getSimulationData({
|
|
2354
|
+
chainId,
|
|
2355
|
+
from,
|
|
2356
|
+
to,
|
|
2357
|
+
value,
|
|
2358
|
+
data
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
const finalTransactionMeta = this.getTransaction(id);
|
|
2362
|
+
if (!finalTransactionMeta) {
|
|
2363
|
+
projectLogger(
|
|
2364
|
+
"Cannot update simulation data as transaction not found",
|
|
2365
|
+
id,
|
|
2366
|
+
simulationData
|
|
2367
|
+
);
|
|
2368
|
+
return;
|
|
2369
|
+
}
|
|
2370
|
+
this.updateTransaction(
|
|
2371
|
+
{ ...finalTransactionMeta, simulationData },
|
|
2372
|
+
"TransactionController#updateSimulationData - Update simulation data"
|
|
2373
|
+
);
|
|
2374
|
+
projectLogger("Updated simulation data", id, simulationData);
|
|
2361
2375
|
};
|
|
2362
2376
|
|
|
2363
2377
|
export {
|
|
@@ -2367,4 +2381,4 @@ export {
|
|
|
2367
2381
|
ApprovalState,
|
|
2368
2382
|
TransactionController
|
|
2369
2383
|
};
|
|
2370
|
-
//# sourceMappingURL=chunk-
|
|
2384
|
+
//# sourceMappingURL=chunk-6ANFIDWC.mjs.map
|