@rolly-dev/wasm-signer 1.7.0 → 1.9.0
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/node/rolly_wasm_signer.d.ts +21 -2
- package/dist/node/rolly_wasm_signer.js +48 -2
- package/dist/node/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/node/rolly_wasm_signer_bg.wasm.d.ts +2 -0
- package/dist/node-inline/rolly_wasm_signer.d.ts +21 -2
- package/dist/node-inline/rolly_wasm_signer.js +49 -3
- package/dist/node-inline/rolly_wasm_signer.mjs +48 -4
- package/dist/node-inline/rolly_wasm_signer_bg.wasm.d.ts +2 -0
- package/dist/web/rolly_wasm_signer.d.ts +23 -2
- package/dist/web/rolly_wasm_signer.js +46 -2
- package/dist/web/rolly_wasm_signer_bg.wasm +0 -0
- package/dist/web/rolly_wasm_signer_bg.wasm.d.ts +2 -0
- package/js/browser.mjs +2 -0
- package/js/index.d.ts +2 -0
- package/js/node-inline.cjs +2 -0
- package/js/node-inline.mjs +2 -0
- package/js/node.cjs +2 -0
- package/js/node.mjs +2 -0
- package/js/react.mjs +4 -0
- package/package.json +1 -1
|
@@ -26,6 +26,17 @@ export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
|
26
26
|
*/
|
|
27
27
|
export function compute_multi_dice(win_numbers: number): bigint;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Full coinflip payout computation — pure integer arithmetic, zero floats.
|
|
31
|
+
*
|
|
32
|
+
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
33
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
34
|
+
* `prediction`: 0 or 1.
|
|
35
|
+
*
|
|
36
|
+
* Returns `BigUint64Array[4]`: `[win_amount, roll (0|1), is_win (0|1), multiplier×10000]`.
|
|
37
|
+
*/
|
|
38
|
+
export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
|
|
39
|
+
|
|
29
40
|
/**
|
|
30
41
|
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
31
42
|
*
|
|
@@ -58,11 +69,19 @@ export function compute_payout_plinko(random: BigUint64Array, bet_atomic: bigint
|
|
|
58
69
|
* and the in-circuit `build_prediction_hash`.
|
|
59
70
|
*
|
|
60
71
|
* Semantics of p0–p2 depend on the game:
|
|
61
|
-
* Dice:
|
|
62
|
-
* Plinko:
|
|
72
|
+
* Dice: `(mode, pred_lo, pred_hi)`
|
|
73
|
+
* Plinko: `(sector, rows, is_extreme)`
|
|
74
|
+
* CoinFlip: `(prediction, 0, 0)`
|
|
63
75
|
*/
|
|
64
76
|
export function compute_prediction_hash(game_id: number, p0: number, p1: number, p2: number): BigUint64Array;
|
|
65
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Extract coinflip roll (0 or 1) from Poseidon2 random output.
|
|
80
|
+
*
|
|
81
|
+
* `random` must be exactly 4 elements. Returns `random[0] % 2`.
|
|
82
|
+
*/
|
|
83
|
+
export function compute_roll_coinflip(random: BigUint64Array): number;
|
|
84
|
+
|
|
66
85
|
/**
|
|
67
86
|
* Extract dice roll number [0, 1000) from Poseidon2 random output.
|
|
68
87
|
*
|
|
@@ -63,6 +63,36 @@ function compute_multi_dice(win_numbers) {
|
|
|
63
63
|
}
|
|
64
64
|
exports.compute_multi_dice = compute_multi_dice;
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Full coinflip payout computation — pure integer arithmetic, zero floats.
|
|
68
|
+
*
|
|
69
|
+
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
70
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
71
|
+
* `prediction`: 0 or 1.
|
|
72
|
+
*
|
|
73
|
+
* Returns `BigUint64Array[4]`: `[win_amount, roll (0|1), is_win (0|1), multiplier×10000]`.
|
|
74
|
+
* @param {BigUint64Array} random
|
|
75
|
+
* @param {bigint} bet_atomic
|
|
76
|
+
* @param {number} prediction
|
|
77
|
+
* @returns {BigUint64Array}
|
|
78
|
+
*/
|
|
79
|
+
function compute_payout_coinflip(random, bet_atomic, prediction) {
|
|
80
|
+
try {
|
|
81
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
82
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
|
|
83
|
+
const len0 = WASM_VECTOR_LEN;
|
|
84
|
+
wasm.compute_payout_coinflip(retptr, ptr0, len0, bet_atomic, prediction);
|
|
85
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
86
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
87
|
+
var v2 = getArrayU64FromWasm0(r0, r1).slice();
|
|
88
|
+
wasm.__wbindgen_export2(r0, r1 * 8, 8);
|
|
89
|
+
return v2;
|
|
90
|
+
} finally {
|
|
91
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.compute_payout_coinflip = compute_payout_coinflip;
|
|
95
|
+
|
|
66
96
|
/**
|
|
67
97
|
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
68
98
|
*
|
|
@@ -137,8 +167,9 @@ exports.compute_payout_plinko = compute_payout_plinko;
|
|
|
137
167
|
* and the in-circuit `build_prediction_hash`.
|
|
138
168
|
*
|
|
139
169
|
* Semantics of p0–p2 depend on the game:
|
|
140
|
-
* Dice:
|
|
141
|
-
* Plinko:
|
|
170
|
+
* Dice: `(mode, pred_lo, pred_hi)`
|
|
171
|
+
* Plinko: `(sector, rows, is_extreme)`
|
|
172
|
+
* CoinFlip: `(prediction, 0, 0)`
|
|
142
173
|
* @param {number} game_id
|
|
143
174
|
* @param {number} p0
|
|
144
175
|
* @param {number} p1
|
|
@@ -160,6 +191,21 @@ function compute_prediction_hash(game_id, p0, p1, p2) {
|
|
|
160
191
|
}
|
|
161
192
|
exports.compute_prediction_hash = compute_prediction_hash;
|
|
162
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Extract coinflip roll (0 or 1) from Poseidon2 random output.
|
|
196
|
+
*
|
|
197
|
+
* `random` must be exactly 4 elements. Returns `random[0] % 2`.
|
|
198
|
+
* @param {BigUint64Array} random
|
|
199
|
+
* @returns {number}
|
|
200
|
+
*/
|
|
201
|
+
function compute_roll_coinflip(random) {
|
|
202
|
+
const ptr0 = passArray64ToWasm0(random, wasm.__wbindgen_export3);
|
|
203
|
+
const len0 = WASM_VECTOR_LEN;
|
|
204
|
+
const ret = wasm.compute_roll_coinflip(ptr0, len0);
|
|
205
|
+
return ret >>> 0;
|
|
206
|
+
}
|
|
207
|
+
exports.compute_roll_coinflip = compute_roll_coinflip;
|
|
208
|
+
|
|
163
209
|
/**
|
|
164
210
|
* Extract dice roll number [0, 1000) from Poseidon2 random output.
|
|
165
211
|
*
|
|
Binary file
|
|
@@ -4,9 +4,11 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const amount_split: (a: number, b: bigint) => void;
|
|
5
5
|
export const compute_address_hash: (a: number, b: number, c: number) => void;
|
|
6
6
|
export const compute_multi_dice: (a: number) => bigint;
|
|
7
|
+
export const compute_payout_coinflip: (a: number, b: number, c: number, d: bigint, e: number) => void;
|
|
7
8
|
export const compute_payout_dice: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
8
9
|
export const compute_payout_plinko: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number) => void;
|
|
9
10
|
export const compute_prediction_hash: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
11
|
+
export const compute_roll_coinflip: (a: number, b: number) => number;
|
|
10
12
|
export const compute_roll_dice: (a: number, b: number) => number;
|
|
11
13
|
export const compute_roll_plinko: (a: number, b: number, c: number) => number;
|
|
12
14
|
export const compute_server_seed_hash: (a: number, b: number, c: number) => void;
|
|
@@ -26,6 +26,17 @@ export function compute_address_hash(address_hex: string): BigUint64Array;
|
|
|
26
26
|
*/
|
|
27
27
|
export function compute_multi_dice(win_numbers: number): bigint;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Full coinflip payout computation — pure integer arithmetic, zero floats.
|
|
31
|
+
*
|
|
32
|
+
* `random`: 4 Goldilocks field elements (Poseidon2 output).
|
|
33
|
+
* `bet_atomic`: bet in atomic units (1 USDT = 1_000_000).
|
|
34
|
+
* `prediction`: 0 or 1.
|
|
35
|
+
*
|
|
36
|
+
* Returns `BigUint64Array[4]`: `[win_amount, roll (0|1), is_win (0|1), multiplier×10000]`.
|
|
37
|
+
*/
|
|
38
|
+
export function compute_payout_coinflip(random: BigUint64Array, bet_atomic: bigint, prediction: number): BigUint64Array;
|
|
39
|
+
|
|
29
40
|
/**
|
|
30
41
|
* Full dice payout computation — pure integer arithmetic, zero floats.
|
|
31
42
|
*
|
|
@@ -58,11 +69,19 @@ export function compute_payout_plinko(random: BigUint64Array, bet_atomic: bigint
|
|
|
58
69
|
* and the in-circuit `build_prediction_hash`.
|
|
59
70
|
*
|
|
60
71
|
* Semantics of p0–p2 depend on the game:
|
|
61
|
-
* Dice:
|
|
62
|
-
* Plinko:
|
|
72
|
+
* Dice: `(mode, pred_lo, pred_hi)`
|
|
73
|
+
* Plinko: `(sector, rows, is_extreme)`
|
|
74
|
+
* CoinFlip: `(prediction, 0, 0)`
|
|
63
75
|
*/
|
|
64
76
|
export function compute_prediction_hash(game_id: number, p0: number, p1: number, p2: number): BigUint64Array;
|
|
65
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Extract coinflip roll (0 or 1) from Poseidon2 random output.
|
|
80
|
+
*
|
|
81
|
+
* `random` must be exactly 4 elements. Returns `random[0] % 2`.
|
|
82
|
+
*/
|
|
83
|
+
export function compute_roll_coinflip(random: BigUint64Array): number;
|
|
84
|
+
|
|
66
85
|
/**
|
|
67
86
|
* Extract dice roll number [0, 1000) from Poseidon2 random output.
|
|
68
87
|
*
|