@block52/poker-vm-sdk 1.7.0 → 1.8.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
@@ -2848,6 +2848,7 @@ function createBaseMsgCreateGame() {
2848
2848
  entryFee: Long.UZERO,
2849
2849
  name: "",
2850
2850
  bettingLimit: "",
2851
+ startTime: Long.ZERO,
2851
2852
  };
2852
2853
  }
2853
2854
  const MsgCreateGame = {
@@ -2909,6 +2910,9 @@ const MsgCreateGame = {
2909
2910
  if (message.bettingLimit !== "") {
2910
2911
  writer.uint32(162).string(message.bettingLimit);
2911
2912
  }
2913
+ if (!message.startTime.equals(Long.ZERO)) {
2914
+ writer.uint32(168).int64(message.startTime.toString());
2915
+ }
2912
2916
  return writer;
2913
2917
  },
2914
2918
  decode(input, length) {
@@ -3051,6 +3055,13 @@ const MsgCreateGame = {
3051
3055
  message.bettingLimit = reader.string();
3052
3056
  continue;
3053
3057
  }
3058
+ case 21: {
3059
+ if (tag !== 168) {
3060
+ break;
3061
+ }
3062
+ message.startTime = Long.fromString(reader.int64().toString());
3063
+ continue;
3064
+ }
3054
3065
  }
3055
3066
  if ((tag & 7) === 4 || tag === 0) {
3056
3067
  break;
@@ -3080,6 +3091,7 @@ const MsgCreateGame = {
3080
3091
  entryFee: isSet$2b(object.entryFee) ? Long.fromValue(object.entryFee) : Long.UZERO,
3081
3092
  name: isSet$2b(object.name) ? globalThis.String(object.name) : "",
3082
3093
  bettingLimit: isSet$2b(object.bettingLimit) ? globalThis.String(object.bettingLimit) : "",
3094
+ startTime: isSet$2b(object.startTime) ? Long.fromValue(object.startTime) : Long.ZERO,
3083
3095
  };
3084
3096
  },
3085
3097
  toJSON(message) {
@@ -3141,6 +3153,9 @@ const MsgCreateGame = {
3141
3153
  if (message.bettingLimit !== "") {
3142
3154
  obj.bettingLimit = message.bettingLimit;
3143
3155
  }
3156
+ if (!message.startTime.equals(Long.ZERO)) {
3157
+ obj.startTime = (message.startTime || Long.ZERO).toString();
3158
+ }
3144
3159
  return obj;
3145
3160
  },
3146
3161
  create(base) {
@@ -3186,6 +3201,9 @@ const MsgCreateGame = {
3186
3201
  message.gameVariant = object.gameVariant ?? "";
3187
3202
  message.name = object.name ?? "";
3188
3203
  message.bettingLimit = object.bettingLimit ?? "";
3204
+ message.startTime = (object.startTime !== undefined && object.startTime !== null)
3205
+ ? Long.fromValue(object.startTime)
3206
+ : Long.ZERO;
3189
3207
  message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
3190
3208
  ? Long.fromValue(object.entryFee)
3191
3209
  : Long.UZERO;
@@ -56093,6 +56111,10 @@ exports.NonPlayerActionType = void 0;
56093
56111
  // current turn. Rejected off-turn, past the deadline, or with no bank left.
56094
56112
  NonPlayerActionType["TIME_BANK"] = "time-bank";
56095
56113
  NonPlayerActionType["TOP_UP"] = "top-up";
56114
+ // Scheduled single-table tournament (poker-vm#2680): any registered player
56115
+ // starts the sit-and-go once gameOptions.scheduledStartTime has passed and
56116
+ // at least minPlayers are seated. Offered in legalActions when it is due.
56117
+ NonPlayerActionType["START"] = "start";
56096
56118
  })(exports.NonPlayerActionType || (exports.NonPlayerActionType = {}));
56097
56119
  const AllPlayerActions = { ...exports.PlayerActionType, ...exports.NonPlayerActionType };
56098
56120
  /**
@@ -71006,6 +71028,26 @@ function gaslessFee(gasLimit = DEFAULT_GAS_LIMIT) {
71006
71028
  gas: gasLimit.toString()
71007
71029
  };
71008
71030
  }
71031
+ /**
71032
+ * Fail fast on a sit-and-go field the chain would refuse (poker-vm#2680):
71033
+ * seats 2..9, min <= max, and a flexible field (min < max) needs a scheduled
71034
+ * start in the future. Mirrors x/poker/keeper/msg_server_create_game.go.
71035
+ */
71036
+ function assertCreatableSngField(minPlayers, maxPlayers, sngConfig, nowSeconds = Math.floor(Date.now() / 1000)) {
71037
+ if (maxPlayers < 2 || maxPlayers > 9) {
71038
+ throw new Error(`sit-and-go maxPlayers must be 2..9; got ${maxPlayers}.`);
71039
+ }
71040
+ if (minPlayers < 2 || minPlayers > maxPlayers) {
71041
+ throw new Error(`sit-and-go minPlayers must be 2..maxPlayers (${maxPlayers}); got ${minPlayers}.`);
71042
+ }
71043
+ const startTime = sngConfig?.startTime;
71044
+ if (minPlayers !== maxPlayers && !startTime) {
71045
+ throw new Error("sit-and-go with minPlayers < maxPlayers needs sngConfig.startTime (a scheduled start).");
71046
+ }
71047
+ if (startTime !== undefined && startTime <= nowSeconds) {
71048
+ throw new Error(`sngConfig.startTime ${startTime} must be in the future (now ${nowSeconds}).`);
71049
+ }
71050
+ }
71009
71051
  /**
71010
71052
  * Signing Cosmos Client that extends the read-only CosmosClient with transaction capabilities
71011
71053
  */
@@ -71137,6 +71179,7 @@ class SigningCosmosClient extends CosmosClient {
71137
71179
  if (!sngConfig.blindLevelDuration || sngConfig.blindLevelDuration <= 0) {
71138
71180
  throw new Error(`${gameFormat} games require a positive blindLevelDuration; got ${sngConfig.blindLevelDuration}.`);
71139
71181
  }
71182
+ assertCreatableSngField(minPlayers, maxPlayers, sngConfig);
71140
71183
  }
71141
71184
  assertCreatableBettingLimit(bettingLimit);
71142
71185
  await this.initializeSigningClient();
@@ -71174,6 +71217,9 @@ class SigningCosmosClient extends CosmosClient {
71174
71217
  // Betting structure (block52/pokerchain#407). "" = the variant's default
71175
71218
  // on chain, and an empty proto3 string is not encoded at all.
71176
71219
  bettingLimit: bettingLimit ?? "",
71220
+ // Scheduled start (poker-vm#2680), unix seconds. 0 = unscheduled, and
71221
+ // a zero proto3 int64 is not encoded at all.
71222
+ startTime: sngConfig?.startTime ? Long.fromNumber(sngConfig.startTime) : Long.ZERO,
71177
71223
  });
71178
71224
  // Create the transaction message
71179
71225
  const msg = {