@block52/poker-vm-sdk 1.2.16 → 1.3.1

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.
@@ -0,0 +1,65 @@
1
+ import { IJSONModel } from "./deck";
2
+ import { Card, TexasHoldemRound } from "./types/game";
3
+ /**
4
+ * The community board for a Texas Hold'em hand.
5
+ *
6
+ * Encapsulates the two community-card arrays the engine currently keeps — the
7
+ * cards dealt street-by-street (`street`, persisted to the DTO) and the five
8
+ * pre-dealt up front at `deal()` (`preDealt`) — behind one type. This is a pure
9
+ * refactor: every accessor returns exactly what the inline engine logic did, so
10
+ * behaviour is unchanged. Collapsing the two arrays into a single canonical
11
+ * board is a separate, consensus-affecting change (issue #2299).
12
+ */
13
+ export declare class Board implements IJSONModel {
14
+ static readonly MAX_COMMUNITY_CARDS = 5;
15
+ private readonly street;
16
+ private readonly preDealt;
17
+ /**
18
+ * Append cards dealt for the current street (was `_communityCards.push`).
19
+ */
20
+ addStreet(cards: Card[]): void;
21
+ /**
22
+ * Record the five cards pre-dealt at deal() (was `_communityCards2.push`).
23
+ */
24
+ setPreDealt(cards: Card[]): void;
25
+ /**
26
+ * Number of street-dealt cards (was `_communityCards.length`).
27
+ */
28
+ get streetLength(): number;
29
+ /**
30
+ * Number of pre-dealt cards (was `_communityCards2.length`).
31
+ */
32
+ get preDealtLength(): number;
33
+ /**
34
+ * The street-dealt community cards (was `[...this._communityCards]`).
35
+ */
36
+ get cards(): Card[];
37
+ /**
38
+ * The community cards visible at a given round, taken from the pre-dealt
39
+ * board — matching the previous `getCommunityCards()` exactly:
40
+ * FLOP -> preDealt[0..3], TURN -> preDealt[0..4], RIVER -> preDealt[0..5].
41
+ */
42
+ forRound(round: TexasHoldemRound): Card[];
43
+ /**
44
+ * The board `findWinners` falls back to when `forRound` is short: the
45
+ * pre-dealt board for live games, else the street board rehydrated from JSON.
46
+ * Preserves the previous inline selection verbatim.
47
+ */
48
+ forEvaluation(count: number): Card[];
49
+ /**
50
+ * The board `calculateWinner` falls back to at an early showdown: the fully
51
+ * dealt street board if available, else the pre-dealt board. Preserves the
52
+ * previous inline selection verbatim.
53
+ */
54
+ forShowdown(): Card[];
55
+ /**
56
+ * Clear both boards for a new hand (was two `.length = 0` assignments).
57
+ */
58
+ clear(): void;
59
+ /**
60
+ * Serialize the street board to mnemonics, matching
61
+ * `TexasHoldemStateDTO.communityCards` (was `_communityCards.map(...)`).
62
+ */
63
+ toJson(): string[];
64
+ }
65
+ //# sourceMappingURL=board.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"board.d.ts","sourceRoot":"","sources":["../src/board.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEtD;;;;;;;;;GASG;AACH,qBAAa,KAAM,YAAW,UAAU;IACpC,gBAAuB,mBAAmB,KAAK;IAI/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IAErC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IAEvC;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;IAIrC;;OAEG;IACI,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;IAIvC;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED;;OAEG;IACH,IAAW,cAAc,IAAI,MAAM,CAElC;IAED;;OAEG;IACH,IAAW,KAAK,IAAI,IAAI,EAAE,CAEzB;IAED;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,EAAE;IAchD;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE;IAM3C;;;;OAIG;IACI,WAAW,IAAI,IAAI,EAAE;IAM5B;;OAEG;IACI,KAAK,IAAI,IAAI;IAKpB;;;OAGG;IACI,MAAM,IAAI,MAAM,EAAE;CAG5B"}
package/dist/index.d.ts CHANGED
@@ -46125,6 +46125,69 @@ declare class Deck implements IDeck, IJSONModel {
46125
46125
  private initStandard52;
46126
46126
  }
