@metamask-previews/bridge-status-controller 76.4.0-preview-d687d3ab2 → 76.4.0-preview-b50d61887

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 (35) hide show
  1. package/CHANGELOG.md +0 -14
  2. package/dist/bridge-status-controller.d.ts.map +1 -1
  3. package/dist/bridge-status-controller.js +40 -78
  4. package/dist/bridge-status-controller.js.map +1 -1
  5. package/dist/strategy/batch-sell-strategy.d.ts.map +1 -1
  6. package/dist/strategy/batch-sell-strategy.js +34 -62
  7. package/dist/strategy/batch-sell-strategy.js.map +1 -1
  8. package/dist/strategy/batch-strategy.d.ts.map +1 -1
  9. package/dist/strategy/batch-strategy.js +13 -38
  10. package/dist/strategy/batch-strategy.js.map +1 -1
  11. package/dist/strategy/evm-strategy.d.ts +28 -2
  12. package/dist/strategy/evm-strategy.d.ts.map +1 -1
  13. package/dist/strategy/evm-strategy.js +39 -62
  14. package/dist/strategy/evm-strategy.js.map +1 -1
  15. package/dist/strategy/intent-strategy.d.ts.map +1 -1
  16. package/dist/strategy/intent-strategy.js +1 -2
  17. package/dist/strategy/intent-strategy.js.map +1 -1
  18. package/dist/strategy/types.d.ts +2 -3
  19. package/dist/strategy/types.d.ts.map +1 -1
  20. package/dist/strategy/types.js.map +1 -1
  21. package/dist/types.d.ts +2 -1
  22. package/dist/types.d.ts.map +1 -1
  23. package/dist/types.js.map +1 -1
  24. package/dist/utils/history.d.ts +2 -2
  25. package/dist/utils/history.d.ts.map +1 -1
  26. package/dist/utils/history.js +25 -64
  27. package/dist/utils/history.js.map +1 -1
  28. package/dist/utils/metrics.d.ts +33 -2
  29. package/dist/utils/metrics.d.ts.map +1 -1
  30. package/dist/utils/metrics.js.map +1 -1
  31. package/dist/utils/transaction.d.ts +0 -2
  32. package/dist/utils/transaction.d.ts.map +1 -1
  33. package/dist/utils/transaction.js +4 -16
  34. package/dist/utils/transaction.js.map +1 -1
  35. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -9,20 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Changed
11
11
 
