@block52/poker-vm-sdk 1.3.5 → 1.4.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.
- package/dist/index.d.ts +102 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +189 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +193 -20
- package/dist/index.js.map +1 -1
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts +5 -0
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts.map +1 -1
- package/dist/signingClient.d.ts +14 -1
- package/dist/signingClient.d.ts.map +1 -1
- package/dist/txResult.d.ts +63 -0
- package/dist/txResult.d.ts.map +1 -0
- package/dist/types/game.d.ts +18 -0
- package/dist/types/game.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -44941,6 +44941,11 @@ interface MsgCreateGame {
|
|
|
44941
44941
|
gameVariant: string;
|
|
44942
44942
|
/** SNG flat entry fee in micro-units, skimmed to the creator (poker-vm#2118) */
|
|
44943
44943
|
entryFee: Long;
|
|
44944
|
+
/**
|
|
44945
|
+
* Optional ENS-style table name (field 19). Lowercase [a-z0-9-], 1-32 chars,
|
|
44946
|
+
* globally unique, $0.10/char to validators. Empty = unnamed. (block52/pokerchain#337)
|
|
44947
|
+
*/
|
|
44948
|
+
name: string;
|
|
44944
44949
|
}
|
|
44945
44950
|
declare const MsgCreateGame: MessageFns<MsgCreateGame>;
|
|
44946
44951
|
/** MsgJoinGame defines the MsgJoinGame message. */
|
|
@@ -45260,6 +45265,7 @@ declare enum NonPlayerActionType {
|
|
|
45260
45265
|
SIT_IN = "sit-in",
|
|
45261
45266
|
SIT_IN_AND_WAIT = "sit-in-and-wait",
|
|
45262
45267
|
SIT_OUT = "sit-out",
|
|
45268
|
+
TIMEOUT = "timeout",
|
|
45263
45269
|
TOP_UP = "top-up"
|
|
45264
45270
|
}
|
|
45265
45271
|
declare const AllPlayerActions: {
|
|
@@ -45273,6 +45279,7 @@ declare const AllPlayerActions: {
|
|
|
45273
45279
|
SIT_IN: NonPlayerActionType.SIT_IN;
|
|
45274
45280
|
SIT_IN_AND_WAIT: NonPlayerActionType.SIT_IN_AND_WAIT;
|
|
45275
45281
|
SIT_OUT: NonPlayerActionType.SIT_OUT;
|
|
45282
|
+
TIMEOUT: NonPlayerActionType.TIMEOUT;
|
|
45276
45283
|
TOP_UP: NonPlayerActionType.TOP_UP;
|
|
45277
45284
|
SMALL_BLIND: PlayerActionType.SMALL_BLIND;
|
|
45278
45285
|
BIG_BLIND: PlayerActionType.BIG_BLIND;
|
|
@@ -45527,6 +45534,7 @@ type GameStateResponseDTO = {
|
|
|
45527
45534
|
creator: string;
|
|
45528
45535
|
format: GameFormat;
|
|
45529
45536
|
variant: GameVariant;
|
|
45537
|
+
name?: string;
|
|
45530
45538
|
gameState: TexasHoldemStateDTO;
|
|
45531
45539
|
};
|
|
45532
45540
|
declare enum SUIT {
|
|
@@ -45558,11 +45566,26 @@ type GameListItem = {
|
|
|
45558
45566
|
creator: string;
|
|
45559
45567
|
format: GameFormat;
|
|
45560
45568
|
variant: GameVariant;
|
|
45569
|
+
name?: string;
|
|
45561
45570
|
gameOptions: GameOptionsDTO;
|
|
45562
45571
|
currentPlayers: number;
|
|
45563
45572
|
createdAt?: string;
|
|
45564
45573
|
updatedAt?: string;
|
|
45565
45574
|
};
|
|
45575
|
+
/**
|
|
45576
|
+
* Cost of ONE character of a paid table name, in micro-USDC ($0.10). The total
|
|
45577
|
+
* naming fee is `length * GAME_NAME_MICRO_PER_CHAR`, charged on top of the
|
|
45578
|
+
* game-creation cost and paid to validators. This is the SINGLE SOURCE OF TRUTH
|
|
45579
|
+
* for the price so the UI preview and the chain agree. (block52/pokerchain#337)
|
|
45580
|
+
*/
|
|
45581
|
+
declare const GAME_NAME_MICRO_PER_CHAR = 100000n;
|
|
45582
|
+
/** Maximum table-name length (code points); bounds the max fee at 32 * $0.10. */
|
|
45583
|
+
declare const MAX_GAME_NAME_LENGTH = 32;
|
|
45584
|
+
/**
|
|
45585
|
+
* Total naming fee (micro-USDC) for a table name: $0.10 per character. Counts
|
|
45586
|
+
* code points to match the chain's rune-based charge. An empty name is free.
|
|
45587
|
+
*/
|
|
45588
|
+
declare const computeGameNameFee: (name: string) => bigint;
|
|
45566
45589
|
type BlockID = {
|
|
45567
45590
|
hash: string;
|
|
45568
45591
|
part_set_header?: {
|
|
@@ -46537,6 +46560,7 @@ interface SNGConfig {
|
|
|
46537
46560
|
declare class SigningCosmosClient extends CosmosClient {
|
|
46538
46561
|
private wallet?;
|
|
46539
46562
|
private signingClient?;
|
|
46563
|
+
private readonly accountNumbers;
|
|
46540
46564
|
private gasPrice;
|
|
46541
46565
|
constructor(config: SigningCosmosConfig);
|
|
46542
46566
|
/**
|
|
@@ -46558,7 +46582,7 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46558
46582
|
/**
|
|
46559
46583
|
* Create a new poker game
|
|
46560
46584
|
*/
|
|
46561
|
-
createGame(gameFormat: string, gameVariant: string, minPlayers: number, maxPlayers: number, minBuyInB52USDC: bigint, maxBuyInB52USDC: bigint, smallBlindB52USDC: bigint, bigBlindB52USDC: bigint, timeout: number, rakeConfig?: RakeConfig, sngConfig?: SNGConfig): Promise<string>;
|
|
46585
|
+
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): Promise<string>;
|
|
46562
46586
|
/**
|
|
46563
46587
|
* Join a poker game
|
|
46564
46588
|
*/
|
|
@@ -46635,6 +46659,11 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46635
46659
|
*
|
|
46636
46660
|
* Returns the tx hash on CheckTx success; throws if CheckTx
|
|
46637
46661
|
* rejects (invalid signature, malformed msg, insufficient gas).
|
|
46662
|
+
*
|
|
46663
|
+
* Deliberately NOT routed through `assertExecuted` (#2609): there is no
|
|
46664
|
+
* DeliverTx result to check at this point — the hash is a CheckTx receipt,
|
|
46665
|
+
* and the execution outcome arrives over the WebSocket. Every other
|
|
46666
|
+
* broadcasting method in this class waits for inclusion and must check.
|
|
46638
46667
|
*/
|
|
46639
46668
|
performActionSync(gameId: string, action: string, amount?: bigint, data?: string): Promise<string>;
|
|
46640
46669
|
/**
|
|
@@ -46688,6 +46717,13 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46688
46717
|
* long a replay of this exact tx is rejected.
|
|
46689
46718
|
*/
|
|
46690
46719
|
private signUnordered;
|
|
46720
|
+
/**
|
|
46721
|
+
* account_number for the unordered sign doc. It is assigned once when the
|
|
46722
|
+
* account is created and never changes, so look it up once per signer —
|
|
46723
|
+
* performActionSync signs on every player action and shouldn't pay a REST
|
|
46724
|
+
* round trip (or inherit its failure modes) each time.
|
|
46725
|
+
*/
|
|
46726
|
+
private unorderedAccountNumber;
|
|
46691
46727
|
/**
|
|
46692
46728
|
* Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
|
|
46693
46729
|
* broadcasting, returning the base64 TxRaw for the gateway to relay
|
|
@@ -46795,6 +46831,69 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46795
46831
|
*/
|
|
46796
46832
|
declare function createSigningClientFromMnemonic(config: CosmosConfig, mnemonic: string): Promise<SigningCosmosClient>;
|
|
46797
46833
|
|
|
46834
|
+
/**
|
|
46835
|
+
* The part of a broadcast result this module reads. Structurally a subset of
|
|
46836
|
+
* CosmJS's `DeliverTxResponse`, so both the real response and a test double fit.
|
|
46837
|
+
*/
|
|
46838
|
+
interface ExecutionResult {
|
|
46839
|
+
transactionHash: string;
|
|
46840
|
+
code: number;
|
|
46841
|
+
rawLog?: string;
|
|
46842
|
+
}
|
|
46843
|
+
/**
|
|
46844
|
+
* Thrown when a transaction was broadcast and included in a block but its
|
|
46845
|
+
* EXECUTION failed (nonzero `DeliverTxResponse.code`). The hash, code and raw
|
|
46846
|
+
* log are retained so the failure can be looked up and shown. (#2609)
|
|
46847
|
+
*/
|
|
46848
|
+
declare class TxExecutionError extends Error {
|
|
46849
|
+
readonly transactionHash: string;
|
|
46850
|
+
readonly code: number;
|
|
46851
|
+
readonly rawLog?: string;
|
|
46852
|
+
constructor(operation: string, result: ExecutionResult);
|
|
46853
|
+
}
|
|
46854
|
+
/**
|
|
46855
|
+
* Assert that a broadcast transaction actually EXECUTED successfully.
|
|
46856
|
+
*
|
|
46857
|
+
* CosmJS resolves `signAndBroadcast` normally when execution fails — a nonzero
|
|
46858
|
+
* `DeliverTxResponse.code` is the only failure signal, and it is easy to miss
|
|
46859
|
+
* because nothing throws. Returning `result.transactionHash` without checking
|
|
46860
|
+
* reports "insufficient funds" and "invalid request" to the caller as success.
|
|
46861
|
+
*
|
|
46862
|
+
* Every SDK method that broadcasts and waits for inclusion goes through this.
|
|
46863
|
+
* The exception is `performActionSync`, which returns a CheckTx-only hash by
|
|
46864
|
+
* design and whose caller waits on a WebSocket push for the committed result —
|
|
46865
|
+
* see the comment there before adding a check to it.
|
|
46866
|
+
*/
|
|
46867
|
+
declare function assertExecuted(operation: string, result: ExecutionResult): void;
|
|
46868
|
+
/**
|
|
46869
|
+
* Where a failed SDK transaction call stopped. Lets a caller decide whether
|
|
46870
|
+
* chain state may have changed and whether resubmitting is safe:
|
|
46871
|
+
*
|
|
46872
|
+
* - `"not-broadcast"`: the node rejected the tx at CheckTx (CosmJS
|
|
46873
|
+
* `BroadcastTxError`). It never entered a block; nothing changed; fix the
|
|
46874
|
+
* cause and resubmit.
|
|
46875
|
+
* - `"execution-failed"`: the tx was included in a block but failed there
|
|
46876
|
+
* ({@link TxExecutionError}). The state change did not happen, the hash
|
|
46877
|
+
* exists, and resubmitting the same tx fails the same way unless the cause
|
|
46878
|
+
* changed.
|
|
46879
|
+
* - `"unknown"`: the mempool accepted the tx but inclusion was not observed
|
|
46880
|
+
* before CosmJS's timeout (`TimeoutError`). It MAY still execute — look the
|
|
46881
|
+
* hash up before retrying, or the retry can double-submit.
|
|
46882
|
+
*/
|
|
46883
|
+
type TxFailurePhase = "not-broadcast" | "execution-failed" | "unknown";
|
|
46884
|
+
/**
|
|
46885
|
+
* Classify an error thrown by an SDK broadcast method. Returns `undefined` for
|
|
46886
|
+
* errors raised before any broadcast (argument validation, no wallet, signing)
|
|
46887
|
+
* or by another layer (REST queries, network) — those carry no transaction.
|
|
46888
|
+
*/
|
|
46889
|
+
declare function txFailurePhase(error: unknown): TxFailurePhase | undefined;
|
|
46890
|
+
/**
|
|
46891
|
+
* The hash of the transaction behind a failed broadcast call, when one exists:
|
|
46892
|
+
* the included-but-failed tx for `"execution-failed"`, the pending tx for
|
|
46893
|
+
* `"unknown"`. `"not-broadcast"` and pre-broadcast errors have none.
|
|
46894
|
+
*/
|
|
46895
|
+
declare function txFailureHash(error: unknown): string | undefined;
|
|
46896
|
+
|
|
46798
46897
|
declare const Client: typeof IgniteClient & Constructor<{
|
|
46799
46898
|
PokerchainPokerV_1: {
|
|
46800
46899
|
query: ReturnType<typeof queryClient>;
|
|
@@ -47046,5 +47145,5 @@ declare const Client: typeof IgniteClient & Constructor<{
|
|
|
47046
47145
|
}>;
|
|
47047
47146
|
declare const registry: Registry;
|
|
47048
47147
|
|
|
47049
|
-
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, ValidatorBond, WithdrawalRequest, createSigningClientFromMnemonic, createWalletFromMnemonic, formatGameFormatDisplay, formatGameVariantDisplay, generateWallet, getActionByType, getAddressFromMnemonic, getDefaultCosmosConfig, getGameFormat, getGameFormatForCosmos, getGameFormatFromObject, getGameVariant, hasAction, isCashFormat, isEmptyAddress, isSitAndGoFormat, isTournamentFormat, isValidMnemonic, isValidPlayerAddress, parseGameFormat, parseGameVariant, registry };
|
|
47050
|
-
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 };
|
|
47148
|
+
export { AllPlayerActions, BLOCK52_HD_PATH, Board, COSMOS_CONSTANTS, Client, CosmosClient, Deck, GAME_NAME_MICRO_PER_CHAR, GameFormat, GameStatus, GameVariant, HandType, KEYS, MAX_GAME_NAME_LENGTH, 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, assertExecuted, computeGameNameFee, createSigningClientFromMnemonic, createWalletFromMnemonic, formatGameFormatDisplay, formatGameVariantDisplay, generateWallet, getActionByType, getAddressFromMnemonic, getDefaultCosmosConfig, getGameFormat, getGameFormatForCosmos, getGameFormatFromObject, getGameVariant, hasAction, isCashFormat, isEmptyAddress, isSitAndGoFormat, isTournamentFormat, isValidMnemonic, isValidPlayerAddress, parseGameFormat, parseGameVariant, registry, txFailureHash, txFailurePhase };
|
|
47149
|
+
export type { AccountDTO, ActionDTO, Block, BlockDTO, BlockHeader, BlockHeaderDTO, BlockID, BlockResponse, BurnResponseDTO, Card, EquityHand, EquityRequest, EquityResponse, EquityResult, ExecutionResult, GameListItem, GameOptions, GameOptionsDTO, GameOptionsResponse, GameStateResponse, GameStateResponseDTO, HandEvaluation, ISignedResponse, LegalActionDTO, PayoutPlaceDTO, PerformActionResponse, PlayerDTO, RPCRequest, RPCRequestParams, RPCResponse, RakeConfig, RakeConfigDTO, ResultDTO, SitInMethod, SitOutMethod, TexasHoldemGameState, TexasHoldemStateDTO, TransactionDTO, TransactionResponse, TxFailurePhase, WalletInfo, WinnerDTO, WithdrawResponseDTO };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,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;
|
|
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;AAIvG,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAA;AAGvI,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,9 @@
|
|
|
1
1
|
import { Registry, DirectSecp256k1HdWallet, encodePubkey, makeAuthInfoBytes, makeSignDoc } from '@cosmjs/proto-signing';
|
|
2
|
-
import { SigningStargateClient, GasPrice } from '@cosmjs/stargate';
|
|
2
|
+
import { SigningStargateClient, BroadcastTxError, TimeoutError, GasPrice } from '@cosmjs/stargate';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { stringToPath } from '@cosmjs/crypto';
|
|
5
5
|
import { createHash, createHmac } from 'crypto';
|
|
6
|
-
import {
|
|
6
|
+
import { fromBase64, toBase64 } from '@cosmjs/encoding';
|
|
7
7
|
import { encodeSecp256k1Pubkey } from '@cosmjs/amino';
|
|
8
8
|
|
|
9
9
|
/// <reference path="./types.d.ts" />
|
|
@@ -2844,6 +2844,7 @@ function createBaseMsgCreateGame() {
|
|
|
2844
2844
|
blindLevelDuration: 0,
|
|
2845
2845
|
gameVariant: "",
|
|
2846
2846
|
entryFee: Long.UZERO,
|
|
2847
|
+
name: "",
|
|
2847
2848
|
};
|
|
2848
2849
|
}
|
|
2849
2850
|
const MsgCreateGame = {
|
|
@@ -2899,6 +2900,9 @@ const MsgCreateGame = {
|
|
|
2899
2900
|
if (!message.entryFee.equals(Long.UZERO)) {
|
|
2900
2901
|
writer.uint32(136).uint64(message.entryFee.toString());
|
|
2901
2902
|
}
|
|
2903
|
+
if (message.name !== "") {
|
|
2904
|
+
writer.uint32(154).string(message.name);
|
|
2905
|
+
}
|
|
2902
2906
|
return writer;
|
|
2903
2907
|
},
|
|
2904
2908
|
decode(input, length) {
|
|
@@ -3027,6 +3031,13 @@ const MsgCreateGame = {
|
|
|
3027
3031
|
message.entryFee = Long.fromString(reader.uint64().toString(), true);
|
|
3028
3032
|
continue;
|
|
3029
3033
|
}
|
|
3034
|
+
case 19: {
|
|
3035
|
+
if (tag !== 154) {
|
|
3036
|
+
break;
|
|
3037
|
+
}
|
|
3038
|
+
message.name = reader.string();
|
|
3039
|
+
continue;
|
|
3040
|
+
}
|
|
3030
3041
|
}
|
|
3031
3042
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3032
3043
|
break;
|
|
@@ -3054,6 +3065,7 @@ const MsgCreateGame = {
|
|
|
3054
3065
|
blindLevelDuration: isSet$2b(object.blindLevelDuration) ? globalThis.Number(object.blindLevelDuration) : 0,
|
|
3055
3066
|
gameVariant: isSet$2b(object.gameVariant) ? globalThis.String(object.gameVariant) : "",
|
|
3056
3067
|
entryFee: isSet$2b(object.entryFee) ? Long.fromValue(object.entryFee) : Long.UZERO,
|
|
3068
|
+
name: isSet$2b(object.name) ? globalThis.String(object.name) : "",
|
|
3057
3069
|
};
|
|
3058
3070
|
},
|
|
3059
3071
|
toJSON(message) {
|
|
@@ -3109,6 +3121,9 @@ const MsgCreateGame = {
|
|
|
3109
3121
|
if (!message.entryFee.equals(Long.UZERO)) {
|
|
3110
3122
|
obj.entryFee = (message.entryFee || Long.UZERO).toString();
|
|
3111
3123
|
}
|
|
3124
|
+
if (message.name !== "") {
|
|
3125
|
+
obj.name = message.name;
|
|
3126
|
+
}
|
|
3112
3127
|
return obj;
|
|
3113
3128
|
},
|
|
3114
3129
|
create(base) {
|
|
@@ -3152,6 +3167,7 @@ const MsgCreateGame = {
|
|
|
3152
3167
|
: Long.UZERO;
|
|
3153
3168
|
message.blindLevelDuration = object.blindLevelDuration ?? 0;
|
|
3154
3169
|
message.gameVariant = object.gameVariant ?? "";
|
|
3170
|
+
message.name = object.name ?? "";
|
|
3155
3171
|
message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
|
|
3156
3172
|
? Long.fromValue(object.entryFee)
|
|
3157
3173
|
: Long.UZERO;
|
|
@@ -56149,6 +56165,14 @@ var NonPlayerActionType;
|
|
|
56149
56165
|
// so each has a single responsibility. Sets WAITING_FOR_BIG_BLIND. (#2139)
|
|
56150
56166
|
NonPlayerActionType["SIT_IN_AND_WAIT"] = "sit-in-and-wait";
|
|
56151
56167
|
NonPlayerActionType["SIT_OUT"] = "sit-out";
|
|
56168
|
+
// Action clock enforcement (poker-vm#2523): submitted by ANY address once the
|
|
56169
|
+
// next-to-act player's turn deadline (last recorded action timestamp +
|
|
56170
|
+
// gameOptions.timeout seconds) has passed. The engine plays that player's
|
|
56171
|
+
// forced default action on their behalf — CHECK if legal else FOLD in a
|
|
56172
|
+
// betting round, the owed blind post or DEAL in ANTE, MUCK if legal else
|
|
56173
|
+
// SHOW at showdown — and records THAT action; no "timeout" turn is ever
|
|
56174
|
+
// written to previousActions. Rejected while the turn has time remaining.
|
|
56175
|
+
NonPlayerActionType["TIMEOUT"] = "timeout";
|
|
56152
56176
|
NonPlayerActionType["TOP_UP"] = "top-up";
|
|
56153
56177
|
})(NonPlayerActionType || (NonPlayerActionType = {}));
|
|
56154
56178
|
const AllPlayerActions = { ...PlayerActionType, ...NonPlayerActionType };
|
|
@@ -56220,6 +56244,20 @@ var SUIT;
|
|
|
56220
56244
|
SUIT[SUIT["HEARTS"] = 3] = "HEARTS";
|
|
56221
56245
|
SUIT[SUIT["SPADES"] = 4] = "SPADES";
|
|
56222
56246
|
})(SUIT || (SUIT = {}));
|
|
56247
|
+
/**
|
|
56248
|
+
* Cost of ONE character of a paid table name, in micro-USDC ($0.10). The total
|
|
56249
|
+
* naming fee is `length * GAME_NAME_MICRO_PER_CHAR`, charged on top of the
|
|
56250
|
+
* game-creation cost and paid to validators. This is the SINGLE SOURCE OF TRUTH
|
|
56251
|
+
* for the price so the UI preview and the chain agree. (block52/pokerchain#337)
|
|
56252
|
+
*/
|
|
56253
|
+
const GAME_NAME_MICRO_PER_CHAR = 100000n;
|
|
56254
|
+
/** Maximum table-name length (code points); bounds the max fee at 32 * $0.10. */
|
|
56255
|
+
const MAX_GAME_NAME_LENGTH = 32;
|
|
56256
|
+
/**
|
|
56257
|
+
* Total naming fee (micro-USDC) for a table name: $0.10 per character. Counts
|
|
56258
|
+
* code points to match the chain's rune-based charge. An empty name is free.
|
|
56259
|
+
*/
|
|
56260
|
+
const computeGameNameFee = (name) => BigInt([...name].length) * GAME_NAME_MICRO_PER_CHAR;
|
|
56223
56261
|
// Constants for URL parameters
|
|
56224
56262
|
const KEYS = {
|
|
56225
56263
|
ACTION_TYPE: "action_type",
|
|
@@ -61124,6 +61162,79 @@ function requireTx () {
|
|
|
61124
61162
|
|
|
61125
61163
|
var txExports = requireTx();
|
|
61126
61164
|
|
|
61165
|
+
/**
|
|
61166
|
+
* Thrown when a transaction was broadcast and included in a block but its
|
|
61167
|
+
* EXECUTION failed (nonzero `DeliverTxResponse.code`). The hash, code and raw
|
|
61168
|
+
* log are retained so the failure can be looked up and shown. (#2609)
|
|
61169
|
+
*/
|
|
61170
|
+
class TxExecutionError extends Error {
|
|
61171
|
+
constructor(operation, result) {
|
|
61172
|
+
super(`Failed to ${operation}: transaction ${result.transactionHash} failed with code ${result.code}` +
|
|
61173
|
+
(result.rawLog ? ` — ${result.rawLog}` : ""));
|
|
61174
|
+
this.name = "TxExecutionError";
|
|
61175
|
+
this.transactionHash = result.transactionHash;
|
|
61176
|
+
this.code = result.code;
|
|
61177
|
+
this.rawLog = result.rawLog;
|
|
61178
|
+
}
|
|
61179
|
+
}
|
|
61180
|
+
/**
|
|
61181
|
+
* Assert that a broadcast transaction actually EXECUTED successfully.
|
|
61182
|
+
*
|
|
61183
|
+
* CosmJS resolves `signAndBroadcast` normally when execution fails — a nonzero
|
|
61184
|
+
* `DeliverTxResponse.code` is the only failure signal, and it is easy to miss
|
|
61185
|
+
* because nothing throws. Returning `result.transactionHash` without checking
|
|
61186
|
+
* reports "insufficient funds" and "invalid request" to the caller as success.
|
|
61187
|
+
*
|
|
61188
|
+
* Every SDK method that broadcasts and waits for inclusion goes through this.
|
|
61189
|
+
* The exception is `performActionSync`, which returns a CheckTx-only hash by
|
|
61190
|
+
* design and whose caller waits on a WebSocket push for the committed result —
|
|
61191
|
+
* see the comment there before adding a check to it.
|
|
61192
|
+
*/
|
|
61193
|
+
function assertExecuted(operation, result) {
|
|
61194
|
+
// A real DeliverTxResponse always carries `code`. If it is missing we cannot
|
|
61195
|
+
// tell success from failure, so fail closed and say why — reporting it as
|
|
61196
|
+
// "code undefined" would send someone hunting a chain error that does not
|
|
61197
|
+
// exist, when the actual problem is a malformed response or a partial mock.
|
|
61198
|
+
if (typeof result?.code !== "number") {
|
|
61199
|
+
throw new Error(`Failed to ${operation}: broadcast response has no execution code, so success cannot be confirmed ` +
|
|
61200
|
+
`(transaction ${result?.transactionHash ?? "unknown"})`);
|
|
61201
|
+
}
|
|
61202
|
+
if (result.code !== 0) {
|
|
61203
|
+
throw new TxExecutionError(operation, result);
|
|
61204
|
+
}
|
|
61205
|
+
}
|
|
61206
|
+
/**
|
|
61207
|
+
* Classify an error thrown by an SDK broadcast method. Returns `undefined` for
|
|
61208
|
+
* errors raised before any broadcast (argument validation, no wallet, signing)
|
|
61209
|
+
* or by another layer (REST queries, network) — those carry no transaction.
|
|
61210
|
+
*/
|
|
61211
|
+
function txFailurePhase(error) {
|
|
61212
|
+
if (error instanceof TxExecutionError) {
|
|
61213
|
+
return "execution-failed";
|
|
61214
|
+
}
|
|
61215
|
+
if (error instanceof BroadcastTxError) {
|
|
61216
|
+
return "not-broadcast";
|
|
61217
|
+
}
|
|
61218
|
+
if (error instanceof TimeoutError) {
|
|
61219
|
+
return "unknown";
|
|
61220
|
+
}
|
|
61221
|
+
return undefined;
|
|
61222
|
+
}
|
|
61223
|
+
/**
|
|
61224
|
+
* The hash of the transaction behind a failed broadcast call, when one exists:
|
|
61225
|
+
* the included-but-failed tx for `"execution-failed"`, the pending tx for
|
|
61226
|
+
* `"unknown"`. `"not-broadcast"` and pre-broadcast errors have none.
|
|
61227
|
+
*/
|
|
61228
|
+
function txFailureHash(error) {
|
|
61229
|
+
if (error instanceof TxExecutionError) {
|
|
61230
|
+
return error.transactionHash;
|
|
61231
|
+
}
|
|
61232
|
+
if (error instanceof TimeoutError) {
|
|
61233
|
+
return error.txId;
|
|
61234
|
+
}
|
|
61235
|
+
return undefined;
|
|
61236
|
+
}
|
|
61237
|
+
|
|
61127
61238
|
/**
|
|
61128
61239
|
* Default gas limit for all transactions
|
|
61129
61240
|
*/
|
|
@@ -61132,6 +61243,18 @@ const DEFAULT_GAS_LIMIT = 1000000;
|
|
|
61132
61243
|
// hand-building an unordered TxBody (signUnordered). Module-level so it's built
|
|
61133
61244
|
// once and shared with the stargate client's registry semantics.
|
|
61134
61245
|
const pokerRegistry = new Registry(msgTypes$u);
|
|
61246
|
+
// The chain dedups unordered txs on (signer, timeout_timestamp), so two txs
|
|
61247
|
+
// from one account must never share a timeout. Date has millisecond resolution
|
|
61248
|
+
// and a client fires blind + deal + action back to back, so track the last
|
|
61249
|
+
// timeout handed out per signer and keep it strictly increasing. Module-level:
|
|
61250
|
+
// callers rebuild the client (e.g. after a transport error) mid-session.
|
|
61251
|
+
const lastUnorderedTimeoutMs = new Map();
|
|
61252
|
+
function nextUnorderedTimeoutMs(signer, ttlSeconds) {
|
|
61253
|
+
const wanted = Date.now() + ttlSeconds * 1000;
|
|
61254
|
+
const timeoutMs = Math.max(wanted, (lastUnorderedTimeoutMs.get(signer) ?? 0) + 1);
|
|
61255
|
+
lastUnorderedTimeoutMs.set(signer, timeoutMs);
|
|
61256
|
+
return timeoutMs;
|
|
61257
|
+
}
|
|
61135
61258
|
/**
|
|
61136
61259
|
* Create a gasless fee object with specified gas limit
|
|
61137
61260
|
* Chain is configured with min-gas-prices = "0stake" so no fee tokens required
|
|
@@ -61157,6 +61280,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61157
61280
|
gasPrice: typeof config.gasPrice === 'string' ? config.gasPrice : (config.gasPrice?.toString() || COSMOS_CONSTANTS.DEFAULT_GAS_PRICE)
|
|
61158
61281
|
};
|
|
61159
61282
|
super(baseConfig);
|
|
61283
|
+
this.accountNumbers = new Map();
|
|
61160
61284
|
this.wallet = config.wallet;
|
|
61161
61285
|
// Handle gasPrice - convert string to GasPrice if needed
|
|
61162
61286
|
if (typeof config.gasPrice === 'string') {
|
|
@@ -61214,18 +61338,21 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61214
61338
|
const coins = [{ denom: denom, amount: amount.toString() }];
|
|
61215
61339
|
const fee = gaslessFee();
|
|
61216
61340
|
const result = await this.signingClient.sendTokens(fromAddress, toAddress, coins, fee, memo || "");
|
|
61341
|
+
assertExecuted("send tokens", result);
|
|
61217
61342
|
return result.transactionHash;
|
|
61218
61343
|
}
|
|
61219
61344
|
/**
|
|
61220
61345
|
* Send B52USDC tokens
|
|
61221
61346
|
*/
|
|
61222
61347
|
async sendB52USDC(fromAddress, toAddress, amount, memo) {
|
|
61223
|
-
|
|
61348
|
+
// `denom` is the 4th parameter — passing `memo` here put the memo text
|
|
61349
|
+
// into the coin denom and always sent an empty memo.
|
|
61350
|
+
return this.sendTokens(fromAddress, toAddress, amount, undefined, memo);
|
|
61224
61351
|
}
|
|
61225
61352
|
/**
|
|
61226
61353
|
* Create a new poker game
|
|
61227
61354
|
*/
|
|
61228
|
-
async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig) {
|
|
61355
|
+
async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig, name) {
|
|
61229
61356
|
// Validate SNG/Tournament config BEFORE any network work — fail fast.
|
|
61230
61357
|
// SNG/Tournament games are DEFINED by startingStack + blindLevelDuration.
|
|
61231
61358
|
// Refuse to create one with missing/zero values rather than silently
|
|
@@ -61274,6 +61401,9 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61274
61401
|
blindLevelDuration: sngConfig?.blindLevelDuration ?? 0,
|
|
61275
61402
|
// SNG flat entry fee (micro-units), skimmed to the creator at join time (poker-vm#2118)
|
|
61276
61403
|
entryFee: sngConfig?.entryFee ? Long.fromString(sngConfig.entryFee.toString(), true) : Long.UZERO,
|
|
61404
|
+
// Optional ENS-style table name (block52/pokerchain#337). Empty = unnamed
|
|
61405
|
+
// (no fee); a non-empty name costs $0.10/char and must be globally unique.
|
|
61406
|
+
name: name ?? "",
|
|
61277
61407
|
});
|
|
61278
61408
|
// Create the transaction message
|
|
61279
61409
|
const msg = {
|
|
@@ -61307,6 +61437,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61307
61437
|
});
|
|
61308
61438
|
try {
|
|
61309
61439
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61440
|
+
assertExecuted("create game", result);
|
|
61310
61441
|
console.log("✅ Game creation transaction successful:", result.transactionHash);
|
|
61311
61442
|
return result.transactionHash;
|
|
61312
61443
|
}
|
|
@@ -61344,6 +61475,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61344
61475
|
console.log("🪑 Joining game:", { gameId, seat, buyInAmount: buyInAmount.toString() });
|
|
61345
61476
|
try {
|
|
61346
61477
|
const result = await this.signingClient.signAndBroadcast(player, [msg], fee, memo);
|
|
61478
|
+
assertExecuted("join game", result);
|
|
61347
61479
|
console.log("✅ Join game transaction successful:", result.transactionHash);
|
|
61348
61480
|
return result.transactionHash;
|
|
61349
61481
|
}
|
|
@@ -61391,6 +61523,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61391
61523
|
console.log("🚪 Leaving game:", { gameId });
|
|
61392
61524
|
try {
|
|
61393
61525
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61526
|
+
assertExecuted("leave game", result);
|
|
61394
61527
|
console.log("✅ Leave game transaction successful:", result.transactionHash);
|
|
61395
61528
|
return result.transactionHash;
|
|
61396
61529
|
}
|
|
@@ -61423,6 +61556,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61423
61556
|
const memo = "Record hand end via SDK";
|
|
61424
61557
|
try {
|
|
61425
61558
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61559
|
+
assertExecuted("record hand end", result);
|
|
61426
61560
|
return result.transactionHash;
|
|
61427
61561
|
}
|
|
61428
61562
|
catch (error) {
|
|
@@ -61456,6 +61590,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61456
61590
|
console.log("🗑️ Deleting game:", { gameId });
|
|
61457
61591
|
try {
|
|
61458
61592
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61593
|
+
assertExecuted("delete game", result);
|
|
61459
61594
|
console.log("✅ Delete game transaction successful:", result.transactionHash);
|
|
61460
61595
|
return result.transactionHash;
|
|
61461
61596
|
}
|
|
@@ -61495,6 +61630,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61495
61630
|
console.log("🛑 Force-closing game:", { gameId });
|
|
61496
61631
|
try {
|
|
61497
61632
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61633
|
+
assertExecuted("force close game", result);
|
|
61498
61634
|
console.log("✅ Force-close transaction successful:", result.transactionHash);
|
|
61499
61635
|
return result.transactionHash;
|
|
61500
61636
|
}
|
|
@@ -61543,6 +61679,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61543
61679
|
});
|
|
61544
61680
|
try {
|
|
61545
61681
|
const result = await this.signingClient.signAndBroadcast(player, [msg], fee, memo);
|
|
61682
|
+
assertExecuted("perform action", result);
|
|
61546
61683
|
console.log("✅ Action transaction successful:", result.transactionHash);
|
|
61547
61684
|
return result.transactionHash;
|
|
61548
61685
|
}
|
|
@@ -61575,6 +61712,11 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61575
61712
|
*
|
|
61576
61713
|
* Returns the tx hash on CheckTx success; throws if CheckTx
|
|
61577
61714
|
* rejects (invalid signature, malformed msg, insufficient gas).
|
|
61715
|
+
*
|
|
61716
|
+
* Deliberately NOT routed through `assertExecuted` (#2609): there is no
|
|
61717
|
+
* DeliverTx result to check at this point — the hash is a CheckTx receipt,
|
|
61718
|
+
* and the execution outcome arrives over the WebSocket. Every other
|
|
61719
|
+
* broadcasting method in this class waits for inclusion and must check.
|
|
61578
61720
|
*/
|
|
61579
61721
|
async performActionSync(gameId, action, amount = 0n, data) {
|
|
61580
61722
|
await this.initializeSigningClient();
|
|
@@ -61583,26 +61725,30 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61583
61725
|
}
|
|
61584
61726
|
const [account] = await this.wallet.getAccounts();
|
|
61585
61727
|
const player = account.address;
|
|
61586
|
-
// Same msg shape as performAction — only
|
|
61587
|
-
const msgPerformAction = {
|
|
61588
|
-
player,
|
|
61589
|
-
gameId,
|
|
61590
|
-
action,
|
|
61591
|
-
amount: Long.fromString(amount.toString(), true),
|
|
61592
|
-
data: data || ""
|
|
61593
|
-
};
|
|
61728
|
+
// Same msg shape as performAction — only signing + broadcast mode differ.
|
|
61594
61729
|
const msg = {
|
|
61595
61730
|
typeUrl: "/pokerchain.poker.v1.MsgPerformAction",
|
|
61596
|
-
value:
|
|
61731
|
+
value: {
|
|
61732
|
+
player,
|
|
61733
|
+
gameId,
|
|
61734
|
+
action,
|
|
61735
|
+
amount: Long.fromString(amount.toString(), true),
|
|
61736
|
+
data: data || ""
|
|
61737
|
+
}
|
|
61597
61738
|
};
|
|
61598
|
-
const fee = gaslessFee();
|
|
61599
|
-
const memo = `Poker action (sync): ${action}`;
|
|
61600
61739
|
try {
|
|
61601
|
-
//
|
|
61602
|
-
//
|
|
61740
|
+
// UNORDERED (#2619): gameplay txs carry no account sequence. Sync
|
|
61741
|
+
// broadcast returns at CheckTx, not at commit, so an ordered tx
|
|
61742
|
+
// signed before the previous one commits re-reads the same
|
|
61743
|
+
// committed sequence and is rejected with code 32 — blind + deal +
|
|
61744
|
+
// action from one account inside a block did exactly that. This is
|
|
61745
|
+
// the chain-direct twin of signPerformAction's fix (#247, ui#520).
|
|
61746
|
+
const { base64 } = await this.signUnordered(msg);
|
|
61747
|
+
// broadcastTxSync returns just the txhash, no DeliverTx result, and
|
|
61748
|
+
// throws BroadcastTxError when CheckTx rejects — the same contract
|
|
61749
|
+
// signAndBroadcastSync had. The caller waits on the WS push for the
|
|
61603
61750
|
// authoritative outcome.
|
|
61604
|
-
|
|
61605
|
-
return txHash;
|
|
61751
|
+
return await this.signingClient.broadcastTxSync(fromBase64(base64));
|
|
61606
61752
|
}
|
|
61607
61753
|
catch (error) {
|
|
61608
61754
|
console.error("❌ Action (sync) failed at CheckTx:", error);
|
|
@@ -61712,8 +61858,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61712
61858
|
const player = account.address;
|
|
61713
61859
|
// account_number + chainId are still needed for the sign doc; the
|
|
61714
61860
|
// SEQUENCE is not — unordered txs must sign with sequence 0.
|
|
61715
|
-
const
|
|
61716
|
-
const accountNumber = Number(accountInfo.account.account_number);
|
|
61861
|
+
const accountNumber = await this.unorderedAccountNumber(player);
|
|
61717
61862
|
const chainId = this.config.chainId;
|
|
61718
61863
|
// Body with unordered=true + timeout_timestamp, messages packed as Any
|
|
61719
61864
|
// via the poker registry. timeoutHeight stays 0 (we gate on timestamp).
|
|
@@ -61722,7 +61867,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61722
61867
|
memo: "",
|
|
61723
61868
|
timeoutHeight: Long.UZERO,
|
|
61724
61869
|
unordered: true,
|
|
61725
|
-
timeoutTimestamp: new Date(
|
|
61870
|
+
timeoutTimestamp: new Date(nextUnorderedTimeoutMs(player, ttlSeconds))
|
|
61726
61871
|
})).finish();
|
|
61727
61872
|
// AuthInfo with sequence 0 (required for unordered). CosmJS builds this
|
|
61728
61873
|
// — the pubkey/fee encoding is unchanged from an ordered tx.
|
|
@@ -61738,6 +61883,22 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61738
61883
|
})).finish());
|
|
61739
61884
|
return { base64, accountNumber };
|
|
61740
61885
|
}
|
|
61886
|
+
/**
|
|
61887
|
+
* account_number for the unordered sign doc. It is assigned once when the
|
|
61888
|
+
* account is created and never changes, so look it up once per signer —
|
|
61889
|
+
* performActionSync signs on every player action and shouldn't pay a REST
|
|
61890
|
+
* round trip (or inherit its failure modes) each time.
|
|
61891
|
+
*/
|
|
61892
|
+
async unorderedAccountNumber(player) {
|
|
61893
|
+
const cached = this.accountNumbers.get(player);
|
|
61894
|
+
if (cached !== undefined) {
|
|
61895
|
+
return cached;
|
|
61896
|
+
}
|
|
61897
|
+
const accountInfo = await this.getAccount(player);
|
|
61898
|
+
const accountNumber = Number(accountInfo.account.account_number);
|
|
61899
|
+
this.accountNumbers.set(player, accountNumber);
|
|
61900
|
+
return accountNumber;
|
|
61901
|
+
}
|
|
61741
61902
|
/**
|
|
61742
61903
|
* Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
|
|
61743
61904
|
* broadcasting, returning the base64 TxRaw for the gateway to relay
|
|
@@ -61836,6 +61997,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61836
61997
|
});
|
|
61837
61998
|
try {
|
|
61838
61999
|
const result = await this.signingClient.signAndBroadcast(player, [msg], fee, memo);
|
|
62000
|
+
assertExecuted("top up", result);
|
|
61839
62001
|
console.log("✅ Top-up transaction successful:", result.transactionHash);
|
|
61840
62002
|
return result.transactionHash;
|
|
61841
62003
|
}
|
|
@@ -61873,6 +62035,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61873
62035
|
});
|
|
61874
62036
|
try {
|
|
61875
62037
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
62038
|
+
assertExecuted("process deposit", result);
|
|
61876
62039
|
console.log("✅ Process deposit transaction successful:", result.transactionHash);
|
|
61877
62040
|
return result.transactionHash;
|
|
61878
62041
|
}
|
|
@@ -61912,6 +62075,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61912
62075
|
});
|
|
61913
62076
|
try {
|
|
61914
62077
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
62078
|
+
assertExecuted("initiate withdrawal", result);
|
|
61915
62079
|
console.log("✅ Withdrawal initiation successful:", result.transactionHash);
|
|
61916
62080
|
return result.transactionHash;
|
|
61917
62081
|
}
|
|
@@ -61948,6 +62112,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61948
62112
|
});
|
|
61949
62113
|
try {
|
|
61950
62114
|
const result = await this.signingClient.signAndBroadcast(signer, [msg], fee, memo);
|
|
62115
|
+
assertExecuted("sign withdrawal", result);
|
|
61951
62116
|
console.log("✅ Withdrawal signing successful:", result.transactionHash);
|
|
61952
62117
|
return result.transactionHash;
|
|
61953
62118
|
}
|
|
@@ -62028,6 +62193,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
62028
62193
|
});
|
|
62029
62194
|
try {
|
|
62030
62195
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
62196
|
+
assertExecuted("register NFT avatar", result);
|
|
62031
62197
|
console.log("✅ NFT avatar registration successful:", result.transactionHash);
|
|
62032
62198
|
return result.transactionHash;
|
|
62033
62199
|
}
|
|
@@ -62209,5 +62375,5 @@ const registry = new Registry([
|
|
|
62209
62375
|
...msgTypes,
|
|
62210
62376
|
]);
|
|
62211
62377
|
|
|
62212
|
-
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, ValidatorBond, WithdrawalRequest, createSigningClientFromMnemonic, createWalletFromMnemonic, formatGameFormatDisplay, formatGameVariantDisplay, generateWallet, getActionByType, getAddressFromMnemonic, getDefaultCosmosConfig, getGameFormat, getGameFormatForCosmos, getGameFormatFromObject, getGameVariant, hasAction, isCashFormat, isEmptyAddress, isSitAndGoFormat, isTournamentFormat, isValidMnemonic, isValidPlayerAddress, parseGameFormat, parseGameVariant, registry };
|
|
62378
|
+
export { AllPlayerActions, BLOCK52_HD_PATH, Board, COSMOS_CONSTANTS, Client, CosmosClient, Deck, GAME_NAME_MICRO_PER_CHAR, GameFormat, GameStatus, GameVariant, HandType, KEYS, MAX_GAME_NAME_LENGTH, 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, assertExecuted, computeGameNameFee, createSigningClientFromMnemonic, createWalletFromMnemonic, formatGameFormatDisplay, formatGameVariantDisplay, generateWallet, getActionByType, getAddressFromMnemonic, getDefaultCosmosConfig, getGameFormat, getGameFormatForCosmos, getGameFormatFromObject, getGameVariant, hasAction, isCashFormat, isEmptyAddress, isSitAndGoFormat, isTournamentFormat, isValidMnemonic, isValidPlayerAddress, parseGameFormat, parseGameVariant, registry, txFailureHash, txFailurePhase };
|
|
62213
62379
|
//# sourceMappingURL=index.esm.js.map
|