@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.d.ts +43 -0
- package/dist/index.esm.js +88 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -1
- package/dist/signingClient.d.ts +43 -0
- package/dist/signingClient.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -46487,6 +46487,49 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46487
46487
|
sequence: number;
|
|
46488
46488
|
accountNumber: number;
|
|
46489
46489
|
}>;
|
|
46490
|
+
/**
|
|
46491
|
+
* Resolves the signer data (account number + sequence + chain id) for a
|
|
46492
|
+
* sign-only message: uses the caller-supplied data when present (the
|
|
46493
|
+
* gateway settlement path tracks sequence locally so optimistic actions
|
|
46494
|
+
* don't query the stale committed value), else queries the account once.
|
|
46495
|
+
*/
|
|
46496
|
+
private resolveSignerData;
|
|
46497
|
+
/**
|
|
46498
|
+
* Signs a single cosmos message (no broadcast) and returns the base64 TxRaw
|
|
46499
|
+
* plus the signer data used — the sign-only primitive the money-mover
|
|
46500
|
+
* helpers below share with signPerformAction's gateway-settlement pattern.
|
|
46501
|
+
*/
|
|
46502
|
+
private signMsgOnly;
|
|
46503
|
+
/**
|
|
46504
|
+
* Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
|
|
46505
|
+
* broadcasting, returning the base64 TxRaw for the gateway to relay
|
|
46506
|
+
* (WS-first money-mover settlement, block52/poker-vm#2325). The player is
|
|
46507
|
+
* the signer — the gateway never moves funds on their behalf. Mirrors
|
|
46508
|
+
* joinGame()'s message shape and signPerformAction()'s sign-only return.
|
|
46509
|
+
*/
|
|
46510
|
+
signJoinGame(gameId: string, seat: number, buyInAmount: bigint, signerData?: SignerData): Promise<{
|
|
46511
|
+
base64: string;
|
|
46512
|
+
sequence: number;
|
|
46513
|
+
accountNumber: number;
|
|
46514
|
+
}>;
|
|
46515
|
+
/**
|
|
46516
|
+
* Sign-only MsgLeaveGame (no broadcast) — the chain decides the refund
|
|
46517
|
+
* from its own state; the message carries only {creator, gameId}. (#2325)
|
|
46518
|
+
*/
|
|
46519
|
+
signLeaveGame(gameId: string, signerData?: SignerData): Promise<{
|
|
46520
|
+
base64: string;
|
|
46521
|
+
sequence: number;
|
|
46522
|
+
accountNumber: number;
|
|
46523
|
+
}>;
|
|
46524
|
+
/**
|
|
46525
|
+
* Sign-only MsgTopUp (no broadcast) — escrow deposit added to the player's
|
|
46526
|
+
* stack; gateway relays it after PVM-verifying the optimistic apply. (#2325)
|
|
46527
|
+
*/
|
|
46528
|
+
signTopUp(gameId: string, amount: bigint, signerData?: SignerData): Promise<{
|
|
46529
|
+
base64: string;
|
|
46530
|
+
sequence: number;
|
|
46531
|
+
accountNumber: number;
|
|
46532
|
+
}>;
|
|
46490
46533
|
/**
|
|
46491
46534
|
* Top up a player's stack at a table
|
|
46492
46535
|
* The player must be seated at the table and have sufficient wallet balance.
|
package/dist/index.esm.js
CHANGED
|
@@ -61195,6 +61195,94 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61195
61195
|
const base64 = toBase64(txExports.TxRaw.encode(txRaw).finish());
|
|
61196
61196
|
return { base64, sequence: explicit.sequence, accountNumber: explicit.accountNumber };
|
|
61197
61197
|
}
|
|
61198
|
+
/**
|
|
61199
|
+
* Resolves the signer data (account number + sequence + chain id) for a
|
|
61200
|
+
* sign-only message: uses the caller-supplied data when present (the
|
|
61201
|
+
* gateway settlement path tracks sequence locally so optimistic actions
|
|
61202
|
+
* don't query the stale committed value), else queries the account once.
|
|
61203
|
+
*/
|
|
61204
|
+
async resolveSignerData(player, signerData) {
|
|
61205
|
+
if (signerData) {
|
|
61206
|
+
return signerData;
|
|
61207
|
+
}
|
|
61208
|
+
const accountInfo = await this.getAccount(player);
|
|
61209
|
+
return {
|
|
61210
|
+
accountNumber: Number(accountInfo.account.account_number),
|
|
61211
|
+
sequence: Number(accountInfo.account.sequence),
|
|
61212
|
+
chainId: this.config.chainId
|
|
61213
|
+
};
|
|
61214
|
+
}
|
|
61215
|
+
/**
|
|
61216
|
+
* Signs a single cosmos message (no broadcast) and returns the base64 TxRaw
|
|
61217
|
+
* plus the signer data used — the sign-only primitive the money-mover
|
|
61218
|
+
* helpers below share with signPerformAction's gateway-settlement pattern.
|
|
61219
|
+
*/
|
|
61220
|
+
async signMsgOnly(msg, memo, signerData) {
|
|
61221
|
+
await this.initializeSigningClient();
|
|
61222
|
+
if (!this.signingClient || !this.wallet) {
|
|
61223
|
+
throw new Error("Signing client not initialized");
|
|
61224
|
+
}
|
|
61225
|
+
const [account] = await this.wallet.getAccounts();
|
|
61226
|
+
const player = account.address;
|
|
61227
|
+
const explicit = await this.resolveSignerData(player, signerData);
|
|
61228
|
+
const txRaw = await this.signingClient.sign(player, [msg], gaslessFee(), memo, explicit);
|
|
61229
|
+
const base64 = toBase64(txExports.TxRaw.encode(txRaw).finish());
|
|
61230
|
+
return { base64, sequence: explicit.sequence, accountNumber: explicit.accountNumber };
|
|
61231
|
+
}
|
|
61232
|
+
/**
|
|
61233
|
+
* Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
|
|
61234
|
+
* broadcasting, returning the base64 TxRaw for the gateway to relay
|
|
61235
|
+
* (WS-first money-mover settlement, block52/poker-vm#2325). The player is
|
|
61236
|
+
* the signer — the gateway never moves funds on their behalf. Mirrors
|
|
61237
|
+
* joinGame()'s message shape and signPerformAction()'s sign-only return.
|
|
61238
|
+
*/
|
|
61239
|
+
async signJoinGame(gameId, seat, buyInAmount, signerData) {
|
|
61240
|
+
await this.initializeSigningClient();
|
|
61241
|
+
const [account] = await this.wallet.getAccounts();
|
|
61242
|
+
const msg = {
|
|
61243
|
+
typeUrl: "/pokerchain.poker.v1.MsgJoinGame",
|
|
61244
|
+
value: {
|
|
61245
|
+
player: account.address,
|
|
61246
|
+
gameId,
|
|
61247
|
+
seat: Long.fromNumber(seat, true),
|
|
61248
|
+
buyInAmount: Long.fromString(buyInAmount.toString(), true)
|
|
61249
|
+
}
|
|
61250
|
+
};
|
|
61251
|
+
return this.signMsgOnly(msg, "Join poker game (relay)", signerData);
|
|
61252
|
+
}
|
|
61253
|
+
/**
|
|
61254
|
+
* Sign-only MsgLeaveGame (no broadcast) — the chain decides the refund
|
|
61255
|
+
* from its own state; the message carries only {creator, gameId}. (#2325)
|
|
61256
|
+
*/
|
|
61257
|
+
async signLeaveGame(gameId, signerData) {
|
|
61258
|
+
await this.initializeSigningClient();
|
|
61259
|
+
const [account] = await this.wallet.getAccounts();
|
|
61260
|
+
const msg = {
|
|
61261
|
+
typeUrl: "/pokerchain.poker.v1.MsgLeaveGame",
|
|
61262
|
+
value: {
|
|
61263
|
+
creator: account.address,
|
|
61264
|
+
gameId
|
|
61265
|
+
}
|
|
61266
|
+
};
|
|
61267
|
+
return this.signMsgOnly(msg, "Leave poker game (relay)", signerData);
|
|
61268
|
+
}
|
|
61269
|
+
/**
|
|
61270
|
+
* Sign-only MsgTopUp (no broadcast) — escrow deposit added to the player's
|
|
61271
|
+
* stack; gateway relays it after PVM-verifying the optimistic apply. (#2325)
|
|
61272
|
+
*/
|
|
61273
|
+
async signTopUp(gameId, amount, signerData) {
|
|
61274
|
+
await this.initializeSigningClient();
|
|
61275
|
+
const [account] = await this.wallet.getAccounts();
|
|
61276
|
+
const msg = {
|
|
61277
|
+
typeUrl: "/pokerchain.poker.v1.MsgTopUp",
|
|
61278
|
+
value: {
|
|
61279
|
+
player: account.address,
|
|
61280
|
+
gameId,
|
|
61281
|
+
amount: Long.fromString(amount.toString(), true)
|
|
61282
|
+
}
|
|
61283
|
+
};
|
|
61284
|
+
return this.signMsgOnly(msg, "Top up poker stack (relay)", signerData);
|
|
61285
|
+
}
|
|
61198
61286
|
/**
|
|
61199
61287
|
* Top up a player's stack at a table
|
|
61200
61288
|
* The player must be seated at the table and have sufficient wallet balance.
|