@block52/poker-vm-sdk 1.1.18 → 1.2.2
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 +41 -0
- package/dist/index.esm.js +98 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -1
- package/dist/signingClient.d.ts +38 -0
- package/dist/signingClient.d.ts.map +1 -1
- package/dist/types/game.d.ts +3 -0
- package/dist/types/game.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -45213,6 +45213,7 @@ declare enum PlayerActionType {
|
|
|
45213
45213
|
declare enum NonPlayerActionType {
|
|
45214
45214
|
DEAD_SMALL_BLIND = "dead-small-blind",
|
|
45215
45215
|
DEAL = "deal",
|
|
45216
|
+
FORCE_CLOSE = "force-close",
|
|
45216
45217
|
JOIN = "join",
|
|
45217
45218
|
LEAVE = "leave",
|
|
45218
45219
|
NEW_HAND = "new-hand",
|
|
@@ -45223,6 +45224,7 @@ declare enum NonPlayerActionType {
|
|
|
45223
45224
|
declare const AllPlayerActions: {
|
|
45224
45225
|
DEAD_SMALL_BLIND: NonPlayerActionType.DEAD_SMALL_BLIND;
|
|
45225
45226
|
DEAL: NonPlayerActionType.DEAL;
|
|
45227
|
+
FORCE_CLOSE: NonPlayerActionType.FORCE_CLOSE;
|
|
45226
45228
|
JOIN: NonPlayerActionType.JOIN;
|
|
45227
45229
|
LEAVE: NonPlayerActionType.LEAVE;
|
|
45228
45230
|
NEW_HAND: NonPlayerActionType.NEW_HAND;
|
|
@@ -45388,6 +45390,7 @@ type PlayerDTO = {
|
|
|
45388
45390
|
timeout: number;
|
|
45389
45391
|
sitInMethod?: SitInMethod;
|
|
45390
45392
|
pendingSitOut?: string;
|
|
45393
|
+
pendingTopUpAmount?: string;
|
|
45391
45394
|
signature: string;
|
|
45392
45395
|
};
|
|
45393
45396
|
type ResultDTO = {
|
|
@@ -46407,6 +46410,18 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46407
46410
|
* Only the game creator can delete a game, and the game must have no active players
|
|
46408
46411
|
*/
|
|
46409
46412
|
deleteGame(gameId: string): Promise<string>;
|
|
46413
|
+
/**
|
|
46414
|
+
* Force-close a poker game and refund every seated player.
|
|
46415
|
+
*
|
|
46416
|
+
* Only the table creator can invoke this. Distinct from `deleteGame()`:
|
|
46417
|
+
* `deleteGame` requires zero players, this kicks everyone off and refunds
|
|
46418
|
+
* their stacks (plus any current-hand contribution and queued top-up) to
|
|
46419
|
+
* their wallet, then deletes the table.
|
|
46420
|
+
*
|
|
46421
|
+
* Cash format only. Chain rejects SNG/Tournament — those have separate
|
|
46422
|
+
* cancellation semantics (see block52/poker-vm#2173).
|
|
46423
|
+
*/
|
|
46424
|
+
forceCloseGame(gameId: string): Promise<string>;
|
|
46410
46425
|
/**
|
|
46411
46426
|
* Perform a game action (fold, call, raise, etc.)
|
|
46412
46427
|
* The keeper calculates the action index automatically
|
|
@@ -46417,6 +46432,32 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46417
46432
|
* @param data - Optional data string (e.g., entropy for deal action)
|
|
46418
46433
|
*/
|
|
46419
46434
|
performAction(gameId: string, action: string, amount?: bigint, data?: string): Promise<string>;
|
|
46435
|
+
/**
|
|
46436
|
+
* Fast-path variant of {@link performAction}. Broadcasts in SYNC mode —
|
|
46437
|
+
* returns as soon as the tx passes CheckTx (mempool admission), without
|
|
46438
|
+
* waiting for block inclusion. Typical return latency is ~50–100ms vs
|
|
46439
|
+
* 5+ seconds for {@link performAction}.
|
|
46440
|
+
*
|
|
46441
|
+
* **The tx is NOT yet executed when this returns.** The caller MUST
|
|
46442
|
+
* reconcile authoritative state via the chain's WebSocket push, which
|
|
46443
|
+
* fires after block commit. Pair this with optimistic UI rendering
|
|
46444
|
+
* and a rollback path for the case where CheckTx succeeds but the
|
|
46445
|
+
* tx fails at DeliverTx (rare — illegal action that escaped local
|
|
46446
|
+
* validation, or block-time consensus surprises).
|
|
46447
|
+
*
|
|
46448
|
+
* Use cases:
|
|
46449
|
+
* - Frontend action submission where perceived latency matters.
|
|
46450
|
+
* - Any caller that has an independent path (WS, polling) to
|
|
46451
|
+
* learn the action's authoritative outcome.
|
|
46452
|
+
*
|
|
46453
|
+
* Do NOT use this for code paths that need the post-DeliverTx
|
|
46454
|
+
* `events` or `rawLog` — those are only populated by the BLOCK
|
|
46455
|
+
* variant. See block52/poker-vm#2104.
|
|
46456
|
+
*
|
|
46457
|
+
* Returns the tx hash on CheckTx success; throws if CheckTx
|
|
46458
|
+
* rejects (invalid signature, malformed msg, insufficient gas).
|
|
46459
|
+
*/
|
|
46460
|
+
performActionSync(gameId: string, action: string, amount?: bigint, data?: string): Promise<string>;
|
|
46420
46461
|
/**
|
|
46421
46462
|
* Top up a player's stack at a table
|
|
46422
46463
|
* The player must be seated at the table and have sufficient wallet balance.
|
package/dist/index.esm.js
CHANGED
|
@@ -55860,6 +55860,7 @@ var NonPlayerActionType;
|
|
|
55860
55860
|
(function (NonPlayerActionType) {
|
|
55861
55861
|
NonPlayerActionType["DEAD_SMALL_BLIND"] = "dead-small-blind";
|
|
55862
55862
|
NonPlayerActionType["DEAL"] = "deal";
|
|
55863
|
+
NonPlayerActionType["FORCE_CLOSE"] = "force-close";
|
|
55863
55864
|
NonPlayerActionType["JOIN"] = "join";
|
|
55864
55865
|
NonPlayerActionType["LEAVE"] = "leave";
|
|
55865
55866
|
NonPlayerActionType["NEW_HAND"] = "new-hand";
|
|
@@ -57947,6 +57948,45 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
57947
57948
|
throw error;
|
|
57948
57949
|
}
|
|
57949
57950
|
}
|
|
57951
|
+
/**
|
|
57952
|
+
* Force-close a poker game and refund every seated player.
|
|
57953
|
+
*
|
|
57954
|
+
* Only the table creator can invoke this. Distinct from `deleteGame()`:
|
|
57955
|
+
* `deleteGame` requires zero players, this kicks everyone off and refunds
|
|
57956
|
+
* their stacks (plus any current-hand contribution and queued top-up) to
|
|
57957
|
+
* their wallet, then deletes the table.
|
|
57958
|
+
*
|
|
57959
|
+
* Cash format only. Chain rejects SNG/Tournament — those have separate
|
|
57960
|
+
* cancellation semantics (see block52/poker-vm#2173).
|
|
57961
|
+
*/
|
|
57962
|
+
async forceCloseGame(gameId) {
|
|
57963
|
+
await this.initializeSigningClient();
|
|
57964
|
+
if (!this.signingClient || !this.wallet) {
|
|
57965
|
+
throw new Error("Signing client not initialized");
|
|
57966
|
+
}
|
|
57967
|
+
const [account] = await this.wallet.getAccounts();
|
|
57968
|
+
const creator = account.address;
|
|
57969
|
+
const msgForceCloseGame = {
|
|
57970
|
+
creator,
|
|
57971
|
+
gameId
|
|
57972
|
+
};
|
|
57973
|
+
const msg = {
|
|
57974
|
+
typeUrl: "/pokerchain.poker.v1.MsgForceCloseGame",
|
|
57975
|
+
value: msgForceCloseGame
|
|
57976
|
+
};
|
|
57977
|
+
const fee = gaslessFee();
|
|
57978
|
+
const memo = "Force-close poker game via SDK";
|
|
57979
|
+
console.log("🛑 Force-closing game:", { gameId });
|
|
57980
|
+
try {
|
|
57981
|
+
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
57982
|
+
console.log("✅ Force-close transaction successful:", result.transactionHash);
|
|
57983
|
+
return result.transactionHash;
|
|
57984
|
+
}
|
|
57985
|
+
catch (error) {
|
|
57986
|
+
console.error("❌ Force-close failed:", error);
|
|
57987
|
+
throw error;
|
|
57988
|
+
}
|
|
57989
|
+
}
|
|
57950
57990
|
/**
|
|
57951
57991
|
* Perform a game action (fold, call, raise, etc.)
|
|
57952
57992
|
* The keeper calculates the action index automatically
|
|
@@ -57995,6 +58035,64 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
57995
58035
|
throw error;
|
|
57996
58036
|
}
|
|
57997
58037
|
}
|
|
58038
|
+
/**
|
|
58039
|
+
* Fast-path variant of {@link performAction}. Broadcasts in SYNC mode —
|
|
58040
|
+
* returns as soon as the tx passes CheckTx (mempool admission), without
|
|
58041
|
+
* waiting for block inclusion. Typical return latency is ~50–100ms vs
|
|
58042
|
+
* 5+ seconds for {@link performAction}.
|
|
58043
|
+
*
|
|
58044
|
+
* **The tx is NOT yet executed when this returns.** The caller MUST
|
|
58045
|
+
* reconcile authoritative state via the chain's WebSocket push, which
|
|
58046
|
+
* fires after block commit. Pair this with optimistic UI rendering
|
|
58047
|
+
* and a rollback path for the case where CheckTx succeeds but the
|
|
58048
|
+
* tx fails at DeliverTx (rare — illegal action that escaped local
|
|
58049
|
+
* validation, or block-time consensus surprises).
|
|
58050
|
+
*
|
|
58051
|
+
* Use cases:
|
|
58052
|
+
* - Frontend action submission where perceived latency matters.
|
|
58053
|
+
* - Any caller that has an independent path (WS, polling) to
|
|
58054
|
+
* learn the action's authoritative outcome.
|
|
58055
|
+
*
|
|
58056
|
+
* Do NOT use this for code paths that need the post-DeliverTx
|
|
58057
|
+
* `events` or `rawLog` — those are only populated by the BLOCK
|
|
58058
|
+
* variant. See block52/poker-vm#2104.
|
|
58059
|
+
*
|
|
58060
|
+
* Returns the tx hash on CheckTx success; throws if CheckTx
|
|
58061
|
+
* rejects (invalid signature, malformed msg, insufficient gas).
|
|
58062
|
+
*/
|
|
58063
|
+
async performActionSync(gameId, action, amount = 0n, data) {
|
|
58064
|
+
await this.initializeSigningClient();
|
|
58065
|
+
if (!this.signingClient || !this.wallet) {
|
|
58066
|
+
throw new Error("Signing client not initialized");
|
|
58067
|
+
}
|
|
58068
|
+
const [account] = await this.wallet.getAccounts();
|
|
58069
|
+
const player = account.address;
|
|
58070
|
+
// Same msg shape as performAction — only the broadcast mode differs.
|
|
58071
|
+
const msgPerformAction = {
|
|
58072
|
+
player,
|
|
58073
|
+
gameId,
|
|
58074
|
+
action,
|
|
58075
|
+
amount: Long.fromString(amount.toString(), true),
|
|
58076
|
+
data: data || ""
|
|
58077
|
+
};
|
|
58078
|
+
const msg = {
|
|
58079
|
+
typeUrl: "/pokerchain.poker.v1.MsgPerformAction",
|
|
58080
|
+
value: msgPerformAction
|
|
58081
|
+
};
|
|
58082
|
+
const fee = gaslessFee();
|
|
58083
|
+
const memo = `Poker action (sync): ${action}`;
|
|
58084
|
+
try {
|
|
58085
|
+
// signAndBroadcastSync returns just the txhash, no DeliverTx
|
|
58086
|
+
// result. The caller waits on the WS push for the
|
|
58087
|
+
// authoritative outcome.
|
|
58088
|
+
const txHash = await this.signingClient.signAndBroadcastSync(player, [msg], fee, memo);
|
|
58089
|
+
return txHash;
|
|
58090
|
+
}
|
|
58091
|
+
catch (error) {
|
|
58092
|
+
console.error("❌ Action (sync) failed at CheckTx:", error);
|
|
58093
|
+
throw error;
|
|
58094
|
+
}
|
|
58095
|
+
}
|
|
57998
58096
|
/**
|
|
57999
58097
|
* Top up a player's stack at a table
|
|
58000
58098
|
* The player must be seated at the table and have sufficient wallet balance.
|