@block52/poker-vm-sdk 1.14.0 → 1.16.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.d.ts CHANGED
@@ -45432,12 +45432,20 @@ type AlgorithmicBlindStructureBase = {
45432
45432
  maxLevel?: number;
45433
45433
  ante?: AnteRuleDTO;
45434
45434
  };
45435
+ /**
45436
+ * Rounds every level after the first up to two significant figures once its big
45437
+ * blind reaches 1,000 (640/1,280 → 650/1,300), with sb = bb / 2. Each level
45438
+ * rounds its own exact value. Omitted = exact blinds. (poker-vm#2738)
45439
+ */
45440
+ type RoundBlindsOption = {
45441
+ roundBlinds?: boolean;
45442
+ };
45435
45443
  /** sb_n = startSmallBlind × 2^n — bit-identical to the doubling a structure-less sit-and-go runs. */
45436
- type DoubleBlindStructureDTO = AlgorithmicBlindStructureBase & {
45444
+ type DoubleBlindStructureDTO = AlgorithmicBlindStructureBase & RoundBlindsOption & {
45437
45445
  progression: "double";
45438
45446
  };
45439
45447
  /** sb_n = startSmallBlind + step × n. */
45440
- type LinearBlindStructureDTO = AlgorithmicBlindStructureBase & {
45448
+ type LinearBlindStructureDTO = AlgorithmicBlindStructureBase & RoundBlindsOption & {
45441
45449
  progression: "linear";
45442
45450
  step: string;
45443
45451
  };
@@ -46185,6 +46193,12 @@ declare function formatBlindStructure(structure: BlindStructureDTO, name?: strin
46185
46193
  declare const BLIND_PRESET_STRUCTURES: Readonly<Record<BlindPreset, Exclude<BlindStructureDTO, BlindStructurePresetDTO>>>;
46186
46194
  /** Replaces a preset with its concrete structure (a deep copy); anything else is returned as is. */
46187
46195
  declare function resolveBlindPreset(structure: BlindStructureDTO): Exclude<BlindStructureDTO, BlindStructurePresetDTO>;
46196
+ /**
46197
+ * The engine's roundBlind (poker-vm#2738): a big blind of 1,000 or more rounded
46198
+ * up to two significant figures (1,280 → 1,300; 10,240 → 11,000). The unit is
46199
+ * then at least 100, so the result stays even. Below 1,000 it is returned as is.
46200
+ */
46201
+ declare function roundBlind(bigBlind: bigint): bigint;
46188
46202
  /**
46189
46203
  * Level n (0-based) of a structure, exactly as the engine expands it: the cap
46190
46204
  * (`maxLevel`) freezes the blinds while the level number keeps counting; a
@@ -46895,7 +46909,8 @@ declare class SigningCosmosClient extends CosmosClient {
46895
46909
  * `bettingLimit` is the table's betting structure (block52/pokerchain#407).
46896
46910
  * Omit it for the variant's default: pot-limit for omaha (PLO), no-limit for
46897
46911
  * texas-holdem. Omitted, the field is not encoded at all, so a chain without
46898
- * it accepts the tx unchanged. Fixed-limit is not playable yet (poker-vm#2654).
46912
+ * it accepts the tx unchanged. Fixed-limit is texas-holdem only (poker-vm#2654,
46913
+ * block52/pokerchain#439).
46899
46914
  */
46900
46915
  createGame(gameFormat: string, gameVariant: string, minPlayers: number, maxPlayers: number, minBuyInB52USDC: bigint, maxBuyInB52USDC: bigint, smallBlindB52USDC: bigint, bigBlindB52USDC: bigint, timeout: number, rakeConfig?: RakeConfig, sngConfig?: SNGConfig, name?: string, bettingLimit?: BettingLimit): Promise<string>;
46901
46916
  /**
@@ -47142,9 +47157,10 @@ declare class SigningCosmosClient extends CosmosClient {
47142
47157
  declare function createSigningClientFromMnemonic(config: CosmosConfig, mnemonic: string): Promise<SigningCosmosClient>;
47143
47158
  /**
47144
47159
  * Throws for a betting limit a table cannot be created with (block52/pokerchain#407).
47145
- * Undefined is allowed: the chain applies the variant's default.
47160
+ * Undefined is allowed: the chain applies the variant's default. Fixed-limit is
47161
+ * texas-holdem only, as the chain decides (block52/pokerchain#439, poker-vm#2654).
47146
47162
  */
47147
- declare function assertCreatableBettingLimit(bettingLimit?: BettingLimit): void;
47163
+ declare function assertCreatableBettingLimit(bettingLimit: BettingLimit | undefined, gameVariant: string): void;
47148
47164
 
47149
47165
  /**
47150
47166
  * The part of a broadcast result this module reads. Structurally a subset of
@@ -47460,5 +47476,5 @@ declare const Client: typeof IgniteClient & Constructor<{
47460
47476
  }>;
47461
47477
  declare const registry: Registry;
47462
47478
 
47463
- 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, 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, 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, registry, resolveBlindPreset, toValoperAddress, txFailureHash, txFailurePhase };
47479
+ 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, 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, 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, registry, resolveBlindPreset, roundBlind, toValoperAddress, txFailureHash, txFailurePhase };
47464
47480
  export type { AccountDTO, ActionDTO, AnteRuleDTO, BlindLevelDTO, BlindPreset, BlindProgression, BlindStructureDTO, BlindStructurePresetDTO, Block, BlockDTO, BlockHeader, BlockHeaderDTO, BlockID, BlockResponse, BurnResponseDTO, Card, CreateValidatorParams, DoubleBlindStructureDTO, EquityHand, EquityRequest, EquityResponse, EquityResult, ExecutionResult, GameListItem, GameOptions, GameOptionsDTO, GameOptionsResponse, GameStateResponse, GameStateResponseDTO, HandEvaluation, ISignedResponse, LegalActionDTO, LinearBlindStructureDTO, PayoutPlaceDTO, PercentageBlindStructureDTO, PerformActionResponse, PlayerDTO, RPCRequest, RPCRequestParams, RPCResponse, RakeConfig, RakeConfigDTO, ResultDTO, SealedAwaiting, SealedDTO, SitInMethod, SitOutMethod, TableBlindStructureDTO, TexasHoldemGameState, TexasHoldemStateDTO, TransactionDTO, TransactionResponse, TxFailurePhase, WalletInfo, WinnerDTO, WithdrawResponseDTO };
package/dist/index.esm.js CHANGED
@@ -56650,7 +56650,8 @@ const isValidPlayerAddress = (address) => {
56650
56650
  * start: 25/50
56651
56651
  * duration: 5m
56652
56652
  * progression: double | linear 25 | percentage 1.5
56653
- * round: 25 percentage only (the engine's roundTo)
56653
+ * round: 25 percentage: the engine's roundTo
56654
+ * round: blinds double / linear: round levels of 1,000+ (roundBlinds)
56654
56655
  * ante: bb | bb * 0.1 | level >= 4 ? bb * 0.1 : 0
56655
56656
  * cap: 15
56656
56657
  * }
@@ -56866,6 +56867,15 @@ function parseTable(body) {
56866
56867
  out.maxLevel = parseInteger("cap", body.fields.get("cap").join(" "));
56867
56868
  return out;
56868
56869
  }
56870
+ /** `round: blinds` on double / linear turns on roundBlinds (poker-vm#2738); no other value is accepted there. */
56871
+ function parseRoundBlinds(f) {
56872
+ if (!f.has("round"))
56873
+ return {};
56874
+ const value = f.get("round").join(" ");
56875
+ if (value !== "blinds")
56876
+ fail(`double and linear take "round: blinds" (round levels of 1,000+), got "round: ${value}"`);
56877
+ return { roundBlinds: true };
56878
+ }
56869
56879
  function parseAlgorithmic(body) {
56870
56880
  const f = body.fields;
56871
56881
  for (const key of f.keys()) {
@@ -56894,16 +56904,16 @@ function parseAlgorithmic(body) {
56894
56904
  const [kind, ...rest] = f.get("progression");
56895
56905
  switch (kind) {
56896
56906
  case "double":
56897
- if (rest.length !== 0 || f.has("round"))
56898
- fail("double takes no argument and no round");
56899
- return { progression: "double", ...base };
56907
+ if (rest.length !== 0)
56908
+ fail("double takes no argument");
56909
+ return { progression: "double", ...base, ...parseRoundBlinds(f) };
56900
56910
  case "linear": {
56901
- if (rest.length !== 1 || f.has("round"))
56902
- fail('linear needs one step, e.g. "linear 25", and no round');
56911
+ if (rest.length !== 1)
56912
+ fail('linear needs one step, e.g. "linear 25"');
56903
56913
  const step = parseAmount("linear step", rest[0]);
56904
56914
  if (BigInt(step) <= 0n)
56905
56915
  fail("linear step must be positive");
56906
- return { progression: "linear", ...base, step };
56916
+ return { progression: "linear", ...base, step, ...parseRoundBlinds(f) };
56907
56917
  }
56908
56918
  case "percentage": {
56909
56919
  if (rest.length !== 1)
@@ -56976,9 +56986,13 @@ function formatBlindStructure(structure, name = "custom") {
56976
56986
  switch (structure.progression) {
56977
56987
  case "double":
56978
56988
  lines.push(" progression: double");
56989
+ if (structure.roundBlinds)
56990
+ lines.push(" round: blinds");
56979
56991
  break;
56980
56992
  case "linear":
56981
56993
  lines.push(` progression: linear ${structure.step}`);
56994
+ if (structure.roundBlinds)
56995
+ lines.push(" round: blinds");
56982
56996
  break;
56983
56997
  case "percentage":
56984
56998
  lines.push(` progression: percentage ${formatBps(structure.factorBps)}`);
@@ -57005,8 +57019,8 @@ function formatBlindStructure(structure, name = "custom") {
57005
57019
  * levels can be previewed before the table exists.
57006
57020
  */
57007
57021
  const BLIND_PRESET_STRUCTURES = {
57008
- turbo: { progression: "double", startSmallBlind: "25", startBigBlind: "50", durationMinutes: 5, ante: { startLevel: 4, bps: 1000 } },
57009
- standard: { progression: "double", startSmallBlind: "25", startBigBlind: "50", durationMinutes: 10, ante: { startLevel: 5, bps: 1000 } },
57022
+ turbo: { progression: "double", startSmallBlind: "25", startBigBlind: "50", durationMinutes: 5, roundBlinds: true, ante: { startLevel: 4, bps: 1000 } },
57023
+ standard: { progression: "double", startSmallBlind: "25", startBigBlind: "50", durationMinutes: 10, roundBlinds: true, ante: { startLevel: 5, bps: 1000 } },
57010
57024
  deep_stack: {
57011
57025
  progression: "percentage",
57012
57026
  startSmallBlind: "25",
@@ -57016,7 +57030,7 @@ const BLIND_PRESET_STRUCTURES = {
57016
57030
  durationMinutes: 15,
57017
57031
  ante: { startLevel: 6, bps: 1250 }
57018
57032
  },
57019
- hyper_turbo: { progression: "double", startSmallBlind: "50", startBigBlind: "100", durationMinutes: 3, ante: { startLevel: 3, bps: 1000 } }
57033
+ hyper_turbo: { progression: "double", startSmallBlind: "50", startBigBlind: "100", durationMinutes: 3, roundBlinds: true, ante: { startLevel: 3, bps: 1000 } }
57020
57034
  };
57021
57035
  /** Replaces a preset with its concrete structure (a deep copy); anything else is returned as is. */
57022
57036
  function resolveBlindPreset(structure) {
@@ -57027,6 +57041,17 @@ function resolveBlindPreset(structure) {
57027
57041
  fail(`"${structure.preset}" is not a preset (${BLIND_PRESETS.join(", ")})`);
57028
57042
  return JSON.parse(JSON.stringify(preset));
57029
57043
  }
57044
+ /**
57045
+ * The engine's roundBlind (poker-vm#2738): a big blind of 1,000 or more rounded
57046
+ * up to two significant figures (1,280 → 1,300; 10,240 → 11,000). The unit is
57047
+ * then at least 100, so the result stays even. Below 1,000 it is returned as is.
57048
+ */
57049
+ function roundBlind(bigBlind) {
57050
+ if (bigBlind < 1000n)
57051
+ return bigBlind;
57052
+ const unit = 10n ** BigInt(bigBlind.toString().length - 2);
57053
+ return ((bigBlind + unit - 1n) / unit) * unit;
57054
+ }
57030
57055
  function algorithmicSmallBlind(structure, n) {
57031
57056
  const sb0 = BigInt(structure.startSmallBlind);
57032
57057
  switch (structure.progression) {
@@ -57075,8 +57100,13 @@ function expandBlindLevel(structure, n) {
57075
57100
  row.durationMinutes = n >= rows.length ? rows[rows.length - 1].durationMinutes : rows[n].durationMinutes;
57076
57101
  return row;
57077
57102
  }
57078
- const sb = algorithmicSmallBlind(structure, m);
57079
- const bb = sb * 2n;
57103
+ let sb = algorithmicSmallBlind(structure, m);
57104
+ let bb = sb * 2n;
57105
+ // Level 0 is the creator's opening blinds and is never rounded.
57106
+ if (structure.progression !== "percentage" && structure.roundBlinds && m > 0) {
57107
+ bb = roundBlind(bb);
57108
+ sb = bb / 2n;
57109
+ }
57080
57110
  let ante = 0n;
57081
57111
  if (structure.ante && n >= structure.ante.startLevel)
57082
57112
  ante = (bb * BigInt(structure.ante.bps)) / BPS;
@@ -71796,7 +71826,8 @@ class SigningCosmosClient extends CosmosClient {
71796
71826
  * `bettingLimit` is the table's betting structure (block52/pokerchain#407).
71797
71827
  * Omit it for the variant's default: pot-limit for omaha (PLO), no-limit for
71798
71828
  * texas-holdem. Omitted, the field is not encoded at all, so a chain without
71799
- * it accepts the tx unchanged. Fixed-limit is not playable yet (poker-vm#2654).
71829
+ * it accepts the tx unchanged. Fixed-limit is texas-holdem only (poker-vm#2654,
71830
+ * block52/pokerchain#439).
71800
71831
  */
71801
71832
  async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig, name, bettingLimit) {
71802
71833
  // Validate SNG/Tournament config BEFORE any network work — fail fast.
@@ -71819,7 +71850,7 @@ class SigningCosmosClient extends CosmosClient {
71819
71850
  }
71820
71851
  assertCreatableSngField(minPlayers, maxPlayers, sngConfig);
71821
71852
  }
71822
- assertCreatableBettingLimit(bettingLimit);
71853
+ assertCreatableBettingLimit(bettingLimit, gameVariant);
71823
71854
  await this.initializeSigningClient();
71824
71855
  if (!this.signingClient || !this.wallet) {
71825
71856
  throw new Error("Signing client not initialized");
@@ -72762,14 +72793,18 @@ async function createSigningClientFromMnemonic(config, mnemonic) {
72762
72793
  }
72763
72794
  /**
72764
72795
  * Throws for a betting limit a table cannot be created with (block52/pokerchain#407).
72765
- * Undefined is allowed: the chain applies the variant's default.
72796
+ * Undefined is allowed: the chain applies the variant's default. Fixed-limit is
72797
+ * texas-holdem only, as the chain decides (block52/pokerchain#439, poker-vm#2654).
72766
72798
  */
72767
- function assertCreatableBettingLimit(bettingLimit) {
72799
+ function assertCreatableBettingLimit(bettingLimit, gameVariant) {
72768
72800
  if (bettingLimit === undefined) {
72769
72801
  return;
72770
72802
  }
72771
72803
  if (bettingLimit === BettingLimit.FIXED_LIMIT) {
72772
- throw new Error("Fixed-limit tables are not available yet (poker-vm#2654).");
72804
+ if (gameVariant !== GameVariant.TEXAS_HOLDEM) {
72805
+ throw new Error(`Betting limit fixed-limit is only available for texas-holdem; got ${gameVariant}.`);
72806
+ }
72807
+ return;
72773
72808
  }
72774
72809
  if (bettingLimit !== BettingLimit.NO_LIMIT && bettingLimit !== BettingLimit.POT_LIMIT) {
72775
72810
  throw new Error(`Invalid betting limit: ${bettingLimit}.`);
@@ -72814,5 +72849,5 @@ const registry = new Registry([
72814
72849
  ...msgTypes,
72815
72850
  ]);
72816
72851
 
72817
- 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, 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, registry, resolveBlindPreset, toValoperAddress, txFailureHash, txFailurePhase };
72852
+ 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, 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, registry, resolveBlindPreset, roundBlind, toValoperAddress, txFailureHash, txFailurePhase };
72818
72853
  //# sourceMappingURL=index.esm.js.map