@metamask-previews/smart-transactions-controller 19.2.1-preview-54c655a → 19.2.1-preview-520a56d

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.
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
2
  if (kind === "m") throw new TypeError("Private method is not writable");
4
3
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -10,32 +9,27 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
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");
11
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
11
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
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;
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.SmartTransactionsController = exports.getDefaultSmartTransactionsControllerState = exports.DEFAULT_INTERVAL = void 0;
19
13
  function $importDefault(module) {
20
14
  if (module === null || module === void 0 ? void 0 : module.__esModule) {
21
15
  return module.default;
22
16
  }
23
17
  return module;
24
18
  }
25
- const bytes_1 = require("@ethersproject/bytes");
26
- const controller_utils_1 = require("@metamask/controller-utils");
27
- const eth_query_1 = __importDefault(require("@metamask/eth-query"));
19
+ import { hexlify } from "@ethersproject/bytes";
20
+ import { query, safelyExecute, ChainId, isSafeDynamicKey } from "@metamask/controller-utils";
21
+ import $EthQuery from "@metamask/eth-query";
28
22
  const EthQuery = $importDefault($EthQuery);
29
- const polling_controller_1 = require("@metamask/polling-controller");
30
- const transaction_controller_1 = require("@metamask/transaction-controller");
31
- const bignumber_js_1 = require("bignumber.js");
32
- const cloneDeep_1 = __importDefault(require("lodash/cloneDeep.js"));
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";
33
27
  const cloneDeep = $importDefault($cloneDeep);
34
- const constants_1 = require("./constants.mjs");
35
- const types_1 = require("./types.mjs");
36
- const utils_1 = require("./utils.mjs");
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";
37
31
  const SECOND = 1000;
38
- exports.DEFAULT_INTERVAL = SECOND * 5;
32
+ export const DEFAULT_INTERVAL = SECOND * 5;
39
33
  const ETH_QUERY_ERROR_MSG = '`ethQuery` is not defined on SmartTransactionsController';
40
34
  /**
41
35
  * The name of the {@link SmartTransactionsController}
@@ -54,7 +48,7 @@ const controllerMetadata = {
54
48
  *
55
49
  * @returns The default {@link SmartTransactionsController} state.
56
50
  */
