@metamask/bridge-status-controller 70.0.0 → 70.0.1

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 (72) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/dist/bridge-status-controller.cjs +48 -172
  3. package/dist/bridge-status-controller.cjs.map +1 -1
  4. package/dist/bridge-status-controller.d.cts +2 -1
  5. package/dist/bridge-status-controller.d.cts.map +1 -1
  6. package/dist/bridge-status-controller.d.mts +2 -1
  7. package/dist/bridge-status-controller.d.mts.map +1 -1
  8. package/dist/bridge-status-controller.intent.cjs +7 -19
  9. package/dist/bridge-status-controller.intent.cjs.map +1 -1
  10. package/dist/bridge-status-controller.intent.d.cts +2 -10
  11. package/dist/bridge-status-controller.intent.d.cts.map +1 -1
  12. package/dist/bridge-status-controller.intent.d.mts +2 -10
  13. package/dist/bridge-status-controller.intent.d.mts.map +1 -1
  14. package/dist/bridge-status-controller.intent.mjs +7 -19
  15. package/dist/bridge-status-controller.intent.mjs.map +1 -1
  16. package/dist/bridge-status-controller.mjs +51 -175
  17. package/dist/bridge-status-controller.mjs.map +1 -1
  18. package/dist/types.cjs.map +1 -1
  19. package/dist/types.d.cts +10 -4
  20. package/dist/types.d.cts.map +1 -1
  21. package/dist/types.d.mts +10 -4
  22. package/dist/types.d.mts.map +1 -1
  23. package/dist/types.mjs.map +1 -1
  24. package/dist/utils/bridge-status.cjs +17 -1
  25. package/dist/utils/bridge-status.cjs.map +1 -1
  26. package/dist/utils/bridge-status.d.cts +8 -2
  27. package/dist/utils/bridge-status.d.cts.map +1 -1
  28. package/dist/utils/bridge-status.d.mts +8 -2
  29. package/dist/utils/bridge-status.d.mts.map +1 -1
  30. package/dist/utils/bridge-status.mjs +15 -0
  31. package/dist/utils/bridge-status.mjs.map +1 -1
  32. package/dist/utils/gas.cjs +1 -58
  33. package/dist/utils/gas.cjs.map +1 -1
  34. package/dist/utils/gas.d.cts +3 -26
  35. package/dist/utils/gas.d.cts.map +1 -1
  36. package/dist/utils/gas.d.mts +3 -26
  37. package/dist/utils/gas.d.mts.map +1 -1
  38. package/dist/utils/gas.mjs +0 -55
  39. package/dist/utils/gas.mjs.map +1 -1
  40. package/dist/utils/history.cjs +9 -8
  41. package/dist/utils/history.cjs.map +1 -1
  42. package/dist/utils/history.d.cts +3 -2
  43. package/dist/utils/history.d.cts.map +1 -1
  44. package/dist/utils/history.d.mts +3 -2
  45. package/dist/utils/history.d.mts.map +1 -1
  46. package/dist/utils/history.mjs +9 -8
  47. package/dist/utils/history.mjs.map +1 -1
  48. package/dist/utils/intent-api.cjs +26 -26
  49. package/dist/utils/intent-api.cjs.map +1 -1
  50. package/dist/utils/intent-api.d.cts +7 -2
  51. package/dist/utils/intent-api.d.cts.map +1 -1
  52. package/dist/utils/intent-api.d.mts +7 -2
  53. package/dist/utils/intent-api.d.mts.map +1 -1
  54. package/dist/utils/intent-api.mjs +24 -25
  55. package/dist/utils/intent-api.mjs.map +1 -1
  56. package/dist/utils/snaps.cjs +5 -5
  57. package/dist/utils/snaps.cjs.map +1 -1
  58. package/dist/utils/snaps.d.cts +3 -17
  59. package/dist/utils/snaps.d.cts.map +1 -1
  60. package/dist/utils/snaps.d.mts +3 -17
  61. package/dist/utils/snaps.d.mts.map +1 -1
  62. package/dist/utils/snaps.mjs +6 -6
  63. package/dist/utils/snaps.mjs.map +1 -1
  64. package/dist/utils/transaction.cjs +250 -24
  65. package/dist/utils/transaction.cjs.map +1 -1
  66. package/dist/utils/transaction.d.cts +91 -169
  67. package/dist/utils/transaction.d.cts.map +1 -1
  68. package/dist/utils/transaction.d.mts +91 -169
  69. package/dist/utils/transaction.d.mts.map +1 -1
  70. package/dist/utils/transaction.mjs +234 -19
  71. package/dist/utils/transaction.mjs.map +1 -1
  72. package/package.json +3 -3
package/dist/types.d.mts CHANGED
@@ -6,7 +6,6 @@ import type { KeyringControllerSignTypedMessageAction } from "@metamask/keyring-
6
6
  import type { Messenger } from "@metamask/messenger";
7
7
  import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction } from "@metamask/network-controller";
8
8
  import type { AuthenticationControllerGetBearerTokenAction } from "@metamask/profile-sync-controller/auth";
9
- import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
10
9
  import type { HandleSnapRequest } from "@metamask/snaps-controllers";
11
10
  import type { Infer } from "@metamask/superstruct";
12
11
  import type { TransactionControllerAddTransactionAction, TransactionControllerEstimateGasFeeAction, TransactionControllerGetStateAction, TransactionControllerIsAtomicBatchSupportedAction, TransactionControllerTransactionConfirmedEvent, TransactionControllerTransactionFailedEvent, TransactionControllerUpdateTransactionAction, TransactionMeta } from "@metamask/transaction-controller";
