@rolly-dev/wasm-signer 1.31.2 → 1.31.3
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/dist/web/README.md +103 -0
- package/dist/web/rolly_wasm_signer.d.ts +667 -0
- package/dist/web/rolly_wasm_signer.js +1917 -0
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +69 -0
- package/js/browser.mjs +65 -0
- package/js/react.d.mts +7 -0
- package/js/react.mjs +162 -0
- package/package.json +25 -6
|
Binary file
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const amount_split: (a: number, b: bigint) => void;
|
|
5
|
+
export const aviato_rtp_percent: () => number;
|
|
6
|
+
export const blackjack_deal_shoe: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
7
|
+
export const blackjack_pack_actions: (a: number, b: number, c: number) => void;
|
|
8
|
+
export const coinflip_multiplier_x10000: () => number;
|
|
9
|
+
export const compute_address_hash: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const compute_aviato_point: (a: number, b: number) => number;
|
|
11
|
+
export const compute_crash_point: (a: number, b: number) => number;
|
|
12
|
+
export const compute_drawn_keno: (a: number, b: number, c: number) => void;
|
|
13
|
+
export const compute_multi_dice: (a: number) => bigint;
|
|
14
|
+
export const compute_payout_aviato: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
15
|
+
export const compute_payout_blackjack: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => void;
|
|
16
|
+
export const compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
17
|
+
export const compute_payout_crash: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
18
|
+
export const compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
19
|
+
export const compute_payout_keno: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
20
|
+
export const compute_payout_limbo: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
21
|
+
export const compute_payout_plinko: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
22
|
+
export const compute_prediction_hash: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
23
|
+
export const compute_prediction_hash_keno: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
24
|
+
export const compute_roll_coinflip: (a: number, b: number) => number;
|
|
25
|
+
export const compute_roll_dice: (a: number, b: number) => number;
|
|
26
|
+
export const compute_roll_limbo: (a: number, b: number) => number;
|
|
27
|
+
export const compute_roll_plinko: (a: number, b: number, c: number) => number;
|
|
28
|
+
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
29
|
+
export const compute_user_seed_binding: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => void;
|
|
30
|
+
export const derive_session_key: (a: number, b: number, c: number) => void;
|
|
31
|
+
export const encode_keno_selected: (a: number, b: number, c: number) => void;
|
|
32
|
+
export const generate_user_secret: (a: number) => void;
|
|
33
|
+
export const generate_user_seed: (a: number) => void;
|
|
34
|
+
export const goldilocks_fields_to_hex: (a: number, b: number, c: number) => void;
|
|
35
|
+
export const goldilocks_reduce: (a: bigint) => bigint;
|
|
36
|
+
export const hash_balance_leaf: (a: number, b: number, c: number) => void;
|
|
37
|
+
export const keno_all_rtp_x100: () => number;
|
|
38
|
+
export const keno_draw_count: () => number;
|
|
39
|
+
export const keno_is_valid_config: (a: number, b: number) => number;
|
|
40
|
+
export const keno_multiplier_table: (a: number, b: number, c: number) => void;
|
|
41
|
+
export const keno_numbers_range: () => number;
|
|
42
|
+
export const keno_rtp_x100: (a: number, b: number) => bigint;
|
|
43
|
+
export const limbo_rtp_percent: () => number;
|
|
44
|
+
export const make_main_leaf: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
45
|
+
export const plinko_all_rtp_x100: () => number;
|
|
46
|
+
export const plinko_is_valid_config: (a: number, b: number, c: number) => number;
|
|
47
|
+
export const plinko_is_valid_rows: (a: number) => number;
|
|
48
|
+
export const plinko_max_rows: () => number;
|
|
49
|
+
export const plinko_min_rows: () => number;
|
|
50
|
+
export const plinko_multiplier_table: (a: number, b: number, c: number, d: number) => void;
|
|
51
|
+
export const plinko_num_sectors: () => number;
|
|
52
|
+
export const plinko_rtp_x100: (a: number, b: number, c: number) => bigint;
|
|
53
|
+
export const poseidon2_hash: (a: number, b: number, c: number) => void;
|
|
54
|
+
export const poseidon2_two_to_one: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
55
|
+
export const seed_hash_truncated: (a: number, b: number, c: number) => void;
|
|
56
|
+
export const session_public_key: (a: number, b: number, c: number, d: bigint) => void;
|
|
57
|
+
export const string_to_user_seed: (a: number, b: number, c: number) => void;
|
|
58
|
+
export const string_to_user_seed_hex: (a: number, b: number, c: number) => void;
|
|
59
|
+
export const validate_slot: (a: number, b: number) => void;
|
|
60
|
+
export const coinflip_rtp_percent: () => number;
|
|
61
|
+
export const crash_rtp_percent: () => number;
|
|
62
|
+
export const dice_rtp_percent: () => number;
|
|
63
|
+
export const keno_max_picks: () => number;
|
|
64
|
+
export const goldilocks_modulus: () => bigint;
|
|
65
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
66
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
67
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
68
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
69
|
+
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
package/js/browser.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export { default as init } from '../dist/web/rolly_wasm_signer.js';
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
amount_split,
|
|
5
|
+
aviato_rtp_percent,
|
|
6
|
+
blackjack_deal_shoe,
|
|
7
|
+
blackjack_pack_actions,
|
|
8
|
+
coinflip_multiplier_x10000,
|
|
9
|
+
coinflip_rtp_percent,
|
|
10
|
+
compute_address_hash,
|
|
11
|
+
compute_aviato_point,
|
|
12
|
+
compute_crash_point,
|
|
13
|
+
compute_drawn_keno,
|
|
14
|
+
compute_multi_dice,
|
|
15
|
+
compute_payout_aviato,
|
|
16
|
+
compute_payout_blackjack,
|
|
17
|
+
compute_payout_coinflip,
|
|
18
|
+
compute_payout_crash,
|
|
19
|
+
compute_payout_dice,
|
|
20
|
+
compute_payout_keno,
|
|
21
|
+
compute_payout_limbo,
|
|
22
|
+
compute_payout_plinko,
|
|
23
|
+
compute_prediction_hash,
|
|
24
|
+
compute_prediction_hash_keno,
|
|
25
|
+
compute_roll_coinflip,
|
|
26
|
+
compute_roll_dice,
|
|
27
|
+
compute_roll_limbo,
|
|
28
|
+
compute_roll_plinko,
|
|
29
|
+
compute_server_seed_hash,
|
|
30
|
+
compute_user_seed_binding,
|
|
31
|
+
crash_rtp_percent,
|
|
32
|
+
derive_session_key,
|
|
33
|
+
dice_rtp_percent,
|
|
34
|
+
encode_keno_selected,
|
|
35
|
+
generate_user_secret,
|
|
36
|
+
generate_user_seed,
|
|
37
|
+
goldilocks_fields_to_hex,
|
|
38
|
+
goldilocks_modulus,
|
|
39
|
+
goldilocks_reduce,
|
|
40
|
+
hash_balance_leaf,
|
|
41
|
+
keno_all_rtp_x100,
|
|
42
|
+
keno_draw_count,
|
|
43
|
+
keno_is_valid_config,
|
|
44
|
+
keno_max_picks,
|
|
45
|
+
keno_multiplier_table,
|
|
46
|
+
keno_numbers_range,
|
|
47
|
+
keno_rtp_x100,
|
|
48
|
+
limbo_rtp_percent,
|
|
49
|
+
make_main_leaf,
|
|
50
|
+
plinko_all_rtp_x100,
|
|
51
|
+
plinko_is_valid_config,
|
|
52
|
+
plinko_is_valid_rows,
|
|
53
|
+
plinko_max_rows,
|
|
54
|
+
plinko_min_rows,
|
|
55
|
+
plinko_multiplier_table,
|
|
56
|
+
plinko_num_sectors,
|
|
57
|
+
plinko_rtp_x100,
|
|
58
|
+
poseidon2_hash,
|
|
59
|
+
poseidon2_two_to_one,
|
|
60
|
+
seed_hash_truncated,
|
|
61
|
+
session_public_key,
|
|
62
|
+
string_to_user_seed,
|
|
63
|
+
string_to_user_seed_hex,
|
|
64
|
+
validate_slot,
|
|
65
|
+
} from '../dist/web/rolly_wasm_signer.js';
|
package/js/react.d.mts
ADDED
package/js/react.mjs
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import init, {
|
|
3
|
+
amount_split,
|
|
4
|
+
aviato_rtp_percent,
|
|
5
|
+
blackjack_deal_shoe,
|
|
6
|
+
blackjack_pack_actions,
|
|
7
|
+
coinflip_multiplier_x10000,
|
|
8
|
+
coinflip_rtp_percent,
|
|
9
|
+
compute_address_hash,
|
|
10
|
+
compute_aviato_point,
|
|
11
|
+
compute_crash_point,
|
|
12
|
+
compute_drawn_keno,
|
|
13
|
+
compute_multi_dice,
|
|
14
|
+
compute_payout_aviato,
|
|
15
|
+
compute_payout_blackjack,
|
|
16
|
+
compute_payout_coinflip,
|
|
17
|
+
compute_payout_crash,
|
|
18
|
+
compute_payout_dice,
|
|
19
|
+
compute_payout_keno,
|
|
20
|
+
compute_payout_limbo,
|
|
21
|
+
compute_payout_plinko,
|
|
22
|
+
compute_prediction_hash,
|
|
23
|
+
compute_prediction_hash_keno,
|
|
24
|
+
compute_roll_coinflip,
|
|
25
|
+
compute_roll_dice,
|
|
26
|
+
compute_roll_limbo,
|
|
27
|
+
compute_roll_plinko,
|
|
28
|
+
compute_server_seed_hash,
|
|
29
|
+
compute_user_seed_binding,
|
|
30
|
+
crash_rtp_percent,
|
|
31
|
+
derive_session_key,
|
|
32
|
+
dice_rtp_percent,
|
|
33
|
+
encode_keno_selected,
|
|
34
|
+
generate_user_secret,
|
|
35
|
+
generate_user_seed,
|
|
36
|
+
goldilocks_fields_to_hex,
|
|
37
|
+
goldilocks_modulus,
|
|
38
|
+
goldilocks_reduce,
|
|
39
|
+
hash_balance_leaf,
|
|
40
|
+
keno_all_rtp_x100,
|
|
41
|
+
keno_draw_count,
|
|
42
|
+
keno_is_valid_config,
|
|
43
|
+
keno_max_picks,
|
|
44
|
+
keno_multiplier_table,
|
|
45
|
+
keno_numbers_range,
|
|
46
|
+
keno_rtp_x100,
|
|
47
|
+
limbo_rtp_percent,
|
|
48
|
+
make_main_leaf,
|
|
49
|
+
plinko_all_rtp_x100,
|
|
50
|
+
plinko_is_valid_config,
|
|
51
|
+
plinko_is_valid_rows,
|
|
52
|
+
plinko_max_rows,
|
|
53
|
+
plinko_min_rows,
|
|
54
|
+
plinko_multiplier_table,
|
|
55
|
+
plinko_num_sectors,
|
|
56
|
+
plinko_rtp_x100,
|
|
57
|
+
poseidon2_hash,
|
|
58
|
+
poseidon2_two_to_one,
|
|
59
|
+
seed_hash_truncated,
|
|
60
|
+
session_public_key,
|
|
61
|
+
string_to_user_seed,
|
|
62
|
+
string_to_user_seed_hex,
|
|
63
|
+
validate_slot,
|
|
64
|
+
} from '../dist/web/rolly_wasm_signer.js';
|
|
65
|
+
|
|
66
|
+
let _ready = false;
|
|
67
|
+
let _promise = null;
|
|
68
|
+
|
|
69
|
+
function guard(fn) {
|
|
70
|
+
return (...args) => {
|
|
71
|
+
if (!_ready) throw new Error('@rolly-dev/wasm-signer: WASM not initialized yet. Check ready === true before calling.');
|
|
72
|
+
return fn(...args);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const fns = {
|
|
77
|
+
amount_split: guard(amount_split),
|
|
78
|
+
aviato_rtp_percent: guard(aviato_rtp_percent),
|
|
79
|
+
blackjack_deal_shoe: guard(blackjack_deal_shoe),
|
|
80
|
+
blackjack_pack_actions: guard(blackjack_pack_actions),
|
|
81
|
+
coinflip_multiplier_x10000: guard(coinflip_multiplier_x10000),
|
|
82
|
+
coinflip_rtp_percent: guard(coinflip_rtp_percent),
|
|
83
|
+
compute_address_hash: guard(compute_address_hash),
|
|
84
|
+
compute_aviato_point: guard(compute_aviato_point),
|
|
85
|
+
compute_crash_point: guard(compute_crash_point),
|
|
86
|
+
compute_drawn_keno: guard(compute_drawn_keno),
|
|
87
|
+
compute_multi_dice: guard(compute_multi_dice),
|
|
88
|
+
compute_payout_aviato: guard(compute_payout_aviato),
|
|
89
|
+
compute_payout_blackjack: guard(compute_payout_blackjack),
|
|
90
|
+
compute_payout_coinflip: guard(compute_payout_coinflip),
|
|
91
|
+
compute_payout_crash: guard(compute_payout_crash),
|
|
92
|
+
compute_payout_dice: guard(compute_payout_dice),
|
|
93
|
+
compute_payout_keno: guard(compute_payout_keno),
|
|
94
|
+
compute_payout_limbo: guard(compute_payout_limbo),
|
|
95
|
+
compute_payout_plinko: guard(compute_payout_plinko),
|
|
96
|
+
compute_prediction_hash: guard(compute_prediction_hash),
|
|
97
|
+
compute_prediction_hash_keno:guard(compute_prediction_hash_keno),
|
|
98
|
+
compute_roll_coinflip: guard(compute_roll_coinflip),
|
|
99
|
+
compute_roll_dice: guard(compute_roll_dice),
|
|
100
|
+
compute_roll_limbo: guard(compute_roll_limbo),
|
|
101
|
+
compute_roll_plinko: guard(compute_roll_plinko),
|
|
102
|
+
compute_server_seed_hash: guard(compute_server_seed_hash),
|
|
103
|
+
compute_user_seed_binding: guard(compute_user_seed_binding),
|
|
104
|
+
crash_rtp_percent: guard(crash_rtp_percent),
|
|
105
|
+
derive_session_key: guard(derive_session_key),
|
|
106
|
+
dice_rtp_percent: guard(dice_rtp_percent),
|
|
107
|
+
encode_keno_selected: guard(encode_keno_selected),
|
|
108
|
+
generate_user_secret: guard(generate_user_secret),
|
|
109
|
+
generate_user_seed: guard(generate_user_seed),
|
|
110
|
+
goldilocks_fields_to_hex: guard(goldilocks_fields_to_hex),
|
|
111
|
+
goldilocks_modulus: guard(goldilocks_modulus),
|
|
112
|
+
goldilocks_reduce: guard(goldilocks_reduce),
|
|
113
|
+
hash_balance_leaf: guard(hash_balance_leaf),
|
|
114
|
+
keno_all_rtp_x100: guard(keno_all_rtp_x100),
|
|
115
|
+
keno_draw_count: guard(keno_draw_count),
|
|
116
|
+
keno_is_valid_config: guard(keno_is_valid_config),
|
|
117
|
+
keno_max_picks: guard(keno_max_picks),
|
|
118
|
+
keno_multiplier_table: guard(keno_multiplier_table),
|
|
119
|
+
keno_numbers_range: guard(keno_numbers_range),
|
|
120
|
+
keno_rtp_x100: guard(keno_rtp_x100),
|
|
121
|
+
limbo_rtp_percent: guard(limbo_rtp_percent),
|
|
122
|
+
make_main_leaf: guard(make_main_leaf),
|
|
123
|
+
plinko_all_rtp_x100: guard(plinko_all_rtp_x100),
|
|
124
|
+
plinko_is_valid_config: guard(plinko_is_valid_config),
|
|
125
|
+
plinko_is_valid_rows: guard(plinko_is_valid_rows),
|
|
126
|
+
plinko_max_rows: guard(plinko_max_rows),
|
|
127
|
+
plinko_min_rows: guard(plinko_min_rows),
|
|
128
|
+
plinko_multiplier_table: guard(plinko_multiplier_table),
|
|
129
|
+
plinko_num_sectors: guard(plinko_num_sectors),
|
|
130
|
+
plinko_rtp_x100: guard(plinko_rtp_x100),
|
|
131
|
+
poseidon2_hash: guard(poseidon2_hash),
|
|
132
|
+
poseidon2_two_to_one: guard(poseidon2_two_to_one),
|
|
133
|
+
seed_hash_truncated: guard(seed_hash_truncated),
|
|
134
|
+
session_public_key: guard(session_public_key),
|
|
135
|
+
string_to_user_seed: guard(string_to_user_seed),
|
|
136
|
+
string_to_user_seed_hex: guard(string_to_user_seed_hex),
|
|
137
|
+
validate_slot: guard(validate_slot),
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* React hook that initialises the WASM module once (singleton) and
|
|
142
|
+
* returns `{ ready, error, ...wasmFunctions }`.
|
|
143
|
+
*
|
|
144
|
+
* Functions are always available but will throw if called before `ready === true`.
|
|
145
|
+
*/
|
|
146
|
+
export function useRollyWasm() {
|
|
147
|
+
const [ready, setReady] = useState(_ready);
|
|
148
|
+
const [error, setError] = useState(null);
|
|
149
|
+
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
if (_ready) {
|
|
152
|
+
setReady(true);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (!_promise) {
|
|
156
|
+
_promise = init().then(() => { _ready = true; });
|
|
157
|
+
}
|
|
158
|
+
_promise.then(() => setReady(true)).catch(setError);
|
|
159
|
+
}, []);
|
|
160
|
+
|
|
161
|
+
return { ready, error, ...fns };
|
|
162
|
+
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rolly-dev/wasm-signer",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.3",
|
|
4
4
|
"description": "Poseidon2 hashing & bet signing for Rolly ZK-Rollup (WASM, Goldilocks field)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
8
|
"types": "./js/index.d.ts",
|
|
9
|
-
"
|
|
10
|
-
|
|
9
|
+
"node": {
|
|
10
|
+
"require": "./js/node-inline.cjs",
|
|
11
|
+
"import": "./js/node-inline.mjs"
|
|
12
|
+
},
|
|
13
|
+
"browser": "./js/browser.mjs",
|
|
14
|
+
"default": "./js/browser.mjs"
|
|
15
|
+
},
|
|
16
|
+
"./react": {
|
|
17
|
+
"types": "./js/react.d.mts",
|
|
18
|
+
"default": "./js/react.mjs"
|
|
19
|
+
},
|
|
20
|
+
"./init": {
|
|
21
|
+
"types": "./dist/web/rolly_wasm_signer.d.ts",
|
|
22
|
+
"default": "./dist/web/rolly_wasm_signer.js"
|
|
11
23
|
}
|
|
12
24
|
},
|
|
13
25
|
"main": "./js/node-inline.cjs",
|
|
14
|
-
"module": "./js/
|
|
26
|
+
"module": "./js/browser.mjs",
|
|
15
27
|
"types": "./js/index.d.ts",
|
|
16
28
|
"files": [
|
|
17
|
-
"dist/
|
|
18
|
-
"dist/node-inline/",
|
|
29
|
+
"dist/",
|
|
19
30
|
"js/"
|
|
20
31
|
],
|
|
21
32
|
"scripts": {
|
|
@@ -24,6 +35,14 @@
|
|
|
24
35
|
"test": "node test.js"
|
|
25
36
|
},
|
|
26
37
|
"sideEffects": false,
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"react": ">=17.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"react": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
27
46
|
"keywords": [
|
|
28
47
|
"wasm",
|
|
29
48
|
"poseidon2",
|