57
- function getDefaultSmartTransactionsControllerState() {
51
+ export function getDefaultSmartTransactionsControllerState() {
58
52
  return {
59
53
  smartTransactionsState: {
60
54
  smartTransactions: {},
@@ -66,15 +60,15 @@ function getDefaultSmartTransactionsControllerState() {
66
60
  },
67
61
  liveness: true,
68
62
  livenessByChainId: {
69
- [controller_utils_1.ChainId.mainnet]: true,
70
- [controller_utils_1.ChainId.sepolia]: true,
63
+ [ChainId.mainnet]: true,
64
+ [ChainId.sepolia]: true,
71
65
  },
72
66
  feesByChainId: {
73
- [controller_utils_1.ChainId.mainnet]: {
67
+ [ChainId.mainnet]: {
74
68
  approvalTxFees: null,
75
69
  tradeTxFees: null,
76
70
  },
77
- [controller_utils_1.ChainId.sepolia]: {
71
+ [ChainId.sepolia]: {
78
72
  approvalTxFees: null,
79
73
  tradeTxFees: null,
80
74
  },
@@ -82,9 +76,8 @@ function getDefaultSmartTransactionsControllerState() {
82
76
  },
83
77
  };
84
78
  }
85
- exports.getDefaultSmartTransactionsControllerState = getDefaultSmartTransactionsControllerState;
86
- class SmartTransactionsController extends (0, polling_controller_1.StaticIntervalPollingController)() {
87
- constructor({ interval = exports.DEFAULT_INTERVAL, clientId, chainId: InitialChainId = controller_utils_1.ChainId.mainnet, supportedChainIds = [controller_utils_1.ChainId.mainnet, controller_utils_1.ChainId.sepolia], trackMetaMetricsEvent, state = {}, messenger, getMetaMetricsProps, getFeatureFlags, trace, }) {
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, }) {
88
81
  super({
89
82
  name: controllerName,
90
83
  metadata: controllerMetadata,
@@ -115,7 +108,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
115
108
  this.messenger.subscribe('NetworkController:stateChange', ({ selectedNetworkClientId }) => {
116
109
  const { configuration: { chainId }, provider, } = this.messenger.call('NetworkController:getNetworkClientById', selectedNetworkClientId);
117
110
  __classPrivateFieldSet(this, _SmartTransactionsController_chainId, chainId, "f");
118
- __classPrivateFieldSet(this, _SmartTransactionsController_ethQuery, new eth_query_1.default(provider), "f");
111
+ __classPrivateFieldSet(this, _SmartTransactionsController_ethQuery, new EthQuery(provider), "f");
119
112
  this.initializeSmartTransactionsForChainId();
120
113
  this.checkPoll(this.state);
121
114
  });
@@ -134,7 +127,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
134
127
  }
135
128
  checkPoll({ smartTransactionsState: { smartTransactions }, }) {
136
129
  const smartTransactionsForAllChains = Object.values(smartTransactions).flat();
137
- const pendingTransactions = smartTransactionsForAllChains === null || smartTransactionsForAllChains === void 0 ? void 0 : smartTransactionsForAllChains.filter(utils_1.isSmartTransactionPending);
130
+ const pendingTransactions = smartTransactionsForAllChains === null || smartTransactionsForAllChains === void 0 ? void 0 : smartTransactionsForAllChains.filter(isSmartTransactionPending);
138
131
  if (!this.timeoutHandle && (pendingTransactions === null || pendingTransactions === void 0 ? void 0 : pendingTransactions.length) > 0) {
139
132
  this.poll();
140
133
  }
@@ -160,9 +153,9 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
160
153
  return;
161
154
  }
162
155
  this.timeoutHandle = setInterval(() => {
163
- (0, controller_utils_1.safelyExecute)(async () => this.updateSmartTransactions());
156
+ safelyExecute(async () => this.updateSmartTransactions());
164
157
  }, __classPrivateFieldGet(this, _SmartTransactionsController_interval, "f"));
165
- await (0, controller_utils_1.safelyExecute)(async () => this.updateSmartTransactions());
158
+ await safelyExecute(async () => this.updateSmartTransactions());
166
159
  }
167
160
  async stop() {
168
161
  this.timeoutHandle && clearInterval(this.timeoutHandle);
@@ -174,16 +167,16 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
174
167
  });
175
168
  }
176
169
  trackStxStatusChange(smartTransaction, prevSmartTransaction) {
177
- let updatedSmartTransaction = (0, cloneDeep_1.default)(smartTransaction);
178
- updatedSmartTransaction = Object.assign(Object.assign({}, (0, cloneDeep_1.default)(prevSmartTransaction)), updatedSmartTransaction);
170
+ let updatedSmartTransaction = cloneDeep(smartTransaction);
171
+ updatedSmartTransaction = Object.assign(Object.assign({}, cloneDeep(prevSmartTransaction)), updatedSmartTransaction);
179
172
  if (updatedSmartTransaction.status === (prevSmartTransaction === null || prevSmartTransaction === void 0 ? void 0 : prevSmartTransaction.status)) {
180
173
  return; // If status hasn't changed, don't track it again.
181
174
  }
182
175
  __classPrivateFieldGet(this, _SmartTransactionsController_trackMetaMetricsEvent, "f").call(this, {
183
- event: constants_1.MetaMetricsEventName.StxStatusUpdated,
184
- category: constants_1.MetaMetricsEventCategory.Transactions,
185
- properties: (0, utils_1.getSmartTransactionMetricsProperties)(updatedSmartTransaction),
186
- sensitiveProperties: (0, utils_1.getSmartTransactionMetricsSensitiveProperties)(updatedSmartTransaction),
176
+ event: MetaMetricsEventName.StxStatusUpdated,
177
+ category: MetaMetricsEventCategory.Transactions,
178
+ properties: getSmartTransactionMetricsProperties(updatedSmartTransaction),
179
+ sensitiveProperties: getSmartTransactionMetricsSensitiveProperties(updatedSmartTransaction),
187
180
  });
188
181
  }
189
182
  isNewSmartTransaction(smartTransactionUuid, chainId) {
@@ -198,7 +191,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
198
191
  if (networkClientId) {
199
192
  const { configuration, provider } = this.messenger.call('NetworkController:getNetworkClientById', networkClientId);
200
193
  chainId = configuration.chainId;
201
- ethQuery = new eth_query_1.default(provider);
194
+ ethQuery = new EthQuery(provider);
202
195
  }
203
196
  __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_createOrUpdateSmartTransaction).call(this, smartTransaction, {
204
197
  chainId,
@@ -216,7 +209,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
216
209
  }
217
210
  // Filter pending transactions and map them to the desired shape
218
211
  const pendingTransactions = transactions
219
- .filter(utils_1.isSmartTransactionPending)
212
+ .filter(isSmartTransactionPending)
220
213
  .map((pendingSmartTransaction) => {
221
214
  // Use the transaction's chainId (from the key) to derive a networkClientId
222
215
  const networkClientIdToUse = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getNetworkClientId).call(this, {
@@ -246,7 +239,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
246
239
  networkClientId: transactions[0].networkClientId,
247
240
  });
248
241
  // Construct the URL and fetch the data
249
- const url = `${(0, utils_1.getAPIRequestURL)(types_1.APIType.BATCH_STATUS, chainId)}?${params.toString()}`;
242
+ const url = `${getAPIRequestURL(APIType.BATCH_STATUS, chainId)}?${params.toString()}`;
250
243
  const data = (await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, url));
251
244
  // Process each returned status
252
245
  for (const [uuid, stxStatus] of Object.entries(data)) {
@@ -257,8 +250,8 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
257
250
  }
258
251
  const smartTransaction = {
259
252
  statusMetadata: stxStatus,
260
- status: (0, utils_1.calculateStatus)(stxStatus),
261
- cancellable: (0, utils_1.isSmartTransactionCancellable)(stxStatus),
253
+ status: calculateStatus(stxStatus),
254
+ cancellable: isSmartTransactionCancellable(stxStatus),
262
255
  uuid,
263
256
  networkClientId: matchingTx.networkClientId,
264
257
  };
@@ -291,7 +284,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
291
284
  transactions.push(unsignedApprovalTransactionWithNonce);
292
285
  unsignedTradeTransactionWithNonce = Object.assign(Object.assign({}, tradeTx), {
293
286
  // If there is an approval tx, the trade tx's nonce is increased by 1.
294
- nonce: (0, utils_1.incrementNonceInHex)(unsignedApprovalTransactionWithNonce.nonce) });
287
+ nonce: incrementNonceInHex(unsignedApprovalTransactionWithNonce.nonce) });
295
288
  }
296
289
  else if (tradeTx.nonce) {
297
290
  unsignedTradeTransactionWithNonce = tradeTx;
@@ -300,7 +293,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
300
293
  unsignedTradeTransactionWithNonce = await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_addNonceToTransaction).call(this, tradeTx, selectedNetworkClientId);
301
294
  }
302
295
  transactions.push(unsignedTradeTransactionWithNonce);
303
- const data = await __classPrivateFieldGet(this, _SmartTransactionsController_trace, "f").call(this, { name: constants_1.SmartTransactionsTraceName.GetFees }, async () => await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, (0, utils_1.getAPIRequestURL)(types_1.APIType.GET_FEES, chainId), {
296
+ 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), {
304
297
  method: 'POST',
305
298
  body: JSON.stringify({
306
299
  txs: transactions,
@@ -344,7 +337,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
344
337
  const ethQuery = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getEthQuery).call(this, {
345
338
  networkClientId: selectedNetworkClientId,
346
339
  });
347
- const data = await __classPrivateFieldGet(this, _SmartTransactionsController_trace, "f").call(this, { name: constants_1.SmartTransactionsTraceName.SubmitTransactions }, async () => await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, (0, utils_1.getAPIRequestURL)(types_1.APIType.SUBMIT_TRANSACTIONS, chainId), {
340
+ 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), {
348
341
  method: 'POST',
349
342
  body: JSON.stringify({
350
343
  rawTxs: signedTransactions,
@@ -355,10 +348,10 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
355
348
  let preTxBalance;
356
349
  try {
357
350
  if (txParams === null || txParams === void 0 ? void 0 : txParams.from) {
358
- const preTxBalanceBN = await (0, controller_utils_1.query)(ethQuery, 'getBalance', [
351
+ const preTxBalanceBN = await query(ethQuery, 'getBalance', [
359
352
  txParams.from,
360
353
  ]);
361
- preTxBalance = new bignumber_js_1.BigNumber(preTxBalanceBN).toString(16);
354
+ preTxBalance = new BigNumber(preTxBalanceBN).toString(16);
362
355
  }
363
356
  }
364
357
  catch (error) {
@@ -372,7 +365,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
372
365
  if (requiresNonce) {
373
366
  try {
374
367
  nonceLock = await this.messenger.call('TransactionController:getNonceLock', txParams.from, selectedNetworkClientId);
375
- nonce = (0, bytes_1.hexlify)(nonceLock.nextNonce);
368
+ nonce = hexlify(nonceLock.nextNonce);
376
369
  nonceDetails = nonceLock.nonceDetails;
377
370
  (_a = txParams.nonce) !== null && _a !== void 0 ? _a : (txParams.nonce = nonce);
378
371
  }
@@ -381,7 +374,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
381
374
  throw error;
382
375
  }
383
376
  }
384
- const txHashes = signedTransactions.map((tx) => (0, utils_1.getTxHash)(tx));
377
+ const txHashes = signedTransactions.map((tx) => getTxHash(tx));
385
378
  const submitTransactionResponse = Object.assign(Object.assign({}, data), { txHash: txHashes[txHashes.length - 1], // For backward compatibility - use the last tx hash
386
379
  txHashes });
387
380
  try {
@@ -389,7 +382,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
389
382
  chainId,
390
383
  nonceDetails,
391
384
  preTxBalance,
392
- status: types_1.SmartTransactionStatuses.PENDING,
385
+ status: SmartTransactionStatuses.PENDING,
393
386
  time,
394
387
  txParams,
395
388
  uuid: submitTransactionResponse.uuid,
@@ -417,7 +410,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
417
410
  // in transaction controller external transactions list
418
411
  async cancelSmartTransaction(uuid, { networkClientId, } = {}) {
419
412
  const chainId = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getChainId).call(this, { networkClientId });
420
- await __classPrivateFieldGet(this, _SmartTransactionsController_trace, "f").call(this, { name: constants_1.SmartTransactionsTraceName.CancelTransaction }, async () => await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, (0, utils_1.getAPIRequestURL)(types_1.APIType.CANCEL, chainId), {
413
+ 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), {
421
414
  method: 'POST',
422
415
  body: JSON.stringify({ uuid }),
423
416
  }));
@@ -426,7 +419,7 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
426
419
  const chainId = __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_getChainId).call(this, { networkClientId });
427
420
  let liveness = false;
428
421
  try {
429
- const response = await __classPrivateFieldGet(this, _SmartTransactionsController_trace, "f").call(this, { name: constants_1.SmartTransactionsTraceName.FetchLiveness }, async () => await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_fetch).call(this, (0, utils_1.getAPIRequestURL)(types_1.APIType.LIVENESS, chainId)));
422
+ 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)));
430
423
  liveness = Boolean(response.smartTransactions);
431
424
  }
432
425
  catch (error) {
@@ -485,12 +478,11 @@ class SmartTransactionsController extends (0, polling_controller_1.StaticInterva
485
478
  }
486
479
  }
487
480
  }
488
- exports.SmartTransactionsController = SmartTransactionsController;
489
481
  _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 =
490
482
  /* istanbul ignore next */
491
483
  async function _SmartTransactionsController_fetch(request, options) {
492
484
  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") })) });
493
- return (0, utils_1.handleFetch)(request, fetchOptions);
485
+ return handleFetch(request, fetchOptions);
494
486
  }, _SmartTransactionsController_updateSmartTransaction = function _SmartTransactionsController_updateSmartTransaction(smartTransaction, { chainId = __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f"), }) {
495
487
  var _a;
496
488
  const { smartTransactionsState: { smartTransactions }, } = this.state;
@@ -499,7 +491,7 @@ async function _SmartTransactionsController_fetch(request, options) {
499
491
  if (currentIndex === -1) {
500
492
  return; // Smart transaction not found, don't update anything.
501
493
  }
502
- if (!(0, controller_utils_1.isSafeDynamicKey)(chainId)) {
494
+ if (!isSafeDynamicKey(chainId)) {
503
495
  return;
504
496
  }
505
497
  this.update((state) => {
@@ -539,7 +531,7 @@ async function _SmartTransactionsController_fetch(request, options) {
539
531
  return ((_a = stx.txParams) === null || _a === void 0 ? void 0 : _a.nonce) === ((_b = smartTransaction.txParams) === null || _b === void 0 ? void 0 : _b.nonce) &&
540
532
  ((_c = stx.status) === null || _c === void 0 ? void 0 : _c.startsWith('cancelled'));
541
533
  });
542
- const snapshot = (0, cloneDeep_1.default)(smartTransaction);
534
+ const snapshot = cloneDeep(smartTransaction);
543
535
  const history = [snapshot];
544
536
  const historifiedSmartTransaction = Object.assign(Object.assign({}, smartTransaction), { history });
545
537
  const nextSmartTransactions = cancelledNonceIndex > -1
@@ -559,19 +551,19 @@ async function _SmartTransactionsController_fetch(request, options) {
559
551
  // We have to emit this event here, because then a txHash is returned to the TransactionController once it's available
560
552
  // and the #doesTransactionNeedConfirmation function will work properly, since it will find the txHash in the regular transactions list.
561
553
  this.messenger.publish(`SmartTransactionsController:smartTransaction`, nextSmartTransaction);
562
- if ((0, utils_1.shouldMarkRegularTransactionAsFailed)({
554
+ if (shouldMarkRegularTransactionAsFailed({
563
555
  smartTransaction: nextSmartTransaction,
564
556
  clientId: __classPrivateFieldGet(this, _SmartTransactionsController_clientId, "f"),
565
557
  getFeatureFlags: __classPrivateFieldGet(this, _SmartTransactionsController_getFeatureFlags, "f"),
566
558
  })) {
567
- (0, utils_1.markRegularTransactionAsFailed)({
559
+ markRegularTransactionAsFailed({
568
560
  smartTransaction: nextSmartTransaction,
569
561
  getRegularTransactions: () => this.messenger.call('TransactionController:getTransactions'),
570
562
  updateTransaction: (transactionMeta, note) => this.messenger.call('TransactionController:updateTransaction', transactionMeta, note),
571
563
  });
572
564
  }
573
- if ((smartTransaction.status === types_1.SmartTransactionStatuses.SUCCESS ||
574
- smartTransaction.status === types_1.SmartTransactionStatuses.REVERTED) &&
565
+ if ((smartTransaction.status === SmartTransactionStatuses.SUCCESS ||
566
+ smartTransaction.status === SmartTransactionStatuses.REVERTED) &&
575
567
  !smartTransaction.confirmed) {
576
568
  await __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_confirmSmartTransaction).call(this, nextSmartTransaction, {
577
569
  chainId,
@@ -598,7 +590,7 @@ async function _SmartTransactionsController_fetch(request, options) {
598
590
  // If a found transaction is either confirmed or submitted, it doesn't need confirmation from the STX controller.
599
591
  // When it's in the submitted state, the TransactionController checks its status and confirms it,
600
592
  // so no need to confirm it again here.
601
- return ![transaction_controller_1.TransactionStatus.confirmed, transaction_controller_1.TransactionStatus.submitted].includes(foundTransaction.status);
593
+ return ![TransactionStatus.confirmed, TransactionStatus.submitted].includes(foundTransaction.status);
602
594
  }, _SmartTransactionsController_confirmSmartTransaction = async function _SmartTransactionsController_confirmSmartTransaction(smartTransaction, { chainId = __classPrivateFieldGet(this, _SmartTransactionsController_chainId, "f"), ethQuery = __classPrivateFieldGet(this, _SmartTransactionsController_ethQuery, "f"), }) {
603
595
  var _a;
604
596
  if (ethQuery === undefined) {
@@ -606,23 +598,23 @@ async function _SmartTransactionsController_fetch(request, options) {
606
598
  }
607
599
  const txHash = (_a = smartTransaction.statusMetadata) === null || _a === void 0 ? void 0 : _a.minedHash;
608
600
  try {
609
- const transactionReceipt = await (0, controller_utils_1.query)(ethQuery, 'getTransactionReceipt', [txHash]);
610
- const transaction = await (0, controller_utils_1.query)(ethQuery, 'getTransactionByHash', [txHash]);
601
+ const transactionReceipt = await query(ethQuery, 'getTransactionReceipt', [txHash]);
602
+ const transaction = await query(ethQuery, 'getTransactionByHash', [txHash]);
611
603
  const maxFeePerGas = transaction === null || transaction === void 0 ? void 0 : transaction.maxFeePerGas;
612
604
  const maxPriorityFeePerGas = transaction === null || transaction === void 0 ? void 0 : transaction.maxPriorityFeePerGas;
613
605
  if (transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.blockNumber) {
614
- const blockData = await (0, controller_utils_1.query)(ethQuery, 'getBlockByNumber', [transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.blockNumber, false]);
606
+ const blockData = await query(ethQuery, 'getBlockByNumber', [transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.blockNumber, false]);
615
607
  const baseFeePerGas = blockData === null || blockData === void 0 ? void 0 : blockData.baseFeePerGas;
616
608
  const updatedTxParams = Object.assign(Object.assign({}, smartTransaction.txParams), { maxFeePerGas,
617
609
  maxPriorityFeePerGas });
618
610
  // call confirmExternalTransaction
619
- const originalTxMeta = Object.assign(Object.assign({}, smartTransaction), { id: smartTransaction.uuid, status: transaction_controller_1.TransactionStatus.confirmed, hash: txHash, txParams: updatedTxParams });
611
+ const originalTxMeta = Object.assign(Object.assign({}, smartTransaction), { id: smartTransaction.uuid, status: TransactionStatus.confirmed, hash: txHash, txParams: updatedTxParams });
620
612
  // create txMeta snapshot for history
621
- const snapshot = (0, utils_1.snapshotFromTxMeta)(originalTxMeta);
613
+ const snapshot = snapshotFromTxMeta(originalTxMeta);
622
614
  // recover previous tx state obj
623
- const previousState = (0, utils_1.replayHistory)(originalTxMeta.history);
615
+ const previousState = replayHistory(originalTxMeta.history);
624
616
  // generate history entry and add to history
625
- const entry = (0, utils_1.generateHistoryEntry)(previousState, snapshot, 'txStateManager: setting status to confirmed');
617
+ const entry = generateHistoryEntry(previousState, snapshot, 'txStateManager: setting status to confirmed');
626
618
  const txMeta = entry.length > 0
627
619
  ? Object.assign(Object.assign({}, originalTxMeta), { history: originalTxMeta.history.concat(entry) }) : originalTxMeta;
628
620
  if (__classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_doesTransactionNeedConfirmation).call(this, txHash)) {
@@ -633,10 +625,10 @@ async function _SmartTransactionsController_fetch(request, options) {
633
625
  baseFeePerGas);
634
626
  }
635
627
  __classPrivateFieldGet(this, _SmartTransactionsController_trackMetaMetricsEvent, "f").call(this, {
636
- event: constants_1.MetaMetricsEventName.StxConfirmed,
637
- category: constants_1.MetaMetricsEventCategory.Transactions,
638
- properties: (0, utils_1.getSmartTransactionMetricsProperties)(smartTransaction),
639
- sensitiveProperties: (0, utils_1.getSmartTransactionMetricsSensitiveProperties)(smartTransaction),
628
+ event: MetaMetricsEventName.StxConfirmed,
629
+ category: MetaMetricsEventCategory.Transactions,
630
+ properties: getSmartTransactionMetricsProperties(smartTransaction),
631
+ sensitiveProperties: getSmartTransactionMetricsSensitiveProperties(smartTransaction),
640
632
  });
641
633
  __classPrivateFieldGet(this, _SmartTransactionsController_instances, "m", _SmartTransactionsController_updateSmartTransaction).call(this, Object.assign(Object.assign({}, smartTransaction), { confirmed: true }), {
642
634
  chainId,
@@ -645,8 +637,8 @@ async function _SmartTransactionsController_fetch(request, options) {
645
637
  }
646
638
  catch (error) {
647
639
  __classPrivateFieldGet(this, _SmartTransactionsController_trackMetaMetricsEvent, "f").call(this, {
648
- event: constants_1.MetaMetricsEventName.StxConfirmationFailed,
649
- category: constants_1.MetaMetricsEventCategory.Transactions,
640
+ event: MetaMetricsEventName.StxConfirmationFailed,
641
+ category: MetaMetricsEventCategory.Transactions,
650
642
  });
651
643
  console.error('confirm error', error);
652
644
  }
@@ -672,7 +664,7 @@ async function _SmartTransactionsController_fetch(request, options) {
672
664
  }, _SmartTransactionsController_getEthQuery = function _SmartTransactionsController_getEthQuery({ networkClientId, } = {}) {
673
665
  if (networkClientId) {
674
666
  const { provider } = this.messenger.call('NetworkController:getNetworkClientById', networkClientId);
675
- return new eth_query_1.default(provider);
667
+ return new EthQuery(provider);
676
668
  }
677
669
  if (__classPrivateFieldGet(this, _SmartTransactionsController_ethQuery, "f") === undefined) {
678
670
  throw new Error(ETH_QUERY_ERROR_MSG);