extended-typescript-sdk 0.0.4 → 0.0.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extended-typescript-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Unofficial TypeScript SDK for Extended Exchange - A perpetual DEX built by ex-Revolut team",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
- import * as wasm from "./stark_crypto_wasm_bg.wasm";
2
- export * from "./stark_crypto_wasm_bg.js";
3
- import { __wbg_set_wasm } from "./stark_crypto_wasm_bg.js";
1
+ import * as wasm from "./stark_crypto_wasm_bg-web.wasm";
2
+ export * from "./stark_crypto_wasm_bg-web.js";
3
+ import { __wbg_set_wasm } from "./stark_crypto_wasm_bg-web.js";
4
4
  __wbg_set_wasm(wasm);
5
5
  wasm.__wbindgen_start();
@@ -1,6 +1,31 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
-
3
+ /**
4
+ * Initialize the WASM module
5
+ */
6
+ export function init(): void;
7
+ /**
8
+ * Sign a message hash with a private key
9
+ *
10
+ * # Arguments
11
+ * * `private_key` - Private key as hex string (e.g., "0x123...")
12
+ * * `msg_hash` - Message hash as hex string (e.g., "0x456...")
13
+ *
14
+ * # Returns
15
+ * Array of two hex strings: [r, s]
16
+ */
17
+ export function sign(private_key: string, msg_hash: string): string[];
18
+ /**
19
+ * Compute Pedersen hash of two field elements
20
+ *
21
+ * # Arguments
22
+ * * `a` - First field element as hex string
23
+ * * `b` - Second field element as hex string
24
+ *
25
+ * # Returns
26
+ * Hash result as hex string
27
+ */
28
+ export function pedersen_hash(a: string, b: string): string;
4
29
  /**
5
30
  * Generate Stark keypair from Ethereum signature
6
31
  *
@@ -14,7 +39,6 @@
14
39
  * Array of two hex strings: [private_key, public_key]
15
40
  */
16
41
  export function generate_keypair_from_eth_signature(eth_signature: string): string[];
17
-
18
42
  /**
19
43
  * Get order message hash
20
44
  *
@@ -22,7 +46,6 @@ export function generate_keypair_from_eth_signature(eth_signature: string): stri
22
46
  * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
23
47
  */
24
48
  export function get_order_msg_hash(position_id: bigint, base_asset_id: string, base_amount: string, quote_asset_id: string, quote_amount: string, fee_amount: string, fee_asset_id: string, expiration: bigint, salt: bigint, user_public_key: string, domain_name: string, domain_version: string, domain_chain_id: string, domain_revision: string): string;
25
-
26
49
  /**
27
50
  * Get transfer message hash
28
51
  *
@@ -30,7 +53,6 @@ export function get_order_msg_hash(position_id: bigint, base_asset_id: string, b
30
53
  * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
31
54
  */
32
55
  export function get_transfer_msg_hash(recipient_position_id: bigint, sender_position_id: bigint, amount: string, expiration: bigint, salt: string, user_public_key: string, domain_name: string, domain_version: string, domain_chain_id: string, domain_revision: string, collateral_id: string): string;
33
-
34
56
  /**
35
57
  * Get withdrawal message hash
36
58
  *
@@ -38,34 +60,4 @@ export function get_transfer_msg_hash(recipient_position_id: bigint, sender_posi
38
60
  * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
39
61
  */
40
62
  export function get_withdrawal_msg_hash(recipient_hex: string, position_id: bigint, amount: string, expiration: bigint, salt: string, user_public_key: string, domain_name: string, domain_version: string, domain_chain_id: string, domain_revision: string, collateral_id: string): string;
41
-
42
- /**
43
- * Initialize the WASM module
44
- */
45
- export function init(): void;
46
-
47
63
  export function main(): void;
