@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
@@ -1,471 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateBatchSellTradesResponse = exports.BatchSellTradesResponseSchema = exports.SimulatedGasFeeLimitsSchema = exports.BatchSellTransactionType = exports.validateQuoteStreamComplete = exports.QuoteStreamCompleteSchema = exports.QuoteStreamCompleteReason = exports.validateTokenFeature = exports.TokenFeatureSchema = exports.TokenFeatureType = exports.validateQuoteResponseV1 = exports.QuoteResponseSchema = exports.StellarTradeDataSchema = exports.TronTradeDataSchema = exports.BitcoinTradeDataSchema = exports.TxDataSchema = exports.QuoteSchema = exports.GaslessPropertiesSchema = exports.TxFeeGasLimitsSchema = exports.IntentSchema = exports.IntentOrderSchema = exports.StepSchema = exports.ProtocolSchema = exports.FeeDataSchema = exports.validateSwapsTokenObject = exports.validateFeatureFlagsResponse = exports.PlatformConfigSchema = exports.PriceImpactThresholdSchema = exports.ChainConfigurationSchema = exports.ChainRankingSchema = exports.ChainRankingItemSchema = exports.BridgeAssetSchema = exports.truthyString = exports.ActionTypes = exports.DiscountType = exports.FeeType = void 0;
4
- /* eslint-disable @typescript-eslint/naming-convention */
5
- const controller_utils_1 = require("@metamask/controller-utils");
6
- const superstruct_1 = require("@metamask/superstruct");
7
- const utils_1 = require("@metamask/utils");
8
- var FeeType;
9
- (function (FeeType) {
10
- FeeType["METABRIDGE"] = "metabridge";
11
- FeeType["REFUEL"] = "refuel";
12
- FeeType["TX_FEE"] = "txFee";
13
- })(FeeType || (exports.FeeType = FeeType = {}));
14
- var DiscountType;
15
- (function (DiscountType) {
16
- DiscountType["VIP"] = "vip";
17
- DiscountType["PROMO"] = "promo";
18
- DiscountType["DAO"] = "dao";
19
- })(DiscountType || (exports.DiscountType = DiscountType = {}));
20
- var ActionTypes;
21
- (function (ActionTypes) {
22
- ActionTypes["BRIDGE"] = "bridge";
23
- ActionTypes["SWAP"] = "swap";
24
- ActionTypes["REFUEL"] = "refuel";
25
- })(ActionTypes || (exports.ActionTypes = ActionTypes = {}));
26
- const HexAddressSchema = (0, superstruct_1.define)('HexAddress', (value) => (0, controller_utils_1.isValidHexAddress)(value, { allowNonPrefixed: false }));
27
- const HexStringSchema = (0, superstruct_1.define)('HexString', utils_1.isStrictHexString);
28
- const NumberStringSchema = (0, superstruct_1.define)('NumberString', (value) => typeof value === 'string' && /^\d+$/u.test(value));
29
- const VersionStringSchema = (0, superstruct_1.define)('VersionString', (value) => typeof value === 'string' &&
30
- /^(\d+\.*){2}\d+$/u.test(value) &&
31
- value.split('.').length === 3);
32
- const truthyString = (value) => Boolean(value?.length);
33
- exports.truthyString = truthyString;
34
- const TruthyDigitStringSchema = (0, superstruct_1.pattern)((0, superstruct_1.string)(), /^\d+$/u);
35
- const ChainIdSchema = (0, superstruct_1.number)();
36
- exports.BridgeAssetSchema = (0, superstruct_1.type)({
37
- /**
38
- * The chainId of the token
39
- */
40
- chainId: ChainIdSchema,
41
- /**
42
- * An address that the metaswap-api recognizes as the default token
43
- */
44
- address: (0, superstruct_1.string)(),
45
- /**
46
- * The assetId of the token
47
- */
48
- assetId: utils_1.CaipAssetTypeStruct,
49
- /**
50
- * The symbol of token object
51
- */
52
- symbol: (0, superstruct_1.string)(),
53
- /**
54
- * The name for the network
55
- */
56
- name: (0, superstruct_1.string)(),
57
- decimals: (0, superstruct_1.number)(),
58
- /**
59
- * URL for token icon
60
- */
61
- icon: (0, superstruct_1.optional)((0, superstruct_1.nullable)((0, superstruct_1.string)())),
62
- /**
63
- * URL for token icon
64
- */
65
- iconUrl: (0, superstruct_1.optional)((0, superstruct_1.nullable)((0, superstruct_1.string)())),
66
- });
67
- const DefaultPairSchema = (0, superstruct_1.type)({
68
- /**
69
- * The standard default pairs. Use this if the pair is only set once.
70
- * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
71
- */
72
- standard: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.string)()),
73
- /**
74
- * The other default pairs. Use this if the dest token depends on the src token and can be set multiple times.
75
- * The key is the CAIP asset type of the src token and the value is the CAIP asset type of the dest token.
76
- */
77
- other: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.string)()),
78
- });
79
- exports.ChainRankingItemSchema = (0, superstruct_1.type)({
80
- /**
81
- * The CAIP-2 chain identifier (e.g., "eip155:1" for Ethereum mainnet)
82
- */
83
- chainId: utils_1.CaipChainIdStruct,
84
- /**
85
- * The display name of the chain (e.g., "Ethereum")
86
- */
87
- name: (0, superstruct_1.string)(),
88
- });
89
- exports.ChainRankingSchema = (0, superstruct_1.optional)((0, superstruct_1.array)(exports.ChainRankingItemSchema));
90
- exports.ChainConfigurationSchema = (0, superstruct_1.type)({
91
- isActiveSrc: (0, superstruct_1.boolean)(),
92
- isActiveDest: (0, superstruct_1.boolean)(),
93
- refreshRate: (0, superstruct_1.optional)((0, superstruct_1.number)()),
94
- topAssets: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
95
- stablecoins: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
96
- batchSellDestStablecoins: (0, superstruct_1.optional)((0, superstruct_1.array)(utils_1.CaipAssetTypeStruct)),
97
- isUnifiedUIEnabled: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
98
- isSingleSwapBridgeButtonEnabled: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
99
- isGaslessSwapEnabled: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
100
- noFeeAssets: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
101
- defaultPairs: (0, superstruct_1.optional)(DefaultPairSchema),
102
- });
103
- exports.PriceImpactThresholdSchema = (0, superstruct_1.type)({
104
- // TODO:
105
- // We are moving into a unified approach where
106
- // price impact thresholds will be segmented by
107
- // importance rather than transaction type.
108
- // The introduction of warning/danger will first be handled
109
- // by mobile, followed by extension and then removal of gasless/normal
110
- // from LD configs.
111
- // To make the migration easier, we define all fields as optional for now.
112
- // After the migration takes place, gasless/normal will be removed
113
- // and warning/danger will be set as required fields.
114
- gasless: (0, superstruct_1.number)(), // Percentage value in decimal format (eg 0.02 is 2%)
115
- normal: (0, superstruct_1.number)(), // Percentage value in decimal format
116
- warning: (0, superstruct_1.optional)((0, superstruct_1.number)()), // Percentage value in decimal format
117
- error: (0, superstruct_1.optional)((0, superstruct_1.number)()), // Percentage value in decimal format
118
- });
119
- const GenericQuoteRequestSchema = (0, superstruct_1.type)({
120
- aggIds: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
121
- bridgeIds: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.string)())),
122
- fee: (0, superstruct_1.optional)((0, superstruct_1.number)()),
123
- });
124
- /**
125
- * This is the schema for the feature flags response from the RemoteFeatureFlagController
126
- */
127
- exports.PlatformConfigSchema = (0, superstruct_1.type)({
128
- priceImpactThreshold: (0, superstruct_1.optional)(exports.PriceImpactThresholdSchema),
129
- quoteRequestOverrides: (0, superstruct_1.optional)((0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.optional)(GenericQuoteRequestSchema))),
130
- minimumVersion: (0, superstruct_1.string)(),
131
- refreshRate: (0, superstruct_1.number)(),
132
- maxRefreshCount: (0, superstruct_1.number)(),
133
- support: (0, superstruct_1.boolean)(),
134
- chains: (0, superstruct_1.record)((0, superstruct_1.string)(), exports.ChainConfigurationSchema),
135
- /**
136
- * The bip44 default pairs for the chains
137
- * Key is the CAIP chainId namespace
138
- */
139
- bip44DefaultPairs: (0, superstruct_1.optional)((0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.optional)(DefaultPairSchema))),
140
- sse: (0, superstruct_1.optional)((0, superstruct_1.type)({
141
- enabled: (0, superstruct_1.boolean)(),
142
- /**
143
- * The minimum version of the client required to enable SSE, for example 13.8.0
144
- */
145
- minimumVersion: VersionStringSchema,
146
- })),
147
- /**
148
- * Array of chain objects ordered by preference/ranking
149
- */
150
- chainRanking: exports.ChainRankingSchema,
151
- maxPendingHistoryItemAgeMs: (0, superstruct_1.optional)((0, superstruct_1.number)()),
152
- });
153
- const validateFeatureFlagsResponse = (data) => {
154
- return (0, superstruct_1.is)(data, exports.PlatformConfigSchema);
155
- };
156
- exports.validateFeatureFlagsResponse = validateFeatureFlagsResponse;
157
- const validateSwapsTokenObject = (data) => {
158
- return (0, superstruct_1.is)(data, exports.BridgeAssetSchema);
159
- };
160
- exports.validateSwapsTokenObject = validateSwapsTokenObject;
161
- exports.FeeDataSchema = (0, superstruct_1.type)({
162
- amount: TruthyDigitStringSchema,
163
- asset: exports.BridgeAssetSchema,
164
- discountType: (0, superstruct_1.optional)((0, superstruct_1.nullable)((0, superstruct_1.string)())),
165
- });
166
- exports.ProtocolSchema = (0, superstruct_1.type)({
167
- name: (0, superstruct_1.string)(),
168
- displayName: (0, superstruct_1.optional)((0, superstruct_1.string)()),
169
- icon: (0, superstruct_1.optional)((0, superstruct_1.string)()),
170
- });
171
- exports.StepSchema = (0, superstruct_1.type)({
172
- action: (0, superstruct_1.enums)(Object.values(ActionTypes)),
173
- srcChainId: ChainIdSchema,
174
- destChainId: (0, superstruct_1.optional)(ChainIdSchema),
175
- srcAsset: exports.BridgeAssetSchema,
176
- destAsset: exports.BridgeAssetSchema,
177
- srcAmount: (0, superstruct_1.string)(),
178
- destAmount: (0, superstruct_1.string)(),
179
- protocol: exports.ProtocolSchema,
180
- });
181
- const RefuelDataSchema = exports.StepSchema;
182
- // Allow digit strings for amounts/validTo for flexibility across providers
183
- const DigitStringOrNumberSchema = (0, superstruct_1.union)([TruthyDigitStringSchema, (0, superstruct_1.number)()]);
184
- /**
185
- * Identifier of the intent protocol used for order creation and submission.
186
- *
187
- * Examples:
188
- * - CoW Swap
189
- * - Other EIP-712–based intent protocols
190
- */
191
- const IntentProtocolSchema = (0, superstruct_1.string)();
192
- /**
193
- * Schema for an intent-based order used for EIP-712 signing and submission.
194
- *
195
- * This represents the minimal subset of fields required by intent-based
196
- * protocols (e.g. CoW Swap) to build, sign, and submit an order.
197
- */
198
- exports.IntentOrderSchema = (0, superstruct_1.type)({
199
- /**
200
- * Address of the token being sold.
201
- */
202
- sellToken: HexAddressSchema,
203
- /**
204
- * Address of the token being bought.
205
- */
206
- buyToken: HexAddressSchema,
207
- /**
208
- * Optional receiver of the bought tokens.
209
- * If omitted, defaults to the signer / order owner.
210
- */
211
- receiver: (0, superstruct_1.optional)(HexAddressSchema),
212
- /**
213
- * Order expiration time.
214
- *
215
- * Can be provided as a UNIX timestamp in seconds, either as a number
216
- * or as a digit string, depending on provider requirements.
217
- */
218
- validTo: DigitStringOrNumberSchema,
219
- /**
220
- * Arbitrary application-specific data attached to the order.
221
- */
222
- appData: (0, superstruct_1.string)(),
223
- /**
224
- * Hash of the `appData` field, used for EIP-712 signing.
225
- */
226
- appDataHash: HexStringSchema,
227
- /**
228
- * Fee amount paid for order execution, expressed as a digit string.
229
- */
230
- feeAmount: TruthyDigitStringSchema,
231
- /**
232
- * Order kind.
233
- *
234
- * - `sell`: exact sell amount, variable buy amount
235
- * - `buy`: exact buy amount, variable sell amount
236
- */
237
- kind: (0, superstruct_1.enums)(['sell', 'buy']),
238
- /**
239
- * Whether the order can be partially filled.
240
- */
241
- partiallyFillable: (0, superstruct_1.boolean)(),
242
- /**
243
- * Exact amount of the sell token.
244
- *
245
- * Required for `sell` orders.
246
- */
247
- sellAmount: (0, superstruct_1.optional)(TruthyDigitStringSchema),
248
- /**
249
- * Exact amount of the buy token.
250
- *
251
- * Required for `buy` orders.
252
- */
253
- buyAmount: (0, superstruct_1.optional)(TruthyDigitStringSchema),
254
- /**
255
- * Optional order owner / sender address.
256
- *
257
- * Provided for convenience when building the EIP-712 domain and message.
258
- */
259
- from: (0, superstruct_1.optional)(HexAddressSchema),
260
- });
261
- /**
262
- * Schema representing an intent submission payload.
263
- *
264
- * Wraps the intent order along with protocol and optional routing metadata
265
- * required by the backend or relayer infrastructure.
266
- */
267
- exports.IntentSchema = (0, superstruct_1.type)({
268
- /**
269
- * Identifier of the intent protocol used to interpret the order.
270
- */
271
- protocol: IntentProtocolSchema,
272
- /**
273
- * The intent order to be signed and submitted.
274
- */
275
- order: exports.IntentOrderSchema,
276
- /**
277
- * Optional settlement contract address used for execution.
278
- */
279
- settlementContract: (0, superstruct_1.optional)(HexAddressSchema),
280
- /**
281
- * Optional EIP-712 typed data payload for signing.
282
- * Must be JSON-serializable and include required EIP-712 fields.
283
- */
284
- typedData: (0, superstruct_1.type)({
285
- // Keep values as `any()` here. Using `unknown()` in this record causes
286
- // TS2321/TS2589 (excessive type instantiation depth) in bridge state
287
- // inference during build.
288
- types: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.array)((0, superstruct_1.type)({
289
- name: (0, superstruct_1.string)(),
290
- type: (0, superstruct_1.string)(),
291
- }))),
292
- primaryType: (0, superstruct_1.string)(),
293
- domain: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.any)()),
294
- message: (0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.any)()),
295
- }),
296
- });
297
- exports.TxFeeGasLimitsSchema = (0, superstruct_1.type)({
298
- maxFeePerGas: NumberStringSchema,
299
- maxPriorityFeePerGas: NumberStringSchema,
300
- });
301
- exports.GaslessPropertiesSchema = (0, superstruct_1.type)({
302
- gasIncluded: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
303
- /**
304
- * Whether the quote can use EIP-7702 delegated gasless execution
305
- */
306
- gasIncluded7702: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
307
- /**
308
- * A third party sponsors the gas. If true, then gasIncluded7702 is also true.
309
- */
310
- gasSponsored: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
311
- });
312
- exports.QuoteSchema = (0, superstruct_1.intersection)([
313
- exports.GaslessPropertiesSchema,
314
- (0, superstruct_1.type)({
315
- requestId: (0, superstruct_1.string)(),
316
- srcChainId: ChainIdSchema,
317
- srcAsset: exports.BridgeAssetSchema,
318
- /**
319
- * The amount sent, in atomic amount: amount sent - fees
320
- * Some tokens have a fee of 0, so sometimes it's equal to amount sent
321
- */
322
- srcTokenAmount: (0, superstruct_1.string)(),
323
- destChainId: ChainIdSchema,
324
- destAsset: exports.BridgeAssetSchema,
325
- /**
326
- * The amount received, in atomic amount
327
- */
328
- destTokenAmount: (0, superstruct_1.string)(),
329
- /**
330
- * The minimum amount that will be received, in atomic amount
331
- */
332
- minDestTokenAmount: (0, superstruct_1.string)(),
333
- feeData: (0, superstruct_1.type)({
334
- [FeeType.METABRIDGE]: exports.FeeDataSchema,
335
- /**
336
- * This is the fee for the swap transaction taken from either the
337
- * src or dest token if the quote has gas fees included or "gasless"
338
- */
339
- [FeeType.TX_FEE]: (0, superstruct_1.optional)((0, superstruct_1.intersection)([exports.FeeDataSchema, exports.TxFeeGasLimitsSchema])),
340
- }),
341
- bridgeId: (0, superstruct_1.string)(),
342
- bridges: (0, superstruct_1.array)((0, superstruct_1.string)()),
343
- steps: (0, superstruct_1.array)(exports.StepSchema),
344
- refuel: (0, superstruct_1.optional)(RefuelDataSchema),
345
- priceData: (0, superstruct_1.optional)((0, superstruct_1.type)({
346
- totalFromAmountUsd: (0, superstruct_1.optional)((0, superstruct_1.string)()),
347
- totalToAmountUsd: (0, superstruct_1.optional)((0, superstruct_1.string)()),
348
- priceImpact: (0, superstruct_1.optional)((0, superstruct_1.string)()),
349
- totalFeeAmountUsd: (0, superstruct_1.optional)((0, superstruct_1.string)()),
350
- })),
351
- intent: (0, superstruct_1.optional)(exports.IntentSchema),
352
- }),
353
- ]);
354
- exports.TxDataSchema = (0, superstruct_1.type)({
355
- chainId: (0, superstruct_1.number)(),
356
- to: HexAddressSchema,
357
- from: HexAddressSchema,
358
- value: HexStringSchema,
359
- data: HexStringSchema,
360
- gasLimit: (0, superstruct_1.nullable)((0, superstruct_1.number)()),
361
- effectiveGas: (0, superstruct_1.optional)((0, superstruct_1.number)()),
362
- });
363
- exports.BitcoinTradeDataSchema = (0, superstruct_1.type)({
364
- unsignedPsbtBase64: (0, superstruct_1.string)(),
365
- inputsToSign: (0, superstruct_1.nullable)((0, superstruct_1.array)((0, superstruct_1.type)({}))),
366
- });
367
- exports.TronTradeDataSchema = (0, superstruct_1.type)({
368
- raw_data_hex: (0, superstruct_1.string)(),
369
- visible: (0, superstruct_1.optional)((0, superstruct_1.boolean)()),
370
- raw_data: (0, superstruct_1.optional)((0, superstruct_1.nullable)((0, superstruct_1.type)({
371
- contract: (0, superstruct_1.optional)((0, superstruct_1.array)((0, superstruct_1.type)({
372
- type: (0, superstruct_1.optional)((0, superstruct_1.string)()),
373
- }))),
374
- fee_limit: (0, superstruct_1.optional)((0, superstruct_1.number)()),
375
- }))),
376
- });
377
- /**
378
- * Stellar bridge quote: unsigned transaction envelope as XDR (base64).
379
- */
380
- exports.StellarTradeDataSchema = (0, superstruct_1.union)([
381
- (0, superstruct_1.type)({ xdrBase64: (0, superstruct_1.string)() }),
382
- (0, superstruct_1.type)({ xdr: (0, superstruct_1.string)() }),
383
- ]);
384
- exports.QuoteResponseSchema = (0, superstruct_1.type)({
385
- quoteId: (0, superstruct_1.optional)((0, superstruct_1.string)()),
386
- quote: exports.QuoteSchema,
387
- estimatedProcessingTimeInSeconds: (0, superstruct_1.number)(),
388
- approval: (0, superstruct_1.optional)((0, superstruct_1.union)([exports.TxDataSchema, exports.TronTradeDataSchema])),
389
- trade: (0, superstruct_1.union)([
390
- exports.TxDataSchema,
391
- exports.BitcoinTradeDataSchema,
392
- exports.TronTradeDataSchema,
393
- exports.StellarTradeDataSchema,
394
- (0, superstruct_1.string)(),
395
- ]),
396
- });
397
- const validateQuoteResponseV1 = (data) => {
398
- (0, superstruct_1.assert)(data, exports.QuoteResponseSchema);
399
- return true;
400
- };
401
- exports.validateQuoteResponseV1 = validateQuoteResponseV1;
402
- var TokenFeatureType;
403
- (function (TokenFeatureType) {
404
- TokenFeatureType["MALICIOUS"] = "Malicious";
405
- TokenFeatureType["WARNING"] = "Warning";
406
- TokenFeatureType["INFO"] = "Info";
407
- TokenFeatureType["BENIGN"] = "Benign";
408
- })(TokenFeatureType || (exports.TokenFeatureType = TokenFeatureType = {}));
409
- exports.TokenFeatureSchema = (0, superstruct_1.type)({
410
- feature_id: (0, superstruct_1.string)(),
411
- type: (0, superstruct_1.enums)(Object.values(TokenFeatureType)),
412
- description: (0, superstruct_1.string)(),
413
- });
414
- const validateTokenFeature = (data) => {
415
- (0, superstruct_1.assert)(data, exports.TokenFeatureSchema);
416
- return true;
417
- };
418
- exports.validateTokenFeature = validateTokenFeature;
419
- var QuoteStreamCompleteReason;
420
- (function (QuoteStreamCompleteReason) {
421
- QuoteStreamCompleteReason["RETRY"] = "RETRY";
422
- QuoteStreamCompleteReason["AMOUNT_TOO_HIGH"] = "AMOUNT_TOO_HIGH";
423
- QuoteStreamCompleteReason["AMOUNT_TOO_LOW"] = "AMOUNT_TOO_LOW";
424
- QuoteStreamCompleteReason["SLIPPAGE_TOO_HIGH"] = "SLIPPAGE_TOO_HIGH";
425
- QuoteStreamCompleteReason["SLIPPAGE_TOO_LOW"] = "SLIPPAGE_TOO_LOW";
426
- QuoteStreamCompleteReason["TOKEN_NOT_SUPPORTED"] = "TOKEN_NOT_SUPPORTED";
427
- QuoteStreamCompleteReason["RWA_GEO_RESTRICTED"] = "RWA_GEO_RESTRICTED";
428
- QuoteStreamCompleteReason["RWA_NATIVE_TOKEN_UNSUPPORTED"] = "RWA_NATIVE_TOKEN_UNSUPPORTED";
429
- QuoteStreamCompleteReason["RWA_MARKET_UNAVAILABLE"] = "RWA_MARKET_UNAVAILABLE";
430
- })(QuoteStreamCompleteReason || (exports.QuoteStreamCompleteReason = QuoteStreamCompleteReason = {}));
431
- exports.QuoteStreamCompleteSchema = (0, superstruct_1.type)({
432
- quoteCount: (0, superstruct_1.number)(),
433
- hasQuotes: (0, superstruct_1.boolean)(),
434
- reason: (0, superstruct_1.optional)((0, superstruct_1.enums)(Object.values(QuoteStreamCompleteReason))),
435
- context: (0, superstruct_1.optional)((0, superstruct_1.record)((0, superstruct_1.string)(), (0, superstruct_1.any)())),
436
- });
437
- const validateQuoteStreamComplete = (data) => {
438
- (0, superstruct_1.assert)(data, exports.QuoteStreamCompleteSchema);
439
- return true;
440
- };
441
- exports.validateQuoteStreamComplete = validateQuoteStreamComplete;
442
- var BatchSellTransactionType;
443
- (function (BatchSellTransactionType) {
444
- BatchSellTransactionType["TRADE"] = "trade";
445
- BatchSellTransactionType["APPROVAL"] = "approval";
446
- BatchSellTransactionType["TRANSFER"] = "transfer";
447
- })(BatchSellTransactionType || (exports.BatchSellTransactionType = BatchSellTransactionType = {}));
448
- exports.SimulatedGasFeeLimitsSchema = (0, superstruct_1.type)({
449
- maxFeePerGas: HexStringSchema,
450
- maxPriorityFeePerGas: HexStringSchema,
451
- });
452
- exports.BatchSellTradesResponseSchema = (0, superstruct_1.intersection)([
453
- (0, superstruct_1.type)({
454
- transactions: (0, superstruct_1.array)((0, superstruct_1.intersection)([
455
- exports.TxDataSchema,
456
- exports.SimulatedGasFeeLimitsSchema,
457
- (0, superstruct_1.type)({ type: (0, superstruct_1.enums)(Object.values(BatchSellTransactionType)) }),
458
- ])),
459
- fee: (0, superstruct_1.optional)((0, superstruct_1.type)({
460
- asset: exports.BridgeAssetSchema,
461
- amount: NumberStringSchema,
462
- })),
463
- }),
464
- exports.GaslessPropertiesSchema,
465
- ]);
466
- const validateBatchSellTradesResponse = (data) => {
467
- (0, superstruct_1.assert)(data, exports.BatchSellTradesResponseSchema);
468
- return true;
469
- };
470
- exports.validateBatchSellTradesResponse = validateBatchSellTradesResponse;
471
- //# sourceMappingURL=validators.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validators.cjs","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,iEAA+D;AAE/D,uDAiB+B;AAC/B,2CAIyB;AAEzB,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,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C3C,CAAC,CAAC;AAEI,MAAM,2BAA2B,GAAG,CACzC,IAAa,EACoC,EAAE;IACnD,IAAA,oBAAM,EAAC,IAAI,EAAE,iCAAyB,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,2BAA2B,+BAKtC;AAEF,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,2CAAe,CAAA;IACf,iDAAqB,CAAA;IACrB,iDAAqB,CAAA;AACvB,CAAC,EAJW,wBAAwB,wCAAxB,wBAAwB,QAInC;AAEY,QAAA,2BAA2B,GAAG,IAAA,kBAAI,EAAC;IAC9C,YAAY,EAAE,eAAe;IAC7B,oBAAoB,EAAE,eAAe;CACtC,CAAC,CAAC;AAEU,QAAA,6BAA6B,GAAG,IAAA,0BAAY,EAAC;IACxD,IAAA,kBAAI,EAAC;QACH,YAAY,EAAE,IAAA,mBAAK,EACjB,IAAA,0BAAY,EAAC;YACX,oBAAY;YACZ,mCAA2B;YAC3B,IAAA,kBAAI,EAAC,EAAE,IAAI,EAAE,IAAA,mBAAK,EAAC,MAAM,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,EAAE,CAAC;SAC/D,CAAC,CACH;QACD,GAAG,EAAE,IAAA,sBAAQ,EACX,IAAA,kBAAI,EAAC;YACH,KAAK,EAAE,yBAAiB;YACxB,MAAM,EAAE,kBAAkB;SAC3B,CAAC,CACH;KACF,CAAC;IACF,+BAAuB;CACxB,CAAC,CAAC;AAEI,MAAM,+BAA+B,GAAG,CAC7C,IAAa,EACwC,EAAE;IACvD,IAAA,oBAAM,EAAC,IAAI,EAAE,qCAA6B,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,+BAA+B,mCAK1C","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport { isValidHexAddress } from '@metamask/controller-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n any,\n string,\n boolean,\n number,\n type,\n is,\n record,\n array,\n nullable,\n optional,\n enums,\n define,\n union,\n assert,\n pattern,\n intersection,\n} from '@metamask/superstruct';\nimport {\n CaipAssetTypeStruct,\n CaipChainIdStruct,\n isStrictHexString,\n} from '@metamask/utils';\n\nexport enum FeeType {\n METABRIDGE = 'metabridge',\n REFUEL = 'refuel',\n TX_FEE = 'txFee',\n}\n\nexport enum DiscountType {\n VIP = 'vip',\n PROMO = 'promo',\n DAO = 'dao',\n}\n\nexport enum ActionTypes {\n BRIDGE = 'bridge',\n SWAP = 'swap',\n REFUEL = 'refuel',\n}\n\nconst HexAddressSchema = define<`0x${string}`>('HexAddress', (value: unknown) =>\n isValidHexAddress(value as string, { allowNonPrefixed: false }),\n);\n\nconst HexStringSchema = define<`0x${string}`>('HexString', isStrictHexString);\n\nconst NumberStringSchema = define<string>(\n 'NumberString',\n (value: unknown) => typeof value === 'string' && /^\\d+$/u.test(value),\n);\n\nconst 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\nexport const truthyString = (value: string): boolean => Boolean(value?.length);\nconst TruthyDigitStringSchema = pattern(string(), /^\\d+$/u);\n\nconst ChainIdSchema = number();\n\nexport const BridgeAssetSchema = type({\n /**\n * The chainId of the token\n */\n chainId: ChainIdSchema,\n /**\n * An address that the metaswap-api recognizes as the default token\n */\n address: string(),\n /**\n * The assetId of the token\n */\n assetId: CaipAssetTypeStruct,\n /**\n * The symbol of token object\n */\n symbol: string(),\n /**\n * The name for the network\n */\n name: string(),\n decimals: number(),\n /**\n * URL for token icon\n */\n icon: optional(nullable(string())),\n /**\n * URL for token icon\n */\n iconUrl: optional(nullable(string())),\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 // TODO:\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\nexport const validateSwapsTokenObject = (\n data: unknown,\n): data is Infer<typeof BridgeAssetSchema> => {\n return is(data, BridgeAssetSchema);\n};\n\nexport const FeeDataSchema = type({\n amount: TruthyDigitStringSchema,\n asset: BridgeAssetSchema,\n discountType: optional(nullable(string())),\n});\n\nexport const ProtocolSchema = type({\n name: string(),\n displayName: optional(string()),\n icon: optional(string()),\n});\n\nexport const StepSchema = type({\n action: enums(Object.values(ActionTypes)),\n srcChainId: ChainIdSchema,\n destChainId: optional(ChainIdSchema),\n srcAsset: BridgeAssetSchema,\n destAsset: BridgeAssetSchema,\n srcAmount: string(),\n destAmount: string(),\n protocol: ProtocolSchema,\n});\n\nconst RefuelDataSchema = StepSchema;\n\n// Allow digit strings for amounts/validTo for flexibility across providers\nconst DigitStringOrNumberSchema = union([TruthyDigitStringSchema, number()]);\n\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/**\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 */\nexport const IntentOrderSchema = type({\n /**\n * Address of the token being sold.\n */\n sellToken: HexAddressSchema,\n\n /**\n * Address of the token being bought.\n */\n buyToken: HexAddressSchema,\n\n /**\n * Optional receiver of the bought tokens.\n * If omitted, defaults to the signer / order owner.\n */\n receiver: optional(HexAddressSchema),\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: HexStringSchema,\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(HexAddressSchema),\n});\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 */\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(HexAddressSchema),\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\nexport const TxFeeGasLimitsSchema = type({\n maxFeePerGas: NumberStringSchema,\n maxPriorityFeePerGas: NumberStringSchema,\n});\n\nexport const GaslessPropertiesSchema = type({\n gasIncluded: optional(boolean()),\n /**\n * Whether the quote can use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: optional(boolean()),\n /**\n * A third party sponsors the gas. If true, then gasIncluded7702 is also true.\n */\n gasSponsored: optional(boolean()),\n});\n\nexport const QuoteSchema = intersection([\n GaslessPropertiesSchema,\n type({\n requestId: string(),\n srcChainId: ChainIdSchema,\n srcAsset: BridgeAssetSchema,\n /**\n * The amount sent, in atomic amount: amount sent - fees\n * Some tokens have a fee of 0, so sometimes it's equal to amount sent\n */\n srcTokenAmount: string(),\n destChainId: ChainIdSchema,\n destAsset: BridgeAssetSchema,\n /**\n * The amount received, in atomic amount\n */\n destTokenAmount: string(),\n /**\n * The minimum amount that will be received, in atomic amount\n */\n minDestTokenAmount: string(),\n feeData: type({\n [FeeType.METABRIDGE]: FeeDataSchema,\n /**\n * This is the fee for the swap transaction taken from either the\n * src or dest token if the quote has gas fees included or \"gasless\"\n */\n [FeeType.TX_FEE]: optional(\n intersection([FeeDataSchema, TxFeeGasLimitsSchema]),\n ),\n }),\n bridgeId: string(),\n bridges: array(string()),\n steps: array(StepSchema),\n refuel: optional(RefuelDataSchema),\n priceData: optional(\n type({\n totalFromAmountUsd: optional(string()),\n totalToAmountUsd: optional(string()),\n priceImpact: optional(string()),\n totalFeeAmountUsd: optional(string()),\n }),\n ),\n intent: optional(IntentSchema),\n }),\n]);\n\nexport const TxDataSchema = type({\n chainId: number(),\n to: HexAddressSchema,\n from: HexAddressSchema,\n value: HexStringSchema,\n data: HexStringSchema,\n gasLimit: nullable(number()),\n effectiveGas: optional(number()),\n});\n\nexport const BitcoinTradeDataSchema = type({\n unsignedPsbtBase64: string(),\n inputsToSign: nullable(array(type({}))),\n});\n\nexport const TronTradeDataSchema = type({\n raw_data_hex: string(),\n visible: optional(boolean()),\n raw_data: optional(\n nullable(\n type({\n contract: optional(\n array(\n type({\n type: optional(string()),\n }),\n ),\n ),\n fee_limit: optional(number()),\n }),\n ),\n ),\n});\n\n/**\n * Stellar bridge quote: unsigned transaction envelope as XDR (base64).\n */\nexport const StellarTradeDataSchema = union([\n type({ xdrBase64: string() }),\n type({ xdr: string() }),\n]);\n\nexport const QuoteResponseSchema = type({\n quoteId: optional(string()),\n quote: QuoteSchema,\n estimatedProcessingTimeInSeconds: number(),\n approval: optional(union([TxDataSchema, TronTradeDataSchema])),\n trade: union([\n TxDataSchema,\n BitcoinTradeDataSchema,\n TronTradeDataSchema,\n StellarTradeDataSchema,\n string(),\n ]),\n});\n\nexport const validateQuoteResponseV1 = (\n data: unknown,\n): data is Infer<typeof QuoteResponseSchema> => {\n assert(data, QuoteResponseSchema);\n return true;\n};\n\nexport enum TokenFeatureType {\n MALICIOUS = 'Malicious',\n WARNING = 'Warning',\n INFO = 'Info',\n BENIGN = 'Benign',\n}\n\nexport const TokenFeatureSchema = type({\n feature_id: string(),\n type: enums(Object.values(TokenFeatureType)),\n description: string(),\n});\n\nexport const validateTokenFeature = (\n data: unknown,\n): data is Infer<typeof TokenFeatureSchema> => {\n assert(data, TokenFeatureSchema);\n return true;\n};\n\nexport enum QuoteStreamCompleteReason {\n RETRY = 'RETRY',\n AMOUNT_TOO_HIGH = 'AMOUNT_TOO_HIGH',\n AMOUNT_TOO_LOW = 'AMOUNT_TOO_LOW',\n SLIPPAGE_TOO_HIGH = 'SLIPPAGE_TOO_HIGH',\n SLIPPAGE_TOO_LOW = 'SLIPPAGE_TOO_LOW',\n TOKEN_NOT_SUPPORTED = 'TOKEN_NOT_SUPPORTED',\n RWA_GEO_RESTRICTED = 'RWA_GEO_RESTRICTED',\n RWA_NATIVE_TOKEN_UNSUPPORTED = 'RWA_NATIVE_TOKEN_UNSUPPORTED',\n RWA_MARKET_UNAVAILABLE = 'RWA_MARKET_UNAVAILABLE',\n}\n\nexport const QuoteStreamCompleteSchema = type({\n quoteCount: number(),\n hasQuotes: boolean(),\n reason: optional(enums(Object.values(QuoteStreamCompleteReason))),\n context: optional(record(string(), any())),\n});\n\nexport const validateQuoteStreamComplete = (\n data: unknown,\n): data is Infer<typeof QuoteStreamCompleteSchema> => {\n assert(data, QuoteStreamCompleteSchema);\n return true;\n};\n\nexport enum BatchSellTransactionType {\n TRADE = 'trade',\n APPROVAL = 'approval',\n TRANSFER = 'transfer',\n}\n\nexport const SimulatedGasFeeLimitsSchema = type({\n maxFeePerGas: HexStringSchema,\n maxPriorityFeePerGas: HexStringSchema,\n});\n\nexport const BatchSellTradesResponseSchema = intersection([\n type({\n transactions: array(\n intersection([\n TxDataSchema,\n SimulatedGasFeeLimitsSchema,\n type({ type: enums(Object.values(BatchSellTransactionType)) }),\n ]),\n ),\n fee: optional(\n type({\n asset: BridgeAssetSchema,\n amount: NumberStringSchema,\n }),\n ),\n }),\n GaslessPropertiesSchema,\n]);\n\nexport const validateBatchSellTradesResponse = (\n data: unknown,\n): data is Infer<typeof BatchSellTradesResponseSchema> => {\n assert(data, BatchSellTradesResponseSchema);\n return true;\n};\n"]}