@block52/poker-vm-sdk 1.24.0 → 1.25.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.
Files changed (30) hide show
  1. package/dist/cosmosClient.d.ts +11 -1
  2. package/dist/cosmosClient.d.ts.map +1 -1
  3. package/dist/index.d.ts +385 -46
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.esm.js +945 -107
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.js +948 -107
  8. package/dist/index.js.map +1 -1
  9. package/dist/pokerchain.poker.v1/registry.d.ts.map +1 -1
  10. package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/genesis.d.ts +4 -19
  11. package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/genesis.d.ts.map +1 -1
  12. package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/params.d.ts +64 -0
  13. package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/params.d.ts.map +1 -1
  14. package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/query.d.ts +378 -6
  15. package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/query.d.ts.map +1 -1
  16. package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts +361 -32
  17. package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts.map +1 -1
  18. package/dist/pokerchain.poker.v1/types.d.ts +1 -2
  19. package/dist/pokerchain.poker.v1/types.d.ts.map +1 -1
  20. package/dist/signingClient.d.ts +23 -0
  21. package/dist/signingClient.d.ts.map +1 -1
  22. package/dist/types/game.d.ts +66 -0
  23. package/dist/types/game.d.ts.map +1 -1
  24. package/dist/types/rest.d.ts +8 -0
  25. package/dist/types/rest.d.ts.map +1 -1
  26. package/dist/utils/createTournament.d.ts +43 -0
  27. package/dist/utils/createTournament.d.ts.map +1 -0
  28. package/dist/utils/tournamentState.d.ts +15 -0
  29. package/dist/utils/tournamentState.d.ts.map +1 -0
  30. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2716,10 +2716,31 @@ if (typeof BigInt === "function") {
2716
2716
  // source: pokerchain/poker/v1/params.proto
2717
2717
  /* eslint-disable */
2718
2718
  function createBaseParams$c() {
2719
- return {};
2719
+ return {
2720
+ vrfShuffleEnforced: false,
2721
+ sngPayoutStructures: {},
2722
+ gatewayOperators: [],
2723
+ minValidatorBond: Long.UZERO,
2724
+ protocolFeeBps: 0,
2725
+ };
2720
2726
  }
2721
2727
  const Params$c = {
2722
- encode(_, writer = new BinaryWriter()) {
2728
+ encode(message, writer = new BinaryWriter()) {
2729
+ if (message.vrfShuffleEnforced !== false) {
2730
+ writer.uint32(8).bool(message.vrfShuffleEnforced);
2731
+ }
2732
+ Object.entries(message.sngPayoutStructures).forEach(([key, value]) => {
2733
+ Params_SngPayoutStructuresEntry.encode({ key: key, value }, writer.uint32(18).fork()).join();
2734
+ });
2735
+ for (const v of message.gatewayOperators) {
2736
+ writer.uint32(26).string(v);
2737
+ }
2738
+ if (!message.minValidatorBond.equals(Long.UZERO)) {
2739
+ writer.uint32(32).uint64(message.minValidatorBond.toString());
2740
+ }
2741
+ if (message.protocolFeeBps !== 0) {
2742
+ writer.uint32(40).uint32(message.protocolFeeBps);
2743
+ }
2723
2744
  return writer;
2724
2745
  },
2725
2746
  decode(input, length) {
@@ -2728,6 +2749,46 @@ const Params$c = {
2728
2749
  const message = createBaseParams$c();
2729
2750
  while (reader.pos < end) {
2730
2751
  const tag = reader.uint32();
2752
+ switch (tag >>> 3) {
2753
+ case 1: {
2754
+ if (tag !== 8) {
2755
+ break;
2756
+ }
2757
+ message.vrfShuffleEnforced = reader.bool();
2758
+ continue;
2759
+ }
2760
+ case 2: {
2761
+ if (tag !== 18) {
2762
+ break;
2763
+ }
2764
+ const entry2 = Params_SngPayoutStructuresEntry.decode(reader, reader.uint32());
2765
+ if (entry2.value !== undefined) {
2766
+ message.sngPayoutStructures[entry2.key] = entry2.value;
2767
+ }
2768
+ continue;
2769
+ }
2770
+ case 3: {
2771
+ if (tag !== 26) {
2772
+ break;
2773
+ }
2774
+ message.gatewayOperators.push(reader.string());
2775
+ continue;
2776
+ }
2777
+ case 4: {
2778
+ if (tag !== 32) {
2779
+ break;
2780
+ }
2781
+ message.minValidatorBond = Long.fromString(reader.uint64().toString(), true);
2782
+ continue;
2783
+ }
2784
+ case 5: {
2785
+ if (tag !== 40) {
2786
+ break;
2787
+ }
2788
+ message.protocolFeeBps = reader.uint32();
2789
+ continue;
2790
+ }
2791
+ }
2731
2792
  if ((tag & 7) === 4 || tag === 0) {
2732
2793
  break;
2733
2794
  }
@@ -2735,21 +2796,207 @@ const Params$c = {
2735
2796
  }
2736
2797
  return message;
2737
2798
  },
2738
- fromJSON(_) {
2739
- return {};
2799
+ fromJSON(object) {
2800
+ return {
2801
+ vrfShuffleEnforced: isSet$2c(object.vrfShuffleEnforced) ? globalThis.Boolean(object.vrfShuffleEnforced) : false,
2802
+ sngPayoutStructures: isObject$1(object.sngPayoutStructures)
2803
+ ? Object.entries(object.sngPayoutStructures).reduce((acc, [key, value]) => {
2804
+ acc[globalThis.Number(key)] = SngPayoutStructure.fromJSON(value);
2805
+ return acc;
2806
+ }, {})
2807
+ : {},
2808
+ gatewayOperators: globalThis.Array.isArray(object?.gatewayOperators)
2809
+ ? object.gatewayOperators.map((e) => globalThis.String(e))
2810
+ : [],
2811
+ minValidatorBond: isSet$2c(object.minValidatorBond) ? Long.fromValue(object.minValidatorBond) : Long.UZERO,
2812
+ protocolFeeBps: isSet$2c(object.protocolFeeBps) ? globalThis.Number(object.protocolFeeBps) : 0,
2813
+ };
2740
2814
  },
2741
- toJSON(_) {
2815
+ toJSON(message) {
2742
2816
  const obj = {};
2817
+ if (message.vrfShuffleEnforced !== false) {
2818
+ obj.vrfShuffleEnforced = message.vrfShuffleEnforced;
2819
+ }
2820
+ if (message.sngPayoutStructures) {
2821
+ const entries = Object.entries(message.sngPayoutStructures);
2822
+ if (entries.length > 0) {
2823
+ obj.sngPayoutStructures = {};
2824
+ entries.forEach(([k, v]) => {
2825
+ obj.sngPayoutStructures[k] = SngPayoutStructure.toJSON(v);
2826
+ });
2827
+ }
2828
+ }
2829
+ if (message.gatewayOperators?.length) {
2830
+ obj.gatewayOperators = message.gatewayOperators;
2831
+ }
2832
+ if (!message.minValidatorBond.equals(Long.UZERO)) {
2833
+ obj.minValidatorBond = (message.minValidatorBond || Long.UZERO).toString();
2834
+ }
2835
+ if (message.protocolFeeBps !== 0) {
2836
+ obj.protocolFeeBps = Math.round(message.protocolFeeBps);
2837
+ }
2743
2838
  return obj;
2744
2839
  },
2745
2840
  create(base) {
2746
2841
  return Params$c.fromPartial(base ?? {});
2747
2842
  },
2748
- fromPartial(_) {
2843
+ fromPartial(object) {
2749
2844
  const message = createBaseParams$c();
2845
+ message.vrfShuffleEnforced = object.vrfShuffleEnforced ?? false;
2846
+ message.sngPayoutStructures = Object.entries(object.sngPayoutStructures ?? {}).reduce((acc, [key, value]) => {
2847
+ if (value !== undefined) {
2848
+ acc[globalThis.Number(key)] = SngPayoutStructure.fromPartial(value);
2849
+ }
2850
+ return acc;
2851
+ }, {});
2852
+ message.gatewayOperators = object.gatewayOperators?.map((e) => e) || [];
2853
+ message.minValidatorBond = (object.minValidatorBond !== undefined && object.minValidatorBond !== null)
2854
+ ? Long.fromValue(object.minValidatorBond)
2855
+ : Long.UZERO;
2856
+ message.protocolFeeBps = object.protocolFeeBps ?? 0;
2857
+ return message;
2858
+ },
2859
+ };
2860
+ function createBaseParams_SngPayoutStructuresEntry() {
2861
+ return { key: 0, value: undefined };
2862
+ }
2863
+ const Params_SngPayoutStructuresEntry = {
2864
+ encode(message, writer = new BinaryWriter()) {
2865
+ if (message.key !== 0) {
2866
+ writer.uint32(8).uint32(message.key);
2867
+ }
2868
+ if (message.value !== undefined) {
2869
+ SngPayoutStructure.encode(message.value, writer.uint32(18).fork()).join();
2870
+ }
2871
+ return writer;
2872
+ },
2873
+ decode(input, length) {
2874
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2875
+ const end = length === undefined ? reader.len : reader.pos + length;
2876
+ const message = createBaseParams_SngPayoutStructuresEntry();
2877
+ while (reader.pos < end) {
2878
+ const tag = reader.uint32();
2879
+ switch (tag >>> 3) {
2880
+ case 1: {
2881
+ if (tag !== 8) {
2882
+ break;
2883
+ }
2884
+ message.key = reader.uint32();
2885
+ continue;
2886
+ }
2887
+ case 2: {
2888
+ if (tag !== 18) {
2889
+ break;
2890
+ }
2891
+ message.value = SngPayoutStructure.decode(reader, reader.uint32());
2892
+ continue;
2893
+ }
2894
+ }
2895
+ if ((tag & 7) === 4 || tag === 0) {
2896
+ break;
2897
+ }
2898
+ reader.skip(tag & 7);
2899
+ }
2900
+ return message;
2901
+ },
2902
+ fromJSON(object) {
2903
+ return {
2904
+ key: isSet$2c(object.key) ? globalThis.Number(object.key) : 0,
2905
+ value: isSet$2c(object.value) ? SngPayoutStructure.fromJSON(object.value) : undefined,
2906
+ };
2907
+ },
2908
+ toJSON(message) {
2909
+ const obj = {};
2910
+ if (message.key !== 0) {
2911
+ obj.key = Math.round(message.key);
2912
+ }
2913
+ if (message.value !== undefined) {
2914
+ obj.value = SngPayoutStructure.toJSON(message.value);
2915
+ }
2916
+ return obj;
2917
+ },
2918
+ create(base) {
2919
+ return Params_SngPayoutStructuresEntry.fromPartial(base ?? {});
2920
+ },
2921
+ fromPartial(object) {
2922
+ const message = createBaseParams_SngPayoutStructuresEntry();
2923
+ message.key = object.key ?? 0;
2924
+ message.value = (object.value !== undefined && object.value !== null)
2925
+ ? SngPayoutStructure.fromPartial(object.value)
2926
+ : undefined;
2927
+ return message;
2928
+ },
2929
+ };
2930
+ function createBaseSngPayoutStructure() {
2931
+ return { payoutsBps: [] };
2932
+ }
2933
+ const SngPayoutStructure = {
2934
+ encode(message, writer = new BinaryWriter()) {
2935
+ writer.uint32(10).fork();
2936
+ for (const v of message.payoutsBps) {
2937
+ writer.uint32(v);
2938
+ }
2939
+ writer.join();
2940
+ return writer;
2941
+ },
2942
+ decode(input, length) {
2943
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
2944
+ const end = length === undefined ? reader.len : reader.pos + length;
2945
+ const message = createBaseSngPayoutStructure();
2946
+ while (reader.pos < end) {
2947
+ const tag = reader.uint32();
2948
+ switch (tag >>> 3) {
2949
+ case 1: {
2950
+ if (tag === 8) {
2951
+ message.payoutsBps.push(reader.uint32());
2952
+ continue;
2953
+ }
2954
+ if (tag === 10) {
2955
+ const end2 = reader.uint32() + reader.pos;
2956
+ while (reader.pos < end2) {
2957
+ message.payoutsBps.push(reader.uint32());
2958
+ }
2959
+ continue;
2960
+ }
2961
+ break;
2962
+ }
2963
+ }
2964
+ if ((tag & 7) === 4 || tag === 0) {
2965
+ break;
2966
+ }
2967
+ reader.skip(tag & 7);
2968
+ }
2969
+ return message;
2970
+ },
2971
+ fromJSON(object) {
2972
+ return {
2973
+ payoutsBps: globalThis.Array.isArray(object?.payoutsBps)
2974
+ ? object.payoutsBps.map((e) => globalThis.Number(e))
2975
+ : [],
2976
+ };
2977
+ },
2978
+ toJSON(message) {
2979
+ const obj = {};
2980
+ if (message.payoutsBps?.length) {
2981
+ obj.payoutsBps = message.payoutsBps.map((e) => Math.round(e));
2982
+ }
2983
+ return obj;
2984
+ },
2985
+ create(base) {
2986
+ return SngPayoutStructure.fromPartial(base ?? {});
2987
+ },
2988
+ fromPartial(object) {
2989
+ const message = createBaseSngPayoutStructure();
2990
+ message.payoutsBps = object.payoutsBps?.map((e) => e) || [];
2750
2991
  return message;
2751
2992
  },
2752
2993
  };
2994
+ function isObject$1(value) {
2995
+ return typeof value === "object" && value !== null;
2996
+ }
2997
+ function isSet$2c(value) {
2998
+ return value !== null && value !== undefined;
2999
+ }
2753
3000
 
2754
3001
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2755
3002
  // versions:
@@ -2846,6 +3093,7 @@ function createBaseMsgCreateGame() {
2846
3093
  blindLevelDuration: 0,
2847
3094
  gameVariant: "",
2848
3095
  entryFee: Long.UZERO,
3096
+ playerSeed: new Uint8Array(0),
2849
3097
  name: "",
2850
3098
  bettingLimit: "",
2851
3099
  startTime: Long.ZERO,
@@ -2907,6 +3155,9 @@ const MsgCreateGame = {
2907
3155
  if (!message.entryFee.equals(Long.UZERO)) {
2908
3156
  writer.uint32(136).uint64(message.entryFee.toString());
2909
3157
  }
3158
+ if (message.playerSeed.length !== 0) {
3159
+ writer.uint32(146).bytes(message.playerSeed);
3160
+ }
2910
3161
  if (message.name !== "") {
2911
3162
  writer.uint32(154).string(message.name);
2912
3163
  }
@@ -3053,6 +3304,13 @@ const MsgCreateGame = {
3053
3304
  message.entryFee = Long.fromString(reader.uint64().toString(), true);
3054
3305
  continue;
3055
3306
  }
3307
+ case 18: {
3308
+ if (tag !== 146) {
3309
+ break;
3310
+ }
3311
+ message.playerSeed = reader.bytes();
3312
+ continue;
3313
+ }
3056
3314
  case 19: {
3057
3315
  if (tag !== 154) {
3058
3316
  break;
@@ -3122,11 +3380,14 @@ const MsgCreateGame = {
3122
3380
  blindLevelDuration: isSet$2b(object.blindLevelDuration) ? globalThis.Number(object.blindLevelDuration) : 0,
3123
3381
  gameVariant: isSet$2b(object.gameVariant) ? globalThis.String(object.gameVariant) : "",
3124
3382
  entryFee: isSet$2b(object.entryFee) ? Long.fromValue(object.entryFee) : Long.UZERO,
3383
+ playerSeed: isSet$2b(object.playerSeed) ? bytesFromBase64$F(object.playerSeed) : new Uint8Array(0),
3125
3384
  name: isSet$2b(object.name) ? globalThis.String(object.name) : "",
3126
3385
  bettingLimit: isSet$2b(object.bettingLimit) ? globalThis.String(object.bettingLimit) : "",
3127
3386
  startTime: isSet$2b(object.startTime) ? Long.fromValue(object.startTime) : Long.ZERO,
3128
3387
  blindStructure: isSet$2b(object.blindStructure) ? globalThis.String(object.blindStructure) : "",
3129
- lateRegistrationLevels: isSet$2b(object.lateRegistrationLevels) ? globalThis.Number(object.lateRegistrationLevels) : 0,
3388
+ lateRegistrationLevels: isSet$2b(object.lateRegistrationLevels)
3389
+ ? globalThis.Number(object.lateRegistrationLevels)
3390
+ : 0,
3130
3391
  waitForStartTime: isSet$2b(object.waitForStartTime) ? globalThis.Boolean(object.waitForStartTime) : false,
3131
3392
  };
3132
3393
  },
@@ -3183,6 +3444,9 @@ const MsgCreateGame = {
3183
3444
  if (!message.entryFee.equals(Long.UZERO)) {
3184
3445
  obj.entryFee = (message.entryFee || Long.UZERO).toString();
3185
3446
  }
3447
+ if (message.playerSeed.length !== 0) {
3448
+ obj.playerSeed = base64FromBytes$F(message.playerSeed);
3449
+ }
3186
3450
  if (message.name !== "") {
3187
3451
  obj.name = message.name;
3188
3452
  }
@@ -3244,6 +3508,10 @@ const MsgCreateGame = {
3244
3508
  : Long.UZERO;
3245
3509
  message.blindLevelDuration = object.blindLevelDuration ?? 0;
3246
3510
  message.gameVariant = object.gameVariant ?? "";
3511
+ message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
3512
+ ? Long.fromValue(object.entryFee)
3513
+ : Long.UZERO;
3514
+ message.playerSeed = object.playerSeed ?? new Uint8Array(0);
3247
3515
  message.name = object.name ?? "";
3248
3516
  message.bettingLimit = object.bettingLimit ?? "";
3249
3517
  message.startTime = (object.startTime !== undefined && object.startTime !== null)
@@ -3252,9 +3520,6 @@ const MsgCreateGame = {
3252
3520
  message.blindStructure = object.blindStructure ?? "";
3253
3521
  message.lateRegistrationLevels = object.lateRegistrationLevels ?? 0;
3254
3522
  message.waitForStartTime = object.waitForStartTime ?? false;
3255
- message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
3256
- ? Long.fromValue(object.entryFee)
3257
- : Long.UZERO;
3258
3523
  return message;
3259
3524
  },
3260
3525
  };
@@ -4485,6 +4750,372 @@ const MsgRegisterNftAvatar = {
4485
4750
  return message;
4486
4751
  },
4487
4752
  };
4753
+ function createBaseMsgCreateTournament() {
4754
+ return {
4755
+ creator: "",
4756
+ buyIn: Long.UZERO,
4757
+ entryFee: Long.UZERO,
4758
+ startingStack: Long.UZERO,
4759
+ seatsPerTable: 0,
4760
+ minEntrants: 0,
4761
+ maxEntrants: 0,
4762
+ startTime: Long.ZERO,
4763
+ blindStructure: "",
4764
+ actionTimeoutSeconds: 0,
4765
+ };
4766
+ }
4767
+ const MsgCreateTournament = {
4768
+ encode(message, writer = new BinaryWriter()) {
4769
+ if (message.creator !== "") {
4770
+ writer.uint32(10).string(message.creator);
4771
+ }
4772
+ if (!message.buyIn.equals(Long.UZERO)) {
4773
+ writer.uint32(16).uint64(message.buyIn.toString());
4774
+ }
4775
+ if (!message.entryFee.equals(Long.UZERO)) {
4776
+ writer.uint32(24).uint64(message.entryFee.toString());
4777
+ }
4778
+ if (!message.startingStack.equals(Long.UZERO)) {
4779
+ writer.uint32(32).uint64(message.startingStack.toString());
4780
+ }
4781
+ if (message.seatsPerTable !== 0) {
4782
+ writer.uint32(40).uint32(message.seatsPerTable);
4783
+ }
4784
+ if (message.minEntrants !== 0) {
4785
+ writer.uint32(48).uint32(message.minEntrants);
4786
+ }
4787
+ if (message.maxEntrants !== 0) {
4788
+ writer.uint32(56).uint32(message.maxEntrants);
4789
+ }
4790
+ if (!message.startTime.equals(Long.ZERO)) {
4791
+ writer.uint32(64).int64(message.startTime.toString());
4792
+ }
4793
+ if (message.blindStructure !== "") {
4794
+ writer.uint32(74).string(message.blindStructure);
4795
+ }
4796
+ if (message.actionTimeoutSeconds !== 0) {
4797
+ writer.uint32(80).uint32(message.actionTimeoutSeconds);
4798
+ }
4799
+ return writer;
4800
+ },
4801
+ decode(input, length) {
4802
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
4803
+ const end = length === undefined ? reader.len : reader.pos + length;
4804
+ const message = createBaseMsgCreateTournament();
4805
+ while (reader.pos < end) {
4806
+ const tag = reader.uint32();
4807
+ switch (tag >>> 3) {
4808
+ case 1: {
4809
+ if (tag !== 10) {
4810
+ break;
4811
+ }
4812
+ message.creator = reader.string();
4813
+ continue;
4814
+ }
4815
+ case 2: {
4816
+ if (tag !== 16) {
4817
+ break;
4818
+ }
4819
+ message.buyIn = Long.fromString(reader.uint64().toString(), true);
4820
+ continue;
4821
+ }
4822
+ case 3: {
4823
+ if (tag !== 24) {
4824
+ break;
4825
+ }
4826
+ message.entryFee = Long.fromString(reader.uint64().toString(), true);
4827
+ continue;
4828
+ }
4829
+ case 4: {
4830
+ if (tag !== 32) {
4831
+ break;
4832
+ }
4833
+ message.startingStack = Long.fromString(reader.uint64().toString(), true);
4834
+ continue;
4835
+ }
4836
+ case 5: {
4837
+ if (tag !== 40) {
4838
+ break;
4839
+ }
4840
+ message.seatsPerTable = reader.uint32();
4841
+ continue;
4842
+ }
4843
+ case 6: {
4844
+ if (tag !== 48) {
4845
+ break;
4846
+ }
4847
+ message.minEntrants = reader.uint32();
4848
+ continue;
4849
+ }
4850
+ case 7: {
4851
+ if (tag !== 56) {
4852
+ break;
4853
+ }
4854
+ message.maxEntrants = reader.uint32();
4855
+ continue;
4856
+ }
4857
+ case 8: {
4858
+ if (tag !== 64) {
4859
+ break;
4860
+ }
4861
+ message.startTime = Long.fromString(reader.int64().toString());
4862
+ continue;
4863
+ }
4864
+ case 9: {
4865
+ if (tag !== 74) {
4866
+ break;
4867
+ }
4868
+ message.blindStructure = reader.string();
4869
+ continue;
4870
+ }
4871
+ case 10: {
4872
+ if (tag !== 80) {
4873
+ break;
4874
+ }
4875
+ message.actionTimeoutSeconds = reader.uint32();
4876
+ continue;
4877
+ }
4878
+ }
4879
+ if ((tag & 7) === 4 || tag === 0) {
4880
+ break;
4881
+ }
4882
+ reader.skip(tag & 7);
4883
+ }
4884
+ return message;
4885
+ },
4886
+ fromJSON(object) {
4887
+ return {
4888
+ creator: isSet$2b(object.creator) ? globalThis.String(object.creator) : "",
4889
+ buyIn: isSet$2b(object.buyIn) ? Long.fromValue(object.buyIn) : Long.UZERO,
4890
+ entryFee: isSet$2b(object.entryFee) ? Long.fromValue(object.entryFee) : Long.UZERO,
4891
+ startingStack: isSet$2b(object.startingStack) ? Long.fromValue(object.startingStack) : Long.UZERO,
4892
+ seatsPerTable: isSet$2b(object.seatsPerTable) ? globalThis.Number(object.seatsPerTable) : 0,
4893
+ minEntrants: isSet$2b(object.minEntrants) ? globalThis.Number(object.minEntrants) : 0,
4894
+ maxEntrants: isSet$2b(object.maxEntrants) ? globalThis.Number(object.maxEntrants) : 0,
4895
+ startTime: isSet$2b(object.startTime) ? Long.fromValue(object.startTime) : Long.ZERO,
4896
+ blindStructure: isSet$2b(object.blindStructure) ? globalThis.String(object.blindStructure) : "",
4897
+ actionTimeoutSeconds: isSet$2b(object.actionTimeoutSeconds) ? globalThis.Number(object.actionTimeoutSeconds) : 0,
4898
+ };
4899
+ },
4900
+ toJSON(message) {
4901
+ const obj = {};
4902
+ if (message.creator !== "") {
4903
+ obj.creator = message.creator;
4904
+ }
4905
+ if (!message.buyIn.equals(Long.UZERO)) {
4906
+ obj.buyIn = (message.buyIn || Long.UZERO).toString();
4907
+ }
4908
+ if (!message.entryFee.equals(Long.UZERO)) {
4909
+ obj.entryFee = (message.entryFee || Long.UZERO).toString();
4910
+ }
4911
+ if (!message.startingStack.equals(Long.UZERO)) {
4912
+ obj.startingStack = (message.startingStack || Long.UZERO).toString();
4913
+ }
4914
+ if (message.seatsPerTable !== 0) {
4915
+ obj.seatsPerTable = Math.round(message.seatsPerTable);
4916
+ }
4917
+ if (message.minEntrants !== 0) {
4918
+ obj.minEntrants = Math.round(message.minEntrants);
4919
+ }
4920
+ if (message.maxEntrants !== 0) {
4921
+ obj.maxEntrants = Math.round(message.maxEntrants);
4922
+ }
4923
+ if (!message.startTime.equals(Long.ZERO)) {
4924
+ obj.startTime = (message.startTime || Long.ZERO).toString();
4925
+ }
4926
+ if (message.blindStructure !== "") {
4927
+ obj.blindStructure = message.blindStructure;
4928
+ }
4929
+ if (message.actionTimeoutSeconds !== 0) {
4930
+ obj.actionTimeoutSeconds = Math.round(message.actionTimeoutSeconds);
4931
+ }
4932
+ return obj;
4933
+ },
4934
+ create(base) {
4935
+ return MsgCreateTournament.fromPartial(base ?? {});
4936
+ },
4937
+ fromPartial(object) {
4938
+ const message = createBaseMsgCreateTournament();
4939
+ message.creator = object.creator ?? "";
4940
+ message.buyIn = (object.buyIn !== undefined && object.buyIn !== null) ? Long.fromValue(object.buyIn) : Long.UZERO;
4941
+ message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
4942
+ ? Long.fromValue(object.entryFee)
4943
+ : Long.UZERO;
4944
+ message.startingStack = (object.startingStack !== undefined && object.startingStack !== null)
4945
+ ? Long.fromValue(object.startingStack)
4946
+ : Long.UZERO;
4947
+ message.seatsPerTable = object.seatsPerTable ?? 0;
4948
+ message.minEntrants = object.minEntrants ?? 0;
4949
+ message.maxEntrants = object.maxEntrants ?? 0;
4950
+ message.startTime = (object.startTime !== undefined && object.startTime !== null)
4951
+ ? Long.fromValue(object.startTime)
4952
+ : Long.ZERO;
4953
+ message.blindStructure = object.blindStructure ?? "";
4954
+ message.actionTimeoutSeconds = object.actionTimeoutSeconds ?? 0;
4955
+ return message;
4956
+ },
4957
+ };
4958
+ function createBaseMsgRegisterTournament() {
4959
+ return { player: "", tournamentId: "" };
4960
+ }
4961
+ const MsgRegisterTournament = {
4962
+ encode(message, writer = new BinaryWriter()) {
4963
+ if (message.player !== "") {
4964
+ writer.uint32(10).string(message.player);
4965
+ }
4966
+ if (message.tournamentId !== "") {
4967
+ writer.uint32(18).string(message.tournamentId);
4968
+ }
4969
+ return writer;
4970
+ },
4971
+ decode(input, length) {
4972
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
4973
+ const end = length === undefined ? reader.len : reader.pos + length;
4974
+ const message = createBaseMsgRegisterTournament();
4975
+ while (reader.pos < end) {
4976
+ const tag = reader.uint32();
4977
+ switch (tag >>> 3) {
4978
+ case 1: {
4979
+ if (tag !== 10) {
4980
+ break;
4981
+ }
4982
+ message.player = reader.string();
4983
+ continue;
4984
+ }
4985
+ case 2: {
4986
+ if (tag !== 18) {
4987
+ break;
4988
+ }
4989
+ message.tournamentId = reader.string();
4990
+ continue;
4991
+ }
4992
+ }
4993
+ if ((tag & 7) === 4 || tag === 0) {
4994
+ break;
4995
+ }
4996
+ reader.skip(tag & 7);
4997
+ }
4998
+ return message;
4999
+ },
5000
+ fromJSON(object) {
5001
+ return {
5002
+ player: isSet$2b(object.player) ? globalThis.String(object.player) : "",
5003
+ tournamentId: isSet$2b(object.tournamentId) ? globalThis.String(object.tournamentId) : "",
5004
+ };
5005
+ },
5006
+ toJSON(message) {
5007
+ const obj = {};
5008
+ if (message.player !== "") {
5009
+ obj.player = message.player;
5010
+ }
5011
+ if (message.tournamentId !== "") {
5012
+ obj.tournamentId = message.tournamentId;
5013
+ }
5014
+ return obj;
5015
+ },
5016
+ create(base) {
5017
+ return MsgRegisterTournament.fromPartial(base ?? {});
5018
+ },
5019
+ fromPartial(object) {
5020
+ const message = createBaseMsgRegisterTournament();
5021
+ message.player = object.player ?? "";
5022
+ message.tournamentId = object.tournamentId ?? "";
5023
+ return message;
5024
+ },
5025
+ };
5026
+ function createBaseMsgUnregisterTournament() {
5027
+ return { player: "", tournamentId: "" };
5028
+ }
5029
+ const MsgUnregisterTournament = {
5030
+ encode(message, writer = new BinaryWriter()) {
5031
+ if (message.player !== "") {
5032
+ writer.uint32(10).string(message.player);
5033
+ }
5034
+ if (message.tournamentId !== "") {
5035
+ writer.uint32(18).string(message.tournamentId);
5036
+ }
5037
+ return writer;
5038
+ },
5039
+ decode(input, length) {
5040
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
5041
+ const end = length === undefined ? reader.len : reader.pos + length;
5042
+ const message = createBaseMsgUnregisterTournament();
5043
+ while (reader.pos < end) {
5044
+ const tag = reader.uint32();
5045
+ switch (tag >>> 3) {
5046
+ case 1: {
5047
+ if (tag !== 10) {
5048
+ break;
5049
+ }
5050
+ message.player = reader.string();
5051
+ continue;
5052
+ }
5053
+ case 2: {
5054
+ if (tag !== 18) {
5055
+ break;
5056
+ }
5057
+ message.tournamentId = reader.string();
5058
+ continue;
5059
+ }
5060
+ }
5061
+ if ((tag & 7) === 4 || tag === 0) {
5062
+ break;
5063
+ }
5064
+ reader.skip(tag & 7);
5065
+ }
5066
+ return message;
5067
+ },
5068
+ fromJSON(object) {
5069
+ return {
5070
+ player: isSet$2b(object.player) ? globalThis.String(object.player) : "",
5071
+ tournamentId: isSet$2b(object.tournamentId) ? globalThis.String(object.tournamentId) : "",
5072
+ };
5073
+ },
5074
+ toJSON(message) {
5075
+ const obj = {};
5076
+ if (message.player !== "") {
5077
+ obj.player = message.player;
5078
+ }
5079
+ if (message.tournamentId !== "") {
5080
+ obj.tournamentId = message.tournamentId;
5081
+ }
5082
+ return obj;
5083
+ },
5084
+ create(base) {
5085
+ return MsgUnregisterTournament.fromPartial(base ?? {});
5086
+ },
5087
+ fromPartial(object) {
5088
+ const message = createBaseMsgUnregisterTournament();
5089
+ message.player = object.player ?? "";
5090
+ message.tournamentId = object.tournamentId ?? "";
5091
+ return message;
5092
+ },
5093
+ };
5094
+ function bytesFromBase64$F(b64) {
5095
+ if (globalThis.Buffer) {
5096
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
5097
+ }
5098
+ else {
5099
+ const bin = globalThis.atob(b64);
5100
+ const arr = new Uint8Array(bin.length);
5101
+ for (let i = 0; i < bin.length; ++i) {
5102
+ arr[i] = bin.charCodeAt(i);
5103
+ }
5104
+ return arr;
5105
+ }
5106
+ }
5107
+ function base64FromBytes$F(arr) {
5108
+ if (globalThis.Buffer) {
5109
+ return globalThis.Buffer.from(arr).toString("base64");
5110
+ }
5111
+ else {
5112
+ const bin = [];
5113
+ arr.forEach((byte) => {
5114
+ bin.push(globalThis.String.fromCharCode(byte));
5115
+ });
5116
+ return globalThis.btoa(bin.join(""));
5117
+ }
5118
+ }
4488
5119
  function isSet$2b(value) {
4489
5120
  return value !== null && value !== undefined;
4490
5121
  }
@@ -4516,6 +5147,9 @@ const msgTypes$u = [
4516
5147
  ["/pokerchain.poker.v1.MsgDeleteGame", asGeneratedType(MsgDeleteGame)],
4517
5148
  ["/pokerchain.poker.v1.MsgForceCloseGame", asGeneratedType(MsgForceCloseGame)],
4518
5149
  ["/pokerchain.poker.v1.MsgRegisterNftAvatar", asGeneratedType(MsgRegisterNftAvatar)],
5150
+ ["/pokerchain.poker.v1.MsgCreateTournament", asGeneratedType(MsgCreateTournament)],
5151
+ ["/pokerchain.poker.v1.MsgRegisterTournament", asGeneratedType(MsgRegisterTournament)],
5152
+ ["/pokerchain.poker.v1.MsgUnregisterTournament", asGeneratedType(MsgUnregisterTournament)],
4519
5153
  ];
4520
5154
 
4521
5155
  /**
@@ -8853,76 +9487,6 @@ const WithdrawalRequest = {
8853
9487
  return message;
8854
9488
  },
8855
9489
  };
8856
- function createBaseValidatorBond() {
8857
- return { validator: "", bondedUsdc: Long.UZERO };
8858
- }
8859
- const ValidatorBond = {
8860
- encode(message, writer = new BinaryWriter()) {
8861
- if (message.validator !== "") {
8862
- writer.uint32(10).string(message.validator);
8863
- }
8864
- if (!message.bondedUsdc.equals(Long.UZERO)) {
8865
- writer.uint32(16).uint64(message.bondedUsdc.toString());
8866
- }
8867
- return writer;
8868
- },
8869
- decode(input, length) {
8870
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
8871
- const end = length === undefined ? reader.len : reader.pos + length;
8872
- const message = createBaseValidatorBond();
8873
- while (reader.pos < end) {
8874
- const tag = reader.uint32();
8875
- switch (tag >>> 3) {
8876
- case 1: {
8877
- if (tag !== 10) {
8878
- break;
8879
- }
8880
- message.validator = reader.string();
8881
- continue;
8882
- }
8883
- case 2: {
8884
- if (tag !== 16) {
8885
- break;
8886
- }
8887
- message.bondedUsdc = Long.fromString(reader.uint64().toString(), true);
8888
- continue;
8889
- }
8890
- }
8891
- if ((tag & 7) === 4 || tag === 0) {
8892
- break;
8893
- }
8894
- reader.skip(tag & 7);
8895
- }
8896
- return message;
8897
- },
8898
- fromJSON(object) {
8899
- return {
8900
- validator: isSet$2a(object.validator) ? globalThis.String(object.validator) : "",
8901
- bondedUsdc: isSet$2a(object.bondedUsdc) ? Long.fromValue(object.bondedUsdc) : Long.UZERO,
8902
- };
8903
- },
8904
- toJSON(message) {
8905
- const obj = {};
8906
- if (message.validator !== "") {
8907
- obj.validator = message.validator;
8908
- }
8909
- if (!message.bondedUsdc.equals(Long.UZERO)) {
8910
- obj.bondedUsdc = (message.bondedUsdc || Long.UZERO).toString();
8911
- }
8912
- return obj;
8913
- },
8914
- create(base) {
8915
- return ValidatorBond.fromPartial(base ?? {});
8916
- },
8917
- fromPartial(object) {
8918
- const message = createBaseValidatorBond();
8919
- message.validator = object.validator ?? "";
8920
- message.bondedUsdc = (object.bondedUsdc !== undefined && object.bondedUsdc !== null)
8921
- ? Long.fromValue(object.bondedUsdc)
8922
- : Long.UZERO;
8923
- return message;
8924
- },
8925
- };
8926
9490
  function bytesFromBase64$E(b64) {
8927
9491
  if (globalThis.Buffer) {
8928
9492
  return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
@@ -57198,35 +57762,35 @@ function parseLeaderboardDTO(json) {
57198
57762
  throw new Error("tournament leaderboard: empty leaderboard JSON");
57199
57763
  }
57200
57764
  const raw = JSON.parse(json);
57201
- if (!isRecord(raw)) {
57765
+ if (!isRecord$1(raw)) {
57202
57766
  throw new Error("tournament leaderboard: expected a JSON object");
57203
57767
  }
57204
- requireString(raw, "tournamentId", "leaderboard");
57768
+ requireString$1(raw, "tournamentId", "leaderboard");
57205
57769
  requireStatus(raw, "leaderboard");
57206
- requireNumber(raw, "entrants", "leaderboard");
57207
- requireNumber(raw, "remaining", "leaderboard");
57208
- requireString(raw, "averageStack", "leaderboard");
57209
- requireString(raw, "prizePool", "leaderboard");
57770
+ requireNumber$1(raw, "entrants", "leaderboard");
57771
+ requireNumber$1(raw, "remaining", "leaderboard");
57772
+ requireString$1(raw, "averageStack", "leaderboard");
57773
+ requireString$1(raw, "prizePool", "leaderboard");
57210
57774
  if (!Array.isArray(raw.payouts)) {
57211
57775
  throw new Error("tournament leaderboard: payouts must be an array");
57212
57776
  }
57213
57777
  raw.payouts.forEach((p, i) => {
57214
57778
  const where = `payouts[${i}]`;
57215
- if (!isRecord(p))
57779
+ if (!isRecord$1(p))
57216
57780
  throw new Error(`tournament leaderboard: ${where} must be an object`);
57217
- requireNumber(p, "place", where);
57218
- requireString(p, "amount", where);
57781
+ requireNumber$1(p, "place", where);
57782
+ requireString$1(p, "amount", where);
57219
57783
  });
57220
57784
  if (raw.clock !== undefined) {
57221
- if (!isRecord(raw.clock))
57785
+ if (!isRecord$1(raw.clock))
57222
57786
  throw new Error("tournament leaderboard: clock must be an object");
57223
- requireNumber(raw.clock, "level", "clock");
57224
- requireString(raw.clock, "smallBlind", "clock");
57225
- requireString(raw.clock, "bigBlind", "clock");
57226
- requireString(raw.clock, "ante", "clock");
57227
- optionalNumber(raw.clock, "levelStartTime", "clock");
57787
+ requireNumber$1(raw.clock, "level", "clock");
57788
+ requireString$1(raw.clock, "smallBlind", "clock");
57789
+ requireString$1(raw.clock, "bigBlind", "clock");
57790
+ requireString$1(raw.clock, "ante", "clock");
57791
+ optionalNumber$1(raw.clock, "levelStartTime", "clock");
57228
57792
  }
57229
- optionalNumber(raw, "nextLevelAt", "leaderboard");
57793
+ optionalNumber$1(raw, "nextLevelAt", "leaderboard");
57230
57794
  if (!Array.isArray(raw.entries)) {
57231
57795
  throw new Error("tournament leaderboard: entries must be an array");
57232
57796
  }
@@ -57234,34 +57798,158 @@ function parseLeaderboardDTO(json) {
57234
57798
  return raw;
57235
57799
  }
57236
57800
  function requireEntry(e, where) {
57237
- if (!isRecord(e))
57801
+ if (!isRecord$1(e))
57238
57802
  throw new Error(`tournament leaderboard: ${where} must be an object`);
57239
- requireNumber(e, "rank", where);
57240
- requireString(e, "address", where);
57803
+ requireNumber$1(e, "rank", where);
57804
+ requireString$1(e, "address", where);
57241
57805
  if (!TOURNAMENT_ENTRANT_STATUSES.includes(e.status)) {
57242
57806
  throw new Error(`tournament leaderboard: ${where}.status "${String(e.status)}" is not an entrant status`);
57243
57807
  }
57244
- requireString(e, "stack", where);
57245
- optionalString(e, "tableId", where);
57246
- optionalNumber(e, "seat", where);
57247
- optionalNumber(e, "place", where);
57248
- optionalString(e, "payout", where);
57808
+ requireString$1(e, "stack", where);
57809
+ optionalString$1(e, "tableId", where);
57810
+ optionalNumber$1(e, "seat", where);
57811
+ optionalNumber$1(e, "place", where);
57812
+ optionalString$1(e, "payout", where);
57249
57813
  }
57250
57814
  function requireStatus(o, where) {
57251
57815
  if (!TOURNAMENT_STATUSES.includes(o.status)) {
57252
57816
  throw new Error(`tournament leaderboard: ${where}.status "${String(o.status)}" is not a tournament status`);
57253
57817
  }
57254
57818
  }
57819
+ function isRecord$1(v) {
57820
+ return typeof v === "object" && v !== null && !Array.isArray(v);
57821
+ }
57822
+ function requireString$1(o, key, where) {
57823
+ if (typeof o[key] !== "string")
57824
+ throw new Error(`tournament leaderboard: ${where}.${key} must be a string`);
57825
+ }
57826
+ function requireNumber$1(o, key, where) {
57827
+ if (typeof o[key] !== "number")
57828
+ throw new Error(`tournament leaderboard: ${where}.${key} must be a number`);
57829
+ }
57830
+ function optionalString$1(o, key, where) {
57831
+ if (o[key] !== undefined)
57832
+ requireString$1(o, key, where);
57833
+ }
57834
+ function optionalNumber$1(o, key, where) {
57835
+ if (o[key] !== undefined)
57836
+ requireNumber$1(o, key, where);
57837
+ }
57838
+
57839
+ /**
57840
+ * Parses the `tournament` JSON string of the chain's Tournament query
57841
+ * (GET /block52/pokerchain/poker/v1/tournament/{id}) into a TournamentStateDTO.
57842
+ * Checks the fields consumers rely on and throws on anything missing or
57843
+ * mistyped — never fills a default (Commandment 7).
57844
+ *
57845
+ * One wire quirk is normalised: the engine is Go, and a nil slice marshals as
57846
+ * `null`. A registering tournament has no tables, results or intents yet, so
57847
+ * `tables`, `payouts`, `results` and `intents` may arrive as `null` and are
57848
+ * returned as `[]`. That is an encoding artefact, not a hidden default: every
57849
+ * other missing or mistyped field throws.
57850
+ */
57851
+ function parseTournamentStateDTO(json) {
57852
+ if (json === "") {
57853
+ throw new Error("tournament: empty tournament JSON");
57854
+ }
57855
+ const raw = JSON.parse(json);
57856
+ if (!isRecord(raw)) {
57857
+ throw new Error("tournament: expected a JSON object");
57858
+ }
57859
+ requireString(raw, "tournamentId", "tournament");
57860
+ if (!TOURNAMENT_STATUSES.includes(raw.status)) {
57861
+ throw new Error(`tournament: status "${String(raw.status)}" is not a tournament status`);
57862
+ }
57863
+ requireNumber(raw, "level", "tournament");
57864
+ requireString(raw, "prizePool", "tournament");
57865
+ requireNumber(raw, "seq", "tournament");
57866
+ optionalNumber(raw, "startedAt", "tournament");
57867
+ optionalNumber(raw, "levelStartTime", "tournament");
57868
+ requireOptions(raw.options);
57869
+ if (!Array.isArray(raw.entrants)) {
57870
+ throw new Error("tournament: entrants must be an array");
57871
+ }
57872
+ raw.entrants.forEach((e, i) => requireEntrant(e, `entrants[${i}]`));
57873
+ const tables = nilSliceToEmpty(raw, "tables");
57874
+ tables.forEach((t, i) => requireTable(t, `tables[${i}]`));
57875
+ nilSliceToEmpty(raw, "payouts").forEach((p, i) => {
57876
+ const where = `payouts[${i}]`;
57877
+ if (!isRecord(p))
57878
+ throw new Error(`tournament: ${where} must be an object`);
57879
+ requireNumber(p, "place", where);
57880
+ requireString(p, "amount", where);
57881
+ });
57882
+ nilSliceToEmpty(raw, "results").forEach((r, i) => {
57883
+ const where = `results[${i}]`;
57884
+ if (!isRecord(r))
57885
+ throw new Error(`tournament: ${where} must be an object`);
57886
+ requireNumber(r, "place", where);
57887
+ requireString(r, "playerId", where);
57888
+ requireString(r, "payout", where);
57889
+ });
57890
+ nilSliceToEmpty(raw, "intents");
57891
+ return raw;
57892
+ }
57893
+ function requireOptions(o) {
57894
+ if (!isRecord(o))
57895
+ throw new Error("tournament: options must be an object");
57896
+ requireString(o, "buyIn", "options");
57897
+ optionalString(o, "entryFee", "options");
57898
+ optionalNumber(o, "protocolFeeBps", "options");
57899
+ requireString(o, "startingStack", "options");
57900
+ requireNumber(o, "seatsPerTable", "options");
57901
+ requireNumber(o, "minEntrants", "options");
57902
+ requireNumber(o, "maxEntrants", "options");
57903
+ requireNumber(o, "startTime", "options");
57904
+ requireNumber(o, "actionTimeoutSeconds", "options");
57905
+ if (!isRecord(o.blindStructure))
57906
+ throw new Error("tournament: options.blindStructure must be an object");
57907
+ }
57908
+ function requireEntrant(e, where) {
57909
+ if (!isRecord(e))
57910
+ throw new Error(`tournament: ${where} must be an object`);
57911
+ requireString(e, "address", where);
57912
+ if (!TOURNAMENT_ENTRANT_STATUSES.includes(e.status)) {
57913
+ throw new Error(`tournament: ${where}.status "${String(e.status)}" is not an entrant status`);
57914
+ }
57915
+ requireString(e, "stack", where);
57916
+ optionalString(e, "tableId", where);
57917
+ optionalNumber(e, "seat", where);
57918
+ }
57919
+ function requireTable(t, where) {
57920
+ if (!isRecord(t))
57921
+ throw new Error(`tournament: ${where} must be an object`);
57922
+ requireString(t, "tableId", where);
57923
+ requireNumber(t, "ordinal", where);
57924
+ requireNumber(t, "handNumber", where);
57925
+ if (typeof t.broken !== "boolean")
57926
+ throw new Error(`tournament: ${where}.broken must be a boolean`);
57927
+ if (typeof t.atBoundary !== "boolean")
57928
+ throw new Error(`tournament: ${where}.atBoundary must be a boolean`);
57929
+ t.players = nilSliceToEmpty(t, "players");
57930
+ optionalString(t, "hold", where);
57931
+ }
57932
+ /** A Go nil slice is `null` on the wire: return [] for null, the array as is, and throw for anything else. */
57933
+ function nilSliceToEmpty(o, key) {
57934
+ const v = o[key];
57935
+ if (v === null) {
57936
+ o[key] = [];
57937
+ return o[key];
57938
+ }
57939
+ if (!Array.isArray(v))
57940
+ throw new Error(`tournament: ${key} must be an array (or null for an empty list)`);
57941
+ return v;
57942
+ }
57255
57943
  function isRecord(v) {
57256
57944
  return typeof v === "object" && v !== null && !Array.isArray(v);
57257
57945
  }
57258
57946
  function requireString(o, key, where) {
57259
57947
  if (typeof o[key] !== "string")
57260
- throw new Error(`tournament leaderboard: ${where}.${key} must be a string`);
57948
+ throw new Error(`tournament: ${where}.${key} must be a string`);
57261
57949
  }
57262
57950
  function requireNumber(o, key, where) {
57263
57951
  if (typeof o[key] !== "number")
57264
- throw new Error(`tournament leaderboard: ${where}.${key} must be a number`);
57952
+ throw new Error(`tournament: ${where}.${key} must be a number`);
57265
57953
  }
57266
57954
  function optionalString(o, key, where) {
57267
57955
  if (o[key] !== undefined)
@@ -57272,6 +57960,61 @@ function optionalNumber(o, key, where) {
57272
57960
  requireNumber(o, key, where);
57273
57961
  }
57274
57962
 
57963
+ /** The most entrants a tournament can register (engine MaxTournamentEntrants). */
57964
+ const MAX_TOURNAMENT_ENTRANTS = 180;
57965
+ /**
57966
+ * Throws if the parameters could never create a tournament. Mirrors the
57967
+ * structural rules of the engine's NewTournament and the chain's
57968
+ * CreateTournament, so a form fails before it signs; it does not check the
57969
+ * start time against the clock or the blind structure's own rules (the engine
57970
+ * does).
57971
+ */
57972
+ function assertCreatableTournament(p) {
57973
+ if (p.buyIn <= 0n)
57974
+ throw new Error("tournament: buyIn must be positive");
57975
+ if (p.entryFee < 0n)
57976
+ throw new Error("tournament: entryFee must not be negative");
57977
+ if (p.entryFee >= p.buyIn)
57978
+ throw new Error("tournament: entryFee must be below the buyIn");
57979
+ if (p.startingStack <= 0n)
57980
+ throw new Error("tournament: startingStack must be positive");
57981
+ if (!Number.isInteger(p.seatsPerTable) || p.seatsPerTable < 2 || p.seatsPerTable > 9) {
57982
+ throw new Error("tournament: seatsPerTable must be 2..9");
57983
+ }
57984
+ if (!Number.isInteger(p.minEntrants) || p.minEntrants < 2)
57985
+ throw new Error("tournament: minEntrants must be at least 2");
57986
+ if (!Number.isInteger(p.maxEntrants) || p.maxEntrants < p.minEntrants || p.maxEntrants > MAX_TOURNAMENT_ENTRANTS) {
57987
+ throw new Error(`tournament: maxEntrants must be minEntrants..${MAX_TOURNAMENT_ENTRANTS}`);
57988
+ }
57989
+ if (!Number.isInteger(p.startTime) || p.startTime <= 0)
57990
+ throw new Error("tournament: startTime must be unix seconds");
57991
+ if (!Number.isInteger(p.actionTimeoutSeconds) || p.actionTimeoutSeconds <= 0) {
57992
+ throw new Error("tournament: actionTimeoutSeconds must be positive");
57993
+ }
57994
+ if (typeof p.blindStructure !== "object" || p.blindStructure === null) {
57995
+ throw new Error("tournament: blindStructure is required");
57996
+ }
57997
+ }
57998
+ /**
57999
+ * The MsgCreateTournament for these parameters. The blind structure travels as
58000
+ * its JSON string, the way the engine reads it.
58001
+ */
58002
+ function buildMsgCreateTournament(creator, p) {
58003
+ assertCreatableTournament(p);
58004
+ return {
58005
+ creator,
58006
+ buyIn: Long.fromString(p.buyIn.toString(), true),
58007
+ entryFee: Long.fromString(p.entryFee.toString(), true),
58008
+ startingStack: Long.fromString(p.startingStack.toString(), true),
58009
+ seatsPerTable: p.seatsPerTable,
58010
+ minEntrants: p.minEntrants,
58011
+ maxEntrants: p.maxEntrants,
58012
+ startTime: Long.fromNumber(p.startTime),
58013
+ blindStructure: JSON.stringify(p.blindStructure),
58014
+ actionTimeoutSeconds: p.actionTimeoutSeconds
58015
+ };
58016
+ }
58017
+
57275
58018
  /**
57276
58019
  * Poker hand types in order of strength (weakest to strongest)
57277
58020
  */
@@ -58932,6 +59675,34 @@ class CosmosClient {
58932
59675
  throw error;
58933
59676
  }
58934
59677
  }
59678
+ /**
59679
+ * A multi-table tournament's full record: options, entrants, tables, level
59680
+ * clock, prize pool, payouts and results (poker-vm#2613,
59681
+ * block52/pokerchain#445). Unauthenticated.
59682
+ *
59683
+ * @returns the tournament, or null when the chain has no tournament with
59684
+ * this ID (gRPC NotFound, HTTP 404). Any other failure, including a
59685
+ * malformed record, throws.
59686
+ */
59687
+ async getTournament(tournamentId) {
59688
+ if (tournamentId === "") {
59689
+ throw new Error("tournamentId is required");
59690
+ }
59691
+ try {
59692
+ const response = await this.restClient.get(`/block52/pokerchain/poker/v1/tournament/${encodeURIComponent(tournamentId)}`);
59693
+ if (!response.data || typeof response.data.tournament !== "string") {
59694
+ throw new Error(`Empty tournament response for ${tournamentId}`);
59695
+ }
59696
+ return parseTournamentStateDTO(response.data.tournament);
59697
+ }
59698
+ catch (error) {
59699
+ if (isGrpcNotFound(error)) {
59700
+ return null;
59701
+ }
59702
+ console.error("Error fetching tournament:", error);
59703
+ throw error;
59704
+ }
59705
+ }
58935
59706
  /**
58936
59707
  * Calculate equity for multiple hands using Monte Carlo simulation
58937
59708
  * Used when players are all-in and showing to display win percentages
@@ -71850,6 +72621,18 @@ function gaslessFee(gasLimit = DEFAULT_GAS_LIMIT) {
71850
72621
  gas: gasLimit.toString()
71851
72622
  };
71852
72623
  }
72624
+ /** The first attribute `key` of the first event of `type`, or undefined. */
72625
+ function eventAttribute(events, type, key) {
72626
+ for (const event of events) {
72627
+ if (event.type !== type)
72628
+ continue;
72629
+ for (const attribute of event.attributes) {
72630
+ if (attribute.key === key)
72631
+ return attribute.value;
72632
+ }
72633
+ }
72634
+ return undefined;
72635
+ }
71853
72636
  /**
71854
72637
  * Fail fast on a sit-and-go or tournament the chain would refuse. Both have seats
71855
72638
  * 2..9 and min <= max. A sit-and-go starts when the table fills, so its field is
@@ -72116,6 +72899,61 @@ class SigningCosmosClient extends CosmosClient {
72116
72899
  throw error;
72117
72900
  }
72118
72901
  }
72902
+ /**
72903
+ * Create a multi-table tournament (MsgCreateTournament, poker-vm#2613).
72904
+ * The creator pays the creation fee and is paid each entrant's entry fee.
72905
+ *
72906
+ * @returns the transaction hash and the chain-assigned tournament id (from
72907
+ * the `tournament_created` event).
72908
+ */
72909
+ async createTournament(params) {
72910
+ await this.initializeSigningClient();
72911
+ if (!this.signingClient || !this.wallet) {
72912
+ throw new Error("Signing client not initialized");
72913
+ }
72914
+ const [account] = await this.wallet.getAccounts();
72915
+ const creator = account.address;
72916
+ const msg = {
72917
+ typeUrl: "/pokerchain.poker.v1.MsgCreateTournament",
72918
+ value: buildMsgCreateTournament(creator, params)
72919
+ };
72920
+ const result = await this.signingClient.signAndBroadcast(creator, [msg], gaslessFee(2000000), "Create tournament via SDK");
72921
+ assertExecuted("create tournament", result);
72922
+ const tournamentId = eventAttribute(result.events, "tournament_created", "tournament_id");
72923
+ if (tournamentId === undefined || tournamentId === "") {
72924
+ throw new Error(`Created tournament in transaction ${result.transactionHash}, but its tournament_created event has no tournament_id`);
72925
+ }
72926
+ return { transactionHash: result.transactionHash, tournamentId };
72927
+ }
72928
+ /**
72929
+ * Register the signer for a tournament (MsgRegisterTournament): escrows the
72930
+ * buy-in. The entry fee and the protocol cut are taken at registration.
72931
+ */
72932
+ async registerTournament(tournamentId) {
72933
+ return this.tournamentMsg("register tournament", "/pokerchain.poker.v1.MsgRegisterTournament", tournamentId);
72934
+ }
72935
+ /**
72936
+ * Withdraw the signer's registration (MsgUnregisterTournament): returns the
72937
+ * escrowed net buy-in (the entry fee and protocol cut are not refunded).
72938
+ */
72939
+ async unregisterTournament(tournamentId) {
72940
+ return this.tournamentMsg("unregister tournament", "/pokerchain.poker.v1.MsgUnregisterTournament", tournamentId);
72941
+ }
72942
+ async tournamentMsg(operation, typeUrl, tournamentId) {
72943
+ if (tournamentId === "") {
72944
+ throw new Error("tournamentId is required");
72945
+ }
72946
+ await this.initializeSigningClient();
72947
+ if (!this.signingClient || !this.wallet) {
72948
+ throw new Error("Signing client not initialized");
72949
+ }
72950
+ const [account] = await this.wallet.getAccounts();
72951
+ const player = account.address;
72952
+ const msg = { typeUrl, value: { player, tournamentId } };
72953
+ const result = await this.signingClient.signAndBroadcast(player, [msg], gaslessFee(), `${operation} via SDK`);
72954
+ assertExecuted(operation, result);
72955
+ return result.transactionHash;
72956
+ }
72119
72957
  /**
72120
72958
  * Join a poker game
72121
72959
  */
@@ -72984,6 +73822,7 @@ exports.Deck = Deck;
72984
73822
  exports.GAME_NAME_MICRO_PER_CHAR = GAME_NAME_MICRO_PER_CHAR;
72985
73823
  exports.KEYS = KEYS;
72986
73824
  exports.MAX_GAME_NAME_LENGTH = MAX_GAME_NAME_LENGTH;
73825
+ exports.MAX_TOURNAMENT_ENTRANTS = MAX_TOURNAMENT_ENTRANTS;
72987
73826
  exports.MSG_CREATE_VALIDATOR_TYPE_URL = MSG_CREATE_VALIDATOR_TYPE_URL;
72988
73827
  exports.MissingWalletError = MissingWalletError;
72989
73828
  exports.Params = Params$c;
@@ -72997,10 +73836,11 @@ exports.SigningCosmosClient = SigningCosmosClient;
72997
73836
  exports.TOURNAMENT_ENTRANT_STATUSES = TOURNAMENT_ENTRANT_STATUSES;
72998
73837
  exports.TOURNAMENT_STATUSES = TOURNAMENT_STATUSES;
72999
73838
  exports.TxExecutionError = TxExecutionError;
73000
- exports.ValidatorBond = ValidatorBond;
73001
73839
  exports.WithdrawalRequest = WithdrawalRequest;
73002
73840
  exports.assertCreatableBettingLimit = assertCreatableBettingLimit;
73841
+ exports.assertCreatableTournament = assertCreatableTournament;
73003
73842
  exports.assertExecuted = assertExecuted;
73843
+ exports.buildMsgCreateTournament = buildMsgCreateTournament;
73004
73844
  exports.buildMsgCreateValidator = buildMsgCreateValidator;
73005
73845
  exports.computeGameNameFee = computeGameNameFee;
73006
73846
  exports.createSigningClientFromMnemonic = createSigningClientFromMnemonic;
@@ -73034,6 +73874,7 @@ exports.parseBlindStructure = parseBlindStructure;
73034
73874
  exports.parseGameFormat = parseGameFormat;
73035
73875
  exports.parseGameVariant = parseGameVariant;
73036
73876
  exports.parseLeaderboardDTO = parseLeaderboardDTO;
73877
+ exports.parseTournamentStateDTO = parseTournamentStateDTO;
73037
73878
  exports.registry = registry;
73038
73879
  exports.resolveBlindPreset = resolveBlindPreset;
73039
73880
  exports.roundBlind = roundBlind;