@block52/poker-vm-sdk 1.12.1 → 1.15.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/index.d.ts +36 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +85 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +86 -6
- package/dist/index.js.map +1 -1
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts +7 -0
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts.map +1 -1
- package/dist/signingClient.d.ts +6 -3
- package/dist/signingClient.d.ts.map +1 -1
- package/dist/types/game.d.ts +6 -0
- package/dist/types/game.d.ts.map +1 -1
- package/dist/utils/lateRegistration.d.ts +17 -0
- package/dist/utils/lateRegistration.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2850,6 +2850,7 @@ function createBaseMsgCreateGame() {
|
|
|
2850
2850
|
bettingLimit: "",
|
|
2851
2851
|
startTime: Long.ZERO,
|
|
2852
2852
|
blindStructure: "",
|
|
2853
|
+
lateRegistrationLevels: 0,
|
|
2853
2854
|
};
|
|
2854
2855
|
}
|
|
2855
2856
|
const MsgCreateGame = {
|
|
@@ -2917,6 +2918,9 @@ const MsgCreateGame = {
|
|
|
2917
2918
|
if (message.blindStructure !== "") {
|
|
2918
2919
|
writer.uint32(178).string(message.blindStructure);
|
|
2919
2920
|
}
|
|
2921
|
+
if (message.lateRegistrationLevels !== 0) {
|
|
2922
|
+
writer.uint32(184).uint32(message.lateRegistrationLevels);
|
|
2923
|
+
}
|
|
2920
2924
|
return writer;
|
|
2921
2925
|
},
|
|
2922
2926
|
decode(input, length) {
|
|
@@ -3073,6 +3077,13 @@ const MsgCreateGame = {
|
|
|
3073
3077
|
message.blindStructure = reader.string();
|
|
3074
3078
|
continue;
|
|
3075
3079
|
}
|
|
3080
|
+
case 23: {
|
|
3081
|
+
if (tag !== 184) {
|
|
3082
|
+
break;
|
|
3083
|
+
}
|
|
3084
|
+
message.lateRegistrationLevels = reader.uint32();
|
|
3085
|
+
continue;
|
|
3086
|
+
}
|
|
3076
3087
|
}
|
|
3077
3088
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3078
3089
|
break;
|
|
@@ -3104,6 +3115,7 @@ const MsgCreateGame = {
|
|
|
3104
3115
|
bettingLimit: isSet$2b(object.bettingLimit) ? globalThis.String(object.bettingLimit) : "",
|
|
3105
3116
|
startTime: isSet$2b(object.startTime) ? Long.fromValue(object.startTime) : Long.ZERO,
|
|
3106
3117
|
blindStructure: isSet$2b(object.blindStructure) ? globalThis.String(object.blindStructure) : "",
|
|
3118
|
+
lateRegistrationLevels: isSet$2b(object.lateRegistrationLevels) ? globalThis.Number(object.lateRegistrationLevels) : 0,
|
|
3107
3119
|
};
|
|
3108
3120
|
},
|
|
3109
3121
|
toJSON(message) {
|
|
@@ -3171,6 +3183,9 @@ const MsgCreateGame = {
|
|
|
3171
3183
|
if (message.blindStructure !== "") {
|
|
3172
3184
|
obj.blindStructure = message.blindStructure;
|
|
3173
3185
|
}
|
|
3186
|
+
if (message.lateRegistrationLevels !== 0) {
|
|
3187
|
+
obj.lateRegistrationLevels = Math.round(message.lateRegistrationLevels);
|
|
3188
|
+
}
|
|
3174
3189
|
return obj;
|
|
3175
3190
|
},
|
|
3176
3191
|
create(base) {
|
|
@@ -3220,6 +3235,7 @@ const MsgCreateGame = {
|
|
|
3220
3235
|
? Long.fromValue(object.startTime)
|
|
3221
3236
|
: Long.ZERO;
|
|
3222
3237
|
message.blindStructure = object.blindStructure ?? "";
|
|
3238
|
+
message.lateRegistrationLevels = object.lateRegistrationLevels ?? 0;
|
|
3223
3239
|
message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
|
|
3224
3240
|
? Long.fromValue(object.entryFee)
|
|
3225
3241
|
: Long.UZERO;
|
|
@@ -56096,6 +56112,11 @@ exports.PlayerActionType = void 0;
|
|
|
56096
56112
|
exports.NonPlayerActionType = void 0;
|
|
56097
56113
|
(function (NonPlayerActionType) {
|
|
56098
56114
|
NonPlayerActionType["DEAD_SMALL_BLIND"] = "dead-small-blind";
|
|
56115
|
+
// Big-blind ante on a tournament-directed table (poker-vm#2613 slice 7):
|
|
56116
|
+
// dead money the big blind posts for the table before the blind itself,
|
|
56117
|
+
// from the tournament clock. Engine-recorded, never submitted; in the pot
|
|
56118
|
+
// but not a bet the others must match.
|
|
56119
|
+
NonPlayerActionType["ANTE"] = "ante";
|
|
56099
56120
|
NonPlayerActionType["DEAL"] = "deal";
|
|
56100
56121
|
NonPlayerActionType["FORCE_CLOSE"] = "force-close";
|
|
56101
56122
|
NonPlayerActionType["JOIN"] = "join";
|
|
@@ -57064,6 +57085,47 @@ function expandBlindLevel(structure, n) {
|
|
|
57064
57085
|
return { level: n, smallBlind: sb.toString(), bigBlind: bb.toString(), ante: ante.toString(), durationMinutes: structure.durationMinutes, isBreak: false };
|
|
57065
57086
|
}
|
|
57066
57087
|
|
|
57088
|
+
/**
|
|
57089
|
+
* Late registration for a scheduled sit-and-go (poker-vm#2731), read the way
|
|
57090
|
+
* the engine decides it: after the start, a join is accepted while the blind
|
|
57091
|
+
* level at block time is below `gameOptions.lateRegistrationLevels`, until
|
|
57092
|
+
* anyone has finished in the money. The blind clock — and so the window —
|
|
57093
|
+
* runs from the first deal (`sngStartTime`).
|
|
57094
|
+
*/
|
|
57095
|
+
/** When late registration closes (epoch ms): the end of the last open level.
|
|
57096
|
+
* Undefined when the table has no late registration, or has not dealt yet
|
|
57097
|
+
* (the clock has not started, so the window has no end time). */
|
|
57098
|
+
function lateRegistrationClosesAt(options) {
|
|
57099
|
+
const levels = options.lateRegistrationLevels;
|
|
57100
|
+
if (!levels || options.scheduledStartTime === undefined || options.sngStartTime === undefined) {
|
|
57101
|
+
return undefined;
|
|
57102
|
+
}
|
|
57103
|
+
let minutes = 0;
|
|
57104
|
+
for (let n = 0; n < levels; n++) {
|
|
57105
|
+
minutes += options.blindStructure ? expandBlindLevel(options.blindStructure, n).durationMinutes : levelMinutes(options);
|
|
57106
|
+
}
|
|
57107
|
+
return options.sngStartTime + minutes * 60000;
|
|
57108
|
+
}
|
|
57109
|
+
/** Whether a join after the start would be accepted at nowMs. Before the
|
|
57110
|
+
* first deal the window is open (level 0); it shuts at
|
|
57111
|
+
* lateRegistrationClosesAt, or once any result carries a payout. */
|
|
57112
|
+
function isLateRegistrationOpen(options, results, nowMs) {
|
|
57113
|
+
if (!options.lateRegistrationLevels || options.scheduledStartTime === undefined) {
|
|
57114
|
+
return false;
|
|
57115
|
+
}
|
|
57116
|
+
if (results.some(r => BigInt(r.payout) > 0n)) {
|
|
57117
|
+
return false;
|
|
57118
|
+
}
|
|
57119
|
+
const closesAt = lateRegistrationClosesAt(options);
|
|
57120
|
+
return closesAt === undefined || nowMs < closesAt;
|
|
57121
|
+
}
|
|
57122
|
+
function levelMinutes(options) {
|
|
57123
|
+
if (!options.blindLevelDuration || options.blindLevelDuration <= 0) {
|
|
57124
|
+
throw new Error(`a sit-and-go needs a positive blindLevelDuration or a blindStructure; got ${options.blindLevelDuration}.`);
|
|
57125
|
+
}
|
|
57126
|
+
return options.blindLevelDuration;
|
|
57127
|
+
}
|
|
57128
|
+
|
|
57067
57129
|
/**
|
|
57068
57130
|
* Poker hand types in order of strength (weakest to strongest)
|
|
57069
57131
|
*/
|
|
@@ -71616,6 +71678,15 @@ function assertCreatableSngField(minPlayers, maxPlayers, sngConfig, nowSeconds =
|
|
|
71616
71678
|
if (startTime !== undefined && startTime <= nowSeconds) {
|
|
71617
71679
|
throw new Error(`sngConfig.startTime ${startTime} must be in the future (now ${nowSeconds}).`);
|
|
71618
71680
|
}
|
|
71681
|
+
const levels = sngConfig?.lateRegistrationLevels;
|
|
71682
|
+
if (levels !== undefined) {
|
|
71683
|
+
if (!Number.isInteger(levels) || levels <= 0) {
|
|
71684
|
+
throw new Error(`sngConfig.lateRegistrationLevels must be a positive whole number of levels; got ${levels}.`);
|
|
71685
|
+
}
|
|
71686
|
+
if (!startTime) {
|
|
71687
|
+
throw new Error("sngConfig.lateRegistrationLevels needs sngConfig.startTime (late registration is for a scheduled sit-and-go).");
|
|
71688
|
+
}
|
|
71689
|
+
}
|
|
71619
71690
|
}
|
|
71620
71691
|
/**
|
|
71621
71692
|
* Signing Cosmos Client that extends the read-only CosmosClient with transaction capabilities
|
|
@@ -71727,7 +71798,8 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71727
71798
|
* `bettingLimit` is the table's betting structure (block52/pokerchain#407).
|
|
71728
71799
|
* Omit it for the variant's default: pot-limit for omaha (PLO), no-limit for
|
|
71729
71800
|
* texas-holdem. Omitted, the field is not encoded at all, so a chain without
|
|
71730
|
-
* it accepts the tx unchanged. Fixed-limit is
|
|
71801
|
+
* it accepts the tx unchanged. Fixed-limit is texas-holdem only (poker-vm#2654,
|
|
71802
|
+
* block52/pokerchain#439).
|
|
71731
71803
|
*/
|
|
71732
71804
|
async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig, name, bettingLimit) {
|
|
71733
71805
|
// Validate SNG/Tournament config BEFORE any network work — fail fast.
|
|
@@ -71750,7 +71822,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71750
71822
|
}
|
|
71751
71823
|
assertCreatableSngField(minPlayers, maxPlayers, sngConfig);
|
|
71752
71824
|
}
|
|
71753
|
-
assertCreatableBettingLimit(bettingLimit);
|
|
71825
|
+
assertCreatableBettingLimit(bettingLimit, gameVariant);
|
|
71754
71826
|
await this.initializeSigningClient();
|
|
71755
71827
|
if (!this.signingClient || !this.wallet) {
|
|
71756
71828
|
throw new Error("Signing client not initialized");
|
|
@@ -71792,6 +71864,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71792
71864
|
// Blind structure (block52/pokerchain#434) as JSON; "" = doubling, and
|
|
71793
71865
|
// an empty proto3 string is not encoded at all.
|
|
71794
71866
|
blindStructure: sngConfig?.blindStructure ? JSON.stringify(sngConfig.blindStructure) : "",
|
|
71867
|
+
lateRegistrationLevels: sngConfig?.lateRegistrationLevels ?? 0,
|
|
71795
71868
|
});
|
|
71796
71869
|
// Create the transaction message
|
|
71797
71870
|
const msg = {
|
|
@@ -71822,7 +71895,8 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71822
71895
|
startingStack: sngConfig.startingStack.toString(),
|
|
71823
71896
|
blindLevelDuration: sngConfig.blindLevelDuration,
|
|
71824
71897
|
entryFee: sngConfig.entryFee?.toString() ?? "0",
|
|
71825
|
-
...(sngConfig.blindStructure && { blindStructure: sngConfig.blindStructure })
|
|
71898
|
+
...(sngConfig.blindStructure && { blindStructure: sngConfig.blindStructure }),
|
|
71899
|
+
...(sngConfig.lateRegistrationLevels && { lateRegistrationLevels: sngConfig.lateRegistrationLevels })
|
|
71826
71900
|
})
|
|
71827
71901
|
});
|
|
71828
71902
|
try {
|
|
@@ -72691,14 +72765,18 @@ async function createSigningClientFromMnemonic(config, mnemonic) {
|
|
|
72691
72765
|
}
|
|
72692
72766
|
/**
|
|
72693
72767
|
* Throws for a betting limit a table cannot be created with (block52/pokerchain#407).
|
|
72694
|
-
* Undefined is allowed: the chain applies the variant's default.
|
|
72768
|
+
* Undefined is allowed: the chain applies the variant's default. Fixed-limit is
|
|
72769
|
+
* texas-holdem only, as the chain decides (block52/pokerchain#439, poker-vm#2654).
|
|
72695
72770
|
*/
|
|
72696
|
-
function assertCreatableBettingLimit(bettingLimit) {
|
|
72771
|
+
function assertCreatableBettingLimit(bettingLimit, gameVariant) {
|
|
72697
72772
|
if (bettingLimit === undefined) {
|
|
72698
72773
|
return;
|
|
72699
72774
|
}
|
|
72700
72775
|
if (bettingLimit === exports.BettingLimit.FIXED_LIMIT) {
|
|
72701
|
-
|
|
72776
|
+
if (gameVariant !== exports.GameVariant.TEXAS_HOLDEM) {
|
|
72777
|
+
throw new Error(`Betting limit fixed-limit is only available for texas-holdem; got ${gameVariant}.`);
|
|
72778
|
+
}
|
|
72779
|
+
return;
|
|
72702
72780
|
}
|
|
72703
72781
|
if (bettingLimit !== exports.BettingLimit.NO_LIMIT && bettingLimit !== exports.BettingLimit.POT_LIMIT) {
|
|
72704
72782
|
throw new Error(`Invalid betting limit: ${bettingLimit}.`);
|
|
@@ -72793,11 +72871,13 @@ exports.hasAction = hasAction;
|
|
|
72793
72871
|
exports.holeCardsPerPlayer = holeCardsPerPlayer;
|
|
72794
72872
|
exports.isCashFormat = isCashFormat;
|
|
72795
72873
|
exports.isEmptyAddress = isEmptyAddress;
|
|
72874
|
+
exports.isLateRegistrationOpen = isLateRegistrationOpen;
|
|
72796
72875
|
exports.isPotLimit = isPotLimit;
|
|
72797
72876
|
exports.isSitAndGoFormat = isSitAndGoFormat;
|
|
72798
72877
|
exports.isTournamentFormat = isTournamentFormat;
|
|
72799
72878
|
exports.isValidMnemonic = isValidMnemonic;
|
|
72800
72879
|
exports.isValidPlayerAddress = isValidPlayerAddress;
|
|
72880
|
+
exports.lateRegistrationClosesAt = lateRegistrationClosesAt;
|
|
72801
72881
|
exports.parseBlindStructure = parseBlindStructure;
|
|
72802
72882
|
exports.parseGameFormat = parseGameFormat;
|
|
72803
72883
|
exports.parseGameVariant = parseGameVariant;
|