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