@actuallyfair/verifier 0.0.3 → 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/dist/compute-wager.js +15 -1
- package/dist/duel-plinko-payouts.d.ts +14 -0
- package/dist/duel-plinko-payouts.js +478 -0
- package/dist/generated/context/index.d.ts +107 -33
- package/dist/generated/context/plinko.d.ts +171 -7
- package/dist/generated/context/plinko.js +252 -17
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
- package/protobuf/context/plinko.proto +25 -2
- package/src/compute-wager.ts +16 -1
- package/src/duel-plinko-payouts.ts +495 -0
- package/src/generated/context/plinko.ts +292 -20
- package/src/index.ts +1 -0
|
@@ -3,23 +3,66 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Plinko = void 0;
|
|
6
|
+
exports.CustomPlinkoPayouts = exports.DuelPlinkoPayouts = exports.PlinkoPayouts = exports.Plinko = exports.duelPlinkoRiskToJSON = exports.duelPlinkoRiskFromJSON = exports.DuelPlinkoRisk = void 0;
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
9
9
|
const amount_1 = require("../amount");
|
|
10
|
+
var DuelPlinkoRisk;
|
|
11
|
+
(function (DuelPlinkoRisk) {
|
|
12
|
+
DuelPlinkoRisk[DuelPlinkoRisk["DUEL_PLINKO_RISK_UNSPECIFIED"] = 0] = "DUEL_PLINKO_RISK_UNSPECIFIED";
|
|
13
|
+
DuelPlinkoRisk[DuelPlinkoRisk["DUEL_PLINKO_RISK_LOW"] = 1] = "DUEL_PLINKO_RISK_LOW";
|
|
14
|
+
DuelPlinkoRisk[DuelPlinkoRisk["DUEL_PLINKO_RISK_MEDIUM"] = 2] = "DUEL_PLINKO_RISK_MEDIUM";
|
|
15
|
+
DuelPlinkoRisk[DuelPlinkoRisk["DUEL_PLINKO_RISK_HIGH"] = 3] = "DUEL_PLINKO_RISK_HIGH";
|
|
16
|
+
DuelPlinkoRisk[DuelPlinkoRisk["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
17
|
+
})(DuelPlinkoRisk || (exports.DuelPlinkoRisk = DuelPlinkoRisk = {}));
|
|
18
|
+
function duelPlinkoRiskFromJSON(object) {
|
|
19
|
+
switch (object) {
|
|
20
|
+
case 0:
|
|
21
|
+
case "DUEL_PLINKO_RISK_UNSPECIFIED":
|
|
22
|
+
return DuelPlinkoRisk.DUEL_PLINKO_RISK_UNSPECIFIED;
|
|
23
|
+
case 1:
|
|
24
|
+
case "DUEL_PLINKO_RISK_LOW":
|
|
25
|
+
return DuelPlinkoRisk.DUEL_PLINKO_RISK_LOW;
|
|
26
|
+
case 2:
|
|
27
|
+
case "DUEL_PLINKO_RISK_MEDIUM":
|
|
28
|
+
return DuelPlinkoRisk.DUEL_PLINKO_RISK_MEDIUM;
|
|
29
|
+
case 3:
|
|
30
|
+
case "DUEL_PLINKO_RISK_HIGH":
|
|
31
|
+
return DuelPlinkoRisk.DUEL_PLINKO_RISK_HIGH;
|
|
32
|
+
case -1:
|
|
33
|
+
case "UNRECOGNIZED":
|
|
34
|
+
default:
|
|
35
|
+
return DuelPlinkoRisk.UNRECOGNIZED;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.duelPlinkoRiskFromJSON = duelPlinkoRiskFromJSON;
|
|
39
|
+
function duelPlinkoRiskToJSON(object) {
|
|
40
|
+
switch (object) {
|
|
41
|
+
case DuelPlinkoRisk.DUEL_PLINKO_RISK_UNSPECIFIED:
|
|
42
|
+
return "DUEL_PLINKO_RISK_UNSPECIFIED";
|
|
43
|
+
case DuelPlinkoRisk.DUEL_PLINKO_RISK_LOW:
|
|
44
|
+
return "DUEL_PLINKO_RISK_LOW";
|
|
45
|
+
case DuelPlinkoRisk.DUEL_PLINKO_RISK_MEDIUM:
|
|
46
|
+
return "DUEL_PLINKO_RISK_MEDIUM";
|
|
47
|
+
case DuelPlinkoRisk.DUEL_PLINKO_RISK_HIGH:
|
|
48
|
+
return "DUEL_PLINKO_RISK_HIGH";
|
|
49
|
+
case DuelPlinkoRisk.UNRECOGNIZED:
|
|
50
|
+
default:
|
|
51
|
+
return "UNRECOGNIZED";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.duelPlinkoRiskToJSON = duelPlinkoRiskToJSON;
|
|
10
55
|
function createBasePlinko() {
|
|
11
|
-
return { amount: undefined,
|
|
56
|
+
return { amount: undefined, payouts: undefined };
|
|
12
57
|
}
|
|
13
58
|
exports.Plinko = {
|
|
14
59
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
15
60
|
if (message.amount !== undefined) {
|
|
16
61
|
amount_1.Amount.encode(message.amount, writer.uint32(10).fork()).ldelim();
|
|
17
62
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
writer.double(v);
|
|
63
|
+
if (message.payouts !== undefined) {
|
|
64
|
+
exports.PlinkoPayouts.encode(message.payouts, writer.uint32(18).fork()).ldelim();
|
|
21
65
|
}
|
|
22
|
-
writer.ldelim();
|
|
23
66
|
return writer;
|
|
24
67
|
},
|
|
25
68
|
decode(input, length) {
|
|
@@ -36,11 +79,210 @@ exports.Plinko = {
|
|
|
36
79
|
message.amount = amount_1.Amount.decode(reader, reader.uint32());
|
|
37
80
|
continue;
|
|
38
81
|
case 2:
|
|
39
|
-
if (tag
|
|
82
|
+
if (tag !== 18) {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
message.payouts = exports.PlinkoPayouts.decode(reader, reader.uint32());
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
reader.skipType(tag & 7);
|
|
92
|
+
}
|
|
93
|
+
return message;
|
|
94
|
+
},
|
|
95
|
+
fromJSON(object) {
|
|
96
|
+
return {
|
|
97
|
+
amount: isSet(object.amount) ? amount_1.Amount.fromJSON(object.amount) : undefined,
|
|
98
|
+
payouts: isSet(object.payouts) ? exports.PlinkoPayouts.fromJSON(object.payouts) : undefined,
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
toJSON(message) {
|
|
102
|
+
const obj = {};
|
|
103
|
+
if (message.amount !== undefined) {
|
|
104
|
+
obj.amount = amount_1.Amount.toJSON(message.amount);
|
|
105
|
+
}
|
|
106
|
+
if (message.payouts !== undefined) {
|
|
107
|
+
obj.payouts = exports.PlinkoPayouts.toJSON(message.payouts);
|
|
108
|
+
}
|
|
109
|
+
return obj;
|
|
110
|
+
},
|
|
111
|
+
create(base) {
|
|
112
|
+
return exports.Plinko.fromPartial(base ?? {});
|
|
113
|
+
},
|
|
114
|
+
fromPartial(object) {
|
|
115
|
+
const message = createBasePlinko();
|
|
116
|
+
message.amount = (object.amount !== undefined && object.amount !== null)
|
|
117
|
+
? amount_1.Amount.fromPartial(object.amount)
|
|
118
|
+
: undefined;
|
|
119
|
+
message.payouts = (object.payouts !== undefined && object.payouts !== null)
|
|
120
|
+
? exports.PlinkoPayouts.fromPartial(object.payouts)
|
|
121
|
+
: undefined;
|
|
122
|
+
return message;
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
function createBasePlinkoPayouts() {
|
|
126
|
+
return { custom: undefined, duel: undefined };
|
|
127
|
+
}
|
|
128
|
+
exports.PlinkoPayouts = {
|
|
129
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
130
|
+
if (message.custom !== undefined) {
|
|
131
|
+
exports.CustomPlinkoPayouts.encode(message.custom, writer.uint32(10).fork()).ldelim();
|
|
132
|
+
}
|
|
133
|
+
if (message.duel !== undefined) {
|
|
134
|
+
exports.DuelPlinkoPayouts.encode(message.duel, writer.uint32(18).fork()).ldelim();
|
|
135
|
+
}
|
|
136
|
+
return writer;
|
|
137
|
+
},
|
|
138
|
+
decode(input, length) {
|
|
139
|
+
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
140
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
141
|
+
const message = createBasePlinkoPayouts();
|
|
142
|
+
while (reader.pos < end) {
|
|
143
|
+
const tag = reader.uint32();
|
|
144
|
+
switch (tag >>> 3) {
|
|
145
|
+
case 1:
|
|
146
|
+
if (tag !== 10) {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
message.custom = exports.CustomPlinkoPayouts.decode(reader, reader.uint32());
|
|
150
|
+
continue;
|
|
151
|
+
case 2:
|
|
152
|
+
if (tag !== 18) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
message.duel = exports.DuelPlinkoPayouts.decode(reader, reader.uint32());
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
reader.skipType(tag & 7);
|
|
162
|
+
}
|
|
163
|
+
return message;
|
|
164
|
+
},
|
|
165
|
+
fromJSON(object) {
|
|
166
|
+
return {
|
|
167
|
+
custom: isSet(object.custom) ? exports.CustomPlinkoPayouts.fromJSON(object.custom) : undefined,
|
|
168
|
+
duel: isSet(object.duel) ? exports.DuelPlinkoPayouts.fromJSON(object.duel) : undefined,
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
toJSON(message) {
|
|
172
|
+
const obj = {};
|
|
173
|
+
if (message.custom !== undefined) {
|
|
174
|
+
obj.custom = exports.CustomPlinkoPayouts.toJSON(message.custom);
|
|
175
|
+
}
|
|
176
|
+
if (message.duel !== undefined) {
|
|
177
|
+
obj.duel = exports.DuelPlinkoPayouts.toJSON(message.duel);
|
|
178
|
+
}
|
|
179
|
+
return obj;
|
|
180
|
+
},
|
|
181
|
+
create(base) {
|
|
182
|
+
return exports.PlinkoPayouts.fromPartial(base ?? {});
|
|
183
|
+
},
|
|
184
|
+
fromPartial(object) {
|
|
185
|
+
const message = createBasePlinkoPayouts();
|
|
186
|
+
message.custom = (object.custom !== undefined && object.custom !== null)
|
|
187
|
+
? exports.CustomPlinkoPayouts.fromPartial(object.custom)
|
|
188
|
+
: undefined;
|
|
189
|
+
message.duel = (object.duel !== undefined && object.duel !== null)
|
|
190
|
+
? exports.DuelPlinkoPayouts.fromPartial(object.duel)
|
|
191
|
+
: undefined;
|
|
192
|
+
return message;
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
function createBaseDuelPlinkoPayouts() {
|
|
196
|
+
return { rows: 0, risk: 0 };
|
|
197
|
+
}
|
|
198
|
+
exports.DuelPlinkoPayouts = {
|
|
199
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
200
|
+
if (message.rows !== 0) {
|
|
201
|
+
writer.uint32(8).uint32(message.rows);
|
|
202
|
+
}
|
|
203
|
+
if (message.risk !== 0) {
|
|
204
|
+
writer.uint32(16).int32(message.risk);
|
|
205
|
+
}
|
|
206
|
+
return writer;
|
|
207
|
+
},
|
|
208
|
+
decode(input, length) {
|
|
209
|
+
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
210
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
211
|
+
const message = createBaseDuelPlinkoPayouts();
|
|
212
|
+
while (reader.pos < end) {
|
|
213
|
+
const tag = reader.uint32();
|
|
214
|
+
switch (tag >>> 3) {
|
|
215
|
+
case 1:
|
|
216
|
+
if (tag !== 8) {
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
message.rows = reader.uint32();
|
|
220
|
+
continue;
|
|
221
|
+
case 2:
|
|
222
|
+
if (tag !== 16) {
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
message.risk = reader.int32();
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
reader.skipType(tag & 7);
|
|
232
|
+
}
|
|
233
|
+
return message;
|
|
234
|
+
},
|
|
235
|
+
fromJSON(object) {
|
|
236
|
+
return {
|
|
237
|
+
rows: isSet(object.rows) ? globalThis.Number(object.rows) : 0,
|
|
238
|
+
risk: isSet(object.risk) ? duelPlinkoRiskFromJSON(object.risk) : 0,
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
toJSON(message) {
|
|
242
|
+
const obj = {};
|
|
243
|
+
if (message.rows !== 0) {
|
|
244
|
+
obj.rows = Math.round(message.rows);
|
|
245
|
+
}
|
|
246
|
+
if (message.risk !== 0) {
|
|
247
|
+
obj.risk = duelPlinkoRiskToJSON(message.risk);
|
|
248
|
+
}
|
|
249
|
+
return obj;
|
|
250
|
+
},
|
|
251
|
+
create(base) {
|
|
252
|
+
return exports.DuelPlinkoPayouts.fromPartial(base ?? {});
|
|
253
|
+
},
|
|
254
|
+
fromPartial(object) {
|
|
255
|
+
const message = createBaseDuelPlinkoPayouts();
|
|
256
|
+
message.rows = object.rows ?? 0;
|
|
257
|
+
message.risk = object.risk ?? 0;
|
|
258
|
+
return message;
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
function createBaseCustomPlinkoPayouts() {
|
|
262
|
+
return { possibilities: [] };
|
|
263
|
+
}
|
|
264
|
+
exports.CustomPlinkoPayouts = {
|
|
265
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
266
|
+
writer.uint32(10).fork();
|
|
267
|
+
for (const v of message.possibilities) {
|
|
268
|
+
writer.double(v);
|
|
269
|
+
}
|
|
270
|
+
writer.ldelim();
|
|
271
|
+
return writer;
|
|
272
|
+
},
|
|
273
|
+
decode(input, length) {
|
|
274
|
+
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
275
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
276
|
+
const message = createBaseCustomPlinkoPayouts();
|
|
277
|
+
while (reader.pos < end) {
|
|
278
|
+
const tag = reader.uint32();
|
|
279
|
+
switch (tag >>> 3) {
|
|
280
|
+
case 1:
|
|
281
|
+
if (tag === 9) {
|
|
40
282
|
message.possibilities.push(reader.double());
|
|
41
283
|
continue;
|
|
42
284
|
}
|
|
43
|
-
if (tag ===
|
|
285
|
+
if (tag === 10) {
|
|
44
286
|
const end2 = reader.uint32() + reader.pos;
|
|
45
287
|
while (reader.pos < end2) {
|
|
46
288
|
message.possibilities.push(reader.double());
|
|
@@ -58,7 +300,6 @@ exports.Plinko = {
|
|
|
58
300
|
},
|
|
59
301
|
fromJSON(object) {
|
|
60
302
|
return {
|
|
61
|
-
amount: isSet(object.amount) ? amount_1.Amount.fromJSON(object.amount) : undefined,
|
|
62
303
|
possibilities: globalThis.Array.isArray(object?.possibilities)
|
|
63
304
|
? object.possibilities.map((e) => globalThis.Number(e))
|
|
64
305
|
: [],
|
|
@@ -66,22 +307,16 @@ exports.Plinko = {
|
|
|
66
307
|
},
|
|
67
308
|
toJSON(message) {
|
|
68
309
|
const obj = {};
|
|
69
|
-
if (message.amount !== undefined) {
|
|
70
|
-
obj.amount = amount_1.Amount.toJSON(message.amount);
|
|
71
|
-
}
|
|
72
310
|
if (message.possibilities?.length) {
|
|
73
311
|
obj.possibilities = message.possibilities;
|
|
74
312
|
}
|
|
75
313
|
return obj;
|
|
76
314
|
},
|
|
77
315
|
create(base) {
|
|
78
|
-
return exports.
|
|
316
|
+
return exports.CustomPlinkoPayouts.fromPartial(base ?? {});
|
|
79
317
|
},
|
|
80
318
|
fromPartial(object) {
|
|
81
|
-
const message =
|
|
82
|
-
message.amount = (object.amount !== undefined && object.amount !== null)
|
|
83
|
-
? amount_1.Amount.fromPartial(object.amount)
|
|
84
|
-
: undefined;
|
|
319
|
+
const message = createBaseCustomPlinkoPayouts();
|
|
85
320
|
message.possibilities = object.possibilities?.map((e) => e) || [];
|
|
86
321
|
return message;
|
|
87
322
|
},
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -25,3 +25,4 @@ __exportStar(require("./generated/context/tower"), exports);
|
|
|
25
25
|
__exportStar(require("./generated/context/plinko"), exports);
|
|
26
26
|
__exportStar(require("./format-amount"), exports);
|
|
27
27
|
__exportStar(require("./compute-wager"), exports);
|
|
28
|
+
__exportStar(require("./duel-plinko-payouts"), exports);
|
package/package.json
CHANGED
|
@@ -3,5 +3,28 @@ import "amount.proto";
|
|
|
3
3
|
|
|
4
4
|
message Plinko {
|
|
5
5
|
Amount amount = 1;
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
PlinkoPayouts payouts = 2;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
message PlinkoPayouts {
|
|
10
|
+
oneof payout_table {
|
|
11
|
+
CustomPlinkoPayouts custom = 1;
|
|
12
|
+
DuelPlinkoPayouts duel = 2;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
message DuelPlinkoPayouts {
|
|
17
|
+
uint32 rows = 1;
|
|
18
|
+
DuelPlinkoRisk risk = 2;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
message CustomPlinkoPayouts {
|
|
22
|
+
repeated double possibilities = 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
enum DuelPlinkoRisk {
|
|
26
|
+
DUEL_PLINKO_RISK_UNSPECIFIED = 0;
|
|
27
|
+
DUEL_PLINKO_RISK_LOW = 1;
|
|
28
|
+
DUEL_PLINKO_RISK_MEDIUM = 2;
|
|
29
|
+
DUEL_PLINKO_RISK_HIGH = 3;
|
|
30
|
+
}
|
package/src/compute-wager.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { bytesToHex } from "@noble/hashes/utils";
|
|
15
15
|
import { CrashDice } from "./generated/context/crash-dice";
|
|
16
16
|
import { MultiRoulette } from "./generated/context/multi-roulette";
|
|
17
|
+
import { getDuelPlinkoPayoutsFromEnum } from "./duel-plinko-payouts";
|
|
17
18
|
import { Plinko } from "./generated/context/plinko";
|
|
18
19
|
|
|
19
20
|
export function computeFairCoinTossResult(sig: Uint8Array) {
|
|
@@ -279,7 +280,7 @@ export function computePlinkoResult(
|
|
|
279
280
|
clientSeed: string,
|
|
280
281
|
bet: Plinko
|
|
281
282
|
): PlinkoResult {
|
|
282
|
-
const possibilities = bet
|
|
283
|
+
const possibilities = resolvePlinkoPayouts(bet);
|
|
283
284
|
if (possibilities.length < 2) {
|
|
284
285
|
throw new Error("invalid possibilities ");
|
|
285
286
|
}
|
|
@@ -297,6 +298,20 @@ export function computePlinkoResult(
|
|
|
297
298
|
};
|
|
298
299
|
}
|
|
299
300
|
|
|
301
|
+
function resolvePlinkoPayouts(bet: Plinko): number[] {
|
|
302
|
+
const payouts = bet.payouts;
|
|
303
|
+
if (!payouts) {
|
|
304
|
+
return [];
|
|
305
|
+
}
|
|
306
|
+
if (payouts.duel) {
|
|
307
|
+
return getDuelPlinkoPayoutsFromEnum(payouts.duel.rows, payouts.duel.risk);
|
|
308
|
+
}
|
|
309
|
+
if (payouts.custom) {
|
|
310
|
+
return payouts.custom.possibilities;
|
|
311
|
+
}
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
|
|
300
315
|
function hmacSha256(key: Uint8Array, message: string): Uint8Array {
|
|
301
316
|
const data = new TextEncoder().encode(message);
|
|
302
317
|
return hmac(sha256, key, data);
|