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