@metamask-previews/bridge-status-controller 71.2.1-preview-d3514bcb5 → 71.2.1-preview-ce4057bcb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -5
- package/dist/bridge-status-controller-method-action-types.cjs.map +1 -1
- package/dist/bridge-status-controller-method-action-types.d.cts +5 -1
- package/dist/bridge-status-controller-method-action-types.d.cts.map +1 -1
- package/dist/bridge-status-controller-method-action-types.d.mts +5 -1
- package/dist/bridge-status-controller-method-action-types.d.mts.map +1 -1
- package/dist/bridge-status-controller-method-action-types.mjs.map +1 -1
- package/dist/bridge-status-controller.cjs +161 -374
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +27 -7
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +27 -7
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +162 -378
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/strategy/batch-sell-strategy.cjs +101 -0
- package/dist/strategy/batch-sell-strategy.cjs.map +1 -0
- package/dist/strategy/batch-sell-strategy.d.cts +10 -0
- package/dist/strategy/batch-sell-strategy.d.cts.map +1 -0
- package/dist/strategy/batch-sell-strategy.d.mts +10 -0
- package/dist/strategy/batch-sell-strategy.d.mts.map +1 -0
- package/dist/strategy/batch-sell-strategy.mjs +97 -0
- package/dist/strategy/batch-sell-strategy.mjs.map +1 -0
- package/dist/strategy/batch-strategy.cjs +64 -0
- package/dist/strategy/batch-strategy.cjs.map +1 -0
- package/dist/strategy/batch-strategy.d.cts +10 -0
- package/dist/strategy/batch-strategy.d.cts.map +1 -0
- package/dist/strategy/batch-strategy.d.mts +10 -0
- package/dist/strategy/batch-strategy.d.mts.map +1 -0
- package/dist/strategy/batch-strategy.mjs +60 -0
- package/dist/strategy/batch-strategy.mjs.map +1 -0
- package/dist/strategy/evm-strategy.cjs +149 -0
- package/dist/strategy/evm-strategy.cjs.map +1 -0
- package/dist/strategy/evm-strategy.d.cts +38 -0
- package/dist/strategy/evm-strategy.d.cts.map +1 -0
- package/dist/strategy/evm-strategy.d.mts +38 -0
- package/dist/strategy/evm-strategy.d.mts.map +1 -0
- package/dist/strategy/evm-strategy.mjs +143 -0
- package/dist/strategy/evm-strategy.mjs.map +1 -0
- package/dist/strategy/index.cjs +70 -0
- package/dist/strategy/index.cjs.map +1 -0
- package/dist/strategy/index.d.cts +12 -0
- package/dist/strategy/index.d.cts.map +1 -0
- package/dist/strategy/index.d.mts +12 -0
- package/dist/strategy/index.d.mts.map +1 -0
- package/dist/strategy/index.mjs +68 -0
- package/dist/strategy/index.mjs.map +1 -0
- package/dist/strategy/intent-strategy.cjs +160 -0
- package/dist/strategy/intent-strategy.cjs.map +1 -0
- package/dist/strategy/intent-strategy.d.cts +17 -0
- package/dist/strategy/intent-strategy.d.cts.map +1 -0
- package/dist/strategy/intent-strategy.d.mts +17 -0
- package/dist/strategy/intent-strategy.d.mts.map +1 -0
- package/dist/strategy/intent-strategy.mjs +156 -0
- package/dist/strategy/intent-strategy.mjs.map +1 -0
- package/dist/strategy/non-evm-strategy.cjs +80 -0
- package/dist/strategy/non-evm-strategy.cjs.map +1 -0
- package/dist/strategy/non-evm-strategy.d.cts +15 -0
- package/dist/strategy/non-evm-strategy.d.cts.map +1 -0
- package/dist/strategy/non-evm-strategy.d.mts +15 -0
- package/dist/strategy/non-evm-strategy.d.mts.map +1 -0
- package/dist/strategy/non-evm-strategy.mjs +76 -0
- package/dist/strategy/non-evm-strategy.mjs.map +1 -0
- package/dist/strategy/types.cjs +13 -0
- package/dist/strategy/types.cjs.map +1 -0
- package/dist/strategy/types.d.cts +77 -0
- package/dist/strategy/types.d.cts.map +1 -0
- package/dist/strategy/types.d.mts +77 -0
- package/dist/strategy/types.d.mts.map +1 -0
- package/dist/strategy/types.mjs +10 -0
- package/dist/strategy/types.mjs.map +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +16 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +16 -4
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/bridge.cjs +5 -1
- package/dist/utils/bridge.cjs.map +1 -1
- package/dist/utils/bridge.d.cts +2 -2
- package/dist/utils/bridge.d.cts.map +1 -1
- package/dist/utils/bridge.d.mts +2 -2
- package/dist/utils/bridge.d.mts.map +1 -1
- package/dist/utils/bridge.mjs +3 -0
- package/dist/utils/bridge.mjs.map +1 -1
- package/dist/utils/history.cjs +72 -20
- package/dist/utils/history.cjs.map +1 -1
- package/dist/utils/history.d.cts +19 -5
- package/dist/utils/history.d.cts.map +1 -1
- package/dist/utils/history.d.mts +19 -5
- package/dist/utils/history.d.mts.map +1 -1
- package/dist/utils/history.mjs +69 -19
- package/dist/utils/history.mjs.map +1 -1
- package/dist/utils/metrics.cjs +10 -7
- package/dist/utils/metrics.cjs.map +1 -1
- package/dist/utils/metrics.d.cts +7 -6
- package/dist/utils/metrics.d.cts.map +1 -1
- package/dist/utils/metrics.d.mts +7 -6
- package/dist/utils/metrics.d.mts.map +1 -1
- package/dist/utils/metrics.mjs +10 -7
- package/dist/utils/metrics.mjs.map +1 -1
- package/dist/utils/trace.cjs +4 -4
- package/dist/utils/trace.cjs.map +1 -1
- package/dist/utils/trace.d.cts +2 -2
- package/dist/utils/trace.d.cts.map +1 -1
- package/dist/utils/trace.d.mts +2 -2
- package/dist/utils/trace.d.mts.map +1 -1
- package/dist/utils/trace.mjs +4 -4
- package/dist/utils/trace.mjs.map +1 -1
- package/dist/utils/transaction.cjs +80 -54
- package/dist/utils/transaction.cjs.map +1 -1
- package/dist/utils/transaction.d.cts +25 -31
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +25 -31
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/transaction.mjs +76 -52
- package/dist/utils/transaction.mjs.map +1 -1
- package/package.json +2 -2
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA0CA,+CAA4D;AAG5D,8EAA8E;AAC9E,2BAA2B;AAE3B,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAyCD,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,wBAAR,QAAQ,QAanB;AA+FD;;;GAGG;AACH,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,kCAAlB,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 SimulatedGasFeeLimits,\n TxData,\n TxFeeGasLimits,\n} from '@metamask/bridge-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 { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusControllerMethodActions } from './bridge-status-controller-method-action-types';\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\n/**\n * This type ties together the quote, its tx params and the submitted txMeta.\n * Each trade/approval will have its own QuoteAndTxMetadata object.\n */\nexport type QuoteAndTxMetadata = {\n type: TransactionType;\n quoteResponse: QuoteResponse & QuoteMetadata;\n /**\n * The approval or trade object from the quote response\n */\n tx: TxData;\n assetsFiatValues?: { sending?: string; receiving?: string };\n /**\n * The simulated gas fee limits for the transaction provided by the bridge-api\n */\n txFee?: SimulatedGasFeeLimits | TxFeeGasLimits;\n /**\n * Transaction metadata from the TransactionController after submission\n */\n txMeta?: TransactionMeta;\n};\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 * Client-supplied security classification for the destination token at the\n * time the swap/bridge was submitted. Persisted so post-submit analytics\n * events (Completed, Failed, StatusValidationFailed) can include\n * `token_security_type_destination`. `null` when no security data was\n * available for the destination token.\n */\n tokenSecurityTypeDestination?: string | null;\n};\n\n/**\n * @deprecated Use the separate action types instead (e.g.\n * `BridgeStatusControllerStartPollingForBridgeTxStatusAction`).\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 // Client-supplied destination token security classification, persisted on\n // the history item for post-submit analytics events.\n tokenSecurityTypeDestination?: BridgeHistoryItem['tokenSecurityTypeDestination'];\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\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerMethodActions;\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 | RemoteFeatureFlagControllerGetStateAction\n | SnapControllerHandleRequestAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerAction<BridgeBackgroundAction.TRACK_METAMETRICS_EVENT>\n | BridgeControllerAction<BridgeBackgroundAction.STOP_POLLING_FOR_QUOTES>\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent;\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.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA4CA,+CAA4D;AAG5D,8EAA8E;AAC9E,2BAA2B;AAE3B,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAyCD,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,wBAAR,QAAQ,QAanB;AAyGD;;;GAGG;AACH,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,kCAAlB,kBAAkB,QAS7B","sourcesContent":["import type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type {\n ChainId,\n FeatureId,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n MetaMetricsSwapsEventSource,\n SimulatedGasFeeLimits,\n TxData,\n TxFeeGasLimits,\n BridgeControllerTrackUnifiedSwapBridgeEventAction,\n BridgeControllerStopPollingForQuotesAction,\n BatchSellTradesResponse,\n BridgeControllerGetStateAction,\n} from '@metamask/bridge-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 { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusControllerMethodActions } from './bridge-status-controller-method-action-types';\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\n/**\n * This type ties together the quote, its tx params and the submitted txMeta.\n * Each trade/approval will have its own QuoteAndTxMetadata object.\n */\nexport type QuoteAndTxMetadata = {\n type: TransactionType;\n quoteResponse: QuoteResponse & QuoteMetadata;\n /**\n * The approval or trade object from the quote response\n */\n tx: TxData;\n assetsFiatValues?: { sending?: string; receiving?: string };\n /**\n * The simulated gas fee limits for the transaction provided by the bridge-api\n */\n txFee?: SimulatedGasFeeLimits | TxFeeGasLimits;\n /**\n * Transaction metadata from the TransactionController after submission\n */\n txMeta?: TransactionMeta;\n};\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 /**\n * This is defined when the history item is for a batch sell transaction\n */\n batchSellData?: BatchSellTradesResponse;\n /**\n * This is defined when the history item corresponds to the 7702 batch's delegation tx.\n * It contains the list of quoteIds for the BatchSell quotes that are part of the 7702 batch.\n * Each quote can be retrieved from txHistory as `txHistory[quoteId]`.\n */\n quoteIds?: 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 * Client-supplied security classification for the destination token at the\n * time the swap/bridge was submitted. Persisted so post-submit analytics\n * events (Completed, Failed, StatusValidationFailed) can include\n * `token_security_type_destination`. `null` when no security data was\n * available for the destination token.\n */\n tokenSecurityTypeDestination?: string | null;\n};\n\n/**\n * @deprecated Use the separate action types instead (e.g.\n * `BridgeStatusControllerStartPollingForBridgeTxStatusAction`).\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 batchSellData?: BridgeHistoryItem['batchSellData'];\n quoteIds?: BridgeHistoryItem['quoteIds'];\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: MetaMetricsSwapsEventSource;\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 // Client-supplied destination token security classification, persisted on\n // the history item for post-submit analytics events.\n tokenSecurityTypeDestination?: BridgeHistoryItem['tokenSecurityTypeDestination'];\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 & QuoteMetadata;\n};\n\nexport type SourceChainTxMetaId = string;\n\nexport type BridgeStatusControllerState = {\n txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;\n};\n\n// Actions\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerMethodActions;\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 | RemoteFeatureFlagControllerGetStateAction\n | SnapControllerHandleRequestAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerGetStateAction\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent;\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"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccountsControllerGetAccountByAddressAction } from "@metamask/accounts-controller";
|
|
2
2
|
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ChainId, FeatureId, Quote, QuoteMetadata, QuoteResponse, MetaMetricsSwapsEventSource, SimulatedGasFeeLimits, TxData, TxFeeGasLimits, BridgeControllerTrackUnifiedSwapBridgeEventAction, BridgeControllerStopPollingForQuotesAction, BatchSellTradesResponse, BridgeControllerGetStateAction } from "@metamask/bridge-controller";
|
|
4
4
|
import type { KeyringControllerSignTypedMessageAction } from "@metamask/keyring-controller";
|
|
5
5
|
import type { Messenger } from "@metamask/messenger";
|
|
6
6
|
import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction } from "@metamask/network-controller";
|
|
@@ -93,6 +93,16 @@ export type BridgeHistoryItem = {
|
|
|
93
93
|
*/
|
|
94
94
|
originalTransactionId?: string;
|
|
95
95
|
batchId?: string;
|
|
96
|
+
/**
|
|
97
|
+
* This is defined when the history item is for a batch sell transaction
|
|
98
|
+
*/
|
|
99
|
+
batchSellData?: BatchSellTradesResponse;
|
|
100
|
+
/**
|
|
101
|
+
* This is defined when the history item corresponds to the 7702 batch's delegation tx.
|
|
102
|
+
* It contains the list of quoteIds for the BatchSell quotes that are part of the 7702 batch.
|
|
103
|
+
* Each quote can be retrieved from txHistory as `txHistory[quoteId]`.
|
|
104
|
+
*/
|
|
105
|
+
quoteIds?: string[];
|
|
96
106
|
quote: Quote;
|
|
97
107
|
status: StatusResponse;
|
|
98
108
|
startTime: number;
|
|
@@ -206,6 +216,8 @@ export type QuoteMetadataSerialized = {
|
|
|
206
216
|
export type StartPollingForBridgeTxStatusArgs = {
|
|
207
217
|
bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;
|
|
208
218
|
actionId?: string;
|
|
219
|
+
batchSellData?: BridgeHistoryItem['batchSellData'];
|
|
220
|
+
quoteIds?: BridgeHistoryItem['quoteIds'];
|
|
209
221
|
/**
|
|
210
222
|
* @deprecated the txMeta or orderUid should be used instead
|
|
211
223
|
*/
|
|
@@ -217,7 +229,7 @@ export type StartPollingForBridgeTxStatusArgs = {
|
|
|
217
229
|
targetContractAddress?: BridgeHistoryItem['targetContractAddress'];
|
|
218
230
|
approvalTxId?: BridgeHistoryItem['approvalTxId'];
|
|
219
231
|
isStxEnabled?: BridgeHistoryItem['isStxEnabled'];
|
|
220
|
-
location
|
|
232
|
+
location: MetaMetricsSwapsEventSource;
|
|
221
233
|
abTests?: BridgeHistoryItem['abTests'];
|
|
222
234
|
activeAbTests?: BridgeHistoryItem['activeAbTests'];
|
|
223
235
|
accountAddress: string;
|
|
@@ -229,7 +241,7 @@ export type StartPollingForBridgeTxStatusArgs = {
|
|
|
229
241
|
* so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action
|
|
230
242
|
*/
|
|
231
243
|
export type StartPollingForBridgeTxStatusArgsSerialized = Omit<StartPollingForBridgeTxStatusArgs, 'quoteResponse'> & {
|
|
232
|
-
quoteResponse: QuoteResponse &
|
|
244
|
+
quoteResponse: QuoteResponse & QuoteMetadata;
|
|
233
245
|
};
|
|
234
246
|
export type SourceChainTxMetaId = string;
|
|
235
247
|
export type BridgeStatusControllerState = {
|
|
@@ -250,7 +262,7 @@ export type BridgeStatusControllerEvents = BridgeStatusControllerStateChangeEven
|
|
|
250
262
|
/**
|
|
251
263
|
* The external actions available to the BridgeStatusController.
|
|
252
264
|
*/
|
|
253
|
-
type AllowedActions = NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | RemoteFeatureFlagControllerGetStateAction | SnapControllerHandleRequestAction | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction | TransactionControllerAddTransactionAction | TransactionControllerEstimateGasFeeAction | TransactionControllerIsAtomicBatchSupportedAction |
|
|
265
|
+
type AllowedActions = NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | RemoteFeatureFlagControllerGetStateAction | SnapControllerHandleRequestAction | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction | TransactionControllerAddTransactionAction | TransactionControllerEstimateGasFeeAction | TransactionControllerIsAtomicBatchSupportedAction | BridgeControllerTrackUnifiedSwapBridgeEventAction | BridgeControllerStopPollingForQuotesAction | BridgeControllerGetStateAction | AccountsControllerGetAccountByAddressAction | AuthenticationControllerGetBearerTokenAction | KeyringControllerSignTypedMessageAction;
|
|
254
266
|
/**
|
|
255
267
|
* The external events available to the BridgeStatusController.
|
|
256
268
|
*/
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","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,
|
|
1
|
+
{"version":3,"file":"types.d.cts","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,OAAO,EACP,SAAS,EACT,KAAK,EACL,aAAa,EACb,aAAa,EACb,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,EACN,cAAc,EACd,iDAAiD,EACjD,0CAA0C,EAC1C,uBAAuB,EACvB,8BAA8B,EAC/B,oCAAoC;AACrC,OAAO,KAAK,EAAE,uCAAuC,EAAE,qCAAqC;AAC5F,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CAA2C,EAC3C,+BAA+B,EAChC,qCAAqC;AACtC,OAAO,KAAK,EAAE,4CAA4C,EAAE,+CAA+C;AAC3G,OAAO,KAAK,EAAE,yCAAyC,EAAE,iDAAiD;AAC1G,OAAO,KAAK,EAAE,iCAAiC,EAAE,oCAAoC;AACrF,OAAO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AC/D,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,4BAA4B,GACpC,sCAAsC,GACtC,0DAA0D,CAAC;AAE/D;;GAEG;AACH,KAAK,cAAc,GACf,mDAAmD,GACnD,+BAA+B,GAC/B,2CAA2C,GAC3C,yCAAyC,GACzC,iCAAiC,GACjC,mCAAmC,GACnC,4CAA4C,GAC5C,yCAAyC,GACzC,yCAAyC,GACzC,iDAAiD,GACjD,iDAAiD,GACjD,0CAA0C,GAC1C,8BAA8B,GAC9B,2CAA2C,GAC3C,4CAA4C,GAC5C,uCAAuC,CAAC;AAE5C;;GAEG;AACH,KAAK,aAAa,GAAG,kDAAkD,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,6BAA6B,EACpC,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccountsControllerGetAccountByAddressAction } from "@metamask/accounts-controller";
|
|
2
2
|
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ChainId, FeatureId, Quote, QuoteMetadata, QuoteResponse, MetaMetricsSwapsEventSource, SimulatedGasFeeLimits, TxData, TxFeeGasLimits, BridgeControllerTrackUnifiedSwapBridgeEventAction, BridgeControllerStopPollingForQuotesAction, BatchSellTradesResponse, BridgeControllerGetStateAction } from "@metamask/bridge-controller";
|
|
4
4
|
import type { KeyringControllerSignTypedMessageAction } from "@metamask/keyring-controller";
|
|
5
5
|
import type { Messenger } from "@metamask/messenger";
|
|
6
6
|
import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction } from "@metamask/network-controller";
|
|
@@ -93,6 +93,16 @@ export type BridgeHistoryItem = {
|
|
|
93
93
|
*/
|
|
94
94
|
originalTransactionId?: string;
|
|
95
95
|
batchId?: string;
|
|
96
|
+
/**
|
|
97
|
+
* This is defined when the history item is for a batch sell transaction
|
|
98
|
+
*/
|
|
99
|
+
batchSellData?: BatchSellTradesResponse;
|
|
100
|
+
/**
|
|
101
|
+
* This is defined when the history item corresponds to the 7702 batch's delegation tx.
|
|
102
|
+
* It contains the list of quoteIds for the BatchSell quotes that are part of the 7702 batch.
|
|
103
|
+
* Each quote can be retrieved from txHistory as `txHistory[quoteId]`.
|
|
104
|
+
*/
|
|
105
|
+
quoteIds?: string[];
|
|
96
106
|
quote: Quote;
|
|
97
107
|
status: StatusResponse;
|
|
98
108
|
startTime: number;
|
|
@@ -206,6 +216,8 @@ export type QuoteMetadataSerialized = {
|
|
|
206
216
|
export type StartPollingForBridgeTxStatusArgs = {
|
|
207
217
|
bridgeTxMeta?: Pick<TransactionMeta, 'id' | 'hash' | 'batchId'>;
|
|
208
218
|
actionId?: string;
|
|
219
|
+
batchSellData?: BridgeHistoryItem['batchSellData'];
|
|
220
|
+
quoteIds?: BridgeHistoryItem['quoteIds'];
|
|
209
221
|
/**
|
|
210
222
|
* @deprecated the txMeta or orderUid should be used instead
|
|
211
223
|
*/
|
|
@@ -217,7 +229,7 @@ export type StartPollingForBridgeTxStatusArgs = {
|
|
|
217
229
|
targetContractAddress?: BridgeHistoryItem['targetContractAddress'];
|
|
218
230
|
approvalTxId?: BridgeHistoryItem['approvalTxId'];
|
|
219
231
|
isStxEnabled?: BridgeHistoryItem['isStxEnabled'];
|
|
220
|
-
location
|
|
232
|
+
location: MetaMetricsSwapsEventSource;
|
|
221
233
|
abTests?: BridgeHistoryItem['abTests'];
|
|
222
234
|
activeAbTests?: BridgeHistoryItem['activeAbTests'];
|
|
223
235
|
accountAddress: string;
|
|
@@ -229,7 +241,7 @@ export type StartPollingForBridgeTxStatusArgs = {
|
|
|
229
241
|
* so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action
|
|
230
242
|
*/
|
|
231
243
|
export type StartPollingForBridgeTxStatusArgsSerialized = Omit<StartPollingForBridgeTxStatusArgs, 'quoteResponse'> & {
|
|
232
|
-
quoteResponse: QuoteResponse &
|
|
244
|
+
quoteResponse: QuoteResponse & QuoteMetadata;
|
|
233
245
|
};
|
|
234
246
|
export type SourceChainTxMetaId = string;
|
|
235
247
|
export type BridgeStatusControllerState = {
|
|
@@ -250,7 +262,7 @@ export type BridgeStatusControllerEvents = BridgeStatusControllerStateChangeEven
|
|
|
250
262
|
/**
|
|
251
263
|
* The external actions available to the BridgeStatusController.
|
|
252
264
|
*/
|
|
253
|
-
type AllowedActions = NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | RemoteFeatureFlagControllerGetStateAction | SnapControllerHandleRequestAction | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction | TransactionControllerAddTransactionAction | TransactionControllerEstimateGasFeeAction | TransactionControllerIsAtomicBatchSupportedAction |
|
|
265
|
+
type AllowedActions = NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | RemoteFeatureFlagControllerGetStateAction | SnapControllerHandleRequestAction | TransactionControllerGetStateAction | TransactionControllerUpdateTransactionAction | TransactionControllerAddTransactionAction | TransactionControllerEstimateGasFeeAction | TransactionControllerIsAtomicBatchSupportedAction | BridgeControllerTrackUnifiedSwapBridgeEventAction | BridgeControllerStopPollingForQuotesAction | BridgeControllerGetStateAction | AccountsControllerGetAccountByAddressAction | AuthenticationControllerGetBearerTokenAction | KeyringControllerSignTypedMessageAction;
|
|
254
266
|
/**
|
|
255
267
|
* The external events available to the BridgeStatusController.
|
|
256
268
|
*/
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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AAa,GAAG,kDAAkD,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,SAAS,CACrD,OAAO,6BAA6B,EACpC,6BAA6B,GAAG,cAAc,EAC9C,4BAA4B,GAAG,aAAa,CAC7C,CAAC"}
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA0CA,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;AA+FD;;;GAGG;AACH,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 SimulatedGasFeeLimits,\n TxData,\n TxFeeGasLimits,\n} from '@metamask/bridge-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 { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusControllerMethodActions } from './bridge-status-controller-method-action-types';\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\n/**\n * This type ties together the quote, its tx params and the submitted txMeta.\n * Each trade/approval will have its own QuoteAndTxMetadata object.\n */\nexport type QuoteAndTxMetadata = {\n type: TransactionType;\n quoteResponse: QuoteResponse & QuoteMetadata;\n /**\n * The approval or trade object from the quote response\n */\n tx: TxData;\n assetsFiatValues?: { sending?: string; receiving?: string };\n /**\n * The simulated gas fee limits for the transaction provided by the bridge-api\n */\n txFee?: SimulatedGasFeeLimits | TxFeeGasLimits;\n /**\n * Transaction metadata from the TransactionController after submission\n */\n txMeta?: TransactionMeta;\n};\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 * Client-supplied security classification for the destination token at the\n * time the swap/bridge was submitted. Persisted so post-submit analytics\n * events (Completed, Failed, StatusValidationFailed) can include\n * `token_security_type_destination`. `null` when no security data was\n * available for the destination token.\n */\n tokenSecurityTypeDestination?: string | null;\n};\n\n/**\n * @deprecated Use the separate action types instead (e.g.\n * `BridgeStatusControllerStartPollingForBridgeTxStatusAction`).\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 // Client-supplied destination token security classification, persisted on\n // the history item for post-submit analytics events.\n tokenSecurityTypeDestination?: BridgeHistoryItem['tokenSecurityTypeDestination'];\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\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerMethodActions;\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 | RemoteFeatureFlagControllerGetStateAction\n | SnapControllerHandleRequestAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerAction<BridgeBackgroundAction.TRACK_METAMETRICS_EVENT>\n | BridgeControllerAction<BridgeBackgroundAction.STOP_POLLING_FOR_QUOTES>\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent;\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":"AA4CA,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;AAyGD;;;GAGG;AACH,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 ChainId,\n FeatureId,\n Quote,\n QuoteMetadata,\n QuoteResponse,\n MetaMetricsSwapsEventSource,\n SimulatedGasFeeLimits,\n TxData,\n TxFeeGasLimits,\n BridgeControllerTrackUnifiedSwapBridgeEventAction,\n BridgeControllerStopPollingForQuotesAction,\n BatchSellTradesResponse,\n BridgeControllerGetStateAction,\n} from '@metamask/bridge-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 { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n TransactionControllerAddTransactionAction,\n TransactionControllerEstimateGasFeeAction,\n TransactionControllerGetStateAction,\n TransactionControllerIsAtomicBatchSupportedAction,\n TransactionControllerTransactionStatusUpdatedEvent,\n TransactionControllerUpdateTransactionAction,\n TransactionMeta,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { CaipAssetType } from '@metamask/utils';\n\nimport type { BridgeStatusControllerMethodActions } from './bridge-status-controller-method-action-types';\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\n/**\n * This type ties together the quote, its tx params and the submitted txMeta.\n * Each trade/approval will have its own QuoteAndTxMetadata object.\n */\nexport type QuoteAndTxMetadata = {\n type: TransactionType;\n quoteResponse: QuoteResponse & QuoteMetadata;\n /**\n * The approval or trade object from the quote response\n */\n tx: TxData;\n assetsFiatValues?: { sending?: string; receiving?: string };\n /**\n * The simulated gas fee limits for the transaction provided by the bridge-api\n */\n txFee?: SimulatedGasFeeLimits | TxFeeGasLimits;\n /**\n * Transaction metadata from the TransactionController after submission\n */\n txMeta?: TransactionMeta;\n};\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 /**\n * This is defined when the history item is for a batch sell transaction\n */\n batchSellData?: BatchSellTradesResponse;\n /**\n * This is defined when the history item corresponds to the 7702 batch's delegation tx.\n * It contains the list of quoteIds for the BatchSell quotes that are part of the 7702 batch.\n * Each quote can be retrieved from txHistory as `txHistory[quoteId]`.\n */\n quoteIds?: 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 * Client-supplied security classification for the destination token at the\n * time the swap/bridge was submitted. Persisted so post-submit analytics\n * events (Completed, Failed, StatusValidationFailed) can include\n * `token_security_type_destination`. `null` when no security data was\n * available for the destination token.\n */\n tokenSecurityTypeDestination?: string | null;\n};\n\n/**\n * @deprecated Use the separate action types instead (e.g.\n * `BridgeStatusControllerStartPollingForBridgeTxStatusAction`).\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 batchSellData?: BridgeHistoryItem['batchSellData'];\n quoteIds?: BridgeHistoryItem['quoteIds'];\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: MetaMetricsSwapsEventSource;\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 // Client-supplied destination token security classification, persisted on\n // the history item for post-submit analytics events.\n tokenSecurityTypeDestination?: BridgeHistoryItem['tokenSecurityTypeDestination'];\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 & QuoteMetadata;\n};\n\nexport type SourceChainTxMetaId = string;\n\nexport type BridgeStatusControllerState = {\n txHistory: Record<SourceChainTxMetaId, BridgeHistoryItem>;\n};\n\n// Actions\nexport type BridgeStatusControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_STATUS_CONTROLLER_NAME,\n BridgeStatusControllerState\n>;\n\nexport type BridgeStatusControllerActions =\n | BridgeStatusControllerGetStateAction\n | BridgeStatusControllerMethodActions;\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 | RemoteFeatureFlagControllerGetStateAction\n | SnapControllerHandleRequestAction\n | TransactionControllerGetStateAction\n | TransactionControllerUpdateTransactionAction\n | TransactionControllerAddTransactionAction\n | TransactionControllerEstimateGasFeeAction\n | TransactionControllerIsAtomicBatchSupportedAction\n | BridgeControllerTrackUnifiedSwapBridgeEventAction\n | BridgeControllerStopPollingForQuotesAction\n | BridgeControllerGetStateAction\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | KeyringControllerSignTypedMessageAction;\n\n/**\n * The external events available to the BridgeStatusController.\n */\ntype AllowedEvents = TransactionControllerTransactionStatusUpdatedEvent;\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"]}
|
package/dist/utils/bridge.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.trackMetricsEvent = exports.stopPollingForQuotes = void 0;
|
|
3
|
+
exports.trackMetricsEvent = exports.getBatchSellTrades = exports.stopPollingForQuotes = void 0;
|
|
4
4
|
const bridge_controller_1 = require("@metamask/bridge-controller");
|
|
5
5
|
const stopPollingForQuotes = (messenger, featureId, metricsContext) => {
|
|
6
6
|
messenger.call('BridgeController:stopPollingForQuotes', bridge_controller_1.AbortReason.TransactionSubmitted,
|
|
@@ -9,6 +9,10 @@ const stopPollingForQuotes = (messenger, featureId, metricsContext) => {
|
|
|
9
9
|
featureId ? undefined : metricsContext);
|
|
10
10
|
};
|
|
11
11
|
exports.stopPollingForQuotes = stopPollingForQuotes;
|
|
12
|
+
const getBatchSellTrades = (messenger) => {
|
|
13
|
+
return messenger.call('BridgeController:getState').batchSellTrades;
|
|
14
|
+
};
|
|
15
|
+
exports.getBatchSellTrades = getBatchSellTrades;
|
|
12
16
|
const trackMetricsEvent = ({ messenger, eventName, properties, }) => {
|
|
13
17
|
messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, properties);
|
|
14
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.cjs","sourceRoot":"","sources":["../../src/utils/bridge.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"bridge.cjs","sourceRoot":"","sources":["../../src/utils/bridge.ts"],"names":[],"mappings":";;;AAAA,mEAMqC;AAI9B,MAAM,oBAAoB,GAAG,CAClC,SAA0C,EAC1C,SAAqB,EACrB,cAA0F,EACpF,EAAE;IACR,SAAS,CAAC,IAAI,CACZ,uCAAuC,EACvC,+BAAW,CAAC,oBAAoB;IAChC,4FAA4F;IAC5F,qJAAqJ;IACrJ,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CACvC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B;AAEK,MAAM,kBAAkB,GAAG,CAChC,SAA0C,EACV,EAAE;IAClC,OAAO,SAAS,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,eAAe,CAAC;AACrE,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B;AAEK,MAAM,iBAAiB,GAAG,CAAC,EAChC,SAAS,EACT,SAAS,EACT,UAAU,GAKX,EAAQ,EAAE;IACT,SAAS,CAAC,IAAI,CACZ,8CAA8C,EAC9C,SAAS,EACT,UAAU,CACX,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,iBAAiB,qBAc5B","sourcesContent":["import {\n AbortReason,\n FeatureId,\n UnifiedSwapBridgeEventName,\n BatchSellTradesResponse,\n RequiredEventContextFromClient,\n} from '@metamask/bridge-controller';\n\nimport { BridgeStatusControllerMessenger } from '../types';\n\nexport const stopPollingForQuotes = (\n messenger: BridgeStatusControllerMessenger,\n featureId?: FeatureId,\n metricsContext?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n): void => {\n messenger.call(\n 'BridgeController:stopPollingForQuotes',\n AbortReason.TransactionSubmitted,\n // If trade is submitted before all quotes are loaded, the QuotesReceived event is published\n // If the trade has a featureId, it means it was submitted outside of the Unified Swap and Bridge experience, so no QuotesReceived event is published\n featureId ? undefined : metricsContext,\n );\n};\n\nexport const getBatchSellTrades = (\n messenger: BridgeStatusControllerMessenger,\n): BatchSellTradesResponse | null => {\n return messenger.call('BridgeController:getState').batchSellTrades;\n};\n\nexport const trackMetricsEvent = ({\n messenger,\n eventName,\n properties,\n}: {\n messenger: BridgeStatusControllerMessenger;\n eventName: UnifiedSwapBridgeEventName;\n properties: RequiredEventContextFromClient[UnifiedSwapBridgeEventName];\n}): void => {\n messenger.call(\n 'BridgeController:trackUnifiedSwapBridgeEvent',\n eventName,\n properties,\n );\n};\n"]}
|
package/dist/utils/bridge.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FeatureId, UnifiedSwapBridgeEventName } from "@metamask/bridge-controller";
|
|
2
|
-
import type { RequiredEventContextFromClient } from "@metamask/bridge-controller";
|
|
1
|
+
import { FeatureId, UnifiedSwapBridgeEventName, BatchSellTradesResponse, RequiredEventContextFromClient } from "@metamask/bridge-controller";
|
|
3
2
|
import { BridgeStatusControllerMessenger } from "../types.cjs";
|
|
4
3
|
export declare const stopPollingForQuotes: (messenger: BridgeStatusControllerMessenger, featureId?: FeatureId, metricsContext?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived]) => void;
|
|
4
|
+
export declare const getBatchSellTrades: (messenger: BridgeStatusControllerMessenger) => BatchSellTradesResponse | null;
|
|
5
5
|
export declare const trackMetricsEvent: ({ messenger, eventName, properties, }: {
|
|
6
6
|
messenger: BridgeStatusControllerMessenger;
|
|
7
7
|
eventName: UnifiedSwapBridgeEventName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.cts","sourceRoot":"","sources":["../../src/utils/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,0BAA0B,
|
|
1
|
+
{"version":3,"file":"bridge.d.cts","sourceRoot":"","sources":["../../src/utils/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,0BAA0B,EAC1B,uBAAuB,EACvB,8BAA8B,EAC/B,oCAAoC;AAErC,OAAO,EAAE,+BAA+B,EAAE,qBAAiB;AAE3D,eAAO,MAAM,oBAAoB,2DAEnB,SAAS,mBACJ,8BAA8B,CAAC,2BAA2B,cAAc,CAAC,KACzF,IAQF,CAAC;AAEF,eAAO,MAAM,kBAAkB,kDAE5B,uBAAuB,GAAG,IAE5B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;eAMjB,0BAA0B;gBACzB,8BAA8B,CAAC,0BAA0B,CAAC;MACpE,IAMH,CAAC"}
|
package/dist/utils/bridge.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FeatureId, UnifiedSwapBridgeEventName } from "@metamask/bridge-controller";
|
|
2
|
-
import type { RequiredEventContextFromClient } from "@metamask/bridge-controller";
|
|
1
|
+
import { FeatureId, UnifiedSwapBridgeEventName, BatchSellTradesResponse, RequiredEventContextFromClient } from "@metamask/bridge-controller";
|
|
3
2
|
import { BridgeStatusControllerMessenger } from "../types.mjs";
|
|
4
3
|
export declare const stopPollingForQuotes: (messenger: BridgeStatusControllerMessenger, featureId?: FeatureId, metricsContext?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived]) => void;
|
|
4
|
+
export declare const getBatchSellTrades: (messenger: BridgeStatusControllerMessenger) => BatchSellTradesResponse | null;
|
|
5
5
|
export declare const trackMetricsEvent: ({ messenger, eventName, properties, }: {
|
|
6
6
|
messenger: BridgeStatusControllerMessenger;
|
|
7
7
|
eventName: UnifiedSwapBridgeEventName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.mts","sourceRoot":"","sources":["../../src/utils/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,0BAA0B,
|
|
1
|
+
{"version":3,"file":"bridge.d.mts","sourceRoot":"","sources":["../../src/utils/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,0BAA0B,EAC1B,uBAAuB,EACvB,8BAA8B,EAC/B,oCAAoC;AAErC,OAAO,EAAE,+BAA+B,EAAE,qBAAiB;AAE3D,eAAO,MAAM,oBAAoB,2DAEnB,SAAS,mBACJ,8BAA8B,CAAC,2BAA2B,cAAc,CAAC,KACzF,IAQF,CAAC;AAEF,eAAO,MAAM,kBAAkB,kDAE5B,uBAAuB,GAAG,IAE5B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;eAMjB,0BAA0B;gBACzB,8BAA8B,CAAC,0BAA0B,CAAC;MACpE,IAMH,CAAC"}
|
package/dist/utils/bridge.mjs
CHANGED
|
@@ -5,6 +5,9 @@ export const stopPollingForQuotes = (messenger, featureId, metricsContext) => {
|
|
|
5
5
|
// If the trade has a featureId, it means it was submitted outside of the Unified Swap and Bridge experience, so no QuotesReceived event is published
|
|
6
6
|
featureId ? undefined : metricsContext);
|
|
7
7
|
};
|
|
8
|
+
export const getBatchSellTrades = (messenger) => {
|
|
9
|
+
return messenger.call('BridgeController:getState').batchSellTrades;
|
|
10
|
+
};
|
|
8
11
|
export const trackMetricsEvent = ({ messenger, eventName, properties, }) => {
|
|
9
12
|
messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, properties);
|
|
10
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.mjs","sourceRoot":"","sources":["../../src/utils/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,0BAA0B,
|
|
1
|
+
{"version":3,"file":"bridge.mjs","sourceRoot":"","sources":["../../src/utils/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,0BAA0B,EAG3B,oCAAoC;AAIrC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,SAA0C,EAC1C,SAAqB,EACrB,cAA0F,EACpF,EAAE;IACR,SAAS,CAAC,IAAI,CACZ,uCAAuC,EACvC,WAAW,CAAC,oBAAoB;IAChC,4FAA4F;IAC5F,qJAAqJ;IACrJ,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CACvC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,SAA0C,EACV,EAAE;IAClC,OAAO,SAAS,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,eAAe,CAAC;AACrE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,SAAS,EACT,SAAS,EACT,UAAU,GAKX,EAAQ,EAAE;IACT,SAAS,CAAC,IAAI,CACZ,8CAA8C,EAC9C,SAAS,EACT,UAAU,CACX,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n AbortReason,\n FeatureId,\n UnifiedSwapBridgeEventName,\n BatchSellTradesResponse,\n RequiredEventContextFromClient,\n} from '@metamask/bridge-controller';\n\nimport { BridgeStatusControllerMessenger } from '../types';\n\nexport const stopPollingForQuotes = (\n messenger: BridgeStatusControllerMessenger,\n featureId?: FeatureId,\n metricsContext?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n): void => {\n messenger.call(\n 'BridgeController:stopPollingForQuotes',\n AbortReason.TransactionSubmitted,\n // If trade is submitted before all quotes are loaded, the QuotesReceived event is published\n // If the trade has a featureId, it means it was submitted outside of the Unified Swap and Bridge experience, so no QuotesReceived event is published\n featureId ? undefined : metricsContext,\n );\n};\n\nexport const getBatchSellTrades = (\n messenger: BridgeStatusControllerMessenger,\n): BatchSellTradesResponse | null => {\n return messenger.call('BridgeController:getState').batchSellTrades;\n};\n\nexport const trackMetricsEvent = ({\n messenger,\n eventName,\n properties,\n}: {\n messenger: BridgeStatusControllerMessenger;\n eventName: UnifiedSwapBridgeEventName;\n properties: RequiredEventContextFromClient[UnifiedSwapBridgeEventName];\n}): void => {\n messenger.call(\n 'BridgeController:trackUnifiedSwapBridgeEvent',\n eventName,\n properties,\n );\n};\n"]}
|
package/dist/utils/history.cjs
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isHistoryItemTooOld = exports.shouldPollHistoryItem = exports.getInitialHistoryItem = exports.getHistoryKey = exports.getMatchingHistoryEntryForApprovalTxMeta = exports.getMatchingHistoryEntryForTxMeta = exports.rekeyHistoryItemInState = void 0;
|
|
3
|
+
exports.isHistoryItemTooOld = exports.shouldPollHistoryItem = exports.getInitialHistoryItem = exports.getHistoryKey = exports.getBatchSellHistoryItemsForTxHash = exports.getMatchingHistoryEntryForApprovalTxMeta = exports.getMatchingHistoryEntryForTxMeta = exports.isBatchSellHistoryItem = exports.rekeyHistoryItemInState = void 0;
|
|
4
4
|
const bridge_controller_1 = require("@metamask/bridge-controller");
|
|
5
5
|
const feature_flags_1 = require("./feature-flags.cjs");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
state.txHistory[txMeta.id] = {
|
|
12
|
-
...historyItem,
|
|
6
|
+
const updateHistoryItem = (oldHistoryItem, txMeta) => {
|
|
7
|
+
return {
|
|
8
|
+
...oldHistoryItem,
|
|
13
9
|
txMetaId: txMeta.id,
|
|
14
|
-
originalTransactionId:
|
|
10
|
+
originalTransactionId: oldHistoryItem.originalTransactionId ?? txMeta.id,
|
|
15
11
|
status: {
|
|
16
|
-
...
|
|
12
|
+
...oldHistoryItem.status,
|
|
17
13
|
srcChain: {
|
|
18
|
-
...
|
|
19
|
-
txHash: txMeta.hash ??
|
|
14
|
+
...oldHistoryItem.status.srcChain,
|
|
15
|
+
txHash: txMeta.hash ?? oldHistoryItem.status.srcChain?.txHash,
|
|
20
16
|
},
|
|
21
17
|
},
|
|
22
18
|
};
|
|
23
|
-
|
|
19
|
+
};
|
|
20
|
+
const rekeyHistoryItemInState = (state, oldKey, newKey, txMeta) => {
|
|
21
|
+
const historyItem = state.txHistory[oldKey];
|
|
22
|
+
if (!historyItem) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
state.txHistory[newKey] = {
|
|
26
|
+
...historyItem,
|
|
27
|
+
...updateHistoryItem(historyItem, txMeta),
|
|
28
|
+
};
|
|
29
|
+
delete state.txHistory[oldKey];
|
|
24
30
|
return true;
|
|
25
31
|
};
|
|
26
32
|
exports.rekeyHistoryItemInState = rekeyHistoryItemInState;
|
|
33
|
+
const isBatchSellHistoryItem = (historyItem) => Boolean(historyItem?.batchSellData);
|
|
34
|
+
exports.isBatchSellHistoryItem = isBatchSellHistoryItem;
|
|
27
35
|
/**
|
|
28
36
|
* Returns the history entry that matches the txMeta by id, actionId, batchId, or txHash
|
|
29
37
|
*
|
|
@@ -39,7 +47,12 @@ const getMatchingHistoryEntryForTxMeta = (txHistory, txMeta) => {
|
|
|
39
47
|
key === txMeta.actionId ||
|
|
40
48
|
txMetaId === txMeta.id ||
|
|
41
49
|
(actionId ? actionId === txMeta.actionId : false) ||
|
|
42
|
-
(
|
|
50
|
+
// When the batch is not atomic (BatchSell), ignore batchId matching to prevent txs
|
|
51
|
+
// in the batch from getting marked complete/failed too early if one fails
|
|
52
|
+
// Multiple BatchSell STX trades may have the same batchId
|
|
53
|
+
(Boolean(batchId) &&
|
|
54
|
+
!(0, exports.isBatchSellHistoryItem)(value) &&
|
|
55
|
+
batchId === txMeta.batchId) ||
|
|
43
56
|
(txHash ? txHash.toLowerCase() === txMeta.hash?.toLowerCase() : false));
|
|
44
57
|
});
|
|
45
58
|
};
|
|
@@ -56,10 +69,47 @@ const getMatchingHistoryEntryForApprovalTxMeta = (txHistory, txMeta) => {
|
|
|
56
69
|
return historyEntries.find(([_, value]) => value.approvalTxId ? value.approvalTxId === txMeta.id : false);
|
|
57
70
|
};
|
|
58
71
|
exports.getMatchingHistoryEntryForApprovalTxMeta = getMatchingHistoryEntryForApprovalTxMeta;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the BatchSell history items in the same batch as the provided tx hash.
|
|
74
|
+
*
|
|
75
|
+
* @param txHistory - The bridge status controller's history to search for matching history items
|
|
76
|
+
* @param txHashOrId - the hash or txMeta.id of a single trade in a BatchSell
|
|
77
|
+
* @returns The matching history items for the tx hash and a boolean indicating if it's a 7702 batch.
|
|
78
|
+
* @example
|
|
79
|
+
* getBatchSellHistoryItemsForTxHash(txHistory, id)
|
|
80
|
+
* If id is the hash or txMetaId of a BatchSell trade, it will return the history items for
|
|
81
|
+
* the trade and all other trades in the same batch.
|
|
82
|
+
*/
|
|
83
|
+
const getBatchSellHistoryItemsForTxHash = (txHistory, txHashOrId) => {
|
|
84
|
+
const historyItems = Object.values(txHistory);
|
|
85
|
+
if (!txHashOrId) {
|
|
86
|
+
return {
|
|
87
|
+
historyItems: [],
|
|
88
|
+
is7702Batch: false,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Either a delegation tx or a single STX BatchSell trade
|
|
93
|
+
*/
|
|
94
|
+
const parentHistoryItem = historyItems.find(({ status, txMetaId }) => status.srcChain.txHash?.toLowerCase() === txHashOrId.toLowerCase() ||
|
|
95
|
+
txMetaId === txHashOrId);
|
|
96
|
+
// Match by batchId or by quoteId
|
|
97
|
+
const matchingHistoryItems = parentHistoryItem?.quoteIds?.map((quoteId) => txHistory[quoteId]) ??
|
|
98
|
+
historyItems.filter(({ batchId }) => batchId &&
|
|
99
|
+
parentHistoryItem?.batchId &&
|
|
100
|
+
batchId === parentHistoryItem.batchId);
|
|
101
|
+
return {
|
|
102
|
+
historyItems: matchingHistoryItems.filter((item) => item !== undefined),
|
|
103
|
+
is7702Batch: Boolean(parentHistoryItem) &&
|
|
104
|
+
Boolean(parentHistoryItem?.quoteIds?.length),
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
exports.getBatchSellHistoryItemsForTxHash = getBatchSellHistoryItemsForTxHash;
|
|
59
108
|
/**
|
|
60
109
|
* Determines the key to use for storing a bridge history item.
|
|
61
110
|
* Uses actionId for pre-submission tracking, or bridgeTxMetaId for post-submission.
|
|
62
111
|
*
|
|
112
|
+
* @deprecated specify an explicit history key instead
|
|
63
113
|
* @param actionId - The action ID used for pre-submission tracking
|
|
64
114
|
* @param bridgeTxMetaId - The transaction meta ID from bridgeTxMeta
|
|
65
115
|
* @param syntheticTransactionId - The transactionId of the intent's placeholder transaction
|
|
@@ -75,11 +125,7 @@ function getHistoryKey(actionId, bridgeTxMetaId, syntheticTransactionId) {
|
|
|
75
125
|
}
|
|
76
126
|
exports.getHistoryKey = getHistoryKey;
|
|
77
127
|
const getInitialHistoryItem = (args) => {
|
|
78
|
-
const { bridgeTxMeta, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, location, abTests, activeAbTests, accountAddress: selectedAddress, originalTransactionId, actionId, tokenSecurityTypeDestination, } = args;
|
|
79
|
-
// Determine the key for this history item:
|
|
80
|
-
// - For pre-submission (non-batch EVM): use actionId
|
|
81
|
-
// - For post-submission or other cases: use bridgeTxMeta.id
|
|
82
|
-
const historyKey = getHistoryKey(actionId, bridgeTxMeta?.id, originalTransactionId);
|
|
128
|
+
const { bridgeTxMeta, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, location, abTests, activeAbTests, accountAddress: selectedAddress, originalTransactionId, actionId, tokenSecurityTypeDestination, batchSellData, quoteIds, } = args;
|
|
83
129
|
// Write all non-status fields to state so we can reference the quote in Activity list without the Bridge API
|
|
84
130
|
// We know it's in progress but not the exact status yet
|
|
85
131
|
const txHistoryItem = {
|
|
@@ -125,7 +171,13 @@ const getInitialHistoryItem = (args) => {
|
|
|
125
171
|
tokenSecurityTypeDestination,
|
|
126
172
|
}),
|
|
127
173
|
};
|
|
128
|
-
|
|
174
|
+
if (batchSellData) {
|
|
175
|
+
txHistoryItem.batchSellData = batchSellData;
|
|
176
|
+
}
|
|
177
|
+
if (quoteIds) {
|
|
178
|
+
txHistoryItem.quoteIds = quoteIds;
|
|
179
|
+
}
|
|
180
|
+
return txHistoryItem;
|
|
129
181
|
};
|
|
130
182
|
exports.getInitialHistoryItem = getInitialHistoryItem;
|
|
131
183
|
const shouldPollHistoryItem = (historyItem) => {
|