@actuallyfair/verifier 0.0.1 → 0.0.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.
@@ -18,30 +18,12 @@ export interface Context {
18
18
  mines?: Mines | undefined;
19
19
  tower?: Tower | undefined;
20
20
  plinko?: Plinko | undefined;
21
- }
22
-
23
- export interface PosthashContext {
24
21
  init?: PosthashInit | undefined;
25
- dice?: PosthashDice | undefined;
26
- plinko?: PosthashPlinko | undefined;
27
22
  }
28
23
 
29
24
  export interface PosthashInit {
30
25
  }
31
26
 
32
- export interface PosthashDice {
33
- target: number;
34
- clientSeed: string;
35
- hashchainServerHash: Uint8Array;
36
- }
37
-
38
- export interface PosthashPlinko {
39
- rows: number;
40
- riskLevel: string;
41
- clientSeed: string;
42
- hashchainServerHash: Uint8Array;
43
- }
44
-
45
27
  function createBaseContext(): Context {
46
28
  return {
47
29
  fairCoinToss: undefined,
@@ -52,6 +34,7 @@ function createBaseContext(): Context {
52
34
  mines: undefined,
53
35
  tower: undefined,
54
36
  plinko: undefined,
37
+ init: undefined,
55
38
  };
56
39
  }
57
40
 
@@ -81,6 +64,9 @@ export const Context = {
81
64
  if (message.plinko !== undefined) {
82
65
  Plinko.encode(message.plinko, writer.uint32(66).fork()).ldelim();
83
66
  }
67
+ if (message.init !== undefined) {
68
+ PosthashInit.encode(message.init, writer.uint32(74).fork()).ldelim();
69
+ }
84
70
  return writer;
85
71
  },
86
72
 
@@ -147,6 +133,13 @@ export const Context = {
147
133
 
148
134
  message.plinko = Plinko.decode(reader, reader.uint32());
149
135
  continue;
136
+ case 9:
137
+ if (tag !== 74) {
138
+ break;
139
+ }
140
+
141
+ message.init = PosthashInit.decode(reader, reader.uint32());
142
+ continue;
150
143
  }
151
144
  if ((tag & 7) === 4 || tag === 0) {
152
145
  break;
@@ -166,6 +159,7 @@ export const Context = {
166
159
  mines: isSet(object.mines) ? Mines.fromJSON(object.mines) : undefined,
167
160
  tower: isSet(object.tower) ? Tower.fromJSON(object.tower) : undefined,
168
161
  plinko: isSet(object.plinko) ? Plinko.fromJSON(object.plinko) : undefined,
162
+ init: isSet(object.init) ? PosthashInit.fromJSON(object.init) : undefined,
169
163
  };
170
164
  },
171
165
 
@@ -195,6 +189,9 @@ export const Context = {
195
189
  if (message.plinko !== undefined) {
196
190
  obj.plinko = Plinko.toJSON(message.plinko);
197
191
  }
192
+ if (message.init !== undefined) {
193
+ obj.init = PosthashInit.toJSON(message.init);
194
+ }
198
195
  return obj;
199
196
  },
200
197
 
@@ -219,101 +216,9 @@ export const Context = {
219
216
  message.plinko = (object.plinko !== undefined && object.plinko !== null)
220
217
  ? Plinko.fromPartial(object.plinko)
221
218
  : undefined;
222
- return message;
223
- },
224
- };
225
-
226
- function createBasePosthashContext(): PosthashContext {
227
- return { init: undefined, dice: undefined, plinko: undefined };
228
- }
229
-
230
- export const PosthashContext = {
231
- encode(message: PosthashContext, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
232
- if (message.init !== undefined) {
233
- PosthashInit.encode(message.init, writer.uint32(10).fork()).ldelim();
234
- }
235
- if (message.dice !== undefined) {
236
- PosthashDice.encode(message.dice, writer.uint32(18).fork()).ldelim();
237
- }
238
- if (message.plinko !== undefined) {
239
- PosthashPlinko.encode(message.plinko, writer.uint32(26).fork()).ldelim();
240
- }
241
- return writer;
242
- },
243
-
244
- decode(input: _m0.Reader | Uint8Array, length?: number): PosthashContext {
245
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
246
- let end = length === undefined ? reader.len : reader.pos + length;
247
- const message = createBasePosthashContext();
248
- while (reader.pos < end) {
249
- const tag = reader.uint32();
250
- switch (tag >>> 3) {
251
- case 1:
252
- if (tag !== 10) {
253
- break;
254
- }
255
-
256
- message.init = PosthashInit.decode(reader, reader.uint32());
257
- continue;
258
- case 2:
259
- if (tag !== 18) {
260
- break;
261
- }
262
-
263
- message.dice = PosthashDice.decode(reader, reader.uint32());
264
- continue;
265
- case 3:
266
- if (tag !== 26) {
267
- break;
268
- }
269
-
270
- message.plinko = PosthashPlinko.decode(reader, reader.uint32());
271
- continue;
272
- }
273
- if ((tag & 7) === 4 || tag === 0) {
274
- break;
275
- }
276
- reader.skipType(tag & 7);
277
- }
278
- return message;
279
- },
280
-
281
- fromJSON(object: any): PosthashContext {
282
- return {
283
- init: isSet(object.init) ? PosthashInit.fromJSON(object.init) : undefined,
284
- dice: isSet(object.dice) ? PosthashDice.fromJSON(object.dice) : undefined,
285
- plinko: isSet(object.plinko) ? PosthashPlinko.fromJSON(object.plinko) : undefined,
286
- };
287
- },
288
-
289
- toJSON(message: PosthashContext): unknown {
290
- const obj: any = {};
291
- if (message.init !== undefined) {
292
- obj.init = PosthashInit.toJSON(message.init);
293
- }
294
- if (message.dice !== undefined) {
295
- obj.dice = PosthashDice.toJSON(message.dice);
296
- }
297
- if (message.plinko !== undefined) {
298
- obj.plinko = PosthashPlinko.toJSON(message.plinko);
299
- }
300
- return obj;
301
- },
302
-
303
- create<I extends Exact<DeepPartial<PosthashContext>, I>>(base?: I): PosthashContext {
304
- return PosthashContext.fromPartial(base ?? ({} as any));
305
- },
306
- fromPartial<I extends Exact<DeepPartial<PosthashContext>, I>>(object: I): PosthashContext {
307
- const message = createBasePosthashContext();
308
219
  message.init = (object.init !== undefined && object.init !== null)
309
220
  ? PosthashInit.fromPartial(object.init)
310
221
  : undefined;
311
- message.dice = (object.dice !== undefined && object.dice !== null)
312
- ? PosthashDice.fromPartial(object.dice)
313
- : undefined;
314
- message.plinko = (object.plinko !== undefined && object.plinko !== null)
315
- ? PosthashPlinko.fromPartial(object.plinko)
316
- : undefined;
317
222
  return message;
318
223
  },
319
224
  };
