@block52/poker-vm-sdk 1.2.7 → 1.2.8

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
@@ -61197,6 +61197,94 @@ class SigningCosmosClient extends CosmosClient {
61197
61197
  const base64 = encoding.toBase64(txExports.TxRaw.encode(txRaw).finish());
61198
61198
  return { base64, sequence: explicit.sequence, accountNumber: explicit.accountNumber };
61199
61199
  }
61200
+ /**
61201
+ * Resolves the signer data (account number + sequence + chain id) for a
61202
+ * sign-only message: uses the caller-supplied data when present (the
61203
+ * gateway settlement path tracks sequence locally so optimistic actions
61204
+ * don't query the stale committed value), else queries the account once.
61205
+ */
61206
+ async resolveSignerData(player, signerData) {
61207
+ if (signerData) {
61208
+ return signerData;
61209
+ }
61210
+ const accountInfo = await this.getAccount(player);
61211
+ return {
61212
+ accountNumber: Number(accountInfo.account.account_number),
61213
+ sequence: Number(accountInfo.account.sequence),
61214
+ chainId: this.config.chainId
61215
+ };
61216
+ }
61217
+ /**
61218
+ * Signs a single cosmos message (no broadcast) and returns the base64 TxRaw
61219
+ * plus the signer data used — the sign-only primitive the money-mover
61220
+ * helpers below share with signPerformAction's gateway-settlement pattern.
61221
+ */
61222
+ async signMsgOnly(msg, memo, signerData) {
61223
+ await this.initializeSigningClient();
61224
+ if (!this.signingClient || !this.wallet) {
61225
+ throw new Error("Signing client not initialized");
61226
+ }
61227
+ const [account] = await this.wallet.getAccounts();
61228
+ const player = account.address;
61229
+ const explicit = await this.resolveSignerData(player, signerData);
61230
+ const txRaw = await this.signingClient.sign(player, [msg], gaslessFee(), memo, explicit);
61231
+ const base64 = encoding.toBase64(txExports.TxRaw.encode(txRaw).finish());
61232
+ return { base64, sequence: explicit.sequence, accountNumber: explicit.accountNumber };
61233
+ }
61234
+ /**
61235
+ * Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
61236
+ * broadcasting, returning the base64 TxRaw for the gateway to relay
61237
+ * (WS-first money-mover settlement, block52/poker-vm#2325). The player is
61238
+ * the signer — the gateway never moves funds on their behalf. Mirrors
61239
+ * joinGame()'s message shape and signPerformAction()'s sign-only return.
61240
+ */
61241
+ async signJoinGame(gameId, seat, buyInAmount, signerData) {
61242
+ await this.initializeSigningClient();
61243
+ const [account] = await this.wallet.getAccounts();
61244
+ const msg = {
61245
+ typeUrl: "/pokerchain.poker.v1.MsgJoinGame",
61246
+ value: {
61247
+ player: account.address,
61248
+ gameId,
61249
+ seat: Long.fromNumber(seat, true),
61250
+ buyInAmount: Long.fromString(buyInAmount.toString(), true)
61251
+ }
61252
+ };
61253
+ return this.signMsgOnly(msg, "Join poker game (relay)", signerData);
61254
+ }
61255
+ /**
61256
+ * Sign-only MsgLeaveGame (no broadcast) — the chain decides the refund
61257
+ * from its own state; the message carries only {creator, gameId}. (#2325)
61258
+ */
61259
+ async signLeaveGame(gameId, signerData) {
61260
+ await this.initializeSigningClient();
61261
+ const [account] = await this.wallet.getAccounts();
61262
+ const msg = {
61263
+ typeUrl: "/pokerchain.poker.v1.MsgLeaveGame",
61264
+ value: {
61265
+ creator: account.address,
61266
+ gameId
61267
+ }
61268
+ };
61269
+ return this.signMsgOnly(msg, "Leave poker game (relay)", signerData);
61270
+ }
61271
+ /**
61272
+ * Sign-only MsgTopUp (no broadcast) — escrow deposit added to the player's
61273
+ * stack; gateway relays it after PVM-verifying the optimistic apply. (#2325)
61274
+ */
61275
+ async signTopUp(gameId, amount, signerData) {
61276
+ await this.initializeSigningClient();
61277
+ const [account] = await this.wallet.getAccounts();
61278
+ const msg = {
61279
+ typeUrl: "/pokerchain.poker.v1.MsgTopUp",
61280
+ value: {
61281
+ player: account.address,
61282
+ gameId,
61283
+ amount: Long.fromString(amount.toString(), true)
61284
+ }
61285
+ };
61286
+ return this.signMsgOnly(msg, "Top up poker stack (relay)", signerData);
61287
+ }
61200
61288
  /**
61201
61289
  * Top up a player's stack at a table
61202
61290
  * The player must be seated at the table and have sufficient wallet balance.