@symbiome-forge/cow-sdk-wasm 0.1.0-alpha.1

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 (119) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +278 -0
  3. package/dist/cloudflare/callbacks.cjs +2 -0
  4. package/dist/cloudflare/callbacks.d.ts +55 -0
  5. package/dist/cloudflare/callbacks.js +1 -0
  6. package/dist/cloudflare/envelope.cjs +2 -0
  7. package/dist/cloudflare/envelope.d.ts +5 -0
  8. package/dist/cloudflare/envelope.js +1 -0
  9. package/dist/cloudflare/errors.cjs +150 -0
  10. package/dist/cloudflare/errors.d.ts +82 -0
  11. package/dist/cloudflare/errors.js +145 -0
  12. package/dist/cloudflare/index.cjs +286 -0
  13. package/dist/cloudflare/index.d.ts +78 -0
  14. package/dist/cloudflare/index.js +1 -0
  15. package/dist/cloudflare/index.mjs +223 -0
  16. package/dist/cloudflare/internal.cjs +127 -0
  17. package/dist/cloudflare/internal.d.ts +40 -0
  18. package/dist/cloudflare/internal.js +115 -0
  19. package/dist/cloudflare/options.cjs +2 -0
  20. package/dist/cloudflare/options.d.ts +70 -0
  21. package/dist/cloudflare/options.js +1 -0
  22. package/dist/cloudflare/raw/cloudflare.cjs +65 -0
  23. package/dist/cloudflare/raw/cloudflare.d.ts +30 -0
  24. package/dist/cloudflare/raw/cloudflare.js +29 -0
  25. package/dist/default/callbacks.cjs +2 -0
  26. package/dist/default/callbacks.d.ts +55 -0
  27. package/dist/default/callbacks.js +1 -0
  28. package/dist/default/envelope.cjs +2 -0
  29. package/dist/default/envelope.d.ts +5 -0
  30. package/dist/default/envelope.js +1 -0
  31. package/dist/default/errors.cjs +150 -0
  32. package/dist/default/errors.d.ts +82 -0
  33. package/dist/default/errors.js +145 -0
  34. package/dist/default/index.cjs +359 -0
  35. package/dist/default/index.d.ts +94 -0
  36. package/dist/default/index.js +1 -0
  37. package/dist/default/index.mjs +295 -0
  38. package/dist/default/internal.cjs +127 -0
  39. package/dist/default/internal.d.ts +40 -0
  40. package/dist/default/internal.js +115 -0
  41. package/dist/default/options.cjs +2 -0
  42. package/dist/default/options.d.ts +70 -0
  43. package/dist/default/options.js +1 -0
  44. package/dist/default/raw/default.cjs +66 -0
  45. package/dist/default/raw/default.d.ts +31 -0
  46. package/dist/default/raw/default.js +30 -0
  47. package/dist/orderbook/callbacks.cjs +2 -0
  48. package/dist/orderbook/callbacks.d.ts +55 -0
  49. package/dist/orderbook/callbacks.js +1 -0
  50. package/dist/orderbook/envelope.cjs +2 -0
  51. package/dist/orderbook/envelope.d.ts +5 -0
  52. package/dist/orderbook/envelope.js +1 -0
  53. package/dist/orderbook/errors.cjs +150 -0
  54. package/dist/orderbook/errors.d.ts +82 -0
  55. package/dist/orderbook/errors.js +145 -0
  56. package/dist/orderbook/index.cjs +195 -0
  57. package/dist/orderbook/index.d.ts +57 -0
  58. package/dist/orderbook/index.js +1 -0
  59. package/dist/orderbook/index.mjs +139 -0
  60. package/dist/orderbook/internal.cjs +127 -0
  61. package/dist/orderbook/internal.d.ts +40 -0
  62. package/dist/orderbook/internal.js +115 -0
  63. package/dist/orderbook/options.cjs +2 -0
  64. package/dist/orderbook/options.d.ts +70 -0
  65. package/dist/orderbook/options.js +1 -0
  66. package/dist/orderbook/raw/orderbook.cjs +58 -0
  67. package/dist/orderbook/raw/orderbook.d.ts +23 -0
  68. package/dist/orderbook/raw/orderbook.js +22 -0
  69. package/dist/raw/cloudflare-web/cow_sdk_wasm.d.ts +2870 -0
  70. package/dist/raw/cloudflare-web/cow_sdk_wasm.js +2183 -0
  71. package/dist/raw/cloudflare-web/cow_sdk_wasm_bg.wasm +0 -0
  72. package/dist/raw/cloudflare-web/cow_sdk_wasm_bg.wasm.d.ts +65 -0
  73. package/dist/raw/default-bundler/cow_sdk_wasm.d.ts +2916 -0
  74. package/dist/raw/default-bundler/cow_sdk_wasm.js +9 -0
  75. package/dist/raw/default-bundler/cow_sdk_wasm_bg.js +2297 -0
  76. package/dist/raw/default-bundler/cow_sdk_wasm_bg.wasm +0 -0
  77. package/dist/raw/default-bundler/cow_sdk_wasm_bg.wasm.d.ts +75 -0
  78. package/dist/raw/default-nodejs/cow_sdk_wasm.cjs +2330 -0
  79. package/dist/raw/default-nodejs/cow_sdk_wasm.d.ts +2916 -0
  80. package/dist/raw/default-nodejs/cow_sdk_wasm_bg.wasm.d.ts +75 -0
  81. package/dist/raw/orderbook-bundler/cow_sdk_wasm.d.ts +1876 -0
  82. package/dist/raw/orderbook-bundler/cow_sdk_wasm.js +9 -0
  83. package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.js +1636 -0
  84. package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.wasm +0 -0
  85. package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.wasm.d.ts +50 -0
  86. package/dist/raw/orderbook-nodejs/cow_sdk_wasm.cjs +1661 -0
  87. package/dist/raw/orderbook-nodejs/cow_sdk_wasm.d.ts +1876 -0
  88. package/dist/raw/orderbook-nodejs/cow_sdk_wasm_bg.wasm.d.ts +50 -0
  89. package/dist/raw/signing-bundler/cow_sdk_wasm.d.ts +774 -0
  90. package/dist/raw/signing-bundler/cow_sdk_wasm.js +9 -0
  91. package/dist/raw/signing-bundler/cow_sdk_wasm_bg.js +1059 -0
  92. package/dist/raw/signing-bundler/cow_sdk_wasm_bg.wasm +0 -0
  93. package/dist/raw/signing-bundler/cow_sdk_wasm_bg.wasm.d.ts +27 -0
  94. package/dist/raw/signing-nodejs/cow_sdk_wasm.cjs +1078 -0
  95. package/dist/raw/signing-nodejs/cow_sdk_wasm.d.ts +774 -0
  96. package/dist/raw/signing-nodejs/cow_sdk_wasm_bg.wasm.d.ts +27 -0
  97. package/dist/signing/callbacks.cjs +2 -0
  98. package/dist/signing/callbacks.d.ts +55 -0
  99. package/dist/signing/callbacks.js +1 -0
  100. package/dist/signing/envelope.cjs +2 -0
  101. package/dist/signing/envelope.d.ts +5 -0
  102. package/dist/signing/envelope.js +1 -0
  103. package/dist/signing/errors.cjs +150 -0
  104. package/dist/signing/errors.d.ts +82 -0
  105. package/dist/signing/errors.js +145 -0
  106. package/dist/signing/index.cjs +93 -0
  107. package/dist/signing/index.d.ts +23 -0
  108. package/dist/signing/index.js +1 -0
  109. package/dist/signing/index.mjs +44 -0
  110. package/dist/signing/internal.cjs +127 -0
  111. package/dist/signing/internal.d.ts +40 -0
  112. package/dist/signing/internal.js +115 -0
  113. package/dist/signing/options.cjs +2 -0
  114. package/dist/signing/options.d.ts +70 -0
  115. package/dist/signing/options.js +1 -0
  116. package/dist/signing/raw/signing.cjs +52 -0
  117. package/dist/signing/raw/signing.d.ts +17 -0
  118. package/dist/signing/raw/signing.js +16 -0
  119. package/package.json +112 -0
