@metamask/transaction-controller 27.0.1 → 28.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -1
- package/dist/TransactionController.js +19 -17
- package/dist/TransactionController.mjs +18 -16
- package/dist/{chunk-5WFLNKCL.js → chunk-2XKEAKQG.js} +11 -5
- package/dist/chunk-2XKEAKQG.js.map +1 -0
- package/dist/{chunk-LYD4TEKH.js → chunk-4RJXBKSR.js} +5 -5
- package/dist/{chunk-DRSMLO7B.mjs → chunk-5G6OHAXI.mjs} +2 -2
- package/dist/{chunk-CPYXP2OC.js → chunk-5XQ2KRYL.js} +3 -3
- package/dist/{chunk-WLCFETHR.js → chunk-C2LNDHP4.js} +10 -10
- package/dist/{chunk-TKWTUPCQ.mjs → chunk-CPMTUMMZ.mjs} +3 -3
- package/dist/{chunk-5SKCGFUC.js → chunk-DMMUAJKY.js} +106 -66
- package/dist/chunk-DMMUAJKY.js.map +1 -0
- package/dist/{chunk-L337FYVS.js → chunk-EQNKFFTM.js} +3 -3
- package/dist/{chunk-3JEUO765.js → chunk-EQT25RSP.js} +6 -6
- package/dist/{chunk-RXRJSBSF.mjs → chunk-F6E3TTR3.mjs} +2 -2
- package/dist/{chunk-F247MMTE.js → chunk-FDUCRHYT.js} +3 -3
- package/dist/chunk-FG74Z3F5.mjs +102 -0
- package/dist/chunk-FG74Z3F5.mjs.map +1 -0
- package/dist/{chunk-35MG26Y3.mjs → chunk-HHK4QSNF.mjs} +44 -34
- package/dist/chunk-HHK4QSNF.mjs.map +1 -0
- package/dist/{chunk-L7ZKSKEI.mjs → chunk-IZVRGO3P.mjs} +2 -2
- package/dist/{chunk-3VF7ZGRV.js → chunk-JAYYMCBQ.js} +4 -4
- package/dist/{chunk-P74YLPJO.mjs → chunk-LDXTSESK.mjs} +2 -2
- package/dist/{chunk-UBXRAA6G.js → chunk-LNX4JTOL.js} +3 -3
- package/dist/{chunk-JDLNCMGI.mjs → chunk-MG7HTD3H.mjs} +94 -54
- package/dist/chunk-MG7HTD3H.mjs.map +1 -0
- package/dist/{chunk-2XFBWPHD.mjs → chunk-NCRWKI6Y.mjs} +2 -2
- package/dist/{chunk-W3CS5GRD.mjs → chunk-NOHEXQ7Y.mjs} +11 -5
- package/dist/chunk-NOHEXQ7Y.mjs.map +1 -0
- package/dist/{chunk-CWWZQZVR.mjs → chunk-NPEXNXSY.mjs} +2 -2
- package/dist/chunk-NYKRCWBG.js +31 -0
- package/dist/chunk-NYKRCWBG.js.map +1 -0
- package/dist/{chunk-4VLQV2GA.mjs → chunk-O6ZZVIFH.mjs} +4 -2
- package/dist/{chunk-LQS2M5QR.js.map → chunk-O6ZZVIFH.mjs.map} +1 -1
- package/dist/{chunk-DOX6H5UJ.mjs → chunk-QZLPYOGC.mjs} +2 -2
- package/dist/{chunk-LQS2M5QR.js → chunk-UGN7PBON.js} +4 -2
- package/dist/chunk-UGN7PBON.js.map +1 -0
- package/dist/{chunk-HUVOOFOM.js → chunk-V6UIRCOF.js} +43 -33
- package/dist/chunk-V6UIRCOF.js.map +1 -0
- package/dist/{chunk-AO3AE3L7.js → chunk-V72C4MCR.js} +3 -3
- package/dist/chunk-VEVVBHP3.mjs +31 -0
- package/dist/chunk-VEVVBHP3.mjs.map +1 -0
- package/dist/chunk-WR5F34OW.js +23 -0
- package/dist/chunk-WR5F34OW.js.map +1 -0
- package/dist/chunk-YVCX6Z75.js +102 -0
- package/dist/chunk-YVCX6Z75.js.map +1 -0
- package/dist/chunk-Z4GV3YQQ.mjs +23 -0
- package/dist/chunk-Z4GV3YQQ.mjs.map +1 -0
- package/dist/{chunk-RBF6CW7D.mjs → chunk-ZGUNOEUQ.mjs} +2 -2
- package/dist/constants.js +2 -2
- package/dist/constants.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/OptimismLayer1GasFeeFlow.js +4 -3
- package/dist/gas-flows/OptimismLayer1GasFeeFlow.mjs +3 -2
- package/dist/gas-flows/OracleLayer1GasFeeFlow.js +9 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.js.map +1 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs +9 -0
- package/dist/gas-flows/OracleLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.js +11 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.js.map +1 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs +11 -0
- package/dist/gas-flows/ScrollLayer1GasFeeFlow.mjs.map +1 -0
- package/dist/helpers/EtherscanRemoteTransactionSource.js +4 -4
- package/dist/helpers/EtherscanRemoteTransactionSource.mjs +3 -3
- package/dist/helpers/GasFeePoller.js +3 -3
- package/dist/helpers/GasFeePoller.mjs +2 -2
- package/dist/helpers/MultichainTrackingHelper.js +5 -5
- package/dist/helpers/MultichainTrackingHelper.mjs +4 -4
- package/dist/index.js +19 -17
- package/dist/index.mjs +18 -16
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/TransactionController.d.ts +11 -6
- package/dist/types/TransactionController.d.ts.map +1 -1
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts +5 -5
- package/dist/types/gas-flows/OptimismLayer1GasFeeFlow.d.ts.map +1 -1
- package/dist/types/gas-flows/OracleLayer1GasFeeFlow.d.ts +12 -0
- package/dist/types/gas-flows/OracleLayer1GasFeeFlow.d.ts.map +1 -0
- package/dist/types/gas-flows/ScrollLayer1GasFeeFlow.d.ts +10 -0
- package/dist/types/gas-flows/ScrollLayer1GasFeeFlow.d.ts.map +1 -0
- package/dist/types/helpers/GasFeePoller.d.ts.map +1 -1
- package/dist/types/utils/layer1-gas-fee-flow.d.ts.map +1 -1
- package/dist/utils/etherscan.js +3 -3
- package/dist/utils/etherscan.mjs +2 -2
- package/dist/utils/gas-fees.js +4 -4
- package/dist/utils/gas-fees.mjs +3 -3
- package/dist/utils/gas.js +3 -3
- package/dist/utils/gas.mjs +2 -2
- package/dist/utils/layer1-gas-fee-flow.js +2 -2
- package/dist/utils/layer1-gas-fee-flow.mjs +1 -1
- package/dist/utils/simulation.js +3 -3
- package/dist/utils/simulation.mjs +2 -2
- package/dist/utils/swaps.js +3 -3
- package/dist/utils/swaps.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunk-35MG26Y3.mjs.map +0 -1
- package/dist/chunk-4VLQV2GA.mjs.map +0 -1
- package/dist/chunk-53IYIDVS.mjs +0 -132
- package/dist/chunk-53IYIDVS.mjs.map +0 -1
- package/dist/chunk-5SKCGFUC.js.map +0 -1
- package/dist/chunk-5WFLNKCL.js.map +0 -1
- package/dist/chunk-ETMW527M.js +0 -132
- package/dist/chunk-ETMW527M.js.map +0 -1
- package/dist/chunk-HUVOOFOM.js.map +0 -1
- package/dist/chunk-JDLNCMGI.mjs.map +0 -1
- package/dist/chunk-W3CS5GRD.mjs.map +0 -1
- /package/dist/{chunk-LYD4TEKH.js.map → chunk-4RJXBKSR.js.map} +0 -0
- /package/dist/{chunk-DRSMLO7B.mjs.map → chunk-5G6OHAXI.mjs.map} +0 -0
- /package/dist/{chunk-CPYXP2OC.js.map → chunk-5XQ2KRYL.js.map} +0 -0
- /package/dist/{chunk-WLCFETHR.js.map → chunk-C2LNDHP4.js.map} +0 -0
- /package/dist/{chunk-TKWTUPCQ.mjs.map → chunk-CPMTUMMZ.mjs.map} +0 -0
- /package/dist/{chunk-L337FYVS.js.map → chunk-EQNKFFTM.js.map} +0 -0
- /package/dist/{chunk-3JEUO765.js.map → chunk-EQT25RSP.js.map} +0 -0
- /package/dist/{chunk-RXRJSBSF.mjs.map → chunk-F6E3TTR3.mjs.map} +0 -0
- /package/dist/{chunk-F247MMTE.js.map → chunk-FDUCRHYT.js.map} +0 -0
- /package/dist/{chunk-L7ZKSKEI.mjs.map → chunk-IZVRGO3P.mjs.map} +0 -0
- /package/dist/{chunk-3VF7ZGRV.js.map → chunk-JAYYMCBQ.js.map} +0 -0
- /package/dist/{chunk-P74YLPJO.mjs.map → chunk-LDXTSESK.mjs.map} +0 -0
- /package/dist/{chunk-UBXRAA6G.js.map → chunk-LNX4JTOL.js.map} +0 -0
- /package/dist/{chunk-2XFBWPHD.mjs.map → chunk-NCRWKI6Y.mjs.map} +0 -0
- /package/dist/{chunk-CWWZQZVR.mjs.map → chunk-NPEXNXSY.mjs.map} +0 -0
- /package/dist/{chunk-DOX6H5UJ.mjs.map → chunk-QZLPYOGC.mjs.map} +0 -0
- /package/dist/{chunk-AO3AE3L7.js.map → chunk-V72C4MCR.js.map} +0 -0
- /package/dist/{chunk-RBF6CW7D.mjs.map → chunk-ZGUNOEUQ.mjs.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
getTransactionLayer1GasFee
|
|
3
|
+
} from "./chunk-NOHEXQ7Y.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getGasFeeFlow
|
|
6
6
|
} from "./chunk-TWND5SFD.mjs";
|
|
@@ -20,7 +20,7 @@ import { createModuleLogger } from "@metamask/utils";
|
|
|
20
20
|
import EventEmitter from "events";
|
|
21
21
|
var log = createModuleLogger(projectLogger, "gas-fee-poller");
|
|
22
22
|
var INTERVAL_MILLISECONDS = 1e4;
|
|
23
|
-
var _gasFeeFlows, _getGasFeeControllerEstimates, _getProvider, _getTransactions, _layer1GasFeeFlows, _timeout, _running, _start, start_fn, _stop, stop_fn, _onTimeout, onTimeout_fn,
|
|
23
|
+
var _gasFeeFlows, _getGasFeeControllerEstimates, _getProvider, _getTransactions, _layer1GasFeeFlows, _timeout, _running, _start, start_fn, _stop, stop_fn, _onTimeout, onTimeout_fn, _updateUnapprovedTransactions, updateUnapprovedTransactions_fn, _updateUnapprovedTransaction, updateUnapprovedTransaction_fn, _updateTransactionGasFeeEstimates, updateTransactionGasFeeEstimates_fn, _updateTransactionLayer1GasFee, updateTransactionLayer1GasFee_fn, _getUnapprovedTransactions, getUnapprovedTransactions_fn;
|
|
24
24
|
var GasFeePoller = class {
|
|
25
25
|
/**
|
|
26
26
|
* Constructs a new instance of the GasFeePoller.
|
|
@@ -43,8 +43,9 @@ var GasFeePoller = class {
|
|
|
43
43
|
__privateAdd(this, _start);
|
|
44
44
|
__privateAdd(this, _stop);
|
|
45
45
|
__privateAdd(this, _onTimeout);
|
|
46
|
+
__privateAdd(this, _updateUnapprovedTransactions);
|
|
47
|
+
__privateAdd(this, _updateUnapprovedTransaction);
|
|
46
48
|
__privateAdd(this, _updateTransactionGasFeeEstimates);
|
|
47
|
-
__privateAdd(this, _updateTransactionSuggestedFees);
|
|
48
49
|
__privateAdd(this, _updateTransactionLayer1GasFee);
|
|
49
50
|
__privateAdd(this, _getUnapprovedTransactions);
|
|
50
51
|
this.hub = new EventEmitter();
|
|
@@ -98,30 +99,44 @@ stop_fn = function() {
|
|
|
98
99
|
};
|
|
99
100
|
_onTimeout = new WeakSet();
|
|
100
101
|
onTimeout_fn = async function() {
|
|
101
|
-
await __privateMethod(this,
|
|
102
|
+
await __privateMethod(this, _updateUnapprovedTransactions, updateUnapprovedTransactions_fn).call(this);
|
|
102
103
|
__privateSet(this, _timeout, setTimeout(() => __privateMethod(this, _onTimeout, onTimeout_fn).call(this), INTERVAL_MILLISECONDS));
|
|
103
104
|
};
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
_updateUnapprovedTransactions = new WeakSet();
|
|
106
|
+
updateUnapprovedTransactions_fn = async function() {
|
|
106
107
|
const unapprovedTransactions = __privateMethod(this, _getUnapprovedTransactions, getUnapprovedTransactions_fn).call(this);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
108
|
+
if (unapprovedTransactions.length) {
|
|
109
|
+
log("Found unapproved transactions", unapprovedTransactions.length);
|
|
110
|
+
}
|
|
110
111
|
await Promise.all(
|
|
111
|
-
unapprovedTransactions.flatMap(
|
|
112
|
-
__privateMethod(this,
|
|
113
|
-
|
|
114
|
-
])
|
|
112
|
+
unapprovedTransactions.flatMap(
|
|
113
|
+
(tx) => __privateMethod(this, _updateUnapprovedTransaction, updateUnapprovedTransaction_fn).call(this, tx)
|
|
114
|
+
)
|
|
115
115
|
);
|
|
116
116
|
};
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
_updateUnapprovedTransaction = new WeakSet();
|
|
118
|
+
updateUnapprovedTransaction_fn = async function(transactionMeta) {
|
|
119
|
+
const { id } = transactionMeta;
|
|
120
|
+
const [gasFeeEstimatesResponse, layer1GasFee] = await Promise.all([
|
|
121
|
+
__privateMethod(this, _updateTransactionGasFeeEstimates, updateTransactionGasFeeEstimates_fn).call(this, transactionMeta),
|
|
122
|
+
__privateMethod(this, _updateTransactionLayer1GasFee, updateTransactionLayer1GasFee_fn).call(this, transactionMeta)
|
|
123
|
+
]);
|
|
124
|
+
if (!gasFeeEstimatesResponse && !layer1GasFee) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.hub.emit("transaction-updated", {
|
|
128
|
+
transactionId: id,
|
|
129
|
+
gasFeeEstimates: gasFeeEstimatesResponse?.gasFeeEstimates,
|
|
130
|
+
gasFeeEstimatesLoaded: gasFeeEstimatesResponse?.gasFeeEstimatesLoaded,
|
|
131
|
+
layer1GasFee
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
_updateTransactionGasFeeEstimates = new WeakSet();
|
|
135
|
+
updateTransactionGasFeeEstimates_fn = async function(transactionMeta) {
|
|
119
136
|
const { chainId, networkClientId } = transactionMeta;
|
|
120
137
|
const ethQuery = new EthQuery(__privateGet(this, _getProvider).call(this, chainId, networkClientId));
|
|
121
138
|
const gasFeeFlow = getGasFeeFlow(transactionMeta, __privateGet(this, _gasFeeFlows));
|
|
122
|
-
if (
|
|
123
|
-
log("No gas fee flow found", transactionMeta.id);
|
|
124
|
-
} else {
|
|
139
|
+
if (gasFeeFlow) {
|
|
125
140
|
log(
|
|
126
141
|
"Found gas fee flow",
|
|
127
142
|
gasFeeFlow.constructor.name,
|
|
@@ -143,32 +158,27 @@ updateTransactionSuggestedFees_fn = async function(transactionMeta) {
|
|
|
143
158
|
}
|
|
144
159
|
}
|
|
145
160
|
if (!gasFeeEstimates && transactionMeta.gasFeeEstimatesLoaded) {
|
|
146
|
-
return;
|
|
161
|
+
return void 0;
|
|
147
162
|
}
|
|
148
|
-
|
|
149
|
-
...transactionMeta,
|
|
163
|
+
log("Updated gas fee estimates", {
|
|
150
164
|
gasFeeEstimates,
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
this.hub.emit("transaction-updated", updatedTransactionMeta);
|
|
154
|
-
log("Updated suggested gas fees", {
|
|
155
|
-
gasFeeEstimates: updatedTransactionMeta.gasFeeEstimates,
|
|
156
|
-
transaction: updatedTransactionMeta.id
|
|
165
|
+
transaction: transactionMeta.id
|
|
157
166
|
});
|
|
167
|
+
return { gasFeeEstimates, gasFeeEstimatesLoaded: true };
|
|
158
168
|
};
|
|
159
169
|
_updateTransactionLayer1GasFee = new WeakSet();
|
|
160
170
|
updateTransactionLayer1GasFee_fn = async function(transactionMeta) {
|
|
161
171
|
const { chainId, networkClientId } = transactionMeta;
|
|
162
172
|
const provider = __privateGet(this, _getProvider).call(this, chainId, networkClientId);
|
|
163
|
-
await
|
|
164
|
-
provider,
|
|
173
|
+
const layer1GasFee = await getTransactionLayer1GasFee({
|
|
165
174
|
layer1GasFeeFlows: __privateGet(this, _layer1GasFeeFlows),
|
|
175
|
+
provider,
|
|
166
176
|
transactionMeta
|
|
167
177
|
});
|
|
168
|
-
if (
|
|
169
|
-
|
|
178
|
+
if (layer1GasFee) {
|
|
179
|
+
log("Updated layer 1 gas fee", layer1GasFee, transactionMeta.id);
|
|
170
180
|
}
|
|
171
|
-
|
|
181
|
+
return layer1GasFee;
|
|
172
182
|
};
|
|
173
183
|
_getUnapprovedTransactions = new WeakSet();
|
|
174
184
|
getUnapprovedTransactions_fn = function() {
|
|
@@ -180,4 +190,4 @@ getUnapprovedTransactions_fn = function() {
|
|
|
180
190
|
export {
|
|
181
191
|
GasFeePoller
|
|
182
192
|
};
|
|
183
|
-
//# sourceMappingURL=chunk-
|
|
193
|
+
//# sourceMappingURL=chunk-HHK4QSNF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/GasFeePoller.ts"],"sourcesContent":["import EthQuery from '@metamask/eth-query';\nimport type { GasFeeState } from '@metamask/gas-fee-controller';\nimport type { NetworkClientId, Provider } 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 { getTransactionLayer1GasFee } 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 #getGasFeeControllerEstimates: () => Promise<GasFeeState>;\n\n #getProvider: (chainId: Hex, networkClientId?: NetworkClientId) => Provider;\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.getGasFeeControllerEstimates - Callback to obtain the default fee estimates.\n * @param options.getProvider - Callback to obtain a provider instance.\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 getGasFeeControllerEstimates,\n getProvider,\n getTransactions,\n layer1GasFeeFlows,\n onStateChange,\n }: {\n gasFeeFlows: GasFeeFlow[];\n getGasFeeControllerEstimates: () => Promise<GasFeeState>;\n getProvider: (chainId: Hex, networkClientId?: NetworkClientId) => Provider;\n getTransactions: () => TransactionMeta[];\n layer1GasFeeFlows: Layer1GasFeeFlow[];\n onStateChange: (listener: () => void) => void;\n }) {\n this.#gasFeeFlows = gasFeeFlows;\n this.#layer1GasFeeFlows = layer1GasFeeFlows;\n this.#getGasFeeControllerEstimates = getGasFeeControllerEstimates;\n this.#getProvider = getProvider;\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.#updateUnapprovedTransactions();\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.#timeout = setTimeout(() => this.#onTimeout(), INTERVAL_MILLISECONDS);\n }\n\n async #updateUnapprovedTransactions() {\n const unapprovedTransactions = this.#getUnapprovedTransactions();\n\n if (unapprovedTransactions.length) {\n log('Found unapproved transactions', unapprovedTransactions.length);\n }\n\n await Promise.all(\n unapprovedTransactions.flatMap((tx) =>\n this.#updateUnapprovedTransaction(tx),\n ),\n );\n }\n\n async #updateUnapprovedTransaction(transactionMeta: TransactionMeta) {\n const { id } = transactionMeta;\n\n const [gasFeeEstimatesResponse, layer1GasFee] = await Promise.all([\n this.#updateTransactionGasFeeEstimates(transactionMeta),\n this.#updateTransactionLayer1GasFee(transactionMeta),\n ]);\n\n if (!gasFeeEstimatesResponse && !layer1GasFee) {\n return;\n }\n\n this.hub.emit('transaction-updated', {\n transactionId: id,\n gasFeeEstimates: gasFeeEstimatesResponse?.gasFeeEstimates,\n gasFeeEstimatesLoaded: gasFeeEstimatesResponse?.gasFeeEstimatesLoaded,\n layer1GasFee,\n });\n }\n\n async #updateTransactionGasFeeEstimates(\n transactionMeta: TransactionMeta,\n ): Promise<\n | { gasFeeEstimates?: GasFeeEstimates; gasFeeEstimatesLoaded: boolean }\n | undefined\n > {\n const { chainId, networkClientId } = transactionMeta;\n\n const ethQuery = new EthQuery(this.#getProvider(chainId, networkClientId));\n const gasFeeFlow = getGasFeeFlow(transactionMeta, this.#gasFeeFlows);\n\n if (gasFeeFlow) {\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 undefined;\n }\n\n log('Updated gas fee estimates', {\n gasFeeEstimates,\n transaction: transactionMeta.id,\n });\n\n return { gasFeeEstimates, gasFeeEstimatesLoaded: true };\n }\n\n async #updateTransactionLayer1GasFee(\n transactionMeta: TransactionMeta,\n ): Promise<Hex | undefined> {\n const { chainId, networkClientId } = transactionMeta;\n const provider = this.#getProvider(chainId, networkClientId);\n\n const layer1GasFee = await getTransactionLayer1GasFee({\n layer1GasFeeFlows: this.#layer1GasFeeFlows,\n provider,\n transactionMeta,\n });\n\n if (layer1GasFee) {\n log('Updated layer 1 gas fee', layer1GasFee, transactionMeta.id);\n }\n\n return layer1GasFee;\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":[]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
ABI_SIMULATION_ERC20_WRAPPED,
|
|
11
11
|
ABI_SIMULATION_ERC721_LEGACY
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-O6ZZVIFH.mjs";
|
|
13
13
|
import {
|
|
14
14
|
projectLogger
|
|
15
15
|
} from "./chunk-UQQWZT6C.mjs";
|
|
@@ -333,4 +333,4 @@ export {
|
|
|
333
333
|
SupportedToken,
|
|
334
334
|
getSimulationData
|
|
335
335
|
};
|
|
336
|
-
//# sourceMappingURL=chunk-
|
|
336
|
+
//# sourceMappingURL=chunk-IZVRGO3P.mjs.map
|
|
@@ -9,7 +9,7 @@ var _chunkHMOSP33Fjs = require('./chunk-HMOSP33F.js');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkUGN7PBONjs = require('./chunk-UGN7PBON.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -49,11 +49,11 @@ var SUPPORTED_TOKEN_ABIS = {
|
|
|
49
49
|
standard: "erc1155" /* erc1155 */
|
|
50
50
|
},
|
|
51
51
|
["erc20Wrapped" /* ERC20_WRAPPED */]: {
|
|
52
|
-
abi:
|
|
52
|
+
abi: _chunkUGN7PBONjs.ABI_SIMULATION_ERC20_WRAPPED,
|
|
53
53
|
standard: "erc20" /* erc20 */
|
|
54
54
|
},
|
|
55
55
|
["erc721Legacy" /* ERC721_LEGACY */]: {
|
|
56
|
-
abi:
|
|
56
|
+
abi: _chunkUGN7PBONjs.ABI_SIMULATION_ERC721_LEGACY,
|
|
57
57
|
standard: "erc721" /* erc721 */
|
|
58
58
|
}
|
|
59
59
|
};
|
|
@@ -333,4 +333,4 @@ function getContractInterfaces() {
|
|
|
333
333
|
|
|
334
334
|
|
|
335
335
|
exports.SupportedToken = SupportedToken; exports.getSimulationData = getSimulationData;
|
|
336
|
-
//# sourceMappingURL=chunk-
|
|
336
|
+
//# sourceMappingURL=chunk-JAYYMCBQ.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SWAP_TRANSACTION_TYPES
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZGUNOEUQ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getGasFeeFlow
|
|
6
6
|
} from "./chunk-TWND5SFD.mjs";
|
|
@@ -205,4 +205,4 @@ export {
|
|
|
205
205
|
updateGasFees,
|
|
206
206
|
gweiDecimalToWeiHex
|
|
207
207
|
};
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-LDXTSESK.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk4RJXBKSRjs = require('./chunk-4RJXBKSR.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS6VGOPUYjs = require('./chunk-S6VGOPUY.js');
|
|
@@ -48,7 +48,7 @@ var LineaGasFeeFlow = class {
|
|
|
48
48
|
return await _chunkZ4BLTVTBjs.__privateMethod.call(void 0, this, _getLineaGasFees, getLineaGasFees_fn).call(this, request);
|
|
49
49
|
} catch (error) {
|
|
50
50
|
log("Using default flow as fallback due to error", error);
|
|
51
|
-
return new (0,
|
|
51
|
+
return new (0, _chunk4RJXBKSRjs.DefaultGasFeeFlow)().getGasFees(request);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
};
|
|
@@ -118,4 +118,4 @@ feesToString_fn = function(fees) {
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
exports.LineaGasFeeFlow = LineaGasFeeFlow;
|
|
121
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-LNX4JTOL.js.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSimulationData
|
|
3
|
+
} from "./chunk-IZVRGO3P.mjs";
|
|
1
4
|
import {
|
|
2
5
|
determineTransactionType
|
|
3
6
|
} from "./chunk-KG4UW4K4.mjs";
|
|
@@ -5,11 +8,14 @@ import {
|
|
|
5
8
|
validateTransactionOrigin,
|
|
6
9
|
validateTxParams
|
|
7
10
|
} from "./chunk-NM6OYEPP.mjs";
|
|
11
|
+
import {
|
|
12
|
+
validateConfirmedExternalTransaction
|
|
13
|
+
} from "./chunk-FRKQ3Z2L.mjs";
|
|
8
14
|
import {
|
|
9
15
|
addGasBuffer,
|
|
10
16
|
estimateGas,
|
|
11
17
|
updateGas
|
|
12
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5G6OHAXI.mjs";
|
|
13
19
|
import {
|
|
14
20
|
addInitialHistorySnapshot,
|
|
15
21
|
updateTransactionHistory
|
|
@@ -18,47 +24,44 @@ import {
|
|
|
18
24
|
getAndFormatTransactionsForNonceTracker,
|
|
19
25
|
getNextNonce
|
|
20
26
|
} from "./chunk-NHRBO3LU.mjs";
|
|
21
|
-
import {
|
|
22
|
-
getSimulationData
|
|
23
|
-
} from "./chunk-L7ZKSKEI.mjs";
|
|
24
27
|
import {
|
|
25
28
|
OptimismLayer1GasFeeFlow
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-VEVVBHP3.mjs";
|
|
30
|
+
import {
|
|
31
|
+
ScrollLayer1GasFeeFlow
|
|
32
|
+
} from "./chunk-Z4GV3YQQ.mjs";
|
|
27
33
|
import {
|
|
28
34
|
GasFeePoller
|
|
29
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-HHK4QSNF.mjs";
|
|
30
36
|
import {
|
|
31
37
|
getTransactionLayer1GasFee,
|
|
32
38
|
updateTransactionLayer1GasFee
|
|
33
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-NOHEXQ7Y.mjs";
|
|
34
40
|
import {
|
|
35
41
|
IncomingTransactionHelper
|
|
36
42
|
} from "./chunk-Y7ENNK7L.mjs";
|
|
37
43
|
import {
|
|
38
44
|
MultichainTrackingHelper
|
|
39
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-F6E3TTR3.mjs";
|
|
40
46
|
import {
|
|
41
47
|
EtherscanRemoteTransactionSource
|
|
42
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-CPMTUMMZ.mjs";
|
|
43
49
|
import {
|
|
44
50
|
PendingTransactionTracker
|
|
45
51
|
} from "./chunk-5YES3V2R.mjs";
|
|
46
|
-
import {
|
|
47
|
-
validateConfirmedExternalTransaction
|
|
48
|
-
} from "./chunk-FRKQ3Z2L.mjs";
|
|
49
52
|
import {
|
|
50
53
|
LineaGasFeeFlow
|
|
51
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-NCRWKI6Y.mjs";
|
|
52
55
|
import {
|
|
53
56
|
DefaultGasFeeFlow
|
|
54
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-NPEXNXSY.mjs";
|
|
55
58
|
import {
|
|
56
59
|
updateGasFees
|
|
57
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-LDXTSESK.mjs";
|
|
58
61
|
import {
|
|
59
62
|
updatePostTransactionBalance,
|
|
60
63
|
updateSwapsTransaction
|
|
61
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-ZGUNOEUQ.mjs";
|
|
62
65
|
import {
|
|
63
66
|
getIncreasedPriceFromExisting,
|
|
64
67
|
isEIP1559Transaction,
|
|
@@ -134,7 +137,7 @@ function getDefaultTransactionControllerState() {
|
|
|
134
137
|
lastFetchedBlockNumbers: {}
|
|
135
138
|
};
|
|
136
139
|
}
|
|
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, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn, _updateSimulationData, updateSimulationData_fn;
|
|
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;
|
|
138
141
|
var TransactionController = class extends BaseController {
|
|
139
142
|
/**
|
|
140
143
|
* Constructs a TransactionController.
|
|
@@ -217,6 +220,7 @@ var TransactionController = class extends BaseController {
|
|
|
217
220
|
__privateAdd(this, _checkIfTransactionParamsUpdated);
|
|
218
221
|
__privateAdd(this, _onTransactionParamsUpdated);
|
|
219
222
|
__privateAdd(this, _updateSimulationData);
|
|
223
|
+
__privateAdd(this, _onGasFeePollerTransactionUpdate);
|
|
220
224
|
__privateAdd(this, _internalEvents, new EventEmitter());
|
|
221
225
|
this.inProcessOfSigning = /* @__PURE__ */ new Set();
|
|
222
226
|
this.mutex = new Mutex();
|
|
@@ -323,7 +327,7 @@ var TransactionController = class extends BaseController {
|
|
|
323
327
|
});
|
|
324
328
|
gasFeePoller.hub.on(
|
|
325
329
|
"transaction-updated",
|
|
326
|
-
|
|
330
|
+
__privateMethod(this, _onGasFeePollerTransactionUpdate, onGasFeePollerTransactionUpdate_fn).bind(this)
|
|
327
331
|
);
|
|
328
332
|
this.messagingSystem.subscribe(
|
|
329
333
|
"TransactionController:stateChange",
|
|
@@ -857,10 +861,8 @@ var TransactionController = class extends BaseController {
|
|
|
857
861
|
* @param note - A note or update reason to include in the transaction history.
|
|
858
862
|
*/
|
|
859
863
|
updateTransaction(transactionMeta, note) {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
skipHistory: this.isHistoryDisabled
|
|
863
|
-
});
|
|
864
|
+
const { id: transactionId } = transactionMeta;
|
|
865
|
+
__privateMethod(this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, { transactionId, note, skipHistory: this.isHistoryDisabled }, () => ({ ...transactionMeta }));
|
|
864
866
|
}
|
|
865
867
|
/**
|
|
866
868
|
* Update the security alert response for a transaction.
|
|
@@ -1367,18 +1369,23 @@ var TransactionController = class extends BaseController {
|
|
|
1367
1369
|
return filteredTransactions;
|
|
1368
1370
|
}
|
|
1369
1371
|
/**
|
|
1370
|
-
*
|
|
1372
|
+
* Determine the layer 1 gas fee for the given transaction parameters.
|
|
1371
1373
|
*
|
|
1372
|
-
* @param
|
|
1373
|
-
* @param
|
|
1374
|
-
* @param
|
|
1374
|
+
* @param request - The request object.
|
|
1375
|
+
* @param request.transactionParams - The transaction parameters to estimate the layer 1 gas fee for.
|
|
1376
|
+
* @param request.chainId - The ID of the chain where the transaction will be executed.
|
|
1377
|
+
* @param request.networkClientId - The ID of a specific network client to process the transaction.
|
|
1375
1378
|
*/
|
|
1376
|
-
async getLayer1GasFee(
|
|
1379
|
+
async getLayer1GasFee({
|
|
1380
|
+
transactionParams,
|
|
1381
|
+
chainId,
|
|
1382
|
+
networkClientId
|
|
1383
|
+
}) {
|
|
1377
1384
|
const provider = __privateGet(this, _multichainTrackingHelper).getProvider({
|
|
1378
1385
|
networkClientId,
|
|
1379
1386
|
chainId
|
|
1380
1387
|
});
|
|
1381
|
-
|
|
1388
|
+
return await getTransactionLayer1GasFee({
|
|
1382
1389
|
layer1GasFeeFlows: this.layer1GasFeeFlows,
|
|
1383
1390
|
provider,
|
|
1384
1391
|
transactionMeta: {
|
|
@@ -1386,7 +1393,6 @@ var TransactionController = class extends BaseController {
|
|
|
1386
1393
|
chainId
|
|
1387
1394
|
}
|
|
1388
1395
|
});
|
|
1389
|
-
return layer1GasFee;
|
|
1390
1396
|
}
|
|
1391
1397
|
async signExternalTransaction(chainId, transactionParams) {
|
|
1392
1398
|
if (!this.sign) {
|
|
@@ -2324,28 +2330,39 @@ getGasFeeFlows_fn = function() {
|
|
|
2324
2330
|
};
|
|
2325
2331
|
_getLayer1GasFeeFlows = new WeakSet();
|
|
2326
2332
|
getLayer1GasFeeFlows_fn = function() {
|
|
2327
|
-
return [new OptimismLayer1GasFeeFlow()];
|
|
2333
|
+
return [new OptimismLayer1GasFeeFlow(), new ScrollLayer1GasFeeFlow()];
|
|
2328
2334
|
};
|
|
2329
2335
|
_updateTransactionInternal = new WeakSet();
|
|
2330
|
-
updateTransactionInternal_fn = function(
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
const updatedTransactionParams = __privateMethod(this, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn).call(this, normalizedTransaction);
|
|
2337
|
-
const transactionWithUpdatedHistory = skipHistory === true ? normalizedTransaction : updateTransactionHistory(
|
|
2338
|
-
normalizedTransaction,
|
|
2339
|
-
note ?? "Transaction updated"
|
|
2340
|
-
);
|
|
2336
|
+
updateTransactionInternal_fn = function({
|
|
2337
|
+
transactionId,
|
|
2338
|
+
note,
|
|
2339
|
+
skipHistory
|
|
2340
|
+
}, callback) {
|
|
2341
|
+
let updatedTransactionParams = [];
|
|
2341
2342
|
this.update((state) => {
|
|
2342
2343
|
const index = state.transactions.findIndex(
|
|
2343
|
-
({ id }) =>
|
|
2344
|
+
({ id }) => id === transactionId
|
|
2344
2345
|
);
|
|
2345
|
-
state.transactions[index]
|
|
2346
|
+
let transactionMeta2 = state.transactions[index];
|
|
2347
|
+
transactionMeta2 = callback(transactionMeta2) ?? transactionMeta2;
|
|
2348
|
+
transactionMeta2.txParams = normalizeTransactionParams(
|
|
2349
|
+
transactionMeta2.txParams
|
|
2350
|
+
);
|
|
2351
|
+
validateTxParams(transactionMeta2.txParams);
|
|
2352
|
+
updatedTransactionParams = __privateMethod(this, _checkIfTransactionParamsUpdated, checkIfTransactionParamsUpdated_fn).call(this, transactionMeta2);
|
|
2353
|
+
if (skipHistory !== true) {
|
|
2354
|
+
transactionMeta2 = updateTransactionHistory(
|
|
2355
|
+
transactionMeta2,
|
|
2356
|
+
note ?? "Transaction updated"
|
|
2357
|
+
);
|
|
2358
|
+
}
|
|
2359
|
+
state.transactions[index] = transactionMeta2;
|
|
2346
2360
|
});
|
|
2361
|
+
const transactionMeta = this.getTransaction(
|
|
2362
|
+
transactionId
|
|
2363
|
+
);
|
|
2347
2364
|
if (updatedTransactionParams.length > 0) {
|
|
2348
|
-
__privateMethod(this, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn).call(this,
|
|
2365
|
+
__privateMethod(this, _onTransactionParamsUpdated, onTransactionParamsUpdated_fn).call(this, transactionMeta, updatedTransactionParams);
|
|
2349
2366
|
}
|
|
2350
2367
|
};
|
|
2351
2368
|
_checkIfTransactionParamsUpdated = new WeakSet();
|
|
@@ -2379,7 +2396,7 @@ onTransactionParamsUpdated_fn = function(transactionMeta, updatedParams) {
|
|
|
2379
2396
|
};
|
|
2380
2397
|
_updateSimulationData = new WeakSet();
|
|
2381
2398
|
updateSimulationData_fn = async function(transactionMeta) {
|
|
2382
|
-
const { id, chainId, txParams } = transactionMeta;
|
|
2399
|
+
const { id: transactionId, chainId, txParams } = transactionMeta;
|
|
2383
2400
|
const { from, to, value, data } = txParams;
|
|
2384
2401
|
let simulationData = {
|
|
2385
2402
|
error: {
|
|
@@ -2389,7 +2406,9 @@ updateSimulationData_fn = async function(transactionMeta) {
|
|
|
2389
2406
|
tokenBalanceChanges: []
|
|
2390
2407
|
};
|
|
2391
2408
|
if (__privateGet(this, _isSimulationEnabled).call(this)) {
|
|
2392
|
-
__privateMethod(this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, {
|
|
2409
|
+
__privateMethod(this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, { transactionId, skipHistory: true }, (txMeta) => {
|
|
2410
|
+
txMeta.simulationData = void 0;
|
|
2411
|
+
});
|
|
2393
2412
|
simulationData = await getSimulationData({
|
|
2394
2413
|
chainId,
|
|
2395
2414
|
from,
|
|
@@ -2398,20 +2417,41 @@ updateSimulationData_fn = async function(transactionMeta) {
|
|
|
2398
2417
|
data
|
|
2399
2418
|
});
|
|
2400
2419
|
}
|
|
2401
|
-
const finalTransactionMeta = this.getTransaction(
|
|
2420
|
+
const finalTransactionMeta = this.getTransaction(transactionId);
|
|
2402
2421
|
if (!finalTransactionMeta) {
|
|
2403
2422
|
projectLogger(
|
|
2404
2423
|
"Cannot update simulation data as transaction not found",
|
|
2405
|
-
|
|
2424
|
+
transactionId,
|
|
2406
2425
|
simulationData
|
|
2407
2426
|
);
|
|
2408
2427
|
return;
|
|
2409
2428
|
}
|
|
2410
|
-
this.
|
|
2411
|
-
|
|
2412
|
-
"TransactionController#updateSimulationData - Update simulation data"
|
|
2413
|
-
)
|
|
2414
|
-
|
|
2429
|
+
__privateMethod(this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, {
|
|
2430
|
+
transactionId,
|
|
2431
|
+
note: "TransactionController#updateSimulationData - Update simulation data"
|
|
2432
|
+
}, (txMeta) => {
|
|
2433
|
+
txMeta.simulationData = simulationData;
|
|
2434
|
+
});
|
|
2435
|
+
projectLogger("Updated simulation data", transactionId, simulationData);
|
|
2436
|
+
};
|
|
2437
|
+
_onGasFeePollerTransactionUpdate = new WeakSet();
|
|
2438
|
+
onGasFeePollerTransactionUpdate_fn = function({
|
|
2439
|
+
transactionId,
|
|
2440
|
+
gasFeeEstimates,
|
|
2441
|
+
gasFeeEstimatesLoaded,
|
|
2442
|
+
layer1GasFee
|
|
2443
|
+
}) {
|
|
2444
|
+
__privateMethod(this, _updateTransactionInternal, updateTransactionInternal_fn).call(this, { transactionId, skipHistory: true }, (txMeta) => {
|
|
2445
|
+
if (gasFeeEstimates) {
|
|
2446
|
+
txMeta.gasFeeEstimates = gasFeeEstimates;
|
|
2447
|
+
}
|
|
2448
|
+
if (gasFeeEstimatesLoaded !== void 0) {
|
|
2449
|
+
txMeta.gasFeeEstimatesLoaded = gasFeeEstimatesLoaded;
|
|
2450
|
+
}
|
|
2451
|
+
if (layer1GasFee) {
|
|
2452
|
+
txMeta.layer1GasFee = layer1GasFee;
|
|
2453
|
+
}
|
|
2454
|
+
});
|
|
2415
2455
|
};
|
|
2416
2456
|
|
|
2417
2457
|
export {
|
|
@@ -2421,4 +2461,4 @@ export {
|
|
|
2421
2461
|
ApprovalState,
|
|
2422
2462
|
TransactionController
|
|
2423
2463
|
};
|
|
2424
|
-
//# sourceMappingURL=chunk-
|
|
2464
|
+
//# sourceMappingURL=chunk-MG7HTD3H.mjs.map
|