@block52/poker-vm-sdk 1.2.7 → 1.2.9
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 +58 -0
- package/dist/index.esm.js +115 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +115 -1
- package/dist/index.js.map +1 -1
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts +7 -0
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts.map +1 -1
- package/dist/signingClient.d.ts +51 -0
- package/dist/signingClient.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -44938,6 +44938,13 @@ declare const MsgJoinGame: MessageFns<MsgJoinGame>;
|
|
|
44938
44938
|
interface MsgLeaveGame {
|
|
44939
44939
|
creator: string;
|
|
44940
44940
|
gameId: string;
|
|
44941
|
+
/**
|
|
44942
|
+
* finishing_order: place-1-first player addresses for an SNG that finalized
|
|
44943
|
+
* off-chain (WS-first money-movers, poker-vm#2325). Empty for cash games and
|
|
44944
|
+
* for SNGs the chain already finalized. The chain validates this ordering
|
|
44945
|
+
* and recomputes payouts with its own prize-pool math. (pokerchain#229)
|
|
44946
|
+
*/
|
|
44947
|
+
finishingOrder: string[];
|
|
44941
44948
|
}
|
|
44942
44949
|
declare const MsgLeaveGame: MessageFns<MsgLeaveGame>;
|
|
44943
44950
|
/** MsgDealCards defines the MsgDealCards message. */
|
|
@@ -46487,6 +46494,57 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46487
46494
|
sequence: number;
|
|
46488
46495
|
accountNumber: number;
|
|
46489
46496
|
}>;
|
|
46497
|
+
/**
|
|
46498
|
+
* Resolves the signer data (account number + sequence + chain id) for a
|
|
46499
|
+
* sign-only message: uses the caller-supplied data when present (the
|
|
46500
|
+
* gateway settlement path tracks sequence locally so optimistic actions
|
|
46501
|
+
* don't query the stale committed value), else queries the account once.
|
|
46502
|
+
*/
|
|
46503
|
+
private resolveSignerData;
|
|
46504
|
+
/**
|
|
46505
|
+
* Signs a single cosmos message (no broadcast) and returns the base64 TxRaw
|
|
46506
|
+
* plus the signer data used — the sign-only primitive the money-mover
|
|
46507
|
+
* helpers below share with signPerformAction's gateway-settlement pattern.
|
|
46508
|
+
*/
|
|
46509
|
+
private signMsgOnly;
|
|
46510
|
+
/**
|
|
46511
|
+
* Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
|
|
46512
|
+
* broadcasting, returning the base64 TxRaw for the gateway to relay
|
|
46513
|
+
* (WS-first money-mover settlement, block52/poker-vm#2325). The player is
|
|
46514
|
+
* the signer — the gateway never moves funds on their behalf. Mirrors
|
|
46515
|
+
* joinGame()'s message shape and signPerformAction()'s sign-only return.
|
|
46516
|
+
*/
|
|
46517
|
+
signJoinGame(gameId: string, seat: number, buyInAmount: bigint, signerData?: SignerData): Promise<{
|
|
46518
|
+
base64: string;
|
|
46519
|
+
sequence: number;
|
|
46520
|
+
accountNumber: number;
|
|
46521
|
+
}>;
|
|
46522
|
+
/**
|
|
46523
|
+
* Sign-only MsgLeaveGame (no broadcast). For cash games and SNGs the chain
|
|
46524
|
+
* already finalized, the chain decides the refund from its own state and
|
|
46525
|
+
* the message carries only {creator, gameId}. (#2325)
|
|
46526
|
+
*
|
|
46527
|
+
* For an SNG that finalized off-chain (WS-first money-movers — the gateway
|
|
46528
|
+
* never relays the tournament-ending gameplay action, so the chain's
|
|
46529
|
+
* Results are empty), pass `finishingOrder`: the place-1-first list of
|
|
46530
|
+
* player addresses. The chain validates the ordering and recomputes the
|
|
46531
|
+
* payouts from its own prize-pool math — this message supplies only the
|
|
46532
|
+
* ORDER, never any amount. (pokerchain#229)
|
|
46533
|
+
*/
|
|
46534
|
+
signLeaveGame(gameId: string, signerData?: SignerData, finishingOrder?: string[]): Promise<{
|
|
46535
|
+
base64: string;
|
|
46536
|
+
sequence: number;
|
|
46537
|
+
accountNumber: number;
|
|
46538
|
+
}>;
|
|
46539
|
+
/**
|
|
46540
|
+
* Sign-only MsgTopUp (no broadcast) — escrow deposit added to the player's
|
|
46541
|
+
* stack; gateway relays it after PVM-verifying the optimistic apply. (#2325)
|
|
46542
|
+
*/
|
|
46543
|
+
signTopUp(gameId: string, amount: bigint, signerData?: SignerData): Promise<{
|
|
46544
|
+
base64: string;
|
|
46545
|
+
sequence: number;
|
|
46546
|
+
accountNumber: number;
|
|
46547
|
+
}>;
|
|
46490
46548
|
/**
|
|
46491
46549
|
* Top up a player's stack at a table
|
|
46492
46550
|
* The player must be seated at the table and have sufficient wallet balance.
|
package/dist/index.esm.js
CHANGED
|
@@ -3240,7 +3240,7 @@ const MsgJoinGame = {
|
|
|
3240
3240
|
},
|
|
3241
3241
|
};
|
|
3242
3242
|
function createBaseMsgLeaveGame() {
|
|
3243
|
-
return { creator: "", gameId: "" };
|
|
3243
|
+
return { creator: "", gameId: "", finishingOrder: [] };
|
|
3244
3244
|
}
|
|
3245
3245
|
const MsgLeaveGame = {
|
|
3246
3246
|
encode(message, writer = new BinaryWriter()) {
|
|
@@ -3250,6 +3250,9 @@ const MsgLeaveGame = {
|
|
|
3250
3250
|
if (message.gameId !== "") {
|
|
3251
3251
|
writer.uint32(18).string(message.gameId);
|
|
3252
3252
|
}
|
|
3253
|
+
for (const v of message.finishingOrder) {
|
|
3254
|
+
writer.uint32(26).string(v);
|
|
3255
|
+
}
|
|
3253
3256
|
return writer;
|
|
3254
3257
|
},
|
|
3255
3258
|
decode(input, length) {
|
|
@@ -3273,6 +3276,13 @@ const MsgLeaveGame = {
|
|
|
3273
3276
|
message.gameId = reader.string();
|
|
3274
3277
|
continue;
|
|
3275
3278
|
}
|
|
3279
|
+
case 3: {
|
|
3280
|
+
if (tag !== 26) {
|
|
3281
|
+
break;
|
|
3282
|
+
}
|
|
3283
|
+
message.finishingOrder.push(reader.string());
|
|
3284
|
+
continue;
|
|
3285
|
+
}
|
|
3276
3286
|
}
|
|
3277
3287
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3278
3288
|
break;
|
|
@@ -3285,6 +3295,9 @@ const MsgLeaveGame = {
|
|
|
3285
3295
|
return {
|
|
3286
3296
|
creator: isSet$2b(object.creator) ? globalThis.String(object.creator) : "",
|
|
3287
3297
|
gameId: isSet$2b(object.gameId) ? globalThis.String(object.gameId) : "",
|
|
3298
|
+
finishingOrder: globalThis.Array.isArray(object?.finishingOrder)
|
|
3299
|
+
? object.finishingOrder.map((e) => globalThis.String(e))
|
|
3300
|
+
: [],
|
|
3288
3301
|
};
|
|
3289
3302
|
},
|
|
3290
3303
|
toJSON(message) {
|
|
@@ -3295,6 +3308,9 @@ const MsgLeaveGame = {
|
|
|
3295
3308
|
if (message.gameId !== "") {
|
|
3296
3309
|
obj.gameId = message.gameId;
|
|
3297
3310
|
}
|
|
3311
|
+
if (message.finishingOrder?.length) {
|
|
3312
|
+
obj.finishingOrder = message.finishingOrder;
|
|
3313
|
+
}
|
|
3298
3314
|
return obj;
|
|
3299
3315
|
},
|
|
3300
3316
|
create(base) {
|
|
@@ -3304,6 +3320,7 @@ const MsgLeaveGame = {
|
|
|
3304
3320
|
const message = createBaseMsgLeaveGame();
|
|
3305
3321
|
message.creator = object.creator ?? "";
|
|
3306
3322
|
message.gameId = object.gameId ?? "";
|
|
3323
|
+
message.finishingOrder = object.finishingOrder?.map((e) => e) || [];
|
|
3307
3324
|
return message;
|
|
3308
3325
|
},
|
|
3309
3326
|
};
|
|
@@ -61195,6 +61212,103 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61195
61212
|
const base64 = toBase64(txExports.TxRaw.encode(txRaw).finish());
|
|
61196
61213
|
return { base64, sequence: explicit.sequence, accountNumber: explicit.accountNumber };
|
|
61197
61214
|
}
|
|
61215
|
+
/**
|
|
61216
|
+
* Resolves the signer data (account number + sequence + chain id) for a
|
|
61217
|
+
* sign-only message: uses the caller-supplied data when present (the
|
|
61218
|
+
* gateway settlement path tracks sequence locally so optimistic actions
|
|
61219
|
+
* don't query the stale committed value), else queries the account once.
|
|
61220
|
+
*/
|
|
61221
|
+
async resolveSignerData(player, signerData) {
|
|
61222
|
+
if (signerData) {
|
|
61223
|
+
return signerData;
|
|
61224
|
+
}
|
|
61225
|
+
const accountInfo = await this.getAccount(player);
|
|
61226
|
+
return {
|
|
61227
|
+
accountNumber: Number(accountInfo.account.account_number),
|
|
61228
|
+
sequence: Number(accountInfo.account.sequence),
|
|
61229
|
+
chainId: this.config.chainId
|
|
61230
|
+
};
|
|
61231
|
+
}
|
|
61232
|
+
/**
|
|
61233
|
+
* Signs a single cosmos message (no broadcast) and returns the base64 TxRaw
|
|
61234
|
+
* plus the signer data used — the sign-only primitive the money-mover
|
|
61235
|
+
* helpers below share with signPerformAction's gateway-settlement pattern.
|
|
61236
|
+
*/
|
|
61237
|
+
async signMsgOnly(msg, memo, signerData) {
|
|
61238
|
+
await this.initializeSigningClient();
|
|
61239
|
+
if (!this.signingClient || !this.wallet) {
|
|
61240
|
+
throw new Error("Signing client not initialized");
|
|
61241
|
+
}
|
|
61242
|
+
const [account] = await this.wallet.getAccounts();
|
|
61243
|
+
const player = account.address;
|
|
61244
|
+
const explicit = await this.resolveSignerData(player, signerData);
|
|
61245
|
+
const txRaw = await this.signingClient.sign(player, [msg], gaslessFee(), memo, explicit);
|
|
61246
|
+
const base64 = toBase64(txExports.TxRaw.encode(txRaw).finish());
|
|
61247
|
+
return { base64, sequence: explicit.sequence, accountNumber: explicit.accountNumber };
|
|
61248
|
+
}
|
|
61249
|
+
/**
|
|
61250
|
+
* Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
|
|
61251
|
+
* broadcasting, returning the base64 TxRaw for the gateway to relay
|
|
61252
|
+
* (WS-first money-mover settlement, block52/poker-vm#2325). The player is
|
|
61253
|
+
* the signer — the gateway never moves funds on their behalf. Mirrors
|
|
61254
|
+
* joinGame()'s message shape and signPerformAction()'s sign-only return.
|
|
61255
|
+
*/
|
|
61256
|
+
async signJoinGame(gameId, seat, buyInAmount, signerData) {
|
|
61257
|
+
await this.initializeSigningClient();
|
|
61258
|
+
const [account] = await this.wallet.getAccounts();
|
|
61259
|
+
const msg = {
|
|
61260
|
+
typeUrl: "/pokerchain.poker.v1.MsgJoinGame",
|
|
61261
|
+
value: {
|
|
61262
|
+
player: account.address,
|
|
61263
|
+
gameId,
|
|
61264
|
+
seat: Long.fromNumber(seat, true),
|
|
61265
|
+
buyInAmount: Long.fromString(buyInAmount.toString(), true)
|
|
61266
|
+
}
|
|
61267
|
+
};
|
|
61268
|
+
return this.signMsgOnly(msg, "Join poker game (relay)", signerData);
|
|
61269
|
+
}
|
|
61270
|
+
/**
|
|
61271
|
+
* Sign-only MsgLeaveGame (no broadcast). For cash games and SNGs the chain
|
|
61272
|
+
* already finalized, the chain decides the refund from its own state and
|
|
61273
|
+
* the message carries only {creator, gameId}. (#2325)
|
|
61274
|
+
*
|
|
61275
|
+
* For an SNG that finalized off-chain (WS-first money-movers — the gateway
|
|
61276
|
+
* never relays the tournament-ending gameplay action, so the chain's
|
|
61277
|
+
* Results are empty), pass `finishingOrder`: the place-1-first list of
|
|
61278
|
+
* player addresses. The chain validates the ordering and recomputes the
|
|
61279
|
+
* payouts from its own prize-pool math — this message supplies only the
|
|
61280
|
+
* ORDER, never any amount. (pokerchain#229)
|
|
61281
|
+
*/
|
|
61282
|
+
async signLeaveGame(gameId, signerData, finishingOrder = []) {
|
|
61283
|
+
await this.initializeSigningClient();
|
|
61284
|
+
const [account] = await this.wallet.getAccounts();
|
|
61285
|
+
const msg = {
|
|
61286
|
+
typeUrl: "/pokerchain.poker.v1.MsgLeaveGame",
|
|
61287
|
+
value: {
|
|
61288
|
+
creator: account.address,
|
|
61289
|
+
gameId,
|
|
61290
|
+
finishingOrder
|
|
61291
|
+
}
|
|
61292
|
+
};
|
|
61293
|
+
return this.signMsgOnly(msg, "Leave poker game (relay)", signerData);
|
|
61294
|
+
}
|
|
61295
|
+
/**
|
|
61296
|
+
* Sign-only MsgTopUp (no broadcast) — escrow deposit added to the player's
|
|
61297
|
+
* stack; gateway relays it after PVM-verifying the optimistic apply. (#2325)
|
|
61298
|
+
*/
|
|
61299
|
+
async signTopUp(gameId, amount, signerData) {
|
|
61300
|
+
await this.initializeSigningClient();
|
|
61301
|
+
const [account] = await this.wallet.getAccounts();
|
|
61302
|
+
const msg = {
|
|
61303
|
+
typeUrl: "/pokerchain.poker.v1.MsgTopUp",
|
|
61304
|
+
value: {
|
|
61305
|
+
player: account.address,
|
|
61306
|
+
gameId,
|
|
61307
|
+
amount: Long.fromString(amount.toString(), true)
|
|
61308
|
+
}
|
|
61309
|
+
};
|
|
61310
|
+
return this.signMsgOnly(msg, "Top up poker stack (relay)", signerData);
|
|
61311
|
+
}
|
|
61198
61312
|
/**
|
|
61199
61313
|
* Top up a player's stack at a table
|
|
61200
61314
|
* The player must be seated at the table and have sufficient wallet balance.
|