@@ -0,0 +1,774 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export interface WalletConfig {
5
+ timeoutMs?: number;
6
+ }
7
+
8
+ export interface SigningOptions extends SdkClientOptions {
9
+ walletConfig?: WalletConfig;
10
+ }
11
+
12
+ export type TypedDataSignerCallback = (
13
+ envelope: TypedDataEnvelopeDto,
14
+ ) => Promise<string> | string;
15
+
16
+ export type Eip1193RequestCallback = (
17
+ request: { method: string; params?: unknown[] },
18
+ ) => Promise<unknown> | unknown;
19
+
20
+ export type DigestSignerCallback = (
21
+ digest: string,
22
+ ) => Promise<string> | string;
23
+
24
+ export type CowEip1271SignCallback = (
25
+ request: CowEip1271SignRequest,
26
+ ) => Promise<string> | string;
27
+
28
+ export type CustomEip1271Callback = CowEip1271SignCallback;
29
+
30
+
31
+
32
+ export type Value = unknown;
33
+ export type CowError = WasmError;
34
+
35
+ export interface SdkClientOptions {
36
+ timeoutMs?: number;
37
+ signal?: AbortSignal;
38
+ }
39
+
40
+
41
+ /**
42
+ * A decoded `GPv2Settlement` (or inherited `GPv2Signing`) event.
43
+ *
44
+ * Mirrors `cow_sdk_contracts::SettlementEvent`. Addresses and the order UID
45
+ * are lowercase `0x`-prefixed hex; amounts are base-10 atom strings; the
46
+ * interaction `selector` is a `0x`-prefixed 4-byte hex string. The `kind`
47
+ * discriminator distinguishes the variants.
48
+ */
49
+ export type SettlementEventDto = { kind: "trade"; owner: string; sellToken: string; buyToken: string; sellAmount: string; buyAmount: string; feeAmount: string; orderUid: string } | { kind: "interaction"; target: string; value: string; selector: string } | { kind: "settlement"; solver: string } | { kind: "orderInvalidated"; owner: string; orderUid: string } | { kind: "preSignature"; owner: string; orderUid: string; signed: boolean };
50
+
51
+ /**
52
+ * A decoded eth-flow on-chain order lifecycle event.
53
+ *
54
+ * Mirrors `cow_sdk_contracts::EthFlowEvent`. The placement `order` reuses the
55
+ * canonical [`OrderInput`] shape (its `validTo` is the on-chain clamped value;
56
+ * the trader\'s real expiry travels in the opaque `data` trailer). `signature`
57
+ * and `data` are `0x`-prefixed hex strings carrying the raw on-chain signature
58
+ * payload and the opaque trailing data field; addresses and the order UID are
59
+ * lowercase `0x`-prefixed hex. The `kind` discriminator distinguishes the
60
+ * variants.
61
+ */
62
+ export type EthFlowEventDto = { kind: "orderPlacement"; sender: string; order: OrderInput; signingScheme: string; signature: string; data: string } | { kind: "orderInvalidation"; orderUid: string } | { kind: "orderRefund"; orderUid: string; refunder: string };
63
+
64
+ /**
65
+ * Coarse, switchable classification of an orderbook rejection, mirrored for
66
+ * the JS error surface.
67
+ *
68
+ * A consumer can branch on the action a rejection calls for — fix the
69
+ * request, fund the wallet, re-quote, wait, or escalate — without matching
70
+ * every wire tag. The category carries no message or code, so it never
71
+ * re-exposes redacted rejection text.
72
+ */
73
+ export type OrderBookRejectionCategoryDto = "authorization" | "insufficientFunds" | "invalidOrder" | "notFound" | "conflict" | "unfulfillable" | "server" | "__unknown";
74
+
75
+ /**
76
+ * Custom EIP-1271 callback request.
77
+ */
78
+ export interface CowEip1271SignRequest {
79
+ /**
80
+ * Original order input.
81
+ */
82
+ order: OrderInput;
83
+ /**
84
+ * Typed-data envelope.
85
+ */
86
+ typedData: TypedDataEnvelopeDto;
87
+ /**
88
+ * Owner or smart-account address.
89
+ */
90
+ owner: string;
91
+ /**
92
+ * Numeric chain id.
93
+ */
94
+ chainId: number;
95
+ }
96
+
97
+ /**
98
+ * Deployment address output.
99
+ */
100
+ export interface DeploymentAddressesDto {
101
+ /**
102
+ * Settlement contract.
103
+ */
104
+ settlement: string;
105
+ /**
106
+ * Vault relayer contract.
107
+ */
108
+ vaultRelayer: string;
109
+ /**
110
+ * EthFlow contract.
111
+ */
112
+ ethFlow: string;
113
+ }
114
+
115
+ /**
116
+ * EIP-1193 request DTO.
117
+ */
118
+ export interface Eip1193Request {
119
+ /**
120
+ * Provider method.
121
+ */
122
+ method: string;
123
+ /**
124
+ * Provider params.
125
+ */
126
+ params?: Value[];
127
+ }
128
+
129
+ /**
130
+ * Explicit raw GraphQL query input.
131
+ */
132
+ export interface SubgraphQueryInput {
133
+ /**
134
+ * Raw GraphQL document.
135
+ */
136
+ query: string;
137
+ /**
138
+ * Optional GraphQL variables.
139
+ */
140
+ variables?: Value;
141
+ /**
142
+ * Optional operation name.
143
+ */
144
+ operationName?: string;
145
+ }
146
+
147
+ /**
148
+ * Generated order UID output.
149
+ */
150
+ export interface GeneratedOrderUidDto {
151
+ /**
152
+ * Compact order UID.
153
+ */
154
+ orderUid: string;
155
+ /**
156
+ * Underlying order digest.
157
+ */
158
+ orderDigest: string;
159
+ }
160
+
161
+ /**
162
+ * Generic validated 32-byte hash wrapper for user-domain and contract surfaces.
163
+ *
164
+ * The wire form is the protocol-canonical `0x`-prefixed 66-character
165
+ * lowercase hexadecimal string. The newtype is `#[repr(transparent)]` over
166
+ * [`alloy_primitives::B256`] and forwards `Display`/`Serialize`/
167
+ * `Deserialize` to the inner alloy type, whose canonical defaults already
168
+ * emit the cow lowercase wire form.
169
+ */
170
+ export type Hash32 = string;
171
+
172
+ /**
173
+ * JS-visible typed error envelope for every wasm export.
174
+ */
175
+ export type WasmError = { kind: "invalidInput"; schemaVersion: SchemaVersion; message: string; field?: string } | { kind: "unknownEnumValue"; schemaVersion: SchemaVersion; message: string; field: string; value: string } | { kind: "unsupportedChain"; schemaVersion: SchemaVersion; message: string; chainId: number } | { kind: "walletRequest"; schemaVersion: SchemaVersion; method: string; code?: number; message: string } | { kind: "walletTimeout"; schemaVersion: SchemaVersion; message: string; timeoutMs: number } | { kind: "transport"; schemaVersion: SchemaVersion; class: string; message: string; status?: number; headers?: [string, string][]; body?: string } | { kind: "orderbook"; schemaVersion: SchemaVersion; code?: string; category?: OrderBookRejectionCategoryDto; message: string; retryable?: boolean; retryAfterMs?: number } | { kind: "subgraph"; schemaVersion: SchemaVersion; message: string } | { kind: "signing"; schemaVersion: SchemaVersion; message: string } | { kind: "appData"; schemaVersion: SchemaVersion; class?: string; message: string } | { kind: "cancelled"; schemaVersion: SchemaVersion; message: string } | { kind: "internal"; schemaVersion: SchemaVersion; message: string } | { kind: "__unknown"; schemaVersion: SchemaVersion; message: string; raw: Value };
176
+
177
+ /**
178
+ * Order input shared by signing and UID exports.
179
+ */
180
+ export interface OrderInput {
181
+ /**
182
+ * Sell token address.
183
+ */
184
+ sellToken: string;
185
+ /**
186
+ * Buy token address.
187
+ */
188
+ buyToken: string;
189
+ /**
190
+ * Optional receiver.
191
+ */
192
+ receiver?: string;
193
+ /**
194
+ * Sell amount.
195
+ */
196
+ sellAmount: string;
197
+ /**
198
+ * Buy amount.
199
+ */
200
+ buyAmount: string;
201
+ /**
202
+ * Valid-to timestamp.
203
+ */
204
+ validTo: number;
205
+ /**
206
+ * App-data hash.
207
+ */
208
+ appData: string;
209
+ /**
210
+ * Fee amount.
211
+ */
212
+ feeAmount: string;
213
+ /**
214
+ * Order side.
215
+ */
216
+ kind: OrderKindDto;
217
+ /**
218
+ * Partial fill flag.
219
+ */
220
+ partiallyFillable: boolean;
221
+ /**
222
+ * Sell balance source.
223
+ */
224
+ sellTokenBalance: TokenBalanceDto;
225
+ /**
226
+ * Buy balance destination.
227
+ */
228
+ buyTokenBalance: TokenBalanceDto;
229
+ }
230
+
231
+ /**
232
+ * Order side accepted by wasm order inputs.
233
+ */
234
+ export type OrderKindDto = "sell" | "buy";
235
+
236
+ /**
237
+ * Order transaction helper parameters.
238
+ */
239
+ export interface OrderTraderParametersInput {
240
+ /**
241
+ * Target order UID.
242
+ */
243
+ orderUid: string;
244
+ /**
245
+ * Optional chain-id override.
246
+ */
247
+ chainId?: number;
248
+ /**
249
+ * Optional environment override.
250
+ */
251
+ env?: string;
252
+ /**
253
+ * Optional settlement-contract overrides keyed by chain id.
254
+ *
255
+ * Typed as `Record` rather than `Map` because the runtime
256
+ * serializer emits a plain JavaScript object for `BTreeMap`
257
+ * fields; the override aligns the declaration with the runtime.
258
+ */
259
+ settlementContractOverride?: Record<string, string>;
260
+ /**
261
+ * Optional `EthFlow` contract overrides keyed by chain id.
262
+ *
263
+ * Typed as `Record` rather than `Map` for the same runtime
264
+ * alignment reason as `settlement_contract_override`.
265
+ */
266
+ ethFlowContractOverride?: Record<string, string>;
267
+ }
268
+
269
+ /**
270
+ * Pagination options shared by orderbook list helpers.
271
+ */
272
+ export interface PaginationOptions {
273
+ /**
274
+ * Pagination offset.
275
+ */
276
+ offset?: number;
277
+ /**
278
+ * Pagination limit.
279
+ */
280
+ limit?: number;
281
+ }
282
+
283
+ /**
284
+ * Raw EVM event log accepted by the on-chain event decoders.
285
+ *
286
+ * `topics` carries the indexed log topics as `0x`-prefixed 32-byte hex
287
+ * strings with topic-0 (the event signature hash) first; `data` is the
288
+ * ABI-encoded non-indexed payload as a `0x`-prefixed hex string (`\"0x\"` for an
289
+ * empty payload).
290
+ */
291
+ export interface EventLogInput {
292
+ /**
293
+ * Indexed log topics as 0x-prefixed 32-byte hex strings (topic-0 first).
294
+ */
295
+ topics: string[];
296
+ /**
297
+ * ABI-encoded non-indexed log data as a 0x-prefixed hex string.
298
+ */
299
+ data: string;
300
+ }
301
+
302
+ /**
303
+ * Signed order DTO returned by wallet callback exports.
304
+ */
305
+ export interface SignedOrderDto {
306
+ /**
307
+ * Compact order UID.
308
+ */
309
+ orderUid: string;
310
+ /**
311
+ * Signature payload submitted to the orderbook.
312
+ */
313
+ signature: string;
314
+ /**
315
+ * Signing scheme.
316
+ */
317
+ signingScheme: string;
318
+ /**
319
+ * Effective owner submitted as `from`.
320
+ */
321
+ from: string;
322
+ /**
323
+ * Underlying order digest.
324
+ */
325
+ orderDigest: string;
326
+ /**
327
+ * Typed-data envelope used for signing.
328
+ */
329
+ typedData: TypedDataEnvelopeDto;
330
+ /**
331
+ * Optional quote id.
332
+ */
333
+ quoteId?: number;
334
+ }
335
+
336
+ /**
337
+ * Signed order-cancellation DTO.
338
+ */
339
+ export interface SignedCancellationsInput {
340
+ /**
341
+ * Order UIDs to cancel.
342
+ */
343
+ orderUids: string[];
344
+ /**
345
+ * Cancellation signature.
346
+ */
347
+ signature: string;
348
+ /**
349
+ * ECDSA signing scheme.
350
+ */
351
+ signingScheme: string;
352
+ }
353
+
354
+ /**
355
+ * Token-balance mode accepted by wasm order inputs.
356
+ */
357
+ export type TokenBalanceDto = "erc20" | "external" | "internal";
358
+
359
+ /**
360
+ * Trades query accepted by `OrderBookClient.getTrades`.
361
+ */
362
+ export interface TradesQueryInput {
363
+ /**
364
+ * Owner filter. Set exactly one of `owner` or `orderUid`.
365
+ */
366
+ owner?: string;
367
+ /**
368
+ * Order UID filter. Set exactly one of `owner` or `orderUid`.
369
+ */
370
+ orderUid?: string;
371
+ /**
372
+ * Pagination offset.
373
+ */
374
+ offset?: number;
375
+ /**
376
+ * Pagination limit.
377
+ */
378
+ limit?: number;
379
+ }
380
+
381
+ /**
382
+ * Transaction request DTO returned by transaction builders.
383
+ */
384
+ export interface TransactionRequestDto {
385
+ /**
386
+ * Destination address.
387
+ */
388
+ to?: string;
389
+ /**
390
+ * Hex-encoded calldata.
391
+ */
392
+ data?: string;
393
+ /**
394
+ * Native value.
395
+ */
396
+ value?: string;
397
+ /**
398
+ * Gas limit.
399
+ */
400
+ gasLimit?: string;
401
+ }
402
+
403
+ /**
404
+ * Typed-data domain DTO.
405
+ */
406
+ export interface TypedDataDomainDto {
407
+ /**
408
+ * Domain name.
409
+ */
410
+ name: string;
411
+ /**
412
+ * Domain version.
413
+ */
414
+ version: string;
415
+ /**
416
+ * Chain id.
417
+ */
418
+ chainId: number;
419
+ /**
420
+ * Verifying contract.
421
+ */
422
+ verifyingContract: string;
423
+ }
424
+
425
+ /**
426
+ * Typed-data envelope DTO.
427
+ */
428
+ export interface TypedDataEnvelopeDto {
429
+ /**
430
+ * Domain metadata.
431
+ */
432
+ domain: TypedDataDomainDto;
433
+ /**
434
+ * Primary type.
435
+ */
436
+ primaryType: string;
437
+ /**
438
+ * Type map.
439
+ *
440
+ * Typed as `Record` because the runtime serializer
441
+ * (`serde_wasm_bindgen::Serializer::json_compatible`) emits a
442
+ * plain JavaScript object for `BTreeMap` fields. The override
443
+ * aligns the generated TypeScript declaration with the runtime
444
+ * shape so the declared type matches the value the wasm boundary
445
+ * emits byte-for-byte.
446
+ */
447
+ types: Record<string, TypedDataFieldDto[]>;
448
+ /**
449
+ * Parsed message body.
450
+ */
451
+ message: Value;
452
+ }
453
+
454
+ /**
455
+ * Typed-data field DTO.
456
+ */
457
+ export interface TypedDataFieldDto {
458
+ /**
459
+ * Field name.
460
+ */
461
+ name: string;
462
+ /**
463
+ * Solidity field type.
464
+ */
465
+ type: string;
466
+ }
467
+
468
+ /**
469
+ * Validated 32-byte app-data hash.
470
+ *
471
+ * The wire form is the protocol-canonical `0x`-prefixed 66-character
472
+ * lowercase hexadecimal string. The newtype is `#[repr(transparent)]`
473
+ * over [`alloy_primitives::B256`], so the in-memory layout is
474
+ * bit-for-bit identical to the alloy primitive and conversion at the
475
+ * alloy seam is free at runtime through [`AppDataHash::as_alloy`]
476
+ * (borrowed), [`AppDataHash::into_alloy`] (owned), or [`From`] /
477
+ * [`Into`].
478
+ *
479
+ * `AppDataHash` forwards [`Serialize`] / [`Deserialize`] to the inner
480
+ * [`alloy_primitives::B256`] via `#[serde(transparent)]` because the
481
+ * alloy lowercase 0x-prefixed default already matches the cow wire
482
+ * form. [`fmt::Display`] is a one-line delegate to the inner primitive
483
+ * for the same reason.
484
+ *
485
+ * Equality, hash, and ordering derive from the packed 32-byte
486
+ * representation, which is equivalent to the documented
487
+ * case-insensitive comparison contract because every valid value parses
488
+ * to the same bytes regardless of input casing.
489
+ *
490
+ *
491
+ */
492
+ export type AppDataHash = string;
493
+
494
+ /**
495
+ * Validated EVM address.
496
+ *
497
+ * The wire form is the protocol-canonical `0x`-prefixed 42-character
498
+ * lowercase hexadecimal string. The newtype is `#[repr(transparent)]` over
499
+ * [`alloy_primitives::Address`], so the in-memory layout is bit-for-bit
500
+ * identical to the alloy primitive and conversion at the alloy seam is free
501
+ * at runtime through [`Address::as_alloy`] (borrowed), [`Address::into_alloy`]
502
+ * (owned), or [`From`] / [`Into`].
503
+ *
504
+ * `Address` carries cow-owned [`fmt::Display`], [`Serialize`], and
505
+ * [`Deserialize`] impls because alloy\'s default `Display` for
506
+ * [`alloy_primitives::Address`] emits the EIP-55 mixed-case checksum form,
507
+ * while the cow protocol wire form is lowercase. The cow `Display` impl
508
+ * writes `format!(\"{:#x}\", self.0)` which routes through alloy\'s
509
+ * [`fmt::LowerHex`] impl and emits lowercase 0x-prefixed hex.
510
+ *
511
+ * [`PartialEq`], [`Eq`], [`Hash`](std::hash::Hash), [`PartialOrd`], and
512
+ * [`Ord`] derive from the inner alloy primitive, which compares addresses on
513
+ * the packed 20-byte representation.
514
+ */
515
+ export type Address = string;
516
+
517
+ /**
518
+ * Validated `CoW` order UID.
519
+ *
520
+ * The wire form is the protocol-canonical `0x`-prefixed 114-character
521
+ * lowercase hexadecimal string. The newtype is `#[repr(transparent)]` over
522
+ * [`alloy_primitives::FixedBytes<56>`] and forwards `Display`/`Serialize`/
523
+ * `Deserialize` to the inner alloy type, whose canonical defaults already
524
+ * emit the cow lowercase wire form.
525
+ *
526
+ *
527
+ *
528
+ */
529
+ export type OrderUid = string;
530
+
531
+ /**
532
+ * Validated hex payload used for calldata and byte blobs.
533
+ *
534
+ * The wire form is the protocol-canonical `0x`-prefixed lowercase
535
+ * hexadecimal string. The newtype is `#[repr(transparent)]` over
536
+ * [`alloy_primitives::Bytes`] and forwards `Display`/`Serialize`/
537
+ * `Deserialize` to the inner alloy type, whose canonical defaults already
538
+ * emit the cow lowercase wire form. Odd-length inputs are left-padded with
539
+ * one zero nibble during construction so the stored value remains
540
+ * byte-aligned hex.
541
+ */
542
+ export type HexData = string;
543
+
544
+ /**
545
+ * Version tag carried by wasm output and error envelopes.
546
+ */
547
+ export type SchemaVersion = "v1" | "__unknown";
548
+
549
+ /**
550
+ * Versioned output envelope.
551
+ */
552
+ export interface WasmEnvelope<T> {
553
+ /**
554
+ * Schema version.
555
+ */
556
+ schemaVersion: SchemaVersion;
557
+ /**
558
+ * Envelope payload.
559
+ */
560
+ value: T;
561
+ }
562
+
563
+
564
+ /**
565
+ * Initializes the wasm crate's panic hook once.
566
+ */
567
+ export function __cow_sdk_wasm_init(): void;
568
+
569
+ /**
570
+ * Computes the canonical order UID and order digest for an unsigned order.
571
+ *
572
+ * The UID combines the EIP-712 order digest, owner address, and validity
573
+ * timestamp using the same packing rules as the native Rust SDK.
574
+ *
575
+ * @param input Unsigned order fields to hash and pack.
576
+ * @param chainId EVM chain id used for the EIP-712 domain.
577
+ * @param owner Order owner address included in the UID suffix.
578
+ * @returns A versioned envelope with `orderUid` and `orderDigest`.
579
+ * @throws CowError when the order, owner, or chain id is invalid.
580
+ */
581
+ export function computeOrderUid(input: OrderInput, chainId: number, owner: string): WasmEnvelope<GeneratedOrderUidDto>;
582
+
583
+ /**
584
+ * Decodes an eth-flow on-chain order lifecycle event log into a typed event.
585
+ *
586
+ * Dispatches on the log's topic-0 across the `CoWSwapOnchainOrders`
587
+ * `OrderPlacement` / `OrderInvalidation` events and the `CoWSwapEthFlow`
588
+ * `OrderRefund` event. The decode is fail-closed: the topic set and on-chain
589
+ * signing scheme are validated and every order UID is length-checked, so a
590
+ * malformed or hostile log returns a typed error rather than panicking.
591
+ *
592
+ * @param log Raw log with `topics` (0x-prefixed 32-byte hex, topic-0 first)
593
+ * and `data` (0x-prefixed hex, `"0x"` when empty).
594
+ * @returns A versioned envelope containing the decoded eth-flow event.
595
+ * @throws CowError when the log is malformed or its topic set matches no known
596
+ * eth-flow lifecycle event.
597
+ */
598
+ export function decodeEthFlowLog(log: EventLogInput): WasmEnvelope<EthFlowEventDto>;
599
+
600
+ /**
601
+ * Decodes a `GPv2Settlement` event log into a typed settlement event.
602
+ *
603
+ * Dispatches on the log's topic-0 across `Trade`, `Interaction`, `Settlement`,
604
+ * `OrderInvalidated`, and `PreSignature`. The decode is fail-closed: the topic
605
+ * set is validated before ABI decoding and every order UID is length-checked,
606
+ * so a malformed or hostile log returns a typed error rather than panicking.
607
+ *
608
+ * @param log Raw log with `topics` (0x-prefixed 32-byte hex, topic-0 first)
609
+ * and `data` (0x-prefixed hex, `"0x"` when empty).
610
+ * @returns A versioned envelope containing the decoded settlement event.
611
+ * @throws CowError when the log is malformed or its topic set matches no known
612
+ * settlement event.
613
+ */
614
+ export function decodeSettlementLog(log: EventLogInput): WasmEnvelope<SettlementEventDto>;
615
+
616
+ /**
617
+ * Returns canonical CoW Protocol deployment addresses for a chain.
618
+ *
619
+ * The optional environment selects production or staging deployment data. When
620
+ * omitted, the helper uses the SDK default environment.
621
+ *
622
+ * @param chainId EVM chain id to resolve.
623
+ * @param env Optional CoW environment name, such as `prod` or `staging`.
624
+ * @returns Settlement, VaultRelayer, EthFlow, and AllowListAuth addresses.
625
+ * @throws CowError when the chain or environment is unsupported.
626
+ */
627
+ export function deploymentAddresses(chainId: number, env?: string | null): WasmEnvelope<DeploymentAddressesDto>;
628
+
629
+ /**
630
+ * Computes the CoW Protocol EIP-712 domain separator for a supported chain.
631
+ *
632
+ * Use this helper when a JavaScript host needs to compare the domain hash used
633
+ * by the Rust SDK with another signing stack. The input is an EVM chain id,
634
+ * not a CoW environment selector.
635
+ *
636
+ * @param chainId EVM chain id supported by the deployment registry.
637
+ * @returns The `0x`-prefixed 32-byte domain separator.
638
+ * @throws CowError when the chain is not supported.
639
+ */
640
+ export function domainSeparator(chainId: number): string;
641
+
642
+ /**
643
+ * Encodes a CoW EIP-1271 payload from an ECDSA order signature.
644
+ *
645
+ * Use this pure helper when a smart-account flow already has the wrapped ECDSA
646
+ * signature and needs the contract-signature payload bytes expected by CoW
647
+ * Protocol order submission.
648
+ *
649
+ * @param input Unsigned order used to derive the EIP-1271 payload.
650
+ * @param ecdsaSignature Wrapped ECDSA signature as a `0x`-prefixed string.
651
+ * @returns A versioned envelope containing the encoded EIP-1271 payload.
652
+ * @throws CowError when the order or signature is invalid.
653
+ */
654
+ export function eip1271SignaturePayload(input: OrderInput, ecdsaSignature: string): WasmEnvelope<string>;
655
+
656
+ /**
657
+ * Builds signer-facing EIP-712 typed data for an unsigned order.
658
+ *
659
+ * The returned envelope contains the domain, type map, primary type, and
660
+ * order message that wallet libraries expect for EIP-712 signing. It is
661
+ * deterministic for the provided order and chain id.
662
+ *
663
+ * @param input Unsigned order fields using the facade order DTO shape.
664
+ * @param chainId EVM chain id used for the EIP-712 domain.
665
+ * @returns A versioned envelope containing typed-data DTO fields.
666
+ * @throws CowError when order parsing or chain validation fails.
667
+ */
668
+ export function orderTypedData(input: OrderInput, chainId: number): WasmEnvelope<TypedDataEnvelopeDto>;
669
+
670
+ /**
671
+ * Signs an order digest through an explicit `eth_sign` callback.
672
+ *
673
+ * The SDK computes the canonical order digest, passes the digest as a
674
+ * `0x`-prefixed string to the callback, normalizes the signature, and returns
675
+ * an `ethsign` signed-order DTO.
676
+ *
677
+ * @param input Unsigned order fields to sign.
678
+ * @param chainId EVM chain id used for the digest.
679
+ * @param owner Owner address used in the generated order UID.
680
+ * @param digestSigner Callback that signs the digest string.
681
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
682
+ * @returns A versioned envelope containing the signed order.
683
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
684
+ */
685
+ export function signOrderEthSignDigest(input: OrderInput, chainId: number, owner: string, digestSigner: DigestSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<SignedOrderDto>>;
686
+
687
+ /**
688
+ * Signs an order through a custom EIP-1271 callback.
689
+ *
690
+ * Use this method when the JavaScript host owns the smart-account or
691
+ * account-abstraction client and can return the final contract signature
692
+ * directly. The SDK still builds typed data and the deterministic order UID.
693
+ *
694
+ * @param input Unsigned order to sign.
695
+ * @param chainId EVM chain id for the EIP-712 domain.
696
+ * @param owner Smart-account owner address used in the generated order UID.
697
+ * @param customCallback Callback that returns the final EIP-1271 signature.
698
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
699
+ * @returns A versioned envelope containing the signed-order DTO.
700
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
701
+ */
702
+ export function signOrderWithCustomEip1271(input: OrderInput, chainId: number, owner: string, customCallback: CustomEip1271Callback, options?: SigningOptions | null): Promise<WasmEnvelope<SignedOrderDto>>;
703
+
704
+ /**
705
+ * Signs an order through an EIP-1193 request callback.
706
+ *
707
+ * The callback receives an `eth_signTypedData_v4` request object with owner
708
+ * address and serialized typed data. This is the bridge for injected wallets
709
+ * and wallet-client libraries that expose an EIP-1193-style request function.
710
+ *
711
+ * @param input Unsigned order fields to sign.
712
+ * @param chainId EVM chain id used for the EIP-712 domain.
713
+ * @param owner Owner address used in the wallet request and order UID.
714
+ * @param requestCallback Callback that executes the EIP-1193 request.
715
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
716
+ * @returns A versioned envelope containing the signed order.
717
+ * @throws CowError for invalid input, wallet failure, timeout, or cancellation.
718
+ */
719
+ export function signOrderWithEip1193(input: OrderInput, chainId: number, owner: string, requestCallback: Eip1193RequestCallback, options?: SigningOptions | null): Promise<WasmEnvelope<SignedOrderDto>>;
720
+
721
+ /**
722
+ * Signs an order through typed-data ECDSA and wraps it as EIP-1271.
723
+ *
724
+ * The SDK sends the EIP-712 envelope to the provided typed-data callback,
725
+ * then converts the returned ECDSA signature into the CoW EIP-1271 payload.
726
+ * Per-call options may attach cancellation and wallet timeout settings.
727
+ *
728
+ * @param input Unsigned order to sign.
729
+ * @param chainId EVM chain id for the EIP-712 domain.
730
+ * @param owner Smart-account owner address used in the generated order UID.
731
+ * @param typedDataSigner Callback that signs the typed-data envelope.
732
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
733
+ * @returns A versioned envelope containing the signed-order DTO.
734
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
735
+ */
736
+ export function signOrderWithEip1271(input: OrderInput, chainId: number, owner: string, typedDataSigner: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<SignedOrderDto>>;
737
+
738
+ /**
739
+ * Signs an order through a typed-data callback.
740
+ *
741
+ * The SDK builds the EIP-712 typed-data envelope, passes it to the callback,
742
+ * normalizes the returned ECDSA signature, and returns the signed-order DTO
743
+ * with the canonical order UID and digest.
744
+ *
745
+ * @param input Unsigned order fields to sign.
746
+ * @param chainId EVM chain id used for the EIP-712 domain.
747
+ * @param owner Owner address used in the generated order UID.
748
+ * @param typedDataSigner Callback that signs the typed-data envelope.
749
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
750
+ * @returns A versioned envelope containing the signed order.
751
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
752
+ */
753
+ export function signOrderWithTypedDataSigner(input: OrderInput, chainId: number, owner: string, typedDataSigner: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<SignedOrderDto>>;
754
+
755
+ /**
756
+ * Returns the EVM chain ids supported by the SDK deployment registry.
757
+ *
758
+ * This is a pure helper and does not perform network I/O. The returned list is
759
+ * suitable for runtime validation, UI selection, or capability checks before a
760
+ * client is constructed.
761
+ *
762
+ * @returns A typed array of supported EVM chain ids.
763
+ */
764
+ export function supportedChainIds(): Uint32Array;
765
+
766
+ /**
767
+ * Returns the version of the wasm package runtime.
768
+ *
769
+ * The value comes from the Rust package metadata used to build the wasm
770
+ * artifact and can be included in diagnostics or compatibility checks.
771
+ *
772
+ * @returns The semantic version string for this wasm build.
773
+ */
774
+ export function wasmVersion(): string;