@block52/poker-vm-sdk 1.17.0 → 1.21.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 +82 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +164 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +166 -7
- package/dist/index.js.map +1 -1
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts +6 -0
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts.map +1 -1
- package/dist/signingClient.d.ts +1 -0
- package/dist/signingClient.d.ts.map +1 -1
- package/dist/types/game.d.ts +53 -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
|
@@ -2851,6 +2851,7 @@ function createBaseMsgCreateGame() {
|
|
|
2851
2851
|
startTime: Long.ZERO,
|
|
2852
2852
|
blindStructure: "",
|
|
2853
2853
|
lateRegistrationLevels: 0,
|
|
2854
|
+
waitForStartTime: false,
|
|
2854
2855
|
};
|
|
2855
2856
|
}
|
|
2856
2857
|
const MsgCreateGame = {
|
|
@@ -2921,6 +2922,9 @@ const MsgCreateGame = {
|
|
|
2921
2922
|
if (message.lateRegistrationLevels !== 0) {
|
|
2922
2923
|
writer.uint32(184).uint32(message.lateRegistrationLevels);
|
|
2923
2924
|
}
|
|
2925
|
+
if (message.waitForStartTime !== false) {
|
|
2926
|
+
writer.uint32(192).bool(message.waitForStartTime);
|
|
2927
|
+
}
|
|
2924
2928
|
return writer;
|
|
2925
2929
|
},
|
|
2926
2930
|
decode(input, length) {
|
|
@@ -3084,6 +3088,13 @@ const MsgCreateGame = {
|
|
|
3084
3088
|
message.lateRegistrationLevels = reader.uint32();
|
|
3085
3089
|
continue;
|
|
3086
3090
|
}
|
|
3091
|
+
case 24: {
|
|
3092
|
+
if (tag !== 192) {
|
|
3093
|
+
break;
|
|
3094
|
+
}
|
|
3095
|
+
message.waitForStartTime = reader.bool();
|
|
3096
|
+
continue;
|
|
3097
|
+
}
|
|
3087
3098
|
}
|
|
3088
3099
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3089
3100
|
break;
|
|
@@ -3116,6 +3127,7 @@ const MsgCreateGame = {
|
|
|
3116
3127
|
startTime: isSet$2b(object.startTime) ? Long.fromValue(object.startTime) : Long.ZERO,
|
|
3117
3128
|
blindStructure: isSet$2b(object.blindStructure) ? globalThis.String(object.blindStructure) : "",
|
|
3118
3129
|
lateRegistrationLevels: isSet$2b(object.lateRegistrationLevels) ? globalThis.Number(object.lateRegistrationLevels) : 0,
|
|
3130
|
+
waitForStartTime: isSet$2b(object.waitForStartTime) ? globalThis.Boolean(object.waitForStartTime) : false,
|
|
3119
3131
|
};
|
|
3120
3132
|
},
|
|
3121
3133
|
toJSON(message) {
|
|
@@ -3186,6 +3198,9 @@ const MsgCreateGame = {
|
|
|
3186
3198
|
if (message.lateRegistrationLevels !== 0) {
|
|
3187
3199
|
obj.lateRegistrationLevels = Math.round(message.lateRegistrationLevels);
|
|
3188
3200
|
}
|
|
3201
|
+
if (message.waitForStartTime !== false) {
|
|
3202
|
+
obj.waitForStartTime = message.waitForStartTime;
|
|
3203
|
+
}
|
|
3189
3204
|
return obj;
|
|
3190
3205
|
},
|
|
3191
3206
|
create(base) {
|
|
@@ -3236,6 +3251,7 @@ const MsgCreateGame = {
|
|
|
3236
3251
|
: Long.ZERO;
|
|
3237
3252
|
message.blindStructure = object.blindStructure ?? "";
|
|
3238
3253
|
message.lateRegistrationLevels = object.lateRegistrationLevels ?? 0;
|
|
3254
|
+
message.waitForStartTime = object.waitForStartTime ?? false;
|
|
3239
3255
|
message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
|
|
3240
3256
|
? Long.fromValue(object.entryFee)
|
|
3241
3257
|
: Long.UZERO;
|
|
@@ -56136,6 +56152,9 @@ exports.NonPlayerActionType = void 0;
|
|
|
56136
56152
|
// player's bet (they're matched) but excluded from the first-to-act /
|
|
56137
56153
|
// has-acted scans (it's a non-player action, like DEAD_SMALL_BLIND).
|
|
56138
56154
|
NonPlayerActionType["POST"] = "post";
|
|
56155
|
+
// A missed small blind posted dead on sitting back in (poker-vm#2200).
|
|
56156
|
+
// Recorded in ANTE; in the pot but not a bet anyone must match (like ANTE).
|
|
56157
|
+
NonPlayerActionType["POST_DEAD"] = "post-dead";
|
|
56139
56158
|
NonPlayerActionType["SIT_IN"] = "sit-in";
|
|
56140
56159
|
// Sit in and wait for the big blind — distinct action from SIT_IN (post now)
|
|
56141
56160
|
// so each has a single responsibility. Sets WAITING_FOR_BIG_BLIND. (#2139)
|
|
@@ -56149,12 +56168,13 @@ exports.NonPlayerActionType = void 0;
|
|
|
56149
56168
|
// SHOW at showdown — and records THAT action; no "timeout" turn is ever
|
|
56150
56169
|
// written to previousActions. Rejected while the turn has time remaining.
|
|
56151
56170
|
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,
|
|
56171
|
+
// Time bank (ui#19/#20): the player to act extends their turn's action-clock
|
|
56172
|
+
// deadline by their whole bank, once per decision: gameOptions.timeBankMs
|
|
56173
|
+
// the first time, 30s the second, then 5s refilling 5s per orbit up to
|
|
56174
|
+
// gameOptions.timeBankCapMs. Records a no-chip turn that does NOT advance the
|
|
56175
|
+
// betting order or move the clock anchor; the deadline adds the user's
|
|
56176
|
+
// PlayerDTO.timeBankLastGrantMs for the current turn. Rejected off-turn,
|
|
56177
|
+
// past the deadline, or with no bank left.
|
|
56158
56178
|
NonPlayerActionType["TIME_BANK"] = "time-bank";
|
|
56159
56179
|
NonPlayerActionType["TOP_UP"] = "top-up";
|
|
56160
56180
|
// Scheduled single-table tournament (poker-vm#2680): any registered player
|
|
@@ -56245,6 +56265,8 @@ const BLIND_PRESETS = ["turbo", "standard", "deep_stack", "hyper_turbo"];
|
|
|
56245
56265
|
const BLIND_PROGRESSIONS = ["double", "linear", "percentage", "table"];
|
|
56246
56266
|
const SIT_OUT_METHOD_NEXT_HAND = "next-hand";
|
|
56247
56267
|
const SIT_OUT_METHOD_NEXT_BB = "next-bb";
|
|
56268
|
+
const TOURNAMENT_STATUSES = ["registering", "running", "finished", "cancelled"];
|
|
56269
|
+
const TOURNAMENT_ENTRANT_STATUSES = ["registered", "playing", "busted", "unregistered"];
|
|
56248
56270
|
exports.SUIT = void 0;
|
|
56249
56271
|
(function (SUIT) {
|
|
56250
56272
|
SUIT[SUIT["CLUBS"] = 1] = "CLUBS";
|
|
@@ -57165,6 +57187,91 @@ function levelMinutes(options) {
|
|
|
57165
57187
|
return options.blindLevelDuration;
|
|
57166
57188
|
}
|
|
57167
57189
|
|
|
57190
|
+
/**
|
|
57191
|
+
* Parses the `leaderboard` JSON string of the chain's TournamentLeaderboard
|
|
57192
|
+
* query (block52/pokerchain#405, poker-vm#2613) into a LeaderboardDTO. Checks
|
|
57193
|
+
* the required fields and throws on anything missing or mistyped — never fills
|
|
57194
|
+
* a default (Commandment 7): a malformed board is a chain/engine bug to surface.
|
|
57195
|
+
*/
|
|
57196
|
+
function parseLeaderboardDTO(json) {
|
|
57197
|
+
if (json === "") {
|
|
57198
|
+
throw new Error("tournament leaderboard: empty leaderboard JSON");
|
|
57199
|
+
}
|
|
57200
|
+
const raw = JSON.parse(json);
|
|
57201
|
+
if (!isRecord(raw)) {
|
|
57202
|
+
throw new Error("tournament leaderboard: expected a JSON object");
|
|
57203
|
+
}
|
|
57204
|
+
requireString(raw, "tournamentId", "leaderboard");
|
|
57205
|
+
requireStatus(raw, "leaderboard");
|
|
57206
|
+
requireNumber(raw, "entrants", "leaderboard");
|
|
57207
|
+
requireNumber(raw, "remaining", "leaderboard");
|
|
57208
|
+
requireString(raw, "averageStack", "leaderboard");
|
|
57209
|
+
requireString(raw, "prizePool", "leaderboard");
|
|
57210
|
+
if (!Array.isArray(raw.payouts)) {
|
|
57211
|
+
throw new Error("tournament leaderboard: payouts must be an array");
|
|
57212
|
+
}
|
|
57213
|
+
raw.payouts.forEach((p, i) => {
|
|
57214
|
+
const where = `payouts[${i}]`;
|
|
57215
|
+
if (!isRecord(p))
|
|
57216
|
+
throw new Error(`tournament leaderboard: ${where} must be an object`);
|
|
57217
|
+
requireNumber(p, "place", where);
|
|
57218
|
+
requireString(p, "amount", where);
|
|
57219
|
+
});
|
|
57220
|
+
if (raw.clock !== undefined) {
|
|
57221
|
+
if (!isRecord(raw.clock))
|
|
57222
|
+
throw new Error("tournament leaderboard: clock must be an object");
|
|
57223
|
+
requireNumber(raw.clock, "level", "clock");
|
|
57224
|
+
requireString(raw.clock, "smallBlind", "clock");
|
|
57225
|
+
requireString(raw.clock, "bigBlind", "clock");
|
|
57226
|
+
requireString(raw.clock, "ante", "clock");
|
|
57227
|
+
optionalNumber(raw.clock, "levelStartTime", "clock");
|
|
57228
|
+
}
|
|
57229
|
+
optionalNumber(raw, "nextLevelAt", "leaderboard");
|
|
57230
|
+
if (!Array.isArray(raw.entries)) {
|
|
57231
|
+
throw new Error("tournament leaderboard: entries must be an array");
|
|
57232
|
+
}
|
|
57233
|
+
raw.entries.forEach((e, i) => requireEntry(e, `entries[${i}]`));
|
|
57234
|
+
return raw;
|
|
57235
|
+
}
|
|
57236
|
+
function requireEntry(e, where) {
|
|
57237
|
+
if (!isRecord(e))
|
|
57238
|
+
throw new Error(`tournament leaderboard: ${where} must be an object`);
|
|
57239
|
+
requireNumber(e, "rank", where);
|
|
57240
|
+
requireString(e, "address", where);
|
|
57241
|
+
if (!TOURNAMENT_ENTRANT_STATUSES.includes(e.status)) {
|
|
57242
|
+
throw new Error(`tournament leaderboard: ${where}.status "${String(e.status)}" is not an entrant status`);
|
|
57243
|
+
}
|
|
57244
|
+
requireString(e, "stack", where);
|
|
57245
|
+
optionalString(e, "tableId", where);
|
|
57246
|
+
optionalNumber(e, "seat", where);
|
|
57247
|
+
optionalNumber(e, "place", where);
|
|
57248
|
+
optionalString(e, "payout", where);
|
|
57249
|
+
}
|
|
57250
|
+
function requireStatus(o, where) {
|
|
57251
|
+
if (!TOURNAMENT_STATUSES.includes(o.status)) {
|
|
57252
|
+
throw new Error(`tournament leaderboard: ${where}.status "${String(o.status)}" is not a tournament status`);
|
|
57253
|
+
}
|
|
57254
|
+
}
|
|
57255
|
+
function isRecord(v) {
|
|
57256
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
57257
|
+
}
|
|
57258
|
+
function requireString(o, key, where) {
|
|
57259
|
+
if (typeof o[key] !== "string")
|
|
57260
|
+
throw new Error(`tournament leaderboard: ${where}.${key} must be a string`);
|
|
57261
|
+
}
|
|
57262
|
+
function requireNumber(o, key, where) {
|
|
57263
|
+
if (typeof o[key] !== "number")
|
|
57264
|
+
throw new Error(`tournament leaderboard: ${where}.${key} must be a number`);
|
|
57265
|
+
}
|
|
57266
|
+
function optionalString(o, key, where) {
|
|
57267
|
+
if (o[key] !== undefined)
|
|
57268
|
+
requireString(o, key, where);
|
|
57269
|
+
}
|
|
57270
|
+
function optionalNumber(o, key, where) {
|
|
57271
|
+
if (o[key] !== undefined)
|
|
57272
|
+
requireNumber(o, key, where);
|
|
57273
|
+
}
|
|
57274
|
+
|
|
57168
57275
|
/**
|
|
57169
57276
|
* Poker hand types in order of strength (weakest to strongest)
|
|
57170
57277
|
*/
|
|
@@ -58796,6 +58903,35 @@ class CosmosClient {
|
|
|
58796
58903
|
return [];
|
|
58797
58904
|
}
|
|
58798
58905
|
}
|
|
58906
|
+
/**
|
|
58907
|
+
* A multi-table tournament's live standings (block52/pokerchain#405,
|
|
58908
|
+
* poker-vm#2613), ranked by the engine: the chain runs engine.Leaderboard
|
|
58909
|
+
* over the stored tournament state and serves the LeaderboardDTO verbatim.
|
|
58910
|
+
* Unauthenticated: standings are public.
|
|
58911
|
+
*
|
|
58912
|
+
* @returns the board, or null when the chain has no tournament with this ID
|
|
58913
|
+
* (gRPC NotFound, HTTP 404). Any other failure — including an empty or
|
|
58914
|
+
* malformed leaderboard — throws.
|
|
58915
|
+
*/
|
|
58916
|
+
async getTournamentLeaderboard(tournamentId) {
|
|
58917
|
+
if (tournamentId === "") {
|
|
58918
|
+
throw new Error("tournamentId is required");
|
|
58919
|
+
}
|
|
58920
|
+
try {
|
|
58921
|
+
const response = await this.restClient.get(`/block52/pokerchain/poker/v1/tournament_leaderboard/${encodeURIComponent(tournamentId)}`);
|
|
58922
|
+
if (!response.data || typeof response.data.leaderboard !== "string") {
|
|
58923
|
+
throw new Error(`Empty tournament leaderboard response for ${tournamentId}`);
|
|
58924
|
+
}
|
|
58925
|
+
return parseLeaderboardDTO(response.data.leaderboard);
|
|
58926
|
+
}
|
|
58927
|
+
catch (error) {
|
|
58928
|
+
if (isGrpcNotFound(error)) {
|
|
58929
|
+
return null;
|
|
58930
|
+
}
|
|
58931
|
+
console.error("Error fetching tournament leaderboard:", error);
|
|
58932
|
+
throw error;
|
|
58933
|
+
}
|
|
58934
|
+
}
|
|
58799
58935
|
/**
|
|
58800
58936
|
* Calculate equity for multiple hands using Monte Carlo simulation
|
|
58801
58937
|
* Used when players are all-in and showing to display win percentages
|
|
@@ -58866,6 +59002,19 @@ const getDefaultCosmosConfig = (domain = "localhost") => ({
|
|
|
58866
59002
|
denom: "stake", // Use stake as the denomination (lowercase, as stored on blockchain)
|
|
58867
59003
|
gasPrice: "0.0stake" // Gas price in stake (not used in REST-only mode)
|
|
58868
59004
|
});
|
|
59005
|
+
/** gRPC code NOT_FOUND as grpc-gateway reports it in an error body. */
|
|
59006
|
+
const GRPC_NOT_FOUND = 5;
|
|
59007
|
+
/**
|
|
59008
|
+
* True for a grpc-gateway NotFound reply: HTTP 404 whose body carries gRPC code
|
|
59009
|
+
* 5. An unknown route (an older chain without the query) is a 501, not this.
|
|
59010
|
+
*/
|
|
59011
|
+
function isGrpcNotFound(error) {
|
|
59012
|
+
if (!axios.isAxiosError(error) || error.response?.status !== 404) {
|
|
59013
|
+
return false;
|
|
59014
|
+
}
|
|
59015
|
+
const body = error.response.data;
|
|
59016
|
+
return typeof body === "object" && body !== null && body.code === GRPC_NOT_FOUND;
|
|
59017
|
+
}
|
|
58869
59018
|
|
|
58870
59019
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
58871
59020
|
|
|
@@ -71729,6 +71878,9 @@ function assertCreatableSngField(minPlayers, maxPlayers, sngConfig, nowSeconds =
|
|
|
71729
71878
|
throw new Error("sngConfig.lateRegistrationLevels needs sngConfig.startTime (late registration is for a scheduled sit-and-go).");
|
|
71730
71879
|
}
|
|
71731
71880
|
}
|
|
71881
|
+
if (sngConfig?.waitForStartTime && !startTime) {
|
|
71882
|
+
throw new Error("sngConfig.waitForStartTime needs sngConfig.startTime (it holds a scheduled sit-and-go until its start time).");
|
|
71883
|
+
}
|
|
71732
71884
|
}
|
|
71733
71885
|
/**
|
|
71734
71886
|
* Signing Cosmos Client that extends the read-only CosmosClient with transaction capabilities
|
|
@@ -71907,6 +72059,9 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71907
72059
|
// an empty proto3 string is not encoded at all.
|
|
71908
72060
|
blindStructure: sngConfig?.blindStructure ? JSON.stringify(sngConfig.blindStructure) : "",
|
|
71909
72061
|
lateRegistrationLevels: sngConfig?.lateRegistrationLevels ?? 0,
|
|
72062
|
+
// Hold a full table until the start time (poker-vm#2760). false is
|
|
72063
|
+
// not encoded, so chains without the field accept the message.
|
|
72064
|
+
waitForStartTime: sngConfig?.waitForStartTime ?? false,
|
|
71910
72065
|
});
|
|
71911
72066
|
// Create the transaction message
|
|
71912
72067
|
const msg = {
|
|
@@ -71938,7 +72093,8 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71938
72093
|
blindLevelDuration: sngConfig.blindLevelDuration,
|
|
71939
72094
|
entryFee: sngConfig.entryFee?.toString() ?? "0",
|
|
71940
72095
|
...(sngConfig.blindStructure && { blindStructure: sngConfig.blindStructure }),
|
|
71941
|
-
...(sngConfig.lateRegistrationLevels && { lateRegistrationLevels: sngConfig.lateRegistrationLevels })
|
|
72096
|
+
...(sngConfig.lateRegistrationLevels && { lateRegistrationLevels: sngConfig.lateRegistrationLevels }),
|
|
72097
|
+
...(sngConfig.waitForStartTime && { waitForStartTime: true })
|
|
71942
72098
|
})
|
|
71943
72099
|
});
|
|
71944
72100
|
try {
|
|
@@ -72830,6 +72986,8 @@ exports.SIT_IN_METHOD_POST_NOW = SIT_IN_METHOD_POST_NOW;
|
|
|
72830
72986
|
exports.SIT_OUT_METHOD_NEXT_BB = SIT_OUT_METHOD_NEXT_BB;
|
|
72831
72987
|
exports.SIT_OUT_METHOD_NEXT_HAND = SIT_OUT_METHOD_NEXT_HAND;
|
|
72832
72988
|
exports.SigningCosmosClient = SigningCosmosClient;
|
|
72989
|
+
exports.TOURNAMENT_ENTRANT_STATUSES = TOURNAMENT_ENTRANT_STATUSES;
|
|
72990
|
+
exports.TOURNAMENT_STATUSES = TOURNAMENT_STATUSES;
|
|
72833
72991
|
exports.TxExecutionError = TxExecutionError;
|
|
72834
72992
|
exports.ValidatorBond = ValidatorBond;
|
|
72835
72993
|
exports.WithdrawalRequest = WithdrawalRequest;
|
|
@@ -72867,6 +73025,7 @@ exports.lateRegistrationClosesAt = lateRegistrationClosesAt;
|
|
|
72867
73025
|
exports.parseBlindStructure = parseBlindStructure;
|
|
72868
73026
|
exports.parseGameFormat = parseGameFormat;
|
|
72869
73027
|
exports.parseGameVariant = parseGameVariant;
|
|
73028
|
+
exports.parseLeaderboardDTO = parseLeaderboardDTO;
|
|
72870
73029
|
exports.registry = registry;
|
|
72871
73030
|
exports.resolveBlindPreset = resolveBlindPreset;
|
|
72872
73031
|
exports.roundBlind = roundBlind;
|