48
-
49
- /**
50
- * Compute Pedersen hash of two field elements
51
- *
52
- * # Arguments
53
- * * `a` - First field element as hex string
54
- * * `b` - Second field element as hex string
55
- *
56
- * # Returns
57
- * Hash result as hex string
58
- */
59
- export function pedersen_hash(a: string, b: string): string;
60
-
61
- /**
62
- * Sign a message hash with a private key
63
- *
64
- * # Arguments
65
- * * `private_key` - Private key as hex string (e.g., "0x123...")
66
- * * `msg_hash` - Message hash as hex string (e.g., "0x456...")
67
- *
68
- * # Returns
69
- * Array of two hex strings: [r, s]
70
- */
71
- export function sign(private_key: string, msg_hash: string): string[];
@@ -1,6 +1,31 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
-
3
+ /**
4
+ * Initialize the WASM module
5
+ */
6
+ export function init(): void;
7
+ /**
8
+ * Sign a message hash with a private key
9
+ *
10
+ * # Arguments
11
+ * * `private_key` - Private key as hex string (e.g., "0x123...")
12
+ * * `msg_hash` - Message hash as hex string (e.g., "0x456...")
13
+ *
14
+ * # Returns
15
+ * Array of two hex strings: [r, s]
16
+ */
17
+ export function sign(private_key: string, msg_hash: string): string[];
18
+ /**
19
+ * Compute Pedersen hash of two field elements
20
+ *
21
+ * # Arguments
22
+ * * `a` - First field element as hex string
23
+ * * `b` - Second field element as hex string
24
+ *
25
+ * # Returns
26
+ * Hash result as hex string
27
+ */
28
+ export function pedersen_hash(a: string, b: string): string;
4
29
  /**
5
30
  * Generate Stark keypair from Ethereum signature
6
31
  *
@@ -14,7 +39,6 @@
14
39
  * Array of two hex strings: [private_key, public_key]
15
40
  */
16
41
  export function generate_keypair_from_eth_signature(eth_signature: string): string[];
17
-
18
42
  /**
19
43
  * Get order message hash
20
44
  *
@@ -22,7 +46,6 @@ export function generate_keypair_from_eth_signature(eth_signature: string): stri
22
46
  * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
23
47
  */
24
48
  export function get_order_msg_hash(position_id: bigint, base_asset_id: string, base_amount: string, quote_asset_id: string, quote_amount: string, fee_amount: string, fee_asset_id: string, expiration: bigint, salt: bigint, user_public_key: string, domain_name: string, domain_version: string, domain_chain_id: string, domain_revision: string): string;
25
-
26
49
  /**
27
50
  * Get transfer message hash
28
51
  *
@@ -30,7 +53,6 @@ export function get_order_msg_hash(position_id: bigint, base_asset_id: string, b
30
53
  * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
31
54
  */
32
55
  export function get_transfer_msg_hash(recipient_position_id: bigint, sender_position_id: bigint, amount: string, expiration: bigint, salt: string, user_public_key: string, domain_name: string, domain_version: string, domain_chain_id: string, domain_revision: string, collateral_id: string): string;
33
-
34
56
  /**
35
57
  * Get withdrawal message hash
36
58
  *
@@ -38,34 +60,4 @@ export function get_transfer_msg_hash(recipient_position_id: bigint, sender_posi
38
60
  * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
39
61
  */
40
62
  export function get_withdrawal_msg_hash(recipient_hex: string, position_id: bigint, amount: string, expiration: bigint, salt: string, user_public_key: string, domain_name: string, domain_version: string, domain_chain_id: string, domain_revision: string, collateral_id: string): string;
41
-
42
- /**
43
- * Initialize the WASM module
44
- */
45
- export function init(): void;
46
-
47
63
  export function main(): void;
48
-
49
- /**
50
- * Compute Pedersen hash of two field elements
51
- *
52
- * # Arguments
53
- * * `a` - First field element as hex string
54
- * * `b` - Second field element as hex string
55
- *
56
- * # Returns
57
- * Hash result as hex string
58
- */
59
- export function pedersen_hash(a: string, b: string): string;
60
-
61
- /**
62
- * Sign a message hash with a private key
63
- *
64
- * # Arguments
65
- * * `private_key` - Private key as hex string (e.g., "0x123...")
66
- * * `msg_hash` - Message hash as hex string (e.g., "0x456...")
67
- *
68
- * # Returns
69
- * Array of two hex strings: [r, s]
70
- */
71
- export function sign(private_key: string, msg_hash: string): string[];
@@ -13,39 +13,51 @@ imports['./stark_crypto_wasm_bg.js'] = new Proxy({}, {
13
13
  }
14
14
  });
15
15
 
