@block52/poker-vm-sdk 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2847,6 +2847,7 @@ function createBaseMsgCreateGame() {
2847
2847
  gameVariant: "",
2848
2848
  entryFee: Long.UZERO,
2849
2849
  name: "",
2850
+ bettingLimit: "",
2850
2851
  };
2851
2852
  }
2852
2853
  const MsgCreateGame = {
@@ -2905,6 +2906,9 @@ const MsgCreateGame = {
2905
2906
  if (message.name !== "") {
2906
2907
  writer.uint32(154).string(message.name);
2907
2908
  }
2909
+ if (message.bettingLimit !== "") {
2910
+ writer.uint32(162).string(message.bettingLimit);
2911
+ }
2908
2912
  return writer;
2909
2913
  },
2910
2914
  decode(input, length) {
@@ -3040,6 +3044,13 @@ const MsgCreateGame = {
3040
3044
  message.name = reader.string();
3041
3045
  continue;
3042
3046
  }
3047
+ case 20: {
3048
+ if (tag !== 162) {
3049
+ break;
3050
+ }
3051
+ message.bettingLimit = reader.string();
3052
+ continue;
3053
+ }
3043
3054
  }
3044
3055
  if ((tag & 7) === 4 || tag === 0) {
3045
3056
  break;
@@ -3068,6 +3079,7 @@ const MsgCreateGame = {
3068
3079
  gameVariant: isSet$2b(object.gameVariant) ? globalThis.String(object.gameVariant) : "",
3069
3080
  entryFee: isSet$2b(object.entryFee) ? Long.fromValue(object.entryFee) : Long.UZERO,
3070
3081
  name: isSet$2b(object.name) ? globalThis.String(object.name) : "",
3082
+ bettingLimit: isSet$2b(object.bettingLimit) ? globalThis.String(object.bettingLimit) : "",
3071
3083
  };
3072
3084
  },
3073
3085
  toJSON(message) {
@@ -3126,6 +3138,9 @@ const MsgCreateGame = {
3126
3138
  if (message.name !== "") {
3127
3139
  obj.name = message.name;
3128
3140
  }
3141
+ if (message.bettingLimit !== "") {
3142
+ obj.bettingLimit = message.bettingLimit;
3143
+ }
3129
3144
  return obj;
3130
3145
  },
3131
3146
  create(base) {
@@ -3170,6 +3185,7 @@ const MsgCreateGame = {
3170
3185
  message.blindLevelDuration = object.blindLevelDuration ?? 0;
3171
3186
  message.gameVariant = object.gameVariant ?? "";
3172
3187
  message.name = object.name ?? "";
3188
+ message.bettingLimit = object.bettingLimit ?? "";
3173
3189
  message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
3174
3190
  ? Long.fromValue(object.entryFee)
3175
3191
  : Long.UZERO;
@@ -56097,6 +56113,17 @@ exports.GameVariant = void 0;
56097
56113
  GameVariant["TEXAS_HOLDEM"] = "texas-holdem";
56098
56114
  GameVariant["OMAHA"] = "omaha";
56099
56115
  })(exports.GameVariant || (exports.GameVariant = {}));
56116
+ /**
56117
+ * BettingLimit — the table's betting structure. Orthogonal to GameVariant: any
56118
+ * variant can be played at any limit (pot-limit Omaha, pot-limit Hold'em,
56119
+ * fixed-limit Hold'em, …). Absent on GameOptions ⇒ no-limit (current behavior).
56120
+ */
56121
+ exports.BettingLimit = void 0;
56122
+ (function (BettingLimit) {
56123
+ BettingLimit["NO_LIMIT"] = "no-limit";
56124
+ BettingLimit["POT_LIMIT"] = "pot-limit";
56125
+ BettingLimit["FIXED_LIMIT"] = "fixed-limit";
56126
+ })(exports.BettingLimit || (exports.BettingLimit = {}));
56100
56127
  exports.GameStatus = void 0;
56101
56128
  (function (GameStatus) {
56102
56129
  GameStatus["WAITING_FOR_PLAYERS"] = "waiting-for-players";
@@ -56468,6 +56495,30 @@ const parseGameVariant = (value) => {
56468
56495
  return "unknown";
56469
56496
  }
56470
56497
  };
56498
+ /**
56499
+ * The betting structure a table plays. The engine treats an absent
56500
+ * `gameOptions.bettingLimit` as no-limit (poker-vm#2652), so this mirrors that
56501
+ * rule rather than inventing a default (block52/pokerchain#407).
56502
+ *
56503
+ * @param options - the table's gameOptions (or anything carrying bettingLimit)
56504
+ * @returns the table's BettingLimit
56505
+ */
56506
+ const getBettingLimit = (options) => {
56507
+ return options?.bettingLimit ?? exports.BettingLimit.NO_LIMIT;
56508
+ };
56509
+ /**
56510
+ * Check whether a table is pot-limit (its max bet or raise is the pot cap).
56511
+ */
56512
+ const isPotLimit = (options) => {
56513
+ return getBettingLimit(options) === exports.BettingLimit.POT_LIMIT;
56514
+ };
56515
+ /**
56516
+ * How many hole cards a variant deals each player: 4 for Omaha, 2 for Texas
56517
+ * Hold'em. Mirrors the engine's HoleCardsPerPlayer (poker-vm#2650).
56518
+ */
56519
+ const holeCardsPerPlayer = (variant) => {
56520
+ return variant === exports.GameVariant.OMAHA ? 4 : 2;
56521
+ };
56471
56522
 
56472
56523
  /**
56473
56524
  * Check if a specific action is available in the legal actions list.
@@ -71025,9 +71076,14 @@ class SigningCosmosClient extends CosmosClient {
71025
71076
  return this.sendTokens(fromAddress, toAddress, amount, undefined, memo);
71026
71077
  }
71027
71078
  /**
71028
- * Create a new poker game
71079
+ * Create a new poker game.
71080
+ *
71081
+ * `bettingLimit` is the table's betting structure (block52/pokerchain#407).
71082
+ * Omit it for the variant's default: pot-limit for omaha (PLO), no-limit for
71083
+ * texas-holdem. Omitted, the field is not encoded at all, so a chain without
71084
+ * it accepts the tx unchanged. Fixed-limit is not playable yet (poker-vm#2654).
71029
71085
  */
71030
- async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig, name) {
71086
+ async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig, name, bettingLimit) {
71031
71087
  // Validate SNG/Tournament config BEFORE any network work — fail fast.
71032
71088
  // SNG/Tournament games are DEFINED by startingStack + blindLevelDuration.
71033
71089
  // Refuse to create one with missing/zero values rather than silently
@@ -71047,6 +71103,7 @@ class SigningCosmosClient extends CosmosClient {
71047
71103
  throw new Error(`${gameFormat} games require a positive blindLevelDuration; got ${sngConfig.blindLevelDuration}.`);
71048
71104
  }
71049
71105
  }
71106
+ assertCreatableBettingLimit(bettingLimit);
71050
71107
  await this.initializeSigningClient();
71051
71108
  if (!this.signingClient || !this.wallet) {
71052
71109
  throw new Error("Signing client not initialized");
@@ -71079,6 +71136,9 @@ class SigningCosmosClient extends CosmosClient {
71079
71136
  // Optional ENS-style table name (block52/pokerchain#337). Empty = unnamed
71080
71137
  // (no fee); a non-empty name costs $0.10/char and must be globally unique.
71081
71138
  name: name ?? "",
71139
+ // Betting structure (block52/pokerchain#407). "" = the variant's default
71140
+ // on chain, and an empty proto3 string is not encoded at all.
71141
+ bettingLimit: bettingLimit ?? "",
71082
71142
  });
71083
71143
  // Create the transaction message
71084
71144
  const msg = {
@@ -71098,6 +71158,7 @@ class SigningCosmosClient extends CosmosClient {
71098
71158
  smallBlind: smallBlindB52USDC.toString(),
71099
71159
  bigBlind: bigBlindB52USDC.toString(),
71100
71160
  timeout,
71161
+ ...(bettingLimit && { bettingLimit }),
71101
71162
  ...(rakeConfig && {
71102
71163
  rakeFreeThreshold: rakeConfig.rakeFreeThreshold.toString(),
71103
71164
  rakePercentage: rakeConfig.rakePercentage,
@@ -71974,6 +72035,21 @@ async function createSigningClientFromMnemonic(config, mnemonic) {
71974
72035
  });
71975
72036
  return createSigningCosmosClient(config, wallet);
71976
72037
  }
72038
+ /**
72039
+ * Throws for a betting limit a table cannot be created with (block52/pokerchain#407).
72040
+ * Undefined is allowed: the chain applies the variant's default.
72041
+ */
72042
+ function assertCreatableBettingLimit(bettingLimit) {
72043
+ if (bettingLimit === undefined) {
72044
+ return;
72045
+ }
72046
+ if (bettingLimit === exports.BettingLimit.FIXED_LIMIT) {
72047
+ throw new Error("Fixed-limit tables are not available yet (poker-vm#2654).");
72048
+ }
72049
+ if (bettingLimit !== exports.BettingLimit.NO_LIMIT && bettingLimit !== exports.BettingLimit.POT_LIMIT) {
72050
+ throw new Error(`Invalid betting limit: ${bettingLimit}.`);
72051
+ }
72052
+ }
71977
72053
 
71978
72054
  // Generated by Ignite ignite.com/cli
71979
72055
  const Client = IgniteClient.plugin([
@@ -72036,6 +72112,7 @@ exports.SigningCosmosClient = SigningCosmosClient;
72036
72112
  exports.TxExecutionError = TxExecutionError;
72037
72113
  exports.ValidatorBond = ValidatorBond;
72038
72114
  exports.WithdrawalRequest = WithdrawalRequest;
72115
+ exports.assertCreatableBettingLimit = assertCreatableBettingLimit;
72039
72116
  exports.assertExecuted = assertExecuted;
72040
72117
  exports.buildMsgCreateValidator = buildMsgCreateValidator;
72041
72118
  exports.computeGameNameFee = computeGameNameFee;
@@ -72047,14 +72124,17 @@ exports.formatGameVariantDisplay = formatGameVariantDisplay;
72047
72124
  exports.generateWallet = generateWallet;
72048
72125
  exports.getActionByType = getActionByType;
72049
72126
  exports.getAddressFromMnemonic = getAddressFromMnemonic;
72127
+ exports.getBettingLimit = getBettingLimit;
72050
72128
  exports.getDefaultCosmosConfig = getDefaultCosmosConfig;
72051
72129
  exports.getGameFormat = getGameFormat;
72052
72130
  exports.getGameFormatForCosmos = getGameFormatForCosmos;
72053
72131
  exports.getGameFormatFromObject = getGameFormatFromObject;
72054
72132
  exports.getGameVariant = getGameVariant;
72055
72133
  exports.hasAction = hasAction;
72134
+ exports.holeCardsPerPlayer = holeCardsPerPlayer;
72056
72135
  exports.isCashFormat = isCashFormat;
72057
72136
  exports.isEmptyAddress = isEmptyAddress;
72137
+ exports.isPotLimit = isPotLimit;
72058
72138
  exports.isSitAndGoFormat = isSitAndGoFormat;
72059
72139
  exports.isTournamentFormat = isTournamentFormat;
72060
72140
  exports.isValidMnemonic = isValidMnemonic;