@@ -195,32 +195,121 @@ const RefuelDataSchema = StepSchema;
195195// Allow digit strings for amounts/validTo for flexibility across providers
196196const DigitStringOrNumberSchema = union ( [ TruthyDigitStringSchema , number ( ) ] ) ;
197197
198- // Intent support (e.g., CoW Swap EIP-712 order signing)
198+ /**
199+ * Identifier of the intent protocol used for order creation and submission.
200+ *
201+ * Examples:
202+ * - CoW Swap
203+ * - Other EIP-712–based intent protocols
204+ */
199205const IntentProtocolSchema = string ;
200206
207+ /**
208+ * Schema for an intent-based order used for EIP-712 signing and submission.
209+ *
210+ * This represents the minimal subset of fields required by intent-based
211+ * protocols (e.g. CoW Swap) to build, sign, and submit an order.
212+ */
201213export const IntentOrderSchema = type ( {
202- // EIP-712 Order fields (subset required for signing/submission)
214+ /**
215+ * Address of the token being sold.
216+ */
203217 sellToken : HexAddressSchema ,
218+
219+ /**
220+ * Address of the token being bought.
221+ */
204222 buyToken : HexAddressSchema ,
223+
224+ /**
225+ * Optional receiver of the bought tokens.
226+ * If omitted, defaults to the signer / order owner.
227+ */
205228 receiver : optional ( HexAddressSchema ) ,
229+
230+ /**
231+ * Order expiration time.
232+ *
233+ * Can be provided as a UNIX timestamp in seconds, either as a number
234+ * or as a digit string, depending on provider requirements.
235+ */
206236 validTo : DigitStringOrNumberSchema ,
237+
238+ /**
239+ * Arbitrary application-specific data attached to the order.
240+ */
207241 appData : string ( ) ,
242+
243+ /**
244+ * Hash of the `appData` field, used for EIP-712 signing.
245+ */
208246 appDataHash : HexStringSchema ,
247+
248+ /**
249+ * Fee amount paid for order execution, expressed as a digit string.
250+ */
209251 feeAmount : TruthyDigitStringSchema ,
252+
253+ /**
254+ * Order kind.
255+ *
256+ * - `sell`: exact sell amount, variable buy amount
257+ * - `buy`: exact buy amount, variable sell amount
258+ */
210259 kind : enums ( [ 'sell' , 'buy' ] ) ,
260+
261+ /**
262+ * Whether the order can be partially filled.
263+ */
211264 partiallyFillable : boolean ( ) ,
212- // One of these is required by CoW depending on kind; we keep both optional here and rely on backend validation
265+
266+ /**
267+ * Exact amount of the sell token.
268+ *
269+ * Required for `sell` orders.
270+ */
213271 sellAmount : optional ( TruthyDigitStringSchema ) ,
272+
273+ /**
274+ * Exact amount of the buy token.
275+ *
276+ * Required for `buy` orders.
277+ */
214278 buyAmount : optional ( TruthyDigitStringSchema ) ,
215- // Optional owner/from for convenience when building domain/message
279+
280+ /**
281+ * Optional order owner / sender address.
282+ *
283+ * Provided for convenience when building the EIP-712 domain and message.
284+ */
216285 from : optional ( HexAddressSchema ) ,
217286} ) ;
218287
288+ /**
289+ * Schema representing an intent submission payload.
290+ *
291+ * Wraps the intent order along with protocol and optional routing metadata
292+ * required by the backend or relayer infrastructure.
293+ */
219294export const IntentSchema = type ( {
295+ /**
296+ * Identifier of the intent protocol used to interpret the order.
297+ */
220298 protocol : IntentProtocolSchema ,
299+
300+ /**
301+ * The intent order to be signed and submitted.
302+ */
221303 order : IntentOrderSchema ,
222- // Optional metadata to aid submission/routing
304+
305+ /**
306+ * Optional settlement contract address used for execution.
307+ */
223308 settlementContract : optional ( HexAddressSchema ) ,
309+
310+ /**
311+ * Optional relayer address responsible for order submission.
312+ */
224313 relayer : optional ( HexAddressSchema ) ,
225314} ) ;
226315
0 commit comments