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