@@ -65,6 +64,9 @@ export type RefuelStatusResponse = object & StatusResponse;
65
64
  export type BridgeHistoryItem = {
66
65
  txMetaId?: string;
67
66
  actionId?: string;
67
+ /**
68
+ * @deprecated the txMeta or orderUid should be used instead
69
+ */
68
70
  originalTransactionId?: string;
69
71
  batchId?: string;
70
72
  quote: Quote;
@@ -166,8 +168,12 @@ export type QuoteMetadataSerialized = {
166
168
  cost: Omit<TokenAmountValuesSerialized, 'amount'>;
167
169
  };
168
170
  export type StartPollingForBridgeTxStatusArgs = {
169
- bridgeTxMeta?: TransactionMeta;
170
- statusRequest: StatusRequest;
171
+ bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;
172
+ actionId?: string;
173
+ /**
174
+ * @deprecated the txMeta or orderUid should be used instead
175
+ */
176
+ originalTransactionId?: string;
171
177
  quoteResponse: QuoteResponse & QuoteMetadata;
172
178
  startTime?: BridgeHistoryItem['startTime'];
173
179
  slippagePercentage: BridgeHistoryItem['slippagePercentage'];
@@ -218,7 +224,7 @@ export type BridgeStatusControllerEvents = BridgeStatusControllerStateChangeEven
218
224
  /**
219
225
  * The external actions available to the BridgeStatusController.
220
226
  */
221
- type AllowedActions = NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | HandleSnapRequest | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction | TransactionControllerAddTransactionAction | TransactionControllerEstimateGasFeeAction | TransactionControllerIsAtomicBatchSupportedAction | BridgeControllerAction<BridgeBackgroundAction.TRACK_METAMETRICS_EVENT> | BridgeControllerAction<BridgeBackgroundAction.STOP_POLLING_FOR_QUOTES> | GetGasFeeState | AccountsControllerGetAccountByAddressAction | RemoteFeatureFlagControllerGetStateAction | AuthenticationControllerGetBearerTokenAction | KeyringControllerSignTypedMessageAction;
227
+ type AllowedActions = NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | HandleSnapRequest | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction | TransactionControllerAddTransactionAction | TransactionControllerEstimateGasFeeAction | TransactionControllerIsAtomicBatchSupportedAction | BridgeControllerAction<BridgeBackgroundAction.TRACK_METAMETRICS_EVENT> | BridgeControllerAction<BridgeBackgroundAction.STOP_POLLING_FOR_QUOTES> | GetGasFeeState | AccountsControllerGetAccountByAddressAction | AuthenticationControllerGetBearerTokenAction | KeyringControllerSignTypedMessageAction;
222
228
  /**
223
229
  * The external events available to the BridgeStatusController.
224
230
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2CAA2C,EAAE,sCAAsC;AACjG,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,OAAO,EACP,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,2BAA2B,EAC5B,oCAAoC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,qCAAqC;AACnE,OAAO,KAAK,EAAE,uCAAuC,EAAE,qCAAqC;AAC5F,OAAO,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Y,QAaX;AAbD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,2BAAe,CAAA;IACf,uCAA2B,CAAA;IAC3B,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,mCAAuB,CAAA;IACvB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,CAAC,EAbW,QAAQ,KAAR,QAAQ,QAanB;AA8DD,MAAM,CAAN,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC5B,qFAA+D,CAAA;IAC/D,2DAAqC,CAAA;IACrC,2CAAqB,CAAA;IACrB,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;IACrB,mDAA6B,CAAA;IAC7B,yFAAmE,CAAA;IACnE,uFAAiE,CAAA;AACnE,CAAC,EATW,kBAAkB,KAAlB,kBAAkB,QAS7B","sourcesContent":["import type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type {\n BridgeBackgroundAction,\n BridgeControllerAction,\n ChainId,\n FeatureId,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n MetaMetricsSwapsEventSource,\n} from '@metamask/bridge-controller';\nimport type { GetGasFeeState } from '@metamask/gas-fee-controller';\nimport type { KeyringControllerSignTypedMessageAction } from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionConfirmedEvent,\n TransactionControllerTransactionFailedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusController } from './bridge-status-controller';\nimport { BRIDGE_STATUS_CONTROLLER_NAME } from './constants';\nimport type { StatusResponseSchema } from './utils/validators';\n\n// All fields need to be types not interfaces, same with their children fields\n// o/w you get a type error\n\nexport enum BridgeClientId {\n EXTENSION = 'extension',\n MOBILE = 'mobile',\n}\n\nexport type FetchFunction = (\n input: RequestInfo | URL,\n init?: RequestInit,\n) => Promise<unknown>;\n\n/**\n * These fields are specific to Solana transactions and can likely be infered from TransactionMeta\n *\n * @deprecated these should be removed eventually\n */\nexport type SolanaTransactionMeta = {\n isSolana: boolean;\n isBridgeTx: boolean;\n};\n\nexport type StatusRequest = {\n bridgeId: string; // lifi, socket, squid\n srcTxHash?: string; // lifi, socket, squid, might be undefined for STX\n bridge: string; // lifi, socket, squid\n srcChainId: ChainId; // lifi, socket, squid\n destChainId: ChainId; // lifi, socket, squid\n quote?: Quote; // squid\n refuel?: boolean; // lifi\n};\n\nexport type StatusRequestDto = Omit<\n StatusRequest,\n 'quote' | 'srcChainId' | 'destChainId' | 'refuel'\n> & {\n srcChainId: string; // lifi, socket, squid\n destChainId: string; // lifi, socket, squid\n requestId?: string;\n refuel?: string; // lifi\n};\n\nexport type StatusRequestWithSrcTxHash = StatusRequest & {\n srcTxHash: string;\n};\n\nexport enum BridgeId {\n HOP = 'hop',\n CELER = 'celer',\n CELERCIRCLE = 'celercircle',\n CONNEXT = 'connext',\n POLYGON = 'polygon',\n AVALANCHE = 'avalanche',\n MULTICHAIN = 'multichain',\n AXELAR = 'axelar',\n ACROSS = 'across',\n STARGATE = 'stargate',\n RELAY = 'relay',\n MAYAN = 'mayan',\n}\n\nexport type StatusResponse = Infer<typeof StatusResponseSchema>;\n\nexport type RefuelStatusResponse = object & StatusResponse;\n\nexport type BridgeHistoryItem = {\n txMetaId?: string; // Optional: not available pre-submission or on sync failure\n actionId?: string; // Only for non-batch EVM transactions\n originalTransactionId?: string; // Keep original transaction ID for intent transactions\n batchId?: string;\n quote: Quote;\n status: StatusResponse;\n startTime?: number; // timestamp in ms\n estimatedProcessingTimeInSeconds: number;\n slippagePercentage: number;\n completionTime?: number; // timestamp in ms\n pricingData?: {\n /**\n * The actual amount sent by user in non-atomic decimal form\n */\n amountSent: QuoteMetadata['sentAmount']['amount'];\n amountSentInUsd?: QuoteMetadata['sentAmount']['usd'];\n quotedGasInUsd?: QuoteMetadata['gasFee']['effective']['usd'];\n quotedGasAmount?: QuoteMetadata['gasFee']['effective']['amount'];\n quotedReturnInUsd?: QuoteMetadata['toTokenAmount']['usd'];\n quotedRefuelSrcAmountInUsd?: string;\n quotedRefuelDestAmountInUsd?: string;\n };\n initialDestAssetBalance?: string;\n targetContractAddress?: string;\n account: string;\n hasApprovalTx: boolean;\n approvalTxId?: string;\n featureId?: FeatureId;\n isStxEnabled?: boolean;\n /**\n * The location/entry point from which the user initiated the swap or bridge.\n * Used to attribute swaps to specific flows (e.g. Trending Explore).\n */\n location?: MetaMetricsSwapsEventSource;\n /**\n * Legacy A/B test metrics context (`ab_tests`) kept for backward compatibility.\n * Keys are test names, values are variant names (e.g. { token_details_layout: 'treatment' }).\n */\n abTests?: Record<string, string>;\n /**\n * New A/B test metrics context (`active_ab_tests`) that replaces `ab_tests`.\n * Kept separate so migration can run both payloads in parallel.\n * This field is an array of test objects.\n */\n activeAbTests?: { key: string; value: string }[];\n /**\n * Attempts tracking for exponential backoff on failed fetches.\n * We track the number of attempts and the last attempt time for each txMetaId that has failed at least once\n */\n attempts?: {\n counter: number;\n lastAttemptTime: number; // timestamp in ms\n };\n};\n\nexport enum BridgeStatusAction {\n StartPollingForBridgeTxStatus = 'StartPollingForBridgeTxStatus',\n WipeBridgeStatus = 'WipeBridgeStatus',\n GetState = 'GetState',\n ResetState = 'ResetState',\n SubmitTx = 'SubmitTx',\n SubmitIntent = 'SubmitIntent',\n RestartPollingForFailedAttempts = 'RestartPollingForFailedAttempts',\n GetBridgeHistoryItemByTxMetaId = 'GetBridgeHistoryItemByTxMetaId',\n}\n\nexport type TokenAmountValuesSerialized = {\n amount: string;\n valueInCurrency: string | null;\n usd: string | null;\n};\n\nexport type QuoteMetadataSerialized = {\n gasFee: TokenAmountValuesSerialized;\n /**\n * The total network fee for the bridge transaction\n * estimatedGasFees + relayerFees\n */\n totalNetworkFee: TokenAmountValuesSerialized;\n /**\n * The total max network fee for the bridge transaction\n * maxGasFees + relayerFees\n */\n totalMaxNetworkFee: TokenAmountValuesSerialized;\n toTokenAmount: TokenAmountValuesSerialized;\n /**\n * The adjusted return for the bridge transaction\n * destTokenAmount - totalNetworkFee\n */\n adjustedReturn: Omit<TokenAmountValuesSerialized, 'amount'>;\n /**\n * The actual amount sent by user in non-atomic decimal form\n * srcTokenAmount + metabridgeFee\n */\n sentAmount: TokenAmountValuesSerialized;\n swapRate: string; // destTokenAmount / sentAmount\n /**\n * The cost of the bridge transaction\n * sentAmount - adjustedReturn\n */\n cost: Omit<TokenAmountValuesSerialized, 'amount'>;\n};\n\nexport type StartPollingForBridgeTxStatusArgs = {\n bridgeTxMeta?: TransactionMeta;\n statusRequest: StatusRequest;\n quoteResponse: QuoteResponse & QuoteMetadata;\n startTime?: BridgeHistoryItem['startTime'];\n slippagePercentage: BridgeHistoryItem['slippagePercentage'];\n initialDestAssetBalance?: BridgeHistoryItem['initialDestAssetBalance'];\n targetContractAddress?: BridgeHistoryItem['targetContractAddress'];\n approvalTxId?: BridgeHistoryItem['approvalTxId'];\n isStxEnabled?: BridgeHistoryItem['isStxEnabled'];\n location?: BridgeHistoryItem['location'];\n // Legacy field for `ab_tests` metrics payload.\n abTests?: BridgeHistoryItem['abTests'];\n // New field for `active_ab_tests` metrics payload.\n activeAbTests?: BridgeHistoryItem['activeAbTests'];\n accountAddress: string;\n};\n\n/**\n * Chrome: The BigNumber values are automatically serialized to strings when sent to the background\n * Firefox: The BigNumber values are not serialized to strings when sent to the background,\n * so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action\n */\nexport type StartPollingForBridgeTxStatusArgsSerialized = Omit<\n StartPollingForBridgeTxStatusArgs,\n 'quoteResponse'\n> & {\n quoteResponse: QuoteResponse & Partial<QuoteMetadata>;\n};\n\nexport type SourceChainTxMetaId = string;\n\nexport type BridgeStatusControllerState = {\n txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;\n};\n\n// Actions\ntype BridgeStatusControllerAction<\n FunctionName extends keyof BridgeStatusController,\n> = {\n type: `${typeof BRIDGE_STATUS_CONTROLLER_NAME}:${FunctionName}`;\n handler: BridgeStatusController[FunctionName];\n};\n\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\n// Maps to BridgeController function names\nexport type BridgeStatusControllerStartPollingForBridgeTxStatusAction =\n BridgeStatusControllerAction<'startPollingForBridgeTxStatus'>;\n\nexport type BridgeStatusControllerWipeBridgeStatusAction =\n BridgeStatusControllerAction<'wipeBridgeStatus'>;\n\nexport type BridgeStatusControllerResetStateAction =\n BridgeStatusControllerAction<'resetState'>;\n\nexport type BridgeStatusControllerSubmitTxAction =\n BridgeStatusControllerAction<'submitTx'>;\n\nexport type BridgeStatusControllerSubmitIntentAction =\n BridgeStatusControllerAction<'submitIntent'>;\n\nexport type BridgeStatusControllerRestartPollingForFailedAttemptsAction =\n BridgeStatusControllerAction<'restartPollingForFailedAttempts'>;\n\nexport type BridgeStatusControllerGetBridgeHistoryItemByTxMetaIdAction =\n BridgeStatusControllerAction<'getBridgeHistoryItemByTxMetaId'>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerStartPollingForBridgeTxStatusAction\n | BridgeStatusControllerWipeBridgeStatusAction\n | BridgeStatusControllerResetStateAction\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerSubmitTxAction\n | BridgeStatusControllerSubmitIntentAction\n | BridgeStatusControllerRestartPollingForFailedAttemptsAction\n | BridgeStatusControllerGetBridgeHistoryItemByTxMetaIdAction;\n\n// Events\nexport type BridgeStatusControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n/**\n * This event is published when the destination bridge transaction is completed\n * The payload is the asset received on the destination chain\n */\nexport type BridgeStatusControllerDestinationTransactionCompletedEvent = {\n type: 'BridgeStatusController:destinationTransactionCompleted';\n payload: [CaipAssetType];\n};\n\nexport type BridgeStatusControllerEvents =\n | BridgeStatusControllerStateChangeEvent\n | BridgeStatusControllerDestinationTransactionCompletedEvent;\n\n/**\n * The external actions available to the BridgeStatusController.\n */\ntype AllowedActions =\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction\n | HandleSnapRequest\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerAction<BridgeBackgroundAction.TRACK_METAMETRICS_EVENT>\n | BridgeControllerAction<BridgeBackgroundAction.STOP_POLLING_FOR_QUOTES>\n | GetGasFeeState\n | AccountsControllerGetAccountByAddressAction\n | RemoteFeatureFlagControllerGetStateAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents =\n | TransactionControllerTransactionFailedEvent\n | TransactionControllerTransactionConfirmedEvent;\n\n/**\n * The messenger for the BridgeStatusController.\n */\nexport type BridgeStatusControllerMessenger = Messenger<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerActions | AllowedActions,\n BridgeStatusControllerEvents | AllowedEvents\n>;\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAE,6BAA6B,EAAE,wBAAoB;AAG5D,8EAA8E;AAC9E,2BAA2B;AAE3B,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAyCD,MAAM,CAAN,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,2BAAe,CAAA;IACf,uCAA2B,CAAA;IAC3B,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,mCAAuB,CAAA;IACvB,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,iCAAqB,CAAA;IACrB,2BAAe,CAAA;IACf,2BAAe,CAAA;AACjB,CAAC,EAbW,QAAQ,KAAR,QAAQ,QAanB;AAiED,MAAM,CAAN,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC5B,qFAA+D,CAAA;IAC/D,2DAAqC,CAAA;IACrC,2CAAqB,CAAA;IACrB,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;IACrB,mDAA6B,CAAA;IAC7B,yFAAmE,CAAA;IACnE,uFAAiE,CAAA;AACnE,CAAC,EATW,kBAAkB,KAAlB,kBAAkB,QAS7B","sourcesContent":["import type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type {\n BridgeBackgroundAction,\n BridgeControllerAction,\n ChainId,\n FeatureId,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n MetaMetricsSwapsEventSource,\n} from '@metamask/bridge-controller';\nimport type { GetGasFeeState } from '@metamask/gas-fee-controller';\nimport type { KeyringControllerSignTypedMessageAction } from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetStateAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionConfirmedEvent,\n TransactionControllerTransactionFailedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusController } from './bridge-status-controller';\nimport { BRIDGE_STATUS_CONTROLLER_NAME } from './constants';\nimport type { StatusResponseSchema } from './utils/validators';\n\n// All fields need to be types not interfaces, same with their children fields\n// o/w you get a type error\n\nexport enum BridgeClientId {\n EXTENSION = 'extension',\n MOBILE = 'mobile',\n}\n\nexport type FetchFunction = (\n input: RequestInfo | URL,\n init?: RequestInit,\n) => Promise<unknown>;\n\n/**\n * These fields are specific to Solana transactions and can likely be infered from TransactionMeta\n *\n * @deprecated these should be removed eventually\n */\nexport type SolanaTransactionMeta = {\n isSolana: boolean;\n isBridgeTx: boolean;\n};\n\nexport type StatusRequest = {\n bridgeId: string; // lifi, socket, squid\n srcTxHash?: string; // lifi, socket, squid, might be undefined for STX\n bridge: string; // lifi, socket, squid\n srcChainId: ChainId; // lifi, socket, squid\n destChainId: ChainId; // lifi, socket, squid\n quote?: Quote; // squid\n refuel?: boolean; // lifi\n};\n\nexport type StatusRequestDto = Omit<\n StatusRequest,\n 'quote' | 'srcChainId' | 'destChainId' | 'refuel'\n> & {\n srcChainId: string; // lifi, socket, squid\n destChainId: string; // lifi, socket, squid\n requestId?: string;\n refuel?: string; // lifi\n};\n\nexport type StatusRequestWithSrcTxHash = StatusRequest & {\n srcTxHash: string;\n};\n\nexport enum BridgeId {\n HOP = 'hop',\n CELER = 'celer',\n CELERCIRCLE = 'celercircle',\n CONNEXT = 'connext',\n POLYGON = 'polygon',\n AVALANCHE = 'avalanche',\n MULTICHAIN = 'multichain',\n AXELAR = 'axelar',\n ACROSS = 'across',\n STARGATE = 'stargate',\n RELAY = 'relay',\n MAYAN = 'mayan',\n}\n\nexport type StatusResponse = Infer<typeof StatusResponseSchema>;\n\nexport type RefuelStatusResponse = object & StatusResponse;\n\nexport type BridgeHistoryItem = {\n txMetaId?: string; // Optional: not available pre-submission or on sync failure\n actionId?: string; // Only for non-batch EVM transactions\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string; // Keep original transaction ID for intent transactions\n batchId?: string;\n quote: Quote;\n status: StatusResponse;\n startTime?: number; // timestamp in ms\n estimatedProcessingTimeInSeconds: number;\n slippagePercentage: number;\n completionTime?: number; // timestamp in ms\n pricingData?: {\n /**\n * The actual amount sent by user in non-atomic decimal form\n */\n amountSent: QuoteMetadata['sentAmount']['amount'];\n amountSentInUsd?: QuoteMetadata['sentAmount']['usd'];\n quotedGasInUsd?: QuoteMetadata['gasFee']['effective']['usd'];\n quotedGasAmount?: QuoteMetadata['gasFee']['effective']['amount'];\n quotedReturnInUsd?: QuoteMetadata['toTokenAmount']['usd'];\n quotedRefuelSrcAmountInUsd?: string;\n quotedRefuelDestAmountInUsd?: string;\n };\n initialDestAssetBalance?: string;\n targetContractAddress?: string;\n account: string;\n hasApprovalTx: boolean;\n approvalTxId?: string;\n featureId?: FeatureId;\n isStxEnabled?: boolean;\n /**\n * The location/entry point from which the user initiated the swap or bridge.\n * Used to attribute swaps to specific flows (e.g. Trending Explore).\n */\n location?: MetaMetricsSwapsEventSource;\n /**\n * Legacy A/B test metrics context (`ab_tests`) kept for backward compatibility.\n * Keys are test names, values are variant names (e.g. { token_details_layout: 'treatment' }).\n */\n abTests?: Record<string, string>;\n /**\n * New A/B test metrics context (`active_ab_tests`) that replaces `ab_tests`.\n * Kept separate so migration can run both payloads in parallel.\n * This field is an array of test objects.\n */\n activeAbTests?: { key: string; value: string }[];\n /**\n * Attempts tracking for exponential backoff on failed fetches.\n * We track the number of attempts and the last attempt time for each txMetaId that has failed at least once\n */\n attempts?: {\n counter: number;\n lastAttemptTime: number; // timestamp in ms\n };\n};\n\nexport enum BridgeStatusAction {\n StartPollingForBridgeTxStatus = 'StartPollingForBridgeTxStatus',\n WipeBridgeStatus = 'WipeBridgeStatus',\n GetState = 'GetState',\n ResetState = 'ResetState',\n SubmitTx = 'SubmitTx',\n SubmitIntent = 'SubmitIntent',\n RestartPollingForFailedAttempts = 'RestartPollingForFailedAttempts',\n GetBridgeHistoryItemByTxMetaId = 'GetBridgeHistoryItemByTxMetaId',\n}\n\nexport type TokenAmountValuesSerialized = {\n amount: string;\n valueInCurrency: string | null;\n usd: string | null;\n};\n\nexport type QuoteMetadataSerialized = {\n gasFee: TokenAmountValuesSerialized;\n /**\n * The total network fee for the bridge transaction\n * estimatedGasFees + relayerFees\n */\n totalNetworkFee: TokenAmountValuesSerialized;\n /**\n * The total max network fee for the bridge transaction\n * maxGasFees + relayerFees\n */\n totalMaxNetworkFee: TokenAmountValuesSerialized;\n toTokenAmount: TokenAmountValuesSerialized;\n /**\n * The adjusted return for the bridge transaction\n * destTokenAmount - totalNetworkFee\n */\n adjustedReturn: Omit<TokenAmountValuesSerialized, 'amount'>;\n /**\n * The actual amount sent by user in non-atomic decimal form\n * srcTokenAmount + metabridgeFee\n */\n sentAmount: TokenAmountValuesSerialized;\n swapRate: string; // destTokenAmount / sentAmount\n /**\n * The cost of the bridge transaction\n * sentAmount - adjustedReturn\n */\n cost: Omit<TokenAmountValuesSerialized, 'amount'>;\n};\n\nexport type StartPollingForBridgeTxStatusArgs = {\n bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;\n actionId?: string;\n /**\n * @deprecated the txMeta or orderUid should be used instead\n */\n originalTransactionId?: string;\n quoteResponse: QuoteResponse & QuoteMetadata;\n startTime?: BridgeHistoryItem['startTime'];\n slippagePercentage: BridgeHistoryItem['slippagePercentage'];\n initialDestAssetBalance?: BridgeHistoryItem['initialDestAssetBalance'];\n targetContractAddress?: BridgeHistoryItem['targetContractAddress'];\n approvalTxId?: BridgeHistoryItem['approvalTxId'];\n isStxEnabled?: BridgeHistoryItem['isStxEnabled'];\n location?: BridgeHistoryItem['location'];\n // Legacy field for `ab_tests` metrics payload.\n abTests?: BridgeHistoryItem['abTests'];\n // New field for `active_ab_tests` metrics payload.\n activeAbTests?: BridgeHistoryItem['activeAbTests'];\n accountAddress: string;\n};\n\n/**\n * Chrome: The BigNumber values are automatically serialized to strings when sent to the background\n * Firefox: The BigNumber values are not serialized to strings when sent to the background,\n * so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action\n */\nexport type StartPollingForBridgeTxStatusArgsSerialized = Omit<\n StartPollingForBridgeTxStatusArgs,\n 'quoteResponse'\n> & {\n quoteResponse: QuoteResponse & Partial<QuoteMetadata>;\n};\n\nexport type SourceChainTxMetaId = string;\n\nexport type BridgeStatusControllerState = {\n txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;\n};\n\n// Actions\ntype BridgeStatusControllerAction<\n FunctionName extends keyof BridgeStatusController,\n> = {\n type: `${typeof BRIDGE_STATUS_CONTROLLER_NAME}:${FunctionName}`;\n handler: BridgeStatusController[FunctionName];\n};\n\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\n// Maps to BridgeController function names\nexport type BridgeStatusControllerStartPollingForBridgeTxStatusAction =\n BridgeStatusControllerAction<'startPollingForBridgeTxStatus'>;\n\nexport type BridgeStatusControllerWipeBridgeStatusAction =\n BridgeStatusControllerAction<'wipeBridgeStatus'>;\n\nexport type BridgeStatusControllerResetStateAction =\n BridgeStatusControllerAction<'resetState'>;\n\nexport type BridgeStatusControllerSubmitTxAction =\n BridgeStatusControllerAction<'submitTx'>;\n\nexport type BridgeStatusControllerSubmitIntentAction =\n BridgeStatusControllerAction<'submitIntent'>;\n\nexport type BridgeStatusControllerRestartPollingForFailedAttemptsAction =\n BridgeStatusControllerAction<'restartPollingForFailedAttempts'>;\n\nexport type BridgeStatusControllerGetBridgeHistoryItemByTxMetaIdAction =\n BridgeStatusControllerAction<'getBridgeHistoryItemByTxMetaId'>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerStartPollingForBridgeTxStatusAction\n | BridgeStatusControllerWipeBridgeStatusAction\n | BridgeStatusControllerResetStateAction\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerSubmitTxAction\n | BridgeStatusControllerSubmitIntentAction\n | BridgeStatusControllerRestartPollingForFailedAttemptsAction\n | BridgeStatusControllerGetBridgeHistoryItemByTxMetaIdAction;\n\n// Events\nexport type BridgeStatusControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n/**\n * This event is published when the destination bridge transaction is completed\n * The payload is the asset received on the destination chain\n */\nexport type BridgeStatusControllerDestinationTransactionCompletedEvent = {\n type: 'BridgeStatusController:destinationTransactionCompleted';\n payload: [CaipAssetType];\n};\n\nexport type BridgeStatusControllerEvents =\n | BridgeStatusControllerStateChangeEvent\n | BridgeStatusControllerDestinationTransactionCompletedEvent;\n\n/**\n * The external actions available to the BridgeStatusController.\n */\ntype AllowedActions =\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction\n | HandleSnapRequest\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerAction<BridgeBackgroundAction.TRACK_METAMETRICS_EVENT>\n | BridgeControllerAction<BridgeBackgroundAction.STOP_POLLING_FOR_QUOTES>\n | GetGasFeeState\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents =\n | TransactionControllerTransactionFailedEvent\n | TransactionControllerTransactionConfirmedEvent;\n\n/**\n * The messenger for the BridgeStatusController.\n */\nexport type BridgeStatusControllerMessenger = Messenger<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerActions | AllowedActions,\n BridgeStatusControllerEvents | AllowedEvents\n>;\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldSkipFetchDueToFetchFailures = exports.getStatusRequestWithSrcTxHash = exports.fetchBridgeTxStatus = exports.getStatusRequestDto = exports.getBridgeStatusUrl = void 0;
3
+ exports.getStatusRequestParams = exports.shouldSkipFetchDueToFetchFailures = exports.getStatusRequestWithSrcTxHash = exports.fetchBridgeTxStatus = exports.getStatusRequestDto = exports.getBridgeStatusUrl = void 0;
4
4
  const bridge_controller_1 = require("@metamask/bridge-controller");
5
5
  const superstruct_1 = require("@metamask/superstruct");
6
6
  const validators_1 = require("./validators.cjs");
@@ -78,4 +78,20 @@ const shouldSkipFetchDueToFetchFailures = (attempts) => {
78
78
  return false;
79
79
  };
80
80
  exports.shouldSkipFetchDueToFetchFailures = shouldSkipFetchDueToFetchFailures;
81
+ /**
82
+ * @deprecated Use getStatusRequestWithSrcTxHash instead
83
+ * @param quoteResponse - The quote response to get the status request parameters from
84
+ * @returns The status request parameters
85
+ */
86
+ const getStatusRequestParams = (quoteResponse) => {
87
+ return {
88
+ bridgeId: quoteResponse.quote.bridgeId,
89
+ bridge: quoteResponse.quote.bridges[0],
90
+ srcChainId: quoteResponse.quote.srcChainId,
91
+ destChainId: quoteResponse.quote.destChainId,
92
+ quote: quoteResponse.quote,
93
+ refuel: Boolean(quoteResponse.quote.refuel),
94
+ };
95
+ };
96
+ exports.getStatusRequestParams = getStatusRequestParams;
81
97
  //# sourceMappingURL=bridge-status.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-status.cjs","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":";;;AAAA,mEAA+D;AAE/D,uDAAoD;AAEpD,iDAA4D;AAC5D,gDAAmD;AAS5C,MAAM,kBAAkB,GAAG,CAAC,gBAAwB,EAAU,EAAE,CACrE,GAAG,gBAAgB,cAAc,CAAC;AADvB,QAAA,kBAAkB,sBACK;AAE7B,MAAM,mBAAmB,GAAG,CACjC,aAAyC,EACvB,EAAE;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,oBAAoB,EAAE,GAAG,aAAa,CAAC;IAEzD,MAAM,6BAA6B,GAAG,MAAM,CAAC,WAAW,CACtD,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QACzD,GAAG;QACH,KAAK,CAAC,QAAQ,EAAE;KACjB,CAAC,CAC+C,CAAC;IAEpD,MAAM,SAAS,GACb,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEzD,OAAO;QACL,GAAG,6BAA6B;QAChC,GAAG,SAAS;KACb,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,mBAAmB,uBAmB9B;AAEK,MAAM,mBAAmB,GAAG,KAAK,EACtC,aAAyC,EACzC,QAAgB,EAChB,GAAuB,EACvB,OAAsB,EACtB,gBAAwB,EAC2C,EAAE;IACrE,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,aAAa,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,IAAI,e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;QACL,QAAQ;QACR,SAAS;QACT,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QAClB,UAAU;QACV,WAAW;QACX,KAAK;QACL,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;KACxB,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,6BAA6B,iCAcxC;AAEK,MAAM,iCAAiC,GAAG,CAC/C,QAAwC,EAC/B,EAAE;IACX,8DAA8D;IAC9D,2EAA2E;IAC3E,IAAI,QAAQ,EAAE,CAAC;QACb,sEAAsE;QACtE,MAAM,YAAY,GAChB,+BAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;QAC1D,MAAM,oBAAoB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAEnE,IAAI,oBAAoB,GAAG,YAAY,EAAE,CAAC;YACxC,8CAA8C;YAC9C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAjBW,QAAA,iCAAiC,qCAiB5C","sourcesContent":["import { getClientHeaders } from '@metamask/bridge-controller';\nimport type { Quote } from '@metamask/bridge-controller';\nimport { StructError } from '@metamask/superstruct';\n\nimport { validateBridgeStatusResponse } from './validators';\nimport { REFRESH_INTERVAL_MS } from '../constants';\nimport type {\n StatusResponse,\n StatusRequestWithSrcTxHash,\n StatusRequestDto,\n FetchFunction,\n BridgeHistoryItem,\n} from '../types';\n\nexport const getBridgeStatusUrl = (bridgeApiBaseUrl: string): string =>\n `${bridgeApiBaseUrl}/getTxStatus`;\n\nexport const getStatusRequestDto = (\n statusRequest: StatusRequestWithSrcTxHash,\n): StatusRequestDto => {\n const { quote, ...statusRequestNoQuote } = statusRequest;\n\n const statusRequestNoQuoteFormatted = Object.fromEntries(\n Object.entries(statusRequestNoQuote).map(([key, value]) => [\n key,\n value.toString(),\n ]),\n ) as unknown as Omit<StatusRequestDto, 'requestId'>;\n\n const requestId: { requestId: string } | Record<string, never> =\n quote?.requestId ? { requestId: quote.requestId } : {};\n\n return {\n ...statusRequestNoQuoteFormatted,\n ...requestId,\n };\n};\n\nexport const fetchBridgeTxStatus = async (\n statusRequest: StatusRequestWithSrcTxHash,\n clientId: string,\n jwt: string | undefined,\n fetchFn: FetchFunction,\n bridgeApiBaseUrl: string,\n): Promise<{ status: StatusResponse; validationFailures: string[] }> => {\n const statusRequestDto = getStatusRequestDto(statusRequest);\n const params = new URLSearchParams(statusRequestDto);\n\n // Fetch\n const url = `${getBridgeStatusUrl(bridgeApiBaseUrl)}?${params.toString()}`;\n\n const rawTxStatus: unknown = await fetchFn(url, {\n headers: getClientHeaders({ clientId, jwt }),\n });\n\n const validationFailures: string[] = [];\n\n try {\n validateBridgeStatusResponse(rawTxStatus);\n } catch (error) {\n // Build validation failure event properties\n if (error instanceof StructError) {\n error.failures().forEach(({ path }) => {\n const aggregatorId =\n (rawTxStatus as StatusResponse)?.bridge ??\n (statusRequest.bridge || statusRequest.bridgeId) ??\n ('unknown' as string);\n const pathString = path?.join('.') || 'unknown';\n validationFailures.push([aggregatorId, pathString].join('|'));\n });\n }\n }\n return {\n status: rawTxStatus as StatusResponse,\n validationFailures,\n };\n};\n\nexport const getStatusRequestWithSrcTxHash = (\n quote: Quote,\n srcTxHash: string,\n): StatusRequestWithSrcTxHash => {\n const { bridgeId, bridges, srcChainId, destChainId, refuel } = quote;\n return {\n bridgeId,\n srcTxHash,\n bridge: bridges[0],\n srcChainId,\n destChainId,\n quote,\n refuel: Boolean(refuel),\n };\n};\n\nexport const shouldSkipFetchDueToFetchFailures = (\n attempts?: BridgeHistoryItem['attempts'],\n): boolean => {\n // If there's an attempt, it means we've failed at least once,\n // so we need to check if we need to wait longer due to exponential backoff\n if (attempts) {\n // Calculate exponential backoff delay: base interval * 2^(attempts-1)\n const backoffDelay =\n REFRESH_INTERVAL_MS * Math.pow(2, attempts.counter - 1);\n const timeSinceLastAttempt = Date.now() - attempts.lastAttemptTime;\n\n if (timeSinceLastAttempt < backoffDelay) {\n // Not enough time has passed, skip this fetch\n return true;\n }\n }\n return false;\n};\n"]}
1
+ {"version":3,"file":"bridge-status.cjs","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":";;;AAAA,mEAA+D;AAE/D,uDAAoD;AAEpD,iDAA4D;AAC5D,gDAAmD;AAU5C,MAAM,kBAAkB,GAAG,CAAC,gBAAwB,EAAU,EAAE,CACrE,GAAG,gBAAgB,cAAc,CAAC;AADvB,QAAA,kBAAkB,sBACK;AAE7B,MAAM,mBAAmB,GAAG,CACjC,aAAyC,EACvB,EAAE;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,oBAAoB,EAAE,GAAG,aAAa,CAAC;IAEzD,MAAM,6BAA6B,GAAG,MAAM,CAAC,WAAW,CACtD,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QACzD,GAAG;QACH,KAAK,CAAC,QAAQ,EAAE;KACjB,CAAC,CAC+C,CAAC;IAEpD,MAAM,SAAS,GACb,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEzD,OAAO;QACL,GAAG,6BAA6B;QAChC,GAAG,SAAS;KACb,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,mBAAmB,uBAmB9B;AAEK,MAAM,mBAAmB,GAAG,KAAK,EACtC,aAAyC,EACzC,QAAgB,EAChB,GAAuB,EACvB,OAAsB,EACtB,gBAAwB,EAC2C,EAAE;IACrE,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,aAAa,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,gBAAgB,CAAC,CAAC;IAErD,QAAQ;IACR,MAAM,G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C,CAAC;QAClB,UAAU;QACV,WAAW;QACX,KAAK;QACL,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;KACxB,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,6BAA6B,iCAcxC;AAEK,MAAM,iCAAiC,GAAG,CAC/C,QAAwC,EAC/B,EAAE;IACX,8DAA8D;IAC9D,2EAA2E;IAC3E,IAAI,QAAQ,EAAE,CAAC;QACb,sEAAsE;QACtE,MAAM,YAAY,GAChB,+BAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;QAC1D,MAAM,oBAAoB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAEnE,IAAI,oBAAoB,GAAG,YAAY,EAAE,CAAC;YACxC,8CAA8C;YAC9C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAjBW,QAAA,iCAAiC,qCAiB5C;AAEF;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,CACpC,aAA4B,EACb,EAAE;IACjB,OAAO;QACL,QAAQ,EAAE,aAAa,CAAC,KAAK,CAAC,QAAQ;QACtC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACtC,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC,UAAU;QAC1C,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW;QAC5C,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;KAC5C,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC","sourcesContent":["import { getClientHeaders } from '@metamask/bridge-controller';\nimport type { Quote, QuoteResponse } from '@metamask/bridge-controller';\nimport { StructError } from '@metamask/superstruct';\n\nimport { validateBridgeStatusResponse } from './validators';\nimport { REFRESH_INTERVAL_MS } from '../constants';\nimport type {\n StatusResponse,\n StatusRequestWithSrcTxHash,\n StatusRequestDto,\n FetchFunction,\n BridgeHistoryItem,\n StatusRequest,\n} from '../types';\n\nexport const getBridgeStatusUrl = (bridgeApiBaseUrl: string): string =>\n `${bridgeApiBaseUrl}/getTxStatus`;\n\nexport const getStatusRequestDto = (\n statusRequest: StatusRequestWithSrcTxHash,\n): StatusRequestDto => {\n const { quote, ...statusRequestNoQuote } = statusRequest;\n\n const statusRequestNoQuoteFormatted = Object.fromEntries(\n Object.entries(statusRequestNoQuote).map(([key, value]) => [\n key,\n value.toString(),\n ]),\n ) as unknown as Omit<StatusRequestDto, 'requestId'>;\n\n const requestId: { requestId: string } | Record<string, never> =\n quote?.requestId ? { requestId: quote.requestId } : {};\n\n return {\n ...statusRequestNoQuoteFormatted,\n ...requestId,\n };\n};\n\nexport const fetchBridgeTxStatus = async (\n statusRequest: StatusRequestWithSrcTxHash,\n clientId: string,\n jwt: string | undefined,\n fetchFn: FetchFunction,\n bridgeApiBaseUrl: string,\n): Promise<{ status: StatusResponse; validationFailures: string[] }> => {\n const statusRequestDto = getStatusRequestDto(statusRequest);\n const params = new URLSearchParams(statusRequestDto);\n\n // Fetch\n const url = `${getBridgeStatusUrl(bridgeApiBaseUrl)}?${params.toString()}`;\n\n const rawTxStatus: unknown = await fetchFn(url, {\n headers: getClientHeaders({ clientId, jwt }),\n });\n\n const validationFailures: string[] = [];\n\n try {\n validateBridgeStatusResponse(rawTxStatus);\n } catch (error) {\n // Build validation failure event properties\n if (error instanceof StructError) {\n error.failures().forEach(({ path }) => {\n const aggregatorId =\n (rawTxStatus as StatusResponse)?.bridge ??\n (statusRequest.bridge || statusRequest.bridgeId) ??\n ('unknown' as string);\n const pathString = path?.join('.') || 'unknown';\n validationFailures.push([aggregatorId, pathString].join('|'));\n });\n }\n }\n return {\n status: rawTxStatus as StatusResponse,\n validationFailures,\n };\n};\n\nexport const getStatusRequestWithSrcTxHash = (\n quote: Quote,\n srcTxHash: string,\n): StatusRequestWithSrcTxHash => {\n const { bridgeId, bridges, srcChainId, destChainId, refuel } = quote;\n return {\n bridgeId,\n srcTxHash,\n bridge: bridges[0],\n srcChainId,\n destChainId,\n quote,\n refuel: Boolean(refuel),\n };\n};\n\nexport const shouldSkipFetchDueToFetchFailures = (\n attempts?: BridgeHistoryItem['attempts'],\n): boolean => {\n // If there's an attempt, it means we've failed at least once,\n // so we need to check if we need to wait longer due to exponential backoff\n if (attempts) {\n // Calculate exponential backoff delay: base interval * 2^(attempts-1)\n const backoffDelay =\n REFRESH_INTERVAL_MS * Math.pow(2, attempts.counter - 1);\n const timeSinceLastAttempt = Date.now() - attempts.lastAttemptTime;\n\n if (timeSinceLastAttempt < backoffDelay) {\n // Not enough time has passed, skip this fetch\n return true;\n }\n }\n return false;\n};\n\n/**\n * @deprecated Use getStatusRequestWithSrcTxHash instead\n * @param quoteResponse - The quote response to get the status request parameters from\n * @returns The status request parameters\n */\nexport const getStatusRequestParams = (\n quoteResponse: QuoteResponse,\n): StatusRequest => {\n return {\n bridgeId: quoteResponse.quote.bridgeId,\n bridge: quoteResponse.quote.bridges[0],\n srcChainId: quoteResponse.quote.srcChainId,\n destChainId: quoteResponse.quote.destChainId,\n quote: quoteResponse.quote,\n refuel: Boolean(quoteResponse.quote.refuel),\n };\n};\n"]}
@@ -1,5 +1,5 @@
1
- import type { Quote } from "@metamask/bridge-controller";
2
- import type { StatusResponse, StatusRequestWithSrcTxHash, StatusRequestDto, FetchFunction, BridgeHistoryItem } from "../types.cjs";
1
+ import type { Quote, QuoteResponse } from "@metamask/bridge-controller";
2
+ import type { StatusResponse, StatusRequestWithSrcTxHash, StatusRequestDto, FetchFunction, BridgeHistoryItem, StatusRequest } from "../types.cjs";
3
3
  export declare const getBridgeStatusUrl: (bridgeApiBaseUrl: string) => string;
4
4
  export declare const getStatusRequestDto: (statusRequest: StatusRequestWithSrcTxHash) => StatusRequestDto;
5
5
  export declare const fetchBridgeTxStatus: (statusRequest: StatusRequestWithSrcTxHash, clientId: string, jwt: string | undefined, fetchFn: FetchFunction, bridgeApiBaseUrl: string) => Promise<{
@@ -8,4 +8,10 @@ export declare const fetchBridgeTxStatus: (statusRequest: StatusRequestWithSrcTx
8
8
  }>;
9
9
  export declare const getStatusRequestWithSrcTxHash: (quote: Quote, srcTxHash: string) => StatusRequestWithSrcTxHash;
10
10
  export declare const shouldSkipFetchDueToFetchFailures: (attempts?: BridgeHistoryItem['attempts']) => boolean;
11
+ /**
12
+ * @deprecated Use getStatusRequestWithSrcTxHash instead
13
+ * @param quoteResponse - The quote response to get the status request parameters from
14
+ * @returns The status request parameters
15
+ */
16
+ export declare const getStatusRequestParams: (quoteResponse: QuoteResponse) => StatusRequest;
11
17
  //# sourceMappingURL=bridge-status.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-status.d.cts","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,oCAAoC;AAKzD,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EAClB,qBAAiB;AAElB,eAAO,MAAM,kBAAkB,qBAAsB,MAAM,KAAG,MAC3B,CAAC;AAEpC,eAAO,MAAM,mBAAmB,kBACf,0BAA0B,KACxC,gBAiBF,CAAC;AAEF,eAAO,MAAM,mBAAmB,kBACf,0BAA0B,YAC/B,MAAM,OACX,MAAM,GAAG,SAAS,WACd,aAAa,oBACJ,MAAM;YACL,cAAc;wBAAsB,MAAM,EAAE;EAgChE,CAAC;AAEF,eAAO,MAAM,6BAA6B,UACjC,KAAK,aACD,MAAM,KAChB,0BAWF,CAAC;AAEF,eAAO,MAAM,iCAAiC,cACjC,iBAAiB,CAAC,UAAU,CAAC,KACvC,OAeF,CAAC"}
1
+ {"version":3,"file":"bridge-status.d.cts","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,oCAAoC;AAKxE,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACd,qBAAiB;AAElB,eAAO,MAAM,kBAAkB,qBAAsB,MAAM,KAAG,MAC3B,CAAC;AAEpC,eAAO,MAAM,mBAAmB,kBACf,0BAA0B,KACxC,gBAiBF,CAAC;AAEF,eAAO,MAAM,mBAAmB,kBACf,0BAA0B,YAC/B,MAAM,OACX,MAAM,GAAG,SAAS,WACd,aAAa,oBACJ,MAAM;YACL,cAAc;wBAAsB,MAAM,EAAE;EAgChE,CAAC;AAEF,eAAO,MAAM,6BAA6B,UACjC,KAAK,aACD,MAAM,KAChB,0BAWF,CAAC;AAEF,eAAO,MAAM,iCAAiC,cACjC,iBAAiB,CAAC,UAAU,CAAC,KACvC,OAeF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,kBAClB,aAAa,KAC3B,aASF,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Quote } from "@metamask/bridge-controller";
2
- import type { StatusResponse, StatusRequestWithSrcTxHash, StatusRequestDto, FetchFunction, BridgeHistoryItem } from "../types.mjs";
1
+ import type { Quote, QuoteResponse } from "@metamask/bridge-controller";
2
+ import type { StatusResponse, StatusRequestWithSrcTxHash, StatusRequestDto, FetchFunction, BridgeHistoryItem, StatusRequest } from "../types.mjs";
3
3
  export declare const getBridgeStatusUrl: (bridgeApiBaseUrl: string) => string;
4
4
  export declare const getStatusRequestDto: (statusRequest: StatusRequestWithSrcTxHash) => StatusRequestDto;
5
5
  export declare const fetchBridgeTxStatus: (statusRequest: StatusRequestWithSrcTxHash, clientId: string, jwt: string | undefined, fetchFn: FetchFunction, bridgeApiBaseUrl: string) => Promise<{
@@ -8,4 +8,10 @@ export declare const fetchBridgeTxStatus: (statusRequest: StatusRequestWithSrcTx
8
8
  }>;
9
9
  export declare const getStatusRequestWithSrcTxHash: (quote: Quote, srcTxHash: string) => StatusRequestWithSrcTxHash;
10
10
  export declare const shouldSkipFetchDueToFetchFailures: (attempts?: BridgeHistoryItem['attempts']) => boolean;
11
+ /**
12
+ * @deprecated Use getStatusRequestWithSrcTxHash instead
13
+ * @param quoteResponse - The quote response to get the status request parameters from
14
+ * @returns The status request parameters
15
+ */
16
+ export declare const getStatusRequestParams: (quoteResponse: QuoteResponse) => StatusRequest;
11
17
  //# sourceMappingURL=bridge-status.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-status.d.mts","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,oCAAoC;AAKzD,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EAClB,qBAAiB;AAElB,eAAO,MAAM,kBAAkB,qBAAsB,MAAM,KAAG,MAC3B,CAAC;AAEpC,eAAO,MAAM,mBAAmB,kBACf,0BAA0B,KACxC,gBAiBF,CAAC;AAEF,eAAO,MAAM,mBAAmB,kBACf,0BAA0B,YAC/B,MAAM,OACX,MAAM,GAAG,SAAS,WACd,aAAa,oBACJ,MAAM;YACL,cAAc;wBAAsB,MAAM,EAAE;EAgChE,CAAC;AAEF,eAAO,MAAM,6BAA6B,UACjC,KAAK,aACD,MAAM,KAChB,0BAWF,CAAC;AAEF,eAAO,MAAM,iCAAiC,cACjC,iBAAiB,CAAC,UAAU,CAAC,KACvC,OAeF,CAAC"}
1
+ {"version":3,"file":"bridge-status.d.mts","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,oCAAoC;AAKxE,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC1B,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACd,qBAAiB;AAElB,eAAO,MAAM,kBAAkB,qBAAsB,MAAM,KAAG,MAC3B,CAAC;AAEpC,eAAO,MAAM,mBAAmB,kBACf,0BAA0B,KACxC,gBAiBF,CAAC;AAEF,eAAO,MAAM,mBAAmB,kBACf,0BAA0B,YAC/B,MAAM,OACX,MAAM,GAAG,SAAS,WACd,aAAa,oBACJ,MAAM;YACL,cAAc;wBAAsB,MAAM,EAAE;EAgChE,CAAC;AAEF,eAAO,MAAM,6BAA6B,UACjC,KAAK,aACD,MAAM,KAChB,0BAWF,CAAC;AAEF,eAAO,MAAM,iCAAiC,cACjC,iBAAiB,CAAC,UAAU,CAAC,KACvC,OAeF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,kBAClB,aAAa,KAC3B,aASF,CAAC"}
@@ -70,4 +70,19 @@ export const shouldSkipFetchDueToFetchFailures = (attempts) => {
70
70
  }
71
71
  return false;
72
72
  };
73
+ /**
74
+ * @deprecated Use getStatusRequestWithSrcTxHash instead
75
+ * @param quoteResponse - The quote response to get the status request parameters from
76
+ * @returns The status request parameters
77
+ */
78
+ export const getStatusRequestParams = (quoteResponse) => {
79
+ return {
80
+ bridgeId: quoteResponse.quote.bridgeId,
81
+ bridge: quoteResponse.quote.bridges[0],
82
+ srcChainId: quoteResponse.quote.srcChainId,
83
+ destChainId: quoteResponse.quote.destChainId,
84
+ quote: quoteResponse.quote,
85
+ refuel: Boolean(quoteResponse.quote.refuel),
86
+ };
87
+ };
73
88
  //# sourceMappingURL=bridge-status.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-status.mjs","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oCAAoC;AAE/D,OAAO,EAAE,WAAW,EAAE,8BAA8B;AAEpD,OAAO,EAAE,4BAA4B,EAAE,yBAAqB;AAC5D,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AASnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC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AC;QAC1D,MAAM,oBAAoB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAEnE,IAAI,oBAAoB,GAAG,YAAY,EAAE,CAAC;YACxC,8CAA8C;YAC9C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import { getClientHeaders } from '@metamask/bridge-controller';\nimport type { Quote } from '@metamask/bridge-controller';\nimport { StructError } from '@metamask/superstruct';\n\nimport { validateBridgeStatusResponse } from './validators';\nimport { REFRESH_INTERVAL_MS } from '../constants';\nimport type {\n StatusResponse,\n StatusRequestWithSrcTxHash,\n StatusRequestDto,\n FetchFunction,\n BridgeHistoryItem,\n} from '../types';\n\nexport const getBridgeStatusUrl = (bridgeApiBaseUrl: string): string =>\n `${bridgeApiBaseUrl}/getTxStatus`;\n\nexport const getStatusRequestDto = (\n statusRequest: StatusRequestWithSrcTxHash,\n): StatusRequestDto => {\n const { quote, ...statusRequestNoQuote } = statusRequest;\n\n const statusRequestNoQuoteFormatted = Object.fromEntries(\n Object.entries(statusRequestNoQuote).map(([key, value]) => [\n key,\n value.toString(),\n ]),\n ) as unknown as Omit<StatusRequestDto, 'requestId'>;\n\n const requestId: { requestId: string } | Record<string, never> =\n quote?.requestId ? { requestId: quote.requestId } : {};\n\n return {\n ...statusRequestNoQuoteFormatted,\n ...requestId,\n };\n};\n\nexport const fetchBridgeTxStatus = async (\n statusRequest: StatusRequestWithSrcTxHash,\n clientId: string,\n jwt: string | undefined,\n fetchFn: FetchFunction,\n bridgeApiBaseUrl: string,\n): Promise<{ status: StatusResponse; validationFailures: string[] }> => {\n const statusRequestDto = getStatusRequestDto(statusRequest);\n const params = new URLSearchParams(statusRequestDto);\n\n // Fetch\n const url = `${getBridgeStatusUrl(bridgeApiBaseUrl)}?${params.toString()}`;\n\n const rawTxStatus: unknown = await fetchFn(url, {\n headers: getClientHeaders({ clientId, jwt }),\n });\n\n const validationFailures: string[] = [];\n\n try {\n validateBridgeStatusResponse(rawTxStatus);\n } catch (error) {\n // Build validation failure event properties\n if (error instanceof StructError) {\n error.failures().forEach(({ path }) => {\n const aggregatorId =\n (rawTxStatus as StatusResponse)?.bridge ??\n (statusRequest.bridge || statusRequest.bridgeId) ??\n ('unknown' as string);\n const pathString = path?.join('.') || 'unknown';\n validationFailures.push([aggregatorId, pathString].join('|'));\n });\n }\n }\n return {\n status: rawTxStatus as StatusResponse,\n validationFailures,\n };\n};\n\nexport const getStatusRequestWithSrcTxHash = (\n quote: Quote,\n srcTxHash: string,\n): StatusRequestWithSrcTxHash => {\n const { bridgeId, bridges, srcChainId, destChainId, refuel } = quote;\n return {\n bridgeId,\n srcTxHash,\n bridge: bridges[0],\n srcChainId,\n destChainId,\n quote,\n refuel: Boolean(refuel),\n };\n};\n\nexport const shouldSkipFetchDueToFetchFailures = (\n attempts?: BridgeHistoryItem['attempts'],\n): boolean => {\n // If there's an attempt, it means we've failed at least once,\n // so we need to check if we need to wait longer due to exponential backoff\n if (attempts) {\n // Calculate exponential backoff delay: base interval * 2^(attempts-1)\n const backoffDelay =\n REFRESH_INTERVAL_MS * Math.pow(2, attempts.counter - 1);\n const timeSinceLastAttempt = Date.now() - attempts.lastAttemptTime;\n\n if (timeSinceLastAttempt < backoffDelay) {\n // Not enough time has passed, skip this fetch\n return true;\n }\n }\n return false;\n};\n"]}
1
+ {"version":3,"file":"bridge-status.mjs","sourceRoot":"","sources":["../../src/utils/bridge-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oCAAoC;AAE/D,OAAO,EAAE,WAAW,EAAE,8BAA8B;AAEpD,OAAO,EAAE,4BAA4B,EAAE,yBAAqB;AAC5D,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AAUnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,gBAAwB,EAAU,EAAE,CACrE,GAAG,gBAAgB,cAAc,CAAC;AAEpC,MAAM,CA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AAC,eAAe,CAAC;QAEnE,IAAI,oBAAoB,GAAG,YAAY,EAAE,CAAC;YACxC,8CAA8C;YAC9C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,aAA4B,EACb,EAAE;IACjB,OAAO;QACL,QAAQ,EAAE,aAAa,CAAC,KAAK,CAAC,QAAQ;QACtC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACtC,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC,UAAU;QAC1C,WAAW,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW;QAC5C,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;KAC5C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { getClientHeaders } from '@metamask/bridge-controller';\nimport type { Quote, QuoteResponse } from '@metamask/bridge-controller';\nimport { StructError } from '@metamask/superstruct';\n\nimport { validateBridgeStatusResponse } from './validators';\nimport { REFRESH_INTERVAL_MS } from '../constants';\nimport type {\n StatusResponse,\n StatusRequestWithSrcTxHash,\n StatusRequestDto,\n FetchFunction,\n BridgeHistoryItem,\n StatusRequest,\n} from '../types';\n\nexport const getBridgeStatusUrl = (bridgeApiBaseUrl: string): string =>\n `${bridgeApiBaseUrl}/getTxStatus`;\n\nexport const getStatusRequestDto = (\n statusRequest: StatusRequestWithSrcTxHash,\n): StatusRequestDto => {\n const { quote, ...statusRequestNoQuote } = statusRequest;\n\n const statusRequestNoQuoteFormatted = Object.fromEntries(\n Object.entries(statusRequestNoQuote).map(([key, value]) => [\n key,\n value.toString(),\n ]),\n ) as unknown as Omit<StatusRequestDto, 'requestId'>;\n\n const requestId: { requestId: string } | Record<string, never> =\n quote?.requestId ? { requestId: quote.requestId } : {};\n\n return {\n ...statusRequestNoQuoteFormatted,\n ...requestId,\n };\n};\n\nexport const fetchBridgeTxStatus = async (\n statusRequest: StatusRequestWithSrcTxHash,\n clientId: string,\n jwt: string | undefined,\n fetchFn: FetchFunction,\n bridgeApiBaseUrl: string,\n): Promise<{ status: StatusResponse; validationFailures: string[] }> => {\n const statusRequestDto = getStatusRequestDto(statusRequest);\n const params = new URLSearchParams(statusRequestDto);\n\n // Fetch\n const url = `${getBridgeStatusUrl(bridgeApiBaseUrl)}?${params.toString()}`;\n\n const rawTxStatus: unknown = await fetchFn(url, {\n headers: getClientHeaders({ clientId, jwt }),\n });\n\n const validationFailures: string[] = [];\n\n try {\n validateBridgeStatusResponse(rawTxStatus);\n } catch (error) {\n // Build validation failure event properties\n if (error instanceof StructError) {\n error.failures().forEach(({ path }) => {\n const aggregatorId =\n (rawTxStatus as StatusResponse)?.bridge ??\n (statusRequest.bridge || statusRequest.bridgeId) ??\n ('unknown' as string);\n const pathString = path?.join('.') || 'unknown';\n validationFailures.push([aggregatorId, pathString].join('|'));\n });\n }\n }\n return {\n status: rawTxStatus as StatusResponse,\n validationFailures,\n };\n};\n\nexport const getStatusRequestWithSrcTxHash = (\n quote: Quote,\n srcTxHash: string,\n): StatusRequestWithSrcTxHash => {\n const { bridgeId, bridges, srcChainId, destChainId, refuel } = quote;\n return {\n bridgeId,\n srcTxHash,\n bridge: bridges[0],\n srcChainId,\n destChainId,\n quote,\n refuel: Boolean(refuel),\n };\n};\n\nexport const shouldSkipFetchDueToFetchFailures = (\n attempts?: BridgeHistoryItem['attempts'],\n): boolean => {\n // If there's an attempt, it means we've failed at least once,\n // so we need to check if we need to wait longer due to exponential backoff\n if (attempts) {\n // Calculate exponential backoff delay: base interval * 2^(attempts-1)\n const backoffDelay =\n REFRESH_INTERVAL_MS * Math.pow(2, attempts.counter - 1);\n const timeSinceLastAttempt = Date.now() - attempts.lastAttemptTime;\n\n if (timeSinceLastAttempt < backoffDelay) {\n // Not enough time has passed, skip this fetch\n return true;\n }\n }\n return false;\n};\n\n/**\n * @deprecated Use getStatusRequestWithSrcTxHash instead\n * @param quoteResponse - The quote response to get the status request parameters from\n * @returns The status request parameters\n */\nexport const getStatusRequestParams = (\n quoteResponse: QuoteResponse,\n): StatusRequest => {\n return {\n bridgeId: quoteResponse.quote.bridgeId,\n bridge: quoteResponse.quote.bridges[0],\n srcChainId: quoteResponse.quote.srcChainId,\n destChainId: quoteResponse.quote.destChainId,\n quote: quoteResponse.quote,\n refuel: Boolean(quoteResponse.quote.refuel),\n };\n};\n"]}
@@ -1,64 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calcActualGasUsed = exports.calculateGasFees = exports.getTxGasEstimates = void 0;
4
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
5
- const bridge_controller_1 = require("@metamask/bridge-controller");
6
- const controller_utils_1 = require("@metamask/controller-utils");
3
+ exports.calcActualGasUsed = void 0;
7
4
  const bignumber_js_1 = require("bignumber.js");
8
- const getTransaction1559GasFeeEstimates = (txGasFeeEstimates, estimatedBaseFee) => {
9
- const { maxFeePerGas, maxPriorityFeePerGas } = txGasFeeEstimates?.[bridge_controller_1.BRIDGE_PREFERRED_GAS_ESTIMATE] ?? {};
10
- const baseAndPriorityFeePerGas = maxPriorityFeePerGas
11
- ? new bignumber_js_1.BigNumber(estimatedBaseFee, 10)
12
- .times(10 ** 9)
13
- .plus(maxPriorityFeePerGas, 16)
14
- : undefined;
15
- return {
16
- baseAndPriorityFeePerGas,
17
- maxFeePerGas,
18
- maxPriorityFeePerGas,
19
- };
20
- };
21
- /**
22
- * Get the gas fee estimates for a transaction
23
- *
24
- * @param params - The parameters for the gas fee estimates
25
- * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)
26
- * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)
27
- * @returns The gas fee estimates for the transaction
28
- */
29
- const getTxGasEstimates = ({ txGasFeeEstimates, networkGasFeeEstimates, }) => {
30
- const { estimatedBaseFee = '0' } = networkGasFeeEstimates;
31
- return getTransaction1559GasFeeEstimates(txGasFeeEstimates, estimatedBaseFee);
32
- };
33
- exports.getTxGasEstimates = getTxGasEstimates;
34
- const calculateGasFees = async (skipGasFields, messenger, { chainId: _, gasLimit, ...trade }, networkClientId, chainId, txFee) => {
35
- if (skipGasFields) {
36
- return {};
37
- }
38
- if (txFee) {
39
- return { ...txFee, gas: gasLimit?.toString() };
40
- }
41
- const transactionParams = {
42
- ...trade,
43
- gas: gasLimit?.toString(),
44
- data: trade.data,
45
- to: trade.to,
46
- value: trade.value,
47
- };
48
- const { gasFeeEstimates } = messenger.call('GasFeeController:getState');
49
- const { estimates: txGasFeeEstimates } = await messenger.call('TransactionController:estimateGasFee', { transactionParams, chainId, networkClientId });
50
- const { maxFeePerGas, maxPriorityFeePerGas } = (0, exports.getTxGasEstimates)({
51
- networkGasFeeEstimates: gasFeeEstimates,
52
- txGasFeeEstimates,
53
- });
54
- const maxGasLimit = (0, controller_utils_1.toHex)(transactionParams.gas ?? 0);
55
- return {
56
- maxFeePerGas,
57
- maxPriorityFeePerGas,
58
- gas: maxGasLimit,
59
- };
60
- };
61
- exports.calculateGasFees = calculateGasFees;
62
5
  const calcGasInHexWei = (gasLimit, gasPrice) => {
63
6
  return gasLimit && gasPrice
64
7
  ? new bignumber_js_1.BigNumber(gasLimit, 16).times(new bignumber_js_1.BigNumber(gasPrice, 16))
@@ -1 +1 @@
1
- {"version":3,"file":"gas.cjs","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,mEAA4E;AAE5E,iEAAmD;AAWnD,+CAAyC;AAOzC,MAAM,iCAAiC,GAAG,CACxC,iBAA2C,EAC3C,gBAAwB,EACxB,EAAE;IACF,MAAM,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAC1C,iBAAiB,EAAE,CAAC,iDAA6B,CAAC,IAAI,EAAE,CAAC;IAE3D,MAAM,wB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CACrC,IAAI,CAAC,CACP,CAAC;IAEF,MAAM,iBAAiB,GAAG,iBAAiB;QACzC,EAAE,GAAG,CAAC,IAAI,wBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SAC/B,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEhB,OAAO,iBAAiB,IAAI,iBAAiB;QAC3C,CAAC,CAAC;YACE,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,GAAG,EACD,eAAe,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI;SACxE;QACH,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAjCW,QAAA,iBAAiB,qBAiC5B","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport { BRIDGE_PREFERRED_GAS_ESTIMATE } from '@metamask/bridge-controller';\nimport type { TokenAmountValues, TxData } from '@metamask/bridge-controller';\nimport { toHex } from '@metamask/controller-utils';\nimport type {\n GasFeeEstimates,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type {\n FeeMarketGasFeeEstimates,\n TransactionController,\n TransactionReceipt,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type {\n BridgeHistoryItem,\n BridgeStatusControllerMessenger,\n} from '../types';\n\nconst getTransaction1559GasFeeEstimates = (\n txGasFeeEstimates: FeeMarketGasFeeEstimates,\n estimatedBaseFee: string,\n) => {\n const { maxFeePerGas, maxPriorityFeePerGas } =\n txGasFeeEstimates?.[BRIDGE_PREFERRED_GAS_ESTIMATE] ?? {};\n\n const baseAndPriorityFeePerGas = maxPriorityFeePerGas\n ? new BigNumber(estimatedBaseFee, 10)\n .times(10 ** 9)\n .plus(maxPriorityFeePerGas, 16)\n : undefined;\n\n return {\n baseAndPriorityFeePerGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n};\n\n/**\n * Get the gas fee estimates for a transaction\n *\n * @param params - The parameters for the gas fee estimates\n * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)\n * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)\n * @returns The gas fee estimates for the transaction\n */\nexport const getTxGasEstimates = ({\n txGasFeeEstimates,\n networkGasFeeEstimates,\n}: {\n txGasFeeEstimates: Awaited<\n ReturnType<TransactionController['estimateGasFee']>\n >['estimates'];\n networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];\n}) => {\n const { estimatedBaseFee = '0' } = networkGasFeeEstimates as GasFeeEstimates;\n return getTransaction1559GasFeeEstimates(\n txGasFeeEstimates as unknown as FeeMarketGasFeeEstimates,\n estimatedBaseFee,\n );\n};\n\nexport const calculateGasFees = async (\n skipGasFields: boolean,\n messenger: BridgeStatusControllerMessenger,\n { chainId: _, gasLimit, ...trade }: TxData,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n) => {\n if (skipGasFields) {\n return {};\n }\n if (txFee) {\n return { ...txFee, gas: gasLimit?.toString() };\n }\n const transactionParams = {\n ...trade,\n gas: gasLimit?.toString(),\n data: trade.data as `0x${string}`,\n to: trade.to as `0x${string}`,\n value: trade.value as `0x${string}`,\n };\n const { gasFeeEstimates } = messenger.call('GasFeeController:getState');\n const { estimates: txGasFeeEstimates } = await messenger.call(\n 'TransactionController:estimateGasFee',\n { transactionParams, chainId, networkClientId },\n );\n const { maxFeePerGas, maxPriorityFeePerGas } = getTxGasEstimates({\n networkGasFeeEstimates: gasFeeEstimates,\n txGasFeeEstimates,\n });\n const maxGasLimit = toHex(transactionParams.gas ?? 0);\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: maxGasLimit,\n };\n};\n\nconst calcGasInHexWei = (gasLimit?: string, gasPrice?: string) => {\n return gasLimit && gasPrice\n ? new BigNumber(gasLimit, 16).times(new BigNumber(gasPrice, 16))\n : null;\n};\n\n/**\n * Calculate the effective gas used for a transaction and its approval tx\n *\n * @param bridgeHistoryItem - The bridge history item\n * @param bridgeHistoryItem.pricingData - pricing data from the submitted quote\n * @param txReceipt - tx receipt from the txMeta\n * @param approvalTxReceipt - tx receipt from the approvalTxMeta\n * @returns The actual gas used for the transaction in Wei and its value in USD\n */\nexport const calcActualGasUsed = (\n { pricingData }: BridgeHistoryItem,\n txReceipt?: TransactionReceipt,\n approvalTxReceipt?: TransactionReceipt,\n): Omit<TokenAmountValues, 'valueInCurrency'> | null => {\n const usdExchangeRate =\n pricingData?.quotedGasInUsd && pricingData?.quotedGasAmount\n ? new BigNumber(pricingData?.quotedGasInUsd).div(\n pricingData.quotedGasAmount,\n )\n : null;\n\n const actualGasInHexWei = calcGasInHexWei(\n txReceipt?.gasUsed,\n txReceipt?.effectiveGasPrice,\n )?.plus(\n calcGasInHexWei(\n approvalTxReceipt?.gasUsed,\n approvalTxReceipt?.effectiveGasPrice,\n ) ?? 0,\n );\n\n const actualGasInDecEth = actualGasInHexWei\n ?.div(new BigNumber(10).pow(18))\n .toString(10);\n\n return actualGasInHexWei && actualGasInDecEth\n ? {\n amount: actualGasInHexWei.toString(10),\n usd:\n usdExchangeRate?.multipliedBy(actualGasInDecEth).toString(10) ?? null,\n }\n : null;\n};\n"]}
1
+ {"version":3,"file":"gas.cjs","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";;;AAGA,+CAAyC;AAIzC,MAAM,eAAe,GAAG,CAAC,QAAiB,EAAE,QAAiB,EAAE,EAAE;IAC/D,OAAO,QAAQ,IAAI,QAAQ;QACzB,CAAC,CAAC,IAAI,wBAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,wBAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,iBAAiB,GAAG,CAC/B,EAAE,WAAW,EAAqB,EAClC,SAA8B,EAC9B,iBAAsC,EACa,EAAE;IACrD,MAAM,eAAe,GACnB,WAAW,EAAE,cAAc,IAAI,WAAW,EAAE,eAAe;QACzD,CAAC,CAAC,IAAI,wBAAS,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,GAAG,CAC5C,WAAW,CAAC,eAAe,CAC5B;QACH,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,iBAAiB,GAAG,eAAe,CACvC,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,iBAAiB,CAC7B,EAAE,IAAI,CACL,eAAe,CACb,iBAAiB,EAAE,OAAO,EAC1B,iBAAiB,EAAE,iBAAiB,CACrC,IAAI,CAAC,CACP,CAAC;IAEF,MAAM,iBAAiB,GAAG,iBAAiB;QACzC,EAAE,GAAG,CAAC,IAAI,wBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SAC/B,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEhB,OAAO,iBAAiB,IAAI,iBAAiB;QAC3C,CAAC,CAAC;YACE,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,GAAG,EACD,eAAe,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI;SACxE;QACH,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAjCW,QAAA,iBAAiB,qBAiC5B","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport type { TokenAmountValues } from '@metamask/bridge-controller';\nimport type { TransactionReceipt } from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\n\nimport type { BridgeHistoryItem } from '../types';\n\nconst calcGasInHexWei = (gasLimit?: string, gasPrice?: string) => {\n return gasLimit && gasPrice\n ? new BigNumber(gasLimit, 16).times(new BigNumber(gasPrice, 16))\n : null;\n};\n\n/**\n * Calculate the effective gas used for a transaction and its approval tx\n *\n * @param bridgeHistoryItem - The bridge history item\n * @param bridgeHistoryItem.pricingData - pricing data from the submitted quote\n * @param txReceipt - tx receipt from the txMeta\n * @param approvalTxReceipt - tx receipt from the approvalTxMeta\n * @returns The actual gas used for the transaction in Wei and its value in USD\n */\nexport const calcActualGasUsed = (\n { pricingData }: BridgeHistoryItem,\n txReceipt?: TransactionReceipt,\n approvalTxReceipt?: TransactionReceipt,\n): Omit<TokenAmountValues, 'valueInCurrency'> | null => {\n const usdExchangeRate =\n pricingData?.quotedGasInUsd && pricingData?.quotedGasAmount\n ? new BigNumber(pricingData?.quotedGasInUsd).div(\n pricingData.quotedGasAmount,\n )\n : null;\n\n const actualGasInHexWei = calcGasInHexWei(\n txReceipt?.gasUsed,\n txReceipt?.effectiveGasPrice,\n )?.plus(\n calcGasInHexWei(\n approvalTxReceipt?.gasUsed,\n approvalTxReceipt?.effectiveGasPrice,\n ) ?? 0,\n );\n\n const actualGasInDecEth = actualGasInHexWei\n ?.div(new BigNumber(10).pow(18))\n .toString(10);\n\n return actualGasInHexWei && actualGasInDecEth\n ? {\n amount: actualGasInHexWei.toString(10),\n usd:\n usdExchangeRate?.multipliedBy(actualGasInDecEth).toString(10) ?? null,\n }\n : null;\n};\n"]}
@@ -1,29 +1,6 @@
1
- import type { TokenAmountValues, TxData } from "@metamask/bridge-controller";
2
- import type { GasFeeState } from "@metamask/gas-fee-controller";
3
- import type { TransactionController, TransactionReceipt } from "@metamask/transaction-controller";
4
- import type { Hex } from "@metamask/utils";
5
- import { BigNumber } from "bignumber.js";
6
- import type { BridgeHistoryItem, BridgeStatusControllerMessenger } from "../types.cjs";
7
- /**
8
- * Get the gas fee estimates for a transaction
9
- *
10
- * @param params - The parameters for the gas fee estimates
11
- * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)
12
- * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)
13
- * @returns The gas fee estimates for the transaction
14
- */
15
- export declare const getTxGasEstimates: ({ txGasFeeEstimates, networkGasFeeEstimates, }: {
16
- txGasFeeEstimates: Awaited<ReturnType<TransactionController['estimateGasFee']>>['estimates'];
17
- networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];
18
- }) => {
19
- baseAndPriorityFeePerGas: BigNumber | undefined;
20
- maxFeePerGas: `0x${string}`;
21
- maxPriorityFeePerGas: `0x${string}`;
22
- };
23
- export declare const calculateGasFees: (skipGasFields: boolean, messenger: BridgeStatusControllerMessenger, { chainId: _, gasLimit, ...trade }: TxData, networkClientId: string, chainId: Hex, txFee?: {
24
- maxFeePerGas: string;
25
- maxPriorityFeePerGas: string;
26
- }) => Promise<{}>;
1
+ import type { TokenAmountValues } from "@metamask/bridge-controller";
2
+ import type { TransactionReceipt } from "@metamask/transaction-controller";
3
+ import type { BridgeHistoryItem } from "../types.cjs";
27
4
  /**
28
5
  * Calculate the effective gas used for a transaction and its approval tx
29
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"gas.d.cts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,oCAAoC;AAE7E,OAAO,KAAK,EAEV,WAAW,EACZ,qCAAqC;AACtC,OAAO,KAAK,EAEV,qBAAqB,EACrB,kBAAkB,EACnB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,KAAK,EACV,iBAAiB,EACjB,+BAA+B,EAChC,qBAAiB;AAsBlB;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;uBAIT,QACjB,WAAW,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CACpD,CAAC,WAAW,CAAC;4BACU,WAAW,CAAC,iBAAiB,CAAC;;;;;CAOvD,CAAC;AAEF,eAAO,MAAM,gBAAgB,kBACZ,OAAO,kFAEc,MAAM,mBACzB,MAAM,WACd,GAAG,UACJ;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,gBA+B/D,CAAC;AAQF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBACX,iBAAiB,cACtB,kBAAkB,sBACV,kBAAkB,KACrC,KAAK,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,IA6B/C,CAAC"}
1
+ {"version":3,"file":"gas.d.cts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,yCAAyC;AAG3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAQlD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBACX,iBAAiB,cACtB,kBAAkB,sBACV,kBAAkB,KACrC,KAAK,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,IA6B/C,CAAC"}
@@ -1,29 +1,6 @@
1
- import type { TokenAmountValues, TxData } from "@metamask/bridge-controller";
2
- import type { GasFeeState } from "@metamask/gas-fee-controller";
3
- import type { TransactionController, TransactionReceipt } from "@metamask/transaction-controller";
4
- import type { Hex } from "@metamask/utils";
5
- import { BigNumber } from "bignumber.js";
6
- import type { BridgeHistoryItem, BridgeStatusControllerMessenger } from "../types.mjs";
7
- /**
8
- * Get the gas fee estimates for a transaction
9
- *
10
- * @param params - The parameters for the gas fee estimates
11
- * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)
12
- * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)
13
- * @returns The gas fee estimates for the transaction
14
- */
15
- export declare const getTxGasEstimates: ({ txGasFeeEstimates, networkGasFeeEstimates, }: {
16
- txGasFeeEstimates: Awaited<ReturnType<TransactionController['estimateGasFee']>>['estimates'];
17
- networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];
18
- }) => {
19
- baseAndPriorityFeePerGas: BigNumber | undefined;
20
- maxFeePerGas: `0x${string}`;
21
- maxPriorityFeePerGas: `0x${string}`;
22
- };
23
- export declare const calculateGasFees: (skipGasFields: boolean, messenger: BridgeStatusControllerMessenger, { chainId: _, gasLimit, ...trade }: TxData, networkClientId: string, chainId: Hex, txFee?: {
24
- maxFeePerGas: string;
25
- maxPriorityFeePerGas: string;
26
- }) => Promise<{}>;
1
+ import type { TokenAmountValues } from "@metamask/bridge-controller";
2
+ import type { TransactionReceipt } from "@metamask/transaction-controller";
3
+ import type { BridgeHistoryItem } from "../types.mjs";
27
4
  /**
28
5
  * Calculate the effective gas used for a transaction and its approval tx
29
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"gas.d.mts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,oCAAoC;AAE7E,OAAO,KAAK,EAEV,WAAW,EACZ,qCAAqC;AACtC,OAAO,KAAK,EAEV,qBAAqB,EACrB,kBAAkB,EACnB,yCAAyC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,KAAK,EACV,iBAAiB,EACjB,+BAA+B,EAChC,qBAAiB;AAsBlB;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;uBAIT,QACjB,WAAW,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CACpD,CAAC,WAAW,CAAC;4BACU,WAAW,CAAC,iBAAiB,CAAC;;;;;CAOvD,CAAC;AAEF,eAAO,MAAM,gBAAgB,kBACZ,OAAO,kFAEc,MAAM,mBACzB,MAAM,WACd,GAAG,UACJ;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,gBA+B/D,CAAC;AAQF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBACX,iBAAiB,cACtB,kBAAkB,sBACV,kBAAkB,KACrC,KAAK,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,IA6B/C,CAAC"}
1
+ {"version":3,"file":"gas.d.mts","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,yCAAyC;AAG3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAQlD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBACX,iBAAiB,cACtB,kBAAkB,sBACV,kBAAkB,KACrC,KAAK,iBAAiB,EAAE,iBAAiB,CAAC,GAAG,IA6B/C,CAAC"}
@@ -1,59 +1,4 @@
1
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
2
- import { BRIDGE_PREFERRED_GAS_ESTIMATE } from "@metamask/bridge-controller";
3
- import { toHex } from "@metamask/controller-utils";
4
1
  import { BigNumber } from "bignumber.js";
5
- const getTransaction1559GasFeeEstimates = (txGasFeeEstimates, estimatedBaseFee) => {
6
- const { maxFeePerGas, maxPriorityFeePerGas } = txGasFeeEstimates?.[BRIDGE_PREFERRED_GAS_ESTIMATE] ?? {};
7
- const baseAndPriorityFeePerGas = maxPriorityFeePerGas
8
- ? new BigNumber(estimatedBaseFee, 10)
9
- .times(10 ** 9)
10
- .plus(maxPriorityFeePerGas, 16)
11
- : undefined;
12
- return {
13
- baseAndPriorityFeePerGas,
14
- maxFeePerGas,
15
- maxPriorityFeePerGas,
16
- };
17
- };
18
- /**
19
- * Get the gas fee estimates for a transaction
20
- *
21
- * @param params - The parameters for the gas fee estimates
22
- * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)
23
- * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)
24
- * @returns The gas fee estimates for the transaction
25
- */
26
- export const getTxGasEstimates = ({ txGasFeeEstimates, networkGasFeeEstimates, }) => {
27
- const { estimatedBaseFee = '0' } = networkGasFeeEstimates;
28
- return getTransaction1559GasFeeEstimates(txGasFeeEstimates, estimatedBaseFee);
29
- };
30
- export const calculateGasFees = async (skipGasFields, messenger, { chainId: _, gasLimit, ...trade }, networkClientId, chainId, txFee) => {
31
- if (skipGasFields) {
32
- return {};
33
- }
34
- if (txFee) {
35
- return { ...txFee, gas: gasLimit?.toString() };
36
- }
37
- const transactionParams = {
38
- ...trade,
39
- gas: gasLimit?.toString(),
40
- data: trade.data,
41
- to: trade.to,
42
- value: trade.value,
43
- };
44
- const { gasFeeEstimates } = messenger.call('GasFeeController:getState');
45
- const { estimates: txGasFeeEstimates } = await messenger.call('TransactionController:estimateGasFee', { transactionParams, chainId, networkClientId });
46
- const { maxFeePerGas, maxPriorityFeePerGas } = getTxGasEstimates({
47
- networkGasFeeEstimates: gasFeeEstimates,
48
- txGasFeeEstimates,
49
- });
50
- const maxGasLimit = toHex(transactionParams.gas ?? 0);
51
- return {
52
- maxFeePerGas,
53
- maxPriorityFeePerGas,
54
- gas: maxGasLimit,
55
- };
56
- };
57
2
  const calcGasInHexWei = (gasLimit, gasPrice) => {
58
3
  return gasLimit && gasPrice
59
4
  ? new BigNumber(gasLimit, 16).times(new BigNumber(gasPrice, 16))
@@ -1 +1 @@
1
- {"version":3,"file":"gas.mjs","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAAE,6BAA6B,EAAE,oCAAoC;AAE5E,OAAO,EAAE,KAAK,EAAE,mCAAmC;AAWnD,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAOzC,MAAM,iCAAiC,GAAG,CACxC,iBAA2C,EAC3C,gBAAwB,EACxB,EAAE;IACF,MAAM,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAC1C,iBAAiB,EAAE,CAAC,6BAA6B,CAAC,IAAI,EAAE,CAAC;IAE3D,MAAM,wBAAwB,GAAG,oBAAoB;QACnD,CAAC,CAAC,IAAI,SAAS,CAAC,gBAAgB,EAAE,EAAE,CAAC;aAChC,KAAK,CAAC,EA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AC,CAAC;SAC/B,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEhB,OAAO,iBAAiB,IAAI,iBAAiB;QAC3C,CAAC,CAAC;YACE,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,GAAG,EACD,eAAe,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI;SACxE;QACH,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport { BRIDGE_PREFERRED_GAS_ESTIMATE } from '@metamask/bridge-controller';\nimport type { TokenAmountValues, TxData } from '@metamask/bridge-controller';\nimport { toHex } from '@metamask/controller-utils';\nimport type {\n GasFeeEstimates,\n GasFeeState,\n} from '@metamask/gas-fee-controller';\nimport type {\n FeeMarketGasFeeEstimates,\n TransactionController,\n TransactionReceipt,\n} from '@metamask/transaction-controller';\nimport type { Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type {\n BridgeHistoryItem,\n BridgeStatusControllerMessenger,\n} from '../types';\n\nconst getTransaction1559GasFeeEstimates = (\n txGasFeeEstimates: FeeMarketGasFeeEstimates,\n estimatedBaseFee: string,\n) => {\n const { maxFeePerGas, maxPriorityFeePerGas } =\n txGasFeeEstimates?.[BRIDGE_PREFERRED_GAS_ESTIMATE] ?? {};\n\n const baseAndPriorityFeePerGas = maxPriorityFeePerGas\n ? new BigNumber(estimatedBaseFee, 10)\n .times(10 ** 9)\n .plus(maxPriorityFeePerGas, 16)\n : undefined;\n\n return {\n baseAndPriorityFeePerGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n};\n\n/**\n * Get the gas fee estimates for a transaction\n *\n * @param params - The parameters for the gas fee estimates\n * @param params.txGasFeeEstimates - The gas fee estimates for the transaction (TransactionController)\n * @param params.networkGasFeeEstimates - The gas fee estimates for the network (GasFeeController)\n * @returns The gas fee estimates for the transaction\n */\nexport const getTxGasEstimates = ({\n txGasFeeEstimates,\n networkGasFeeEstimates,\n}: {\n txGasFeeEstimates: Awaited<\n ReturnType<TransactionController['estimateGasFee']>\n >['estimates'];\n networkGasFeeEstimates: GasFeeState['gasFeeEstimates'];\n}) => {\n const { estimatedBaseFee = '0' } = networkGasFeeEstimates as GasFeeEstimates;\n return getTransaction1559GasFeeEstimates(\n txGasFeeEstimates as unknown as FeeMarketGasFeeEstimates,\n estimatedBaseFee,\n );\n};\n\nexport const calculateGasFees = async (\n skipGasFields: boolean,\n messenger: BridgeStatusControllerMessenger,\n { chainId: _, gasLimit, ...trade }: TxData,\n networkClientId: string,\n chainId: Hex,\n txFee?: { maxFeePerGas: string; maxPriorityFeePerGas: string },\n) => {\n if (skipGasFields) {\n return {};\n }\n if (txFee) {\n return { ...txFee, gas: gasLimit?.toString() };\n }\n const transactionParams = {\n ...trade,\n gas: gasLimit?.toString(),\n data: trade.data as `0x${string}`,\n to: trade.to as `0x${string}`,\n value: trade.value as `0x${string}`,\n };\n const { gasFeeEstimates } = messenger.call('GasFeeController:getState');\n const { estimates: txGasFeeEstimates } = await messenger.call(\n 'TransactionController:estimateGasFee',\n { transactionParams, chainId, networkClientId },\n );\n const { maxFeePerGas, maxPriorityFeePerGas } = getTxGasEstimates({\n networkGasFeeEstimates: gasFeeEstimates,\n txGasFeeEstimates,\n });\n const maxGasLimit = toHex(transactionParams.gas ?? 0);\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n gas: maxGasLimit,\n };\n};\n\nconst calcGasInHexWei = (gasLimit?: string, gasPrice?: string) => {\n return gasLimit && gasPrice\n ? new BigNumber(gasLimit, 16).times(new BigNumber(gasPrice, 16))\n : null;\n};\n\n/**\n * Calculate the effective gas used for a transaction and its approval tx\n *\n * @param bridgeHistoryItem - The bridge history item\n * @param bridgeHistoryItem.pricingData - pricing data from the submitted quote\n * @param txReceipt - tx receipt from the txMeta\n * @param approvalTxReceipt - tx receipt from the approvalTxMeta\n * @returns The actual gas used for the transaction in Wei and its value in USD\n */\nexport const calcActualGasUsed = (\n { pricingData }: BridgeHistoryItem,\n txReceipt?: TransactionReceipt,\n approvalTxReceipt?: TransactionReceipt,\n): Omit<TokenAmountValues, 'valueInCurrency'> | null => {\n const usdExchangeRate =\n pricingData?.quotedGasInUsd && pricingData?.quotedGasAmount\n ? new BigNumber(pricingData?.quotedGasInUsd).div(\n pricingData.quotedGasAmount,\n )\n : null;\n\n const actualGasInHexWei = calcGasInHexWei(\n txReceipt?.gasUsed,\n txReceipt?.effectiveGasPrice,\n )?.plus(\n calcGasInHexWei(\n approvalTxReceipt?.gasUsed,\n approvalTxReceipt?.effectiveGasPrice,\n ) ?? 0,\n );\n\n const actualGasInDecEth = actualGasInHexWei\n ?.div(new BigNumber(10).pow(18))\n .toString(10);\n\n return actualGasInHexWei && actualGasInDecEth\n ? {\n amount: actualGasInHexWei.toString(10),\n usd:\n usdExchangeRate?.multipliedBy(actualGasInDecEth).toString(10) ?? null,\n }\n : null;\n};\n"]}
1
+ {"version":3,"file":"gas.mjs","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAIzC,MAAM,eAAe,GAAG,CAAC,QAAiB,EAAE,QAAiB,EAAE,EAAE;IAC/D,OAAO,QAAQ,IAAI,QAAQ;QACzB,CAAC,CAAC,IAAI,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAChE,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,EAAE,WAAW,EAAqB,EAClC,SAA8B,EAC9B,iBAAsC,EACa,EAAE;IACrD,MAAM,eAAe,GACnB,WAAW,EAAE,cAAc,IAAI,WAAW,EAAE,eAAe;QACzD,CAAC,CAAC,IAAI,SAAS,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,GAAG,CAC5C,WAAW,CAAC,eAAe,CAC5B;QACH,CAAC,CAAC,IAAI,CAAC;IAEX,MAAM,iBAAiB,GAAG,eAAe,CACvC,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,iBAAiB,CAC7B,EAAE,IAAI,CACL,eAAe,CACb,iBAAiB,EAAE,OAAO,EAC1B,iBAAiB,EAAE,iBAAiB,CACrC,IAAI,CAAC,CACP,CAAC;IAEF,MAAM,iBAAiB,GAAG,iBAAiB;QACzC,EAAE,GAAG,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;SAC/B,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEhB,OAAO,iBAAiB,IAAI,iBAAiB;QAC3C,CAAC,CAAC;YACE,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,GAAG,EACD,eAAe,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI;SACxE;QACH,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport type { TokenAmountValues } from '@metamask/bridge-controller';\nimport type { TransactionReceipt } from '@metamask/transaction-controller';\nimport { BigNumber } from 'bignumber.js';\n\nimport type { BridgeHistoryItem } from '../types';\n\nconst calcGasInHexWei = (gasLimit?: string, gasPrice?: string) => {\n return gasLimit && gasPrice\n ? new BigNumber(gasLimit, 16).times(new BigNumber(gasPrice, 16))\n : null;\n};\n\n/**\n * Calculate the effective gas used for a transaction and its approval tx\n *\n * @param bridgeHistoryItem - The bridge history item\n * @param bridgeHistoryItem.pricingData - pricing data from the submitted quote\n * @param txReceipt - tx receipt from the txMeta\n * @param approvalTxReceipt - tx receipt from the approvalTxMeta\n * @returns The actual gas used for the transaction in Wei and its value in USD\n */\nexport const calcActualGasUsed = (\n { pricingData }: BridgeHistoryItem,\n txReceipt?: TransactionReceipt,\n approvalTxReceipt?: TransactionReceipt,\n): Omit<TokenAmountValues, 'valueInCurrency'> | null => {\n const usdExchangeRate =\n pricingData?.quotedGasInUsd && pricingData?.quotedGasAmount\n ? new BigNumber(pricingData?.quotedGasInUsd).div(\n pricingData.quotedGasAmount,\n )\n : null;\n\n const actualGasInHexWei = calcGasInHexWei(\n txReceipt?.gasUsed,\n txReceipt?.effectiveGasPrice,\n )?.plus(\n calcGasInHexWei(\n approvalTxReceipt?.gasUsed,\n approvalTxReceipt?.effectiveGasPrice,\n ) ?? 0,\n );\n\n const actualGasInDecEth = actualGasInHexWei\n ?.div(new BigNumber(10).pow(18))\n .toString(10);\n\n return actualGasInHexWei && actualGasInDecEth\n ? {\n amount: actualGasInHexWei.toString(10),\n usd:\n usdExchangeRate?.multipliedBy(actualGasInDecEth).toString(10) ?? null,\n }\n : null;\n};\n"]}