@metamask/smart-transactions-controller 18.0.0 → 19.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/dist/{SmartTransactionsController.js → SmartTransactionsController.cjs} +18 -24
  3. package/dist/SmartTransactionsController.cjs.map +1 -0
  4. package/dist/{SmartTransactionsController.d.ts → SmartTransactionsController.d.cts} +17 -20
  5. package/dist/SmartTransactionsController.d.cts.map +1 -0
  6. package/dist/SmartTransactionsController.d.mts +149 -0
  7. package/dist/SmartTransactionsController.d.mts.map +1 -0
  8. package/dist/SmartTransactionsController.mjs +696 -0
  9. package/dist/SmartTransactionsController.mjs.map +1 -0
  10. package/dist/{constants.js → constants.cjs} +2 -1
  11. package/dist/constants.cjs.map +1 -0
  12. package/dist/{constants.d.ts → constants.d.cts} +1 -0
  13. package/dist/constants.d.cts.map +1 -0
  14. package/dist/constants.d.mts +23 -0
  15. package/dist/constants.d.mts.map +1 -0
  16. package/dist/constants.mjs +30 -0
  17. package/dist/constants.mjs.map +1 -0
  18. package/dist/index.cjs +6 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/{index.d.ts → index.d.cts} +3 -2
  21. package/dist/index.d.cts.map +1 -0
  22. package/dist/index.d.mts +3 -0
  23. package/dist/index.d.mts.map +1 -0
  24. package/dist/index.mjs +2 -0
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/{types.js → types.cjs} +1 -1
  27. package/dist/types.cjs.map +1 -0
  28. package/dist/{types.d.ts → types.d.cts} +2 -8
  29. package/dist/types.d.cts.map +1 -0
  30. package/dist/types.d.mts +118 -0
  31. package/dist/types.d.mts.map +1 -0
  32. package/dist/types.mjs +51 -0
  33. package/dist/types.mjs.map +1 -0
  34. package/dist/{utils.js → utils.cjs} +3 -3
  35. package/dist/utils.cjs.map +1 -0
  36. package/dist/{utils.d.ts → utils.d.cts} +6 -5
  37. package/dist/utils.d.cts.map +1 -0
  38. package/dist/utils.d.mts +90 -0
  39. package/dist/utils.d.mts.map +1 -0
  40. package/dist/utils.mjs +265 -0
  41. package/dist/utils.mjs.map +1 -0
  42. package/package.json +37 -15
  43. package/dist/SmartTransactionsController.js.map +0 -1
  44. package/dist/constants.js.map +0 -1
  45. package/dist/index.js +0 -9
  46. package/dist/index.js.map +0 -1
  47. package/dist/types.js.map +0 -1
  48. package/dist/utils.js.map +0 -1
