@metamask-previews/bridge-controller 75.2.1-preview-2a256aff2 → 75.2.1-preview-b2742a2fc
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 +6 -0
- package/dist/bridge-controller-method-action-types.cjs.map +1 -1
- package/dist/bridge-controller-method-action-types.d.cts +5 -1
- package/dist/bridge-controller-method-action-types.d.cts.map +1 -1
- package/dist/bridge-controller-method-action-types.d.mts +5 -1
- package/dist/bridge-controller-method-action-types.d.mts.map +1 -1
- package/dist/bridge-controller-method-action-types.mjs.map +1 -1
- package/dist/bridge-controller.cjs +24 -0
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts +2 -1
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts +2 -1
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +24 -0
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/constants/bridge.cjs +3 -0
- package/dist/constants/bridge.cjs.map +1 -1
- package/dist/constants/bridge.d.cts +5 -2
- package/dist/constants/bridge.d.cts.map +1 -1
- package/dist/constants/bridge.d.mts +5 -2
- package/dist/constants/bridge.d.mts.map +1 -1
- package/dist/constants/bridge.mjs +4 -1
- package/dist/constants/bridge.mjs.map +1 -1
- package/dist/constants/tokens.cjs +10 -0
- package/dist/constants/tokens.cjs.map +1 -1
- package/dist/constants/tokens.d.cts +7 -0
- package/dist/constants/tokens.d.cts.map +1 -1
- package/dist/constants/tokens.d.mts +7 -0
- package/dist/constants/tokens.d.mts.map +1 -1
- package/dist/constants/tokens.mjs +11 -1
- package/dist/constants/tokens.mjs.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.d.cts +800 -0
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +800 -0
- package/dist/selectors.d.mts.map +1 -1
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +12 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +12 -2
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/bridge.cjs +18 -3
- package/dist/utils/bridge.cjs.map +1 -1
- package/dist/utils/bridge.d.cts +8 -1
- package/dist/utils/bridge.d.cts.map +1 -1
- package/dist/utils/bridge.d.mts +8 -1
- package/dist/utils/bridge.d.mts.map +1 -1
- package/dist/utils/bridge.mjs +17 -3
- package/dist/utils/bridge.mjs.map +1 -1
- package/dist/utils/caip-formatters.cjs +9 -0
- package/dist/utils/caip-formatters.cjs.map +1 -1
- package/dist/utils/caip-formatters.d.cts.map +1 -1
- package/dist/utils/caip-formatters.d.mts.map +1 -1
- package/dist/utils/caip-formatters.mjs +11 -2
- package/dist/utils/caip-formatters.mjs.map +1 -1
- package/dist/utils/metrics/constants.cjs +1 -0
- package/dist/utils/metrics/constants.cjs.map +1 -1
- package/dist/utils/metrics/constants.d.cts +1 -0
- package/dist/utils/metrics/constants.d.cts.map +1 -1
- package/dist/utils/metrics/constants.d.mts +1 -0
- package/dist/utils/metrics/constants.d.mts.map +1 -1
- package/dist/utils/metrics/constants.mjs +1 -0
- package/dist/utils/metrics/constants.mjs.map +1 -1
- package/dist/utils/metrics/types.cjs.map +1 -1
- package/dist/utils/metrics/types.d.cts +25 -9
- package/dist/utils/metrics/types.d.cts.map +1 -1
- package/dist/utils/metrics/types.d.mts +25 -9
- package/dist/utils/metrics/types.d.mts.map +1 -1
- package/dist/utils/metrics/types.mjs.map +1 -1
- package/dist/utils/trade-utils.cjs +39 -6
- package/dist/utils/trade-utils.cjs.map +1 -1
- package/dist/utils/trade-utils.d.cts +13 -2
- package/dist/utils/trade-utils.d.cts.map +1 -1
- package/dist/utils/trade-utils.d.mts +13 -2
- package/dist/utils/trade-utils.d.mts.map +1 -1
- package/dist/utils/trade-utils.mjs +37 -5
- package/dist/utils/trade-utils.mjs.map +1 -1
- package/dist/utils/validators.cjs +9 -1
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +20 -0
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +20 -0
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +8 -0
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type { FeatureId, SortOrder, StatusTypes } from '../../types';\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n PollingStatus,\n} from './constants';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n /**\n * Client-supplied security classification for the destination token\n * (e.g. from token security/scanning data). Stored on the controller\n * and merged into every analytics event that includes\n * `token_address_destination`. Pass `null` when no security data is\n * available for the selected destination token.\n */\n token_security_type_destination: string | null;\n};\n\nexport type AccountHardwareType =\n | 'Ledger'\n | 'Trezor'\n | 'QR Hardware'\n | 'Lattice'\n | null;\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n account_hardware_type: AccountHardwareType;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n has_gas_included_quote: boolean;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n token_amount_source: string;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'market_closed'\n | 'price_impact'\n | 'quote_expired'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This is the base type without the `location` property which is added to all events\n * via the RequiredEventContextFromClient mapped type.\n */\ntype RequiredEventContextFromClientBase = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { environment_type?: string };\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n input_value: InputValues[keyof InputValues];\n input_amount_preset?: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n usd_balance_source?: number;\n has_sufficient_gas_for_quote?: boolean | null;\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n | 'token_security_type_destination'\n > & {\n action_type: MetricsActionType;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.Failed]: (\n | // Tx failed before confirmation\n (Pick<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'is_hardware_wallet'\n | 'account_hardware_type'\n > &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'token_security_type_destination'\n >)\n // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n TxStatusData & {\n actual_time_minutes: number;\n })\n ) &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n error_message: string;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: {\n polling_status: PollingStatus;\n retry_attempts: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n refresh_count: number;\n };\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: {\n asset_location: 'source' | 'destination';\n };\n};\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This combines the event-specific properties from RequiredEventContextFromClientBase\n * with an optional `location` property. When `location` is omitted, the controller\n * falls back to the value stored via `setLocation()` (defaults to MainView).\n *\n * `ab_tests` is the legacy field and `active_ab_tests` is the newer field.\n * Both are kept for a migration window and are treated as separate payloads.\n */\nexport type RequiredEventContextFromClient = {\n [K in keyof RequiredEventContextFromClientBase]: RequiredEventContextFromClientBase[K] & {\n location?: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n feature_id: FeatureId;\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams &\n Omit<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'security_warnings'\n >;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams;\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: null;\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n batch_id?: string;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n *\n * `ab_tests` will be deprecated in favor of `active_ab_tests` in the future.\n * `ab_tests` and `active_ab_tests` intentionally coexist during migration.\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n feature_id: FeatureId;\n action_type: MetricsActionType;\n location: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n FeatureId,\n InputPrimaryDenomination,\n SortOrder,\n StatusTypes,\n} from '../../types';\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n PollingStatus,\n} from './constants';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n /**\n * Client-supplied security classification for the destination token\n * (e.g. from token security/scanning data). Stored on the controller\n * and merged into every analytics event that includes\n * `token_address_destination`. Pass `null` when no security data is\n * available for the selected destination token.\n */\n token_security_type_destination: string | null;\n};\n\nexport type AccountHardwareType =\n | 'Ledger'\n | 'Trezor'\n | 'QR Hardware'\n | 'Lattice'\n | null;\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n account_hardware_type: AccountHardwareType;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n has_gas_included_quote: boolean;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputPrimaryDenominationData = {\n input_primary_denomination?: InputPrimaryDenomination;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n token_amount_source: string;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'market_closed'\n | 'price_impact'\n | 'quote_expired'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This is the base type without the `location` property which is added to all events\n * via the RequiredEventContextFromClient mapped type.\n */\ntype RequiredEventContextFromClientBase = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { environment_type?: string };\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n input_value: InputValues[keyof InputValues];\n input_amount_preset?: string;\n };\n [UnifiedSwapBridgeEventName.FiatCryptoToggleClicked]: {\n token_symbol_source: string;\n token_symbol_destination: string | null;\n previous_primary_denomination: InputPrimaryDenomination;\n new_primary_denomination: InputPrimaryDenomination;\n chain_id_source?: RequestParams['chain_id_source'];\n chain_id_destination?: RequestParams['chain_id_destination'];\n token_address_source?: RequestParams['token_address_source'];\n token_address_destination?: RequestParams['token_address_destination'];\n token_security_type_destination?: RequestParams['token_security_type_destination'];\n swap_type?: RequestMetadata['swap_type'];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> &\n InputPrimaryDenominationData & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n usd_balance_source?: number;\n has_sufficient_gas_for_quote?: boolean | null;\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n | 'token_security_type_destination'\n > & {\n action_type: MetricsActionType;\n batch_id?: string;\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n batch_id?: string;\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.Failed]: (\n | // Tx failed before confirmation\n (Pick<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'is_hardware_wallet'\n | 'account_hardware_type'\n > &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'token_security_type_destination'\n >)\n // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n TxStatusData & {\n actual_time_minutes: number;\n })\n ) &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n error_message: string;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: {\n polling_status: PollingStatus;\n retry_attempts: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n refresh_count: number;\n } & Partial<RequestParams>;\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: {\n asset_location: 'source' | 'destination';\n };\n};\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This combines the event-specific properties from RequiredEventContextFromClientBase\n * with an optional `location` property. When `location` is omitted, the controller\n * falls back to the value stored via `setLocation()` (defaults to MainView).\n *\n * `ab_tests` is the legacy field and `active_ab_tests` is the newer field.\n * Both are kept for a migration window and are treated as separate payloads.\n */\nexport type RequiredEventContextFromClient = {\n [K in keyof RequiredEventContextFromClientBase]: RequiredEventContextFromClientBase[K] & {\n location?: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n feature_id: FeatureId;\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams &\n Omit<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'security_warnings'\n > &\n InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.FiatCryptoToggleClicked]: RequestParams &\n Pick<RequestMetadata, 'swap_type'>;\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams;\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: null;\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n batch_id?: string;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n *\n * `ab_tests` will be deprecated in favor of `active_ab_tests` in the future.\n * `ab_tests` and `active_ab_tests` intentionally coexist during migration.\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n feature_id: FeatureId;\n action_type: MetricsActionType;\n location: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CaipAssetType, CaipChainId } from "@metamask/utils";
|
|
2
|
-
import type { FeatureId, SortOrder, StatusTypes } from "../../types.cjs";
|
|
2
|
+
import type { FeatureId, InputPrimaryDenomination, SortOrder, StatusTypes } from "../../types.cjs";
|
|
3
3
|
import type { UnifiedSwapBridgeEventName, MetaMetricsSwapsEventSource, MetricsActionType, MetricsSwapType, PollingStatus } from "./constants.cjs";
|
|
4
4
|
/**
|
|
5
5
|
* These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml
|
|
@@ -54,6 +54,9 @@ export type TxStatusData = {
|
|
|
54
54
|
source_transaction?: StatusTypes;
|
|
55
55
|
destination_transaction?: StatusTypes;
|
|
56
56
|
};
|
|
57
|
+
export type InputPrimaryDenominationData = {
|
|
58
|
+
input_primary_denomination?: InputPrimaryDenomination;
|
|
59
|
+
};
|
|
57
60
|
export type InputKeys = 'token_source' | 'token_destination' | 'chain_source' | 'chain_destination' | 'slippage' | 'token_amount_source';
|
|
58
61
|
export type InputValues = {
|
|
59
62
|
token_source: CaipAssetType;
|
|
@@ -79,6 +82,18 @@ type RequiredEventContextFromClientBase = {
|
|
|
79
82
|
input_value: InputValues[keyof InputValues];
|
|
80
83
|
input_amount_preset?: string;
|
|
81
84
|
};
|
|
85
|
+
[UnifiedSwapBridgeEventName.FiatCryptoToggleClicked]: {
|
|
86
|
+
token_symbol_source: string;
|
|
87
|
+
token_symbol_destination: string | null;
|
|
88
|
+
previous_primary_denomination: InputPrimaryDenomination;
|
|
89
|
+
new_primary_denomination: InputPrimaryDenomination;
|
|
90
|
+
chain_id_source?: RequestParams['chain_id_source'];
|
|
91
|
+
chain_id_destination?: RequestParams['chain_id_destination'];
|
|
92
|
+
token_address_source?: RequestParams['token_address_source'];
|
|
93
|
+
token_address_destination?: RequestParams['token_address_destination'];
|
|
94
|
+
token_security_type_destination?: RequestParams['token_security_type_destination'];
|
|
95
|
+
swap_type?: RequestMetadata['swap_type'];
|
|
96
|
+
};
|
|
82
97
|
[UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {
|
|
83
98
|
token_symbol_source: RequestParams['token_symbol_source'];
|
|
84
99
|
token_symbol_destination: RequestParams['token_symbol_destination'];
|
|
@@ -92,8 +107,8 @@ type RequiredEventContextFromClientBase = {
|
|
|
92
107
|
token_symbol_source: RequestParams['token_symbol_source'];
|
|
93
108
|
token_symbol_destination: RequestParams['token_symbol_destination'];
|
|
94
109
|
token_security_type_destination: RequestParams['token_security_type_destination'];
|
|
95
|
-
};
|
|
96
|
-
[UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {
|
|
110
|
+
} & InputPrimaryDenominationData;
|
|
111
|
+
[UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & InputPrimaryDenominationData & {
|
|
97
112
|
warnings: QuoteWarning[];
|
|
98
113
|
best_quote_provider: QuoteFetchData['best_quote_provider'];
|
|
99
114
|
price_impact: QuoteFetchData['price_impact'];
|
|
@@ -108,7 +123,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
108
123
|
[UnifiedSwapBridgeEventName.Submitted]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'token_address_source' | 'token_address_destination' | 'chain_id_source' | 'chain_id_destination' | 'token_security_type_destination'> & {
|
|
109
124
|
action_type: MetricsActionType;
|
|
110
125
|
batch_id?: string;
|
|
111
|
-
};
|
|
126
|
+
} & InputPrimaryDenominationData;
|
|
112
127
|
[UnifiedSwapBridgeEventName.Completed]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & TxStatusData & RequestParams & {
|
|
113
128
|
actual_time_minutes: number;
|
|
114
129
|
usd_actual_return: number;
|
|
@@ -117,7 +132,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
117
132
|
quoted_vs_used_gas_ratio: number;
|
|
118
133
|
action_type: MetricsActionType;
|
|
119
134
|
batch_id?: string;
|
|
120
|
-
};
|
|
135
|
+
} & InputPrimaryDenominationData;
|
|
121
136
|
[UnifiedSwapBridgeEventName.Failed]: (// Tx failed before confirmation
|
|
122
137
|
(Pick<RequestMetadata, 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet' | 'account_hardware_type'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'token_address_source' | 'token_address_destination' | 'token_security_type_destination'>) | (RequestParams & RequestMetadata & TxStatusData & {
|
|
123
138
|
actual_time_minutes: number;
|
|
@@ -132,7 +147,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
132
147
|
[UnifiedSwapBridgeEventName.StatusValidationFailed]: {
|
|
133
148
|
failures: string[];
|
|
134
149
|
refresh_count: number;
|
|
135
|
-
}
|
|
150
|
+
} & Partial<RequestParams>;
|
|
136
151
|
[UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<TradeData, 'gas_included'> & Pick<QuoteFetchData, 'price_impact'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {
|
|
137
152
|
stx_enabled: RequestMetadata['stx_enabled'];
|
|
138
153
|
can_submit: QuoteFetchData['can_submit'];
|
|
@@ -188,18 +203,19 @@ export type RequiredEventContextFromClient = {
|
|
|
188
203
|
*/
|
|
189
204
|
export type EventPropertiesFromControllerState = {
|
|
190
205
|
[UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;
|
|
191
|
-
[UnifiedSwapBridgeEventName.PageViewed]: RequestParams & Omit<RequestMetadata, 'stx_enabled' | 'usd_amount_source' | 'security_warnings'
|
|
206
|
+
[UnifiedSwapBridgeEventName.PageViewed]: RequestParams & Omit<RequestMetadata, 'stx_enabled' | 'usd_amount_source' | 'security_warnings'> & InputPrimaryDenominationData;
|
|
192
207
|
[UnifiedSwapBridgeEventName.InputChanged]: {
|
|
193
208
|
input: InputKeys;
|
|
194
209
|
input_value: string;
|
|
195
210
|
};
|
|
211
|
+
[UnifiedSwapBridgeEventName.FiatCryptoToggleClicked]: RequestParams & Pick<RequestMetadata, 'swap_type'>;
|
|
196
212
|
[UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;
|
|
197
213
|
[UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams & RequestMetadata & {
|
|
198
214
|
has_sufficient_funds: boolean;
|
|
199
|
-
};
|
|
215
|
+
} & InputPrimaryDenominationData;
|
|
200
216
|
[UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams & RequestMetadata & QuoteFetchData & TradeData & {
|
|
201
217
|
refresh_count: number;
|
|
202
|
-
};
|
|
218
|
+
} & InputPrimaryDenominationData;
|
|
203
219
|
[UnifiedSwapBridgeEventName.QuotesError]: RequestParams & RequestMetadata & {
|
|
204
220
|
has_sufficient_funds: boolean;
|
|
205
221
|
error_message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,EACV,SAAS,EACT,wBAAwB,EACxB,SAAS,EACT,WAAW,EACZ,wBAAoB;AACrB,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,EACf,aAAa,EACd,wBAAoB;AAErB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,WAAW,CAAC;I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;KACnB,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,CACxC,CAAC,SAAS,0BAA0B,IAElC;IACE,UAAU,EAAE,SAAS,CAAC;IACtB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpD,GACD,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CaipAssetType, CaipChainId } from "@metamask/utils";
|
|
2
|
-
import type { FeatureId, SortOrder, StatusTypes } from "../../types.mjs";
|
|
2
|
+
import type { FeatureId, InputPrimaryDenomination, SortOrder, StatusTypes } from "../../types.mjs";
|
|
3
3
|
import type { UnifiedSwapBridgeEventName, MetaMetricsSwapsEventSource, MetricsActionType, MetricsSwapType, PollingStatus } from "./constants.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml
|
|
@@ -54,6 +54,9 @@ export type TxStatusData = {
|
|
|
54
54
|
source_transaction?: StatusTypes;
|
|
55
55
|
destination_transaction?: StatusTypes;
|
|
56
56
|
};
|
|
57
|
+
export type InputPrimaryDenominationData = {
|
|
58
|
+
input_primary_denomination?: InputPrimaryDenomination;
|
|
59
|
+
};
|
|
57
60
|
export type InputKeys = 'token_source' | 'token_destination' | 'chain_source' | 'chain_destination' | 'slippage' | 'token_amount_source';
|
|
58
61
|
export type InputValues = {
|
|
59
62
|
token_source: CaipAssetType;
|
|
@@ -79,6 +82,18 @@ type RequiredEventContextFromClientBase = {
|
|
|
79
82
|
input_value: InputValues[keyof InputValues];
|
|
80
83
|
input_amount_preset?: string;
|
|
81
84
|
};
|
|
85
|
+
[UnifiedSwapBridgeEventName.FiatCryptoToggleClicked]: {
|
|
86
|
+
token_symbol_source: string;
|
|
87
|
+
token_symbol_destination: string | null;
|
|
88
|
+
previous_primary_denomination: InputPrimaryDenomination;
|
|
89
|
+
new_primary_denomination: InputPrimaryDenomination;
|
|
90
|
+
chain_id_source?: RequestParams['chain_id_source'];
|
|
91
|
+
chain_id_destination?: RequestParams['chain_id_destination'];
|
|
92
|
+
token_address_source?: RequestParams['token_address_source'];
|
|
93
|
+
token_address_destination?: RequestParams['token_address_destination'];
|
|
94
|
+
token_security_type_destination?: RequestParams['token_security_type_destination'];
|
|
95
|
+
swap_type?: RequestMetadata['swap_type'];
|
|
96
|
+
};
|
|
82
97
|
[UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {
|
|
83
98
|
token_symbol_source: RequestParams['token_symbol_source'];
|
|
84
99
|
token_symbol_destination: RequestParams['token_symbol_destination'];
|
|
@@ -92,8 +107,8 @@ type RequiredEventContextFromClientBase = {
|
|
|
92
107
|
token_symbol_source: RequestParams['token_symbol_source'];
|
|
93
108
|
token_symbol_destination: RequestParams['token_symbol_destination'];
|
|
94
109
|
token_security_type_destination: RequestParams['token_security_type_destination'];
|
|
95
|
-
};
|
|
96
|
-
[UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {
|
|
110
|
+
} & InputPrimaryDenominationData;
|
|
111
|
+
[UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & InputPrimaryDenominationData & {
|
|
97
112
|
warnings: QuoteWarning[];
|
|
98
113
|
best_quote_provider: QuoteFetchData['best_quote_provider'];
|
|
99
114
|
price_impact: QuoteFetchData['price_impact'];
|
|
@@ -108,7 +123,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
108
123
|
[UnifiedSwapBridgeEventName.Submitted]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'token_address_source' | 'token_address_destination' | 'chain_id_source' | 'chain_id_destination' | 'token_security_type_destination'> & {
|
|
109
124
|
action_type: MetricsActionType;
|
|
110
125
|
batch_id?: string;
|
|
111
|
-
};
|
|
126
|
+
} & InputPrimaryDenominationData;
|
|
112
127
|
[UnifiedSwapBridgeEventName.Completed]: TradeData & Pick<QuoteFetchData, 'price_impact'> & Omit<RequestMetadata, 'security_warnings'> & TxStatusData & RequestParams & {
|
|
113
128
|
actual_time_minutes: number;
|
|
114
129
|
usd_actual_return: number;
|
|
@@ -117,7 +132,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
117
132
|
quoted_vs_used_gas_ratio: number;
|
|
118
133
|
action_type: MetricsActionType;
|
|
119
134
|
batch_id?: string;
|
|
120
|
-
};
|
|
135
|
+
} & InputPrimaryDenominationData;
|
|
121
136
|
[UnifiedSwapBridgeEventName.Failed]: (// Tx failed before confirmation
|
|
122
137
|
(Pick<RequestMetadata, 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet' | 'account_hardware_type'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination' | 'token_address_source' | 'token_address_destination' | 'token_security_type_destination'>) | (RequestParams & RequestMetadata & TxStatusData & {
|
|
123
138
|
actual_time_minutes: number;
|
|
@@ -132,7 +147,7 @@ type RequiredEventContextFromClientBase = {
|
|
|
132
147
|
[UnifiedSwapBridgeEventName.StatusValidationFailed]: {
|
|
133
148
|
failures: string[];
|
|
134
149
|
refresh_count: number;
|
|
135
|
-
}
|
|
150
|
+
} & Partial<RequestParams>;
|
|
136
151
|
[UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<TradeData, 'gas_included'> & Pick<QuoteFetchData, 'price_impact'> & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {
|
|
137
152
|
stx_enabled: RequestMetadata['stx_enabled'];
|
|
138
153
|
can_submit: QuoteFetchData['can_submit'];
|
|
@@ -188,18 +203,19 @@ export type RequiredEventContextFromClient = {
|
|
|
188
203
|
*/
|
|
189
204
|
export type EventPropertiesFromControllerState = {
|
|
190
205
|
[UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;
|
|
191
|
-
[UnifiedSwapBridgeEventName.PageViewed]: RequestParams & Omit<RequestMetadata, 'stx_enabled' | 'usd_amount_source' | 'security_warnings'
|
|
206
|
+
[UnifiedSwapBridgeEventName.PageViewed]: RequestParams & Omit<RequestMetadata, 'stx_enabled' | 'usd_amount_source' | 'security_warnings'> & InputPrimaryDenominationData;
|
|
192
207
|
[UnifiedSwapBridgeEventName.InputChanged]: {
|
|
193
208
|
input: InputKeys;
|
|
194
209
|
input_value: string;
|
|
195
210
|
};
|
|
211
|
+
[UnifiedSwapBridgeEventName.FiatCryptoToggleClicked]: RequestParams & Pick<RequestMetadata, 'swap_type'>;
|
|
196
212
|
[UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;
|
|
197
213
|
[UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams & RequestMetadata & {
|
|
198
214
|
has_sufficient_funds: boolean;
|
|
199
|
-
};
|
|
215
|
+
} & InputPrimaryDenominationData;
|
|
200
216
|
[UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams & RequestMetadata & QuoteFetchData & TradeData & {
|
|
201
217
|
refresh_count: number;
|
|
202
|
-
};
|
|
218
|
+
} & InputPrimaryDenominationData;
|
|
203
219
|
[UnifiedSwapBridgeEventName.QuotesError]: RequestParams & RequestMetadata & {
|
|
204
220
|
has_sufficient_funds: boolean;
|
|
205
221
|
error_message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,EACV,SAAS,EACT,wBAAwB,EACxB,SAAS,EACT,WAAW,EACZ,wBAAoB;AACrB,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,EACf,aAAa,EACd,wBAAoB;AAErB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,WAAW,CAAC;IAC7B,oBAAoB,EAAE,WAAW,GAAG,IAAI,CAAC;IACzC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,oBAAoB,EAAE,aAAa,CAAC;IACpC,yBAAyB,EAAE,aAAa,GAAG,IAAI,CAAC;IAChD;;;;;;OAMG;IACH,+BAA+B,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC3B,QAAQ,GACR,QAAQ,GACR,aAAa,GACb,SAAS,GACT,IAAI,CAAC;AAET,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,qBAAqB,EAAE,mBAAmB,CAAC;IAC3C,SAAS,EAAE,eAAe,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,C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C,0BAA0B,CAAC,sBAAsB,CAAC,EAAE,aAAa,GAAG;QACnE,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,CAAC,0BAA0B,CAAC,sBAAsB,CAAC,EAAE,aAAa,CAAC;IACnE,CAAC,0BAA0B,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACrD,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,EAAE,SAAS,GAC1D,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,GACpC,IAAI,CAAC,eAAe,EAAE,mBAAmB,CAAC,GAC1C,IAAI,CACF,aAAa,EACX,qBAAqB,GACrB,0BAA0B,GAC1B,iBAAiB,GACjB,sBAAsB,CACzB,GAAG;QACF,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,CACxC,CAAC,SAAS,0BAA0B,IAElC;IACE,UAAU,EAAE,SAAS,CAAC;IACtB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,eAAe,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpD,GACD,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type { FeatureId, SortOrder, StatusTypes } from '../../types';\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n PollingStatus,\n} from './constants';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n /**\n * Client-supplied security classification for the destination token\n * (e.g. from token security/scanning data). Stored on the controller\n * and merged into every analytics event that includes\n * `token_address_destination`. Pass `null` when no security data is\n * available for the selected destination token.\n */\n token_security_type_destination: string | null;\n};\n\nexport type AccountHardwareType =\n | 'Ledger'\n | 'Trezor'\n | 'QR Hardware'\n | 'Lattice'\n | null;\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n account_hardware_type: AccountHardwareType;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n has_gas_included_quote: boolean;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n token_amount_source: string;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'market_closed'\n | 'price_impact'\n | 'quote_expired'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This is the base type without the `location` property which is added to all events\n * via the RequiredEventContextFromClient mapped type.\n */\ntype RequiredEventContextFromClientBase = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { environment_type?: string };\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n input_value: InputValues[keyof InputValues];\n input_amount_preset?: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n usd_balance_source?: number;\n has_sufficient_gas_for_quote?: boolean | null;\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n | 'token_security_type_destination'\n > & {\n action_type: MetricsActionType;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.Failed]: (\n | // Tx failed before confirmation\n (Pick<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'is_hardware_wallet'\n | 'account_hardware_type'\n > &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'token_security_type_destination'\n >)\n // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n TxStatusData & {\n actual_time_minutes: number;\n })\n ) &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n error_message: string;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: {\n polling_status: PollingStatus;\n retry_attempts: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n refresh_count: number;\n };\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: {\n asset_location: 'source' | 'destination';\n };\n};\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This combines the event-specific properties from RequiredEventContextFromClientBase\n * with an optional `location` property. When `location` is omitted, the controller\n * falls back to the value stored via `setLocation()` (defaults to MainView).\n *\n * `ab_tests` is the legacy field and `active_ab_tests` is the newer field.\n * Both are kept for a migration window and are treated as separate payloads.\n */\nexport type RequiredEventContextFromClient = {\n [K in keyof RequiredEventContextFromClientBase]: RequiredEventContextFromClientBase[K] & {\n location?: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n feature_id: FeatureId;\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams &\n Omit<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'security_warnings'\n >;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams;\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: null;\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n batch_id?: string;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n *\n * `ab_tests` will be deprecated in favor of `active_ab_tests` in the future.\n * `ab_tests` and `active_ab_tests` intentionally coexist during migration.\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n feature_id: FeatureId;\n action_type: MetricsActionType;\n location: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n FeatureId,\n InputPrimaryDenomination,\n SortOrder,\n StatusTypes,\n} from '../../types';\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n PollingStatus,\n} from './constants';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n /**\n * Client-supplied security classification for the destination token\n * (e.g. from token security/scanning data). Stored on the controller\n * and merged into every analytics event that includes\n * `token_address_destination`. Pass `null` when no security data is\n * available for the selected destination token.\n */\n token_security_type_destination: string | null;\n};\n\nexport type AccountHardwareType =\n | 'Ledger'\n | 'Trezor'\n | 'QR Hardware'\n | 'Lattice'\n | null;\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n account_hardware_type: AccountHardwareType;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n has_gas_included_quote: boolean;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputPrimaryDenominationData = {\n input_primary_denomination?: InputPrimaryDenomination;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n token_amount_source: string;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'market_closed'\n | 'price_impact'\n | 'quote_expired'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This is the base type without the `location` property which is added to all events\n * via the RequiredEventContextFromClient mapped type.\n */\ntype RequiredEventContextFromClientBase = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { environment_type?: string };\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage'\n | 'token_amount_source';\n input_value: InputValues[keyof InputValues];\n input_amount_preset?: string;\n };\n [UnifiedSwapBridgeEventName.FiatCryptoToggleClicked]: {\n token_symbol_source: string;\n token_symbol_destination: string | null;\n previous_primary_denomination: InputPrimaryDenomination;\n new_primary_denomination: InputPrimaryDenomination;\n chain_id_source?: RequestParams['chain_id_source'];\n chain_id_destination?: RequestParams['chain_id_destination'];\n token_address_source?: RequestParams['token_address_source'];\n token_address_destination?: RequestParams['token_address_destination'];\n token_security_type_destination?: RequestParams['token_security_type_destination'];\n swap_type?: RequestMetadata['swap_type'];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_security_type_destination: RequestParams['token_security_type_destination'];\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> &\n InputPrimaryDenominationData & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n usd_balance_source?: number;\n has_sufficient_gas_for_quote?: boolean | null;\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n | 'token_security_type_destination'\n > & {\n action_type: MetricsActionType;\n batch_id?: string;\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n batch_id?: string;\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.Failed]: (\n | // Tx failed before confirmation\n (Pick<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'is_hardware_wallet'\n | 'account_hardware_type'\n > &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'token_address_source'\n | 'token_address_destination'\n | 'token_security_type_destination'\n >)\n // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n TxStatusData & {\n actual_time_minutes: number;\n })\n ) &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n error_message: string;\n batch_id?: string;\n };\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: {\n polling_status: PollingStatus;\n retry_attempts: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n refresh_count: number;\n } & Partial<RequestParams>;\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: {\n asset_location: 'source' | 'destination';\n };\n};\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called.\n * This combines the event-specific properties from RequiredEventContextFromClientBase\n * with an optional `location` property. When `location` is omitted, the controller\n * falls back to the value stored via `setLocation()` (defaults to MainView).\n *\n * `ab_tests` is the legacy field and `active_ab_tests` is the newer field.\n * Both are kept for a migration window and are treated as separate payloads.\n */\nexport type RequiredEventContextFromClient = {\n [K in keyof RequiredEventContextFromClientBase]: RequiredEventContextFromClientBase[K] & {\n location?: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n feature_id: FeatureId;\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams &\n Omit<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'security_warnings'\n > &\n InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.FiatCryptoToggleClicked]: RequestParams &\n Pick<RequestMetadata, 'swap_type'>;\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n } & InputPrimaryDenominationData;\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams;\n [UnifiedSwapBridgeEventName.AssetPickerOpened]: null;\n [UnifiedSwapBridgeEventName.PollingStatusUpdated]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n batch_id?: string;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n *\n * `ab_tests` will be deprecated in favor of `active_ab_tests` in the future.\n * `ab_tests` and `active_ab_tests` intentionally coexist during migration.\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n feature_id: FeatureId;\n action_type: MetricsActionType;\n location: MetaMetricsSwapsEventSource;\n ab_tests?: Record<string, string>;\n active_ab_tests?: { key: string; value: string }[];\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractTradeData = exports.isTronTrade = exports.isBitcoinTrade = exports.isEvmTxData = void 0;
|
|
3
|
+
exports.extractTradeData = exports.isStellarTrade = exports.isTronTrade = exports.isBitcoinTrade = exports.isEvmTxData = void 0;
|
|
4
|
+
const hasOwnProp = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
4
5
|
/**
|
|
5
6
|
* Type guard to check if a trade is an EVM TxData object
|
|
6
7
|
*
|
|
@@ -10,9 +11,9 @@ exports.extractTradeData = exports.isTronTrade = exports.isBitcoinTrade = export
|
|
|
10
11
|
const isEvmTxData = (trade) => {
|
|
11
12
|
return (typeof trade === 'object' &&
|
|
12
13
|
trade !== null &&
|
|
13
|
-
'data'
|
|
14
|
-
'chainId'
|
|
15
|
-
'to'
|
|
14
|
+
hasOwnProp(trade, 'data') &&
|
|
15
|
+
hasOwnProp(trade, 'chainId') &&
|
|
16
|
+
hasOwnProp(trade, 'to'));
|
|
16
17
|
};
|
|
17
18
|
exports.isEvmTxData = isEvmTxData;
|
|
18
19
|
/**
|
|
@@ -22,7 +23,9 @@ exports.isEvmTxData = isEvmTxData;
|
|
|
22
23
|
* @returns True if the trade is a Bitcoin trade with unsignedPsbtBase64 property
|
|
23
24
|
*/
|
|
24
25
|
const isBitcoinTrade = (trade) => {
|
|
25
|
-
return (typeof trade === 'object' &&
|
|
26
|
+
return (typeof trade === 'object' &&
|
|
27
|
+
trade !== null &&
|
|
28
|
+
hasOwnProp(trade, 'unsignedPsbtBase64'));
|
|
26
29
|
};
|
|
27
30
|
exports.isBitcoinTrade = isBitcoinTrade;
|
|
28
31
|
/**
|
|
@@ -32,9 +35,32 @@ exports.isBitcoinTrade = isBitcoinTrade;
|
|
|
32
35
|
* @returns True if the trade is a Tron trade with raw_data_hex property
|
|
33
36
|
*/
|
|
34
37
|
const isTronTrade = (trade) => {
|
|
35
|
-
return typeof trade === 'object' &&
|
|
38
|
+
return (typeof trade === 'object' &&
|
|
39
|
+
trade !== null &&
|
|
40
|
+
hasOwnProp(trade, 'raw_data_hex'));
|
|
36
41
|
};
|
|
37
42
|
exports.isTronTrade = isTronTrade;
|
|
43
|
+
/**
|
|
44
|
+
* Type guard to check if a trade is a Stellar trade with XDR (base64) payload
|
|
45
|
+
*
|
|
46
|
+
* @param trade - The trade object to check
|
|
47
|
+
* @returns True if the trade is a Stellar trade with xdrBase64 or xdr property
|
|
48
|
+
*/
|
|
49
|
+
const isStellarTrade = (trade) => {
|
|
50
|
+
if (typeof trade !== 'object' || trade === null) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (hasOwnProp(trade, 'xdrBase64') &&
|
|
54
|
+
typeof trade.xdrBase64 === 'string') {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (hasOwnProp(trade, 'xdr') &&
|
|
58
|
+
typeof trade.xdr === 'string') {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
exports.isStellarTrade = isStellarTrade;
|
|
38
64
|
/**
|
|
39
65
|
* Extracts the transaction data from different trade formats
|
|
40
66
|
*
|
|
@@ -51,6 +77,13 @@ const extractTradeData = (trade) => {
|
|
|
51
77
|
// Tron trades need hex to base64 conversion for SnapController
|
|
52
78
|
return Buffer.from(trade.raw_data_hex, 'hex').toString('base64');
|
|
53
79
|
}
|
|
80
|
+
if ((0, exports.isStellarTrade)(trade)) {
|
|
81
|
+
if (hasOwnProp(trade, 'xdrBase64') &&
|
|
82
|
+
typeof trade.xdrBase64 === 'string') {
|
|
83
|
+
return trade.xdrBase64;
|
|
84
|
+
}
|
|
85
|
+
return trade.xdr;
|
|
86
|
+
}
|
|
54
87
|
if (typeof trade === 'string') {
|
|
55
88
|
// Solana txs - assuming already in correct format
|
|
56
89
|
return trade;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trade-utils.cjs","sourceRoot":"","sources":["../../src/utils/trade-utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"trade-utils.cjs","sourceRoot":"","sources":["../../src/utils/trade-utils.ts"],"names":[],"mappings":";;;AAeA,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,GAAgB,EAAW,EAAE,CAC5D,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEjD;;;;;GAKG;AACI,MAAM,WAAW,GAAG,CAAC,KAAY,EAAmB,EAAE;IAC3D,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC;QACzB,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC;QAC5B,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CACxB,CAAC;AACJ,CAAC,CAAC;A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AAK,CAAC,EAAE,CAAC;QACvB,+DAA+D;QAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,IAAA,sBAAc,EAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,IACE,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC;YAC9B,OAAQ,KAAgC,CAAC,SAAS,KAAK,QAAQ,EAC/D,CAAC;YACD,OAAQ,KAA+B,CAAC,SAAS,CAAC;QACpD,CAAC;QACD,OAAQ,KAAyB,CAAC,GAAG,CAAC;IACxC,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,kDAAkD;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAA,mBAAW,EAAC,KAAK,CAAC,EAAE,CAAC;QACvB,+CAA+C;QAC/C,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAjCW,QAAA,gBAAgB,oBAiC3B","sourcesContent":["import type {\n BitcoinTradeData,\n StellarTradeData,\n TronTradeData,\n TxData,\n} from '../types';\n\n// Union type representing all possible trade formats (EVM, Solana, Bitcoin, Tron, Stellar)\nexport type Trade =\n | TxData\n | string\n | BitcoinTradeData\n | TronTradeData\n | StellarTradeData;\n\nconst hasOwnProp = (obj: object, key: PropertyKey): boolean =>\n Object.prototype.hasOwnProperty.call(obj, key);\n\n/**\n * Type guard to check if a trade is an EVM TxData object\n *\n * @param trade - The trade object to check\n * @returns True if the trade is a TxData object with data property\n */\nexport const isEvmTxData = (trade: Trade): trade is TxData => {\n return (\n typeof trade === 'object' &&\n trade !== null &&\n hasOwnProp(trade, 'data') &&\n hasOwnProp(trade, 'chainId') &&\n hasOwnProp(trade, 'to')\n );\n};\n\n/**\n * Type guard to check if a trade is a Bitcoin trade with unsignedPsbtBase64\n *\n * @param trade - The trade object to check\n * @returns True if the trade is a Bitcoin trade with unsignedPsbtBase64 property\n */\nexport const isBitcoinTrade = (trade: Trade): trade is BitcoinTradeData => {\n return (\n typeof trade === 'object' &&\n trade !== null &&\n hasOwnProp(trade, 'unsignedPsbtBase64')\n );\n};\n\n/**\n * Type guard to check if a trade is a Tron trade with raw_data_hex\n *\n * @param trade - The trade object to check\n * @returns True if the trade is a Tron trade with raw_data_hex property\n */\nexport const isTronTrade = (trade: Trade): trade is TronTradeData => {\n return (\n typeof trade === 'object' &&\n trade !== null &&\n hasOwnProp(trade, 'raw_data_hex')\n );\n};\n\n/**\n * Type guard to check if a trade is a Stellar trade with XDR (base64) payload\n *\n * @param trade - The trade object to check\n * @returns True if the trade is a Stellar trade with xdrBase64 or xdr property\n */\nexport const isStellarTrade = (trade: Trade): trade is StellarTradeData => {\n if (typeof trade !== 'object' || trade === null) {\n return false;\n }\n if (\n hasOwnProp(trade, 'xdrBase64') &&\n typeof (trade as { xdrBase64: unknown }).xdrBase64 === 'string'\n ) {\n return true;\n }\n if (\n hasOwnProp(trade, 'xdr') &&\n typeof (trade as { xdr: unknown }).xdr === 'string'\n ) {\n return true;\n }\n return false;\n};\n\n/**\n * Extracts the transaction data from different trade formats\n *\n * @param trade - The trade object which can be a TxData, string, Bitcoin trade, or Tron trade\n * @returns The extracted transaction data as a base64 string for SnapController\n */\nexport const extractTradeData = (trade: Trade): string => {\n // Check more specific trade types first to prevent misidentification\n if (isBitcoinTrade(trade)) {\n // Bitcoin trades are already base64 encoded\n return trade.unsignedPsbtBase64;\n }\n\n if (isTronTrade(trade)) {\n // Tron trades need hex to base64 conversion for SnapController\n return Buffer.from(trade.raw_data_hex, 'hex').toString('base64');\n }\n\n if (isStellarTrade(trade)) {\n if (\n hasOwnProp(trade, 'xdrBase64') &&\n typeof (trade as { xdrBase64: unknown }).xdrBase64 === 'string'\n ) {\n return (trade as { xdrBase64: string }).xdrBase64;\n }\n return (trade as { xdr: string }).xdr;\n }\n\n if (typeof trade === 'string') {\n // Solana txs - assuming already in correct format\n return trade;\n }\n\n if (isEvmTxData(trade)) {\n // EVM TxData object - return the data property\n return trade.data;\n }\n\n return '';\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BitcoinTradeData, TronTradeData, TxData } from "../types.cjs";
|
|
2
|
-
export type Trade = TxData | string | BitcoinTradeData | TronTradeData;
|
|
1
|
+
import type { BitcoinTradeData, StellarTradeData, TronTradeData, TxData } from "../types.cjs";
|
|
2
|
+
export type Trade = TxData | string | BitcoinTradeData | TronTradeData | StellarTradeData;
|
|
3
3
|
/**
|
|
4
4
|
* Type guard to check if a trade is an EVM TxData object
|
|
5
5
|
*
|
|
@@ -41,6 +41,17 @@ export declare const isTronTrade: (trade: Trade) => trade is {
|
|
|
41
41
|
fee_limit?: number | undefined;
|
|
42
42
|
} | null | undefined;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Type guard to check if a trade is a Stellar trade with XDR (base64) payload
|
|
46
|
+
*
|
|
47
|
+
* @param trade - The trade object to check
|
|
48
|
+
* @returns True if the trade is a Stellar trade with xdrBase64 or xdr property
|
|
49
|
+
*/
|
|
50
|
+
export declare const isStellarTrade: (trade: Trade) => trade is {
|
|
51
|
+
xdrBase64: string;
|
|
52
|
+
} | {
|
|
53
|
+
xdr: string;
|
|
54
|
+
};
|
|
44
55
|
/**
|
|
45
56
|
* Extracts the transaction data from different trade formats
|
|
46
57
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trade-utils.d.cts","sourceRoot":"","sources":["../../src/utils/trade-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"trade-utils.d.cts","sourceRoot":"","sources":["../../src/utils/trade-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,MAAM,EACP,qBAAiB;AAGlB,MAAM,MAAM,KAAK,GACb,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,aAAa,GACb,gBAAgB,CAAC;AAKrB;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,KAAK;;;;;;;;CAQvC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAAW,KAAK;;;CAM1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,KAAK;;;;;;;;;CAMvC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAAW,KAAK;;;;CAiB1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,KAAK,KAAG,MAiC/C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BitcoinTradeData, TronTradeData, TxData } from "../types.mjs";
|
|
2
|
-
export type Trade = TxData | string | BitcoinTradeData | TronTradeData;
|
|
1
|
+
import type { BitcoinTradeData, StellarTradeData, TronTradeData, TxData } from "../types.mjs";
|
|
2
|
+
export type Trade = TxData | string | BitcoinTradeData | TronTradeData | StellarTradeData;
|
|
3
3
|
/**
|
|
4
4
|
* Type guard to check if a trade is an EVM TxData object
|
|
5
5
|
*
|
|
@@ -41,6 +41,17 @@ export declare const isTronTrade: (trade: Trade) => trade is {
|
|
|
41
41
|
fee_limit?: number | undefined;
|
|
42
42
|
} | null | undefined;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Type guard to check if a trade is a Stellar trade with XDR (base64) payload
|
|
46
|
+
*
|
|
47
|
+
* @param trade - The trade object to check
|
|
48
|
+
* @returns True if the trade is a Stellar trade with xdrBase64 or xdr property
|
|
49
|
+
*/
|
|
50
|
+
export declare const isStellarTrade: (trade: Trade) => trade is {
|
|
51
|
+
xdrBase64: string;
|
|
52
|
+
} | {
|
|
53
|
+
xdr: string;
|
|
54
|
+
};
|
|
44
55
|
/**
|
|
45
56
|
* Extracts the transaction data from different trade formats
|
|
46
57
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trade-utils.d.mts","sourceRoot":"","sources":["../../src/utils/trade-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"trade-utils.d.mts","sourceRoot":"","sources":["../../src/utils/trade-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,MAAM,EACP,qBAAiB;AAGlB,MAAM,MAAM,KAAK,GACb,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,aAAa,GACb,gBAAgB,CAAC;AAKrB;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,KAAK;;;;;;;;CAQvC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAAW,KAAK;;;CAM1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,UAAW,KAAK;;;;;;;;;CAMvC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAAW,KAAK;;;;CAiB1C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,KAAK,KAAG,MAiC/C,CAAC"}
|