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