16
- function getArrayJsValueFromWasm0(ptr, len) {
17
- ptr = ptr >>> 0;
18
- const mem = getDataViewMemory0();
19
- const result = [];
20
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
21
- result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
16
+ let cachedUint8ArrayMemory0 = null;
17
+
18
+ function getUint8ArrayMemory0() {
19
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
20
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
22
21
  }
23
- wasm.__externref_drop_slice(ptr, len);
24
- return result;
22
+ return cachedUint8ArrayMemory0;
25
23
  }
26
24
 
27
- let cachedDataViewMemory0 = null;
28
- function getDataViewMemory0() {
29
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
30
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
31
- }
32
- return cachedDataViewMemory0;
25
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
+
27
+ cachedTextDecoder.decode();
28
+
29
+ function decodeText(ptr, len) {
30
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
33
31
  }
34
32
 
35
33
  function getStringFromWasm0(ptr, len) {
36
34
  ptr = ptr >>> 0;
37
35
  return decodeText(ptr, len);
38
36
  }
37
+ /**
38
+ * Initialize the WASM module
39
+ */
40
+ exports.init = function() {
41
+ wasm.main();
42
+ };
39
43
 
40
- let cachedUint8ArrayMemory0 = null;
41
- function getUint8ArrayMemory0() {
42
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
43
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
44
+ let WASM_VECTOR_LEN = 0;
45
+
46
+ const cachedTextEncoder = new TextEncoder();
47
+
48
+ if (!('encodeInto' in cachedTextEncoder)) {
49
+ cachedTextEncoder.encodeInto = function (arg, view) {
50
+ const buf = cachedTextEncoder.encode(arg);
51
+ view.set(buf);
52
+ return {
53
+ read: arg.length,
54
+ written: buf.length
55
+ };
44
56
  }
45
- return cachedUint8ArrayMemory0;
46
57
  }
47
58
 
48
59
  function passStringToWasm0(arg, malloc, realloc) {
60
+
49
61
  if (realloc === undefined) {
50
62
  const buf = cachedTextEncoder.encode(arg);
51
63
  const ptr = malloc(buf.length, 1) >>> 0;
@@ -66,6 +78,7 @@ function passStringToWasm0(arg, malloc, realloc) {
66
78
  if (code > 0x7F) break;
67
79
  mem[ptr + offset] = code;
68
80
  }
81
+
69
82
  if (offset !== len) {
70
83
  if (offset !== 0) {
71
84
  arg = arg.slice(offset);
@@ -82,26 +95,78 @@ function passStringToWasm0(arg, malloc, realloc) {
82
95
  return ptr;
83
96
  }
84
97
 
85
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
86
- cachedTextDecoder.decode();
87
- function decodeText(ptr, len) {
88
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
89
- }
98
+ let cachedDataViewMemory0 = null;
90
99
 
91
- const cachedTextEncoder = new TextEncoder();
100
+ function getDataViewMemory0() {
101
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
102
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
103
+ }
104
+ return cachedDataViewMemory0;
105
+ }
92
106
 
93
- if (!('encodeInto' in cachedTextEncoder)) {
94
- cachedTextEncoder.encodeInto = function (arg, view) {
95
- const buf = cachedTextEncoder.encode(arg);
96
- view.set(buf);
97
- return {
98
- read: arg.length,
99
- written: buf.length
100
- };
107
+ function getArrayJsValueFromWasm0(ptr, len) {
108
+ ptr = ptr >>> 0;
109
+ const mem = getDataViewMemory0();
110
+ const result = [];
111
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
112
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
101
113
  }
114
+ wasm.__externref_drop_slice(ptr, len);
115
+ return result;
102
116
  }
117
+ /**
118
+ * Sign a message hash with a private key
119
+ *
120
+ * # Arguments
121
+ * * `private_key` - Private key as hex string (e.g., "0x123...")
122
+ * * `msg_hash` - Message hash as hex string (e.g., "0x456...")
123
+ *
124
+ * # Returns
125
+ * Array of two hex strings: [r, s]
126
+ * @param {string} private_key
127
+ * @param {string} msg_hash
128
+ * @returns {string[]}
129
+ */
130
+ exports.sign = function(private_key, msg_hash) {
131
+ const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132
+ const len0 = WASM_VECTOR_LEN;
133
+ const ptr1 = passStringToWasm0(msg_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
134
+ const len1 = WASM_VECTOR_LEN;
135
+ const ret = wasm.sign(ptr0, len0, ptr1, len1);
136
+ var v3 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
137
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
138
+ return v3;
139
+ };
103
140
 
104
- let WASM_VECTOR_LEN = 0;
141
+ /**
142
+ * Compute Pedersen hash of two field elements
143
+ *
144
+ * # Arguments
145
+ * * `a` - First field element as hex string
146
+ * * `b` - Second field element as hex string
147
+ *
148
+ * # Returns
149
+ * Hash result as hex string
150
+ * @param {string} a
151
+ * @param {string} b
152
+ * @returns {string}
153
+ */
154
+ exports.pedersen_hash = function(a, b) {
155
+ let deferred3_0;
156
+ let deferred3_1;
157
+ try {
158
+ const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
159
+ const len0 = WASM_VECTOR_LEN;
160
+ const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ const len1 = WASM_VECTOR_LEN;
162
+ const ret = wasm.pedersen_hash(ptr0, len0, ptr1, len1);
163
+ deferred3_0 = ret[0];
164
+ deferred3_1 = ret[1];
165
+ return getStringFromWasm0(ret[0], ret[1]);
166
+ } finally {
167
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
168
+ }
169
+ };
105
170
 
106
171
  /**
107
172
  * Generate Stark keypair from Ethereum signature
@@ -117,15 +182,14 @@ let WASM_VECTOR_LEN = 0;
117
182
  * @param {string} eth_signature
118
183
  * @returns {string[]}
119
184
  */
120
- function generate_keypair_from_eth_signature(eth_signature) {
185
+ exports.generate_keypair_from_eth_signature = function(eth_signature) {
121
186
  const ptr0 = passStringToWasm0(eth_signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
122
187
  const len0 = WASM_VECTOR_LEN;
123
188
  const ret = wasm.generate_keypair_from_eth_signature(ptr0, len0);
124
189
  var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
125
190
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
126
191
  return v2;
127
- }
128
- exports.generate_keypair_from_eth_signature = generate_keypair_from_eth_signature;
192
+ };
129
193
 
130
194
  /**
131
195
  * Get order message hash
@@ -148,7 +212,7 @@ exports.generate_keypair_from_eth_signature = generate_keypair_from_eth_signatur
148
212
  * @param {string} domain_revision
149
213
  * @returns {string}
150
214
  */
151
- function get_order_msg_hash(position_id, base_asset_id, base_amount, quote_asset_id, quote_amount, fee_amount, fee_asset_id, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision) {
215
+ exports.get_order_msg_hash = function(position_id, base_asset_id, base_amount, quote_asset_id, quote_amount, fee_amount, fee_asset_id, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision) {
152
216
  let deferred12_0;
153
217
  let deferred12_1;
154
218
  try {
@@ -181,8 +245,7 @@ function get_order_msg_hash(position_id, base_asset_id, base_amount, quote_asset
181
245
  } finally {
182
246
  wasm.__wbindgen_free(deferred12_0, deferred12_1, 1);
183
247
  }
184
- }
185
- exports.get_order_msg_hash = get_order_msg_hash;
248
+ };
186
249
 
187
250
  /**
188
251
  * Get transfer message hash
@@ -202,7 +265,7 @@ exports.get_order_msg_hash = get_order_msg_hash;
202
265
  * @param {string} collateral_id
203
266
  * @returns {string}
204
267
  */
205
- function get_transfer_msg_hash(recipient_position_id, sender_position_id, amount, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision, collateral_id) {
268
+ exports.get_transfer_msg_hash = function(recipient_position_id, sender_position_id, amount, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision, collateral_id) {
206
269
  let deferred9_0;
207
270
  let deferred9_1;
208
271
  try {
@@ -229,8 +292,7 @@ function get_transfer_msg_hash(recipient_position_id, sender_position_id, amount
229
292
  } finally {
230
293
  wasm.__wbindgen_free(deferred9_0, deferred9_1, 1);
231
294
  }
232
- }
233
- exports.get_transfer_msg_hash = get_transfer_msg_hash;
295
+ };
234
296
 
235
297
  /**
236
298
  * Get withdrawal message hash
@@ -250,7 +312,7 @@ exports.get_transfer_msg_hash = get_transfer_msg_hash;
250
312
  * @param {string} collateral_id
251
313
  * @returns {string}
252
314
  */
253
- function get_withdrawal_msg_hash(recipient_hex, position_id, amount, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision, collateral_id) {
315
+ exports.get_withdrawal_msg_hash = function(recipient_hex, position_id, amount, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision, collateral_id) {
254
316
  let deferred10_0;
255
317
  let deferred10_1;
256
318
  try {
@@ -279,77 +341,11 @@ function get_withdrawal_msg_hash(recipient_hex, position_id, amount, expiration,
279
341
  } finally {
280
342
  wasm.__wbindgen_free(deferred10_0, deferred10_1, 1);
281
343
  }
282
- }
283
- exports.get_withdrawal_msg_hash = get_withdrawal_msg_hash;
284
-
285
- /**
286
- * Initialize the WASM module
287
- */
288
- function init() {
289
- wasm.main();
290
- }
291
- exports.init = init;
344
+ };
292
345
 
293
- function main() {
346
+ exports.main = function() {
294
347
  wasm.main();
295
- }
296
- exports.main = main;
297
-
298
- /**
299
- * Compute Pedersen hash of two field elements
300
- *
301
- * # Arguments
302
- * * `a` - First field element as hex string
303
- * * `b` - Second field element as hex string
304
- *
305
- * # Returns
306
- * Hash result as hex string
307
- * @param {string} a
308
- * @param {string} b
309
- * @returns {string}
310
- */
311
- function pedersen_hash(a, b) {
312
- let deferred3_0;
313
- let deferred3_1;
314
- try {
315
- const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
316
- const len0 = WASM_VECTOR_LEN;
317
- const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
318
- const len1 = WASM_VECTOR_LEN;
319
- const ret = wasm.pedersen_hash(ptr0, len0, ptr1, len1);
320
- deferred3_0 = ret[0];
321
- deferred3_1 = ret[1];
322
- return getStringFromWasm0(ret[0], ret[1]);
323
- } finally {
324
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
325
- }
326
- }
327
- exports.pedersen_hash = pedersen_hash;
328
-
329
- /**
330
- * Sign a message hash with a private key
331
- *
332
- * # Arguments
333
- * * `private_key` - Private key as hex string (e.g., "0x123...")
334
- * * `msg_hash` - Message hash as hex string (e.g., "0x456...")
335
- *
336
- * # Returns
337
- * Array of two hex strings: [r, s]
338
- * @param {string} private_key
339
- * @param {string} msg_hash
340
- * @returns {string[]}
341
- */
342
- function sign(private_key, msg_hash) {
343
- const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
344
- const len0 = WASM_VECTOR_LEN;
345
- const ptr1 = passStringToWasm0(msg_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
346
- const len1 = WASM_VECTOR_LEN;
347
- const ret = wasm.sign(ptr0, len0, ptr1, len1);
348
- var v3 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
349
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
350
- return v3;
351
- }
352
- exports.sign = sign;
348
+ };
353
349
 
354
350
  exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
355
351
  // Cast intrinsic for `Ref(String) -> Externref`.
@@ -365,6 +361,7 @@ exports.__wbindgen_init_externref_table = function() {
365
361
  table.set(offset + 1, null);
366
362
  table.set(offset + 2, true);
367
363
  table.set(offset + 3, false);
364
+ ;
368
365
  };
369
366
 
370
367
  const wasmPath = `${__dirname}/stark_crypto_wasm_bg.wasm`;
@@ -373,3 +370,4 @@ const wasmModule = new WebAssembly.Module(wasmBytes);
373
370
  const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
374
371
 
375
372
  wasm.__wbindgen_start();
373
+
@@ -0,0 +1,365 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
17
+
18
+ cachedTextDecoder.decode();
19
+
20
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
21
+ let numBytesDecoded = 0;
22
+ function decodeText(ptr, len) {
23
+ numBytesDecoded += len;
24
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
25
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
+ cachedTextDecoder.decode();
27
+ numBytesDecoded = len;
28
+ }
29
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
30
+ }
31
+
32
+ function getStringFromWasm0(ptr, len) {
33
+ ptr = ptr >>> 0;
34
+ return decodeText(ptr, len);
35
+ }
36
+ /**
37
+ * Initialize the WASM module
38
+ */
39
+ export function init() {
40
+ wasm.main();
41
+ }
42
+
43
+ let WASM_VECTOR_LEN = 0;
44
+
45
+ const cachedTextEncoder = new TextEncoder();
46
+
47
+ if (!('encodeInto' in cachedTextEncoder)) {
48
+ cachedTextEncoder.encodeInto = function (arg, view) {
49
+ const buf = cachedTextEncoder.encode(arg);
50
+ view.set(buf);
51
+ return {
52
+ read: arg.length,
53
+ written: buf.length
54
+ };
55
+ }
56
+ }
57
+
58
+ function passStringToWasm0(arg, malloc, realloc) {
59
+
60
+ if (realloc === undefined) {
61
+ const buf = cachedTextEncoder.encode(arg);
62
+ const ptr = malloc(buf.length, 1) >>> 0;
63
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
64
+ WASM_VECTOR_LEN = buf.length;
65
+ return ptr;
66
+ }
67
+
68
+ let len = arg.length;
69
+ let ptr = malloc(len, 1) >>> 0;
70
+
71
+ const mem = getUint8ArrayMemory0();
72
+
73
+ let offset = 0;
74
+
75
+ for (; offset < len; offset++) {
76
+ const code = arg.charCodeAt(offset);
77
+ if (code > 0x7F) break;
78
+ mem[ptr + offset] = code;
79
+ }
80
+
81
+ if (offset !== len) {
82
+ if (offset !== 0) {
83
+ arg = arg.slice(offset);
84
+ }
85
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
86
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
87
+ const ret = cachedTextEncoder.encodeInto(arg, view);
88
+
89
+ offset += ret.written;
90
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
91
+ }
92
+
93
+ WASM_VECTOR_LEN = offset;
94
+ return ptr;
95
+ }
96
+
97
+ let cachedDataViewMemory0 = null;
98
+
99
+ function getDataViewMemory0() {
100
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
101
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
102
+ }
103
+ return cachedDataViewMemory0;
104
+ }
105
+
106
+ function getArrayJsValueFromWasm0(ptr, len) {
107
+ ptr = ptr >>> 0;
108
+ const mem = getDataViewMemory0();
109
+ const result = [];
110
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
111
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
112
+ }
113
+ wasm.__externref_drop_slice(ptr, len);
114
+ return result;
115
+ }
116
+ /**
117
+ * Sign a message hash with a private key
118
+ *
119
+ * # Arguments
120
+ * * `private_key` - Private key as hex string (e.g., "0x123...")
121
+ * * `msg_hash` - Message hash as hex string (e.g., "0x456...")
122
+ *
123
+ * # Returns
124
+ * Array of two hex strings: [r, s]
125
+ * @param {string} private_key
126
+ * @param {string} msg_hash
127
+ * @returns {string[]}
128
+ */
129
+ export function sign(private_key, msg_hash) {
130
+ const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ const ptr1 = passStringToWasm0(msg_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
+ const len1 = WASM_VECTOR_LEN;
134
+ const ret = wasm.sign(ptr0, len0, ptr1, len1);
135
+ var v3 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
136
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
137
+ return v3;
138
+ }
139
+
140
+ /**
141
+ * Compute Pedersen hash of two field elements
142
+ *
143
+ * # Arguments
144
+ * * `a` - First field element as hex string
145
+ * * `b` - Second field element as hex string
146
+ *
147
+ * # Returns
148
+ * Hash result as hex string
149
+ * @param {string} a
150
+ * @param {string} b
151
+ * @returns {string}
152
+ */
153
+ export function pedersen_hash(a, b) {
154
+ let deferred3_0;
155
+ let deferred3_1;
156
+ try {
157
+ const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
158
+ const len0 = WASM_VECTOR_LEN;
159
+ const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
160
+ const len1 = WASM_VECTOR_LEN;
161
+ const ret = wasm.pedersen_hash(ptr0, len0, ptr1, len1);
162
+ deferred3_0 = ret[0];
163
+ deferred3_1 = ret[1];
164
+ return getStringFromWasm0(ret[0], ret[1]);
165
+ } finally {
166
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Generate Stark keypair from Ethereum signature
172
+ *
173
+ * This function derives a Stark keypair from an Ethereum signature.
174
+ * Uses the exact implementation compatible with Extended Exchange API.
175
+ *
176
+ * # Arguments
177
+ * * `eth_signature` - Ethereum signature as hex string (65 bytes: r(32) + s(32) + v(1))
178
+ *
179
+ * # Returns
180
+ * Array of two hex strings: [private_key, public_key]
181
+ * @param {string} eth_signature
182
+ * @returns {string[]}
183
+ */
184
+ export function generate_keypair_from_eth_signature(eth_signature) {
185
+ const ptr0 = passStringToWasm0(eth_signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
186
+ const len0 = WASM_VECTOR_LEN;
187
+ const ret = wasm.generate_keypair_from_eth_signature(ptr0, len0);
188
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
189
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
190
+ return v2;
191
+ }
192
+
193
+ /**
194
+ * Get order message hash
195
+ *
196
+ * Computes the structured hash for an order according to StarkEx protocol.
197
+ * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
198
+ * @param {bigint} position_id
199
+ * @param {string} base_asset_id
200
+ * @param {string} base_amount
201
+ * @param {string} quote_asset_id
202
+ * @param {string} quote_amount
203
+ * @param {string} fee_amount
204
+ * @param {string} fee_asset_id
205
+ * @param {bigint} expiration
206
+ * @param {bigint} salt
207
+ * @param {string} user_public_key
208
+ * @param {string} domain_name
209
+ * @param {string} domain_version
210
+ * @param {string} domain_chain_id
211
+ * @param {string} domain_revision
212
+ * @returns {string}
213
+ */
214
+ export function get_order_msg_hash(position_id, base_asset_id, base_amount, quote_asset_id, quote_amount, fee_amount, fee_asset_id, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision) {
215
+ let deferred12_0;
216
+ let deferred12_1;
217
+ try {
218
+ const ptr0 = passStringToWasm0(base_asset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
219
+ const len0 = WASM_VECTOR_LEN;
220
+ const ptr1 = passStringToWasm0(base_amount, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
221
+ const len1 = WASM_VECTOR_LEN;
222
+ const ptr2 = passStringToWasm0(quote_asset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
223
+ const len2 = WASM_VECTOR_LEN;
224
+ const ptr3 = passStringToWasm0(quote_amount, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
225
+ const len3 = WASM_VECTOR_LEN;
226
+ const ptr4 = passStringToWasm0(fee_amount, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
227
+ const len4 = WASM_VECTOR_LEN;
228
+ const ptr5 = passStringToWasm0(fee_asset_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
229
+ const len5 = WASM_VECTOR_LEN;
230
+ const ptr6 = passStringToWasm0(user_public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
231
+ const len6 = WASM_VECTOR_LEN;
232
+ const ptr7 = passStringToWasm0(domain_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
233
+ const len7 = WASM_VECTOR_LEN;
234
+ const ptr8 = passStringToWasm0(domain_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
235
+ const len8 = WASM_VECTOR_LEN;
236
+ const ptr9 = passStringToWasm0(domain_chain_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
237
+ const len9 = WASM_VECTOR_LEN;
238
+ const ptr10 = passStringToWasm0(domain_revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
239
+ const len10 = WASM_VECTOR_LEN;
240
+ const ret = wasm.get_order_msg_hash(position_id, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, expiration, salt, ptr6, len6, ptr7, len7, ptr8, len8, ptr9, len9, ptr10, len10);
241
+ deferred12_0 = ret[0];
242
+ deferred12_1 = ret[1];
243
+ return getStringFromWasm0(ret[0], ret[1]);
244
+ } finally {
245
+ wasm.__wbindgen_free(deferred12_0, deferred12_1, 1);
246
+ }
247
+ }
248
+
249
+ /**
250
+ * Get transfer message hash
251
+ *
252
+ * Computes the structured hash for a transfer according to StarkEx protocol.
253
+ * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
254
+ * @param {bigint} recipient_position_id
255
+ * @param {bigint} sender_position_id
256
+ * @param {string} amount
257
+ * @param {bigint} expiration
258
+ * @param {string} salt
259
+ * @param {string} user_public_key
260
+ * @param {string} domain_name
261
+ * @param {string} domain_version
262
+ * @param {string} domain_chain_id
263
+ * @param {string} domain_revision
264
+ * @param {string} collateral_id
265
+ * @returns {string}
266
+ */
267
+ export function get_transfer_msg_hash(recipient_position_id, sender_position_id, amount, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision, collateral_id) {
268
+ let deferred9_0;
269
+ let deferred9_1;
270
+ try {
271
+ const ptr0 = passStringToWasm0(amount, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
272
+ const len0 = WASM_VECTOR_LEN;
273
+ const ptr1 = passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
274
+ const len1 = WASM_VECTOR_LEN;
275
+ const ptr2 = passStringToWasm0(user_public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
276
+ const len2 = WASM_VECTOR_LEN;
277
+ const ptr3 = passStringToWasm0(domain_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
278
+ const len3 = WASM_VECTOR_LEN;
279
+ const ptr4 = passStringToWasm0(domain_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
280
+ const len4 = WASM_VECTOR_LEN;
281
+ const ptr5 = passStringToWasm0(domain_chain_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
282
+ const len5 = WASM_VECTOR_LEN;
283
+ const ptr6 = passStringToWasm0(domain_revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
284
+ const len6 = WASM_VECTOR_LEN;
285
+ const ptr7 = passStringToWasm0(collateral_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
286
+ const len7 = WASM_VECTOR_LEN;
287
+ const ret = wasm.get_transfer_msg_hash(recipient_position_id, sender_position_id, ptr0, len0, expiration, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
288
+ deferred9_0 = ret[0];
289
+ deferred9_1 = ret[1];
290
+ return getStringFromWasm0(ret[0], ret[1]);
291
+ } finally {
292
+ wasm.__wbindgen_free(deferred9_0, deferred9_1, 1);
293
+ }
294
+ }
295
+
296
+ /**
297
+ * Get withdrawal message hash
298
+ *
299
+ * Computes the structured hash for a withdrawal according to StarkEx protocol.
300
+ * Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
301
+ * @param {string} recipient_hex
302
+ * @param {bigint} position_id
303
+ * @param {string} amount
304
+ * @param {bigint} expiration
305
+ * @param {string} salt
306
+ * @param {string} user_public_key
307
+ * @param {string} domain_name
308
+ * @param {string} domain_version
309
+ * @param {string} domain_chain_id
310
+ * @param {string} domain_revision
311
+ * @param {string} collateral_id
312
+ * @returns {string}
313
+ */
314
+ export function get_withdrawal_msg_hash(recipient_hex, position_id, amount, expiration, salt, user_public_key, domain_name, domain_version, domain_chain_id, domain_revision, collateral_id) {
315
+ let deferred10_0;
316
+ let deferred10_1;
317
+ try {
318
+ const ptr0 = passStringToWasm0(recipient_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
319
+ const len0 = WASM_VECTOR_LEN;
320
+ const ptr1 = passStringToWasm0(amount, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
321
+ const len1 = WASM_VECTOR_LEN;
322
+ const ptr2 = passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
323
+ const len2 = WASM_VECTOR_LEN;
324
+ const ptr3 = passStringToWasm0(user_public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
325
+ const len3 = WASM_VECTOR_LEN;
326
+ const ptr4 = passStringToWasm0(domain_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
327
+ const len4 = WASM_VECTOR_LEN;
328
+ const ptr5 = passStringToWasm0(domain_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
329
+ const len5 = WASM_VECTOR_LEN;
330
+ const ptr6 = passStringToWasm0(domain_chain_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
331
+ const len6 = WASM_VECTOR_LEN;
332
+ const ptr7 = passStringToWasm0(domain_revision, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
333
+ const len7 = WASM_VECTOR_LEN;
334
+ const ptr8 = passStringToWasm0(collateral_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
335
+ const len8 = WASM_VECTOR_LEN;
336
+ const ret = wasm.get_withdrawal_msg_hash(ptr0, len0, position_id, ptr1, len1, expiration, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8);
337
+ deferred10_0 = ret[0];
338
+ deferred10_1 = ret[1];
339
+ return getStringFromWasm0(ret[0], ret[1]);
340
+ } finally {
341
+ wasm.__wbindgen_free(deferred10_0, deferred10_1, 1);
342
+ }
343
+ }
344
+
345
+ export function main() {
346
+ wasm.main();
347
+ }
348
+
349
+ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
350
+ // Cast intrinsic for `Ref(String) -> Externref`.
351
+ const ret = getStringFromWasm0(arg0, arg1);
352
+ return ret;
353
+ };
354
+
355
+ export function __wbindgen_init_externref_table() {
356
+ const table = wasm.__wbindgen_externrefs;
357
+ const offset = table.grow(4);
358
+ table.set(0, undefined);
359
+ table.set(offset + 0, undefined);
360
+ table.set(offset + 1, null);
361
+ table.set(offset + 2, true);
362
+ table.set(offset + 3, false);
363
+ ;
364
+ };
365
+
Binary file
Binary file