extended-typescript-sdk 0.0.2 → 0.0.4
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/README.md +539 -445
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/perpetual/accounts.d.ts +64 -5
- package/dist/perpetual/accounts.d.ts.map +1 -1
- package/dist/perpetual/accounts.js +90 -6
- package/dist/perpetual/accounts.js.map +1 -1
- package/dist/perpetual/crypto/signer.d.ts.map +1 -1
- package/dist/perpetual/crypto/signer.js +24 -14
- package/dist/perpetual/crypto/signer.js.map +1 -1
- package/dist/perpetual/custom-signer.d.ts +51 -0
- package/dist/perpetual/custom-signer.d.ts.map +1 -0
- package/dist/perpetual/custom-signer.js +18 -0
- package/dist/perpetual/custom-signer.js.map +1 -0
- package/dist/perpetual/order-object-settlement.d.ts +3 -3
- package/dist/perpetual/order-object-settlement.d.ts.map +1 -1
- package/dist/perpetual/order-object-settlement.js +2 -2
- package/dist/perpetual/order-object-settlement.js.map +1 -1
- package/dist/perpetual/order-object.d.ts +1 -1
- package/dist/perpetual/order-object.d.ts.map +1 -1
- package/dist/perpetual/order-object.js +4 -4
- package/dist/perpetual/order-object.js.map +1 -1
- package/dist/perpetual/stream-client/stream-client.d.ts +16 -0
- package/dist/perpetual/stream-client/stream-client.d.ts.map +1 -1
- package/dist/perpetual/stream-client/stream-client.js +28 -0
- package/dist/perpetual/stream-client/stream-client.js.map +1 -1
- package/dist/perpetual/trading-client/account-module.d.ts.map +1 -1
- package/dist/perpetual/trading-client/account-module.js +9 -7
- package/dist/perpetual/trading-client/account-module.js.map +1 -1
- package/dist/perpetual/trading-client/trading-client.js +1 -1
- package/dist/perpetual/trading-client/trading-client.js.map +1 -1
- package/dist/perpetual/transfer-object.d.ts +1 -1
- package/dist/perpetual/transfer-object.d.ts.map +1 -1
- package/dist/perpetual/transfer-object.js +2 -2
- package/dist/perpetual/transfer-object.js.map +1 -1
- package/dist/perpetual/user-client/user-client.js +4 -4
- package/dist/perpetual/user-client/user-client.js.map +1 -1
- package/dist/perpetual/withdrawal-object.d.ts +1 -1
- package/dist/perpetual/withdrawal-object.d.ts.map +1 -1
- package/dist/perpetual/withdrawal-object.js +2 -2
- package/dist/perpetual/withdrawal-object.js.map +1 -1
- package/package.json +60 -60
- package/wasm/stark_crypto_wasm.d-web.ts +34 -26
- package/wasm/stark_crypto_wasm.d.ts +34 -26
- package/wasm/stark_crypto_wasm.js +125 -112
- package/wasm/stark_crypto_wasm_bg-web.wasm +0 -0
- package/wasm/stark_crypto_wasm_bg.wasm +0 -0
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
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;
|
|
3
|
+
|
|
29
4
|
/**
|
|
30
5
|
* Generate Stark keypair from Ethereum signature
|
|
31
6
|
*
|
|
@@ -39,6 +14,7 @@ export function pedersen_hash(a: string, b: string): string;
|
|
|
39
14
|
* Array of two hex strings: [private_key, public_key]
|
|
40
15
|
*/
|
|
41
16
|
export function generate_keypair_from_eth_signature(eth_signature: string): string[];
|
|
17
|
+
|
|
42
18
|
/**
|
|
43
19
|
* Get order message hash
|
|
44
20
|
*
|
|
@@ -46,6 +22,7 @@ export function generate_keypair_from_eth_signature(eth_signature: string): stri
|
|
|
46
22
|
* Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
|
|
47
23
|
*/
|
|
48
24
|
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
|
+
|
|
49
26
|
/**
|
|
50
27
|
* Get transfer message hash
|
|
51
28
|
*
|
|
@@ -53,6 +30,7 @@ export function get_order_msg_hash(position_id: bigint, base_asset_id: string, b
|
|
|
53
30
|
* Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
|
|
54
31
|
*/
|
|
55
32
|
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
|
+
|
|
56
34
|
/**
|
|
57
35
|
* Get withdrawal message hash
|
|
58
36
|
*
|
|
@@ -60,4 +38,34 @@ export function get_transfer_msg_hash(recipient_position_id: bigint, sender_posi
|
|
|
60
38
|
* Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
|
|
61
39
|
*/
|
|
62
40
|
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
|
+
|
|
63
47
|
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,31 +1,6 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
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;
|
|
3
|
+
|
|
29
4
|
/**
|
|
30
5
|
* Generate Stark keypair from Ethereum signature
|
|
31
6
|
*
|
|
@@ -39,6 +14,7 @@ export function pedersen_hash(a: string, b: string): string;
|
|
|
39
14
|
* Array of two hex strings: [private_key, public_key]
|
|
40
15
|
*/
|
|
41
16
|
export function generate_keypair_from_eth_signature(eth_signature: string): string[];
|
|
17
|
+
|
|
42
18
|
/**
|
|
43
19
|
* Get order message hash
|
|
44
20
|
*
|
|
@@ -46,6 +22,7 @@ export function generate_keypair_from_eth_signature(eth_signature: string): stri
|
|
|
46
22
|
* Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
|
|
47
23
|
*/
|
|
48
24
|
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
|
+
|
|
49
26
|
/**
|
|
50
27
|
* Get transfer message hash
|
|
51
28
|
*
|
|
@@ -53,6 +30,7 @@ export function get_order_msg_hash(position_id: bigint, base_asset_id: string, b
|
|
|
53
30
|
* Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
|
|
54
31
|
*/
|
|
55
32
|
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
|
+
|
|
56
34
|
/**
|
|
57
35
|
* Get withdrawal message hash
|
|
58
36
|
*
|
|
@@ -60,4 +38,34 @@ export function get_transfer_msg_hash(recipient_position_id: bigint, sender_posi
|
|
|
60
38
|
* Reimplements exact logic from rust-crypto-lib-base using WASM-compatible types.
|
|
61
39
|
*/
|
|
62
40
|
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
|
+
|
|
63
47
|
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,52 +1,51 @@
|
|
|
1
1
|
|
|
2
2
|
let imports = {};
|
|
3
|
-
|
|
3
|
+
// Create a proxy object that will forward to exports once they're defined
|
|
4
|
+
imports['__wbindgen_placeholder__'] = new Proxy({}, {
|
|
5
|
+
get: (target, prop) => {
|
|
6
|
+
return exports[prop];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
// Also handle the "./stark_crypto_wasm_bg.js" import that wasm-bindgen expects
|
|
10
|
+
imports['./stark_crypto_wasm_bg.js'] = new Proxy({}, {
|
|
11
|
+
get: (target, prop) => {
|
|
12
|
+
return exports[prop];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
4
15
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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)));
|
|
10
22
|
}
|
|
11
|
-
|
|
23
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
24
|
+
return result;
|
|
12
25
|
}
|
|
13
26
|
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
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;
|
|
20
33
|
}
|
|
21
34
|
|
|
22
35
|
function getStringFromWasm0(ptr, len) {
|
|
23
36
|
ptr = ptr >>> 0;
|
|
24
37
|
return decodeText(ptr, len);
|
|
25
38
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Initialize the WASM module
|
|
28
|
-
*/
|
|
29
|
-
exports.init = function() {
|
|
30
|
-
wasm.main();
|
|
31
|
-
};
|
|
32
39
|
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
38
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
39
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
40
|
-
view.set(buf);
|
|
41
|
-
return {
|
|
42
|
-
read: arg.length,
|
|
43
|
-
written: buf.length
|
|
44
|
-
};
|
|
40
|
+
let cachedUint8ArrayMemory0 = null;
|
|
41
|
+
function getUint8ArrayMemory0() {
|
|
42
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
43
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
45
44
|
}
|
|
45
|
+
return cachedUint8ArrayMemory0;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
49
|
-
|
|
50
49
|
if (realloc === undefined) {
|
|
51
50
|
const buf = cachedTextEncoder.encode(arg);
|
|
52
51
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
@@ -67,7 +66,6 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
67
66
|
if (code > 0x7F) break;
|
|
68
67
|
mem[ptr + offset] = code;
|
|
69
68
|
}
|
|
70
|
-
|
|
71
69
|
if (offset !== len) {
|
|
72
70
|
if (offset !== 0) {
|
|
73
71
|
arg = arg.slice(offset);
|
|
@@ -84,78 +82,26 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
84
82
|
return ptr;
|
|
85
83
|
}
|
|
86
84
|
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
92
|
-
}
|
|
93
|
-
return cachedDataViewMemory0;
|
|
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));
|
|
94
89
|
}
|
|
95
90
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
const cachedTextEncoder = new TextEncoder();
|
|
92
|
+
|
|
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
|
+
};
|
|
102
101
|
}
|
|
103
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
104
|
-
return result;
|
|
105
102
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Sign a message hash with a private key
|
|
108
|
-
*
|
|
109
|
-
* # Arguments
|
|
110
|
-
* * `private_key` - Private key as hex string (e.g., "0x123...")
|
|
111
|
-
* * `msg_hash` - Message hash as hex string (e.g., "0x456...")
|
|
112
|
-
*
|
|
113
|
-
* # Returns
|
|
114
|
-
* Array of two hex strings: [r, s]
|
|
115
|
-
* @param {string} private_key
|
|
116
|
-
* @param {string} msg_hash
|
|
117
|
-
* @returns {string[]}
|
|
118
|
-
*/
|
|
119
|
-
exports.sign = function(private_key, msg_hash) {
|
|
120
|
-
const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
121
|
-
const len0 = WASM_VECTOR_LEN;
|
|
122
|
-
const ptr1 = passStringToWasm0(msg_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
123
|
-
const len1 = WASM_VECTOR_LEN;
|
|
124
|
-
const ret = wasm.sign(ptr0, len0, ptr1, len1);
|
|
125
|
-
var v3 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
126
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
127
|
-
return v3;
|
|
128
|
-
};
|
|
129
103
|
|
|
130
|
-
|
|
131
|
-
* Compute Pedersen hash of two field elements
|
|
132
|
-
*
|
|
133
|
-
* # Arguments
|
|
134
|
-
* * `a` - First field element as hex string
|
|
135
|
-
* * `b` - Second field element as hex string
|
|
136
|
-
*
|
|
137
|
-
* # Returns
|
|
138
|
-
* Hash result as hex string
|
|
139
|
-
* @param {string} a
|
|
140
|
-
* @param {string} b
|
|
141
|
-
* @returns {string}
|
|
142
|
-
*/
|
|
143
|
-
exports.pedersen_hash = function(a, b) {
|
|
144
|
-
let deferred3_0;
|
|
145
|
-
let deferred3_1;
|
|
146
|
-
try {
|
|
147
|
-
const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
148
|
-
const len0 = WASM_VECTOR_LEN;
|
|
149
|
-
const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
150
|
-
const len1 = WASM_VECTOR_LEN;
|
|
151
|
-
const ret = wasm.pedersen_hash(ptr0, len0, ptr1, len1);
|
|
152
|
-
deferred3_0 = ret[0];
|
|
153
|
-
deferred3_1 = ret[1];
|
|
154
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
155
|
-
} finally {
|
|
156
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
104
|
+
let WASM_VECTOR_LEN = 0;
|
|
159
105
|
|
|
160
106
|
/**
|
|
161
107
|
* Generate Stark keypair from Ethereum signature
|
|
@@ -171,14 +117,15 @@ exports.pedersen_hash = function(a, b) {
|
|
|
171
117
|
* @param {string} eth_signature
|
|
172
118
|
* @returns {string[]}
|
|
173
119
|
*/
|
|
174
|
-
|
|
120
|
+
function generate_keypair_from_eth_signature(eth_signature) {
|
|
175
121
|
const ptr0 = passStringToWasm0(eth_signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
176
122
|
const len0 = WASM_VECTOR_LEN;
|
|
177
123
|
const ret = wasm.generate_keypair_from_eth_signature(ptr0, len0);
|
|
178
124
|
var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
179
125
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
180
126
|
return v2;
|
|
181
|
-
}
|
|
127
|
+
}
|
|
128
|
+
exports.generate_keypair_from_eth_signature = generate_keypair_from_eth_signature;
|
|
182
129
|
|
|
183
130
|
/**
|
|
184
131
|
* Get order message hash
|
|
@@ -201,7 +148,7 @@ exports.generate_keypair_from_eth_signature = function(eth_signature) {
|
|
|
201
148
|
* @param {string} domain_revision
|
|
202
149
|
* @returns {string}
|
|
203
150
|
*/
|
|
204
|
-
|
|
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) {
|
|
205
152
|
let deferred12_0;
|
|
206
153
|
let deferred12_1;
|
|
207
154
|
try {
|
|
@@ -234,7 +181,8 @@ exports.get_order_msg_hash = function(position_id, base_asset_id, base_amount, q
|
|
|
234
181
|
} finally {
|
|
235
182
|
wasm.__wbindgen_free(deferred12_0, deferred12_1, 1);
|
|
236
183
|
}
|
|
237
|
-
}
|
|
184
|
+
}
|
|
185
|
+
exports.get_order_msg_hash = get_order_msg_hash;
|
|
238
186
|
|
|
239
187
|
/**
|
|
240
188
|
* Get transfer message hash
|
|
@@ -254,7 +202,7 @@ exports.get_order_msg_hash = function(position_id, base_asset_id, base_amount, q
|
|
|
254
202
|
* @param {string} collateral_id
|
|
255
203
|
* @returns {string}
|
|
256
204
|
*/
|
|
257
|
-
|
|
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) {
|
|
258
206
|
let deferred9_0;
|
|
259
207
|
let deferred9_1;
|
|
260
208
|
try {
|
|
@@ -281,7 +229,8 @@ exports.get_transfer_msg_hash = function(recipient_position_id, sender_position_
|
|
|
281
229
|
} finally {
|
|
282
230
|
wasm.__wbindgen_free(deferred9_0, deferred9_1, 1);
|
|
283
231
|
}
|
|
284
|
-
}
|
|
232
|
+
}
|
|
233
|
+
exports.get_transfer_msg_hash = get_transfer_msg_hash;
|
|
285
234
|
|
|
286
235
|
/**
|
|
287
236
|
* Get withdrawal message hash
|
|
@@ -301,7 +250,7 @@ exports.get_transfer_msg_hash = function(recipient_position_id, sender_position_
|
|
|
301
250
|
* @param {string} collateral_id
|
|
302
251
|
* @returns {string}
|
|
303
252
|
*/
|
|
304
|
-
|
|
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) {
|
|
305
254
|
let deferred10_0;
|
|
306
255
|
let deferred10_1;
|
|
307
256
|
try {
|
|
@@ -330,11 +279,77 @@ exports.get_withdrawal_msg_hash = function(recipient_hex, position_id, amount, e
|
|
|
330
279
|
} finally {
|
|
331
280
|
wasm.__wbindgen_free(deferred10_0, deferred10_1, 1);
|
|
332
281
|
}
|
|
333
|
-
}
|
|
282
|
+
}
|
|
283
|
+
exports.get_withdrawal_msg_hash = get_withdrawal_msg_hash;
|
|
334
284
|
|
|
335
|
-
|
|
285
|
+
/**
|
|
286
|
+
* Initialize the WASM module
|
|
287
|
+
*/
|
|
288
|
+
function init() {
|
|
336
289
|
wasm.main();
|
|
337
|
-
}
|
|
290
|
+
}
|
|
291
|
+
exports.init = init;
|
|
292
|
+
|
|
293
|
+
function main() {
|
|
294
|
+
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;
|
|
338
353
|
|
|
339
354
|
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
340
355
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
@@ -350,7 +365,6 @@ exports.__wbindgen_init_externref_table = function() {
|
|
|
350
365
|
table.set(offset + 1, null);
|
|
351
366
|
table.set(offset + 2, true);
|
|
352
367
|
table.set(offset + 3, false);
|
|
353
|
-
;
|
|
354
368
|
};
|
|
355
369
|
|
|
356
370
|
const wasmPath = `${__dirname}/stark_crypto_wasm_bg.wasm`;
|
|
@@ -359,4 +373,3 @@ const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
|
359
373
|
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
360
374
|
|
|
361
375
|
wasm.__wbindgen_start();
|
|
362
|
-
|
|
Binary file
|
|
Binary file
|