@@ -0,0 +1,696 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _SmartTransactionsController_instances, _SmartTransactionsController_interval, _SmartTransactionsController_clientId, _SmartTransactionsController_chainId, _SmartTransactionsController_supportedChainIds, _SmartTransactionsController_ethQuery, _SmartTransactionsController_trackMetaMetricsEvent, _SmartTransactionsController_getMetaMetricsProps, _SmartTransactionsController_getFeatureFlags, _SmartTransactionsController_trace, _SmartTransactionsController_fetch, _SmartTransactionsController_updateSmartTransaction, _SmartTransactionsController_addMetaMetricsPropsToNewSmartTransaction, _SmartTransactionsController_createOrUpdateSmartTransaction, _SmartTransactionsController_doesTransactionNeedConfirmation, _SmartTransactionsController_confirmSmartTransaction, _SmartTransactionsController_addNonceToTransaction, _SmartTransactionsController_getChainId, _SmartTransactionsController_getChainIds, _SmartTransactionsController_getNetworkClientId, _SmartTransactionsController_getEthQuery, _SmartTransactionsController_getCurrentSmartTransactions, _SmartTransactionsController_wipeSmartTransactionsPerChainId;
13
+ function $importDefault(module) {
14
+ if (module === null || module === void 0 ? void 0 : module.__esModule) {
15
+ return module.default;
16
+ }
17
+ return module;
18
+ }
19
+ import { hexlify } from "@ethersproject/bytes";
20
+ import { query, safelyExecute, ChainId, isSafeDynamicKey } from "@metamask/controller-utils";
21
+ import $EthQuery from "@metamask/eth-query";
22
+ const EthQuery = $importDefault($EthQuery);
23
+ import { StaticIntervalPollingController } from "@metamask/polling-controller";
24
+ import { TransactionStatus } from "@metamask/transaction-controller";
25
+ import { BigNumber } from "bignumber.js";
26
+ import $cloneDeep from "lodash/cloneDeep.js";
27
+ const cloneDeep = $importDefault($cloneDeep);
28
+ import { MetaMetricsEventCategory, MetaMetricsEventName, SmartTransactionsTraceName } from "./constants.mjs";
29
+ import { APIType, SmartTransactionStatuses } from "./types.mjs";
30
+ import { calculateStatus, generateHistoryEntry, getAPIRequestURL, handleFetch, incrementNonceInHex, isSmartTransactionCancellable, isSmartTransactionPending, replayHistory, snapshotFromTxMeta, getTxHash, getSmartTransactionMetricsProperties, getSmartTransactionMetricsSensitiveProperties, shouldMarkRegularTransactionAsFailed, markRegularTransactionAsFailed } from "./utils.mjs";
31
+ const SECOND = 1000;
32
+ export const DEFAULT_INTERVAL = SECOND * 5;
33
+ const ETH_QUERY_ERROR_MSG = '`ethQuery` is not defined on SmartTransactionsController';
34
+ /**
35
+ * The name of the {@link SmartTransactionsController}
36
+ */
37
+ const controllerName = 'SmartTransactionsController';
38
+ const controllerMetadata = {
39
+ smartTransactionsState: {
40
+ includeInStateLogs: true,
41
+ persist: false,
42
+ anonymous: true,
43
+ usedInUi: true,
44
+ },
45
+ };
46
+ /**
47
+ * Get the default {@link SmartTransactionsController} state.
48
+ *
49
+ * @returns The default {@link SmartTransactionsController} state.
50
+ */
51
+ export function getDefaultSmartTransactionsControllerState() {
52
+ return {
53
+ smartTransactionsState: {
54
+ smartTransactions: {},
55
+ userOptIn: null,
56
+ userOptInV2: null,
57
+ fees: {
58
+ approvalTxFees: null,
59
+ tradeTxFees: null,
60
+ },
61
+ liveness: true,
62
+ livenessByChainId: {
63
+ [ChainId.mainnet]: true,
64
+ [ChainId.sepolia]: true,
65
+ },
66
+ feesByChainId: {
67
+ [ChainId.mainnet]: {
68
+ approvalTxFees: null,
69
+ tradeTxFees: null,
70
+ },
71
+ [ChainId.sepolia]: {
72
+ approvalTxFees: null,
73
+ tradeTxFees: null,
74
+ },
75
+ },
76
+ },
77
+ };
78
+ }
79
+ export class SmartTransactionsController extends StaticIntervalPollingController() {
80
+ constructor({ interval = DEFAULT_INTERVAL, clientId, chainId: InitialChainId = ChainId.mainnet, supportedChainIds = [ChainId.mainnet, ChainId.sepolia], trackMetaMetricsEvent, state = {}, messenger, getMetaMetricsProps, getFeatureFlags, trace, }) {
81
+ super({
82
+ name: controllerName,
83
+ metadata: controllerMetadata,
84
+ messenger,
85
+ state: Object.assign(Object.assign({}, getDefaultSmartTransactionsControllerState()), state),
86
+ });
87
+ _SmartTransactionsController_instances.add(this);
88
+ _SmartTransactionsController_interval.set(this, void 0);
89
+ _SmartTransactionsController_clientId.set(this, void 0);
90
+ _SmartTransactionsController_chainId.set(this, void 0);
91
+ _SmartTransactionsController_supportedChainIds.set(this, void 0);
92
+ _SmartTransactionsController_ethQuery.set(this, void 0);
93
+ _SmartTransactionsController_trackMetaMetricsEvent.set(this, void 0);
94
+ _SmartTransactionsController_getMetaMetricsProps.set(this, void 0);
95
+ _SmartTransactionsController_getFeatureFlags.set(this, void 0);
96
+ _SmartTransactionsController_trace.set(this, void 0);
97
+ __classPrivateFieldSet(this, _SmartTransactionsController_interval, interval, "f");
98
+ __classPrivateFieldSet(this, _SmartTransactionsController_clientId, clientId, "f");
99
+ __classPrivateFieldSet(this, _SmartTransactionsController_chainId, InitialChainId, "f");
100
+ __classPrivateFieldSet(this, _SmartTransactionsController_supportedChainIds, supportedChainIds, "f");
101
+ this.setIntervalLength(interval);
102
+ __classPrivateFieldSet(this, _SmartTransactionsController_ethQuery, undefined, "f");
103
+ __classPrivateFieldSet(this, _SmartTransactionsController_trackMetaMetricsEvent, trackMetaMetricsEvent, "f");
104
+ __classPrivateFieldSet(this, _SmartTransactionsController_getMetaMetricsProps, getMetaMetricsProps, "f");
105
+ __classPrivateFieldSet(this, _SmartTransactionsController_getFeatureFlags, getFeatureFlags, "f");
106
+ __classPrivateFieldSet(this, _SmartTransactionsController_trace, trace !== null && trace !== void 0 ? trace : ((_request, fn) => fn === null || fn === void 0 ? void 0 : fn()), "f");
107
+ this.initializeSmartTransactionsForChainId();
108
+ this.messagingSystem.subscribe('NetworkController:stateChange', ({ selectedNetworkClientId }) => {
109
+ const { configuration: { chainId }, provider, } = this.messagingSystem.call('NetworkController:getNetworkClientById', selectedNetworkClientId);
110
+ __classPrivateFieldSet(this, _SmartTransactionsController_chainId, chainId, "f");
111
+ __classPrivateFieldSet(this, _SmartTransactionsController_ethQuery, new EthQuery(provider), "f");
112
+ this.initializeSmartTransactionsForChainId();
113
+ this.checkPoll(this.state);
114
+ });
115
+ this.messagingSystem.subscribe(`${controllerName}:stateChange`, (currentState) => this.checkPoll(currentState));
116
+ }
117
+ async _executePoll({ chainIds, }) {
118
+ // if this is going to be truly UI driven polling we shouldn't really reach here
119
+ // with a networkClientId that is not supported, but for now I'll add a check in case
120
+ // wondering if we should add some kind of predicate to the polling controller to check whether
121
+ // we should poll or not
122
+ const filteredChainIds = (chainIds !== null && chainIds !== void 0 ? chainIds : []).filter((chainId) => __classPrivateFieldGet(this, _SmartTransactionsController_supportedChainIds, "f").includes(chainId));
123
+ if (filteredChainIds.length === 0) {
124
+ return Promise.resolve();
125
+ }
126
+ return this.updateSmartTransactions({ chainIds: filteredChainIds });
127
+ }
128
+ checkPoll({ smartTransactionsState: { smartTransactions }, }) {
129
+ const smartTransactionsForAllChains = Object.values(smartTransactions).flat();
130
+ const pendingTransactions = smartTransactionsForAllChains === null || smartTransactionsForAllChains === void 0 ? void 0 : smartTransactionsForAllChains.filter(isSmartTransactionPending);
131
+ if (!this.timeoutHandle && (pendingTransactions === null || pendingTransactions === void 0 ? void 0 : pendingTransactions.length) > 0) {
132
+ this.poll();
133
+ }
134
+ else if (this.timeoutHandle && (pendingTransactions === null || pendingTransactions === void 0 ? void 0 : pendingTransactions.length) === 0) {
135
+ this.stop();
136
+ }
137
+ }
138
+ initializeSmartTransactionsForChainId() {
139
+ if (__classPrivateFieldGet(this, _SmartTransactionsController_supportedChainIds, "f").includes(__classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f"))) {
140
+ this.update((state) => {
141
+ var _a;
142
+ state.smartTransactionsState.smartTransactions[__classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f")] =
143
+ (_a = state.smartTransactionsState.smartTransactions[__classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f")]) !== null && _a !== void 0 ? _a : [];
144
+ });
145
+ }
146
+ }
147
+ async poll(interval) {
148
+ if (interval) {
149
+ __classPrivateFieldSet(this, _SmartTransactionsController_interval, interval, "f");
150
+ }
151
+ this.timeoutHandle && clearInterval(this.timeoutHandle);
152
+ if (!__classPrivateFieldGet(this, _SmartTransactionsController_supportedChainIds, "f").includes(__classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f"))) {
153
+ return;
154
+ }
155
+ this.timeoutHandle = setInterval(() => {
156
+ safelyExecute(async () => this.updateSmartTransactions());
157
+ }, __classPrivateFieldGet(this, _SmartTransactionsController_interval, "f"));
158
+ await safelyExecute(async () => this.updateSmartTransactions());
159
+ }
160
+ async stop() {
161
+ this.timeoutHandle && clearInterval(this.timeoutHandle);
162
+ this.timeoutHandle = undefined;
163
+ }
164
+ setOptInState(optInState) {
165
+ this.update((state) => {
166
+ state.smartTransactionsState.userOptInV2 = optInState;
167
+ });
168
+ }
169
+ trackStxStatusChange(smartTransaction, prevSmartTransaction) {
170
+ let updatedSmartTransaction = cloneDeep(smartTransaction);
171
+ updatedSmartTransaction = Object.assign(Object.assign({}, cloneDeep(prevSmartTransaction)), updatedSmartTransaction);
172
+ if (updatedSmartTransaction.status === (prevSmartTransaction === null || prevSmartTransaction === void 0 ? void 0 : prevSmartTransaction.status)) {
173
+ return; // If status hasn't changed, don't track it again.
174
+ }
175
+ __classPrivateFieldGet(this, _SmartTransactionsController_trackMetaMetricsEvent, "f").call(this, {
176
+ event: MetaMetricsEventName.StxStatusUpdated,
177
+ category: MetaMetricsEventCategory.Transactions,
178
+ properties: getSmartTransactionMetricsProperties(updatedSmartTransaction),
179
+ sensitiveProperties: getSmartTransactionMetricsSensitiveProperties(updatedSmartTransaction),
180
+ });
181
+ }
182
+ isNewSmartTransaction(smartTransactionUuid, chainId) {
183
+ const { smartTransactionsState: { smartTransactions }, } = this.state;
184
+ const currentSmartTransactions = smartTransactions[chainId !== null && chainId !== void 0 ? chainId : __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f")];
185
+ const currentIndex = currentSmartTransactions === null || currentSmartTransactions === void 0 ? void 0 : currentSmartTransactions.findIndex((stx) => stx.uuid === smartTransactionUuid);
186
+ return currentIndex === -1 || currentIndex === undefined;
187
+ }
188
+ updateSmartTransaction(smartTransaction, { networkClientId } = {}) {
189
+ let ethQuery = __classPrivateFieldGet(this, _SmartTransactionsController_ethQuery, "f");
190
+ let chainId = __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f");
191
+ if (networkClientId) {
192
+ const { configuration, provider } = this.messagingSystem.call('NetworkController:getNetworkClientById', networkClientId);
193
+ chainId = configuration.chainId;
194
+ ethQuery = new EthQuery(provider);
195
+ }
196
+ __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_createOrUpdateSmartTransaction).call(this, smartTransaction, {
197
+ chainId,
198
+ ethQuery,
199
+ });
200
+ }
201
+ async updateSmartTransactions({ chainIds, } = {
202
+ chainIds: __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getChainIds).call(this),
203
+ }) {
204
+ const { smartTransactionsState: { smartTransactions }, } = this.state;
205
+ // Iterate over each chain group directly
206
+ for (const [chainId, transactions] of Object.entries(smartTransactions)) {
207
+ if (chainIds && !chainIds.includes(chainId)) {
208
+ continue;
209
+ }
210
+ // Filter pending transactions and map them to the desired shape
211
+ const pendingTransactions = transactions
212
+ .filter(isSmartTransactionPending)
213
+ .map((pendingSmartTransaction) => {
214
+ // Use the transaction's chainId (from the key) to derive a networkClientId
215
+ const networkClientIdToUse = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getNetworkClientId).call(this, {
216
+ chainId: chainId,
217
+ });
218
+ return {
219
+ uuid: pendingSmartTransaction.uuid,
220
+ networkClientId: networkClientIdToUse,
221
+ chainId: pendingSmartTransaction.chainId, // same as the key, but explicit on the transaction
222
+ };
223
+ });
224
+ if (pendingTransactions.length > 0) {
225
+ // Since each group is per chain, all transactions share the same chainId.
226
+ await this.fetchSmartTransactionsStatus(pendingTransactions);
227
+ }
228
+ }
229
+ }
230
+ // ! Ask backend API to accept list of uuids as params
231
+ async fetchSmartTransactionsStatus(transactions) {
232
+ // Since transactions come from the same chain group, take the chainId from the first one.
233
+ const { chainId } = transactions[0];
234
+ // Build query parameters with all UUIDs
235
+ const uuids = transactions.map((tx) => tx.uuid);
236
+ const params = new URLSearchParams({ uuids: uuids.join(',') });
237
+ // Get the ethQuery for the first transaction's networkClientId
238
+ const ethQuery = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getEthQuery).call(this, {
239
+ networkClientId: transactions[0].networkClientId,
240
+ });
241
+ // Construct the URL and fetch the data
242
+ const url = `${getAPIRequestURL(APIType.BATCH_STATUS, chainId)}?${params.toString()}`;
243
+ const data = (await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, url));
244
+ // Process each returned status
245
+ for (const [uuid, stxStatus] of Object.entries(data)) {
246
+ const matchingTx = transactions.find((tx) => tx.uuid === uuid);
247
+ if (!matchingTx) {
248
+ console.error(`No matching transaction found for uuid: ${uuid}`);
249
+ continue;
250
+ }
251
+ const smartTransaction = {
252
+ statusMetadata: stxStatus,
253
+ status: calculateStatus(stxStatus),
254
+ cancellable: isSmartTransactionCancellable(stxStatus),
255
+ uuid,
256
+ networkClientId: matchingTx.networkClientId,
257
+ };
258
+ await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_createOrUpdateSmartTransaction).call(this, smartTransaction, {
259
+ chainId,
260
+ ethQuery,
261
+ });
262
+ }
263
+ return data;
264
+ }
265
+ clearFees() {
266
+ const fees = {
267
+ approvalTxFees: null,
268
+ tradeTxFees: null,
269
+ };
270
+ this.update((state) => {
271
+ state.smartTransactionsState.fees = fees;
272
+ });
273
+ return fees;
274
+ }
275
+ async getFees(tradeTx, approvalTx, { networkClientId } = {}) {
276
+ const selectedNetworkClientId = networkClientId !== null && networkClientId !== void 0 ? networkClientId : this.messagingSystem.call('NetworkController:getState')
277
+ .selectedNetworkClientId;
278
+ const chainId = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getChainId).call(this, {
279
+ networkClientId: selectedNetworkClientId,
280
+ });
281
+ const transactions = [];
282
+ let unsignedTradeTransactionWithNonce;
283
+ if (approvalTx) {
284
+ const unsignedApprovalTransactionWithNonce = await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_addNonceToTransaction).call(this, approvalTx, selectedNetworkClientId);
285
+ transactions.push(unsignedApprovalTransactionWithNonce);
286
+ unsignedTradeTransactionWithNonce = Object.assign(Object.assign({}, tradeTx), {
287
+ // If there is an approval tx, the trade tx's nonce is increased by 1.
288
+ nonce: incrementNonceInHex(unsignedApprovalTransactionWithNonce.nonce) });
289
+ }
290
+ else if (tradeTx.nonce) {
291
+ unsignedTradeTransactionWithNonce = tradeTx;
292
+ }
293
+ else {
294
+ unsignedTradeTransactionWithNonce = await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_addNonceToTransaction).call(this, tradeTx, selectedNetworkClientId);
295
+ }
296
+ transactions.push(unsignedTradeTransactionWithNonce);
297
+ const data = await __classPrivateFieldGet(this, _SmartTransactionsController_trace, "f").call(this, { name: SmartTransactionsTraceName.GetFees }, async () => await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, getAPIRequestURL(APIType.GET_FEES, chainId), {
298
+ method: 'POST',
299
+ body: JSON.stringify({
300
+ txs: transactions,
301
+ }),
302
+ }));
303
+ let approvalTxFees;
304
+ let tradeTxFees;
305
+ if (approvalTx) {
306
+ approvalTxFees = data === null || data === void 0 ? void 0 : data.txs[0];
307
+ tradeTxFees = data === null || data === void 0 ? void 0 : data.txs[1];
308
+ }
309
+ else {
310
+ approvalTxFees = null;
311
+ tradeTxFees = data === null || data === void 0 ? void 0 : data.txs[0];
312
+ }
313
+ this.update((state) => {
314
+ if (chainId === __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f")) {
315
+ state.smartTransactionsState.fees = {
316
+ approvalTxFees,
317
+ tradeTxFees,
318
+ };
319
+ }
320
+ state.smartTransactionsState.feesByChainId[chainId] = {
321
+ approvalTxFees,
322
+ tradeTxFees,
323
+ };
324
+ });
325
+ return {
326
+ approvalTxFees,
327
+ tradeTxFees,
328
+ };
329
+ }
330
+ // * After this successful call client must add a nonce representative to
331
+ // * transaction controller external transactions list
332
+ async submitSignedTransactions({ transactionMeta, txParams, signedTransactions, signedCanceledTransactions = [], networkClientId, }) {
333
+ var _a, _b;
334
+ const selectedNetworkClientId = networkClientId !== null && networkClientId !== void 0 ? networkClientId : this.messagingSystem.call('NetworkController:getState')
335
+ .selectedNetworkClientId;
336
+ const chainId = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getChainId).call(this, {
337
+ networkClientId: selectedNetworkClientId,
338
+ });
339
+ const ethQuery = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getEthQuery).call(this, {
340
+ networkClientId: selectedNetworkClientId,
341
+ });
342
+ const data = await __classPrivateFieldGet(this, _SmartTransactionsController_trace, "f").call(this, { name: SmartTransactionsTraceName.SubmitTransactions }, async () => await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, getAPIRequestURL(APIType.SUBMIT_TRANSACTIONS, chainId), {
343
+ method: 'POST',
344
+ body: JSON.stringify({
345
+ rawTxs: signedTransactions,
346
+ rawCancelTxs: signedCanceledTransactions,
347
+ }),
348
+ }));
349
+ const time = Date.now();
350
+ let preTxBalance;
351
+ try {
352
+ if (txParams === null || txParams === void 0 ? void 0 : txParams.from) {
353
+ const preTxBalanceBN = await query(ethQuery, 'getBalance', [
354
+ txParams.from,
355
+ ]);
356
+ preTxBalance = new BigNumber(preTxBalanceBN).toString(16);
357
+ }
358
+ }
359
+ catch (error) {
360
+ console.error('ethQuery.getBalance error:', error);
361
+ }
362
+ const requiresNonce = txParams && !txParams.nonce;
363
+ let nonce;
364
+ let nonceLock;
365
+ let nonceDetails = {};
366
+ // This should only happen for Swaps. Non-swaps transactions should already have a nonce
367
+ if (requiresNonce) {
368
+ try {
369
+ nonceLock = await this.messagingSystem.call('TransactionController:getNonceLock', txParams.from, selectedNetworkClientId);
370
+ nonce = hexlify(nonceLock.nextNonce);
371
+ nonceDetails = nonceLock.nonceDetails;
372
+ (_a = txParams.nonce) !== null && _a !== void 0 ? _a : (txParams.nonce = nonce);
373
+ }
374
+ catch (error) {
375
+ console.error('Failed to acquire nonce lock:', error);
376
+ throw error;
377
+ }
378
+ }
379
+ const txHashes = signedTransactions.map((tx) => getTxHash(tx));
380
+ const submitTransactionResponse = Object.assign(Object.assign({}, data), { txHash: txHashes[txHashes.length - 1], // For backward compatibility - use the last tx hash
381
+ txHashes });
382
+ try {
383
+ await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_createOrUpdateSmartTransaction).call(this, {
384
+ chainId,
385
+ nonceDetails,
386
+ preTxBalance,
387
+ status: SmartTransactionStatuses.PENDING,
388
+ time,
389
+ txParams,
390
+ uuid: submitTransactionResponse.uuid,
391
+ txHash: submitTransactionResponse.txHash,
392
+ cancellable: true,
393
+ type: (_b = transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.type) !== null && _b !== void 0 ? _b : 'swap',
394
+ transactionId: transactionMeta === null || transactionMeta === void 0 ? void 0 : transactionMeta.id,
395
+ networkClientId: selectedNetworkClientId,
396
+ txHashes, // Add support for multiple transaction hashes
397
+ }, { chainId, ethQuery });
398
+ }
399
+ catch (error) {
400
+ console.error('Failed to create a smart transaction:', error);
401
+ throw error;
402
+ }
403
+ finally {
404
+ if (nonceLock) {
405
+ nonceLock.releaseLock();
406
+ }
407
+ }
408
+ return submitTransactionResponse;
409
+ }
410
+ // TODO: This should return if the cancellation was on chain or not (for nonce management)
411
+ // After this successful call client must update nonce representative
412
+ // in transaction controller external transactions list
413
+ async cancelSmartTransaction(uuid, { networkClientId, } = {}) {
414
+ const chainId = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getChainId).call(this, { networkClientId });
415
+ await __classPrivateFieldGet(this, _SmartTransactionsController_trace, "f").call(this, { name: SmartTransactionsTraceName.CancelTransaction }, async () => await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, getAPIRequestURL(APIType.CANCEL, chainId), {
416
+ method: 'POST',
417
+ body: JSON.stringify({ uuid }),
418
+ }));
419
+ }
420
+ async fetchLiveness({ networkClientId, } = {}) {
421
+ const chainId = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getChainId).call(this, { networkClientId });
422
+ let liveness = false;
423
+ try {
424
+ const response = await __classPrivateFieldGet(this, _SmartTransactionsController_trace, "f").call(this, { name: SmartTransactionsTraceName.FetchLiveness }, async () => await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, getAPIRequestURL(APIType.LIVENESS, chainId)));
425
+ liveness = Boolean(response.smartTransactions);
426
+ }
427
+ catch (error) {
428
+ console.log('"fetchLiveness" API call failed');
429
+ }
430
+ this.update((state) => {
431
+ if (chainId === __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f")) {
432
+ state.smartTransactionsState.liveness = liveness;
433
+ }
434
+ state.smartTransactionsState.livenessByChainId[chainId] = liveness;
435
+ });
436
+ return liveness;
437
+ }
438
+ async setStatusRefreshInterval(interval) {
439
+ if (interval !== __classPrivateFieldGet(this, _SmartTransactionsController_interval, "f")) {
440
+ __classPrivateFieldSet(this, _SmartTransactionsController_interval, interval, "f");
441
+ }
442
+ }
443
+ getTransactions({ addressFrom, status, }) {
444
+ const currentSmartTransactions = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getCurrentSmartTransactions).call(this);
445
+ return currentSmartTransactions.filter((stx) => {
446
+ var _a;
447
+ return stx.status === status && ((_a = stx.txParams) === null || _a === void 0 ? void 0 : _a.from) === addressFrom;
448
+ });
449
+ }
450
+ getSmartTransactionByMinedTxHash(txHash) {
451
+ if (!txHash) {
452
+ return undefined;
453
+ }
454
+ const currentSmartTransactions = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getCurrentSmartTransactions).call(this);
455
+ return currentSmartTransactions.find((smartTransaction) => {
456
+ var _a, _b;
457
+ return (((_b = (_a = smartTransaction.statusMetadata) === null || _a === void 0 ? void 0 : _a.minedHash) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
458
+ txHash.toLowerCase());
459
+ });
460
+ }
461
+ wipeSmartTransactions({ address, ignoreNetwork, }) {
462
+ if (!address) {
463
+ return;
464
+ }
465
+ const addressLowerCase = address.toLowerCase();
466
+ if (ignoreNetwork) {
467
+ const { smartTransactionsState: { smartTransactions }, } = this.state;
468
+ Object.keys(smartTransactions).forEach((chainId) => {
469
+ __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_wipeSmartTransactionsPerChainId).call(this, {
470
+ chainId,
471
+ addressLowerCase,
472
+ });
473
+ });
474
+ }
475
+ else {
476
+ __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_wipeSmartTransactionsPerChainId).call(this, {
477
+ chainId: __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f"),
478
+ addressLowerCase,
479
+ });
480
+ }
481
+ }
482
+ }
483
+ _SmartTransactionsController_interval = new WeakMap(), _SmartTransactionsController_clientId = new WeakMap(), _SmartTransactionsController_chainId = new WeakMap(), _SmartTransactionsController_supportedChainIds = new WeakMap(), _SmartTransactionsController_ethQuery = new WeakMap(), _SmartTransactionsController_trackMetaMetricsEvent = new WeakMap(), _SmartTransactionsController_getMetaMetricsProps = new WeakMap(), _SmartTransactionsController_getFeatureFlags = new WeakMap(), _SmartTransactionsController_trace = new WeakMap(), _SmartTransactionsController_instances = new WeakSet(), _SmartTransactionsController_fetch =
484
+ /* istanbul ignore next */
485
+ async function _SmartTransactionsController_fetch(request, options) {
486
+ const fetchOptions = Object.assign(Object.assign({}, options), { headers: Object.assign({ 'Content-Type': 'application/json' }, (__classPrivateFieldGet(this, _SmartTransactionsController_clientId, "f") && { 'X-Client-Id': __classPrivateFieldGet(this, _SmartTransactionsController_clientId, "f") })) });
487
+ return handleFetch(request, fetchOptions);
488
+ }, _SmartTransactionsController_updateSmartTransaction = function _SmartTransactionsController_updateSmartTransaction(smartTransaction, { chainId = __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f"), }) {
489
+ var _a;
490
+ const { smartTransactionsState: { smartTransactions }, } = this.state;
491
+ const currentSmartTransactions = (_a = smartTransactions[chainId]) !== null && _a !== void 0 ? _a : [];
492
+ const currentIndex = currentSmartTransactions === null || currentSmartTransactions === void 0 ? void 0 : currentSmartTransactions.findIndex((stx) => stx.uuid === smartTransaction.uuid);
493
+ if (currentIndex === -1) {
494
+ return; // Smart transaction not found, don't update anything.
495
+ }
496
+ if (!isSafeDynamicKey(chainId)) {
497
+ return;
498
+ }
499
+ this.update((state) => {
500
+ state.smartTransactionsState.smartTransactions[chainId][currentIndex] = Object.assign(Object.assign({}, state.smartTransactionsState.smartTransactions[chainId][currentIndex]), smartTransaction);
501
+ });
502
+ }, _SmartTransactionsController_addMetaMetricsPropsToNewSmartTransaction = async function _SmartTransactionsController_addMetaMetricsPropsToNewSmartTransaction(smartTransaction) {
503
+ const metaMetricsProps = await __classPrivateFieldGet(this, _SmartTransactionsController_getMetaMetricsProps, "f").call(this);
504
+ smartTransaction.accountHardwareType =
505
+ metaMetricsProps === null || metaMetricsProps === void 0 ? void 0 : metaMetricsProps.accountHardwareType;
506
+ smartTransaction.accountType = metaMetricsProps === null || metaMetricsProps === void 0 ? void 0 : metaMetricsProps.accountType;
507
+ smartTransaction.deviceModel = metaMetricsProps === null || metaMetricsProps === void 0 ? void 0 : metaMetricsProps.deviceModel;
508
+ }, _SmartTransactionsController_createOrUpdateSmartTransaction = async function _SmartTransactionsController_createOrUpdateSmartTransaction(smartTransaction, { chainId = __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f"), ethQuery = __classPrivateFieldGet(this, _SmartTransactionsController_ethQuery, "f"), }) {
509
+ var _a;
510
+ const { smartTransactionsState: { smartTransactions }, } = this.state;
511
+ const currentSmartTransactions = (_a = smartTransactions[chainId]) !== null && _a !== void 0 ? _a : [];
512
+ const currentIndex = currentSmartTransactions === null || currentSmartTransactions === void 0 ? void 0 : currentSmartTransactions.findIndex((stx) => stx.uuid === smartTransaction.uuid);
513
+ const isNewSmartTransaction = this.isNewSmartTransaction(smartTransaction.uuid, chainId);
514
+ if (ethQuery === undefined) {
515
+ throw new Error(ETH_QUERY_ERROR_MSG);
516
+ }
517
+ if (isNewSmartTransaction) {
518
+ try {
519
+ await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_addMetaMetricsPropsToNewSmartTransaction).call(this, smartTransaction);
520
+ }
521
+ catch (error) {
522
+ console.error('Failed to add metrics props to smart transaction:', error);
523
+ // Continue without metrics props
524
+ }
525
+ }
526
+ this.trackStxStatusChange(smartTransaction, isNewSmartTransaction
527
+ ? undefined
528
+ : currentSmartTransactions[currentIndex]);
529
+ if (isNewSmartTransaction) {
530
+ // add smart transaction
531
+ const cancelledNonceIndex = currentSmartTransactions === null || currentSmartTransactions === void 0 ? void 0 : currentSmartTransactions.findIndex((stx) => {
532
+ var _a, _b, _c;
533
+ return ((_a = stx.txParams) === null || _a === void 0 ? void 0 : _a.nonce) === ((_b = smartTransaction.txParams) === null || _b === void 0 ? void 0 : _b.nonce) &&
534
+ ((_c = stx.status) === null || _c === void 0 ? void 0 : _c.startsWith('cancelled'));
535
+ });
536
+ const snapshot = cloneDeep(smartTransaction);
537
+ const history = [snapshot];
538
+ const historifiedSmartTransaction = Object.assign(Object.assign({}, smartTransaction), { history });
539
+ const nextSmartTransactions = cancelledNonceIndex > -1
540
+ ? currentSmartTransactions
541
+ .slice(0, cancelledNonceIndex)
542
+ .concat(currentSmartTransactions.slice(cancelledNonceIndex + 1))
543
+ .concat(historifiedSmartTransaction)
544
+ : currentSmartTransactions.concat(historifiedSmartTransaction);
545
+ this.update((state) => {
546
+ state.smartTransactionsState.smartTransactions[chainId] =
547
+ nextSmartTransactions;
548
+ });
549
+ return;
550
+ }
551
+ const currentSmartTransaction = currentSmartTransactions[currentIndex];
552
+ const nextSmartTransaction = Object.assign(Object.assign({}, currentSmartTransaction), smartTransaction);
553
+ // We have to emit this event here, because then a txHash is returned to the TransactionController once it's available
554
+ // and the #doesTransactionNeedConfirmation function will work properly, since it will find the txHash in the regular transactions list.
555
+ this.messagingSystem.publish(`SmartTransactionsController:smartTransaction`, nextSmartTransaction);
556
+ if (shouldMarkRegularTransactionAsFailed({
557
+ smartTransaction: nextSmartTransaction,
558
+ clientId: __classPrivateFieldGet(this, _SmartTransactionsController_clientId, "f"),
559
+ getFeatureFlags: __classPrivateFieldGet(this, _SmartTransactionsController_getFeatureFlags, "f"),
560
+ })) {
561
+ markRegularTransactionAsFailed({
562
+ smartTransaction: nextSmartTransaction,
563
+ getRegularTransactions: () => this.messagingSystem.call('TransactionController:getTransactions'),
564
+ updateTransaction: (transactionMeta, note) => this.messagingSystem.call('TransactionController:updateTransaction', transactionMeta, note),
565
+ });
566
+ }
567
+ if ((smartTransaction.status === SmartTransactionStatuses.SUCCESS ||
568
+ smartTransaction.status === SmartTransactionStatuses.REVERTED) &&
569
+ !smartTransaction.confirmed) {
570
+ await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_confirmSmartTransaction).call(this, nextSmartTransaction, {
571
+ chainId,
572
+ ethQuery,
573
+ });
574
+ }
575
+ else {
576
+ __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_updateSmartTransaction).call(this, smartTransaction, {
577
+ chainId,
578
+ });
579
+ }
580
+ }, _SmartTransactionsController_doesTransactionNeedConfirmation = function _SmartTransactionsController_doesTransactionNeedConfirmation(txHash) {
581
+ if (!txHash) {
582
+ return true;
583
+ }
584
+ const transactions = this.messagingSystem.call('TransactionController:getTransactions');
585
+ const foundTransaction = transactions === null || transactions === void 0 ? void 0 : transactions.find((tx) => {
586
+ var _a;
587
+ return ((_a = tx.hash) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === txHash.toLowerCase();
588
+ });
589
+ if (!foundTransaction) {
590
+ return true;
591
+ }
592
+ // If a found transaction is either confirmed or submitted, it doesn't need confirmation from the STX controller.
593
+ // When it's in the submitted state, the TransactionController checks its status and confirms it,
594
+ // so no need to confirm it again here.
595
+ return ![TransactionStatus.confirmed, TransactionStatus.submitted].includes(foundTransaction.status);
596
+ }, _SmartTransactionsController_confirmSmartTransaction = async function _SmartTransactionsController_confirmSmartTransaction(smartTransaction, { chainId = __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f"), ethQuery = __classPrivateFieldGet(this, _SmartTransactionsController_ethQuery, "f"), }) {
597
+ var _a;
598
+ if (ethQuery === undefined) {
599
+ throw new Error(ETH_QUERY_ERROR_MSG);
600
+ }
601
+ const txHash = (_a = smartTransaction.statusMetadata) === null || _a === void 0 ? void 0 : _a.minedHash;
602
+ try {
603
+ const transactionReceipt = await query(ethQuery, 'getTransactionReceipt', [txHash]);
604
+ const transaction = await query(ethQuery, 'getTransactionByHash', [txHash]);
605
+ const maxFeePerGas = transaction === null || transaction === void 0 ? void 0 : transaction.maxFeePerGas;
606
+ const maxPriorityFeePerGas = transaction === null || transaction === void 0 ? void 0 : transaction.maxPriorityFeePerGas;
607
+ if (transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.blockNumber) {
608
+ const blockData = await query(ethQuery, 'getBlockByNumber', [transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.blockNumber, false]);
609
+ const baseFeePerGas = blockData === null || blockData === void 0 ? void 0 : blockData.baseFeePerGas;
610
+ const updatedTxParams = Object.assign(Object.assign({}, smartTransaction.txParams), { maxFeePerGas,
611
+ maxPriorityFeePerGas });
612
+ // call confirmExternalTransaction
613
+ const originalTxMeta = Object.assign(Object.assign({}, smartTransaction), { id: smartTransaction.uuid, status: TransactionStatus.confirmed, hash: txHash, txParams: updatedTxParams });
614
+ // create txMeta snapshot for history
615
+ const snapshot = snapshotFromTxMeta(originalTxMeta);
616
+ // recover previous tx state obj
617
+ const previousState = replayHistory(originalTxMeta.history);
618
+ // generate history entry and add to history
619
+ const entry = generateHistoryEntry(previousState, snapshot, 'txStateManager: setting status to confirmed');
620
+ const txMeta = entry.length > 0
621
+ ? Object.assign(Object.assign({}, originalTxMeta), { history: originalTxMeta.history.concat(entry) }) : originalTxMeta;
622
+ if (__classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_doesTransactionNeedConfirmation).call(this, txHash)) {
623
+ this.messagingSystem.call('TransactionController:confirmExternalTransaction',
624
+ // TODO: Replace 'as' assertion with correct typing for `txMeta`
625
+ txMeta, transactionReceipt,
626
+ // TODO: Replace 'as' assertion with correct typing for `baseFeePerGas`
627
+ baseFeePerGas);
628
+ }
629
+ __classPrivateFieldGet(this, _SmartTransactionsController_trackMetaMetricsEvent, "f").call(this, {
630
+ event: MetaMetricsEventName.StxConfirmed,
631
+ category: MetaMetricsEventCategory.Transactions,
632
+ properties: getSmartTransactionMetricsProperties(smartTransaction),
633
+ sensitiveProperties: getSmartTransactionMetricsSensitiveProperties(smartTransaction),
634
+ });
635
+ __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_updateSmartTransaction).call(this, Object.assign(Object.assign({}, smartTransaction), { confirmed: true }), {
636
+ chainId,
637
+ });
638
+ }
639
+ }
640
+ catch (error) {
641
+ __classPrivateFieldGet(this, _SmartTransactionsController_trackMetaMetricsEvent, "f").call(this, {
642
+ event: MetaMetricsEventName.StxConfirmationFailed,
643
+ category: MetaMetricsEventCategory.Transactions,
644
+ });
645
+ console.error('confirm error', error);
646
+ }
647
+ finally {
648
+ this.messagingSystem.publish(`SmartTransactionsController:smartTransactionConfirmationDone`, smartTransaction);
649
+ }
650
+ }, _SmartTransactionsController_addNonceToTransaction = async function _SmartTransactionsController_addNonceToTransaction(transaction, networkClientId) {
651
+ const nonceLock = await this.messagingSystem.call('TransactionController:getNonceLock', transaction.from, networkClientId);
652
+ const nonce = nonceLock.nextNonce;
653
+ nonceLock.releaseLock();
654
+ return Object.assign(Object.assign({}, transaction), { nonce: `0x${nonce.toString(16)}` });
655
+ }, _SmartTransactionsController_getChainId = function _SmartTransactionsController_getChainId({ networkClientId, } = {}) {
656
+ if (networkClientId) {
657
+ return this.messagingSystem.call('NetworkController:getNetworkClientById', networkClientId).configuration.chainId;
658
+ }
659
+ return __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f");
660
+ }, _SmartTransactionsController_getChainIds = function _SmartTransactionsController_getChainIds() {
661
+ const { networkConfigurationsByChainId } = this.messagingSystem.call('NetworkController:getState');
662
+ return Object.keys(networkConfigurationsByChainId).filter((chainId) => __classPrivateFieldGet(this, _SmartTransactionsController_supportedChainIds, "f").includes(chainId));
663
+ }, _SmartTransactionsController_getNetworkClientId = function _SmartTransactionsController_getNetworkClientId({ chainId }) {
664
+ const { networkConfigurationsByChainId } = this.messagingSystem.call('NetworkController:getState');
665
+ return networkConfigurationsByChainId[chainId].rpcEndpoints[networkConfigurationsByChainId[chainId].defaultRpcEndpointIndex].networkClientId;
666
+ }, _SmartTransactionsController_getEthQuery = function _SmartTransactionsController_getEthQuery({ networkClientId, } = {}) {
667
+ if (networkClientId) {
668
+ const { provider } = this.messagingSystem.call('NetworkController:getNetworkClientById', networkClientId);
669
+ return new EthQuery(provider);
670
+ }
671
+ if (__classPrivateFieldGet(this, _SmartTransactionsController_ethQuery, "f") === undefined) {
672
+ throw new Error(ETH_QUERY_ERROR_MSG);
673
+ }
674
+ return __classPrivateFieldGet(this, _SmartTransactionsController_ethQuery, "f");
675
+ }, _SmartTransactionsController_getCurrentSmartTransactions = function _SmartTransactionsController_getCurrentSmartTransactions() {
676
+ const { smartTransactionsState: { smartTransactions }, } = this.state;
677
+ const smartTransactionsForAllChains = Object.values(smartTransactions).flat();
678
+ if (!smartTransactionsForAllChains ||
679
+ smartTransactionsForAllChains.length === 0) {
680
+ return [];
681
+ }
682
+ return smartTransactionsForAllChains;
683
+ }, _SmartTransactionsController_wipeSmartTransactionsPerChainId = function _SmartTransactionsController_wipeSmartTransactionsPerChainId({ chainId, addressLowerCase, }) {
684
+ const { smartTransactionsState: { smartTransactions }, } = this.state;
685
+ const smartTransactionsForSelectedChain = smartTransactions === null || smartTransactions === void 0 ? void 0 : smartTransactions[chainId];
686
+ if (!smartTransactionsForSelectedChain ||
687
+ smartTransactionsForSelectedChain.length === 0) {
688
+ return;
689
+ }
690
+ const newSmartTransactionsForSelectedChain = smartTransactionsForSelectedChain.filter((smartTransaction) => { var _a; return ((_a = smartTransaction.txParams) === null || _a === void 0 ? void 0 : _a.from) !== addressLowerCase; });
691
+ this.update((state) => {
692
+ state.smartTransactionsState.smartTransactions[chainId] =
693
+ newSmartTransactionsForSelectedChain;
694
+ });
695
+ };
696
+ //# sourceMappingURL=SmartTransactionsController.mjs.map