@metamask-previews/bridge-controller 77.3.2-preview-bbd2df29f → 77.3.2-preview-34f2bcbf7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/bridge-controller.cjs.map +1 -1
  3. package/dist/bridge-controller.d.cts +3 -2
  4. package/dist/bridge-controller.d.cts.map +1 -1
  5. package/dist/bridge-controller.d.mts +3 -2
  6. package/dist/bridge-controller.d.mts.map +1 -1
  7. package/dist/bridge-controller.mjs +1 -1
  8. package/dist/bridge-controller.mjs.map +1 -1
  9. package/dist/index.cjs +36 -30
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +14 -5
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts +14 -5
  14. package/dist/index.d.mts.map +1 -1
  15. package/dist/index.mjs +10 -4
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/selectors.cjs.map +1 -1
  18. package/dist/selectors.d.cts +5971 -6520
  19. package/dist/selectors.d.cts.map +1 -1
  20. package/dist/selectors.d.mts +5971 -6520
  21. package/dist/selectors.d.mts.map +1 -1
  22. package/dist/selectors.mjs.map +1 -1
  23. package/dist/types.cjs +1 -12
  24. package/dist/types.cjs.map +1 -1
  25. package/dist/types.d.cts +21 -41
  26. package/dist/types.d.cts.map +1 -1
  27. package/dist/types.d.mts +21 -41
  28. package/dist/types.d.mts.map +1 -1
  29. package/dist/types.mjs +0 -11
  30. package/dist/types.mjs.map +1 -1
  31. package/dist/utils/bridge.cjs +1 -0
  32. package/dist/utils/bridge.cjs.map +1 -1
  33. package/dist/utils/bridge.d.cts +4 -3
  34. package/dist/utils/bridge.d.cts.map +1 -1
  35. package/dist/utils/bridge.d.mts +4 -3
  36. package/dist/utils/bridge.d.mts.map +1 -1
  37. package/dist/utils/bridge.mjs +1 -0
  38. package/dist/utils/bridge.mjs.map +1 -1
  39. package/dist/utils/feature-flags.cjs +2 -2
  40. package/dist/utils/feature-flags.cjs.map +1 -1
  41. package/dist/utils/feature-flags.d.cts +1 -1
  42. package/dist/utils/feature-flags.d.mts +1 -1
  43. package/dist/utils/feature-flags.mjs +1 -1
  44. package/dist/utils/feature-flags.mjs.map +1 -1
  45. package/dist/utils/fetch.cjs +16 -11
  46. package/dist/utils/fetch.cjs.map +1 -1
  47. package/dist/utils/fetch.d.cts +3 -1
  48. package/dist/utils/fetch.d.cts.map +1 -1
  49. package/dist/utils/fetch.d.mts +3 -1
  50. package/dist/utils/fetch.d.mts.map +1 -1
  51. package/dist/utils/fetch.mjs +9 -4
  52. package/dist/utils/fetch.mjs.map +1 -1
  53. package/dist/utils/metrics/properties.cjs +2 -2
  54. package/dist/utils/metrics/properties.cjs.map +1 -1
  55. package/dist/utils/metrics/properties.d.cts +4 -2
  56. package/dist/utils/metrics/properties.d.cts.map +1 -1
  57. package/dist/utils/metrics/properties.d.mts +4 -2
  58. package/dist/utils/metrics/properties.d.mts.map +1 -1
  59. package/dist/utils/metrics/properties.mjs +1 -1
  60. package/dist/utils/metrics/properties.mjs.map +1 -1
  61. package/dist/utils/metrics/types.cjs.map +1 -1
  62. package/dist/utils/metrics/types.d.cts +2 -1
  63. package/dist/utils/metrics/types.d.cts.map +1 -1
  64. package/dist/utils/metrics/types.d.mts +2 -1
  65. package/dist/utils/metrics/types.d.mts.map +1 -1
  66. package/dist/utils/metrics/types.mjs.map +1 -1
  67. package/dist/utils/quote-fees.cjs +2 -1
  68. package/dist/utils/quote-fees.cjs.map +1 -1
  69. package/dist/utils/quote-fees.d.cts +2 -1
  70. package/dist/utils/quote-fees.d.cts.map +1 -1
  71. package/dist/utils/quote-fees.d.mts +2 -1
  72. package/dist/utils/quote-fees.d.mts.map +1 -1
  73. package/dist/utils/quote-fees.mjs +2 -1
  74. package/dist/utils/quote-fees.mjs.map +1 -1
  75. package/dist/utils/quote.cjs +3 -3
  76. package/dist/utils/quote.cjs.map +1 -1
  77. package/dist/utils/quote.d.cts +5 -2
  78. package/dist/utils/quote.d.cts.map +1 -1
  79. package/dist/utils/quote.d.mts +5 -2
  80. package/dist/utils/quote.d.mts.map +1 -1
  81. package/dist/utils/quote.mjs +2 -2
  82. package/dist/utils/quote.mjs.map +1 -1
  83. package/dist/utils/struct-error.cjs +16 -0
  84. package/dist/utils/struct-error.cjs.map +1 -0
  85. package/dist/utils/struct-error.d.cts +11 -0
  86. package/dist/utils/struct-error.d.cts.map +1 -0
  87. package/dist/utils/struct-error.d.mts +11 -0
  88. package/dist/utils/struct-error.d.mts.map +1 -0
  89. package/dist/utils/struct-error.mjs +12 -0
  90. package/dist/utils/struct-error.mjs.map +1 -0
  91. package/dist/utils/trade-utils.cjs +7 -66
  92. package/dist/utils/trade-utils.cjs.map +1 -1
  93. package/dist/utils/trade-utils.d.cts +1 -54
  94. package/dist/utils/trade-utils.d.cts.map +1 -1
  95. package/dist/utils/trade-utils.d.mts +1 -54
  96. package/dist/utils/trade-utils.d.mts.map +1 -1
  97. package/dist/utils/trade-utils.mjs +1 -56
  98. package/dist/utils/trade-utils.mjs.map +1 -1
  99. package/dist/validators/batch-sell.cjs +39 -0
  100. package/dist/validators/batch-sell.cjs.map +1 -0
  101. package/dist/validators/batch-sell.d.cts +79 -0
  102. package/dist/validators/batch-sell.d.cts.map +1 -0
  103. package/dist/validators/batch-sell.d.mts +79 -0
  104. package/dist/validators/batch-sell.d.mts.map +1 -0
  105. package/dist/validators/batch-sell.mjs +35 -0
  106. package/dist/validators/batch-sell.mjs.map +1 -0
  107. package/dist/validators/bridge-asset.cjs +42 -0
  108. package/dist/validators/bridge-asset.cjs.map +1 -0
  109. package/dist/validators/bridge-asset.d.cts +52 -0
  110. package/dist/validators/bridge-asset.d.cts.map +1 -0
  111. package/dist/validators/bridge-asset.d.mts +52 -0
  112. package/dist/validators/bridge-asset.d.mts.map +1 -0
  113. package/dist/validators/bridge-asset.mjs +38 -0
  114. package/dist/validators/bridge-asset.mjs.map +1 -0
  115. package/dist/validators/feature-flags.cjs +110 -0
  116. package/dist/validators/feature-flags.cjs.map +1 -0
  117. package/dist/validators/feature-flags.d.cts +264 -0
  118. package/dist/validators/feature-flags.d.cts.map +1 -0
  119. package/dist/validators/feature-flags.d.mts +264 -0
  120. package/dist/validators/feature-flags.d.mts.map +1 -0
  121. package/dist/validators/feature-flags.mjs +106 -0
  122. package/dist/validators/feature-flags.mjs.map +1 -0
  123. package/dist/validators/intent.cjs +122 -0
  124. package/dist/validators/intent.cjs.map +1 -0
  125. package/dist/validators/intent.d.cts +231 -0
  126. package/dist/validators/intent.d.cts.map +1 -0
  127. package/dist/validators/intent.d.mts +231 -0
  128. package/dist/validators/intent.d.mts.map +1 -0
  129. package/dist/validators/intent.mjs +119 -0
  130. package/dist/validators/intent.mjs.map +1 -0
  131. package/dist/validators/number.cjs +8 -0
  132. package/dist/validators/number.cjs.map +1 -0
  133. package/dist/validators/number.d.cts +4 -0
  134. package/dist/validators/number.d.cts.map +1 -0
  135. package/dist/validators/number.d.mts +4 -0
  136. package/dist/validators/number.d.mts.map +1 -0
  137. package/dist/validators/number.mjs +5 -0
  138. package/dist/validators/number.mjs.map +1 -0
  139. package/dist/validators/quote-response-v1.cjs +31 -0
  140. package/dist/validators/quote-response-v1.cjs.map +1 -0
  141. package/dist/validators/quote-response-v1.d.cts +658 -0
  142. package/dist/validators/quote-response-v1.d.cts.map +1 -0
  143. package/dist/validators/quote-response-v1.d.mts +658 -0
  144. package/dist/validators/quote-response-v1.d.mts.map +1 -0
  145. package/dist/validators/quote-response-v1.mjs +27 -0
  146. package/dist/validators/quote-response-v1.mjs.map +1 -0
  147. package/dist/validators/quote-stream-complete.cjs +29 -0
  148. package/dist/validators/quote-stream-complete.cjs.map +1 -0
  149. package/dist/validators/quote-stream-complete.d.cts +39 -0
  150. package/dist/validators/quote-stream-complete.d.cts.map +1 -0
  151. package/dist/validators/quote-stream-complete.d.mts +39 -0
  152. package/dist/validators/quote-stream-complete.d.mts.map +1 -0
  153. package/dist/validators/quote-stream-complete.mjs +25 -0
  154. package/dist/validators/quote-stream-complete.mjs.map +1 -0
  155. package/dist/validators/quote.cjs +96 -0
  156. package/dist/validators/quote.cjs.map +1 -0
  157. package/dist/validators/quote.d.cts +230 -0
  158. package/dist/validators/quote.d.cts.map +1 -0
  159. package/dist/validators/quote.d.mts +230 -0
  160. package/dist/validators/quote.d.mts.map +1 -0
  161. package/dist/validators/quote.mjs +93 -0
  162. package/dist/validators/quote.mjs.map +1 -0
  163. package/dist/validators/step.cjs +20 -0
  164. package/dist/validators/step.cjs.map +1 -0
  165. package/dist/validators/step.d.cts +148 -0
  166. package/dist/validators/step.d.cts.map +1 -0
  167. package/dist/validators/step.d.mts +148 -0
  168. package/dist/validators/step.d.mts.map +1 -0
  169. package/dist/validators/step.mjs +17 -0
  170. package/dist/validators/step.mjs.map +1 -0
  171. package/dist/validators/token-feature.cjs +22 -0
  172. package/dist/validators/token-feature.cjs.map +1 -0
  173. package/dist/validators/token-feature.d.cts +26 -0
  174. package/dist/validators/token-feature.d.cts.map +1 -0
  175. package/dist/validators/token-feature.d.mts +26 -0
  176. package/dist/validators/token-feature.d.mts.map +1 -0
  177. package/dist/validators/token-feature.mjs +18 -0
  178. package/dist/validators/token-feature.mjs.map +1 -0
  179. package/dist/validators/trade.cjs +94 -0
  180. package/dist/validators/trade.cjs.map +1 -0
  181. package/dist/validators/trade.d.cts +121 -0
  182. package/dist/validators/trade.d.cts.map +1 -0
  183. package/dist/validators/trade.d.mts +121 -0
  184. package/dist/validators/trade.d.mts.map +1 -0
  185. package/dist/validators/trade.mjs +86 -0
  186. package/dist/validators/trade.mjs.map +1 -0
  187. package/package.json +4 -4
  188. package/dist/utils/validators.cjs +0 -471
  189. package/dist/utils/validators.cjs.map +0 -1
  190. package/dist/utils/validators.d.cts +0 -1765
  191. package/dist/utils/validators.d.cts.map +0 -1
  192. package/dist/utils/validators.d.mts +0 -1765
  193. package/dist/utils/validators.d.mts.map +0 -1
  194. package/dist/utils/validators.mjs +0 -461
  195. package/dist/utils/validators.mjs.map +0 -1
