@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,2330 @@
1
+ /* @ts-self-types="./cow_sdk_wasm.d.ts" */
2
+
3
+ /**
4
+ * IPFS app-data client backed by an explicitly configured HTTP transport.
5
+ *
6
+ * Construct this client when JavaScript needs to fetch app-data documents by
7
+ * CID or app-data hash while preserving SDK retry, timeout, and cancellation
8
+ * behavior.
9
+ */
10
+ class IpfsClient {
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ IpfsClientFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_ipfsclient_free(ptr, 0);
20
+ }
21
+ /**
22
+ * Fetches and parses an app-data document by CID.
23
+ *
24
+ * The CID is resolved through the configured gateway and transport. The
25
+ * returned document is normalized into the SDK app-data DTO shape.
26
+ *
27
+ * @param cid Canonical IPFS CID for the app-data document.
28
+ * @param options Optional per-call cancellation and timeout settings.
29
+ * @returns A versioned envelope containing the app-data document.
30
+ * @throws CowError for invalid CID, transport failure, timeout, or parse failure.
31
+ * @param {string} cid
32
+ * @param {SdkClientOptions | null} [options]
33
+ * @returns {WasmEnvelope<AppDataDocDto>}
34
+ */
35
+ fetchAppDataFromCid(cid, options) {
36
+ const ptr0 = passStringToWasm0(cid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
37
+ const len0 = WASM_VECTOR_LEN;
38
+ const ret = wasm.ipfsclient_fetchAppDataFromCid(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
39
+ return takeObject(ret);
40
+ }
41
+ /**
42
+ * Fetches and parses an app-data document by app-data hash.
43
+ *
44
+ * The helper converts the app-data hash to the canonical CID before
45
+ * fetching through the configured gateway.
46
+ *
47
+ * @param appDataHex App-data hash as a `0x`-prefixed hex string.
48
+ * @param options Optional per-call cancellation and timeout settings.
49
+ * @returns A versioned envelope containing the app-data document.
50
+ * @throws CowError for invalid hash, transport failure, timeout, or parse failure.
51
+ * @param {string} appDataHex
52
+ * @param {SdkClientOptions | null} [options]
53
+ * @returns {WasmEnvelope<AppDataDocDto>}
54
+ */
55
+ fetchAppDataFromHex(appDataHex, options) {
56
+ const ptr0 = passStringToWasm0(appDataHex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
57
+ const len0 = WASM_VECTOR_LEN;
58
+ const ret = wasm.ipfsclient_fetchAppDataFromHex(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
59
+ return takeObject(ret);
60
+ }
61
+ /**
62
+ * Creates an IPFS app-data client from a single config object.
63
+ *
64
+ * The config must include `transport`. Optional `ipfsUri` overrides the
65
+ * default gateway base, while timeout, signal, and policy fields become
66
+ * defaults for method calls.
67
+ *
68
+ * @param config IPFS client configuration.
69
+ * @throws CowError when transport, policy, timeout, or gateway config is invalid.
70
+ * @param {IpfsClientConfig} config
71
+ */
72
+ constructor(config) {
73
+ try {
74
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
75
+ wasm.ipfsclient_new(retptr, addHeapObject(config));
76
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
77
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
78
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
79
+ if (r2) {
80
+ throw takeObject(r1);
81
+ }
82
+ this.__wbg_ptr = r0;
83
+ IpfsClientFinalization.register(this, this.__wbg_ptr, this);
84
+ return this;
85
+ } finally {
86
+ wasm.__wbindgen_add_to_stack_pointer(16);
87
+ }
88
+ }
89
+ }
90
+ if (Symbol.dispose) IpfsClient.prototype[Symbol.dispose] = IpfsClient.prototype.free;
91
+ exports.IpfsClient = IpfsClient;
92
+
93
+ /**
94
+ * Orderbook client backed by an explicitly configured HTTP transport.
95
+ *
96
+ * Construct this client when JavaScript needs direct access to quote,
97
+ * submission, lookup, trade, native-price, app-data, and cancellation orderbook
98
+ * endpoints. The client owns one callback registration and releases raw wasm
99
+ * resources through the facade `dispose()` method.
100
+ */
101
+ class OrderBookClient {
102
+ __destroy_into_raw() {
103
+ const ptr = this.__wbg_ptr;
104
+ this.__wbg_ptr = 0;
105
+ OrderBookClientFinalization.unregister(this);
106
+ return ptr;
107
+ }
108
+ free() {
109
+ const ptr = this.__destroy_into_raw();
110
+ wasm.__wbg_orderbookclient_free(ptr, 0);
111
+ }
112
+ /**
113
+ * Submits signed off-chain order cancellations.
114
+ *
115
+ * Build the signed cancellation payload with one of the cancellation
116
+ * signing helpers, then submit it through the same orderbook runtime
117
+ * configuration used for order operations.
118
+ *
119
+ * @param signed Signed cancellation payload.
120
+ * @param options Optional per-call cancellation and timeout settings.
121
+ * @returns A versioned envelope containing `{ cancelled: true }` on success.
122
+ * @throws CowError for invalid UID, signature, transport failure, or timeout.
123
+ * @param {SignedCancellationsInput} signed
124
+ * @param {SdkClientOptions | null} [options]
125
+ * @returns {WasmEnvelope<{ cancelled: true }>}
126
+ */
127
+ cancelOrders(signed, options) {
128
+ const ret = wasm.orderbookclient_cancelOrders(this.__wbg_ptr, addHeapObject(signed), isLikeNone(options) ? 0 : addHeapObject(options));
129
+ return takeObject(ret);
130
+ }
131
+ /**
132
+ * Fetches the full app-data document registered for an app-data hash.
133
+ *
134
+ * Use this to retrieve the canonical app-data payload the orderbook holds
135
+ * for a given hash, for example to display or re-verify a document
136
+ * referenced by an order.
137
+ *
138
+ * @param appDataHash App-data hash as a `0x`-prefixed 32-byte hex string.
139
+ * @param options Optional per-call cancellation and timeout settings.
140
+ * @returns A versioned envelope containing the app-data document.
141
+ * @throws CowError for an invalid hash, transport failure, or timeout.
142
+ * @param {string} appDataHash
143
+ * @param {SdkClientOptions | null} [options]
144
+ * @returns {WasmEnvelope<AppDataObjectDto>}
145
+ */
146
+ getAppData(appDataHash, options) {
147
+ const ptr0 = passStringToWasm0(appDataHash, wasm.__wbindgen_export, wasm.__wbindgen_export2);
148
+ const len0 = WASM_VECTOR_LEN;
149
+ const ret = wasm.orderbookclient_getAppData(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
150
+ return takeObject(ret);
151
+ }
152
+ /**
153
+ * Fetches a token's native price from the orderbook API.
154
+ *
155
+ * The token must be an EVM address. The returned value follows the
156
+ * orderbook native-price response shape.
157
+ *
158
+ * @param token Token address to price.
159
+ * @param options Optional per-call cancellation and timeout settings.
160
+ * @returns A versioned envelope containing native price data.
161
+ * @throws CowError for invalid token address, transport failure, or timeout.
162
+ * @param {string} token
163
+ * @param {SdkClientOptions | null} [options]
164
+ * @returns {WasmEnvelope<NativePriceResponseDto>}
165
+ */
166
+ getNativePrice(token, options) {
167
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_export, wasm.__wbindgen_export2);
168
+ const len0 = WASM_VECTOR_LEN;
169
+ const ret = wasm.orderbookclient_getNativePrice(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
170
+ return takeObject(ret);
171
+ }
172
+ /**
173
+ * Fetches one order by its canonical order UID.
174
+ *
175
+ * The UID must be the full 56-byte CoW order UID encoded as a `0x`-prefixed
176
+ * string. The response is returned in the orderbook wire DTO shape.
177
+ *
178
+ * @param orderUid Full order UID to look up.
179
+ * @param options Optional per-call cancellation and timeout settings.
180
+ * @returns A versioned envelope containing the order response.
181
+ * @throws CowError for invalid UID, not-found responses, transport failure, or timeout.
182
+ * @param {string} orderUid
183
+ * @param {SdkClientOptions | null} [options]
184
+ * @returns {WasmEnvelope<OrderDto>}
185
+ */
186
+ getOrder(orderUid, options) {
187
+ const ptr0 = passStringToWasm0(orderUid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
188
+ const len0 = WASM_VECTOR_LEN;
189
+ const ret = wasm.orderbookclient_getOrder(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
190
+ return takeObject(ret);
191
+ }
192
+ /**
193
+ * Fetches the live competition status for one order.
194
+ *
195
+ * Returns the order's status in the current or most recent solver
196
+ * competition, including any per-solver executed amounts the service
197
+ * reports. The UID must be the full 56-byte CoW order UID.
198
+ *
199
+ * @param orderUid Full order UID to look up.
200
+ * @param options Optional per-call cancellation and timeout settings.
201
+ * @returns A versioned envelope containing the competition status.
202
+ * @throws CowError for invalid UID, not-found responses, transport failure, or timeout.
203
+ * @param {string} orderUid
204
+ * @param {SdkClientOptions | null} [options]
205
+ * @returns {WasmEnvelope<CompetitionOrderStatusDto>}
206
+ */
207
+ getOrderCompetitionStatus(orderUid, options) {
208
+ const ptr0 = passStringToWasm0(orderUid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
209
+ const len0 = WASM_VECTOR_LEN;
210
+ const ret = wasm.orderbookclient_getOrderCompetitionStatus(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
211
+ return takeObject(ret);
212
+ }
213
+ /**
214
+ * Builds the public order-details URL for a UID without any network call.
215
+ *
216
+ * @param orderUid Full order UID to link to.
217
+ * @returns A versioned envelope containing the order-details URL.
218
+ * @throws CowError for an invalid UID or an unresolved base URL.
219
+ * @param {string} orderUid
220
+ * @returns {WasmEnvelope<string>}
221
+ */
222
+ getOrderLink(orderUid) {
223
+ try {
224
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
225
+ const ptr0 = passStringToWasm0(orderUid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
226
+ const len0 = WASM_VECTOR_LEN;
227
+ wasm.orderbookclient_getOrderLink(retptr, this.__wbg_ptr, ptr0, len0);
228
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
229
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
230
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
231
+ if (r2) {
232
+ throw takeObject(r1);
233
+ }
234
+ return takeObject(r0);
235
+ } finally {
236
+ wasm.__wbindgen_add_to_stack_pointer(16);
237
+ }
238
+ }
239
+ /**
240
+ * Fetches an order by UID, falling back across environments on a 404.
241
+ *
242
+ * @param orderUid Full order UID to look up.
243
+ * @param options Optional per-call cancellation and timeout settings.
244
+ * @returns A versioned envelope containing the order response.
245
+ * @throws CowError for invalid UID, not-found responses, transport failure, or timeout.
246
+ * @param {string} orderUid
247
+ * @param {SdkClientOptions | null} [options]
248
+ * @returns {WasmEnvelope<OrderDto>}
249
+ */
250
+ getOrderMultiEnv(orderUid, options) {
251
+ const ptr0 = passStringToWasm0(orderUid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
252
+ const len0 = WASM_VECTOR_LEN;
253
+ const ret = wasm.orderbookclient_getOrderMultiEnv(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
254
+ return takeObject(ret);
255
+ }
256
+ /**
257
+ * Fetches orders owned by an address with optional pagination.
258
+ *
259
+ * The owner address is validated before the request is dispatched. The
260
+ * response preserves the typed orderbook order shape.
261
+ *
262
+ * @param owner Owner address to query.
263
+ * @param pagination Optional offset and limit.
264
+ * @param options Optional per-call cancellation and timeout settings.
265
+ * @returns A versioned envelope containing matching orders.
266
+ * @throws CowError for invalid owner, transport failure, timeout, or cancellation.
267
+ * @param {string} owner
268
+ * @param {PaginationOptions | null} [pagination]
269
+ * @param {SdkClientOptions | null} [options]
270
+ * @returns {WasmEnvelope<OrderDto[]>}
271
+ */
272
+ getOrders(owner, pagination, options) {
273
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
274
+ const len0 = WASM_VECTOR_LEN;
275
+ const ret = wasm.orderbookclient_getOrders(this.__wbg_ptr, ptr0, len0, isLikeNone(pagination) ? 0 : addHeapObject(pagination), isLikeNone(options) ? 0 : addHeapObject(options));
276
+ return takeObject(ret);
277
+ }
278
+ /**
279
+ * Fetches a price quote from the orderbook API.
280
+ *
281
+ * The request is converted to the typed orderbook quote request and sent
282
+ * through the configured transport. Per-call options can override the
283
+ * constructor timeout or attach an `AbortSignal`.
284
+ *
285
+ * @param request Quote request DTO.
286
+ * @param options Optional per-call cancellation and timeout settings.
287
+ * @returns A versioned envelope containing the quote response.
288
+ * @throws CowError for invalid input, transport failure, timeout, or cancellation.
289
+ * @param {OrderQuoteRequestInput} request
290
+ * @param {SdkClientOptions | null} [options]
291
+ * @returns {WasmEnvelope<OrderQuoteResponseDto>}
292
+ */
293
+ getQuote(request, options) {
294
+ const ret = wasm.orderbookclient_getQuote(this.__wbg_ptr, addHeapObject(request), isLikeNone(options) ? 0 : addHeapObject(options));
295
+ return takeObject(ret);
296
+ }
297
+ /**
298
+ * Fetches the total accumulated surplus for an account.
299
+ *
300
+ * Returns the lifetime surplus the protocol has captured for the owner
301
+ * across its settled orders, in the upstream decimal-string wire shape.
302
+ *
303
+ * @param owner Owner address to query.
304
+ * @param options Optional per-call cancellation and timeout settings.
305
+ * @returns A versioned envelope containing the total-surplus response.
306
+ * @throws CowError for invalid owner, transport failure, or timeout.
307
+ * @param {string} owner
308
+ * @param {SdkClientOptions | null} [options]
309
+ * @returns {WasmEnvelope<TotalSurplusDto>}
310
+ */
311
+ getTotalSurplus(owner, options) {
312
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
313
+ const len0 = WASM_VECTOR_LEN;
314
+ const ret = wasm.orderbookclient_getTotalSurplus(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
315
+ return takeObject(ret);
316
+ }
317
+ /**
318
+ * Fetches trades for exactly one owner address or order UID.
319
+ *
320
+ * The query must set one of `owner` or `orderUid`, not both. Optional
321
+ * pagination fields are forwarded to the orderbook request.
322
+ *
323
+ * @param query Trade query DTO.
324
+ * @param options Optional per-call cancellation and timeout settings.
325
+ * @returns A versioned envelope containing matching trades.
326
+ * @throws CowError when the query is ambiguous or transport fails.
327
+ * @param {TradesQueryInput} query
328
+ * @param {SdkClientOptions | null} [options]
329
+ * @returns {WasmEnvelope<TradeDto[]>}
330
+ */
331
+ getTrades(query, options) {
332
+ const ret = wasm.orderbookclient_getTrades(this.__wbg_ptr, addHeapObject(query), isLikeNone(options) ? 0 : addHeapObject(options));
333
+ return takeObject(ret);
334
+ }
335
+ /**
336
+ * Fetches the orders contained in a settlement transaction.
337
+ *
338
+ * @param txHash Settlement transaction hash.
339
+ * @param options Optional per-call cancellation and timeout settings.
340
+ * @returns A versioned envelope containing the settled orders.
341
+ * @throws CowError for an invalid hash, transport failure, timeout, or cancellation.
342
+ * @param {string} txHash
343
+ * @param {SdkClientOptions | null} [options]
344
+ * @returns {WasmEnvelope<OrderDto[]>}
345
+ */
346
+ getTxOrders(txHash, options) {
347
+ const ptr0 = passStringToWasm0(txHash, wasm.__wbindgen_export, wasm.__wbindgen_export2);
348
+ const len0 = WASM_VECTOR_LEN;
349
+ const ret = wasm.orderbookclient_getTxOrders(this.__wbg_ptr, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
350
+ return takeObject(ret);
351
+ }
352
+ /**
353
+ * Fetches the orderbook service version string.
354
+ *
355
+ * @param options Optional per-call cancellation and timeout settings.
356
+ * @returns A versioned envelope containing the service version string.
357
+ * @throws CowError for transport failure, timeout, or cancellation.
358
+ * @param {SdkClientOptions | null} [options]
359
+ * @returns {WasmEnvelope<string>}
360
+ */
361
+ getVersion(options) {
362
+ const ret = wasm.orderbookclient_getVersion(this.__wbg_ptr, isLikeNone(options) ? 0 : addHeapObject(options));
363
+ return takeObject(ret);
364
+ }
365
+ /**
366
+ * Creates an orderbook client from a single config object.
367
+ *
368
+ * The config must include `chainId` and `transport`. The optional
369
+ * `timeoutMs`, `signal`, and `transportPolicy` fields become defaults for
370
+ * calls made through this client unless a method call overrides them.
371
+ *
372
+ * @param config Orderbook client configuration.
373
+ * @throws CowError when the chain, environment, transport, or policy is invalid.
374
+ * @param {OrderBookClientConfig} config
375
+ */
376
+ constructor(config) {
377
+ try {
378
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
379
+ wasm.orderbookclient_new(retptr, addHeapObject(config));
380
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
381
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
382
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
383
+ if (r2) {
384
+ throw takeObject(r1);
385
+ }
386
+ this.__wbg_ptr = r0;
387
+ OrderBookClientFinalization.register(this, this.__wbg_ptr, this);
388
+ return this;
389
+ } finally {
390
+ wasm.__wbindgen_add_to_stack_pointer(16);
391
+ }
392
+ }
393
+ /**
394
+ * Submits a signed order to the orderbook.
395
+ *
396
+ * The signed DTO normally comes from a signing helper in the same package.
397
+ * The SDK reconstructs the typed order creation payload and returns the
398
+ * order UID assigned by the orderbook service.
399
+ *
400
+ * @param signed Signed order DTO including typed data, signature, owner, and scheme.
401
+ * @param options Optional per-call cancellation and timeout settings.
402
+ * @returns A versioned envelope containing the submitted order UID.
403
+ * @throws CowError for invalid signatures, transport failure, timeout, or rejection.
404
+ * @param {SignedOrderDto} signed
405
+ * @param {SdkClientOptions | null} [options]
406
+ * @returns {WasmEnvelope<string>}
407
+ */
408
+ sendOrder(signed, options) {
409
+ const ret = wasm.orderbookclient_sendOrder(this.__wbg_ptr, addHeapObject(signed), isLikeNone(options) ? 0 : addHeapObject(options));
410
+ return takeObject(ret);
411
+ }
412
+ /**
413
+ * Submits a raw order-creation payload to the orderbook.
414
+ *
415
+ * Use this method when the host already has a complete orderbook
416
+ * `OrderCreation` shape and does not need the facade to reconstruct it
417
+ * from a signed-order DTO.
418
+ *
419
+ * @param input Raw order-creation DTO.
420
+ * @param options Optional per-call cancellation and timeout settings.
421
+ * @returns A versioned envelope containing the submitted order UID.
422
+ * @throws CowError for malformed input, transport failure, timeout, or rejection.
423
+ * @param {OrderCreationInput} input
424
+ * @param {SdkClientOptions | null} [options]
425
+ * @returns {WasmEnvelope<string>}
426
+ */
427
+ sendOrderCreation(input, options) {
428
+ const ret = wasm.orderbookclient_sendOrderCreation(this.__wbg_ptr, addHeapObject(input), isLikeNone(options) ? 0 : addHeapObject(options));
429
+ return takeObject(ret);
430
+ }
431
+ /**
432
+ * Uploads the full app-data JSON for a content-addressed app-data hash.
433
+ *
434
+ * The SDK enforces the content-addressed-write invariant: the keccak-256
435
+ * digest of `fullAppData` must equal `appDataHash`, or the call rejects
436
+ * before any network request. Serialize `fullAppData` with the canonical
437
+ * app-data writer so the digest matches.
438
+ *
439
+ * @param appDataHash App-data hash as a `0x`-prefixed 32-byte hex string.
440
+ * @param fullAppData Canonically serialized app-data JSON payload.
441
+ * @param options Optional per-call cancellation and timeout settings.
442
+ * @returns A versioned envelope containing `{ uploaded: true }` on success.
443
+ * @throws CowError for a hash mismatch, invalid hash, transport failure, or timeout.
444
+ * @param {string} appDataHash
445
+ * @param {string} fullAppData
446
+ * @param {SdkClientOptions | null} [options]
447
+ * @returns {WasmEnvelope<{ uploaded: true }>}
448
+ */
449
+ uploadAppData(appDataHash, fullAppData, options) {
450
+ const ptr0 = passStringToWasm0(appDataHash, wasm.__wbindgen_export, wasm.__wbindgen_export2);
451
+ const len0 = WASM_VECTOR_LEN;
452
+ const ptr1 = passStringToWasm0(fullAppData, wasm.__wbindgen_export, wasm.__wbindgen_export2);
453
+ const len1 = WASM_VECTOR_LEN;
454
+ const ret = wasm.orderbookclient_uploadAppData(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(options) ? 0 : addHeapObject(options));
455
+ return takeObject(ret);
456
+ }
457
+ }
458
+ if (Symbol.dispose) OrderBookClient.prototype[Symbol.dispose] = OrderBookClient.prototype.free;
459
+ exports.OrderBookClient = OrderBookClient;
460
+
461
+ /**
462
+ * Read-only subgraph client backed by an explicitly configured transport.
463
+ *
464
+ * Construct this client when JavaScript needs protocol totals, recent volume,
465
+ * or custom GraphQL query execution through the same transport and policy
466
+ * model as the orderbook clients.
467
+ */
468
+ class SubgraphClient {
469
+ __destroy_into_raw() {
470
+ const ptr = this.__wbg_ptr;
471
+ this.__wbg_ptr = 0;
472
+ SubgraphClientFinalization.unregister(this);
473
+ return ptr;
474
+ }
475
+ free() {
476
+ const ptr = this.__destroy_into_raw();
477
+ wasm.__wbg_subgraphclient_free(ptr, 0);
478
+ }
479
+ /**
480
+ * Fetches recent daily volume rows.
481
+ *
482
+ * The `days` value controls how many recent daily buckets the subgraph
483
+ * query requests.
484
+ *
485
+ * @param days Number of daily buckets to fetch.
486
+ * @param options Optional per-call cancellation and timeout settings.
487
+ * @returns A versioned envelope containing daily volume rows.
488
+ * @throws CowError for invalid query shape, transport failure, or timeout.
489
+ * @param {number} days
490
+ * @param {SdkClientOptions | null} [options]
491
+ * @returns {Promise<any>}
492
+ */
493
+ getLastDaysVolume(days, options) {
494
+ const ret = wasm.subgraphclient_getLastDaysVolume(this.__wbg_ptr, days, isLikeNone(options) ? 0 : addHeapObject(options));
495
+ return takeObject(ret);
496
+ }
497
+ /**
498
+ * Fetches recent hourly volume rows.
499
+ *
500
+ * The `hours` value controls how many recent hourly buckets the subgraph
501
+ * query requests.
502
+ *
503
+ * @param hours Number of hourly buckets to fetch.
504
+ * @param options Optional per-call cancellation and timeout settings.
505
+ * @returns A versioned envelope containing hourly volume rows.
506
+ * @throws CowError for invalid query shape, transport failure, or timeout.
507
+ * @param {number} hours
508
+ * @param {SdkClientOptions | null} [options]
509
+ * @returns {Promise<any>}
510
+ */
511
+ getLastHoursVolume(hours, options) {
512
+ const ret = wasm.subgraphclient_getLastHoursVolume(this.__wbg_ptr, hours, isLikeNone(options) ? 0 : addHeapObject(options));
513
+ return takeObject(ret);
514
+ }
515
+ /**
516
+ * Fetches aggregate protocol totals from the subgraph.
517
+ *
518
+ * The request uses the client's configured chain, API key, transport, and
519
+ * transport policy.
520
+ *
521
+ * @param options Optional per-call cancellation and timeout settings.
522
+ * @returns A versioned envelope containing aggregate totals.
523
+ * @throws CowError for transport, cancellation, timeout, or subgraph errors.
524
+ * @param {SdkClientOptions | null} [options]
525
+ * @returns {Promise<any>}
526
+ */
527
+ getTotals(options) {
528
+ const ret = wasm.subgraphclient_getTotals(this.__wbg_ptr, isLikeNone(options) ? 0 : addHeapObject(options));
529
+ return takeObject(ret);
530
+ }
531
+ /**
532
+ * Creates a subgraph client from a single config object.
533
+ *
534
+ * The config must include `chainId`, `apiKey`, and `transport`. Optional
535
+ * timeout, signal, and policy fields become client defaults for later
536
+ * method calls.
537
+ *
538
+ * @param config Subgraph client configuration.
539
+ * @throws CowError when the chain, API key, transport, or policy is invalid.
540
+ * @param {SubgraphClientConfig} config
541
+ */
542
+ constructor(config) {
543
+ try {
544
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
545
+ wasm.subgraphclient_new(retptr, addHeapObject(config));
546
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
547
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
548
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
549
+ if (r2) {
550
+ throw takeObject(r1);
551
+ }
552
+ this.__wbg_ptr = r0;
553
+ SubgraphClientFinalization.register(this, this.__wbg_ptr, this);
554
+ return this;
555
+ } finally {
556
+ wasm.__wbindgen_add_to_stack_pointer(16);
557
+ }
558
+ }
559
+ /**
560
+ * Runs a caller-provided GraphQL query against the configured subgraph.
561
+ *
562
+ * Use this method when the built-in totals or volume helpers are too
563
+ * narrow. Variables and operation name are forwarded when present.
564
+ *
565
+ * @param request GraphQL query, variables, and optional operation name.
566
+ * @param options Optional per-call cancellation and timeout settings.
567
+ * @returns A versioned envelope containing the JSON GraphQL response.
568
+ * @throws CowError for transport, timeout, cancellation, or GraphQL errors.
569
+ * @param {SubgraphQueryInput} request
570
+ * @param {SdkClientOptions | null} [options]
571
+ * @returns {Promise<any>}
572
+ */
573
+ runQuery(request, options) {
574
+ const ret = wasm.subgraphclient_runQuery(this.__wbg_ptr, addHeapObject(request), isLikeNone(options) ? 0 : addHeapObject(options));
575
+ return takeObject(ret);
576
+ }
577
+ }
578
+ if (Symbol.dispose) SubgraphClient.prototype[Symbol.dispose] = SubgraphClient.prototype.free;
579
+ exports.SubgraphClient = SubgraphClient;
580
+
581
+ /**
582
+ * High-level trading client backed by an explicitly configured orderbook.
583
+ *
584
+ * Construct this client when JavaScript needs quote, sign, post, allowance,
585
+ * and native-sell helper workflows rather than direct orderbook calls. The
586
+ * client keeps app-code, chain, environment, transport, and policy defaults.
587
+ */
588
+ class TradingClient {
589
+ __destroy_into_raw() {
590
+ const ptr = this.__wbg_ptr;
591
+ this.__wbg_ptr = 0;
592
+ TradingClientFinalization.unregister(this);
593
+ return ptr;
594
+ }
595
+ free() {
596
+ const ptr = this.__destroy_into_raw();
597
+ wasm.__wbg_tradingclient_free(ptr, 0);
598
+ }
599
+ /**
600
+ * Builds the ERC-20 approval transaction for the CoW Protocol vault relayer.
601
+ *
602
+ * The SDK encodes the unsigned `approve` transaction; the JavaScript host
603
+ * owns submission through its own wallet. This completes the
604
+ * read-allowance-then-approve path alongside `getCowProtocolAllowance`.
605
+ *
606
+ * @param params Approval parameters DTO (token, amount, optional vault-relayer override).
607
+ * @param options Optional per-call cancellation and timeout settings.
608
+ * @returns A versioned envelope containing the unsigned approval transaction request.
609
+ * @throws CowError when the token, amount, or vault-relayer override is invalid.
610
+ * @param {ApprovalParametersInput} params
611
+ * @param {SdkClientOptions | null} [options]
612
+ * @returns {WasmEnvelope<TransactionRequestDto>}
613
+ */
614
+ buildApprovalTx(params, options) {
615
+ const ret = wasm.tradingclient_buildApprovalTx(this.__wbg_ptr, addHeapObject(params), isLikeNone(options) ? 0 : addHeapObject(options));
616
+ return takeObject(ret);
617
+ }
618
+ /**
619
+ * Builds the transaction for a native-currency sell order.
620
+ *
621
+ * The helper validates that the order sells the native-token sentinel,
622
+ * resolves the EthFlow deployment, and returns a transaction request for
623
+ * the host wallet to submit.
624
+ *
625
+ * @param order Unsigned native-sell order DTO.
626
+ * @param quoteId Quote identifier returned by the orderbook.
627
+ * @param from Transaction sender address.
628
+ * @param options Optional per-call cancellation and timeout settings.
629
+ * @returns A versioned envelope containing order UID and transaction request.
630
+ * @throws CowError when the order, chain, deployment, or sender is invalid.
631
+ * @param {OrderInput} order
632
+ * @param {number} quoteId
633
+ * @param {string} from
634
+ * @param {SdkClientOptions | null} [options]
635
+ * @returns {WasmEnvelope<BuiltSellNativeCurrencyTxDto>}
636
+ */
637
+ buildSellNativeCurrencyTx(order, quoteId, from, options) {
638
+ const ptr0 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
639
+ const len0 = WASM_VECTOR_LEN;
640
+ const ret = wasm.tradingclient_buildSellNativeCurrencyTx(this.__wbg_ptr, addHeapObject(order), quoteId, ptr0, len0, isLikeNone(options) ? 0 : addHeapObject(options));
641
+ return takeObject(ret);
642
+ }
643
+ /**
644
+ * Reads CoW Protocol allowance through a read-only contract callback.
645
+ *
646
+ * The SDK builds the contract call while the JavaScript host performs the
647
+ * actual chain read. Use this when a TypeScript runtime owns the RPC
648
+ * provider.
649
+ *
650
+ * @param params Allowance parameters DTO.
651
+ * @param readContractCallback Callback that executes the read-only call.
652
+ * @param options Optional per-call cancellation and timeout settings.
653
+ * @returns A versioned envelope containing the allowance amount string.
654
+ * @throws CowError for invalid parameters, callback failure, timeout, or cancellation.
655
+ * @param {AllowanceParametersInput} params
656
+ * @param {ContractReadCallback} readContractCallback
657
+ * @param {SdkClientOptions | null} [options]
658
+ * @returns {WasmEnvelope<string>}
659
+ */
660
+ getCowProtocolAllowance(params, readContractCallback, options) {
661
+ const ret = wasm.tradingclient_getCowProtocolAllowance(this.__wbg_ptr, addHeapObject(params), addHeapObject(readContractCallback), isLikeNone(options) ? 0 : addHeapObject(options));
662
+ return takeObject(ret);
663
+ }
664
+ /**
665
+ * Fetches a quote without signing or submitting an order.
666
+ *
667
+ * Use this method when a host wants to preview the quote response before
668
+ * asking a wallet to sign or before constructing a post request.
669
+ *
670
+ * @param params Swap parameters DTO.
671
+ * @param options Optional per-call cancellation and timeout settings.
672
+ * @returns A versioned envelope containing quote results.
673
+ * @throws CowError for invalid parameters, transport failure, timeout, or cancellation.
674
+ * @param {SwapParametersInput} params
675
+ * @param {SdkClientOptions | null} [options]
676
+ * @returns {WasmEnvelope<QuoteResultsDto>}
677
+ */
678
+ getQuote(params, options) {
679
+ const ret = wasm.tradingclient_getQuote(this.__wbg_ptr, addHeapObject(params), isLikeNone(options) ? 0 : addHeapObject(options));
680
+ return takeObject(ret);
681
+ }
682
+ /**
683
+ * Creates a trading client from a single config object.
684
+ *
685
+ * The config must include `chainId`, `appCode`, and `transport`. Optional
686
+ * environment, API key, timeout, signal, and transport policy fields become
687
+ * defaults for all trading methods.
688
+ *
689
+ * @param config Trading client configuration.
690
+ * @throws CowError when chain, app-code, environment, transport, or policy validation fails.
691
+ * @param {TradingClientConfig} config
692
+ */
693
+ constructor(config) {
694
+ try {
695
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
696
+ wasm.tradingclient_new(retptr, addHeapObject(config));
697
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
698
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
699
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
700
+ if (r2) {
701
+ throw takeObject(r1);
702
+ }
703
+ this.__wbg_ptr = r0;
704
+ TradingClientFinalization.register(this, this.__wbg_ptr, this);
705
+ return this;
706
+ } finally {
707
+ wasm.__wbindgen_add_to_stack_pointer(16);
708
+ }
709
+ }
710
+ /**
711
+ * Signs and posts a limit order through a typed-data callback.
712
+ *
713
+ * This helper follows the native limit-order trading path and lets the SDK
714
+ * build, sign, and submit the order using the configured orderbook.
715
+ *
716
+ * @param params Limit-order parameters DTO.
717
+ * @param owner Owner address to bind to the order when absent from params.
718
+ * @param signerCallback Callback that signs the typed-data envelope.
719
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
720
+ * @returns A versioned envelope containing order posting output.
721
+ * @throws CowError for invalid input, wallet failure, timeout, or rejection.
722
+ * @param {LimitTradeParametersInput} params
723
+ * @param {string} owner
724
+ * @param {TypedDataSignerCallback} signerCallback
725
+ * @param {SigningOptions | null} [options]
726
+ * @returns {WasmEnvelope<OrderPostingResultDto>}
727
+ */
728
+ postLimitOrder(params, owner, signerCallback, options) {
729
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
730
+ const len0 = WASM_VECTOR_LEN;
731
+ const ret = wasm.tradingclient_postLimitOrder(this.__wbg_ptr, addHeapObject(params), ptr0, len0, addHeapObject(signerCallback), isLikeNone(options) ? 0 : addHeapObject(options));
732
+ return takeObject(ret);
733
+ }
734
+ /**
735
+ * Quotes, signs, and posts a swap order through a typed-data callback.
736
+ *
737
+ * The SDK fetches a quote, builds the order to sign, invokes the callback
738
+ * with the EIP-712 envelope, posts the signed order, and returns posting
739
+ * output from the trading workflow.
740
+ *
741
+ * @param params Swap parameters DTO.
742
+ * @param owner Owner address to bind to the order.
743
+ * @param signerCallback Callback that signs the typed-data envelope.
744
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
745
+ * @returns A versioned envelope containing order posting output.
746
+ * @throws CowError for invalid input, quote failure, wallet failure, timeout, or rejection.
747
+ * @param {SwapParametersInput} params
748
+ * @param {string} owner
749
+ * @param {TypedDataSignerCallback} signerCallback
750
+ * @param {SigningOptions | null} [options]
751
+ * @returns {WasmEnvelope<OrderPostingResultDto>}
752
+ */
753
+ postSwapOrder(params, owner, signerCallback, options) {
754
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
755
+ const len0 = WASM_VECTOR_LEN;
756
+ const ret = wasm.tradingclient_postSwapOrder(this.__wbg_ptr, addHeapObject(params), ptr0, len0, addHeapObject(signerCallback), isLikeNone(options) ? 0 : addHeapObject(options));
757
+ return takeObject(ret);
758
+ }
759
+ /**
760
+ * Signs and posts a previously quoted swap order.
761
+ *
762
+ * Use this method when a host has already called `getQuote` and wants to
763
+ * reuse that quote result for posting without requesting a new quote.
764
+ *
765
+ * @param quoteResults Quote result DTO returned by `getQuote`.
766
+ * @param owner Owner address to bind to the order.
767
+ * @param signerCallback Callback that signs the typed-data envelope.
768
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
769
+ * @returns A versioned envelope containing order posting output.
770
+ * @throws CowError for invalid quote data, wallet failure, timeout, or rejection.
771
+ * @param {QuoteResultsDto} quoteResults
772
+ * @param {string} owner
773
+ * @param {TypedDataSignerCallback} signerCallback
774
+ * @param {SigningOptions | null} [options]
775
+ * @returns {WasmEnvelope<OrderPostingResultDto>}
776
+ */
777
+ postSwapOrderFromQuote(quoteResults, owner, signerCallback, options) {
778
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
779
+ const len0 = WASM_VECTOR_LEN;
780
+ const ret = wasm.tradingclient_postSwapOrderFromQuote(this.__wbg_ptr, addHeapObject(quoteResults), ptr0, len0, addHeapObject(signerCallback), isLikeNone(options) ? 0 : addHeapObject(options));
781
+ return takeObject(ret);
782
+ }
783
+ /**
784
+ * Quotes and posts a swap order with a custom EIP-1271 signature callback.
785
+ *
786
+ * Use this method when a smart-account runtime owns final contract
787
+ * signature production. The SDK still quotes the swap, builds typed data,
788
+ * posts the signed order, and returns posting output.
789
+ *
790
+ * @param params Swap parameters DTO.
791
+ * @param owner Smart-account owner address.
792
+ * @param customCallback Callback that returns the final EIP-1271 signature.
793
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
794
+ * @returns A versioned envelope containing order posting output.
795
+ * @throws CowError for invalid input, quote failure, callback failure, timeout, or rejection.
796
+ * @param {SwapParametersInput} params
797
+ * @param {string} owner
798
+ * @param {CustomEip1271Callback} customCallback
799
+ * @param {SigningOptions | null} [options]
800
+ * @returns {WasmEnvelope<OrderPostingResultDto>}
801
+ */
802
+ postSwapOrderWithEip1271(params, owner, customCallback, options) {
803
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
804
+ const len0 = WASM_VECTOR_LEN;
805
+ const ret = wasm.tradingclient_postSwapOrderWithEip1271(this.__wbg_ptr, addHeapObject(params), ptr0, len0, addHeapObject(customCallback), isLikeNone(options) ? 0 : addHeapObject(options));
806
+ return takeObject(ret);
807
+ }
808
+ }
809
+ if (Symbol.dispose) TradingClient.prototype[Symbol.dispose] = TradingClient.prototype.free;
810
+ exports.TradingClient = TradingClient;
811
+
812
+ /**
813
+ * Initializes the wasm crate's panic hook once.
814
+ */
815
+ function __cow_sdk_wasm_init() {
816
+ wasm.__cow_sdk_wasm_init();
817
+ }
818
+ exports.__cow_sdk_wasm_init = __cow_sdk_wasm_init;
819
+
820
+ /**
821
+ * Builds a normalized app-data document without deriving storage metadata.
822
+ *
823
+ * This helper is useful when a host wants to inspect or modify the canonical
824
+ * document shape before separately deriving app-data information.
825
+ *
826
+ * @param doc App-data document input accepted by the SDK schema.
827
+ * @returns A versioned envelope containing the normalized document.
828
+ * @throws CowError when the input cannot be normalized.
829
+ * @param {AppDataDocInput} doc
830
+ * @returns {WasmEnvelope<AppDataDocDto>}
831
+ */
832
+ function appDataDoc(doc) {
833
+ try {
834
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
835
+ wasm.appDataDoc(retptr, addHeapObject(doc));
836
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
837
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
838
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
839
+ if (r2) {
840
+ throw takeObject(r1);
841
+ }
842
+ return takeObject(r0);
843
+ } finally {
844
+ wasm.__wbindgen_add_to_stack_pointer(16);
845
+ }
846
+ }
847
+ exports.appDataDoc = appDataDoc;
848
+
849
+ /**
850
+ * Converts a `0x`-prefixed app-data hash into the canonical IPFS CID.
851
+ *
852
+ * The conversion is pure and uses the same app-data multicodec and multihash
853
+ * rules as the Rust app-data crate.
854
+ *
855
+ * @param appDataHex App-data hash as a `0x`-prefixed hex string.
856
+ * @returns A versioned envelope containing the CID string.
857
+ * @throws CowError when the hash is malformed.
858
+ * @param {string} appDataHex
859
+ * @returns {WasmEnvelope<string>}
860
+ */
861
+ function appDataHexToCid(appDataHex) {
862
+ try {
863
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
864
+ const ptr0 = passStringToWasm0(appDataHex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
865
+ const len0 = WASM_VECTOR_LEN;
866
+ wasm.appDataHexToCid(retptr, ptr0, len0);
867
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
868
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
869
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
870
+ if (r2) {
871
+ throw takeObject(r1);
872
+ }
873
+ return takeObject(r0);
874
+ } finally {
875
+ wasm.__wbindgen_add_to_stack_pointer(16);
876
+ }
877
+ }
878
+ exports.appDataHexToCid = appDataHexToCid;
879
+
880
+ /**
881
+ * Builds app-data content and returns its deterministic hash and CID.
882
+ *
883
+ * Use this when a JavaScript host wants the SDK to construct the canonical
884
+ * document and expose the values needed for order submission and storage.
885
+ *
886
+ * @param doc App-data document input accepted by the SDK schema.
887
+ * @returns A versioned envelope containing document, hash, CID, and hex data.
888
+ * @throws CowError when the document cannot be normalized or hashed.
889
+ * @param {AppDataDocInput} doc
890
+ * @returns {WasmEnvelope<AppDataInfoDto>}
891
+ */
892
+ function appDataInfo(doc) {
893
+ try {
894
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
895
+ wasm.appDataInfo(retptr, addHeapObject(doc));
896
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
897
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
898
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
899
+ if (r2) {
900
+ throw takeObject(r1);
901
+ }
902
+ return takeObject(r0);
903
+ } finally {
904
+ wasm.__wbindgen_add_to_stack_pointer(16);
905
+ }
906
+ }
907
+ exports.appDataInfo = appDataInfo;
908
+
909
+ /**
910
+ * Builds a settlement cancellation transaction for an order UID.
911
+ *
912
+ * The returned transaction request targets the Settlement contract and encodes
913
+ * `invalidateOrder(bytes)`. The host wallet remains responsible for submitting
914
+ * and observing the transaction.
915
+ *
916
+ * @param params Order UID, chain, environment, and optional deployment override.
917
+ * @returns A versioned envelope containing the transaction request DTO.
918
+ * @throws CowError when the chain, deployment, or order UID is invalid.
919
+ * @param {OrderTraderParametersInput} params
920
+ * @returns {WasmEnvelope<TransactionRequestDto>}
921
+ */
922
+ function buildCancelOrderTx(params) {
923
+ try {
924
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
925
+ wasm.buildCancelOrderTx(retptr, addHeapObject(params));
926
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
927
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
928
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
929
+ if (r2) {
930
+ throw takeObject(r1);
931
+ }
932
+ return takeObject(r0);
933
+ } finally {
934
+ wasm.__wbindgen_add_to_stack_pointer(16);
935
+ }
936
+ }
937
+ exports.buildCancelOrderTx = buildCancelOrderTx;
938
+
939
+ /**
940
+ * Builds a settlement pre-sign transaction for an order UID.
941
+ *
942
+ * The returned transaction request targets the Settlement contract and encodes
943
+ * `setPreSignature(bytes,bool)` with the order UID and `true` flag. The host
944
+ * wallet remains responsible for transaction submission.
945
+ *
946
+ * @param params Order UID, chain, environment, and optional deployment override.
947
+ * @returns A versioned envelope containing the transaction request DTO.
948
+ * @throws CowError when the chain, deployment, or order UID is invalid.
949
+ * @param {OrderTraderParametersInput} params
950
+ * @returns {WasmEnvelope<TransactionRequestDto>}
951
+ */
952
+ function buildPresignTx(params) {
953
+ try {
954
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
955
+ wasm.buildPresignTx(retptr, addHeapObject(params));
956
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
957
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
958
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
959
+ if (r2) {
960
+ throw takeObject(r1);
961
+ }
962
+ return takeObject(r0);
963
+ } finally {
964
+ wasm.__wbindgen_add_to_stack_pointer(16);
965
+ }
966
+ }
967
+ exports.buildPresignTx = buildPresignTx;
968
+
969
+ /**
970
+ * Converts a canonical IPFS CID into a `0x`-prefixed app-data hash.
971
+ *
972
+ * Use this helper when an order or metadata path starts from a CID but the
973
+ * orderbook request needs the app-data hash form.
974
+ *
975
+ * @param cid Canonical CID string for an app-data document.
976
+ * @returns A versioned envelope containing the `0x`-prefixed hash.
977
+ * @throws CowError when the CID does not match the supported app-data shape.
978
+ * @param {string} cid
979
+ * @returns {WasmEnvelope<string>}
980
+ */
981
+ function cidToAppDataHex(cid) {
982
+ try {
983
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
984
+ const ptr0 = passStringToWasm0(cid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
985
+ const len0 = WASM_VECTOR_LEN;
986
+ wasm.cidToAppDataHex(retptr, ptr0, len0);
987
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
988
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
989
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
990
+ if (r2) {
991
+ throw takeObject(r1);
992
+ }
993
+ return takeObject(r0);
994
+ } finally {
995
+ wasm.__wbindgen_add_to_stack_pointer(16);
996
+ }
997
+ }
998
+ exports.cidToAppDataHex = cidToAppDataHex;
999
+
1000
+ /**
1001
+ * Computes the canonical order UID and order digest for an unsigned order.
1002
+ *
1003
+ * The UID combines the EIP-712 order digest, owner address, and validity
1004
+ * timestamp using the same packing rules as the native Rust SDK.
1005
+ *
1006
+ * @param input Unsigned order fields to hash and pack.
1007
+ * @param chainId EVM chain id used for the EIP-712 domain.
1008
+ * @param owner Order owner address included in the UID suffix.
1009
+ * @returns A versioned envelope with `orderUid` and `orderDigest`.
1010
+ * @throws CowError when the order, owner, or chain id is invalid.
1011
+ * @param {OrderInput} input
1012
+ * @param {number} chainId
1013
+ * @param {string} owner
1014
+ * @returns {WasmEnvelope<GeneratedOrderUidDto>}
1015
+ */
1016
+ function computeOrderUid(input, chainId, owner) {
1017
+ try {
1018
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1019
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1020
+ const len0 = WASM_VECTOR_LEN;
1021
+ wasm.computeOrderUid(retptr, addHeapObject(input), chainId, ptr0, len0);
1022
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1023
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1024
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1025
+ if (r2) {
1026
+ throw takeObject(r1);
1027
+ }
1028
+ return takeObject(r0);
1029
+ } finally {
1030
+ wasm.__wbindgen_add_to_stack_pointer(16);
1031
+ }
1032
+ }
1033
+ exports.computeOrderUid = computeOrderUid;
1034
+
1035
+ /**
1036
+ * Decodes an eth-flow on-chain order lifecycle event log into a typed event.
1037
+ *
1038
+ * Dispatches on the log's topic-0 across the `CoWSwapOnchainOrders`
1039
+ * `OrderPlacement` / `OrderInvalidation` events and the `CoWSwapEthFlow`
1040
+ * `OrderRefund` event. The decode is fail-closed: the topic set and on-chain
1041
+ * signing scheme are validated and every order UID is length-checked, so a
1042
+ * malformed or hostile log returns a typed error rather than panicking.
1043
+ *
1044
+ * @param log Raw log with `topics` (0x-prefixed 32-byte hex, topic-0 first)
1045
+ * and `data` (0x-prefixed hex, `"0x"` when empty).
1046
+ * @returns A versioned envelope containing the decoded eth-flow event.
1047
+ * @throws CowError when the log is malformed or its topic set matches no known
1048
+ * eth-flow lifecycle event.
1049
+ * @param {EventLogInput} log
1050
+ * @returns {WasmEnvelope<EthFlowEventDto>}
1051
+ */
1052
+ function decodeEthFlowLog(log) {
1053
+ try {
1054
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1055
+ wasm.decodeEthFlowLog(retptr, addHeapObject(log));
1056
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1057
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1058
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1059
+ if (r2) {
1060
+ throw takeObject(r1);
1061
+ }
1062
+ return takeObject(r0);
1063
+ } finally {
1064
+ wasm.__wbindgen_add_to_stack_pointer(16);
1065
+ }
1066
+ }
1067
+ exports.decodeEthFlowLog = decodeEthFlowLog;
1068
+
1069
+ /**
1070
+ * Decodes a `GPv2Settlement` event log into a typed settlement event.
1071
+ *
1072
+ * Dispatches on the log's topic-0 across `Trade`, `Interaction`, `Settlement`,
1073
+ * `OrderInvalidated`, and `PreSignature`. The decode is fail-closed: the topic
1074
+ * set is validated before ABI decoding and every order UID is length-checked,
1075
+ * so a malformed or hostile log returns a typed error rather than panicking.
1076
+ *
1077
+ * @param log Raw log with `topics` (0x-prefixed 32-byte hex, topic-0 first)
1078
+ * and `data` (0x-prefixed hex, `"0x"` when empty).
1079
+ * @returns A versioned envelope containing the decoded settlement event.
1080
+ * @throws CowError when the log is malformed or its topic set matches no known
1081
+ * settlement event.
1082
+ * @param {EventLogInput} log
1083
+ * @returns {WasmEnvelope<SettlementEventDto>}
1084
+ */
1085
+ function decodeSettlementLog(log) {
1086
+ try {
1087
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1088
+ wasm.decodeSettlementLog(retptr, addHeapObject(log));
1089
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1090
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1091
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1092
+ if (r2) {
1093
+ throw takeObject(r1);
1094
+ }
1095
+ return takeObject(r0);
1096
+ } finally {
1097
+ wasm.__wbindgen_add_to_stack_pointer(16);
1098
+ }
1099
+ }
1100
+ exports.decodeSettlementLog = decodeSettlementLog;
1101
+
1102
+ /**
1103
+ * Returns canonical CoW Protocol deployment addresses for a chain.
1104
+ *
1105
+ * The optional environment selects production or staging deployment data. When
1106
+ * omitted, the helper uses the SDK default environment.
1107
+ *
1108
+ * @param chainId EVM chain id to resolve.
1109
+ * @param env Optional CoW environment name, such as `prod` or `staging`.
1110
+ * @returns Settlement, VaultRelayer, EthFlow, and AllowListAuth addresses.
1111
+ * @throws CowError when the chain or environment is unsupported.
1112
+ * @param {number} chainId
1113
+ * @param {string | null} [env]
1114
+ * @returns {WasmEnvelope<DeploymentAddressesDto>}
1115
+ */
1116
+ function deploymentAddresses(chainId, env) {
1117
+ try {
1118
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1119
+ var ptr0 = isLikeNone(env) ? 0 : passStringToWasm0(env, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1120
+ var len0 = WASM_VECTOR_LEN;
1121
+ wasm.deploymentAddresses(retptr, chainId, ptr0, len0);
1122
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1123
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1124
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1125
+ if (r2) {
1126
+ throw takeObject(r1);
1127
+ }
1128
+ return takeObject(r0);
1129
+ } finally {
1130
+ wasm.__wbindgen_add_to_stack_pointer(16);
1131
+ }
1132
+ }
1133
+ exports.deploymentAddresses = deploymentAddresses;
1134
+
1135
+ /**
1136
+ * Computes the CoW Protocol EIP-712 domain separator for a supported chain.
1137
+ *
1138
+ * Use this helper when a JavaScript host needs to compare the domain hash used
1139
+ * by the Rust SDK with another signing stack. The input is an EVM chain id,
1140
+ * not a CoW environment selector.
1141
+ *
1142
+ * @param chainId EVM chain id supported by the deployment registry.
1143
+ * @returns The `0x`-prefixed 32-byte domain separator.
1144
+ * @throws CowError when the chain is not supported.
1145
+ * @param {number} chainId
1146
+ * @returns {string}
1147
+ */
1148
+ function domainSeparator(chainId) {
1149
+ let deferred2_0;
1150
+ let deferred2_1;
1151
+ try {
1152
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1153
+ wasm.domainSeparator(retptr, chainId);
1154
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1155
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1156
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1157
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1158
+ var ptr1 = r0;
1159
+ var len1 = r1;
1160
+ if (r3) {
1161
+ ptr1 = 0; len1 = 0;
1162
+ throw takeObject(r2);
1163
+ }
1164
+ deferred2_0 = ptr1;
1165
+ deferred2_1 = len1;
1166
+ return getStringFromWasm0(ptr1, len1);
1167
+ } finally {
1168
+ wasm.__wbindgen_add_to_stack_pointer(16);
1169
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1170
+ }
1171
+ }
1172
+ exports.domainSeparator = domainSeparator;
1173
+
1174
+ /**
1175
+ * Encodes a CoW EIP-1271 payload from an ECDSA order signature.
1176
+ *
1177
+ * Use this pure helper when a smart-account flow already has the wrapped ECDSA
1178
+ * signature and needs the contract-signature payload bytes expected by CoW
1179
+ * Protocol order submission.
1180
+ *
1181
+ * @param input Unsigned order used to derive the EIP-1271 payload.
1182
+ * @param ecdsaSignature Wrapped ECDSA signature as a `0x`-prefixed string.
1183
+ * @returns A versioned envelope containing the encoded EIP-1271 payload.
1184
+ * @throws CowError when the order or signature is invalid.
1185
+ * @param {OrderInput} input
1186
+ * @param {string} ecdsaSignature
1187
+ * @returns {WasmEnvelope<string>}
1188
+ */
1189
+ function eip1271SignaturePayload(input, ecdsaSignature) {
1190
+ try {
1191
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1192
+ const ptr0 = passStringToWasm0(ecdsaSignature, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1193
+ const len0 = WASM_VECTOR_LEN;
1194
+ wasm.eip1271SignaturePayload(retptr, addHeapObject(input), ptr0, len0);
1195
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1196
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1197
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1198
+ if (r2) {
1199
+ throw takeObject(r1);
1200
+ }
1201
+ return takeObject(r0);
1202
+ } finally {
1203
+ wasm.__wbindgen_add_to_stack_pointer(16);
1204
+ }
1205
+ }
1206
+ exports.eip1271SignaturePayload = eip1271SignaturePayload;
1207
+
1208
+ /**
1209
+ * Builds signer-facing EIP-712 typed data for an unsigned order.
1210
+ *
1211
+ * The returned envelope contains the domain, type map, primary type, and
1212
+ * order message that wallet libraries expect for EIP-712 signing. It is
1213
+ * deterministic for the provided order and chain id.
1214
+ *
1215
+ * @param input Unsigned order fields using the facade order DTO shape.
1216
+ * @param chainId EVM chain id used for the EIP-712 domain.
1217
+ * @returns A versioned envelope containing typed-data DTO fields.
1218
+ * @throws CowError when order parsing or chain validation fails.
1219
+ * @param {OrderInput} input
1220
+ * @param {number} chainId
1221
+ * @returns {WasmEnvelope<TypedDataEnvelopeDto>}
1222
+ */
1223
+ function orderTypedData(input, chainId) {
1224
+ try {
1225
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1226
+ wasm.orderTypedData(retptr, addHeapObject(input), chainId);
1227
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1228
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1229
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1230
+ if (r2) {
1231
+ throw takeObject(r1);
1232
+ }
1233
+ return takeObject(r0);
1234
+ } finally {
1235
+ wasm.__wbindgen_add_to_stack_pointer(16);
1236
+ }
1237
+ }
1238
+ exports.orderTypedData = orderTypedData;
1239
+
1240
+ /**
1241
+ * Signs a cancellation digest through an explicit `eth_sign` callback.
1242
+ *
1243
+ * The SDK computes the canonical cancellation digest for the provided UIDs and
1244
+ * passes it to the digest signer callback as a `0x`-prefixed string.
1245
+ *
1246
+ * @param orderUids One or more full order UIDs to cancel.
1247
+ * @param chainId EVM chain id used for the cancellation digest.
1248
+ * @param digestSigner Callback that signs the digest string.
1249
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
1250
+ * @returns A versioned envelope containing signed cancellations.
1251
+ * @throws CowError for empty input, invalid UID, callback failure, or timeout.
1252
+ * @param {string[]} orderUids
1253
+ * @param {number} chainId
1254
+ * @param {DigestSignerCallback} digestSigner
1255
+ * @param {SigningOptions | null} [options]
1256
+ * @returns {WasmEnvelope<SignedCancellationsInput>}
1257
+ */
1258
+ function signCancellationEthSignDigest(orderUids, chainId, digestSigner, options) {
1259
+ const ptr0 = passArrayJsValueToWasm0(orderUids, wasm.__wbindgen_export);
1260
+ const len0 = WASM_VECTOR_LEN;
1261
+ const ret = wasm.signCancellationEthSignDigest(ptr0, len0, chainId, addHeapObject(digestSigner), isLikeNone(options) ? 0 : addHeapObject(options));
1262
+ return takeObject(ret);
1263
+ }
1264
+ exports.signCancellationEthSignDigest = signCancellationEthSignDigest;
1265
+
1266
+ /**
1267
+ * Signs cancellation typed data through an EIP-1193 callback.
1268
+ *
1269
+ * The callback receives an `eth_signTypedData_v4` request object. Use this
1270
+ * helper when an injected wallet or wallet client owns typed-data signing.
1271
+ *
1272
+ * @param orderUids One or more full order UIDs to cancel.
1273
+ * @param chainId EVM chain id used for the cancellation domain.
1274
+ * @param owner Owner address included in the EIP-1193 request parameters.
1275
+ * @param requestCallback Callback that executes the EIP-1193 request.
1276
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
1277
+ * @returns A versioned envelope containing signed cancellations.
1278
+ * @throws CowError for invalid input, wallet failure, timeout, or cancellation.
1279
+ * @param {string[]} orderUids
1280
+ * @param {number} chainId
1281
+ * @param {string} owner
1282
+ * @param {Eip1193RequestCallback} requestCallback
1283
+ * @param {SigningOptions | null} [options]
1284
+ * @returns {WasmEnvelope<SignedCancellationsInput>}
1285
+ */
1286
+ function signCancellationWithEip1193(orderUids, chainId, owner, requestCallback, options) {
1287
+ const ptr0 = passArrayJsValueToWasm0(orderUids, wasm.__wbindgen_export);
1288
+ const len0 = WASM_VECTOR_LEN;
1289
+ const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1290
+ const len1 = WASM_VECTOR_LEN;
1291
+ const ret = wasm.signCancellationWithEip1193(ptr0, len0, chainId, ptr1, len1, addHeapObject(requestCallback), isLikeNone(options) ? 0 : addHeapObject(options));
1292
+ return takeObject(ret);
1293
+ }
1294
+ exports.signCancellationWithEip1193 = signCancellationWithEip1193;
1295
+
1296
+ /**
1297
+ * Signs cancellation typed data through a typed-data callback.
1298
+ *
1299
+ * The SDK builds the batch cancellation EIP-712 payload for the provided order
1300
+ * UIDs and asks the callback to sign it. The response can be submitted through
1301
+ * `OrderBookClient.cancelOrders`.
1302
+ *
1303
+ * @param orderUids One or more full order UIDs to cancel.
1304
+ * @param chainId EVM chain id used for the cancellation domain.
1305
+ * @param typedDataSigner Callback that signs the typed-data envelope.
1306
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
1307
+ * @returns A versioned envelope containing signed cancellations.
1308
+ * @throws CowError for empty input, invalid UID, callback failure, or timeout.
1309
+ * @param {string[]} orderUids
1310
+ * @param {number} chainId
1311
+ * @param {TypedDataSignerCallback} typedDataSigner
1312
+ * @param {SigningOptions | null} [options]
1313
+ * @returns {WasmEnvelope<SignedCancellationsInput>}
1314
+ */
1315
+ function signCancellationWithTypedDataSigner(orderUids, chainId, typedDataSigner, options) {
1316
+ const ptr0 = passArrayJsValueToWasm0(orderUids, wasm.__wbindgen_export);
1317
+ const len0 = WASM_VECTOR_LEN;
1318
+ const ret = wasm.signCancellationWithTypedDataSigner(ptr0, len0, chainId, addHeapObject(typedDataSigner), isLikeNone(options) ? 0 : addHeapObject(options));
1319
+ return takeObject(ret);
1320
+ }
1321
+ exports.signCancellationWithTypedDataSigner = signCancellationWithTypedDataSigner;
1322
+
1323
+ /**
1324
+ * Signs an order digest through an explicit `eth_sign` callback.
1325
+ *
1326
+ * The SDK computes the canonical order digest, passes the digest as a
1327
+ * `0x`-prefixed string to the callback, normalizes the signature, and returns
1328
+ * an `ethsign` signed-order DTO.
1329
+ *
1330
+ * @param input Unsigned order fields to sign.
1331
+ * @param chainId EVM chain id used for the digest.
1332
+ * @param owner Owner address used in the generated order UID.
1333
+ * @param digestSigner Callback that signs the digest string.
1334
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
1335
+ * @returns A versioned envelope containing the signed order.
1336
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
1337
+ * @param {OrderInput} input
1338
+ * @param {number} chainId
1339
+ * @param {string} owner
1340
+ * @param {DigestSignerCallback} digestSigner
1341
+ * @param {SigningOptions | null} [options]
1342
+ * @returns {WasmEnvelope<SignedOrderDto>}
1343
+ */
1344
+ function signOrderEthSignDigest(input, chainId, owner, digestSigner, options) {
1345
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1346
+ const len0 = WASM_VECTOR_LEN;
1347
+ const ret = wasm.signOrderEthSignDigest(addHeapObject(input), chainId, ptr0, len0, addHeapObject(digestSigner), isLikeNone(options) ? 0 : addHeapObject(options));
1348
+ return takeObject(ret);
1349
+ }
1350
+ exports.signOrderEthSignDigest = signOrderEthSignDigest;
1351
+
1352
+ /**
1353
+ * Signs an order through a custom EIP-1271 callback.
1354
+ *
1355
+ * Use this method when the JavaScript host owns the smart-account or
1356
+ * account-abstraction client and can return the final contract signature
1357
+ * directly. The SDK still builds typed data and the deterministic order UID.
1358
+ *
1359
+ * @param input Unsigned order to sign.
1360
+ * @param chainId EVM chain id for the EIP-712 domain.
1361
+ * @param owner Smart-account owner address used in the generated order UID.
1362
+ * @param customCallback Callback that returns the final EIP-1271 signature.
1363
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
1364
+ * @returns A versioned envelope containing the signed-order DTO.
1365
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
1366
+ * @param {OrderInput} input
1367
+ * @param {number} chainId
1368
+ * @param {string} owner
1369
+ * @param {CustomEip1271Callback} customCallback
1370
+ * @param {SigningOptions | null} [options]
1371
+ * @returns {WasmEnvelope<SignedOrderDto>}
1372
+ */
1373
+ function signOrderWithCustomEip1271(input, chainId, owner, customCallback, options) {
1374
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1375
+ const len0 = WASM_VECTOR_LEN;
1376
+ const ret = wasm.signOrderWithCustomEip1271(addHeapObject(input), chainId, ptr0, len0, addHeapObject(customCallback), isLikeNone(options) ? 0 : addHeapObject(options));
1377
+ return takeObject(ret);
1378
+ }
1379
+ exports.signOrderWithCustomEip1271 = signOrderWithCustomEip1271;
1380
+
1381
+ /**
1382
+ * Signs an order through an EIP-1193 request callback.
1383
+ *
1384
+ * The callback receives an `eth_signTypedData_v4` request object with owner
1385
+ * address and serialized typed data. This is the bridge for injected wallets
1386
+ * and wallet-client libraries that expose an EIP-1193-style request function.
1387
+ *
1388
+ * @param input Unsigned order fields to sign.
1389
+ * @param chainId EVM chain id used for the EIP-712 domain.
1390
+ * @param owner Owner address used in the wallet request and order UID.
1391
+ * @param requestCallback Callback that executes the EIP-1193 request.
1392
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
1393
+ * @returns A versioned envelope containing the signed order.
1394
+ * @throws CowError for invalid input, wallet failure, timeout, or cancellation.
1395
+ * @param {OrderInput} input
1396
+ * @param {number} chainId
1397
+ * @param {string} owner
1398
+ * @param {Eip1193RequestCallback} requestCallback
1399
+ * @param {SigningOptions | null} [options]
1400
+ * @returns {WasmEnvelope<SignedOrderDto>}
1401
+ */
1402
+ function signOrderWithEip1193(input, chainId, owner, requestCallback, options) {
1403
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1404
+ const len0 = WASM_VECTOR_LEN;
1405
+ const ret = wasm.signOrderWithEip1193(addHeapObject(input), chainId, ptr0, len0, addHeapObject(requestCallback), isLikeNone(options) ? 0 : addHeapObject(options));
1406
+ return takeObject(ret);
1407
+ }
1408
+ exports.signOrderWithEip1193 = signOrderWithEip1193;
1409
+
1410
+ /**
1411
+ * Signs an order through typed-data ECDSA and wraps it as EIP-1271.
1412
+ *
1413
+ * The SDK sends the EIP-712 envelope to the provided typed-data callback,
1414
+ * then converts the returned ECDSA signature into the CoW EIP-1271 payload.
1415
+ * Per-call options may attach cancellation and wallet timeout settings.
1416
+ *
1417
+ * @param input Unsigned order to sign.
1418
+ * @param chainId EVM chain id for the EIP-712 domain.
1419
+ * @param owner Smart-account owner address used in the generated order UID.
1420
+ * @param typedDataSigner Callback that signs the typed-data envelope.
1421
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
1422
+ * @returns A versioned envelope containing the signed-order DTO.
1423
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
1424
+ * @param {OrderInput} input
1425
+ * @param {number} chainId
1426
+ * @param {string} owner
1427
+ * @param {TypedDataSignerCallback} typedDataSigner
1428
+ * @param {SigningOptions | null} [options]
1429
+ * @returns {WasmEnvelope<SignedOrderDto>}
1430
+ */
1431
+ function signOrderWithEip1271(input, chainId, owner, typedDataSigner, options) {
1432
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1433
+ const len0 = WASM_VECTOR_LEN;
1434
+ const ret = wasm.signOrderWithEip1271(addHeapObject(input), chainId, ptr0, len0, addHeapObject(typedDataSigner), isLikeNone(options) ? 0 : addHeapObject(options));
1435
+ return takeObject(ret);
1436
+ }
1437
+ exports.signOrderWithEip1271 = signOrderWithEip1271;
1438
+
1439
+ /**
1440
+ * Signs an order through a typed-data callback.
1441
+ *
1442
+ * The SDK builds the EIP-712 typed-data envelope, passes it to the callback,
1443
+ * normalizes the returned ECDSA signature, and returns the signed-order DTO
1444
+ * with the canonical order UID and digest.
1445
+ *
1446
+ * @param input Unsigned order fields to sign.
1447
+ * @param chainId EVM chain id used for the EIP-712 domain.
1448
+ * @param owner Owner address used in the generated order UID.
1449
+ * @param typedDataSigner Callback that signs the typed-data envelope.
1450
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
1451
+ * @returns A versioned envelope containing the signed order.
1452
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
1453
+ * @param {OrderInput} input
1454
+ * @param {number} chainId
1455
+ * @param {string} owner
1456
+ * @param {TypedDataSignerCallback} typedDataSigner
1457
+ * @param {SigningOptions | null} [options]
1458
+ * @returns {WasmEnvelope<SignedOrderDto>}
1459
+ */
1460
+ function signOrderWithTypedDataSigner(input, chainId, owner, typedDataSigner, options) {
1461
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1462
+ const len0 = WASM_VECTOR_LEN;
1463
+ const ret = wasm.signOrderWithTypedDataSigner(addHeapObject(input), chainId, ptr0, len0, addHeapObject(typedDataSigner), isLikeNone(options) ? 0 : addHeapObject(options));
1464
+ return takeObject(ret);
1465
+ }
1466
+ exports.signOrderWithTypedDataSigner = signOrderWithTypedDataSigner;
1467
+
1468
+ /**
1469
+ * Returns the EVM chain ids supported by the SDK deployment registry.
1470
+ *
1471
+ * This is a pure helper and does not perform network I/O. The returned list is
1472
+ * suitable for runtime validation, UI selection, or capability checks before a
1473
+ * client is constructed.
1474
+ *
1475
+ * @returns A typed array of supported EVM chain ids.
1476
+ * @returns {Uint32Array}
1477
+ */
1478
+ function supportedChainIds() {
1479
+ try {
1480
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1481
+ wasm.supportedChainIds(retptr);
1482
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1483
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1484
+ var v1 = getArrayU32FromWasm0(r0, r1).slice();
1485
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
1486
+ return v1;
1487
+ } finally {
1488
+ wasm.__wbindgen_add_to_stack_pointer(16);
1489
+ }
1490
+ }
1491
+ exports.supportedChainIds = supportedChainIds;
1492
+
1493
+ /**
1494
+ * Validates an app-data document against the typed metadata contract.
1495
+ *
1496
+ * Validation is local and deterministic. The result reports whether the
1497
+ * document conforms and includes validation details without uploading data.
1498
+ *
1499
+ * @param doc App-data document input to validate.
1500
+ * @returns A versioned envelope containing the validation result.
1501
+ * @throws CowError when the input cannot be converted into a document.
1502
+ * @param {AppDataDocInput} doc
1503
+ * @returns {WasmEnvelope<ValidationResultDto>}
1504
+ */
1505
+ function validateAppDataDoc(doc) {
1506
+ try {
1507
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1508
+ wasm.validateAppDataDoc(retptr, addHeapObject(doc));
1509
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1510
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1511
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1512
+ if (r2) {
1513
+ throw takeObject(r1);
1514
+ }
1515
+ return takeObject(r0);
1516
+ } finally {
1517
+ wasm.__wbindgen_add_to_stack_pointer(16);
1518
+ }
1519
+ }
1520
+ exports.validateAppDataDoc = validateAppDataDoc;
1521
+
1522
+ /**
1523
+ * Returns the version of the wasm package runtime.
1524
+ *
1525
+ * The value comes from the Rust package metadata used to build the wasm
1526
+ * artifact and can be included in diagnostics or compatibility checks.
1527
+ *
1528
+ * @returns The semantic version string for this wasm build.
1529
+ * @returns {string}
1530
+ */
1531
+ function wasmVersion() {
1532
+ let deferred1_0;
1533
+ let deferred1_1;
1534
+ try {
1535
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1536
+ wasm.wasmVersion(retptr);
1537
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1538
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1539
+ deferred1_0 = r0;
1540
+ deferred1_1 = r1;
1541
+ return getStringFromWasm0(r0, r1);
1542
+ } finally {
1543
+ wasm.__wbindgen_add_to_stack_pointer(16);
1544
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1545
+ }
1546
+ }
1547
+ exports.wasmVersion = wasmVersion;
1548
+ function __wbg_get_imports() {
1549
+ const import0 = {
1550
+ __proto__: null,
1551
+ __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
1552
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1553
+ return addHeapObject(ret);
1554
+ },
1555
+ __wbg_Number_c4bdf66bb78f7977: function(arg0) {
1556
+ const ret = Number(getObject(arg0));
1557
+ return ret;
1558
+ },
1559
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
1560
+ const ret = String(getObject(arg1));
1561
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1562
+ const len1 = WASM_VECTOR_LEN;
1563
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1564
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1565
+ },
1566
+ __wbg___wbindgen_bigint_get_as_i64_d9e915702856f831: function(arg0, arg1) {
1567
+ const v = getObject(arg1);
1568
+ const ret = typeof(v) === 'bigint' ? v : undefined;
1569
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1570
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1571
+ },
1572
+ __wbg___wbindgen_boolean_get_edaed31a367ce1bd: function(arg0) {
1573
+ const v = getObject(arg0);
1574
+ const ret = typeof(v) === 'boolean' ? v : undefined;
1575
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1576
+ },
1577
+ __wbg___wbindgen_debug_string_8a447059637473e2: function(arg0, arg1) {
1578
+ const ret = debugString(getObject(arg1));
1579
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1580
+ const len1 = WASM_VECTOR_LEN;
1581
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1582
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1583
+ },
1584
+ __wbg___wbindgen_in_4990f46af709e33c: function(arg0, arg1) {
1585
+ const ret = getObject(arg0) in getObject(arg1);
1586
+ return ret;
1587
+ },
1588
+ __wbg___wbindgen_is_bigint_90b5ccfe67c78460: function(arg0) {
1589
+ const ret = typeof(getObject(arg0)) === 'bigint';
1590
+ return ret;
1591
+ },
1592
+ __wbg___wbindgen_is_function_acc5528be2b923f2: function(arg0) {
1593
+ const ret = typeof(getObject(arg0)) === 'function';
1594
+ return ret;
1595
+ },
1596
+ __wbg___wbindgen_is_null_6d937fbfb6478470: function(arg0) {
1597
+ const ret = getObject(arg0) === null;
1598
+ return ret;
1599
+ },
1600
+ __wbg___wbindgen_is_object_0beba4a1980d3eea: function(arg0) {
1601
+ const val = getObject(arg0);
1602
+ const ret = typeof(val) === 'object' && val !== null;
1603
+ return ret;
1604
+ },
1605
+ __wbg___wbindgen_is_string_1fca8072260dd261: function(arg0) {
1606
+ const ret = typeof(getObject(arg0)) === 'string';
1607
+ return ret;
1608
+ },
1609
+ __wbg___wbindgen_is_undefined_721f8decd50c87a3: function(arg0) {
1610
+ const ret = getObject(arg0) === undefined;
1611
+ return ret;
1612
+ },
1613
+ __wbg___wbindgen_jsval_eq_4e8c38722cb8ff51: function(arg0, arg1) {
1614
+ const ret = getObject(arg0) === getObject(arg1);
1615
+ return ret;
1616
+ },
1617
+ __wbg___wbindgen_jsval_loose_eq_4b9aba9e5b3c4582: function(arg0, arg1) {
1618
+ const ret = getObject(arg0) == getObject(arg1);
1619
+ return ret;
1620
+ },
1621
+ __wbg___wbindgen_number_get_1cc01dd708740256: function(arg0, arg1) {
1622
+ const obj = getObject(arg1);
1623
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1624
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1625
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1626
+ },
1627
+ __wbg___wbindgen_string_get_71bb4348194e31f0: function(arg0, arg1) {
1628
+ const obj = getObject(arg1);
1629
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1630
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1631
+ var len1 = WASM_VECTOR_LEN;
1632
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1633
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1634
+ },
1635
+ __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
1636
+ throw new Error(getStringFromWasm0(arg0, arg1));
1637
+ },
1638
+ __wbg__wbg_cb_unref_33c39e13d73b25f6: function(arg0) {
1639
+ getObject(arg0)._wbg_cb_unref();
1640
+ },
1641
+ __wbg_abort_413b060ce2cedffd: function(arg0) {
1642
+ getObject(arg0).abort();
1643
+ },
1644
+ __wbg_abort_6e6ea7d259504afc: function(arg0) {
1645
+ getObject(arg0).abort();
1646
+ },
1647
+ __wbg_aborted_4d4114700dc4c251: function(arg0) {
1648
+ const ret = getObject(arg0).aborted;
1649
+ return ret;
1650
+ },
1651
+ __wbg_addEventListener_ea90bc131475777e: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1652
+ getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
1653
+ }, arguments); },
1654
+ __wbg_call_5575218572ead796: function() { return handleError(function (arg0, arg1, arg2) {
1655
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1656
+ return addHeapObject(ret);
1657
+ }, arguments); },
1658
+ __wbg_call_8e98ed2f3c86c4b5: function() { return handleError(function (arg0, arg1) {
1659
+ const ret = getObject(arg0).call(getObject(arg1));
1660
+ return addHeapObject(ret);
1661
+ }, arguments); },
1662
+ __wbg_clearTimeout_323d72e2c87b37b4: function(arg0) {
1663
+ globalThis.clearTimeout(getObject(arg0));
1664
+ },
1665
+ __wbg_clearTimeout_3629d6209dfcc46e: function(arg0) {
1666
+ const ret = clearTimeout(takeObject(arg0));
1667
+ return addHeapObject(ret);
1668
+ },
1669
+ __wbg_done_b62d4a7d2286852a: function(arg0) {
1670
+ const ret = getObject(arg0).done;
1671
+ return ret;
1672
+ },
1673
+ __wbg_entries_c261c3fa1f281256: function(arg0) {
1674
+ const ret = Object.entries(getObject(arg0));
1675
+ return addHeapObject(ret);
1676
+ },
1677
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
1678
+ let deferred0_0;
1679
+ let deferred0_1;
1680
+ try {
1681
+ deferred0_0 = arg0;
1682
+ deferred0_1 = arg1;
1683
+ console.error(getStringFromWasm0(arg0, arg1));
1684
+ } finally {
1685
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
1686
+ }
1687
+ },
1688
+ __wbg_from_50138b2ca136f50c: function(arg0) {
1689
+ const ret = Array.from(getObject(arg0));
1690
+ return addHeapObject(ret);
1691
+ },
1692
+ __wbg_get_197a3fe98f169e38: function(arg0, arg1) {
1693
+ const ret = getObject(arg0)[arg1 >>> 0];
1694
+ return addHeapObject(ret);
1695
+ },
1696
+ __wbg_get_9a29be2cb383ed9a: function() { return handleError(function (arg0, arg1) {
1697
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
1698
+ return addHeapObject(ret);
1699
+ }, arguments); },
1700
+ __wbg_get_dddb90ff5d27a080: function() { return handleError(function (arg0, arg1) {
1701
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
1702
+ return addHeapObject(ret);
1703
+ }, arguments); },
1704
+ __wbg_get_unchecked_54a4374c38e08460: function(arg0, arg1) {
1705
+ const ret = getObject(arg0)[arg1 >>> 0];
1706
+ return addHeapObject(ret);
1707
+ },
1708
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
1709
+ const ret = getObject(arg0)[getObject(arg1)];
1710
+ return addHeapObject(ret);
1711
+ },
1712
+ __wbg_headers_d9123c649c85d441: function(arg0) {
1713
+ const ret = getObject(arg0).headers;
1714
+ return addHeapObject(ret);
1715
+ },
1716
+ __wbg_instanceof_AbortSignal_4bebac9f7add3026: function(arg0) {
1717
+ let result;
1718
+ try {
1719
+ result = getObject(arg0) instanceof AbortSignal;
1720
+ } catch (_) {
1721
+ result = false;
1722
+ }
1723
+ const ret = result;
1724
+ return ret;
1725
+ },
1726
+ __wbg_instanceof_ArrayBuffer_2a7bb09fee70c2da: function(arg0) {
1727
+ let result;
1728
+ try {
1729
+ result = getObject(arg0) instanceof ArrayBuffer;
1730
+ } catch (_) {
1731
+ result = false;
1732
+ }
1733
+ const ret = result;
1734
+ return ret;
1735
+ },
1736
+ __wbg_instanceof_Map_afa18d5840c04c15: function(arg0) {
1737
+ let result;
1738
+ try {
1739
+ result = getObject(arg0) instanceof Map;
1740
+ } catch (_) {
1741
+ result = false;
1742
+ }
1743
+ const ret = result;
1744
+ return ret;
1745
+ },
1746
+ __wbg_instanceof_Object_60be3eaa7a661141: function(arg0) {
1747
+ let result;
1748
+ try {
1749
+ result = getObject(arg0) instanceof Object;
1750
+ } catch (_) {
1751
+ result = false;
1752
+ }
1753
+ const ret = result;
1754
+ return ret;
1755
+ },
1756
+ __wbg_instanceof_Response_79948c98d1d2ba75: function(arg0) {
1757
+ let result;
1758
+ try {
1759
+ result = getObject(arg0) instanceof Response;
1760
+ } catch (_) {
1761
+ result = false;
1762
+ }
1763
+ const ret = result;
1764
+ return ret;
1765
+ },
1766
+ __wbg_instanceof_Uint8Array_f080092dc70f5d58: function(arg0) {
1767
+ let result;
1768
+ try {
1769
+ result = getObject(arg0) instanceof Uint8Array;
1770
+ } catch (_) {
1771
+ result = false;
1772
+ }
1773
+ const ret = result;
1774
+ return ret;
1775
+ },
1776
+ __wbg_isArray_145a34fd0a38d37b: function(arg0) {
1777
+ const ret = Array.isArray(getObject(arg0));
1778
+ return ret;
1779
+ },
1780
+ __wbg_isSafeInteger_a3389a198582f5f6: function(arg0) {
1781
+ const ret = Number.isSafeInteger(getObject(arg0));
1782
+ return ret;
1783
+ },
1784
+ __wbg_iterator_cc47ba25a2be735a: function() {
1785
+ const ret = Symbol.iterator;
1786
+ return addHeapObject(ret);
1787
+ },
1788
+ __wbg_length_589238bdcf171f0e: function(arg0) {
1789
+ const ret = getObject(arg0).length;
1790
+ return ret;
1791
+ },
1792
+ __wbg_length_c6054974c0a6cdb9: function(arg0) {
1793
+ const ret = getObject(arg0).length;
1794
+ return ret;
1795
+ },
1796
+ __wbg_new_0d0108049d844421: function() {
1797
+ const ret = new globalThis.AbortController();
1798
+ return addHeapObject(ret);
1799
+ },
1800
+ __wbg_new_10e2f2ad134f940f: function() { return handleError(function () {
1801
+ const ret = new Headers();
1802
+ return addHeapObject(ret);
1803
+ }, arguments); },
1804
+ __wbg_new_227d7c05414eb861: function() {
1805
+ const ret = new Error();
1806
+ return addHeapObject(ret);
1807
+ },
1808
+ __wbg_new_2e117a478906f062: function() {
1809
+ const ret = new Object();
1810
+ return addHeapObject(ret);
1811
+ },
1812
+ __wbg_new_3444eb7412549f0b: function() {
1813
+ const ret = new Map();
1814
+ return addHeapObject(ret);
1815
+ },
1816
+ __wbg_new_36e147a8ced3c6e0: function() {
1817
+ const ret = new Array();
1818
+ return addHeapObject(ret);
1819
+ },
1820
+ __wbg_new_51233fa2a760b272: function() { return handleError(function () {
1821
+ const ret = new AbortController();
1822
+ return addHeapObject(ret);
1823
+ }, arguments); },
1824
+ __wbg_new_81880fb5002cb255: function(arg0) {
1825
+ const ret = new Uint8Array(getObject(arg0));
1826
+ return addHeapObject(ret);
1827
+ },
1828
+ __wbg_new_f85beb941dc6d8aa: function(arg0, arg1) {
1829
+ try {
1830
+ var state0 = {a: arg0, b: arg1};
1831
+ var cb0 = (arg0, arg1) => {
1832
+ const a = state0.a;
1833
+ state0.a = 0;
1834
+ try {
1835
+ return __wasm_bindgen_func_elem_6489(a, state0.b, arg0, arg1);
1836
+ } finally {
1837
+ state0.a = a;
1838
+ }
1839
+ };
1840
+ const ret = new Promise(cb0);
1841
+ return addHeapObject(ret);
1842
+ } finally {
1843
+ state0.a = 0;
1844
+ }
1845
+ },
1846
+ __wbg_new_typed_00a409eb4ec4f2d9: function(arg0, arg1) {
1847
+ try {
1848
+ var state0 = {a: arg0, b: arg1};
1849
+ var cb0 = (arg0, arg1) => {
1850
+ const a = state0.a;
1851
+ state0.a = 0;
1852
+ try {
1853
+ return __wasm_bindgen_func_elem_6489(a, state0.b, arg0, arg1);
1854
+ } finally {
1855
+ state0.a = a;
1856
+ }
1857
+ };
1858
+ const ret = new Promise(cb0);
1859
+ return addHeapObject(ret);
1860
+ } finally {
1861
+ state0.a = 0;
1862
+ }
1863
+ },
1864
+ __wbg_new_with_str_and_init_5b299538bdeeec64: function() { return handleError(function (arg0, arg1, arg2) {
1865
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
1866
+ return addHeapObject(ret);
1867
+ }, arguments); },
1868
+ __wbg_next_0c4066e251d2eff9: function() { return handleError(function (arg0) {
1869
+ const ret = getObject(arg0).next();
1870
+ return addHeapObject(ret);
1871
+ }, arguments); },
1872
+ __wbg_next_402fa10b59ab20c3: function(arg0) {
1873
+ const ret = getObject(arg0).next;
1874
+ return addHeapObject(ret);
1875
+ },
1876
+ __wbg_now_d2e0afbad4edbe82: function() {
1877
+ const ret = Date.now();
1878
+ return ret;
1879
+ },
1880
+ __wbg_now_e7c6795a7f81e10f: function(arg0) {
1881
+ const ret = getObject(arg0).now();
1882
+ return ret;
1883
+ },
1884
+ __wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
1885
+ const ret = getObject(arg0).performance;
1886
+ return addHeapObject(ret);
1887
+ },
1888
+ __wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
1889
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1890
+ },
1891
+ __wbg_push_f724b5db8acf89d2: function(arg0, arg1) {
1892
+ const ret = getObject(arg0).push(getObject(arg1));
1893
+ return ret;
1894
+ },
1895
+ __wbg_queueMicrotask_1c9b3800e321a967: function(arg0) {
1896
+ const ret = getObject(arg0).queueMicrotask;
1897
+ return addHeapObject(ret);
1898
+ },
1899
+ __wbg_queueMicrotask_311744e534a929a3: function(arg0) {
1900
+ queueMicrotask(getObject(arg0));
1901
+ },
1902
+ __wbg_race_27bed3574f107c6d: function(arg0) {
1903
+ const ret = Promise.race(getObject(arg0));
1904
+ return addHeapObject(ret);
1905
+ },
1906
+ __wbg_removeEventListener_c6782a9c30557d31: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1907
+ getObject(arg0).removeEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
1908
+ }, arguments); },
1909
+ __wbg_resolve_d82363d90af6928a: function(arg0) {
1910
+ const ret = Promise.resolve(getObject(arg0));
1911
+ return addHeapObject(ret);
1912
+ },
1913
+ __wbg_setTimeout_56bcdccbad22fd44: function() { return handleError(function (arg0, arg1) {
1914
+ const ret = setTimeout(getObject(arg0), arg1);
1915
+ return addHeapObject(ret);
1916
+ }, arguments); },
1917
+ __wbg_setTimeout_63c2e8b855bb48ad: function(arg0, arg1) {
1918
+ const ret = globalThis.setTimeout(getObject(arg0), arg1 >>> 0);
1919
+ return addHeapObject(ret);
1920
+ },
1921
+ __wbg_set_1c87dcfd4a93c514: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1922
+ getObject(arg0).set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
1923
+ }, arguments); },
1924
+ __wbg_set_4564f7dc44fcb0c9: function() { return handleError(function (arg0, arg1, arg2) {
1925
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1926
+ return ret;
1927
+ }, arguments); },
1928
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
1929
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1930
+ },
1931
+ __wbg_set_9a1d61e17de7054c: function(arg0, arg1, arg2) {
1932
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
1933
+ return addHeapObject(ret);
1934
+ },
1935
+ __wbg_set_body_97c25d1c0051cb04: function(arg0, arg1) {
1936
+ getObject(arg0).body = getObject(arg1);
1937
+ },
1938
+ __wbg_set_dc601f4a69da0bc2: function(arg0, arg1, arg2) {
1939
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1940
+ },
1941
+ __wbg_set_headers_6751c09a8e579ff7: function(arg0, arg1) {
1942
+ getObject(arg0).headers = getObject(arg1);
1943
+ },
1944
+ __wbg_set_method_1120482abe0934aa: function(arg0, arg1, arg2) {
1945
+ getObject(arg0).method = getStringFromWasm0(arg1, arg2);
1946
+ },
1947
+ __wbg_set_signal_4a69430cb12800f3: function(arg0, arg1) {
1948
+ getObject(arg0).signal = getObject(arg1);
1949
+ },
1950
+ __wbg_signal_4c9d3f39f4095986: function(arg0) {
1951
+ const ret = getObject(arg0).signal;
1952
+ return addHeapObject(ret);
1953
+ },
1954
+ __wbg_signal_4d9d567be73ea52c: function(arg0) {
1955
+ const ret = getObject(arg0).signal;
1956
+ return addHeapObject(ret);
1957
+ },
1958
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
1959
+ const ret = getObject(arg1).stack;
1960
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1961
+ const len1 = WASM_VECTOR_LEN;
1962
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1963
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1964
+ },
1965
+ __wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938: function() {
1966
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1967
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1968
+ },
1969
+ __wbg_static_accessor_GLOBAL_ce44e66a4935da8c: function() {
1970
+ const ret = typeof global === 'undefined' ? null : global;
1971
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1972
+ },
1973
+ __wbg_static_accessor_SELF_44f6e0cb5e67cdad: function() {
1974
+ const ret = typeof self === 'undefined' ? null : self;
1975
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1976
+ },
1977
+ __wbg_static_accessor_WINDOW_168f178805d978fe: function() {
1978
+ const ret = typeof window === 'undefined' ? null : window;
1979
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1980
+ },
1981
+ __wbg_status_0053aa6239760447: function(arg0) {
1982
+ const ret = getObject(arg0).status;
1983
+ return ret;
1984
+ },
1985
+ __wbg_text_68ea00f7126f2706: function() { return handleError(function (arg0) {
1986
+ const ret = getObject(arg0).text();
1987
+ return addHeapObject(ret);
1988
+ }, arguments); },
1989
+ __wbg_then_05edfc8a4fea5106: function(arg0, arg1, arg2) {
1990
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
1991
+ return addHeapObject(ret);
1992
+ },
1993
+ __wbg_then_591b6b3a75ee817a: function(arg0, arg1) {
1994
+ const ret = getObject(arg0).then(getObject(arg1));
1995
+ return addHeapObject(ret);
1996
+ },
1997
+ __wbg_value_49f783bb59765962: function(arg0) {
1998
+ const ret = getObject(arg0).value;
1999
+ return addHeapObject(ret);
2000
+ },
2001
+ __wbg_warn_cd671287bc02594a: function(arg0) {
2002
+ console.warn(getObject(arg0));
2003
+ },
2004
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2005
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 635, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2006
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_6480);
2007
+ return addHeapObject(ret);
2008
+ },
2009
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2010
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 627, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2011
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_6400);
2012
+ return addHeapObject(ret);
2013
+ },
2014
+ __wbindgen_cast_0000000000000003: function(arg0) {
2015
+ // Cast intrinsic for `F64 -> Externref`.
2016
+ const ret = arg0;
2017
+ return addHeapObject(ret);
2018
+ },
2019
+ __wbindgen_cast_0000000000000004: function(arg0) {
2020
+ // Cast intrinsic for `I64 -> Externref`.
2021
+ const ret = arg0;
2022
+ return addHeapObject(ret);
2023
+ },
2024
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
2025
+ // Cast intrinsic for `Ref(String) -> Externref`.
2026
+ const ret = getStringFromWasm0(arg0, arg1);
2027
+ return addHeapObject(ret);
2028
+ },
2029
+ __wbindgen_cast_0000000000000006: function(arg0) {
2030
+ // Cast intrinsic for `U64 -> Externref`.
2031
+ const ret = BigInt.asUintN(64, arg0);
2032
+ return addHeapObject(ret);
2033
+ },
2034
+ __wbindgen_object_clone_ref: function(arg0) {
2035
+ const ret = getObject(arg0);
2036
+ return addHeapObject(ret);
2037
+ },
2038
+ __wbindgen_object_drop_ref: function(arg0) {
2039
+ takeObject(arg0);
2040
+ },
2041
+ };
2042
+ return {
2043
+ __proto__: null,
2044
+ "./cow_sdk_wasm_bg.js": import0,
2045
+ };
2046
+ }
2047
+
2048
+ function __wasm_bindgen_func_elem_6400(arg0, arg1) {
2049
+ wasm.__wasm_bindgen_func_elem_6400(arg0, arg1);
2050
+ }
2051
+
2052
+ function __wasm_bindgen_func_elem_6480(arg0, arg1, arg2) {
2053
+ try {
2054
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2055
+ wasm.__wasm_bindgen_func_elem_6480(retptr, arg0, arg1, addHeapObject(arg2));
2056
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2057
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2058
+ if (r1) {
2059
+ throw takeObject(r0);
2060
+ }
2061
+ } finally {
2062
+ wasm.__wbindgen_add_to_stack_pointer(16);
2063
+ }
2064
+ }
2065
+
2066
+ function __wasm_bindgen_func_elem_6489(arg0, arg1, arg2, arg3) {
2067
+ wasm.__wasm_bindgen_func_elem_6489(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2068
+ }
2069
+
2070
+ const IpfsClientFinalization = (typeof FinalizationRegistry === 'undefined')
2071
+ ? { register: () => {}, unregister: () => {} }
2072
+ : new FinalizationRegistry(ptr => wasm.__wbg_ipfsclient_free(ptr, 1));
2073
+ const OrderBookClientFinalization = (typeof FinalizationRegistry === 'undefined')
2074
+ ? { register: () => {}, unregister: () => {} }
2075
+ : new FinalizationRegistry(ptr => wasm.__wbg_orderbookclient_free(ptr, 1));
2076
+ const SubgraphClientFinalization = (typeof FinalizationRegistry === 'undefined')
2077
+ ? { register: () => {}, unregister: () => {} }
2078
+ : new FinalizationRegistry(ptr => wasm.__wbg_subgraphclient_free(ptr, 1));
2079
+ const TradingClientFinalization = (typeof FinalizationRegistry === 'undefined')
2080
+ ? { register: () => {}, unregister: () => {} }
2081
+ : new FinalizationRegistry(ptr => wasm.__wbg_tradingclient_free(ptr, 1));
2082
+
2083
+ function addHeapObject(obj) {
2084
+ if (heap_next === heap.length) heap.push(heap.length + 1);
2085
+ const idx = heap_next;
2086
+ heap_next = heap[idx];
2087
+
2088
+ heap[idx] = obj;
2089
+ return idx;
2090
+ }
2091
+
2092
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
2093
+ ? { register: () => {}, unregister: () => {} }
2094
+ : new FinalizationRegistry(state => wasm.__wbindgen_export5(state.a, state.b));
2095
+
2096
+ function debugString(val) {
2097
+ // primitive types
2098
+ const type = typeof val;
2099
+ if (type == 'number' || type == 'boolean' || val == null) {
2100
+ return `${val}`;
2101
+ }
2102
+ if (type == 'string') {
2103
+ return `"${val}"`;
2104
+ }
2105
+ if (type == 'symbol') {
2106
+ const description = val.description;
2107
+ if (description == null) {
2108
+ return 'Symbol';
2109
+ } else {
2110
+ return `Symbol(${description})`;
2111
+ }
2112
+ }
2113
+ if (type == 'function') {
2114
+ const name = val.name;
2115
+ if (typeof name == 'string' && name.length > 0) {
2116
+ return `Function(${name})`;
2117
+ } else {
2118
+ return 'Function';
2119
+ }
2120
+ }
2121
+ // objects
2122
+ if (Array.isArray(val)) {
2123
+ const length = val.length;
2124
+ let debug = '[';
2125
+ if (length > 0) {
2126
+ debug += debugString(val[0]);
2127
+ }
2128
+ for(let i = 1; i < length; i++) {
2129
+ debug += ', ' + debugString(val[i]);
2130
+ }
2131
+ debug += ']';
2132
+ return debug;
2133
+ }
2134
+ // Test for built-in
2135
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2136
+ let className;
2137
+ if (builtInMatches && builtInMatches.length > 1) {
2138
+ className = builtInMatches[1];
2139
+ } else {
2140
+ // Failed to match the standard '[object ClassName]'
2141
+ return toString.call(val);
2142
+ }
2143
+ if (className == 'Object') {
2144
+ // we're a user defined class or Object
2145
+ // JSON.stringify avoids problems with cycles, and is generally much
2146
+ // easier than looping through ownProperties of `val`.
2147
+ try {
2148
+ return 'Object(' + JSON.stringify(val) + ')';
2149
+ } catch (_) {
2150
+ return 'Object';
2151
+ }
2152
+ }
2153
+ // errors
2154
+ if (val instanceof Error) {
2155
+ return `${val.name}: ${val.message}\n${val.stack}`;
2156
+ }
2157
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2158
+ return className;
2159
+ }
2160
+
2161
+ function dropObject(idx) {
2162
+ if (idx < 1028) return;
2163
+ heap[idx] = heap_next;
2164
+ heap_next = idx;
2165
+ }
2166
+
2167
+ function getArrayU32FromWasm0(ptr, len) {
2168
+ ptr = ptr >>> 0;
2169
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
2170
+ }
2171
+
2172
+ function getArrayU8FromWasm0(ptr, len) {
2173
+ ptr = ptr >>> 0;
2174
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2175
+ }
2176
+
2177
+ let cachedDataViewMemory0 = null;
2178
+ function getDataViewMemory0() {
2179
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2180
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2181
+ }
2182
+ return cachedDataViewMemory0;
2183
+ }
2184
+
2185
+ function getStringFromWasm0(ptr, len) {
2186
+ return decodeText(ptr >>> 0, len);
2187
+ }
2188
+
2189
+ let cachedUint32ArrayMemory0 = null;
2190
+ function getUint32ArrayMemory0() {
2191
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
2192
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
2193
+ }
2194
+ return cachedUint32ArrayMemory0;
2195
+ }
2196
+
2197
+ let cachedUint8ArrayMemory0 = null;
2198
+ function getUint8ArrayMemory0() {
2199
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2200
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2201
+ }
2202
+ return cachedUint8ArrayMemory0;
2203
+ }
2204
+
2205
+ function getObject(idx) { return heap[idx]; }
2206
+
2207
+ function handleError(f, args) {
2208
+ try {
2209
+ return f.apply(this, args);
2210
+ } catch (e) {
2211
+ wasm.__wbindgen_export3(addHeapObject(e));
2212
+ }
2213
+ }
2214
+
2215
+ let heap = new Array(1024).fill(undefined);
2216
+ heap.push(undefined, null, true, false);
2217
+
2218
+ let heap_next = heap.length;
2219
+
2220
+ function isLikeNone(x) {
2221
+ return x === undefined || x === null;
2222
+ }
2223
+
2224
+ function makeMutClosure(arg0, arg1, f) {
2225
+ const state = { a: arg0, b: arg1, cnt: 1 };
2226
+ const real = (...args) => {
2227
+
2228
+ // First up with a closure we increment the internal reference
2229
+ // count. This ensures that the Rust closure environment won't
2230
+ // be deallocated while we're invoking it.
2231
+ state.cnt++;
2232
+ const a = state.a;
2233
+ state.a = 0;
2234
+ try {
2235
+ return f(a, state.b, ...args);
2236
+ } finally {
2237
+ state.a = a;
2238
+ real._wbg_cb_unref();
2239
+ }
2240
+ };
2241
+ real._wbg_cb_unref = () => {
2242
+ if (--state.cnt === 0) {
2243
+ wasm.__wbindgen_export5(state.a, state.b);
2244
+ state.a = 0;
2245
+ CLOSURE_DTORS.unregister(state);
2246
+ }
2247
+ };
2248
+ CLOSURE_DTORS.register(real, state, state);
2249
+ return real;
2250
+ }
2251
+
2252
+ function passArrayJsValueToWasm0(array, malloc) {
2253
+ const ptr = malloc(array.length * 4, 4) >>> 0;
2254
+ const mem = getDataViewMemory0();
2255
+ for (let i = 0; i < array.length; i++) {
2256
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
2257
+ }
2258
+ WASM_VECTOR_LEN = array.length;
2259
+ return ptr;
2260
+ }
2261
+
2262
+ function passStringToWasm0(arg, malloc, realloc) {
2263
+ if (realloc === undefined) {
2264
+ const buf = cachedTextEncoder.encode(arg);
2265
+ const ptr = malloc(buf.length, 1) >>> 0;
2266
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2267
+ WASM_VECTOR_LEN = buf.length;
2268
+ return ptr;
2269
+ }
2270
+
2271
+ let len = arg.length;
2272
+ let ptr = malloc(len, 1) >>> 0;
2273
+
2274
+ const mem = getUint8ArrayMemory0();
2275
+
2276
+ let offset = 0;
2277
+
2278
+ for (; offset < len; offset++) {
2279
+ const code = arg.charCodeAt(offset);
2280
+ if (code > 0x7F) break;
2281
+ mem[ptr + offset] = code;
2282
+ }
2283
+ if (offset !== len) {
2284
+ if (offset !== 0) {
2285
+ arg = arg.slice(offset);
2286
+ }
2287
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2288
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2289
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2290
+
2291
+ offset += ret.written;
2292
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2293
+ }
2294
+
2295
+ WASM_VECTOR_LEN = offset;
2296
+ return ptr;
2297
+ }
2298
+
2299
+ function takeObject(idx) {
2300
+ const ret = getObject(idx);
2301
+ dropObject(idx);
2302
+ return ret;
2303
+ }
2304
+
2305
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2306
+ cachedTextDecoder.decode();
2307
+ function decodeText(ptr, len) {
2308
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2309
+ }
2310
+
2311
+ const cachedTextEncoder = new TextEncoder();
2312
+
2313
+ if (!('encodeInto' in cachedTextEncoder)) {
2314
+ cachedTextEncoder.encodeInto = function (arg, view) {
2315
+ const buf = cachedTextEncoder.encode(arg);
2316
+ view.set(buf);
2317
+ return {
2318
+ read: arg.length,
2319
+ written: buf.length
2320
+ };
2321
+ };
2322
+ }
2323
+
2324
+ let WASM_VECTOR_LEN = 0;
2325
+
2326
+ const wasmPath = `${__dirname}/../default-bundler/cow_sdk_wasm_bg.wasm`;
2327
+ const wasmBytes = require('fs').readFileSync(wasmPath);
2328
+ const wasmModule = new WebAssembly.Module(wasmBytes);
2329
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
2330
+ let wasm = wasmInstance.exports;