@block52/poker-vm-sdk 1.17.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 +2 -1
- package/dist/IClient.d.ts.map +1 -1
- package/dist/cosmosClient.d.ts +12 -1
- package/dist/cosmosClient.d.ts.map +1 -1
- package/dist/index.d.ts +72 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +140 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +142 -6
- package/dist/index.js.map +1 -1
- package/dist/types/game.d.ts +50 -0
- package/dist/types/game.d.ts.map +1 -1
- package/dist/types/rest.d.ts +8 -0
- package/dist/types/rest.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.js
CHANGED
|
@@ -56136,6 +56136,9 @@ exports.NonPlayerActionType = void 0;
|
|
|
56136
56136
|
// player's bet (they're matched) but excluded from the first-to-act /
|
|
56137
56137
|
// has-acted scans (it's a non-player action, like DEAD_SMALL_BLIND).
|
|
56138
56138
|
NonPlayerActionType["POST"] = "post";
|
|
56139
|
+
// A missed small blind posted dead on sitting back in (poker-vm#2200).
|
|
56140
|
+
// Recorded in ANTE; in the pot but not a bet anyone must match (like ANTE).
|
|
56141
|
+
NonPlayerActionType["POST_DEAD"] = "post-dead";
|
|
56139
56142
|
NonPlayerActionType["SIT_IN"] = "sit-in";
|
|
56140
56143
|
// Sit in and wait for the big blind — distinct action from SIT_IN (post now)
|
|
56141
56144
|
// so each has a single responsibility. Sets WAITING_FOR_BIG_BLIND. (#2139)
|
|
@@ -56149,12 +56152,13 @@ exports.NonPlayerActionType = void 0;
|
|
|
56149
56152
|
// SHOW at showdown — and records THAT action; no "timeout" turn is ever
|
|
56150
56153
|
// written to previousActions. Rejected while the turn has time remaining.
|
|
56151
56154
|
NonPlayerActionType["TIMEOUT"] = "timeout";
|
|
56152
|
-
// Time bank (ui#19): the player to act extends their turn's action-clock
|
|
56153
|
-
// deadline by
|
|
56154
|
-
//
|
|
56155
|
-
// Records a no-chip turn that does NOT advance the
|
|
56156
|
-
// clock anchor; the deadline
|
|
56157
|
-
// current turn. Rejected off-turn,
|
|
56155
|
+
// Time bank (ui#19/#20): the player to act extends their turn's action-clock
|
|
56156
|
+
// deadline by their whole bank, once per decision: gameOptions.timeBankMs
|
|
56157
|
+
// the first time, 30s the second, then 5s refilling 5s per orbit up to
|
|
56158
|
+
// gameOptions.timeBankCapMs. Records a no-chip turn that does NOT advance the
|
|
56159
|
+
// betting order or move the clock anchor; the deadline adds the user's
|
|
56160
|
+
// PlayerDTO.timeBankLastGrantMs for the current turn. Rejected off-turn,
|
|
56161
|
+
// past the deadline, or with no bank left.
|
|
56158
56162
|
NonPlayerActionType["TIME_BANK"] = "time-bank";
|
|
56159
56163
|
NonPlayerActionType["TOP_UP"] = "top-up";
|
|
56160
56164
|
// Scheduled single-table tournament (poker-vm#2680): any registered player
|
|
@@ -56245,6 +56249,8 @@ const BLIND_PRESETS = ["turbo", "standard", "deep_stack", "hyper_turbo"];
|
|
|
56245
56249
|
const BLIND_PROGRESSIONS = ["double", "linear", "percentage", "table"];
|
|
56246
56250
|
const SIT_OUT_METHOD_NEXT_HAND = "next-hand";
|
|
56247
56251
|
const SIT_OUT_METHOD_NEXT_BB = "next-bb";
|
|
56252
|
+
const TOURNAMENT_STATUSES = ["registering", "running", "finished", "cancelled"];
|
|
56253
|
+
const TOURNAMENT_ENTRANT_STATUSES = ["registered", "playing", "busted", "unregistered"];
|
|
56248
56254
|
exports.SUIT = void 0;
|
|
56249
56255
|
(function (SUIT) {
|
|
56250
56256
|
SUIT[SUIT["CLUBS"] = 1] = "CLUBS";
|
|
@@ -57165,6 +57171,91 @@ function levelMinutes(options) {
|
|
|
57165
57171
|
return options.blindLevelDuration;
|
|
57166
57172
|
}
|
|
57167
57173
|
|
|
57174
|
+
/**
|
|
57175
|
+
* Parses the `leaderboard` JSON string of the chain's TournamentLeaderboard
|
|
57176
|
+
* query (block52/pokerchain#405, poker-vm#2613) into a LeaderboardDTO. Checks
|
|
57177
|
+
* the required fields and throws on anything missing or mistyped — never fills
|
|
57178
|
+
* a default (Commandment 7): a malformed board is a chain/engine bug to surface.
|
|
57179
|
+
*/
|
|
57180
|
+
function parseLeaderboardDTO(json) {
|
|
57181
|
+
if (json === "") {
|
|
57182
|
+
throw new Error("tournament leaderboard: empty leaderboard JSON");
|
|
57183
|
+
}
|
|
57184
|
+
const raw = JSON.parse(json);
|
|
57185
|
+
if (!isRecord(raw)) {
|
|
57186
|
+
throw new Error("tournament leaderboard: expected a JSON object");
|
|
57187
|
+
}
|
|
57188
|
+
requireString(raw, "tournamentId", "leaderboard");
|
|
57189
|
+
requireStatus(raw, "leaderboard");
|
|
57190
|
+
requireNumber(raw, "entrants", "leaderboard");
|
|
57191
|
+
requireNumber(raw, "remaining", "leaderboard");
|
|
57192
|
+
requireString(raw, "averageStack", "leaderboard");
|
|
57193
|
+
requireString(raw, "prizePool", "leaderboard");
|
|
57194
|
+
if (!Array.isArray(raw.payouts)) {
|
|
57195
|
+
throw new Error("tournament leaderboard: payouts must be an array");
|
|
57196
|
+
}
|
|
57197
|
+
raw.payouts.forEach((p, i) => {
|
|
57198
|
+
const where = `payouts[${i}]`;
|
|
57199
|
+
if (!isRecord(p))
|
|
57200
|
+
throw new Error(`tournament leaderboard: ${where} must be an object`);
|
|
57201
|
+
requireNumber(p, "place", where);
|
|
57202
|
+
requireString(p, "amount", where);
|
|
57203
|
+
});
|
|
57204
|
+
if (raw.clock !== undefined) {
|
|
57205
|
+
if (!isRecord(raw.clock))
|
|
57206
|
+
throw new Error("tournament leaderboard: clock must be an object");
|
|
57207
|
+
requireNumber(raw.clock, "level", "clock");
|
|
57208
|
+
requireString(raw.clock, "smallBlind", "clock");
|
|
57209
|
+
requireString(raw.clock, "bigBlind", "clock");
|
|
57210
|
+
requireString(raw.clock, "ante", "clock");
|
|
57211
|
+
optionalNumber(raw.clock, "levelStartTime", "clock");
|
|
57212
|
+
}
|
|
57213
|
+
optionalNumber(raw, "nextLevelAt", "leaderboard");
|
|
57214
|
+
if (!Array.isArray(raw.entries)) {
|
|
57215
|
+
throw new Error("tournament leaderboard: entries must be an array");
|
|
57216
|
+
}
|
|
57217
|
+
raw.entries.forEach((e, i) => requireEntry(e, `entries[${i}]`));
|
|
57218
|
+
return raw;
|
|
57219
|
+
}
|
|
57220
|
+
function requireEntry(e, where) {
|
|
57221
|
+
if (!isRecord(e))
|
|
57222
|
+
throw new Error(`tournament leaderboard: ${where} must be an object`);
|
|
57223
|
+
requireNumber(e, "rank", where);
|
|
57224
|
+
requireString(e, "address", where);
|
|
57225
|
+
if (!TOURNAMENT_ENTRANT_STATUSES.includes(e.status)) {
|
|
57226
|
+
throw new Error(`tournament leaderboard: ${where}.status "${String(e.status)}" is not an entrant status`);
|
|
57227
|
+
}
|
|
57228
|
+
requireString(e, "stack", where);
|
|
57229
|
+
optionalString(e, "tableId", where);
|
|
57230
|
+
optionalNumber(e, "seat", where);
|
|
57231
|
+
optionalNumber(e, "place", where);
|
|
57232
|
+
optionalString(e, "payout", where);
|
|
57233
|
+
}
|
|
57234
|
+
function requireStatus(o, where) {
|
|
57235
|
+
if (!TOURNAMENT_STATUSES.includes(o.status)) {
|
|
57236
|
+
throw new Error(`tournament leaderboard: ${where}.status "${String(o.status)}" is not a tournament status`);
|
|
57237
|
+
}
|
|
57238
|
+
}
|
|
57239
|
+
function isRecord(v) {
|
|
57240
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
57241
|
+
}
|
|
57242
|
+
function requireString(o, key, where) {
|
|
57243
|
+
if (typeof o[key] !== "string")
|
|
57244
|
+
throw new Error(`tournament leaderboard: ${where}.${key} must be a string`);
|
|
57245
|
+
}
|
|
57246
|
+
function requireNumber(o, key, where) {
|
|
57247
|
+
if (typeof o[key] !== "number")
|
|
57248
|
+
throw new Error(`tournament leaderboard: ${where}.${key} must be a number`);
|
|
57249
|
+
}
|
|
57250
|
+
function optionalString(o, key, where) {
|
|
57251
|
+
if (o[key] !== undefined)
|
|
57252
|
+
requireString(o, key, where);
|
|
57253
|
+
}
|
|
57254
|
+
function optionalNumber(o, key, where) {
|
|
57255
|
+
if (o[key] !== undefined)
|
|
57256
|
+
requireNumber(o, key, where);
|
|
57257
|
+
}
|
|
57258
|
+
|
|
57168
57259
|
/**
|
|
57169
57260
|
* Poker hand types in order of strength (weakest to strongest)
|
|
57170
57261
|
*/
|
|
@@ -58796,6 +58887,35 @@ class CosmosClient {
|
|
|
58796
58887
|
return [];
|
|
58797
58888
|
}
|
|
58798
58889
|
}
|
|
58890
|
+
/**
|
|
58891
|
+
* A multi-table tournament's live standings (block52/pokerchain#405,
|
|
58892
|
+
* poker-vm#2613), ranked by the engine: the chain runs engine.Leaderboard
|
|
58893
|
+
* over the stored tournament state and serves the LeaderboardDTO verbatim.
|
|
58894
|
+
* Unauthenticated: standings are public.
|
|
58895
|
+
*
|
|
58896
|
+
* @returns the board, or null when the chain has no tournament with this ID
|
|
58897
|
+
* (gRPC NotFound, HTTP 404). Any other failure — including an empty or
|
|
58898
|
+
* malformed leaderboard — throws.
|
|
58899
|
+
*/
|
|
58900
|
+
async getTournamentLeaderboard(tournamentId) {
|
|
58901
|
+
if (tournamentId === "") {
|
|
58902
|
+
throw new Error("tournamentId is required");
|
|
58903
|
+
}
|
|
58904
|
+
try {
|
|
58905
|
+
const response = await this.restClient.get(`/block52/pokerchain/poker/v1/tournament_leaderboard/${encodeURIComponent(tournamentId)}`);
|
|
58906
|
+
if (!response.data || typeof response.data.leaderboard !== "string") {
|
|
58907
|
+
throw new Error(`Empty tournament leaderboard response for ${tournamentId}`);
|
|
58908
|
+
}
|
|
58909
|
+
return parseLeaderboardDTO(response.data.leaderboard);
|
|
58910
|
+
}
|
|
58911
|
+
catch (error) {
|
|
58912
|
+
if (isGrpcNotFound(error)) {
|
|
58913
|
+
return null;
|
|
58914
|
+
}
|
|
58915
|
+
console.error("Error fetching tournament leaderboard:", error);
|
|
58916
|
+
throw error;
|
|
58917
|
+
}
|
|
58918
|
+
}
|
|
58799
58919
|
/**
|
|
58800
58920
|
* Calculate equity for multiple hands using Monte Carlo simulation
|
|
58801
58921
|
* Used when players are all-in and showing to display win percentages
|
|
@@ -58866,6 +58986,19 @@ const getDefaultCosmosConfig = (domain = "localhost") => ({
|
|
|
58866
58986
|
denom: "stake", // Use stake as the denomination (lowercase, as stored on blockchain)
|
|
58867
58987
|
gasPrice: "0.0stake" // Gas price in stake (not used in REST-only mode)
|
|
58868
58988
|
});
|
|
58989
|
+
/** gRPC code NOT_FOUND as grpc-gateway reports it in an error body. */
|
|
58990
|
+
const GRPC_NOT_FOUND = 5;
|
|
58991
|
+
/**
|
|
58992
|
+
* True for a grpc-gateway NotFound reply: HTTP 404 whose body carries gRPC code
|
|
58993
|
+
* 5. An unknown route (an older chain without the query) is a 501, not this.
|
|
58994
|
+
*/
|
|
58995
|
+
function isGrpcNotFound(error) {
|
|
58996
|
+
if (!axios.isAxiosError(error) || error.response?.status !== 404) {
|
|
58997
|
+
return false;
|
|
58998
|
+
}
|
|
58999
|
+
const body = error.response.data;
|
|
59000
|
+
return typeof body === "object" && body !== null && body.code === GRPC_NOT_FOUND;
|
|
59001
|
+
}
|
|
58869
59002
|
|
|
58870
59003
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
58871
59004
|
|
|
@@ -72830,6 +72963,8 @@ exports.SIT_IN_METHOD_POST_NOW = SIT_IN_METHOD_POST_NOW;
|
|
|
72830
72963
|
exports.SIT_OUT_METHOD_NEXT_BB = SIT_OUT_METHOD_NEXT_BB;
|
|
72831
72964
|
exports.SIT_OUT_METHOD_NEXT_HAND = SIT_OUT_METHOD_NEXT_HAND;
|
|
72832
72965
|
exports.SigningCosmosClient = SigningCosmosClient;
|
|
72966
|
+
exports.TOURNAMENT_ENTRANT_STATUSES = TOURNAMENT_ENTRANT_STATUSES;
|
|
72967
|
+
exports.TOURNAMENT_STATUSES = TOURNAMENT_STATUSES;
|
|
72833
72968
|
exports.TxExecutionError = TxExecutionError;
|
|
72834
72969
|
exports.ValidatorBond = ValidatorBond;
|
|
72835
72970
|
exports.WithdrawalRequest = WithdrawalRequest;
|
|
@@ -72867,6 +73002,7 @@ exports.lateRegistrationClosesAt = lateRegistrationClosesAt;
|
|
|
72867
73002
|
exports.parseBlindStructure = parseBlindStructure;
|
|
72868
73003
|
exports.parseGameFormat = parseGameFormat;
|
|
72869
73004
|
exports.parseGameVariant = parseGameVariant;
|
|
73005
|
+
exports.parseLeaderboardDTO = parseLeaderboardDTO;
|
|
72870
73006
|
exports.registry = registry;
|
|
72871
73007
|
exports.resolveBlindPreset = resolveBlindPreset;
|
|
72872
73008
|
exports.roundBlind = roundBlind;
|