@@ -361,228 +266,6 @@ export const PosthashInit = {
361
266
  },
362
267
  };
363
268
 
364
- function createBasePosthashDice(): PosthashDice {
365
- return { target: 0, clientSeed: "", hashchainServerHash: new Uint8Array(0) };
366
- }
367
-
368
- export const PosthashDice = {
369
- encode(message: PosthashDice, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
370
- if (message.target !== 0) {
371
- writer.uint32(9).double(message.target);
372
- }
373
- if (message.clientSeed !== "") {
374
- writer.uint32(18).string(message.clientSeed);
375
- }
376
- if (message.hashchainServerHash.length !== 0) {
377
- writer.uint32(26).bytes(message.hashchainServerHash);
378
- }
379
- return writer;
380
- },
381
-
382
- decode(input: _m0.Reader | Uint8Array, length?: number): PosthashDice {
383
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
384
- let end = length === undefined ? reader.len : reader.pos + length;
385
- const message = createBasePosthashDice();
386
- while (reader.pos < end) {
387
- const tag = reader.uint32();
388
- switch (tag >>> 3) {
389
- case 1:
390
- if (tag !== 9) {
391
- break;
392
- }
393
-
394
- message.target = reader.double();
395
- continue;
396
- case 2:
397
- if (tag !== 18) {
398
- break;
399
- }
400
-
401
- message.clientSeed = reader.string();
402
- continue;
403
- case 3:
404
- if (tag !== 26) {
405
- break;
406
- }
407
-
408
- message.hashchainServerHash = reader.bytes();
409
- continue;
410
- }
411
- if ((tag & 7) === 4 || tag === 0) {
412
- break;
413
- }
414
- reader.skipType(tag & 7);
415
- }
416
- return message;
417
- },
418
-
419
- fromJSON(object: any): PosthashDice {
420
- return {
421
- target: isSet(object.target) ? globalThis.Number(object.target) : 0,
422
- clientSeed: isSet(object.clientSeed) ? globalThis.String(object.clientSeed) : "",
423
- hashchainServerHash: isSet(object.hashchainServerHash)
424
- ? bytesFromBase64(object.hashchainServerHash)
425
- : new Uint8Array(0),
426
- };
427
- },
428
-
429
- toJSON(message: PosthashDice): unknown {
430
- const obj: any = {};
431
- if (message.target !== 0) {
432
- obj.target = message.target;
433
- }
434
- if (message.clientSeed !== "") {
435
- obj.clientSeed = message.clientSeed;
436
- }
437
- if (message.hashchainServerHash.length !== 0) {
438
- obj.hashchainServerHash = base64FromBytes(message.hashchainServerHash);
439
- }
440
- return obj;
441
- },
442
-
443
- create<I extends Exact<DeepPartial<PosthashDice>, I>>(base?: I): PosthashDice {
444
- return PosthashDice.fromPartial(base ?? ({} as any));
445
- },
446
- fromPartial<I extends Exact<DeepPartial<PosthashDice>, I>>(object: I): PosthashDice {
447
- const message = createBasePosthashDice();
448
- message.target = object.target ?? 0;
449
- message.clientSeed = object.clientSeed ?? "";
450
- message.hashchainServerHash = object.hashchainServerHash ?? new Uint8Array(0);
451
- return message;
452
- },
453
- };
454
-
455
- function createBasePosthashPlinko(): PosthashPlinko {
456
- return { rows: 0, riskLevel: "", clientSeed: "", hashchainServerHash: new Uint8Array(0) };
457
- }
458
-
459
- export const PosthashPlinko = {
460
- encode(message: PosthashPlinko, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
461
- if (message.rows !== 0) {
462
- writer.uint32(8).uint32(message.rows);
463
- }
464
- if (message.riskLevel !== "") {
465
- writer.uint32(18).string(message.riskLevel);
466
- }
467
- if (message.clientSeed !== "") {
468
- writer.uint32(26).string(message.clientSeed);
469
- }
470
- if (message.hashchainServerHash.length !== 0) {
471
- writer.uint32(34).bytes(message.hashchainServerHash);
472
- }
473
- return writer;
474
- },
475
-
476
- decode(input: _m0.Reader | Uint8Array, length?: number): PosthashPlinko {
477
- const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
478
- let end = length === undefined ? reader.len : reader.pos + length;
479
- const message = createBasePosthashPlinko();
480
- while (reader.pos < end) {
481
- const tag = reader.uint32();
482
- switch (tag >>> 3) {
483
- case 1:
484
- if (tag !== 8) {
485
- break;
486
- }
487
-
488
- message.rows = reader.uint32();
489
- continue;
490
- case 2:
491
- if (tag !== 18) {
492
- break;
493
- }
494
-
495
- message.riskLevel = reader.string();
496
- continue;
497
- case 3:
498
- if (tag !== 26) {
499
- break;
500
- }
501
-
502
- message.clientSeed = reader.string();
503
- continue;
504
- case 4:
505
- if (tag !== 34) {
506
- break;
507
- }
508
-
509
- message.hashchainServerHash = reader.bytes();
510
- continue;
511
- }
512
- if ((tag & 7) === 4 || tag === 0) {
513
- break;
514
- }
515
- reader.skipType(tag & 7);
516
- }
517
- return message;
518
- },
519
-
520
- fromJSON(object: any): PosthashPlinko {
521
- return {
522
- rows: isSet(object.rows) ? globalThis.Number(object.rows) : 0,
523
- riskLevel: isSet(object.riskLevel) ? globalThis.String(object.riskLevel) : "",
524
- clientSeed: isSet(object.clientSeed) ? globalThis.String(object.clientSeed) : "",
525
- hashchainServerHash: isSet(object.hashchainServerHash)
526
- ? bytesFromBase64(object.hashchainServerHash)
527
- : new Uint8Array(0),
528
- };
529
- },
530
-
531
- toJSON(message: PosthashPlinko): unknown {
532
- const obj: any = {};
533
- if (message.rows !== 0) {
534
- obj.rows = Math.round(message.rows);
535
- }
536
- if (message.riskLevel !== "") {
537
- obj.riskLevel = message.riskLevel;
538
- }
539
- if (message.clientSeed !== "") {
540
- obj.clientSeed = message.clientSeed;
541
- }
542
- if (message.hashchainServerHash.length !== 0) {
543
- obj.hashchainServerHash = base64FromBytes(message.hashchainServerHash);
544
- }
545
- return obj;
546
- },
547
-
548
- create<I extends Exact<DeepPartial<PosthashPlinko>, I>>(base?: I): PosthashPlinko {
549
- return PosthashPlinko.fromPartial(base ?? ({} as any));
550
- },
551
- fromPartial<I extends Exact<DeepPartial<PosthashPlinko>, I>>(object: I): PosthashPlinko {
552
- const message = createBasePosthashPlinko();
553
- message.rows = object.rows ?? 0;
554
- message.riskLevel = object.riskLevel ?? "";
555
- message.clientSeed = object.clientSeed ?? "";
556
- message.hashchainServerHash = object.hashchainServerHash ?? new Uint8Array(0);
557
- return message;
558
- },
559
- };
560
-
561
- function bytesFromBase64(b64: string): Uint8Array {
562
- if (globalThis.Buffer) {
563
- return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
564
- } else {
565
- const bin = globalThis.atob(b64);
566
- const arr = new Uint8Array(bin.length);
567
- for (let i = 0; i < bin.length; ++i) {
568
- arr[i] = bin.charCodeAt(i);
569
- }
570
- return arr;
571
- }
572
- }
573
-
574
- function base64FromBytes(arr: Uint8Array): string {
575
- if (globalThis.Buffer) {
576
- return globalThis.Buffer.from(arr).toString("base64");
577
- } else {
578
- const bin: string[] = [];
579
- arr.forEach((byte) => {
580
- bin.push(globalThis.String.fromCharCode(byte));
581
- });
582
- return globalThis.btoa(bin.join(""));
583
- }
584
- }
585
-
586
269
  type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
587
270
 
588
271
  type DeepPartial<T> = T extends Builtin ? T
Binary file