@block52/poker-vm-sdk 1.16.0 → 1.19.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/IClient.d.ts +8 -5
- package/dist/IClient.d.ts.map +1 -1
- package/dist/cosmosClient.d.ts +19 -7
- package/dist/cosmosClient.d.ts.map +1 -1
- package/dist/index.d.ts +219 -58
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +190 -101
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +192 -100
- package/dist/index.js.map +1 -1
- package/dist/pokerchain.poker.v1/registry.d.ts.map +1 -1
- package/dist/sdkTypes.d.ts +2 -29
- package/dist/sdkTypes.d.ts.map +1 -1
- package/dist/signingClient.d.ts +11 -12
- package/dist/signingClient.d.ts.map +1 -1
- package/dist/types/game.d.ts +52 -2
- package/dist/types/game.d.ts.map +1 -1
- package/dist/types/rest.d.ts +97 -0
- package/dist/types/rest.d.ts.map +1 -0
- package/dist/types.d.ts +2 -29
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/tournamentLeaderboard.d.ts +9 -0
- package/dist/utils/tournamentLeaderboard.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -4471,24 +4471,33 @@ function isSet$2b(value) {
|
|
|
4471
4471
|
return value !== null && value !== undefined;
|
|
4472
4472
|
}
|
|
4473
4473
|
|
|
4474
|
-
|
|
4474
|
+
/**
|
|
4475
|
+
* Adapts a ts-proto MessageFns to cosmjs's GeneratedType (poker-vm#1939).
|
|
4476
|
+
* cosmjs types its writer as protobufjs's Writer class; ours is @bufbuild's
|
|
4477
|
+
* BinaryWriter, a different class with the same contract. The Registry only
|
|
4478
|
+
* calls fromPartial, encode(...).finish() and decode(bytes), all of which
|
|
4479
|
+
* MessageFns provides, so this is the one place that bridges the two. Both
|
|
4480
|
+
* writer types are classes with private members, so no structural adapter can
|
|
4481
|
+
* satisfy GeneratedType without this cast.
|
|
4482
|
+
*/
|
|
4483
|
+
const asGeneratedType = (fns) => fns;
|
|
4475
4484
|
const msgTypes$u = [
|
|
4476
|
-
["/pokerchain.poker.v1.MsgUpdateParams", MsgUpdateParams$d],
|
|
4477
|
-
["/pokerchain.poker.v1.MsgCreateGame", MsgCreateGame],
|
|
4478
|
-
["/pokerchain.poker.v1.MsgJoinGame", MsgJoinGame],
|
|
4479
|
-
["/pokerchain.poker.v1.MsgLeaveGame", MsgLeaveGame],
|
|
4480
|
-
["/pokerchain.poker.v1.MsgRecordHandEnd", MsgRecordHandEnd],
|
|
4481
|
-
["/pokerchain.poker.v1.MsgDealCards", MsgDealCards],
|
|
4482
|
-
["/pokerchain.poker.v1.MsgPerformAction", MsgPerformAction],
|
|
4483
|
-
["/pokerchain.poker.v1.MsgMint", MsgMint],
|
|
4484
|
-
["/pokerchain.poker.v1.MsgBurn", MsgBurn],
|
|
4485
|
-
["/pokerchain.poker.v1.MsgProcessDeposit", MsgProcessDeposit],
|
|
4486
|
-
["/pokerchain.poker.v1.MsgInitiateWithdrawal", MsgInitiateWithdrawal],
|
|
4487
|
-
["/pokerchain.poker.v1.MsgUpdateEthBlockHeight", MsgUpdateEthBlockHeight],
|
|
4488
|
-
["/pokerchain.poker.v1.MsgTopUp", MsgTopUp],
|
|
4489
|
-
["/pokerchain.poker.v1.MsgDeleteGame", MsgDeleteGame],
|
|
4490
|
-
["/pokerchain.poker.v1.MsgForceCloseGame", MsgForceCloseGame],
|
|
4491
|
-
["/pokerchain.poker.v1.MsgRegisterNftAvatar", MsgRegisterNftAvatar],
|
|
4485
|
+
["/pokerchain.poker.v1.MsgUpdateParams", asGeneratedType(MsgUpdateParams$d)],
|
|
4486
|
+
["/pokerchain.poker.v1.MsgCreateGame", asGeneratedType(MsgCreateGame)],
|
|
4487
|
+
["/pokerchain.poker.v1.MsgJoinGame", asGeneratedType(MsgJoinGame)],
|
|
4488
|
+
["/pokerchain.poker.v1.MsgLeaveGame", asGeneratedType(MsgLeaveGame)],
|
|
4489
|
+
["/pokerchain.poker.v1.MsgRecordHandEnd", asGeneratedType(MsgRecordHandEnd)],
|
|
4490
|
+
["/pokerchain.poker.v1.MsgDealCards", asGeneratedType(MsgDealCards)],
|
|
4491
|
+
["/pokerchain.poker.v1.MsgPerformAction", asGeneratedType(MsgPerformAction)],
|
|
4492
|
+
["/pokerchain.poker.v1.MsgMint", asGeneratedType(MsgMint)],
|
|
4493
|
+
["/pokerchain.poker.v1.MsgBurn", asGeneratedType(MsgBurn)],
|
|
4494
|
+
["/pokerchain.poker.v1.MsgProcessDeposit", asGeneratedType(MsgProcessDeposit)],
|
|
4495
|
+
["/pokerchain.poker.v1.MsgInitiateWithdrawal", asGeneratedType(MsgInitiateWithdrawal)],
|
|
4496
|
+
["/pokerchain.poker.v1.MsgUpdateEthBlockHeight", asGeneratedType(MsgUpdateEthBlockHeight)],
|
|
4497
|
+
["/pokerchain.poker.v1.MsgTopUp", asGeneratedType(MsgTopUp)],
|
|
4498
|
+
["/pokerchain.poker.v1.MsgDeleteGame", asGeneratedType(MsgDeleteGame)],
|
|
4499
|
+
["/pokerchain.poker.v1.MsgForceCloseGame", asGeneratedType(MsgForceCloseGame)],
|
|
4500
|
+
["/pokerchain.poker.v1.MsgRegisterNftAvatar", asGeneratedType(MsgRegisterNftAvatar)],
|
|
4492
4501
|
];
|
|
4493
4502
|
|
|
4494
4503
|
/**
|
|
@@ -56125,6 +56134,9 @@ var NonPlayerActionType;
|
|
|
56125
56134
|
// player's bet (they're matched) but excluded from the first-to-act /
|
|
56126
56135
|
// has-acted scans (it's a non-player action, like DEAD_SMALL_BLIND).
|
|
56127
56136
|
NonPlayerActionType["POST"] = "post";
|
|
56137
|
+
// A missed small blind posted dead on sitting back in (poker-vm#2200).
|
|
56138
|
+
// Recorded in ANTE; in the pot but not a bet anyone must match (like ANTE).
|
|
56139
|
+
NonPlayerActionType["POST_DEAD"] = "post-dead";
|
|
56128
56140
|
NonPlayerActionType["SIT_IN"] = "sit-in";
|
|
56129
56141
|
// Sit in and wait for the big blind — distinct action from SIT_IN (post now)
|
|
56130
56142
|
// so each has a single responsibility. Sets WAITING_FOR_BIG_BLIND. (#2139)
|
|
@@ -56138,12 +56150,13 @@ var NonPlayerActionType;
|
|
|
56138
56150
|
// SHOW at showdown — and records THAT action; no "timeout" turn is ever
|
|
56139
56151
|
// written to previousActions. Rejected while the turn has time remaining.
|
|
56140
56152
|
NonPlayerActionType["TIMEOUT"] = "timeout";
|
|
56141
|
-
// Time bank (ui#19): the player to act extends their turn's action-clock
|
|
56142
|
-
// deadline by
|
|
56143
|
-
//
|
|
56144
|
-
// Records a no-chip turn that does NOT advance the
|
|
56145
|
-
// clock anchor; the deadline
|
|
56146
|
-
// current turn. Rejected off-turn,
|
|
56153
|
+
// Time bank (ui#19/#20): the player to act extends their turn's action-clock
|
|
56154
|
+
// deadline by their whole bank, once per decision: gameOptions.timeBankMs
|
|
56155
|
+
// the first time, 30s the second, then 5s refilling 5s per orbit up to
|
|
56156
|
+
// gameOptions.timeBankCapMs. Records a no-chip turn that does NOT advance the
|
|
56157
|
+
// betting order or move the clock anchor; the deadline adds the user's
|
|
56158
|
+
// PlayerDTO.timeBankLastGrantMs for the current turn. Rejected off-turn,
|
|
56159
|
+
// past the deadline, or with no bank left.
|
|
56147
56160
|
NonPlayerActionType["TIME_BANK"] = "time-bank";
|
|
56148
56161
|
NonPlayerActionType["TOP_UP"] = "top-up";
|
|
56149
56162
|
// Scheduled single-table tournament (poker-vm#2680): any registered player
|
|
@@ -56234,6 +56247,8 @@ const BLIND_PRESETS = ["turbo", "standard", "deep_stack", "hyper_turbo"];
|
|
|
56234
56247
|
const BLIND_PROGRESSIONS = ["double", "linear", "percentage", "table"];
|
|
56235
56248
|
const SIT_OUT_METHOD_NEXT_HAND = "next-hand";
|
|
56236
56249
|
const SIT_OUT_METHOD_NEXT_BB = "next-bb";
|
|
56250
|
+
const TOURNAMENT_STATUSES = ["registering", "running", "finished", "cancelled"];
|
|
56251
|
+
const TOURNAMENT_ENTRANT_STATUSES = ["registered", "playing", "busted", "unregistered"];
|
|
56237
56252
|
var SUIT;
|
|
56238
56253
|
(function (SUIT) {
|
|
56239
56254
|
SUIT[SUIT["CLUBS"] = 1] = "CLUBS";
|
|
@@ -57154,6 +57169,91 @@ function levelMinutes(options) {
|
|
|
57154
57169
|
return options.blindLevelDuration;
|
|
57155
57170
|
}
|
|
57156
57171
|
|
|
57172
|
+
/**
|
|
57173
|
+
* Parses the `leaderboard` JSON string of the chain's TournamentLeaderboard
|
|
57174
|
+
* query (block52/pokerchain#405, poker-vm#2613) into a LeaderboardDTO. Checks
|
|
57175
|
+
* the required fields and throws on anything missing or mistyped — never fills
|
|
57176
|
+
* a default (Commandment 7): a malformed board is a chain/engine bug to surface.
|
|
57177
|
+
*/
|
|
57178
|
+
function parseLeaderboardDTO(json) {
|
|
57179
|
+
if (json === "") {
|
|
57180
|
+
throw new Error("tournament leaderboard: empty leaderboard JSON");
|
|
57181
|
+
}
|
|
57182
|
+
const raw = JSON.parse(json);
|
|
57183
|
+
if (!isRecord(raw)) {
|
|
57184
|
+
throw new Error("tournament leaderboard: expected a JSON object");
|
|
57185
|
+
}
|
|
57186
|
+
requireString(raw, "tournamentId", "leaderboard");
|
|
57187
|
+
requireStatus(raw, "leaderboard");
|
|
57188
|
+
requireNumber(raw, "entrants", "leaderboard");
|
|
57189
|
+
requireNumber(raw, "remaining", "leaderboard");
|
|
57190
|
+
requireString(raw, "averageStack", "leaderboard");
|
|
57191
|
+
requireString(raw, "prizePool", "leaderboard");
|
|
57192
|
+
if (!Array.isArray(raw.payouts)) {
|
|
57193
|
+
throw new Error("tournament leaderboard: payouts must be an array");
|
|
57194
|
+
}
|
|
57195
|
+
raw.payouts.forEach((p, i) => {
|
|
57196
|
+
const where = `payouts[${i}]`;
|
|
57197
|
+
if (!isRecord(p))
|
|
57198
|
+
throw new Error(`tournament leaderboard: ${where} must be an object`);
|
|
57199
|
+
requireNumber(p, "place", where);
|
|
57200
|
+
requireString(p, "amount", where);
|
|
57201
|
+
});
|
|
57202
|
+
if (raw.clock !== undefined) {
|
|
57203
|
+
if (!isRecord(raw.clock))
|
|
57204
|
+
throw new Error("tournament leaderboard: clock must be an object");
|
|
57205
|
+
requireNumber(raw.clock, "level", "clock");
|
|
57206
|
+
requireString(raw.clock, "smallBlind", "clock");
|
|
57207
|
+
requireString(raw.clock, "bigBlind", "clock");
|
|
57208
|
+
requireString(raw.clock, "ante", "clock");
|
|
57209
|
+
optionalNumber(raw.clock, "levelStartTime", "clock");
|
|
57210
|
+
}
|
|
57211
|
+
optionalNumber(raw, "nextLevelAt", "leaderboard");
|
|
57212
|
+
if (!Array.isArray(raw.entries)) {
|
|
57213
|
+
throw new Error("tournament leaderboard: entries must be an array");
|
|
57214
|
+
}
|
|
57215
|
+
raw.entries.forEach((e, i) => requireEntry(e, `entries[${i}]`));
|
|
57216
|
+
return raw;
|
|
57217
|
+
}
|
|
57218
|
+
function requireEntry(e, where) {
|
|
57219
|
+
if (!isRecord(e))
|
|
57220
|
+
throw new Error(`tournament leaderboard: ${where} must be an object`);
|
|
57221
|
+
requireNumber(e, "rank", where);
|
|
57222
|
+
requireString(e, "address", where);
|
|
57223
|
+
if (!TOURNAMENT_ENTRANT_STATUSES.includes(e.status)) {
|
|
57224
|
+
throw new Error(`tournament leaderboard: ${where}.status "${String(e.status)}" is not an entrant status`);
|
|
57225
|
+
}
|
|
57226
|
+
requireString(e, "stack", where);
|
|
57227
|
+
optionalString(e, "tableId", where);
|
|
57228
|
+
optionalNumber(e, "seat", where);
|
|
57229
|
+
optionalNumber(e, "place", where);
|
|
57230
|
+
optionalString(e, "payout", where);
|
|
57231
|
+
}
|
|
57232
|
+
function requireStatus(o, where) {
|
|
57233
|
+
if (!TOURNAMENT_STATUSES.includes(o.status)) {
|
|
57234
|
+
throw new Error(`tournament leaderboard: ${where}.status "${String(o.status)}" is not a tournament status`);
|
|
57235
|
+
}
|
|
57236
|
+
}
|
|
57237
|
+
function isRecord(v) {
|
|
57238
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
57239
|
+
}
|
|
57240
|
+
function requireString(o, key, where) {
|
|
57241
|
+
if (typeof o[key] !== "string")
|
|
57242
|
+
throw new Error(`tournament leaderboard: ${where}.${key} must be a string`);
|
|
57243
|
+
}
|
|
57244
|
+
function requireNumber(o, key, where) {
|
|
57245
|
+
if (typeof o[key] !== "number")
|
|
57246
|
+
throw new Error(`tournament leaderboard: ${where}.${key} must be a number`);
|
|
57247
|
+
}
|
|
57248
|
+
function optionalString(o, key, where) {
|
|
57249
|
+
if (o[key] !== undefined)
|
|
57250
|
+
requireString(o, key, where);
|
|
57251
|
+
}
|
|
57252
|
+
function optionalNumber(o, key, where) {
|
|
57253
|
+
if (o[key] !== undefined)
|
|
57254
|
+
requireNumber(o, key, where);
|
|
57255
|
+
}
|
|
57256
|
+
|
|
57157
57257
|
/**
|
|
57158
57258
|
* Poker hand types in order of strength (weakest to strongest)
|
|
57159
57259
|
*/
|
|
@@ -58597,10 +58697,10 @@ class CosmosClient {
|
|
|
58597
58697
|
async getGameState(gameId) {
|
|
58598
58698
|
try {
|
|
58599
58699
|
const response = await this.restClient.get(`/block52/pokerchain/poker/v1/game_state/${gameId}`);
|
|
58600
|
-
if (response.data) {
|
|
58601
|
-
|
|
58700
|
+
if (!response.data) {
|
|
58701
|
+
throw new Error(`Empty game state response for ${gameId}`);
|
|
58602
58702
|
}
|
|
58603
|
-
return
|
|
58703
|
+
return response.data;
|
|
58604
58704
|
}
|
|
58605
58705
|
catch (error) {
|
|
58606
58706
|
console.error("Error fetching game state:", error);
|
|
@@ -58613,10 +58713,10 @@ class CosmosClient {
|
|
|
58613
58713
|
async getGame(gameId) {
|
|
58614
58714
|
try {
|
|
58615
58715
|
const response = await this.restClient.get(`/block52/pokerchain/poker/v1/game/${gameId}`);
|
|
58616
|
-
if (response.data) {
|
|
58617
|
-
|
|
58716
|
+
if (!response.data) {
|
|
58717
|
+
throw new Error(`Empty game response for ${gameId}`);
|
|
58618
58718
|
}
|
|
58619
|
-
return
|
|
58719
|
+
return response.data;
|
|
58620
58720
|
}
|
|
58621
58721
|
catch (error) {
|
|
58622
58722
|
console.error("Error fetching game:", error);
|
|
@@ -58663,9 +58763,11 @@ class CosmosClient {
|
|
|
58663
58763
|
}
|
|
58664
58764
|
catch (error) {
|
|
58665
58765
|
console.error("❌ [CosmosClient] Error listing games:");
|
|
58666
|
-
|
|
58667
|
-
|
|
58668
|
-
|
|
58766
|
+
if (axios.isAxiosError(error)) {
|
|
58767
|
+
console.error(" Message:", error.message);
|
|
58768
|
+
console.error(" Response status:", error.response?.status);
|
|
58769
|
+
console.error(" Response data:", error.response?.data);
|
|
58770
|
+
}
|
|
58669
58771
|
console.error(" Full error:", error);
|
|
58670
58772
|
throw error;
|
|
58671
58773
|
}
|
|
@@ -58771,9 +58873,10 @@ class CosmosClient {
|
|
|
58771
58873
|
*/
|
|
58772
58874
|
async listWithdrawalRequests(cosmosAddress) {
|
|
58773
58875
|
try {
|
|
58876
|
+
// The chain serves withdrawal_requests; list_withdrawal_requests is a 501 (poker-vm#1939).
|
|
58774
58877
|
const url = cosmosAddress
|
|
58775
|
-
? `/block52/pokerchain/poker/v1/
|
|
58776
|
-
: `/block52/pokerchain/poker/v1/
|
|
58878
|
+
? `/block52/pokerchain/poker/v1/withdrawal_requests?cosmos_address=${encodeURIComponent(cosmosAddress)}`
|
|
58879
|
+
: `/block52/pokerchain/poker/v1/withdrawal_requests`;
|
|
58777
58880
|
const response = await this.restClient.get(url);
|
|
58778
58881
|
return response.data.withdrawal_requests || [];
|
|
58779
58882
|
}
|
|
@@ -58782,6 +58885,35 @@ class CosmosClient {
|
|
|
58782
58885
|
return [];
|
|
58783
58886
|
}
|
|
58784
58887
|
}
|
|
58888
|
+
/**
|
|
58889
|
+
* A multi-table tournament's live standings (block52/pokerchain#405,
|
|
58890
|
+
* poker-vm#2613), ranked by the engine: the chain runs engine.Leaderboard
|
|
58891
|
+
* over the stored tournament state and serves the LeaderboardDTO verbatim.
|
|
58892
|
+
* Unauthenticated: standings are public.
|
|
58893
|
+
*
|
|
58894
|
+
* @returns the board, or null when the chain has no tournament with this ID
|
|
58895
|
+
* (gRPC NotFound, HTTP 404). Any other failure — including an empty or
|
|
58896
|
+
* malformed leaderboard — throws.
|
|
58897
|
+
*/
|
|
58898
|
+
async getTournamentLeaderboard(tournamentId) {
|
|
58899
|
+
if (tournamentId === "") {
|
|
58900
|
+
throw new Error("tournamentId is required");
|
|
58901
|
+
}
|
|
58902
|
+
try {
|
|
58903
|
+
const response = await this.restClient.get(`/block52/pokerchain/poker/v1/tournament_leaderboard/${encodeURIComponent(tournamentId)}`);
|
|
58904
|
+
if (!response.data || typeof response.data.leaderboard !== "string") {
|
|
58905
|
+
throw new Error(`Empty tournament leaderboard response for ${tournamentId}`);
|
|
58906
|
+
}
|
|
58907
|
+
return parseLeaderboardDTO(response.data.leaderboard);
|
|
58908
|
+
}
|
|
58909
|
+
catch (error) {
|
|
58910
|
+
if (isGrpcNotFound(error)) {
|
|
58911
|
+
return null;
|
|
58912
|
+
}
|
|
58913
|
+
console.error("Error fetching tournament leaderboard:", error);
|
|
58914
|
+
throw error;
|
|
58915
|
+
}
|
|
58916
|
+
}
|
|
58785
58917
|
/**
|
|
58786
58918
|
* Calculate equity for multiple hands using Monte Carlo simulation
|
|
58787
58919
|
* Used when players are all-in and showing to display win percentages
|
|
@@ -58852,6 +58984,19 @@ const getDefaultCosmosConfig = (domain = "localhost") => ({
|
|
|
58852
58984
|
denom: "stake", // Use stake as the denomination (lowercase, as stored on blockchain)
|
|
58853
58985
|
gasPrice: "0.0stake" // Gas price in stake (not used in REST-only mode)
|
|
58854
58986
|
});
|
|
58987
|
+
/** gRPC code NOT_FOUND as grpc-gateway reports it in an error body. */
|
|
58988
|
+
const GRPC_NOT_FOUND = 5;
|
|
58989
|
+
/**
|
|
58990
|
+
* True for a grpc-gateway NotFound reply: HTTP 404 whose body carries gRPC code
|
|
58991
|
+
* 5. An unknown route (an older chain without the query) is a 501, not this.
|
|
58992
|
+
*/
|
|
58993
|
+
function isGrpcNotFound(error) {
|
|
58994
|
+
if (!axios.isAxiosError(error) || error.response?.status !== 404) {
|
|
58995
|
+
return false;
|
|
58996
|
+
}
|
|
58997
|
+
const body = error.response.data;
|
|
58998
|
+
return typeof body === "object" && body !== null && body.code === GRPC_NOT_FOUND;
|
|
58999
|
+
}
|
|
58855
59000
|
|
|
58856
59001
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
58857
59002
|
|
|
@@ -71806,7 +71951,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71806
71951
|
if (!denom) {
|
|
71807
71952
|
denom = this.config.denom;
|
|
71808
71953
|
}
|
|
71809
|
-
const coins = [{ denom
|
|
71954
|
+
const coins = [{ denom, amount: amount.toString() }];
|
|
71810
71955
|
const fee = gaslessFee();
|
|
71811
71956
|
const result = await this.signingClient.sendTokens(fromAddress, toAddress, coins, fee, memo || "");
|
|
71812
71957
|
assertExecuted("send tokens", result);
|
|
@@ -72658,84 +72803,28 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
72658
72803
|
}
|
|
72659
72804
|
}
|
|
72660
72805
|
/**
|
|
72661
|
-
*
|
|
72662
|
-
*
|
|
72663
|
-
*/
|
|
72664
|
-
async getNextActionIndex(gameId) {
|
|
72665
|
-
try {
|
|
72666
|
-
const gameState = await this.queryGameState(gameId);
|
|
72667
|
-
if (!gameState) {
|
|
72668
|
-
throw new Error("Game state not found");
|
|
72669
|
-
}
|
|
72670
|
-
let nextIndex;
|
|
72671
|
-
// Match original client logic exactly
|
|
72672
|
-
if (!gameState.previousActions || gameState.previousActions.length === 0) {
|
|
72673
|
-
nextIndex = gameState.actionCount + 1;
|
|
72674
|
-
console.log("📊 Action Index Calculation:", {
|
|
72675
|
-
gameId: gameId.substring(0, 20) + "...",
|
|
72676
|
-
method: "actionCount + 1",
|
|
72677
|
-
actionCount: gameState.actionCount,
|
|
72678
|
-
nextIndex,
|
|
72679
|
-
previousActionsLength: 0
|
|
72680
|
-
});
|
|
72681
|
-
}
|
|
72682
|
-
else {
|
|
72683
|
-
const lastAction = gameState.previousActions[gameState.previousActions.length - 1];
|
|
72684
|
-
nextIndex = lastAction.index + 1;
|
|
72685
|
-
console.log("📊 Action Index Calculation:", {
|
|
72686
|
-
gameId: gameId.substring(0, 20) + "...",
|
|
72687
|
-
method: "lastAction.index + 1",
|
|
72688
|
-
lastActionIndex: lastAction.index,
|
|
72689
|
-
nextIndex,
|
|
72690
|
-
previousActionsLength: gameState.previousActions.length,
|
|
72691
|
-
lastAction: {
|
|
72692
|
-
action: lastAction.action,
|
|
72693
|
-
player: lastAction.playerId?.substring(0, 10) + "...",
|
|
72694
|
-
round: lastAction.round
|
|
72695
|
-
}
|
|
72696
|
-
});
|
|
72697
|
-
}
|
|
72698
|
-
return nextIndex;
|
|
72699
|
-
}
|
|
72700
|
-
catch (error) {
|
|
72701
|
-
console.error(`Error getting next action index: ${error.message}`);
|
|
72702
|
-
throw error; // Rethrow to be handled by caller
|
|
72703
|
-
}
|
|
72704
|
-
}
|
|
72705
|
-
/**
|
|
72706
|
-
* Query all games from the blockchain
|
|
72806
|
+
* Query all games from the blockchain.
|
|
72807
|
+
* Same as listGames(); the old /pokerchain/poker/v1/games path is a 501 (poker-vm#1939).
|
|
72707
72808
|
*/
|
|
72708
72809
|
async queryGames() {
|
|
72709
|
-
|
|
72710
|
-
const response = await fetch(`${this.config.restEndpoint}/pokerchain/poker/v1/games`);
|
|
72711
|
-
if (!response.ok) {
|
|
72712
|
-
throw new Error(`Failed to query games: ${response.statusText}`);
|
|
72713
|
-
}
|
|
72714
|
-
const data = await response.json();
|
|
72715
|
-
// The response has games as a JSON string, need to parse it
|
|
72716
|
-
if (data.games) {
|
|
72717
|
-
return JSON.parse(data.games);
|
|
72718
|
-
}
|
|
72719
|
-
return [];
|
|
72720
|
-
}
|
|
72721
|
-
catch (error) {
|
|
72722
|
-
console.error("❌ queryGames() failed:", error);
|
|
72723
|
-
throw error;
|
|
72724
|
-
}
|
|
72810
|
+
return this.listGames();
|
|
72725
72811
|
}
|
|
72726
72812
|
/**
|
|
72727
|
-
* Query game state for a
|
|
72813
|
+
* Query the public game state for a game (hole cards masked), or null when the
|
|
72814
|
+
* chain has none. Uses game_state_public: the game_state query needs a signed
|
|
72815
|
+
* player address (poker-vm#1939).
|
|
72728
72816
|
*/
|
|
72729
72817
|
async queryGameState(gameId) {
|
|
72730
72818
|
try {
|
|
72731
|
-
const response = await fetch(`${this.config.restEndpoint}/block52/pokerchain/poker/v1/
|
|
72819
|
+
const response = await fetch(`${this.config.restEndpoint}/block52/pokerchain/poker/v1/game_state_public/${encodeURIComponent(gameId)}`);
|
|
72732
72820
|
if (!response.ok) {
|
|
72733
72821
|
throw new Error(`Failed to query game state: ${response.statusText}`);
|
|
72734
72822
|
}
|
|
72735
72823
|
const data = await response.json();
|
|
72736
72824
|
// The response has game_state as a JSON string, need to parse it
|
|
72737
72825
|
if (data.game_state) {
|
|
72738
|
-
|
|
72826
|
+
const state = JSON.parse(data.game_state);
|
|
72827
|
+
return state;
|
|
72739
72828
|
}
|
|
72740
72829
|
return null;
|
|
72741
72830
|
}
|
|
@@ -72849,5 +72938,5 @@ const registry = new Registry([
|
|
|
72849
72938
|
...msgTypes,
|
|
72850
72939
|
]);
|
|
72851
72940
|
|
|
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 };
|
|
72941
|
+
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, TOURNAMENT_ENTRANT_STATUSES, TOURNAMENT_STATUSES, 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, parseLeaderboardDTO, registry, resolveBlindPreset, roundBlind, toValoperAddress, txFailureHash, txFailurePhase };
|
|
72853
72942
|
//# sourceMappingURL=index.esm.js.map
|