@block52/poker-vm-sdk 1.1.18 → 1.2.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.js CHANGED
@@ -57997,6 +57997,64 @@ class SigningCosmosClient extends CosmosClient {
57997
57997
  throw error;
57998
57998
  }
57999
57999
  }
58000
+ /**
58001
+ * Fast-path variant of {@link performAction}. Broadcasts in SYNC mode —
58002
+ * returns as soon as the tx passes CheckTx (mempool admission), without
58003
+ * waiting for block inclusion. Typical return latency is ~50–100ms vs
58004
+ * 5+ seconds for {@link performAction}.
58005
+ *
58006
+ * **The tx is NOT yet executed when this returns.** The caller MUST
58007
+ * reconcile authoritative state via the chain's WebSocket push, which
58008
+ * fires after block commit. Pair this with optimistic UI rendering
58009
+ * and a rollback path for the case where CheckTx succeeds but the
58010
+ * tx fails at DeliverTx (rare — illegal action that escaped local
58011
+ * validation, or block-time consensus surprises).
58012
+ *
58013
+ * Use cases:
58014
+ * - Frontend action submission where perceived latency matters.
58015
+ * - Any caller that has an independent path (WS, polling) to
58016
+ * learn the action's authoritative outcome.
58017
+ *
58018
+ * Do NOT use this for code paths that need the post-DeliverTx
58019
+ * `events` or `rawLog` — those are only populated by the BLOCK
58020
+ * variant. See block52/poker-vm#2104.
58021
+ *
58022
+ * Returns the tx hash on CheckTx success; throws if CheckTx
58023
+ * rejects (invalid signature, malformed msg, insufficient gas).
58024
+ */
58025
+ async performActionSync(gameId, action, amount = 0n, data) {
58026
+ await this.initializeSigningClient();
58027
+ if (!this.signingClient || !this.wallet) {
58028
+ throw new Error("Signing client not initialized");
58029
+ }
58030
+ const [account] = await this.wallet.getAccounts();
58031
+ const player = account.address;
58032
+ // Same msg shape as performAction — only the broadcast mode differs.
58033
+ const msgPerformAction = {
58034
+ player,
58035
+ gameId,
58036
+ action,
58037
+ amount: Long.fromString(amount.toString(), true),
58038
+ data: data || ""
58039
+ };
58040
+ const msg = {
58041
+ typeUrl: "/pokerchain.poker.v1.MsgPerformAction",
58042
+ value: msgPerformAction
58043
+ };
58044
+ const fee = gaslessFee();
58045
+ const memo = `Poker action (sync): ${action}`;
58046
+ try {
58047
+ // signAndBroadcastSync returns just the txhash, no DeliverTx
58048
+ // result. The caller waits on the WS push for the
58049
+ // authoritative outcome.
58050
+ const txHash = await this.signingClient.signAndBroadcastSync(player, [msg], fee, memo);
58051
+ return txHash;
58052
+ }
58053
+ catch (error) {
58054
+ console.error("❌ Action (sync) failed at CheckTx:", error);
58055
+ throw error;
58056
+ }
58057
+ }
58000
58058
  /**
58001
58059
  * Top up a player's stack at a table
58002
58060
  * The player must be seated at the table and have sufficient wallet balance.