@metamask-previews/bridge-controller 16.0.0-preview-6df5889d → 16.0.0-preview-ef39cc11
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 +0 -6
- package/dist/bridge-controller.cjs +11 -131
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts +3 -26
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts +3 -26
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +11 -131
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/index.cjs +11 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -3
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +1 -2
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs +1 -2
- package/dist/selectors.mjs.map +1 -1
- package/dist/types.cjs +1 -9
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -9
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -9
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +0 -8
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/utils/metrics/constants.cjs +0 -43
- package/dist/utils/metrics/constants.cjs.map +0 -1
- package/dist/utils/metrics/constants.d.cts +0 -36
- package/dist/utils/metrics/constants.d.cts.map +0 -1
- package/dist/utils/metrics/constants.d.mts +0 -36
- package/dist/utils/metrics/constants.d.mts.map +0 -1
- package/dist/utils/metrics/constants.mjs +0 -40
- package/dist/utils/metrics/constants.mjs.map +0 -1
- package/dist/utils/metrics/properties.cjs +0 -77
- package/dist/utils/metrics/properties.cjs.map +0 -1
- package/dist/utils/metrics/properties.d.cts +0 -22
- package/dist/utils/metrics/properties.d.cts.map +0 -1
- package/dist/utils/metrics/properties.d.mts +0 -22
- package/dist/utils/metrics/properties.d.mts.map +0 -1
- package/dist/utils/metrics/properties.mjs +0 -66
- package/dist/utils/metrics/properties.mjs.map +0 -1
- package/dist/utils/metrics/types.cjs +0 -3
- package/dist/utils/metrics/types.cjs.map +0 -1
- package/dist/utils/metrics/types.d.cts +0 -156
- package/dist/utils/metrics/types.d.cts.map +0 -1
- package/dist/utils/metrics/types.d.mts +0 -156
- package/dist/utils/metrics/types.d.mts.map +0 -1
- package/dist/utils/metrics/types.mjs +0 -2
- package/dist/utils/metrics/types.mjs.map +0 -1
@@ -1,156 +0,0 @@
|
|
1
|
-
import type { CaipAssetType, CaipChainId } from "@metamask/utils";
|
2
|
-
import type { UnifiedSwapBridgeEventName, MetaMetricsSwapsEventSource, MetricsActionType, MetricsSwapType } from "./constants.mjs";
|
3
|
-
import type { SortOrder, StatusTypes } from "../../types.mjs";
|
4
|
-
/**
|
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
|
6
|
-
*/
|
7
|
-
export type RequestParams = {
|
8
|
-
chain_id_source: CaipChainId;
|
9
|
-
chain_id_destination: CaipChainId | null;
|
10
|
-
token_symbol_source: string;
|
11
|
-
token_symbol_destination: string | null;
|
12
|
-
token_address_source: CaipAssetType;
|
13
|
-
token_address_destination: CaipAssetType | null;
|
14
|
-
};
|
15
|
-
export type RequestMetadata = {
|
16
|
-
slippage_limit?: number;
|
17
|
-
custom_slippage: boolean;
|
18
|
-
usd_amount_source: number;
|
19
|
-
stx_enabled: boolean;
|
20
|
-
is_hardware_wallet: boolean;
|
21
|
-
swap_type: MetricsSwapType;
|
22
|
-
};
|
23
|
-
export type QuoteFetchData = {
|
24
|
-
can_submit: boolean;
|
25
|
-
best_quote_provider?: `${string}_${string}`;
|
26
|
-
quotes_count: number;
|
27
|
-
quotes_list: `${string}_${string}`[];
|
28
|
-
initial_load_time_all_quotes: number;
|
29
|
-
};
|
30
|
-
export type TradeData = {
|
31
|
-
usd_quoted_gas: number;
|
32
|
-
gas_included: boolean;
|
33
|
-
quoted_time_minutes: number;
|
34
|
-
usd_quoted_return: number;
|
35
|
-
provider: `${string}_${string}`;
|
36
|
-
price_impact: number;
|
37
|
-
};
|
38
|
-
export type TxStatusData = {
|
39
|
-
allowance_reset_transaction?: StatusTypes;
|
40
|
-
approval_transaction?: StatusTypes;
|
41
|
-
source_transaction?: StatusTypes;
|
42
|
-
destination_transaction?: StatusTypes;
|
43
|
-
};
|
44
|
-
export type InputKeys = 'token_source' | 'token_destination' | 'chain_source' | 'chain_destination' | 'slippage';
|
45
|
-
export type InputValues = {
|
46
|
-
token_source: CaipAssetType;
|
47
|
-
token_destination: CaipAssetType;
|
48
|
-
chain_source: CaipChainId;
|
49
|
-
chain_destination: CaipChainId;
|
50
|
-
slippage: number;
|
51
|
-
};
|
52
|
-
/**
|
53
|
-
* Properties that are required to be provided when trackMetaMetricsEvent is called
|
54
|
-
*/
|
55
|
-
export type RequiredEventContextFromClient = {
|
56
|
-
[UnifiedSwapBridgeEventName.ButtonClicked]: {
|
57
|
-
location: MetaMetricsSwapsEventSource;
|
58
|
-
} & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'>;
|
59
|
-
[UnifiedSwapBridgeEventName.PageViewed]: object;
|
60
|
-
[UnifiedSwapBridgeEventName.InputChanged]: {
|
61
|
-
input: 'token_source' | 'token_destination' | 'chain_source' | 'chain_destination' | 'slippage';
|
62
|
-
value: InputValues[keyof InputValues];
|
63
|
-
};
|
64
|
-
[UnifiedSwapBridgeEventName.InputSourceDestinationFlipped]: {
|
65
|
-
token_symbol_source: RequestParams['token_symbol_source'];
|
66
|
-
token_symbol_destination: RequestParams['token_symbol_destination'];
|
67
|
-
token_address_source: RequestParams['token_address_source'];
|
68
|
-
token_address_destination: RequestParams['token_address_destination'];
|
69
|
-
chain_id_source: RequestParams['chain_id_source'];
|
70
|
-
chain_id_destination: RequestParams['chain_id_destination'];
|
71
|
-
security_warnings: string[];
|
72
|
-
};
|
73
|
-
[UnifiedSwapBridgeEventName.QuotesRequested]: Pick<RequestMetadata, 'stx_enabled'> & {
|
74
|
-
token_symbol_source: RequestParams['token_symbol_source'];
|
75
|
-
token_symbol_destination: RequestParams['token_symbol_destination'];
|
76
|
-
};
|
77
|
-
[UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {
|
78
|
-
warnings: string[];
|
79
|
-
best_quote_provider: QuoteFetchData['best_quote_provider'];
|
80
|
-
};
|
81
|
-
[UnifiedSwapBridgeEventName.QuoteError]: Pick<RequestMetadata, 'stx_enabled'> & {
|
82
|
-
token_symbol_source: RequestParams['token_symbol_source'];
|
83
|
-
token_symbol_destination: RequestParams['token_symbol_destination'];
|
84
|
-
security_warnings: string[];
|
85
|
-
};
|
86
|
-
[UnifiedSwapBridgeEventName.SnapConfirmationViewed]: object;
|
87
|
-
[UnifiedSwapBridgeEventName.Submitted]: RequestParams & RequestMetadata & TradeData & {
|
88
|
-
action_type: MetricsActionType;
|
89
|
-
};
|
90
|
-
[UnifiedSwapBridgeEventName.Completed]: RequestParams & RequestMetadata & TxStatusData & TradeData & {
|
91
|
-
actual_time_minutes: number;
|
92
|
-
usd_actual_return: number;
|
93
|
-
usd_actual_gas: number;
|
94
|
-
quote_vs_execution_ratio: number;
|
95
|
-
quoted_vs_used_gas_ratio: number;
|
96
|
-
action_type: MetricsActionType;
|
97
|
-
};
|
98
|
-
[UnifiedSwapBridgeEventName.Failed]: RequestParams & RequestMetadata & TxStatusData & TradeData & {
|
99
|
-
actual_time_minutes: number;
|
100
|
-
error_message: string;
|
101
|
-
action_type: MetricsActionType;
|
102
|
-
};
|
103
|
-
[UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<TradeData, 'price_impact' | 'gas_included'> & {
|
104
|
-
stx_enabled: RequestMetadata['stx_enabled'];
|
105
|
-
token_symbol_source: RequestParams['token_symbol_source'];
|
106
|
-
token_symbol_destination: RequestParams['token_symbol_destination'];
|
107
|
-
};
|
108
|
-
[UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<TradeData, 'price_impact' | 'gas_included'> & {
|
109
|
-
stx_enabled: RequestMetadata['stx_enabled'];
|
110
|
-
token_symbol_source: RequestParams['token_symbol_source'];
|
111
|
-
token_symbol_destination: RequestParams['token_symbol_destination'];
|
112
|
-
sort_order: SortOrder;
|
113
|
-
best_quote_provider: QuoteFetchData['best_quote_provider'];
|
114
|
-
};
|
115
|
-
[UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {
|
116
|
-
is_best_quote: boolean;
|
117
|
-
best_quote_provider: QuoteFetchData['best_quote_provider'];
|
118
|
-
};
|
119
|
-
};
|
120
|
-
/**
|
121
|
-
* Properties that can be derived from the bridge controller state
|
122
|
-
*/
|
123
|
-
export type EventPropertiesFromControllerState = {
|
124
|
-
[UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;
|
125
|
-
[UnifiedSwapBridgeEventName.PageViewed]: RequestParams;
|
126
|
-
[UnifiedSwapBridgeEventName.InputChanged]: {
|
127
|
-
input: InputKeys;
|
128
|
-
value: string;
|
129
|
-
};
|
130
|
-
[UnifiedSwapBridgeEventName.InputSourceDestinationFlipped]: RequestParams;
|
131
|
-
[UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams & RequestMetadata & {
|
132
|
-
has_sufficient_funds: boolean;
|
133
|
-
};
|
134
|
-
[UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams & RequestMetadata & QuoteFetchData & {
|
135
|
-
refresh_count: number;
|
136
|
-
};
|
137
|
-
[UnifiedSwapBridgeEventName.QuoteError]: RequestParams & RequestMetadata & {
|
138
|
-
has_sufficient_funds: boolean;
|
139
|
-
error_message: string;
|
140
|
-
};
|
141
|
-
[UnifiedSwapBridgeEventName.SnapConfirmationViewed]: RequestMetadata & RequestParams;
|
142
|
-
[UnifiedSwapBridgeEventName.Submitted]: null;
|
143
|
-
[UnifiedSwapBridgeEventName.Completed]: null;
|
144
|
-
[UnifiedSwapBridgeEventName.Failed]: null;
|
145
|
-
[UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams & RequestMetadata & QuoteFetchData & Pick<TradeData, 'price_impact'>;
|
146
|
-
[UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams & RequestMetadata & QuoteFetchData & Pick<TradeData, 'price_impact'>;
|
147
|
-
[UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams & RequestMetadata & QuoteFetchData & TradeData;
|
148
|
-
};
|
149
|
-
/**
|
150
|
-
* trackMetaMetricsEvent payload properties consist of required properties from the client
|
151
|
-
* and properties from the bridge controller
|
152
|
-
*/
|
153
|
-
export type CrossChainSwapsEventProperties<T extends UnifiedSwapBridgeEventName> = {
|
154
|
-
action_type: MetricsActionType;
|
155
|
-
} | Pick<EventPropertiesFromControllerState, T>[T] | Pick<RequiredEventContextFromClient, T>[T];
|
156
|
-
//# sourceMappingURL=types.d.mts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,EAChB,wBAAoB;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAoB;AAE1D;;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;CACj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AE,eAAe,GAClE,aAAa,CAAC;IAChB,CAAC,0BAA0B,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC7C,CAAC,0BAA0B,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC7C,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;IAC1C,CAAC,0BAA0B,CAAC,eAAe,CAAC,EAAE,aAAa,GACzD,eAAe,GACf,cAAc,GACd,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAClC,CAAC,0BAA0B,CAAC,eAAe,CAAC,EAAE,aAAa,GACzD,eAAe,GACf,cAAc,GACd,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAClC,CAAC,0BAA0B,CAAC,aAAa,CAAC,EAAE,aAAa,GACvD,eAAe,GACf,cAAc,GACd,SAAS,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,CACxC,CAAC,SAAS,0BAA0B,IAElC;IACE,WAAW,EAAE,iBAAiB,CAAC;CAChC,GACD,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n} from './constants';\nimport type { SortOrder, StatusTypes } from '../../types';\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\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 swap_type: MetricsSwapType;\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};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n price_impact: number;\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\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n};\n\n/**\n * Properties that are required to be provided when trackMetaMetricsEvent is called\n */\nexport type RequiredEventContextFromClient = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: {\n location: MetaMetricsSwapsEventSource;\n } & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'>;\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 value: InputValues[keyof InputValues];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationFlipped]: {\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 chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n /*\n Only needed for non-EVM chains\n */\n security_warnings: string[]; // TODO standardize warnings\n };\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: string[]; // TODO standardize warnings\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n };\n [UnifiedSwapBridgeEventName.QuoteError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n /*\n Only needed for non-EVM chains\n */\n security_warnings: string[]; // TODO standardize warnings\n };\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.SnapConfirmationViewed]: object;\n [UnifiedSwapBridgeEventName.Submitted]: RequestParams &\n RequestMetadata &\n TradeData & {\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Completed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData & {\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 };\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData & {\n actual_time_minutes: number;\n error_message: string;\n action_type: MetricsActionType;\n };\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'price_impact' | 'gas_included'\n > & {\n stx_enabled: RequestMetadata['stx_enabled'];\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'price_impact' | 'gas_included'\n > & {\n stx_enabled: RequestMetadata['stx_enabled'];\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\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 [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationFlipped]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuoteError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.SnapConfirmationViewed]: RequestMetadata &\n RequestParams;\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: null;\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n Pick<TradeData, 'price_impact'>;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n Pick<TradeData, 'price_impact'>;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n};\n\n/**\n * trackMetaMetricsEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n action_type: MetricsActionType;\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
|