12
- - Update batch-strategy and batch-sell-strategy history persistence ([#10814](https://github.com/MetaMask/core/pull/10814))
13
- - add a history item before submitting transactions. This enables the `TransactionController:transactionStatusUpdated` listener to match the txMeta with history and determine whether to publish the Failed event
14
- - include latest `TransactionStatus` when rekey-ing or adding to history
15
- - Update evm-strategy history persistence ([#10814](https://github.com/MetaMask/core/pull/10814))
16
- - if an approval is required, key initial historyItem by `actionId`
17
- - rekey to the trade's `actionId` if the approval succeeds
18
- - rekey to the trade's `id` on confirmation
19
-
20
- ### Fixed
21
-
22
- - Emit only one `Unified SwapBridge Failed` event when `addTransaction` or `addTransactionBatch` fails ([#10814](https://github.com/MetaMask/core/pull/10814))
23
- - Pre-submit history: evm keyed by actionId, batch + batch-sell keyed by batchId
24
- - After tx exists: listener publishes Failed; submitTx returns the txMeta
25
- - Before tx exists: submitTx catch publishes Failed
26
12
  - Bump `@metamask/accounts-controller` from `^40.0.0` to `^40.1.0` ([#10851](https://github.com/MetaMask/core/pull/10851))
27
13
  - Bump `@metamask/keyring-controller` from `^28.1.0` to `^28.2.0` ([#10851](https://github.com/MetaMask/core/pull/10851))
28
14
  - Bump `@metamask/base-controller` from `^10.0.0` to `^10.1.0` ([#10864](https://github.com/MetaMask/core/pull/10864))
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-status-controller.d.ts","sourceRoot":"","sources":["../src/bridge-status-controller.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,8BAA8B,EAC9B,eAAe,EACf,KAAK,EAEL,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EAMd,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAEV,2BAA2B,EAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAIL,0BAA0B,EAG1B,2BAA2B,EAG5B,MAAM,6BAA6B,CAAC;AACrC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O,CAAC;QACvB,qBAAqB,CAAC,EAAE,8BAA8B,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAC;QAClG,4BAA4B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7C,cAAc,CAAC,EAAE,2BAA2B,CAAC;KAC9C,KAAG,OAAO,CAAC,eAAe,CAAC,CAsB1B;CAsNH"}
@@ -18,7 +18,7 @@ import { getInitialHistoryItem, getMatchingHistoryEntryForTxMeta, rekeyHistoryIt
18
18
  import { getFinalizedTxProperties, getPriceImpactFromQuote, getRequestMetadataFromHistory, getRequestParamFromHistory, getTradeDataFromHistory, getEVMTxPropertiesFromTransactionMeta, getTxStatusesFromHistory, getPreConfirmationPropertiesFromQuote, getHashPresenceProperties, getBroadcastFailureProperties, getFailurePropertiesFromHistory, promoteFailurePhase, } from './utils/metrics.js';
19
19
  import { getSelectedChainId } from './utils/network.js';
20
20
  import { getSwapOperationCompletedTraceParams, getTraceParams, } from './utils/trace.js';
21
- import { getTransactionMetaById, getTransactions, checkIsDelegatedAccount, isApprovalTx, isCrossChainTx, updateTransactionsInBatch, hasNestedSwapTransactions, } from './utils/transaction.js';
21
+ import { getTransactionMetaById, getTransactions, checkIsDelegatedAccount, isCrossChainTx, updateTransactionsInBatch, hasNestedSwapTransactions, } from './utils/transaction.js';
22
22
  const metadata = {
23
23
  // We want to persist the bridge status state so that we can show the proper data for the Activity list
24
24
  // basically match the behavior of TransactionController
@@ -145,9 +145,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
145
145
  historyKey: entryToUse?.[0],
146
146
  historyItem: entryToUse?.[1],
147
147
  txMeta: transactionMeta,
148
- // Means that the triggering event was for an approval tx
149
- isApprovalTxMeta: entryToUse?.[1]?.approvalTxId === transactionMeta.id ||
150
- Boolean(transactionMeta.type && isApprovalTx(transactionMeta.type)),
148
+ isApprovalTxMeta: entryToUse?.[1]?.approvalTxId === transactionMeta.id,
151
149
  };
152
150
  });
153
151
  // Seed any missing quote-status entries from persisted history before
@@ -189,45 +187,36 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
189
187
  #isIntentHistoryItem = (historyKey) => historyKey
190
188
  ? Boolean(this.state.txHistory[historyKey]?.quote.intent)
191
189
  : false;
192
- #onTransactionFailed = ({ txMeta, historyKey, isApprovalTxMeta, eventProperties, }) => {
193
- const isHistoryItemAlreadyFailed = historyKey &&
194
- this.state.txHistory[historyKey]?.status.status === StatusTypes.FAILED;
195
- if (isHistoryItemAlreadyFailed) {
196
- return;
197
- }
190
+ #onTransactionFailed = ({ txMeta, historyKey, isApprovalTxMeta, }) => {
191
+ const isHistoryItemAlreadyFailed = historyKey
192
+ ? this.state.txHistory[historyKey]?.status.status === StatusTypes.FAILED
193
+ : false;
194
+ const isIntent = this.#isIntentHistoryItem(historyKey);
198
195
  this.#updateHistoryItem({
199
196
  historyKey,
200
197
  status: StatusTypes.FAILED,
201
- // Only update txHash if it's not an approval tx failure
202
- txHash: isApprovalTxMeta ? undefined : txMeta?.hash,
198
+ txHash: isApprovalTxMeta ? undefined : txMeta.hash,
203
199
  completionTime: Date.now(),
204
200
  });
205
- if (txMeta?.status === TransactionStatus.rejected) {
201
+ if (txMeta.status === TransactionStatus.rejected) {
206
202
  return;
207
203
  }
208
- // Pre-confirmation failues
209
- if (eventProperties || !txMeta) {
210
- this.#trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.Failed, historyKey, eventProperties);
211
- return;
212
- }
213
- this.#trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.Failed, historyKey, getEVMTxPropertiesFromTransactionMeta(txMeta));
214
- const isIntent = this.#isIntentHistoryItem(historyKey);
215
- if (isIntent) {
204
+ if (isHistoryItemAlreadyFailed) {
216
205
  return;
217
206
  }
218
- this.#traceSwapOperationCompleted(historyKey, 'error', 'source').catch(() => undefined);
219
- // Ignore approval failures, subsequent trade failures will be reported.
220
- if (isApprovalTxMeta) {
221
- return;
207
+ if (!isIntent) {
208
+ this.#traceSwapOperationCompleted(historyKey, 'error', 'source').catch(() => undefined);
222
209
  }
223
210
  // Report finalized failure for swap/bridge transactions.
224
211
  // Note: TransactionStatus.rejected means the user cancelled signing, so the tx was never broadcast.
225
212
  // `hasNestedSwapTransactions` also covers batch/7702 swaps whose type may
226
213
  // still read as `batch` rather than `swap`.
227
- if ((txMeta.type && isCrossChainTx(txMeta.type)) ||
228
- hasNestedSwapTransactions(txMeta)) {
214
+ if (!isIntent &&
215
+ ((txMeta.type && isCrossChainTx(txMeta.type)) ||
216
+ hasNestedSwapTransactions(txMeta))) {
229
217
  this.#quoteStatusManager.reportFinalised(txMeta.id, false, txMeta.chainId, txMeta.hash);
230
218
  }
219
+ this.#trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.Failed, historyKey, getEVMTxPropertiesFromTransactionMeta(txMeta));
231
220
  };
232
221
  // Only EVM txs
233
222
  #onTransactionConfirmed = ({ txMeta, historyKey, isApprovalTxMeta, }) => {
@@ -531,11 +520,10 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
531
520
  * @param txMeta - The transaction meta from the successful submission
532
521
  * @param txMeta.id - The transaction meta id to use as the new key
533
522
  * @param txMeta.hash - The transaction hash to set on the history item
534
- * @param historyItemOverrides - The history item overrides to set on the history item
535
523
  */
536
- #rekeyHistoryItem = (oldKey, newKey, txMeta, historyItemOverrides) => {
524
+ #rekeyHistoryItem = (oldKey, newKey, txMeta) => {
537
525
  this.update((state) => {
538
- rekeyHistoryItemInState(state, oldKey, newKey, txMeta, historyItemOverrides);
526
+ rekeyHistoryItemInState(state, oldKey, newKey, txMeta);
539
527
  });
540
528
  };
541
529
  #startPollingForTxId = (txId) => {
@@ -837,19 +825,17 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
837
825
  */
838
826
  #executeSubmitStrategy = async (params, sharedHistoryItemProperties) => {
839
827
  let tradeTxMeta;
840
- let latestHistoryItemKey;
841
828
  const steps = executeSubmitStrategy(params);
842
829
  // Each submission strategy determines when to execute step, which means these actions can happen in any order
843
- try {
844
- for await (const { type, payload } of steps) {
830
+ for await (const { type, payload } of steps) {
831
+ try {
845
832
  switch (type) {
846
833
  case SubmitStep.RekeyHistoryItem:
847
- this.#rekeyHistoryItem(payload.oldHistoryKey, payload.newHistoryKey, payload.tradeMeta, payload.historyItemOverrides);
848
- latestHistoryItemKey = payload.newHistoryKey;
834
+ this.#rekeyHistoryItem(payload.oldHistoryKey, payload.newHistoryKey, payload.tradeMeta);
849
835
  // Report SUBMITTED as soon as the trade hash is known at submission
850
836
  // time, instead of waiting for the delayed transactionStatusUpdated
851
837
  // (submitted) event.
852
- if (payload.tradeMeta?.hash && payload.tradeMeta.id) {
838
+ if (payload.tradeMeta.hash) {
853
839
  this.#reportSubmittedOnce(payload.newHistoryKey, payload.tradeMeta.hash, payload.tradeMeta.id);
854
840
  }
855
841
  break;
@@ -873,7 +859,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
873
859
  payload.quoteResponse.quote.slippage ??
874
860
  0,
875
861
  });
876
- latestHistoryItemKey = payload.historyKey;
877
862
  this.#reportSubmittedForNonEvmTx(payload.historyKey, payload.bridgeTxMeta);
878
863
  break;
879
864
  case SubmitStep.StartPolling:
@@ -892,16 +877,11 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
892
877
  /* c8 ignore end */
893
878
  }
894
879
  }
880
+ catch (error) {
881
+ console.error('Failed to add to bridge history and start polling.', error);
882
+ }
895
883
  }
896
- catch (error) {
897
- console.error('Failed to persist transaction to history and start polling.', error);
898
- return {
899
- txMeta: tradeTxMeta,
900
- error: error,
901
- txHistoryKey: latestHistoryItemKey,
902
- };
903
- }
904
- return { txMeta: tradeTxMeta, txHistoryKey: latestHistoryItemKey };
884
+ return tradeTxMeta;
905
885
  };
906
886
  /**
907
887
  * Submits a cross-chain swap transaction
@@ -955,12 +935,10 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
955
935
  */
956
936
  const requireApproval = this.#clientId === BridgeClientId.MOBILE && accountHardwareType !== null;
957
937
  const isBridgeTx = isCrossChain(quote.srcChainId, quote.destChainId);
958
- // Appended to batch-sell events
959
938
  const batchId = quoteResponses.some(({ featureId: quoteFeatureId }) => quoteFeatureId === FeatureId.BATCH_SELL)
960
939
  ? generateBatchId()
961
940
  : undefined;
962
941
  const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, isStxEnabled, accountHardwareType, location, abTests, activeAbTests, tokenSecurityTypeDestination, batchSellTrades, batchId, quotesReceivedContext);
963
- let historyKey;
964
942
  try {
965
943
  // Emit Submitted event after submit button is clicked
966
944
  this.#trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.Submitted, undefined, {
@@ -995,38 +973,22 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
995
973
  traceFn: this.#trace,
996
974
  batchId,
997
975
  };
998
- return await this.#trace(getTraceParams(quoteResponse, isStxEnabled), async () => {
999
- const res = await this.#executeSubmitStrategy(strategyParams, {
1000
- startTime,
1001
- location,
1002
- abTests,
1003
- activeAbTests,
1004
- tokenSecurityTypeDestination,
1005
- inputPrimaryDenomination,
1006
- customSlippage: quotesReceivedContext?.custom_slippage,
1007
- slippagePercentage: quotesReceivedContext?.slippage_limit,
1008
- });
1009
- historyKey = res.txHistoryKey;
1010
- if (res.txMeta) {
1011
- return res.txMeta;
1012
- }
1013
- if (res.error) {
1014
- throw res.error;
1015
- }
1016
- throw new Error('Failed to submit transaction');
1017
- });
976
+ return await this.#trace(getTraceParams(quoteResponse, isStxEnabled), async () => await this.#executeSubmitStrategy(strategyParams, {
977
+ startTime,
978
+ location,
979
+ abTests,
980
+ activeAbTests,
981
+ tokenSecurityTypeDestination,
982
+ inputPrimaryDenomination,
983
+ customSlippage: quotesReceivedContext?.custom_slippage,
984
+ slippagePercentage: quotesReceivedContext?.slippage_limit,
985
+ }));
1018
986
  }
1019
987
  catch (error) {
1020
- this.#onTransactionFailed({
1021
- isApprovalTxMeta: false,
1022
- txMeta: undefined,
1023
- // Include latest history key to mark it Failed
1024
- historyKey,
1025
- eventProperties: {
1026
- error_message: error?.message,
1027
- ...preConfirmationProperties,
1028
- ...getBroadcastFailureProperties(error),
1029
- },
988
+ this.#trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.Failed, undefined, {
989
+ error_message: error?.message,
990
+ ...preConfirmationProperties,
991
+ ...getBroadcastFailureProperties(error),
1030
992
  });
1031
993
  throw error;
1032
994
  }