46127
46127
 
46128
+ /**
46129
+ * The community board for a Texas Hold'em hand.
46130
+ *
46131
+ * Encapsulates the two community-card arrays the engine currently keeps — the
46132
+ * cards dealt street-by-street (`street`, persisted to the DTO) and the five
46133
+ * pre-dealt up front at `deal()` (`preDealt`) — behind one type. This is a pure
46134
+ * refactor: every accessor returns exactly what the inline engine logic did, so
46135
+ * behaviour is unchanged. Collapsing the two arrays into a single canonical
46136
+ * board is a separate, consensus-affecting change (issue #2299).
46137
+ */
46138
+ declare class Board implements IJSONModel {
46139
+ static readonly MAX_COMMUNITY_CARDS = 5;
46140
+ private readonly street;
46141
+ private readonly preDealt;
46142
+ /**
46143
+ * Append cards dealt for the current street (was `_communityCards.push`).
46144
+ */
46145
+ addStreet(cards: Card[]): void;
46146
+ /**
46147
+ * Record the five cards pre-dealt at deal() (was `_communityCards2.push`).
46148
+ */
46149
+ setPreDealt(cards: Card[]): void;
46150
+ /**
46151
+ * Number of street-dealt cards (was `_communityCards.length`).
46152
+ */
46153
+ get streetLength(): number;
46154
+ /**
46155
+ * Number of pre-dealt cards (was `_communityCards2.length`).
46156
+ */
46157
+ get preDealtLength(): number;
46158
+ /**
46159
+ * The street-dealt community cards (was `[...this._communityCards]`).
46160
+ */
46161
+ get cards(): Card[];
46162
+ /**
46163
+ * The community cards visible at a given round, taken from the pre-dealt
46164
+ * board — matching the previous `getCommunityCards()` exactly:
46165
+ * FLOP -> preDealt[0..3], TURN -> preDealt[0..4], RIVER -> preDealt[0..5].
46166
+ */
46167
+ forRound(round: TexasHoldemRound): Card[];
46168
+ /**
46169
+ * The board `findWinners` falls back to when `forRound` is short: the
46170
+ * pre-dealt board for live games, else the street board rehydrated from JSON.
46171
+ * Preserves the previous inline selection verbatim.
46172
+ */
46173
+ forEvaluation(count: number): Card[];
46174
+ /**
46175
+ * The board `calculateWinner` falls back to at an early showdown: the fully
46176
+ * dealt street board if available, else the pre-dealt board. Preserves the
46177
+ * previous inline selection verbatim.
46178
+ */
46179
+ forShowdown(): Card[];
46180
+ /**
46181
+ * Clear both boards for a new hand (was two `.length = 0` assignments).
46182
+ */
46183
+ clear(): void;
46184
+ /**
46185
+ * Serialize the street board to mnemonics, matching
46186
+ * `TexasHoldemStateDTO.communityCards` (was `_communityCards.map(...)`).
46187
+ */
46188
+ toJson(): string[];
46189
+ }
46190
+
46128
46191
  /**
46129
46192
  * Example integration of custom poker solver with game engine
46130
46193
  * Demonstrates how to replace pokersolver with our custom implementation
@@ -46535,7 +46598,7 @@ declare class SigningCosmosClient extends CosmosClient {
46535
46598
  * Requires the player account to EXIST on-chain (funded). Same gasless
46536
46599
  * fee + msg shape as {@link performActionSync}.
46537
46600
  */
