@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,1059 @@
1
+ /**
2
+ * Initializes the wasm crate's panic hook once.
3
+ */
4
+ export function __cow_sdk_wasm_init() {
5
+ wasm.__cow_sdk_wasm_init();
6
+ }
7
+
8
+ /**
9
+ * Computes the canonical order UID and order digest for an unsigned order.
10
+ *
11
+ * The UID combines the EIP-712 order digest, owner address, and validity
12
+ * timestamp using the same packing rules as the native Rust SDK.
13
+ *
14
+ * @param input Unsigned order fields to hash and pack.
15
+ * @param chainId EVM chain id used for the EIP-712 domain.
16
+ * @param owner Order owner address included in the UID suffix.
17
+ * @returns A versioned envelope with `orderUid` and `orderDigest`.
18
+ * @throws CowError when the order, owner, or chain id is invalid.
19
+ * @param {OrderInput} input
20
+ * @param {number} chainId
21
+ * @param {string} owner
22
+ * @returns {WasmEnvelope<GeneratedOrderUidDto>}
23
+ */
24
+ export function computeOrderUid(input, chainId, owner) {
25
+ try {
26
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
27
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
28
+ const len0 = WASM_VECTOR_LEN;
29
+ wasm.computeOrderUid(retptr, addHeapObject(input), chainId, ptr0, len0);
30
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
31
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
32
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
33
+ if (r2) {
34
+ throw takeObject(r1);
35
+ }
36
+ return takeObject(r0);
37
+ } finally {
38
+ wasm.__wbindgen_add_to_stack_pointer(16);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Decodes an eth-flow on-chain order lifecycle event log into a typed event.
44
+ *
45
+ * Dispatches on the log's topic-0 across the `CoWSwapOnchainOrders`
46
+ * `OrderPlacement` / `OrderInvalidation` events and the `CoWSwapEthFlow`
47
+ * `OrderRefund` event. The decode is fail-closed: the topic set and on-chain
48
+ * signing scheme are validated and every order UID is length-checked, so a
49
+ * malformed or hostile log returns a typed error rather than panicking.
50
+ *
51
+ * @param log Raw log with `topics` (0x-prefixed 32-byte hex, topic-0 first)
52
+ * and `data` (0x-prefixed hex, `"0x"` when empty).
53
+ * @returns A versioned envelope containing the decoded eth-flow event.
54
+ * @throws CowError when the log is malformed or its topic set matches no known
55
+ * eth-flow lifecycle event.
56
+ * @param {EventLogInput} log
57
+ * @returns {WasmEnvelope<EthFlowEventDto>}
58
+ */
59
+ export function decodeEthFlowLog(log) {
60
+ try {
61
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
62
+ wasm.decodeEthFlowLog(retptr, addHeapObject(log));
63
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
64
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
65
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
66
+ if (r2) {
67
+ throw takeObject(r1);
68
+ }
69
+ return takeObject(r0);
70
+ } finally {
71
+ wasm.__wbindgen_add_to_stack_pointer(16);
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Decodes a `GPv2Settlement` event log into a typed settlement event.
77
+ *
78
+ * Dispatches on the log's topic-0 across `Trade`, `Interaction`, `Settlement`,
79
+ * `OrderInvalidated`, and `PreSignature`. The decode is fail-closed: the topic
80
+ * set is validated before ABI decoding and every order UID is length-checked,
81
+ * so a malformed or hostile log returns a typed error rather than panicking.
82
+ *
83
+ * @param log Raw log with `topics` (0x-prefixed 32-byte hex, topic-0 first)
84
+ * and `data` (0x-prefixed hex, `"0x"` when empty).
85
+ * @returns A versioned envelope containing the decoded settlement event.
86
+ * @throws CowError when the log is malformed or its topic set matches no known
87
+ * settlement event.
88
+ * @param {EventLogInput} log
89
+ * @returns {WasmEnvelope<SettlementEventDto>}
90
+ */
91
+ export function decodeSettlementLog(log) {
92
+ try {
93
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
94
+ wasm.decodeSettlementLog(retptr, addHeapObject(log));
95
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
96
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
97
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
98
+ if (r2) {
99
+ throw takeObject(r1);
100
+ }
101
+ return takeObject(r0);
102
+ } finally {
103
+ wasm.__wbindgen_add_to_stack_pointer(16);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Returns canonical CoW Protocol deployment addresses for a chain.
109
+ *
110
+ * The optional environment selects production or staging deployment data. When
111
+ * omitted, the helper uses the SDK default environment.
112
+ *
113
+ * @param chainId EVM chain id to resolve.
114
+ * @param env Optional CoW environment name, such as `prod` or `staging`.
115
+ * @returns Settlement, VaultRelayer, EthFlow, and AllowListAuth addresses.
116
+ * @throws CowError when the chain or environment is unsupported.
117
+ * @param {number} chainId
118
+ * @param {string | null} [env]
119
+ * @returns {WasmEnvelope<DeploymentAddressesDto>}
120
+ */
121
+ export function deploymentAddresses(chainId, env) {
122
+ try {
123
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
124
+ var ptr0 = isLikeNone(env) ? 0 : passStringToWasm0(env, wasm.__wbindgen_export, wasm.__wbindgen_export2);
125
+ var len0 = WASM_VECTOR_LEN;
126
+ wasm.deploymentAddresses(retptr, chainId, ptr0, len0);
127
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
128
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
129
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
130
+ if (r2) {
131
+ throw takeObject(r1);
132
+ }
133
+ return takeObject(r0);
134
+ } finally {
135
+ wasm.__wbindgen_add_to_stack_pointer(16);
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Computes the CoW Protocol EIP-712 domain separator for a supported chain.
141
+ *
142
+ * Use this helper when a JavaScript host needs to compare the domain hash used
143
+ * by the Rust SDK with another signing stack. The input is an EVM chain id,
144
+ * not a CoW environment selector.
145
+ *
146
+ * @param chainId EVM chain id supported by the deployment registry.
147
+ * @returns The `0x`-prefixed 32-byte domain separator.
148
+ * @throws CowError when the chain is not supported.
149
+ * @param {number} chainId
150
+ * @returns {string}
151
+ */
152
+ export function domainSeparator(chainId) {
153
+ let deferred2_0;
154
+ let deferred2_1;
155
+ try {
156
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
157
+ wasm.domainSeparator(retptr, chainId);
158
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
159
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
160
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
161
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
162
+ var ptr1 = r0;
163
+ var len1 = r1;
164
+ if (r3) {
165
+ ptr1 = 0; len1 = 0;
166
+ throw takeObject(r2);
167
+ }
168
+ deferred2_0 = ptr1;
169
+ deferred2_1 = len1;
170
+ return getStringFromWasm0(ptr1, len1);
171
+ } finally {
172
+ wasm.__wbindgen_add_to_stack_pointer(16);
173
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Encodes a CoW EIP-1271 payload from an ECDSA order signature.
179
+ *
180
+ * Use this pure helper when a smart-account flow already has the wrapped ECDSA
181
+ * signature and needs the contract-signature payload bytes expected by CoW
182
+ * Protocol order submission.
183
+ *
184
+ * @param input Unsigned order used to derive the EIP-1271 payload.
185
+ * @param ecdsaSignature Wrapped ECDSA signature as a `0x`-prefixed string.
186
+ * @returns A versioned envelope containing the encoded EIP-1271 payload.
187
+ * @throws CowError when the order or signature is invalid.
188
+ * @param {OrderInput} input
189
+ * @param {string} ecdsaSignature
190
+ * @returns {WasmEnvelope<string>}
191
+ */
192
+ export function eip1271SignaturePayload(input, ecdsaSignature) {
193
+ try {
194
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
195
+ const ptr0 = passStringToWasm0(ecdsaSignature, wasm.__wbindgen_export, wasm.__wbindgen_export2);
196
+ const len0 = WASM_VECTOR_LEN;
197
+ wasm.eip1271SignaturePayload(retptr, addHeapObject(input), ptr0, len0);
198
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
199
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
200
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
201
+ if (r2) {
202
+ throw takeObject(r1);
203
+ }
204
+ return takeObject(r0);
205
+ } finally {
206
+ wasm.__wbindgen_add_to_stack_pointer(16);
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Builds signer-facing EIP-712 typed data for an unsigned order.
212
+ *
213
+ * The returned envelope contains the domain, type map, primary type, and
214
+ * order message that wallet libraries expect for EIP-712 signing. It is
215
+ * deterministic for the provided order and chain id.
216
+ *
217
+ * @param input Unsigned order fields using the facade order DTO shape.
218
+ * @param chainId EVM chain id used for the EIP-712 domain.
219
+ * @returns A versioned envelope containing typed-data DTO fields.
220
+ * @throws CowError when order parsing or chain validation fails.
221
+ * @param {OrderInput} input
222
+ * @param {number} chainId
223
+ * @returns {WasmEnvelope<TypedDataEnvelopeDto>}
224
+ */
225
+ export function orderTypedData(input, chainId) {
226
+ try {
227
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
228
+ wasm.orderTypedData(retptr, addHeapObject(input), chainId);
229
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
230
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
231
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
232
+ if (r2) {
233
+ throw takeObject(r1);
234
+ }
235
+ return takeObject(r0);
236
+ } finally {
237
+ wasm.__wbindgen_add_to_stack_pointer(16);
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Signs an order digest through an explicit `eth_sign` callback.
243
+ *
244
+ * The SDK computes the canonical order digest, passes the digest as a
245
+ * `0x`-prefixed string to the callback, normalizes the signature, and returns
246
+ * an `ethsign` signed-order DTO.
247
+ *
248
+ * @param input Unsigned order fields to sign.
249
+ * @param chainId EVM chain id used for the digest.
250
+ * @param owner Owner address used in the generated order UID.
251
+ * @param digestSigner Callback that signs the digest string.
252
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
253
+ * @returns A versioned envelope containing the signed order.
254
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
255
+ * @param {OrderInput} input
256
+ * @param {number} chainId
257
+ * @param {string} owner
258
+ * @param {DigestSignerCallback} digestSigner
259
+ * @param {SigningOptions | null} [options]
260
+ * @returns {WasmEnvelope<SignedOrderDto>}
261
+ */
262
+ export function signOrderEthSignDigest(input, chainId, owner, digestSigner, options) {
263
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
264
+ const len0 = WASM_VECTOR_LEN;
265
+ const ret = wasm.signOrderEthSignDigest(addHeapObject(input), chainId, ptr0, len0, addHeapObject(digestSigner), isLikeNone(options) ? 0 : addHeapObject(options));
266
+ return takeObject(ret);
267
+ }
268
+
269
+ /**
270
+ * Signs an order through a custom EIP-1271 callback.
271
+ *
272
+ * Use this method when the JavaScript host owns the smart-account or
273
+ * account-abstraction client and can return the final contract signature
274
+ * directly. The SDK still builds typed data and the deterministic order UID.
275
+ *
276
+ * @param input Unsigned order to sign.
277
+ * @param chainId EVM chain id for the EIP-712 domain.
278
+ * @param owner Smart-account owner address used in the generated order UID.
279
+ * @param customCallback Callback that returns the final EIP-1271 signature.
280
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
281
+ * @returns A versioned envelope containing the signed-order DTO.
282
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
283
+ * @param {OrderInput} input
284
+ * @param {number} chainId
285
+ * @param {string} owner
286
+ * @param {CustomEip1271Callback} customCallback
287
+ * @param {SigningOptions | null} [options]
288
+ * @returns {WasmEnvelope<SignedOrderDto>}
289
+ */
290
+ export function signOrderWithCustomEip1271(input, chainId, owner, customCallback, options) {
291
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ret = wasm.signOrderWithCustomEip1271(addHeapObject(input), chainId, ptr0, len0, addHeapObject(customCallback), isLikeNone(options) ? 0 : addHeapObject(options));
294
+ return takeObject(ret);
295
+ }
296
+
297
+ /**
298
+ * Signs an order through an EIP-1193 request callback.
299
+ *
300
+ * The callback receives an `eth_signTypedData_v4` request object with owner
301
+ * address and serialized typed data. This is the bridge for injected wallets
302
+ * and wallet-client libraries that expose an EIP-1193-style request function.
303
+ *
304
+ * @param input Unsigned order fields to sign.
305
+ * @param chainId EVM chain id used for the EIP-712 domain.
306
+ * @param owner Owner address used in the wallet request and order UID.
307
+ * @param requestCallback Callback that executes the EIP-1193 request.
308
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
309
+ * @returns A versioned envelope containing the signed order.
310
+ * @throws CowError for invalid input, wallet failure, timeout, or cancellation.
311
+ * @param {OrderInput} input
312
+ * @param {number} chainId
313
+ * @param {string} owner
314
+ * @param {Eip1193RequestCallback} requestCallback
315
+ * @param {SigningOptions | null} [options]
316
+ * @returns {WasmEnvelope<SignedOrderDto>}
317
+ */
318
+ export function signOrderWithEip1193(input, chainId, owner, requestCallback, options) {
319
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
320
+ const len0 = WASM_VECTOR_LEN;
321
+ const ret = wasm.signOrderWithEip1193(addHeapObject(input), chainId, ptr0, len0, addHeapObject(requestCallback), isLikeNone(options) ? 0 : addHeapObject(options));
322
+ return takeObject(ret);
323
+ }
324
+
325
+ /**
326
+ * Signs an order through typed-data ECDSA and wraps it as EIP-1271.
327
+ *
328
+ * The SDK sends the EIP-712 envelope to the provided typed-data callback,
329
+ * then converts the returned ECDSA signature into the CoW EIP-1271 payload.
330
+ * Per-call options may attach cancellation and wallet timeout settings.
331
+ *
332
+ * @param input Unsigned order to sign.
333
+ * @param chainId EVM chain id for the EIP-712 domain.
334
+ * @param owner Smart-account owner address used in the generated order UID.
335
+ * @param typedDataSigner Callback that signs the typed-data envelope.
336
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
337
+ * @returns A versioned envelope containing the signed-order DTO.
338
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
339
+ * @param {OrderInput} input
340
+ * @param {number} chainId
341
+ * @param {string} owner
342
+ * @param {TypedDataSignerCallback} typedDataSigner
343
+ * @param {SigningOptions | null} [options]
344
+ * @returns {WasmEnvelope<SignedOrderDto>}
345
+ */
346
+ export function signOrderWithEip1271(input, chainId, owner, typedDataSigner, options) {
347
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
348
+ const len0 = WASM_VECTOR_LEN;
349
+ const ret = wasm.signOrderWithEip1271(addHeapObject(input), chainId, ptr0, len0, addHeapObject(typedDataSigner), isLikeNone(options) ? 0 : addHeapObject(options));
350
+ return takeObject(ret);
351
+ }
352
+
353
+ /**
354
+ * Signs an order through a typed-data callback.
355
+ *
356
+ * The SDK builds the EIP-712 typed-data envelope, passes it to the callback,
357
+ * normalizes the returned ECDSA signature, and returns the signed-order DTO
358
+ * with the canonical order UID and digest.
359
+ *
360
+ * @param input Unsigned order fields to sign.
361
+ * @param chainId EVM chain id used for the EIP-712 domain.
362
+ * @param owner Owner address used in the generated order UID.
363
+ * @param typedDataSigner Callback that signs the typed-data envelope.
364
+ * @param options Optional cancellation, timeout, and wallet timeout settings.
365
+ * @returns A versioned envelope containing the signed order.
366
+ * @throws CowError for invalid input, callback failure, timeout, or cancellation.
367
+ * @param {OrderInput} input
368
+ * @param {number} chainId
369
+ * @param {string} owner
370
+ * @param {TypedDataSignerCallback} typedDataSigner
371
+ * @param {SigningOptions | null} [options]
372
+ * @returns {WasmEnvelope<SignedOrderDto>}
373
+ */
374
+ export function signOrderWithTypedDataSigner(input, chainId, owner, typedDataSigner, options) {
375
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
376
+ const len0 = WASM_VECTOR_LEN;
377
+ const ret = wasm.signOrderWithTypedDataSigner(addHeapObject(input), chainId, ptr0, len0, addHeapObject(typedDataSigner), isLikeNone(options) ? 0 : addHeapObject(options));
378
+ return takeObject(ret);
379
+ }
380
+
381
+ /**
382
+ * Returns the EVM chain ids supported by the SDK deployment registry.
383
+ *
384
+ * This is a pure helper and does not perform network I/O. The returned list is
385
+ * suitable for runtime validation, UI selection, or capability checks before a
386
+ * client is constructed.
387
+ *
388
+ * @returns A typed array of supported EVM chain ids.
389
+ * @returns {Uint32Array}
390
+ */
391
+ export function supportedChainIds() {
392
+ try {
393
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
394
+ wasm.supportedChainIds(retptr);
395
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
396
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
397
+ var v1 = getArrayU32FromWasm0(r0, r1).slice();
398
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
399
+ return v1;
400
+ } finally {
401
+ wasm.__wbindgen_add_to_stack_pointer(16);
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Returns the version of the wasm package runtime.
407
+ *
408
+ * The value comes from the Rust package metadata used to build the wasm
409
+ * artifact and can be included in diagnostics or compatibility checks.
410
+ *
411
+ * @returns The semantic version string for this wasm build.
412
+ * @returns {string}
413
+ */
414
+ export function wasmVersion() {
415
+ let deferred1_0;
416
+ let deferred1_1;
417
+ try {
418
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
419
+ wasm.wasmVersion(retptr);
420
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
421
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
422
+ deferred1_0 = r0;
423
+ deferred1_1 = r1;
424
+ return getStringFromWasm0(r0, r1);
425
+ } finally {
426
+ wasm.__wbindgen_add_to_stack_pointer(16);
427
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
428
+ }
429
+ }
430
+ export function __wbg_Error_fdd633d4bb5dd76a(arg0, arg1) {
431
+ const ret = Error(getStringFromWasm0(arg0, arg1));
432
+ return addHeapObject(ret);
433
+ }
434
+ export function __wbg_Number_c4bdf66bb78f7977(arg0) {
435
+ const ret = Number(getObject(arg0));
436
+ return ret;
437
+ }
438
+ export function __wbg_String_8564e559799eccda(arg0, arg1) {
439
+ const ret = String(getObject(arg1));
440
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
441
+ const len1 = WASM_VECTOR_LEN;
442
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
443
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
444
+ }
445
+ export function __wbg___wbindgen_boolean_get_edaed31a367ce1bd(arg0) {
446
+ const v = getObject(arg0);
447
+ const ret = typeof(v) === 'boolean' ? v : undefined;
448
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
449
+ }
450
+ export function __wbg___wbindgen_debug_string_8a447059637473e2(arg0, arg1) {
451
+ const ret = debugString(getObject(arg1));
452
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
453
+ const len1 = WASM_VECTOR_LEN;
454
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
455
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
456
+ }
457
+ export function __wbg___wbindgen_in_4990f46af709e33c(arg0, arg1) {
458
+ const ret = getObject(arg0) in getObject(arg1);
459
+ return ret;
460
+ }
461
+ export function __wbg___wbindgen_is_function_acc5528be2b923f2(arg0) {
462
+ const ret = typeof(getObject(arg0)) === 'function';
463
+ return ret;
464
+ }
465
+ export function __wbg___wbindgen_is_null_6d937fbfb6478470(arg0) {
466
+ const ret = getObject(arg0) === null;
467
+ return ret;
468
+ }
469
+ export function __wbg___wbindgen_is_object_0beba4a1980d3eea(arg0) {
470
+ const val = getObject(arg0);
471
+ const ret = typeof(val) === 'object' && val !== null;
472
+ return ret;
473
+ }
474
+ export function __wbg___wbindgen_is_string_1fca8072260dd261(arg0) {
475
+ const ret = typeof(getObject(arg0)) === 'string';
476
+ return ret;
477
+ }
478
+ export function __wbg___wbindgen_is_undefined_721f8decd50c87a3(arg0) {
479
+ const ret = getObject(arg0) === undefined;
480
+ return ret;
481
+ }
482
+ export function __wbg___wbindgen_jsval_loose_eq_4b9aba9e5b3c4582(arg0, arg1) {
483
+ const ret = getObject(arg0) == getObject(arg1);
484
+ return ret;
485
+ }
486
+ export function __wbg___wbindgen_number_get_1cc01dd708740256(arg0, arg1) {
487
+ const obj = getObject(arg1);
488
+ const ret = typeof(obj) === 'number' ? obj : undefined;
489
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
490
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
491
+ }
492
+ export function __wbg___wbindgen_string_get_71bb4348194e31f0(arg0, arg1) {
493
+ const obj = getObject(arg1);
494
+ const ret = typeof(obj) === 'string' ? obj : undefined;
495
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
496
+ var len1 = WASM_VECTOR_LEN;
497
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
498
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
499
+ }
500
+ export function __wbg___wbindgen_throw_ea4887a5f8f9a9db(arg0, arg1) {
501
+ throw new Error(getStringFromWasm0(arg0, arg1));
502
+ }
503
+ export function __wbg__wbg_cb_unref_33c39e13d73b25f6(arg0) {
504
+ getObject(arg0)._wbg_cb_unref();
505
+ }
506
+ export function __wbg_aborted_4d4114700dc4c251(arg0) {
507
+ const ret = getObject(arg0).aborted;
508
+ return ret;
509
+ }
510
+ export function __wbg_addEventListener_ea90bc131475777e() { return handleError(function (arg0, arg1, arg2, arg3) {
511
+ getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
512
+ }, arguments); }
513
+ export function __wbg_call_5575218572ead796() { return handleError(function (arg0, arg1, arg2) {
514
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
515
+ return addHeapObject(ret);
516
+ }, arguments); }
517
+ export function __wbg_call_8e98ed2f3c86c4b5() { return handleError(function (arg0, arg1) {
518
+ const ret = getObject(arg0).call(getObject(arg1));
519
+ return addHeapObject(ret);
520
+ }, arguments); }
521
+ export function __wbg_clearTimeout_3629d6209dfcc46e(arg0) {
522
+ const ret = clearTimeout(takeObject(arg0));
523
+ return addHeapObject(ret);
524
+ }
525
+ export function __wbg_done_b62d4a7d2286852a(arg0) {
526
+ const ret = getObject(arg0).done;
527
+ return ret;
528
+ }
529
+ export function __wbg_entries_c261c3fa1f281256(arg0) {
530
+ const ret = Object.entries(getObject(arg0));
531
+ return addHeapObject(ret);
532
+ }
533
+ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
534
+ let deferred0_0;
535
+ let deferred0_1;
536
+ try {
537
+ deferred0_0 = arg0;
538
+ deferred0_1 = arg1;
539
+ console.error(getStringFromWasm0(arg0, arg1));
540
+ } finally {
541
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
542
+ }
543
+ }
544
+ export function __wbg_get_197a3fe98f169e38(arg0, arg1) {
545
+ const ret = getObject(arg0)[arg1 >>> 0];
546
+ return addHeapObject(ret);
547
+ }
548
+ export function __wbg_get_9a29be2cb383ed9a() { return handleError(function (arg0, arg1) {
549
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
550
+ return addHeapObject(ret);
551
+ }, arguments); }
552
+ export function __wbg_get_dddb90ff5d27a080() { return handleError(function (arg0, arg1) {
553
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
554
+ return addHeapObject(ret);
555
+ }, arguments); }
556
+ export function __wbg_get_unchecked_54a4374c38e08460(arg0, arg1) {
557
+ const ret = getObject(arg0)[arg1 >>> 0];
558
+ return addHeapObject(ret);
559
+ }
560
+ export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
561
+ const ret = getObject(arg0)[getObject(arg1)];
562
+ return addHeapObject(ret);
563
+ }
564
+ export function __wbg_instanceof_AbortSignal_4bebac9f7add3026(arg0) {
565
+ let result;
566
+ try {
567
+ result = getObject(arg0) instanceof AbortSignal;
568
+ } catch (_) {
569
+ result = false;
570
+ }
571
+ const ret = result;
572
+ return ret;
573
+ }
574
+ export function __wbg_instanceof_ArrayBuffer_2a7bb09fee70c2da(arg0) {
575
+ let result;
576
+ try {
577
+ result = getObject(arg0) instanceof ArrayBuffer;
578
+ } catch (_) {
579
+ result = false;
580
+ }
581
+ const ret = result;
582
+ return ret;
583
+ }
584
+ export function __wbg_instanceof_Uint8Array_f080092dc70f5d58(arg0) {
585
+ let result;
586
+ try {
587
+ result = getObject(arg0) instanceof Uint8Array;
588
+ } catch (_) {
589
+ result = false;
590
+ }
591
+ const ret = result;
592
+ return ret;
593
+ }
594
+ export function __wbg_isArray_145a34fd0a38d37b(arg0) {
595
+ const ret = Array.isArray(getObject(arg0));
596
+ return ret;
597
+ }
598
+ export function __wbg_isSafeInteger_a3389a198582f5f6(arg0) {
599
+ const ret = Number.isSafeInteger(getObject(arg0));
600
+ return ret;
601
+ }
602
+ export function __wbg_iterator_cc47ba25a2be735a() {
603
+ const ret = Symbol.iterator;
604
+ return addHeapObject(ret);
605
+ }
606
+ export function __wbg_length_589238bdcf171f0e(arg0) {
607
+ const ret = getObject(arg0).length;
608
+ return ret;
609
+ }
610
+ export function __wbg_length_c6054974c0a6cdb9(arg0) {
611
+ const ret = getObject(arg0).length;
612
+ return ret;
613
+ }
614
+ export function __wbg_new_227d7c05414eb861() {
615
+ const ret = new Error();
616
+ return addHeapObject(ret);
617
+ }
618
+ export function __wbg_new_2e117a478906f062() {
619
+ const ret = new Object();
620
+ return addHeapObject(ret);
621
+ }
622
+ export function __wbg_new_3444eb7412549f0b() {
623
+ const ret = new Map();
624
+ return addHeapObject(ret);
625
+ }
626
+ export function __wbg_new_36e147a8ced3c6e0() {
627
+ const ret = new Array();
628
+ return addHeapObject(ret);
629
+ }
630
+ export function __wbg_new_81880fb5002cb255(arg0) {
631
+ const ret = new Uint8Array(getObject(arg0));
632
+ return addHeapObject(ret);
633
+ }
634
+ export function __wbg_new_f85beb941dc6d8aa(arg0, arg1) {
635
+ try {
636
+ var state0 = {a: arg0, b: arg1};
637
+ var cb0 = (arg0, arg1) => {
638
+ const a = state0.a;
639
+ state0.a = 0;
640
+ try {
641
+ return __wasm_bindgen_func_elem_1603(a, state0.b, arg0, arg1);
642
+ } finally {
643
+ state0.a = a;
644
+ }
645
+ };
646
+ const ret = new Promise(cb0);
647
+ return addHeapObject(ret);
648
+ } finally {
649
+ state0.a = 0;
650
+ }
651
+ }
652
+ export function __wbg_new_typed_00a409eb4ec4f2d9(arg0, arg1) {
653
+ try {
654
+ var state0 = {a: arg0, b: arg1};
655
+ var cb0 = (arg0, arg1) => {
656
+ const a = state0.a;
657
+ state0.a = 0;
658
+ try {
659
+ return __wasm_bindgen_func_elem_1603(a, state0.b, arg0, arg1);
660
+ } finally {
661
+ state0.a = a;
662
+ }
663
+ };
664
+ const ret = new Promise(cb0);
665
+ return addHeapObject(ret);
666
+ } finally {
667
+ state0.a = 0;
668
+ }
669
+ }
670
+ export function __wbg_next_0c4066e251d2eff9() { return handleError(function (arg0) {
671
+ const ret = getObject(arg0).next();
672
+ return addHeapObject(ret);
673
+ }, arguments); }
674
+ export function __wbg_next_402fa10b59ab20c3(arg0) {
675
+ const ret = getObject(arg0).next;
676
+ return addHeapObject(ret);
677
+ }
678
+ export function __wbg_prototypesetcall_d721637c7ca66eb8(arg0, arg1, arg2) {
679
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
680
+ }
681
+ export function __wbg_push_f724b5db8acf89d2(arg0, arg1) {
682
+ const ret = getObject(arg0).push(getObject(arg1));
683
+ return ret;
684
+ }
685
+ export function __wbg_queueMicrotask_1c9b3800e321a967(arg0) {
686
+ const ret = getObject(arg0).queueMicrotask;
687
+ return addHeapObject(ret);
688
+ }
689
+ export function __wbg_queueMicrotask_311744e534a929a3(arg0) {
690
+ queueMicrotask(getObject(arg0));
691
+ }
692
+ export function __wbg_race_27bed3574f107c6d(arg0) {
693
+ const ret = Promise.race(getObject(arg0));
694
+ return addHeapObject(ret);
695
+ }
696
+ export function __wbg_removeEventListener_c6782a9c30557d31() { return handleError(function (arg0, arg1, arg2, arg3) {
697
+ getObject(arg0).removeEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
698
+ }, arguments); }
699
+ export function __wbg_resolve_d82363d90af6928a(arg0) {
700
+ const ret = Promise.resolve(getObject(arg0));
701
+ return addHeapObject(ret);
702
+ }
703
+ export function __wbg_setTimeout_56bcdccbad22fd44() { return handleError(function (arg0, arg1) {
704
+ const ret = setTimeout(getObject(arg0), arg1);
705
+ return addHeapObject(ret);
706
+ }, arguments); }
707
+ export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
708
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
709
+ }
710
+ export function __wbg_set_9a1d61e17de7054c(arg0, arg1, arg2) {
711
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
712
+ return addHeapObject(ret);
713
+ }
714
+ export function __wbg_set_dc601f4a69da0bc2(arg0, arg1, arg2) {
715
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
716
+ }
717
+ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
718
+ const ret = getObject(arg1).stack;
719
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
720
+ const len1 = WASM_VECTOR_LEN;
721
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
722
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
723
+ }
724
+ export function __wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938() {
725
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
726
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
727
+ }
728
+ export function __wbg_static_accessor_GLOBAL_ce44e66a4935da8c() {
729
+ const ret = typeof global === 'undefined' ? null : global;
730
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
731
+ }
732
+ export function __wbg_static_accessor_SELF_44f6e0cb5e67cdad() {
733
+ const ret = typeof self === 'undefined' ? null : self;
734
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
735
+ }
736
+ export function __wbg_static_accessor_WINDOW_168f178805d978fe() {
737
+ const ret = typeof window === 'undefined' ? null : window;
738
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
739
+ }
740
+ export function __wbg_then_05edfc8a4fea5106(arg0, arg1, arg2) {
741
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
742
+ return addHeapObject(ret);
743
+ }
744
+ export function __wbg_then_591b6b3a75ee817a(arg0, arg1) {
745
+ const ret = getObject(arg0).then(getObject(arg1));
746
+ return addHeapObject(ret);
747
+ }
748
+ export function __wbg_value_49f783bb59765962(arg0) {
749
+ const ret = getObject(arg0).value;
750
+ return addHeapObject(ret);
751
+ }
752
+ export function __wbg_warn_cd671287bc02594a(arg0) {
753
+ console.warn(getObject(arg0));
754
+ }
755
+ export function __wbindgen_cast_0000000000000001(arg0, arg1) {
756
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 135, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
757
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1594);
758
+ return addHeapObject(ret);
759
+ }
760
+ export function __wbindgen_cast_0000000000000002(arg0, arg1) {
761
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 113, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
762
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1317);
763
+ return addHeapObject(ret);
764
+ }
765
+ export function __wbindgen_cast_0000000000000003(arg0) {
766
+ // Cast intrinsic for `F64 -> Externref`.
767
+ const ret = arg0;
768
+ return addHeapObject(ret);
769
+ }
770
+ export function __wbindgen_cast_0000000000000004(arg0) {
771
+ // Cast intrinsic for `I64 -> Externref`.
772
+ const ret = arg0;
773
+ return addHeapObject(ret);
774
+ }
775
+ export function __wbindgen_cast_0000000000000005(arg0, arg1) {
776
+ // Cast intrinsic for `Ref(String) -> Externref`.
777
+ const ret = getStringFromWasm0(arg0, arg1);
778
+ return addHeapObject(ret);
779
+ }
780
+ export function __wbindgen_cast_0000000000000006(arg0) {
781
+ // Cast intrinsic for `U64 -> Externref`.
782
+ const ret = BigInt.asUintN(64, arg0);
783
+ return addHeapObject(ret);
784
+ }
785
+ export function __wbindgen_object_clone_ref(arg0) {
786
+ const ret = getObject(arg0);
787
+ return addHeapObject(ret);
788
+ }
789
+ export function __wbindgen_object_drop_ref(arg0) {
790
+ takeObject(arg0);
791
+ }
792
+ function __wasm_bindgen_func_elem_1317(arg0, arg1) {
793
+ wasm.__wasm_bindgen_func_elem_1317(arg0, arg1);
794
+ }
795
+
796
+ function __wasm_bindgen_func_elem_1594(arg0, arg1, arg2) {
797
+ try {
798
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
799
+ wasm.__wasm_bindgen_func_elem_1594(retptr, arg0, arg1, addHeapObject(arg2));
800
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
801
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
802
+ if (r1) {
803
+ throw takeObject(r0);
804
+ }
805
+ } finally {
806
+ wasm.__wbindgen_add_to_stack_pointer(16);
807
+ }
808
+ }
809
+
810
+ function __wasm_bindgen_func_elem_1603(arg0, arg1, arg2, arg3) {
811
+ wasm.__wasm_bindgen_func_elem_1603(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
812
+ }
813
+
814
+ function addHeapObject(obj) {
815
+ if (heap_next === heap.length) heap.push(heap.length + 1);
816
+ const idx = heap_next;
817
+ heap_next = heap[idx];
818
+
819
+ heap[idx] = obj;
820
+ return idx;
821
+ }
822
+
823
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
824
+ ? { register: () => {}, unregister: () => {} }
825
+ : new FinalizationRegistry(state => wasm.__wbindgen_export5(state.a, state.b));
826
+
827
+ function debugString(val) {
828
+ // primitive types
829
+ const type = typeof val;
830
+ if (type == 'number' || type == 'boolean' || val == null) {
831
+ return `${val}`;
832
+ }
833
+ if (type == 'string') {
834
+ return `"${val}"`;
835
+ }
836
+ if (type == 'symbol') {
837
+ const description = val.description;
838
+ if (description == null) {
839
+ return 'Symbol';
840
+ } else {
841
+ return `Symbol(${description})`;
842
+ }
843
+ }
844
+ if (type == 'function') {
845
+ const name = val.name;
846
+ if (typeof name == 'string' && name.length > 0) {
847
+ return `Function(${name})`;
848
+ } else {
849
+ return 'Function';
850
+ }
851
+ }
852
+ // objects
853
+ if (Array.isArray(val)) {
854
+ const length = val.length;
855
+ let debug = '[';
856
+ if (length > 0) {
857
+ debug += debugString(val[0]);
858
+ }
859
+ for(let i = 1; i < length; i++) {
860
+ debug += ', ' + debugString(val[i]);
861
+ }
862
+ debug += ']';
863
+ return debug;
864
+ }
865
+ // Test for built-in
866
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
867
+ let className;
868
+ if (builtInMatches && builtInMatches.length > 1) {
869
+ className = builtInMatches[1];
870
+ } else {
871
+ // Failed to match the standard '[object ClassName]'
872
+ return toString.call(val);
873
+ }
874
+ if (className == 'Object') {
875
+ // we're a user defined class or Object
876
+ // JSON.stringify avoids problems with cycles, and is generally much
877
+ // easier than looping through ownProperties of `val`.
878
+ try {
879
+ return 'Object(' + JSON.stringify(val) + ')';
880
+ } catch (_) {
881
+ return 'Object';
882
+ }
883
+ }
884
+ // errors
885
+ if (val instanceof Error) {
886
+ return `${val.name}: ${val.message}\n${val.stack}`;
887
+ }
888
+ // TODO we could test for more things here, like `Set`s and `Map`s.
889
+ return className;
890
+ }
891
+
892
+ function dropObject(idx) {
893
+ if (idx < 1028) return;
894
+ heap[idx] = heap_next;
895
+ heap_next = idx;
896
+ }
897
+
898
+ function getArrayU32FromWasm0(ptr, len) {
899
+ ptr = ptr >>> 0;
900
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
901
+ }
902
+
903
+ function getArrayU8FromWasm0(ptr, len) {
904
+ ptr = ptr >>> 0;
905
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
906
+ }
907
+
908
+ let cachedDataViewMemory0 = null;
909
+ function getDataViewMemory0() {
910
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
911
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
912
+ }
913
+ return cachedDataViewMemory0;
914
+ }
915
+
916
+ function getStringFromWasm0(ptr, len) {
917
+ return decodeText(ptr >>> 0, len);
918
+ }
919
+
920
+ let cachedUint32ArrayMemory0 = null;
921
+ function getUint32ArrayMemory0() {
922
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
923
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
924
+ }
925
+ return cachedUint32ArrayMemory0;
926
+ }
927
+
928
+ let cachedUint8ArrayMemory0 = null;
929
+ function getUint8ArrayMemory0() {
930
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
931
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
932
+ }
933
+ return cachedUint8ArrayMemory0;
934
+ }
935
+
936
+ function getObject(idx) { return heap[idx]; }
937
+
938
+ function handleError(f, args) {
939
+ try {
940
+ return f.apply(this, args);
941
+ } catch (e) {
942
+ wasm.__wbindgen_export3(addHeapObject(e));
943
+ }
944
+ }
945
+
946
+ let heap = new Array(1024).fill(undefined);
947
+ heap.push(undefined, null, true, false);
948
+
949
+ let heap_next = heap.length;
950
+
951
+ function isLikeNone(x) {
952
+ return x === undefined || x === null;
953
+ }
954
+
955
+ function makeMutClosure(arg0, arg1, f) {
956
+ const state = { a: arg0, b: arg1, cnt: 1 };
957
+ const real = (...args) => {
958
+
959
+ // First up with a closure we increment the internal reference
960
+ // count. This ensures that the Rust closure environment won't
961
+ // be deallocated while we're invoking it.
962
+ state.cnt++;
963
+ const a = state.a;
964
+ state.a = 0;
965
+ try {
966
+ return f(a, state.b, ...args);
967
+ } finally {
968
+ state.a = a;
969
+ real._wbg_cb_unref();
970
+ }
971
+ };
972
+ real._wbg_cb_unref = () => {
973
+ if (--state.cnt === 0) {
974
+ wasm.__wbindgen_export5(state.a, state.b);
975
+ state.a = 0;
976
+ CLOSURE_DTORS.unregister(state);
977
+ }
978
+ };
979
+ CLOSURE_DTORS.register(real, state, state);
980
+ return real;
981
+ }
982
+
983
+ function passStringToWasm0(arg, malloc, realloc) {
984
+ if (realloc === undefined) {
985
+ const buf = cachedTextEncoder.encode(arg);
986
+ const ptr = malloc(buf.length, 1) >>> 0;
987
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
988
+ WASM_VECTOR_LEN = buf.length;
989
+ return ptr;
990
+ }
991
+
992
+ let len = arg.length;
993
+ let ptr = malloc(len, 1) >>> 0;
994
+
995
+ const mem = getUint8ArrayMemory0();
996
+
997
+ let offset = 0;
998
+
999
+ for (; offset < len; offset++) {
1000
+ const code = arg.charCodeAt(offset);
1001
+ if (code > 0x7F) break;
1002
+ mem[ptr + offset] = code;
1003
+ }
1004
+ if (offset !== len) {
1005
+ if (offset !== 0) {
1006
+ arg = arg.slice(offset);
1007
+ }
1008
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1009
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1010
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1011
+
1012
+ offset += ret.written;
1013
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1014
+ }
1015
+
1016
+ WASM_VECTOR_LEN = offset;
1017
+ return ptr;
1018
+ }
1019
+
1020
+ function takeObject(idx) {
1021
+ const ret = getObject(idx);
1022
+ dropObject(idx);
1023
+ return ret;
1024
+ }
1025
+
1026
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1027
+ cachedTextDecoder.decode();
1028
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1029
+ let numBytesDecoded = 0;
1030
+ function decodeText(ptr, len) {
1031
+ numBytesDecoded += len;
1032
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1033
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1034
+ cachedTextDecoder.decode();
1035
+ numBytesDecoded = len;
1036
+ }
1037
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1038
+ }
1039
+
1040
+ const cachedTextEncoder = new TextEncoder();
1041
+
1042
+ if (!('encodeInto' in cachedTextEncoder)) {
1043
+ cachedTextEncoder.encodeInto = function (arg, view) {
1044
+ const buf = cachedTextEncoder.encode(arg);
1045
+ view.set(buf);
1046
+ return {
1047
+ read: arg.length,
1048
+ written: buf.length
1049
+ };
1050
+ };
1051
+ }
1052
+
1053
+ let WASM_VECTOR_LEN = 0;
1054
+
1055
+
1056
+ let wasm;
1057
+ export function __wbg_set_wasm(val) {
1058
+ wasm = val;
1059
+ }