@block52/poker-vm-sdk 1.2.9 → 1.2.12

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.js CHANGED
@@ -3326,6 +3326,89 @@ const MsgLeaveGame = {
3326
3326
  return message;
3327
3327
  },
3328
3328
  };
3329
+ function createBaseMsgRecordHandEnd() {
3330
+ return { creator: "", gameId: "", gameState: "" };
3331
+ }
3332
+ const MsgRecordHandEnd = {
3333
+ encode(message, writer = new BinaryWriter()) {
3334
+ if (message.creator !== "") {
3335
+ writer.uint32(10).string(message.creator);
3336
+ }
3337
+ if (message.gameId !== "") {
3338
+ writer.uint32(18).string(message.gameId);
3339
+ }
3340
+ if (message.gameState !== "") {
3341
+ writer.uint32(26).string(message.gameState);
3342
+ }
3343
+ return writer;
3344
+ },
3345
+ decode(input, length) {
3346
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
3347
+ const end = length === undefined ? reader.len : reader.pos + length;
3348
+ const message = createBaseMsgRecordHandEnd();
3349
+ while (reader.pos < end) {
3350
+ const tag = reader.uint32();
3351
+ switch (tag >>> 3) {
3352
+ case 1: {
3353
+ if (tag !== 10) {
3354
+ break;
3355
+ }
3356
+ message.creator = reader.string();
3357
+ continue;
3358
+ }
3359
+ case 2: {
3360
+ if (tag !== 18) {
3361
+ break;
3362
+ }
3363
+ message.gameId = reader.string();
3364
+ continue;
3365
+ }
3366
+ case 3: {
3367
+ if (tag !== 26) {
3368
+ break;
3369
+ }
3370
+ message.gameState = reader.string();
3371
+ continue;
3372
+ }
3373
+ }
3374
+ if ((tag & 7) === 4 || tag === 0) {
3375
+ break;
3376
+ }
3377
+ reader.skip(tag & 7);
3378
+ }
3379
+ return message;
3380
+ },
3381
+ fromJSON(object) {
3382
+ return {
3383
+ creator: isSet$2b(object.creator) ? globalThis.String(object.creator) : "",
3384
+ gameId: isSet$2b(object.gameId) ? globalThis.String(object.gameId) : "",
3385
+ gameState: isSet$2b(object.gameState) ? globalThis.String(object.gameState) : "",
3386
+ };
3387
+ },
3388
+ toJSON(message) {
3389
+ const obj = {};
3390
+ if (message.creator !== "") {
3391
+ obj.creator = message.creator;
3392
+ }
3393
+ if (message.gameId !== "") {
3394
+ obj.gameId = message.gameId;
3395
+ }
3396
+ if (message.gameState !== "") {
3397
+ obj.gameState = message.gameState;
3398
+ }
3399
+ return obj;
3400
+ },
3401
+ create(base) {
3402
+ return MsgRecordHandEnd.fromPartial(base ?? {});
3403
+ },
3404
+ fromPartial(object) {
3405
+ const message = createBaseMsgRecordHandEnd();
3406
+ message.creator = object.creator ?? "";
3407
+ message.gameId = object.gameId ?? "";
3408
+ message.gameState = object.gameState ?? "";
3409
+ return message;
3410
+ },
3411
+ };
3329
3412
  function createBaseMsgDealCards() {
3330
3413
  return { creator: "", gameId: "" };
3331
3414
  }
@@ -4378,6 +4461,7 @@ const msgTypes$u = [
4378
4461
  ["/pokerchain.poker.v1.MsgCreateGame", MsgCreateGame],
4379
4462
  ["/pokerchain.poker.v1.MsgJoinGame", MsgJoinGame],
4380
4463
  ["/pokerchain.poker.v1.MsgLeaveGame", MsgLeaveGame],
4464
+ ["/pokerchain.poker.v1.MsgRecordHandEnd", MsgRecordHandEnd],
4381
4465
  ["/pokerchain.poker.v1.MsgDealCards", MsgDealCards],
4382
4466
  ["/pokerchain.poker.v1.MsgPerformAction", MsgPerformAction],
4383
4467
  ["/pokerchain.poker.v1.MsgMint", MsgMint],
@@ -60988,6 +61072,37 @@ class SigningCosmosClient extends CosmosClient {
60988
61072
  throw error;
60989
61073
  }
60990
61074
  }
61075
+ /**
61076
+ * Record a hand-end game-state snapshot on the chain (pokerchain#239).
61077
+ *
61078
+ * Signed and broadcast directly by the player who finished the position
61079
+ * being recorded (e.g. the 4th-place finisher pushes the state that records
61080
+ * 4th place), so a finished SNG's results reach the chain and the prize pool
61081
+ * becomes claimable. `gameState` is the hand-end TexasHoldemStateDTO,
61082
+ * JSON-encoded (the canonical shape the chain stores in GameStates).
61083
+ */
61084
+ async recordHandEnd(gameId, gameState) {
61085
+ await this.initializeSigningClient();
61086
+ if (!this.signingClient || !this.wallet) {
61087
+ throw new Error("Signing client not initialized");
61088
+ }
61089
+ const [account] = await this.wallet.getAccounts();
61090
+ const creator = account.address;
61091
+ const msg = {
61092
+ typeUrl: "/pokerchain.poker.v1.MsgRecordHandEnd",
61093
+ value: { creator, gameId, gameState }
61094
+ };
61095
+ const fee = gaslessFee();
61096
+ const memo = "Record hand end via SDK";
61097
+ try {
61098
+ const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
61099
+ return result.transactionHash;
61100
+ }
61101
+ catch (error) {
61102
+ console.error("❌ Record hand end failed:", error);
61103
+ throw error;
61104
+ }
61105
+ }
60991
61106
  /**
60992
61107
  * Delete a poker game
60993
61108
  * Only the game creator can delete a game, and the game must have no active players