46538
- signPerformAction(gameId: string, action: string, amount?: bigint, data?: string, signerData?: SignerData): Promise<{
46601
+ signPerformAction(gameId: string, action: string, amount?: bigint, data?: string, _signerData?: SignerData): Promise<{
46539
46602
  base64: string;
46540
46603
  sequence: number;
46541
46604
  accountNumber: number;
@@ -46553,6 +46616,23 @@ declare class SigningCosmosClient extends CosmosClient {
46553
46616
  * helpers below share with signPerformAction's gateway-settlement pattern.
46554
46617
  */
46555
46618
  private signMsgOnly;
46619
+ /**
46620
+ * Sign a single cosmos message as an UNORDERED transaction (SDK 0.53): the
46621
+ * TxBody carries `unordered: true` + a `timeout_timestamp` and NO account
46622
+ * sequence (sequence MUST be 0). The chain admits it regardless of order and
46623
+ * dedups replay on (signer, timeout) — so settlement txs no longer carry a
46624
+ * client-guessed sequence and can never cascade (poker-vm#247, replaces the
46625
+ * sequence-tracking that caused #2413).
46626
+ *
46627
+ * Hand-built because CosmJS 0.32's TxBody proto predates the unordered
46628
+ * fields; we use the SDK's own cosmos.tx proto (which has them) for the body
46629
+ * and CosmJS only for AuthInfo + the direct signature.
46630
+ *
46631
+ * @param ttlSeconds - how far ahead the timeout_timestamp is set. Must be
46632
+ * within the chain's max unordered TTL (SDK default 10m). Also bounds how
46633
+ * long a replay of this exact tx is rejected.
46634
+ */
46635
+ private signUnordered;
46556
46636
  /**
46557
46637
  * Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
46558
46638
  * broadcasting, returning the base64 TxRaw for the gateway to relay
@@ -46911,5 +46991,5 @@ declare const Client: typeof IgniteClient & Constructor<{
46911
46991
  }>;
46912
46992
  declare const registry: Registry;
46913
46993
 
46914
- export { AllPlayerActions, BLOCK52_HD_PATH, COSMOS_CONSTANTS, Client, CosmosClient, Deck, GameFormat, GameStatus, GameVariant, HandType, KEYS, 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, WithdrawalRequest, createSigningClientFromMnemonic, createWalletFromMnemonic, formatGameFormatDisplay, formatGameVariantDisplay, generateWallet, getActionByType, getAddressFromMnemonic, getDefaultCosmosConfig, getGameFormat, getGameFormatForCosmos, getGameFormatFromObject, getGameVariant, hasAction, isCashFormat, isEmptyAddress, isSitAndGoFormat, isTournamentFormat, isValidMnemonic, isValidPlayerAddress, parseGameFormat, parseGameVariant, registry };
46994
+ export { AllPlayerActions, BLOCK52_HD_PATH, Board, COSMOS_CONSTANTS, Client, CosmosClient, Deck, GameFormat, GameStatus, GameVariant, HandType, KEYS, 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, WithdrawalRequest, createSigningClientFromMnemonic, createWalletFromMnemonic, formatGameFormatDisplay, formatGameVariantDisplay, generateWallet, getActionByType, getAddressFromMnemonic, getDefaultCosmosConfig, getGameFormat, getGameFormatForCosmos, getGameFormatFromObject, getGameVariant, hasAction, isCashFormat, isEmptyAddress, isSitAndGoFormat, isTournamentFormat, isValidMnemonic, isValidPlayerAddress, parseGameFormat, parseGameVariant, registry };
46915
46995
  export type { AccountDTO, ActionDTO, Block, BlockDTO, BlockHeader, BlockHeaderDTO, BlockID, BlockResponse, BurnResponseDTO, Card, EquityHand, EquityRequest, EquityResponse, EquityResult, GameListItem, GameOptions, GameOptionsDTO, GameOptionsResponse, GameStateResponse, GameStateResponseDTO, HandEvaluation, ISignedResponse, LegalActionDTO, PayoutPlaceDTO, PerformActionResponse, PlayerDTO, RPCRequest, RPCRequestParams, RPCResponse, RakeConfig, RakeConfigDTO, ResultDTO, SitInMethod, SitOutMethod, TexasHoldemGameState, TexasHoldemStateDTO, TransactionDTO, TransactionResponse, WalletInfo, WinnerDTO, WithdrawResponseDTO };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAkC/C,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEV,CAAC;AAEH,QAAA,MAAM,QAAQ,UAiCZ,CAAA;AAGF,cAAc,6BAA6B,CAAA;AAG3C,cAAc,cAAc,CAAA;AAG5B,cAAc,SAAS,CAAA;AAGvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAGpG,cAAc,eAAe,CAAA;AAG7B,cAAc,eAAe,CAAA;AAG7B,cAAc,yBAAyB,CAAA;AAGvC,cAAc,qBAAqB,CAAA;AAGnC,cAAc,sBAAsB,CAAA;AAGpC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGrE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAG7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAG7D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACvF,OAAO,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGvG,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAGzF,OAAO,EACL,MAAM,EACN,QAAQ,EACR,kBAAkB,EACnB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAkC/C,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEV,CAAC;AAEH,QAAA,MAAM,QAAQ,UAiCZ,CAAA;AAGF,cAAc,6BAA6B,CAAA;AAG3C,cAAc,cAAc,CAAA;AAG5B,cAAc,SAAS,CAAA;AAGvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAGpG,cAAc,eAAe,CAAA;AAG7B,cAAc,eAAe,CAAA;AAG7B,cAAc,yBAAyB,CAAA;AAGvC,cAAc,qBAAqB,CAAA;AAGnC,cAAc,sBAAsB,CAAA;AAGpC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGrE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAG7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAG/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAG7D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACvF,OAAO,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGvG,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAGzF,OAAO,EACL,MAAM,EACN,QAAQ,EACR,kBAAkB,EACnB,CAAA"}
package/dist/index.esm.js CHANGED
@@ -1,9 +1,10 @@
1
- import { Registry, DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
1
+ import { Registry, DirectSecp256k1HdWallet, encodePubkey, makeAuthInfoBytes, makeSignDoc } from '@cosmjs/proto-signing';
2
2
  import { SigningStargateClient, GasPrice } from '@cosmjs/stargate';
3
3
  import { EventEmitter } from 'events';
4
4
  import { stringToPath } from '@cosmjs/crypto';
5
5
  import { createHash } from 'crypto';
6
- import { toBase64 } from '@cosmjs/encoding';
6
+ import { toBase64, fromBase64 } from '@cosmjs/encoding';
7
+ import { encodeSecp256k1Pubkey } from '@cosmjs/amino';
7
8
 
8
9
  /// <reference path="./types.d.ts" />
9
10
  const defaultFee$q = {
@@ -57317,6 +57318,109 @@ Deck.SUIT_MAP = {
57317
57318
  [SUIT.SPADES]: "S"
57318
57319
  };
57319
57320
 
57321
+ /**
57322
+ * The community board for a Texas Hold'em hand.
57323
+ *
57324
+ * Encapsulates the two community-card arrays the engine currently keeps — the
57325
+ * cards dealt street-by-street (`street`, persisted to the DTO) and the five
57326
+ * pre-dealt up front at `deal()` (`preDealt`) — behind one type. This is a pure
57327
+ * refactor: every accessor returns exactly what the inline engine logic did, so
57328
+ * behaviour is unchanged. Collapsing the two arrays into a single canonical
57329
+ * board is a separate, consensus-affecting change (issue #2299).
57330
+ */
57331
+ class Board {
57332
+ constructor() {
57333
+ // Dealt one street at a time via dealCommunityCards() (was `_communityCards`).
57334
+ // This is the board persisted to the game DTO and rehydrated from JSON.
57335
+ this.street = [];
57336
+ // All five dealt up front at deal() (was `_communityCards2`).
57337
+ this.preDealt = [];
57338
+ }
57339
+ /**
57340
+ * Append cards dealt for the current street (was `_communityCards.push`).
57341
+ */
57342
+ addStreet(cards) {
57343
+ this.street.push(...cards);
57344
+ }
57345
+ /**
57346
+ * Record the five cards pre-dealt at deal() (was `_communityCards2.push`).
57347
+ */
57348
+ setPreDealt(cards) {
57349
+ this.preDealt.push(...cards);
57350
+ }
57351
+ /**
57352
+ * Number of street-dealt cards (was `_communityCards.length`).
57353
+ */
57354
+ get streetLength() {
57355
+ return this.street.length;
57356
+ }
57357
+ /**
57358
+ * Number of pre-dealt cards (was `_communityCards2.length`).
57359
+ */
57360
+ get preDealtLength() {
57361
+ return this.preDealt.length;
57362
+ }
57363
+ /**
57364
+ * The street-dealt community cards (was `[...this._communityCards]`).
57365
+ */
57366
+ get cards() {
57367
+ return [...this.street];
57368
+ }
57369
+ /**
57370
+ * The community cards visible at a given round, taken from the pre-dealt
57371
+ * board — matching the previous `getCommunityCards()` exactly:
57372
+ * FLOP -> preDealt[0..3], TURN -> preDealt[0..4], RIVER -> preDealt[0..5].
57373
+ */
57374
+ forRound(round) {
57375
+ const cards = [];
57376
+ if (round === TexasHoldemRound.FLOP) {
57377
+ cards.push(...this.preDealt.slice(0, 3));
57378
+ }
57379
+ if (round === TexasHoldemRound.TURN) {
57380
+ cards.push(...this.preDealt.slice(0, 4));
57381
+ }
57382
+ if (round === TexasHoldemRound.RIVER) {
57383
+ cards.push(...this.preDealt.slice(0, 5));
57384
+ }
57385
+ return cards;
57386
+ }
57387
+ /**
57388
+ * The board `findWinners` falls back to when `forRound` is short: the
57389
+ * pre-dealt board for live games, else the street board rehydrated from JSON.
57390
+ * Preserves the previous inline selection verbatim.
57391
+ */
57392
+ forEvaluation(count) {
57393
+ return this.preDealt.length >= count
57394
+ ? this.preDealt.slice(0, count)
57395
+ : this.street.slice(0, count);
57396
+ }
57397
+ /**
57398
+ * The board `calculateWinner` falls back to at an early showdown: the fully
57399
+ * dealt street board if available, else the pre-dealt board. Preserves the
57400
+ * previous inline selection verbatim.
57401
+ */
57402
+ forShowdown() {
57403
+ return this.street.length >= Board.MAX_COMMUNITY_CARDS
57404
+ ? this.street.slice(0, Board.MAX_COMMUNITY_CARDS)
57405
+ : this.preDealt.slice(0, Board.MAX_COMMUNITY_CARDS);
57406
+ }
57407
+ /**
57408
+ * Clear both boards for a new hand (was two `.length = 0` assignments).
57409
+ */
57410
+ clear() {
57411
+ this.street.length = 0;
57412
+ this.preDealt.length = 0;
57413
+ }
57414
+ /**
57415
+ * Serialize the street board to mnemonics, matching
57416
+ * `TexasHoldemStateDTO.communityCards` (was `_communityCards.map(...)`).
57417
+ */
57418
+ toJson() {
57419
+ return this.street.map(card => card.mnemonic);
57420
+ }
57421
+ }
57422
+ Board.MAX_COMMUNITY_CARDS = 5;
57423
+
57320
57424
  /**
57321
57425
  * Example integration of custom poker solver with game engine
57322
57426
  * Demonstrates how to replace pokersolver with our custom implementation
@@ -60835,6 +60939,10 @@ var txExports = requireTx();
60835
60939
  * Default gas limit for all transactions
60836
60940
  */
60837
60941
  const DEFAULT_GAS_LIMIT = 1000000;
60942
+ // Registry with the poker message types, used to pack a Msg into an Any when
60943
+ // hand-building an unordered TxBody (signUnordered). Module-level so it's built
60944
+ // once and shared with the stargate client's registry semantics.
60945
+ const pokerRegistry = new Registry(msgTypes$u);
60838
60946
  /**
60839
60947
  * Create a gasless fee object with specified gas limit
60840
60948
  * Chain is configured with min-gas-prices = "0stake" so no fee tokens required
@@ -61325,36 +61433,31 @@ class SigningCosmosClient extends CosmosClient {
61325
61433
  * Requires the player account to EXIST on-chain (funded). Same gasless
61326
61434
  * fee + msg shape as {@link performActionSync}.
61327
61435
  */
61328
- async signPerformAction(gameId, action, amount = 0n, data, signerData) {
61329
- await this.initializeSigningClient();
61330
- if (!this.signingClient || !this.wallet) {
61331
- throw new Error("Signing client not initialized");
61436
+ async signPerformAction(gameId, action, amount = 0n, data, _signerData) {
61437
+ // Unordered signing needs only the wallet + REST getAccount — no RPC
61438
+ // stargate client, so this works without a reachable RPC endpoint.
61439
+ if (!this.wallet) {
61440
+ throw new Error("No wallet provided for signing");
61332
61441
  }
61333
61442
  const [account] = await this.wallet.getAccounts();
61334
61443
  const player = account.address;
61335
- const msgPerformAction = {
61336
- player,
61337
- gameId,
61338
- action,
61339
- amount: Long.fromString(amount.toString(), true),
61340
- data: data || ""
61341
- };
61342
61444
  const msg = {
61343
61445
  typeUrl: "/pokerchain.poker.v1.MsgPerformAction",
61344
- value: msgPerformAction
61446
+ value: {
61447
+ player,
61448
+ gameId,
61449
+ action,
61450
+ amount: Long.fromString(amount.toString(), true),
61451
+ data: data || ""
61452
+ }
61345
61453
  };
61346
- let explicit = signerData;
61347
- if (!explicit) {
61348
- const accountInfo = await this.getAccount(player);
61349
- explicit = {
61350
- accountNumber: Number(accountInfo.account.account_number),
61351
- sequence: Number(accountInfo.account.sequence),
61352
- chainId: this.config.chainId
61353
- };
61354
- }
61355
- const txRaw = await this.signingClient.sign(player, [msg], gaslessFee(), `Poker action (relay): ${action}`, explicit);
61356
- const base64 = toBase64(txExports.TxRaw.encode(txRaw).finish());
61357
- return { base64, sequence: explicit.sequence, accountNumber: explicit.accountNumber };
61454
+ // Settlement txs are UNORDERED (#247): no account sequence, so optimistic
61455
+ // play can never desync the chain sequence (the #2413 cascade). The
61456
+ // `signerData`/sequence arg is retained for signature compatibility but
61457
+ // ignored — unordered txs carry sequence 0.
61458
+ const { base64, accountNumber } = await this.signUnordered(msg);
61459
+ // sequence is meaningless for unordered txs; return 0 for shape compat.
61460
+ return { base64, sequence: 0, accountNumber };
61358
61461
  }
61359
61462
  /**
61360
61463
  * Resolves the signer data (account number + sequence + chain id) for a
@@ -61390,6 +61493,59 @@ class SigningCosmosClient extends CosmosClient {
61390
61493
  const base64 = toBase64(txExports.TxRaw.encode(txRaw).finish());
61391
61494
  return { base64, sequence: explicit.sequence, accountNumber: explicit.accountNumber };
61392
61495
  }
61496
+ /**
61497
+ * Sign a single cosmos message as an UNORDERED transaction (SDK 0.53): the
61498
+ * TxBody carries `unordered: true` + a `timeout_timestamp` and NO account
61499
+ * sequence (sequence MUST be 0). The chain admits it regardless of order and
61500
+ * dedups replay on (signer, timeout) — so settlement txs no longer carry a
61501
+ * client-guessed sequence and can never cascade (poker-vm#247, replaces the
61502
+ * sequence-tracking that caused #2413).
61503
+ *
61504
+ * Hand-built because CosmJS 0.32's TxBody proto predates the unordered
61505
+ * fields; we use the SDK's own cosmos.tx proto (which has them) for the body
61506
+ * and CosmJS only for AuthInfo + the direct signature.
61507
+ *
61508
+ * @param ttlSeconds - how far ahead the timeout_timestamp is set. Must be
61509
+ * within the chain's max unordered TTL (SDK default 10m). Also bounds how
61510
+ * long a replay of this exact tx is rejected.
61511
+ */
61512
+ async signUnordered(msg, ttlSeconds = 120) {
61513
+ // No RPC signing client needed: unordered signing is a direct signature
61514
+ // over locally-built bytes. Only the wallet (for signDirect) and a REST
61515
+ // getAccount (for account_number) are required.
61516
+ if (!this.wallet) {
61517
+ throw new Error("No wallet provided for signing");
61518
+ }
61519
+ const [account] = await this.wallet.getAccounts();
61520
+ const player = account.address;
61521
+ // account_number + chainId are still needed for the sign doc; the
61522
+ // SEQUENCE is not — unordered txs must sign with sequence 0.
61523
+ const accountInfo = await this.getAccount(player);
61524
+ const accountNumber = Number(accountInfo.account.account_number);
61525
+ const chainId = this.config.chainId;
61526
+ // Body with unordered=true + timeout_timestamp, messages packed as Any
61527
+ // via the poker registry. timeoutHeight stays 0 (we gate on timestamp).
61528
+ const bodyBytes = TxBody.encode(TxBody.fromPartial({
61529
+ messages: [pokerRegistry.encodeAsAny(msg)],
61530
+ memo: "",
61531
+ timeoutHeight: Long.UZERO,
61532
+ unordered: true,
61533
+ timeoutTimestamp: new Date(Date.now() + ttlSeconds * 1000)
61534
+ })).finish();
61535
+ // AuthInfo with sequence 0 (required for unordered). CosmJS builds this
61536
+ // — the pubkey/fee encoding is unchanged from an ordered tx.
61537
+ const pubkey = encodePubkey(encodeSecp256k1Pubkey(account.pubkey));
61538
+ const gas = gaslessFee();
61539
+ const authInfoBytes = makeAuthInfoBytes([{ pubkey, sequence: 0 }], gas.amount, Number(gas.gas), undefined, undefined);
61540
+ const signDoc = makeSignDoc(bodyBytes, authInfoBytes, chainId, accountNumber);
61541
+ const { signature, signed } = await this.wallet.signDirect(player, signDoc);
61542
+ const base64 = toBase64(TxRaw.encode(TxRaw.fromPartial({
61543
+ bodyBytes: signed.bodyBytes,
61544
+ authInfoBytes: signed.authInfoBytes,
61545
+ signatures: [fromBase64(signature.signature)]
61546
+ })).finish());
61547
+ return { base64, accountNumber };
61548
+ }
61393
61549
  /**
61394
61550
  * Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
61395
61551
  * broadcasting, returning the base64 TxRaw for the gateway to relay
@@ -61861,5 +62017,5 @@ const registry = new Registry([
61861
62017
  ...msgTypes,
61862
62018
  ]);
61863
62019
 
61864
- export { AllPlayerActions, BLOCK52_HD_PATH, COSMOS_CONSTANTS, Client, CosmosClient, Deck, GameFormat, GameStatus, GameVariant, HandType, KEYS, 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, WithdrawalRequest, createSigningClientFromMnemonic, createWalletFromMnemonic, formatGameFormatDisplay, formatGameVariantDisplay, generateWallet, getActionByType, getAddressFromMnemonic, getDefaultCosmosConfig, getGameFormat, getGameFormatForCosmos, getGameFormatFromObject, getGameVariant, hasAction, isCashFormat, isEmptyAddress, isSitAndGoFormat, isTournamentFormat, isValidMnemonic, isValidPlayerAddress, parseGameFormat, parseGameVariant, registry };
62020
+ export { AllPlayerActions, BLOCK52_HD_PATH, Board, COSMOS_CONSTANTS, Client, CosmosClient, Deck, GameFormat, GameStatus, GameVariant, HandType, KEYS, 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, WithdrawalRequest, createSigningClientFromMnemonic, createWalletFromMnemonic, formatGameFormatDisplay, formatGameVariantDisplay, generateWallet, getActionByType, getAddressFromMnemonic, getDefaultCosmosConfig, getGameFormat, getGameFormatForCosmos, getGameFormatFromObject, getGameVariant, hasAction, isCashFormat, isEmptyAddress, isSitAndGoFormat, isTournamentFormat, isValidMnemonic, isValidPlayerAddress, parseGameFormat, parseGameVariant, registry };
61865
62021
  //# sourceMappingURL=index.esm.js.map