@@ -0,0 +1,264 @@
1
+ export declare enum FeatureId {
2
+ UNKNOWN = "unknown",
3
+ PERPS = "perps",
4
+ QUICK_BUY_FOLLOW_TRADING = "quick_buy_follow_trading",
5
+ QUICK_BUY_TOKEN_DETAILS = "quick_buy_token_details",
6
+ QUICK_BUY_EXPLORE = "quick_buy_explore",
7
+ DAPP_SWAP = "dapp_swap",
8
+ BATCH_SELL = "batch_sell",
9
+ UNIFIED_SWAP_BRIDGE = "unified_swap_bridge"
10
+ }
11
+ export declare const VersionStringSchema: import("@metamask/superstruct").Struct<string, null>;
12
+ export declare const ChainRankingItemSchema: import("@metamask/superstruct").Struct<{
13
+ chainId: `${string}:${string}`;
14
+ name: string;
15
+ }, {
16
+ /**
17
+ * The CAIP-2 chain identifier (e.g., "eip155:1" for Ethereum mainnet)
18
+ */
19
+ chainId: import("@metamask/superstruct").Struct<`${string}:${string}`, null>;
20
+ /**
21
+ * The display name of the chain (e.g., "Ethereum")
22
+ */
23
+ name: import("@metamask/superstruct").Struct<string, null>;
24
+ }>;
25
+ export declare const ChainRankingSchema: import("@metamask/superstruct").Struct<{
26
+ chainId: `${string}:${string}`;
27
+ name: string;
28
+ }[] | undefined, import("@metamask/superstruct").Struct<{
29
+ chainId: `${string}:${string}`;
30
+ name: string;
31
+ }, {
32
+ /**
33
+ * The CAIP-2 chain identifier (e.g., "eip155:1" for Ethereum mainnet)
34
+ */
35
+ chainId: import("@metamask/superstruct").Struct<`${string}:${string}`, null>;
36
+ /**
37
+ * The display name of the chain (e.g., "Ethereum")
38
+ */
39
+ name: import("@metamask/superstruct").Struct<string, null>;
40
+ }>>;
41
+ export declare const ChainConfigurationSchema: import("@metamask/superstruct").Struct<{
42
+ isActiveSrc: boolean;
43
+ isActiveDest: boolean;
44
+ refreshRate?: number | undefined;
45
+ topAssets?: string[] | undefined;
46
+ stablecoins?: string[] | undefined;
47
+ batchSellDestStablecoins?: `${string}:${string}/${string}:${string}`[] | undefined;
48
+ isUnifiedUIEnabled?: boolean | undefined;
49
+ isSingleSwapBridgeButtonEnabled?: boolean | undefined;
50
+ isGaslessSwapEnabled?: boolean | undefined;
51
+ noFeeAssets?: string[] | undefined;
52
+ defaultPairs?: {
53
+ standard: Record<string, string>;
54
+ other: Record<string, string>;
55
+ } | undefined;
56
+ }, {
57
+ isActiveSrc: import("@metamask/superstruct").Struct<boolean, null>;
58
+ isActiveDest: import("@metamask/superstruct").Struct<boolean, null>;
59
+ refreshRate: import("@metamask/superstruct").Struct<number | undefined, null>;
60
+ topAssets: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
61
+ stablecoins: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
62
+ batchSellDestStablecoins: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`[] | undefined, import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>>;
63
+ isUnifiedUIEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
64
+ isSingleSwapBridgeButtonEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
65
+ isGaslessSwapEnabled: import("@metamask/superstruct").Struct<boolean | undefined, null>;
66
+ noFeeAssets: import("@metamask/superstruct").Struct<string[] | undefined, import("@metamask/superstruct").Struct<string, null>>;
67
+ defaultPairs: import("@metamask/superstruct").Struct<{
68
+ standard: Record<string, string>;
69
+ other: Record<string, string>;
70
+ } | undefined, {
71
+ /**
72
+ * The standard default pairs. Use this if the pair is only set once.
73
+ * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
74
+ */
75
+ standard: import("@metamask/superstruct").Struct<Record<string, string>, null>;
76
+ /**
77
+ * The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.
78
+ * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
79
+ */
80
+ other: import("@metamask/superstruct").Struct<Record<string, string>, null>;
81
+ }>;
82
+ }>;
83
+ export declare const PriceImpactThresholdSchema: import("@metamask/superstruct").Struct<{
84
+ gasless: number;
85
+ normal: number;
86
+ warning?: number | undefined;
87
+ error?: number | undefined;
88
+ }, {
89
+ gasless: import("@metamask/superstruct").Struct<number, null>;
90
+ normal: import("@metamask/superstruct").Struct<number, null>;
91
+ warning: import("@metamask/superstruct").Struct<number | undefined, null>;
92
+ error: import("@metamask/superstruct").Struct<number | undefined, null>;
93
+ }>;
94
+ /**
95
+ * This is the schema for the feature flags response from the RemoteFeatureFlagController
96
+ */
97
+ export declare const PlatformConfigSchema: import("@metamask/superstruct").Struct<{
98
+ refreshRate: number;
99
+ minimumVersion: string;
100
+ maxRefreshCount: number;
101
+ support: boolean;
102
+ chains: Record<string, {
103
+ isActiveSrc: boolean;
104
+ isActiveDest: boolean;
105
+ refreshRate?: number | undefined;
106
+ topAssets?: string[] | undefined;
107
+ stablecoins?: string[] | undefined;
108
+ batchSellDestStablecoins?: `${string}:${string}/${string}:${string}`[] | undefined;
109
+ isUnifiedUIEnabled?: boolean | undefined;
110
+ isSingleSwapBridgeButtonEnabled?: boolean | undefined;
111
+ isGaslessSwapEnabled?: boolean | undefined;
112
+ noFeeAssets?: string[] | undefined;
113
+ defaultPairs?: {
114
+ standard: Record<string, string>;
115
+ other: Record<string, string>;
116
+ } | undefined;
117
+ }>;
118
+ priceImpactThreshold?: {
119
+ gasless: number;
120
+ normal: number;
121
+ warning?: number | undefined;
122
+ error?: number | undefined;
123
+ } | undefined;
124
+ quoteRequestOverrides?: Record<string, {
125
+ fee?: number | undefined;
126
+ aggIds?: string[] | undefined;
127
+ bridgeIds?: string[] | undefined;
128
+ } | undefined> | undefined;
129
+ bip44DefaultPairs?: Record<string, {
130
+ standard: Record<string, string>;
131
+ other: Record<string, string>;
132
+ } | undefined> | undefined;
133
+ sse?: {
134
+ minimumVersion: string;
135
+ enabled: boolean;
136
+ } | undefined;
137
+ chainRanking?: {
138
+ chainId: `${string}:${string}`;
139
+ name: string;
140
+ }[] | undefined;
141
+ maxPendingHistoryItemAgeMs?: number | undefined;
142
+ }, {
143
+ priceImpactThreshold: import("@metamask/superstruct").Struct<{
144
+ gasless: number;
145
+ normal: number;
146
+ warning?: number | undefined;
147
+ error?: number | undefined;
148
+ } | undefined, {
149
+ gasless: import("@metamask/superstruct").Struct<number, null>;
150
+ normal: import("@metamask/superstruct").Struct<number, null>;
151
+ warning: import("@metamask/superstruct").Struct<number | undefined, null>;
152
+ error: import("@metamask/superstruct").Struct<number | undefined, null>;
153
+ }>;
154
+ quoteRequestOverrides: import("@metamask/superstruct").Struct<Record<string, {
155
+ fee?: number | undefined;
156
+ aggIds?: string[] | undefined;
157
+ bridgeIds?: string[] | undefined;
158
+ } | undefined> | undefined, null>;
159
+ minimumVersion: import("@metamask/superstruct").Struct<string, null>;
160
+ refreshRate: import("@metamask/superstruct").Struct<number, null>;
161
+ maxRefreshCount: import("@metamask/superstruct").Struct<number, null>;
162
+ support: import("@metamask/superstruct").Struct<boolean, null>;
163
+ chains: import("@metamask/superstruct").Struct<Record<string, {
164
+ isActiveSrc: boolean;
165
+ isActiveDest: boolean;
166
+ refreshRate?: number | undefined;
167
+ topAssets?: string[] | undefined;
168
+ stablecoins?: string[] | undefined;
169
+ batchSellDestStablecoins?: `${string}:${string}/${string}:${string}`[] | undefined;
170
+ isUnifiedUIEnabled?: boolean | undefined;
171
+ isSingleSwapBridgeButtonEnabled?: boolean | undefined;
172
+ isGaslessSwapEnabled?: boolean | undefined;
173
+ noFeeAssets?: string[] | undefined;
174
+ defaultPairs?: {
175
+ standard: Record<string, string>;
176
+ other: Record<string, string>;
177
+ } | undefined;
178
+ }>, null>;
179
+ /**
180
+ * The bip44 default pairs for the chains
181
+ * Key is the CAIP chainId namespace
182
+ */
183
+ bip44DefaultPairs: import("@metamask/superstruct").Struct<Record<string, {
184
+ standard: Record<string, string>;
185
+ other: Record<string, string>;
186
+ } | undefined> | undefined, null>;
187
+ sse: import("@metamask/superstruct").Struct<{
188
+ minimumVersion: string;
189
+ enabled: boolean;
190
+ } | undefined, {
191
+ enabled: import("@metamask/superstruct").Struct<boolean, null>;
192
+ /**
193
+ * The minimum version of the client required to enable SSE, for example 13.8.0
194
+ */
195
+ minimumVersion: import("@metamask/superstruct").Struct<string, null>;
196
+ }>;
197
+ /**
198
+ * Array of chain objects ordered by preference/ranking
199
+ */
200
+ chainRanking: import("@metamask/superstruct").Struct<{
201
+ chainId: `${string}:${string}`;
202
+ name: string;
203
+ }[] | undefined, import("@metamask/superstruct").Struct<{
204
+ chainId: `${string}:${string}`;
205
+ name: string;
206
+ }, {
207
+ /**
208
+ * The CAIP-2 chain identifier (e.g., "eip155:1" for Ethereum mainnet)
209
+ */
210
+ chainId: import("@metamask/superstruct").Struct<`${string}:${string}`, null>;
211
+ /**
212
+ * The display name of the chain (e.g., "Ethereum")
213
+ */
214
+ name: import("@metamask/superstruct").Struct<string, null>;
215
+ }>>;
216
+ maxPendingHistoryItemAgeMs: import("@metamask/superstruct").Struct<number | undefined, null>;
217
+ }>;
218
+ export declare const validateFeatureFlagsResponse: (data: unknown) => data is {
219
+ refreshRate: number;
220
+ minimumVersion: string;
221
+ maxRefreshCount: number;
222
+ support: boolean;
223
+ chains: Record<string, {
224
+ isActiveSrc: boolean;
225
+ isActiveDest: boolean;
226
+ refreshRate?: number | undefined;
227
+ topAssets?: string[] | undefined;
228
+ stablecoins?: string[] | undefined;
229
+ batchSellDestStablecoins?: `${string}:${string}/${string}:${string}`[] | undefined;
230
+ isUnifiedUIEnabled?: boolean | undefined;
231
+ isSingleSwapBridgeButtonEnabled?: boolean | undefined;
232
+ isGaslessSwapEnabled?: boolean | undefined;
233
+ noFeeAssets?: string[] | undefined;
234
+ defaultPairs?: {
235
+ standard: Record<string, string>;
236
+ other: Record<string, string>;
237
+ } | undefined;
238
+ }>;
239
+ priceImpactThreshold?: {
240
+ gasless: number;
241
+ normal: number;
242
+ warning?: number | undefined;
243
+ error?: number | undefined;
244
+ } | undefined;
245
+ quoteRequestOverrides?: Record<string, {
246
+ fee?: number | undefined;
247
+ aggIds?: string[] | undefined;
248
+ bridgeIds?: string[] | undefined;
249
+ } | undefined> | undefined;
250
+ bip44DefaultPairs?: Record<string, {
251
+ standard: Record<string, string>;
252
+ other: Record<string, string>;
253
+ } | undefined> | undefined;
254
+ sse?: {
255
+ minimumVersion: string;
256
+ enabled: boolean;
257
+ } | undefined;
258
+ chainRanking?: {
259
+ chainId: `${string}:${string}`;
260
+ name: string;
261
+ }[] | undefined;
262
+ maxPendingHistoryItemAgeMs?: number | undefined;
263
+ };
264
+ //# sourceMappingURL=feature-flags.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-flags.d.mts","sourceRoot":"","sources":["../../src/validators/feature-flags.ts"],"names":[],"mappings":"AAeA,oBAAY,SAAS;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,wBAAwB,6BAA6B;IACrD,uBAAuB,4BAA4B;IACnD,iBAAiB,sBAAsB;IACvC,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,mBAAmB,wBAAwB;CAC5C;AAED,eAAO,MAAM,mBAAmB,sDAM/B,CAAC;AAeF,eAAO,MAAM,sBAAsB;;;;IACjC;;OAEG;;IAEH;;OAEG;;EAEH,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;IAV7B;;OAEG;;IAEH;;OAEG;;GAIoE,CAAC;AAE1E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAzBnC;;;WAGG;;QAEH;;;WAGG;;;EA6BH,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;EAcrC,CAAC;AAQH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAU/B;;;OAGG;;;;;;;;;;QAKC;;WAEG;;;IAIP;;OAEG;;;;;;;;QA7EH;;WAEG;;QAEH;;WAEG;;;;EA0EH,CAAC;AAEH,eAAO,MAAM,4BAA4B,SACjC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGd,CAAC"}
@@ -0,0 +1,106 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { type, record, string, optional, array, boolean, number, is, define } from "@metamask/superstruct";
3
+ import { CaipChainIdStruct, CaipAssetTypeStruct } from "@metamask/utils";
4
+ export var FeatureId;
5
+ (function (FeatureId) {
6
+ FeatureId["UNKNOWN"] = "unknown";
7
+ FeatureId["PERPS"] = "perps";
8
+ FeatureId["QUICK_BUY_FOLLOW_TRADING"] = "quick_buy_follow_trading";
9
+ FeatureId["QUICK_BUY_TOKEN_DETAILS"] = "quick_buy_token_details";
10
+ FeatureId["QUICK_BUY_EXPLORE"] = "quick_buy_explore";
11
+ FeatureId["DAPP_SWAP"] = "dapp_swap";
12
+ FeatureId["BATCH_SELL"] = "batch_sell";
13
+ FeatureId["UNIFIED_SWAP_BRIDGE"] = "unified_swap_bridge";
14
+ })(FeatureId || (FeatureId = {}));
15
+ export const VersionStringSchema = define('VersionString', (value) => typeof value === 'string' &&
16
+ /^(\d+\.*){2}\d+$/u.test(value) &&
17
+ value.split('.').length === 3);
18
+ const DefaultPairSchema = type({
19
+ /**
20
+ * The standard default pairs. Use this if the pair is only set once.
21
+ * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
22
+ */
23
+ standard: record(string(), string()),
24
+ /**
25
+ * The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.
26
+ * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
27
+ */
28
+ other: record(string(), string()),
29
+ });
30
+ export const ChainRankingItemSchema = type({
31
+ /**
32
+ * The CAIP-2 chain identifier (e.g., "eip155:1" for Ethereum mainnet)
33
+ */
34
+ chainId: CaipChainIdStruct,
35
+ /**
36
+ * The display name of the chain (e.g., "Ethereum")
37
+ */
38
+ name: string(),
39
+ });
40
+ export const ChainRankingSchema = optional(array(ChainRankingItemSchema));
41
+ export const ChainConfigurationSchema = type({
42
+ isActiveSrc: boolean(),
43
+ isActiveDest: boolean(),
44
+ refreshRate: optional(number()),
45
+ topAssets: optional(array(string())),
46
+ stablecoins: optional(array(string())),
47
+ batchSellDestStablecoins: optional(array(CaipAssetTypeStruct)),
48
+ isUnifiedUIEnabled: optional(boolean()),
49
+ isSingleSwapBridgeButtonEnabled: optional(boolean()),
50
+ isGaslessSwapEnabled: optional(boolean()),
51
+ noFeeAssets: optional(array(string())),
52
+ defaultPairs: optional(DefaultPairSchema),
53
+ });
54
+ export const PriceImpactThresholdSchema = type({
55
+ // We are moving into a unified approach where
56
+ // price impact thresholds will be segmented by
57
+ // importance rather than transaction type.
58
+ // The introduction of warning/danger will first be handled
59
+ // by mobile, followed by extension and then removal of gasless/normal
60
+ // from LD configs.
61
+ // To make the migration easier, we define all fields as optional for now.
62
+ // After the migration takes place, gasless/normal will be removed
63
+ // and warning/danger will be set as required fields.
64
+ gasless: number(), // Percentage value in decimal format (eg 0.02 is 2%)
65
+ normal: number(), // Percentage value in decimal format
66
+ warning: optional(number()), // Percentage value in decimal format
67
+ error: optional(number()), // Percentage value in decimal format
68
+ });
69
+ const GenericQuoteRequestSchema = type({
70
+ aggIds: optional(array(string())),
71
+ bridgeIds: optional(array(string())),
72
+ fee: optional(number()),
73
+ });
74
+ /**
75
+ * This is the schema for the feature flags response from the RemoteFeatureFlagController
76
+ */
77
+ export const PlatformConfigSchema = type({
78
+ priceImpactThreshold: optional(PriceImpactThresholdSchema),
79
+ quoteRequestOverrides: optional(record(string(), optional(GenericQuoteRequestSchema))),
80
+ minimumVersion: string(),
81
+ refreshRate: number(),
82
+ maxRefreshCount: number(),
83
+ support: boolean(),
84
+ chains: record(string(), ChainConfigurationSchema),
85
+ /**
86
+ * The bip44 default pairs for the chains
87
+ * Key is the CAIP chainId namespace
88
+ */
89
+ bip44DefaultPairs: optional(record(string(), optional(DefaultPairSchema))),
90
+ sse: optional(type({
91
+ enabled: boolean(),
92
+ /**
93
+ * The minimum version of the client required to enable SSE, for example 13.8.0
94
+ */
95
+ minimumVersion: VersionStringSchema,
96
+ })),
97
+ /**
98
+ * Array of chain objects ordered by preference/ranking
99
+ */
100
+ chainRanking: ChainRankingSchema,
101
+ maxPendingHistoryItemAgeMs: optional(number()),
102
+ });
103
+ export const validateFeatureFlagsResponse = (data) => {
104
+ return is(data, PlatformConfigSchema);
105
+ };
106
+ //# sourceMappingURL=feature-flags.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-flags.mjs","sourceRoot":"","sources":["../../src/validators/feature-flags.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,QAAQ,EACR,KAAK,EACL,OAAO,EACP,MAAM,EACN,EAAE,EACF,MAAM,EACP,8BAA8B;AAE/B,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,wBAAwB;AAEzE,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB,gCAAmB,CAAA;IACnB,4BAAe,CAAA;IACf,kEAAqD,CAAA;IACrD,gEAAmD,CAAA;IACnD,oDAAuC,CAAA;IACvC,oCAAuB,CAAA;IACvB,sCAAyB,CAAA;IACzB,wDAA2C,CAAA;AAC7C,CAAC,EATW,SAAS,KAAT,SAAS,QASpB;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CACvC,eAAe,EACf,CAAC,KAAc,EAAE,EAAE,CACjB,OAAO,KAAK,KAAK,QAAQ;IACzB,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;IAC/B,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAChC,CAAC;AAEF,MAAM,iBAAiB,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC;IACpC;;;O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C,OAAO,EAAE,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport {\n type,\n record,\n string,\n optional,\n array,\n boolean,\n number,\n is,\n define,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport { CaipChainIdStruct, CaipAssetTypeStruct } from '@metamask/utils';\n\nexport enum FeatureId {\n UNKNOWN = 'unknown',\n PERPS = 'perps',\n QUICK_BUY_FOLLOW_TRADING = 'quick_buy_follow_trading',\n QUICK_BUY_TOKEN_DETAILS = 'quick_buy_token_details',\n QUICK_BUY_EXPLORE = 'quick_buy_explore',\n DAPP_SWAP = 'dapp_swap',\n BATCH_SELL = 'batch_sell',\n UNIFIED_SWAP_BRIDGE = 'unified_swap_bridge',\n}\n\nexport const VersionStringSchema = define<string>(\n 'VersionString',\n (value: unknown) =>\n typeof value === 'string' &&\n /^(\\d+\\.*){2}\\d+$/u.test(value) &&\n value.split('.').length === 3,\n);\n\nconst DefaultPairSchema = type({\n /**\n * The standard default pairs. Use this if the pair is only set once.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n standard: record(string(), string()),\n /**\n * The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.\n * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.\n */\n other: record(string(), string()),\n});\n\nexport const ChainRankingItemSchema = type({\n /**\n * The CAIP-2 chain identifier (e.g., \"eip155:1\" for Ethereum mainnet)\n */\n chainId: CaipChainIdStruct,\n /**\n * The display name of the chain (e.g., \"Ethereum\")\n */\n name: string(),\n});\n\nexport const ChainRankingSchema = optional(array(ChainRankingItemSchema));\n\nexport const ChainConfigurationSchema = type({\n isActiveSrc: boolean(),\n isActiveDest: boolean(),\n refreshRate: optional(number()),\n topAssets: optional(array(string())),\n stablecoins: optional(array(string())),\n batchSellDestStablecoins: optional(array(CaipAssetTypeStruct)),\n isUnifiedUIEnabled: optional(boolean()),\n isSingleSwapBridgeButtonEnabled: optional(boolean()),\n isGaslessSwapEnabled: optional(boolean()),\n noFeeAssets: optional(array(string())),\n defaultPairs: optional(DefaultPairSchema),\n});\n\nexport const PriceImpactThresholdSchema = type({\n // We are moving into a unified approach where\n // price impact thresholds will be segmented by\n // importance rather than transaction type.\n // The introduction of warning/danger will first be handled\n // by mobile, followed by extension and then removal of gasless/normal\n // from LD configs.\n // To make the migration easier, we define all fields as optional for now.\n // After the migration takes place, gasless/normal will be removed\n // and warning/danger will be set as required fields.\n gasless: number(), // Percentage value in decimal format (eg 0.02 is 2%)\n normal: number(), // Percentage value in decimal format\n warning: optional(number()), // Percentage value in decimal format\n error: optional(number()), // Percentage value in decimal format\n});\n\nconst GenericQuoteRequestSchema = type({\n aggIds: optional(array(string())),\n bridgeIds: optional(array(string())),\n fee: optional(number()),\n});\n\n/**\n * This is the schema for the feature flags response from the RemoteFeatureFlagController\n */\nexport const PlatformConfigSchema = type({\n priceImpactThreshold: optional(PriceImpactThresholdSchema),\n quoteRequestOverrides: optional(\n record(string(), optional(GenericQuoteRequestSchema)),\n ),\n minimumVersion: string(),\n refreshRate: number(),\n maxRefreshCount: number(),\n support: boolean(),\n chains: record(string(), ChainConfigurationSchema),\n /**\n * The bip44 default pairs for the chains\n * Key is the CAIP chainId namespace\n */\n bip44DefaultPairs: optional(record(string(), optional(DefaultPairSchema))),\n sse: optional(\n type({\n enabled: boolean(),\n /**\n * The minimum version of the client required to enable SSE, for example 13.8.0\n */\n minimumVersion: VersionStringSchema,\n }),\n ),\n /**\n * Array of chain objects ordered by preference/ranking\n */\n chainRanking: ChainRankingSchema,\n maxPendingHistoryItemAgeMs: optional(number()),\n});\n\nexport const validateFeatureFlagsResponse = (\n data: unknown,\n): data is Infer<typeof PlatformConfigSchema> => {\n return is(data, PlatformConfigSchema);\n};\n"]}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntentSchema = exports.IntentOrderSchema = void 0;
4
+ const superstruct_1 = require("@metamask/superstruct");
5
+ const number_1 = require("./number.cjs");
6
+ const trade_1 = require("./trade.cjs");
7
+ // Allow digit strings for amounts/validTo for flexibility across providers
8
+ const DigitStringOrNumberSchema = (0, superstruct_1.union)([number_1.TruthyDigitStringSchema, (0, superstruct_1.number)()]);
9
+ /**
10
+ * Identifier of the intent protocol used for order creation and submission.
11
+ *
12
+ * Examples:
13
+ * - CoW Swap
14
+ * - Other EIP-712–based intent protocols
15
+ */
16
+ const IntentProtocolSchema = (0, superstruct_1.string)();
17
+ /**
18
+ * Schema for an intent-based order used for EIP-712 signing and submission.
19
+ *
20
+ * This represents the minimal subset of fields required by intent-based
21
+ * protocols (e.g. CoW Swap) to build, sign, and submit an order.
22
+ */
23
+ exports.IntentOrderSchema = (0, superstruct_1.type)({
24
+ /**
25
+ * Address of the token being sold.
26
+ */
27
+ sellToken: trade_1.HexString,
28
+ /**
29
+ * Address of the token being bought.
30
+ */
31
+ buyToken: trade_1.HexString,
32
+ /**
33
+ * Optional receiver of the bought tokens.
34
+ * If omitted, defaults to the signer / order owner.
35
+ */
36
+ receiver: (0, superstruct_1.optional)(trade_1.HexString),
37
+ /**
38
+ * Order expiration time.
39
+ *
40
+ * Can be provided as a UNIX timestamp in seconds, either as a number
41
+ * or as a digit string, depending on provider requirements.
42
+ */
43
+ validTo: DigitStringOrNumberSchema,
44
+ /**
45
+ * Arbitrary application-specific data attached to the order.
46
+ */
47
+ appData: (0, superstruct_1.string)(),
48
+ /**
49
+ * Hash of the `appData` field, used for EIP-712 signing.
50
+ */
51
+ appDataHash: trade_1.HexString,
52
+ /**
53
+ * Fee amount paid for order execution, expressed as a digit string.
54
+ */
55
+ feeAmount: number_1.TruthyDigitStringSchema,
56
+ /**
57
+ * Order kind.
58
+ *
59
+ * - `sell`: exact sell amount, variable buy amount
60
+ * - `buy`: exact buy amount, variable sell amount
61
+ */
62
+ kind: (0, superstruct_1.enums)(['sell', 'buy']),
63
+ /**
64
+ * Whether the order can be partially filled.
65
+ */
66
+ partiallyFillable: (0, superstruct_1.boolean)(),
67
+ /**
68
+ * Exact amount of the sell token.
69
+ *
70
+ * Required for `sell` orders.
71
+ */
72
+ sellAmount: (0, superstruct_1.optional)(number_1.TruthyDigitStringSchema),
73
+ /**
74
+ * Exact amount of the buy token.
75
+ *
76
+ * Required for `buy` orders.
77
+ */
78
+ buyAmount: (0, superstruct_1.optional)(number_1.TruthyDigitStringSchema),
79
+ /**
80
+ * Optional order owner / sender address.
81
+ *
82
+ * Provided for convenience when building the EIP-712 domain and message.
83
+ */
84
+ from: (0, superstruct_1.optional)(trade_1.HexString),
85
+ });
86
+ /**
87
+ * Schema representing an intent submission payload.
88
+ *
89
+ * Wraps the intent order along with protocol and optional routing metadata
90
+ * required by the backend or relayer infrastructure.
91
+ */
92
+ exports.IntentSchema = (0, superstruct_1.type)({
93
+ /**
94
+ * Identifier of the intent protocol used to interpret the order.
95
+ */
96
+ protocol: IntentProtocolSchema,
97
+ /**
98
+ * The intent order to be signed and submitted.
99
+ */
100
+ order: exports.IntentOrderSchema,
101
+ /**
102
+ * Optional settlement contract address used for execution.
103
+ */
104
+ settlementContract: (0, superstruct_1.optional)(trade_1.HexString),
105
+ /**
106
+ * Optional EIP-712 typed data payload for signing.
107
+ * Must be JSON-serializable and include required EIP-712 fields.
108
+ */
109
+ typedData: (0, superstruct_1.type)({
110
+ // Keep values as `any()` here. Using `unknown()` in this record causes
111
+ // TS2321/TS2589 (excessive type instantiation depth) in bridge state
112
+ // inference during build.
113
+ types: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.array)((0, superstruct_1.type)({
114
+ name: (0, superstruct_1.string)(),
115
+ type: (0, superstruct_1.string)(),
116
+ }))),
117
+ primaryType: (0, superstruct_1.string)(),
118
+ domain: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.any)()),
119
+ message: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.any)()),
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KAAK,EAAE,yBAAiB;IAExB;;OAEG;IACH,kBAAkB,EAAE,IAAA,sBAAQ,EAAC,iBAAS,CAAC;IAEvC;;;OAGG;IACH,SAAS,EAAE,IAAA,kBAAI,EAAC;QACd,uEAAuE;QACvE,qEAAqE;QACrE,0BAA0B;QAC1B,KAAK,EAAE,IAAA,oBAAM,EACX,IAAA,oBAAM,GAAE,EACR,IAAA,mBAAK,EACH,IAAA,kBAAI,EAAC;YACH,IAAI,EAAE,IAAA,oBAAM,GAAE;YACd,IAAI,EAAE,IAAA,oBAAM,GAAE;SACf,CAAC,CACH,CACF;QACD,WAAW,EAAE,IAAA,oBAAM,GAAE;QACrB,MAAM,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,iBAAG,GAAE,CAAC;QAC/B,OAAO,EAAE,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,iBAAG,GAAE,CAAC;KACjC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import {\n union,\n number,\n string,\n type,\n optional,\n enums,\n boolean,\n record,\n array,\n any,\n} from '@metamask/superstruct';\n\nimport { TruthyDigitStringSchema } from './number';\nimport { HexString } from './trade';\n\n// Allow digit strings for amounts/validTo for flexibility across providers\nconst DigitStringOrNumberSchema = union([TruthyDigitStringSchema, number()]);\n/**\n * Identifier of the intent protocol used for order creation and submission.\n *\n * Examples:\n * - CoW Swap\n * - Other EIP-712–based intent protocols\n */\nconst IntentProtocolSchema = string();\n/**\n * Schema for an intent-based order used for EIP-712 signing and submission.\n *\n * This represents the minimal subset of fields required by intent-based\n * protocols (e.g. CoW Swap) to build, sign, and submit an order.\n */\n\nexport const IntentOrderSchema = type({\n /**\n * Address of the token being sold.\n */\n sellToken: HexString,\n\n /**\n * Address of the token being bought.\n */\n buyToken: HexString,\n\n /**\n * Optional receiver of the bought tokens.\n * If omitted, defaults to the signer / order owner.\n */\n receiver: optional(HexString),\n\n /**\n * Order expiration time.\n *\n * Can be provided as a UNIX timestamp in seconds, either as a number\n * or as a digit string, depending on provider requirements.\n */\n validTo: DigitStringOrNumberSchema,\n\n /**\n * Arbitrary application-specific data attached to the order.\n */\n appData: string(),\n\n /**\n * Hash of the `appData` field, used for EIP-712 signing.\n */\n appDataHash: HexString,\n\n /**\n * Fee amount paid for order execution, expressed as a digit string.\n */\n feeAmount: TruthyDigitStringSchema,\n\n /**\n * Order kind.\n *\n * - `sell`: exact sell amount, variable buy amount\n * - `buy`: exact buy amount, variable sell amount\n */\n kind: enums(['sell', 'buy']),\n\n /**\n * Whether the order can be partially filled.\n */\n partiallyFillable: boolean(),\n\n /**\n * Exact amount of the sell token.\n *\n * Required for `sell` orders.\n */\n sellAmount: optional(TruthyDigitStringSchema),\n\n /**\n * Exact amount of the buy token.\n *\n * Required for `buy` orders.\n */\n buyAmount: optional(TruthyDigitStringSchema),\n\n /**\n * Optional order owner / sender address.\n *\n * Provided for convenience when building the EIP-712 domain and message.\n */\n from: optional(HexString),\n});\n/**\n * Schema representing an intent submission payload.\n *\n * Wraps the intent order along with protocol and optional routing metadata\n * required by the backend or relayer infrastructure.\n */\n\nexport const IntentSchema = type({\n /**\n * Identifier of the intent protocol used to interpret the order.\n */\n protocol: IntentProtocolSchema,\n\n /**\n * The intent order to be signed and submitted.\n */\n order: IntentOrderSchema,\n\n /**\n * Optional settlement contract address used for execution.\n */\n settlementContract: optional(HexString),\n\n /**\n * Optional EIP-712 typed data payload for signing.\n * Must be JSON-serializable and include required EIP-712 fields.\n */\n typedData: type({\n // Keep values as `any()` here. Using `unknown()` in this record causes\n // TS2321/TS2589 (excessive type instantiation depth) in bridge state\n // inference during build.\n types: record(\n string(),\n array(\n type({\n name: string(),\n type: string(),\n }),\n ),\n ),\n primaryType: string(),\n domain: record(string(), any()),\n message: record(string(), any()),\n }),\n});\n"]}