@block52/poker-vm-sdk 1.3.5 → 1.4.1
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 +102 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +189 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +193 -20
- package/dist/index.js.map +1 -1
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts +5 -0
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts.map +1 -1
- package/dist/signingClient.d.ts +14 -1
- package/dist/signingClient.d.ts.map +1 -1
- package/dist/txResult.d.ts +63 -0
- package/dist/txResult.d.ts.map +1 -0
- package/dist/types/game.d.ts +18 -0
- package/dist/types/game.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2846,6 +2846,7 @@ function createBaseMsgCreateGame() {
|
|
|
2846
2846
|
blindLevelDuration: 0,
|
|
2847
2847
|
gameVariant: "",
|
|
2848
2848
|
entryFee: Long.UZERO,
|
|
2849
|
+
name: "",
|
|
2849
2850
|
};
|
|
2850
2851
|
}
|
|
2851
2852
|
const MsgCreateGame = {
|
|
@@ -2901,6 +2902,9 @@ const MsgCreateGame = {
|
|
|
2901
2902
|
if (!message.entryFee.equals(Long.UZERO)) {
|
|
2902
2903
|
writer.uint32(136).uint64(message.entryFee.toString());
|
|
2903
2904
|
}
|
|
2905
|
+
if (message.name !== "") {
|
|
2906
|
+
writer.uint32(154).string(message.name);
|
|
2907
|
+
}
|
|
2904
2908
|
return writer;
|
|
2905
2909
|
},
|
|
2906
2910
|
decode(input, length) {
|
|
@@ -3029,6 +3033,13 @@ const MsgCreateGame = {
|
|
|
3029
3033
|
message.entryFee = Long.fromString(reader.uint64().toString(), true);
|
|
3030
3034
|
continue;
|
|
3031
3035
|
}
|
|
3036
|
+
case 19: {
|
|
3037
|
+
if (tag !== 154) {
|
|
3038
|
+
break;
|
|
3039
|
+
}
|
|
3040
|
+
message.name = reader.string();
|
|
3041
|
+
continue;
|
|
3042
|
+
}
|
|
3032
3043
|
}
|
|
3033
3044
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3034
3045
|
break;
|
|
@@ -3056,6 +3067,7 @@ const MsgCreateGame = {
|
|
|
3056
3067
|
blindLevelDuration: isSet$2b(object.blindLevelDuration) ? globalThis.Number(object.blindLevelDuration) : 0,
|
|
3057
3068
|
gameVariant: isSet$2b(object.gameVariant) ? globalThis.String(object.gameVariant) : "",
|
|
3058
3069
|
entryFee: isSet$2b(object.entryFee) ? Long.fromValue(object.entryFee) : Long.UZERO,
|
|
3070
|
+
name: isSet$2b(object.name) ? globalThis.String(object.name) : "",
|
|
3059
3071
|
};
|
|
3060
3072
|
},
|
|
3061
3073
|
toJSON(message) {
|
|
@@ -3111,6 +3123,9 @@ const MsgCreateGame = {
|
|
|
3111
3123
|
if (!message.entryFee.equals(Long.UZERO)) {
|
|
3112
3124
|
obj.entryFee = (message.entryFee || Long.UZERO).toString();
|
|
3113
3125
|
}
|
|
3126
|
+
if (message.name !== "") {
|
|
3127
|
+
obj.name = message.name;
|
|
3128
|
+
}
|
|
3114
3129
|
return obj;
|
|
3115
3130
|
},
|
|
3116
3131
|
create(base) {
|
|
@@ -3154,6 +3169,7 @@ const MsgCreateGame = {
|
|
|
3154
3169
|
: Long.UZERO;
|
|
3155
3170
|
message.blindLevelDuration = object.blindLevelDuration ?? 0;
|
|
3156
3171
|
message.gameVariant = object.gameVariant ?? "";
|
|
3172
|
+
message.name = object.name ?? "";
|
|
3157
3173
|
message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
|
|
3158
3174
|
? Long.fromValue(object.entryFee)
|
|
3159
3175
|
: Long.UZERO;
|
|
@@ -56151,6 +56167,14 @@ exports.NonPlayerActionType = void 0;
|
|
|
56151
56167
|
// so each has a single responsibility. Sets WAITING_FOR_BIG_BLIND. (#2139)
|
|
56152
56168
|
NonPlayerActionType["SIT_IN_AND_WAIT"] = "sit-in-and-wait";
|
|
56153
56169
|
NonPlayerActionType["SIT_OUT"] = "sit-out";
|
|
56170
|
+
// Action clock enforcement (poker-vm#2523): submitted by ANY address once the
|
|
56171
|
+
// next-to-act player's turn deadline (last recorded action timestamp +
|
|
56172
|
+
// gameOptions.timeout seconds) has passed. The engine plays that player's
|
|
56173
|
+
// forced default action on their behalf — CHECK if legal else FOLD in a
|
|
56174
|
+
// betting round, the owed blind post or DEAL in ANTE, MUCK if legal else
|
|
56175
|
+
// SHOW at showdown — and records THAT action; no "timeout" turn is ever
|
|
56176
|
+
// written to previousActions. Rejected while the turn has time remaining.
|
|
56177
|
+
NonPlayerActionType["TIMEOUT"] = "timeout";
|
|
56154
56178
|
NonPlayerActionType["TOP_UP"] = "top-up";
|
|
56155
56179
|
})(exports.NonPlayerActionType || (exports.NonPlayerActionType = {}));
|
|
56156
56180
|
const AllPlayerActions = { ...exports.PlayerActionType, ...exports.NonPlayerActionType };
|
|
@@ -56222,6 +56246,20 @@ exports.SUIT = void 0;
|
|
|
56222
56246
|
SUIT[SUIT["HEARTS"] = 3] = "HEARTS";
|
|
56223
56247
|
SUIT[SUIT["SPADES"] = 4] = "SPADES";
|
|
56224
56248
|
})(exports.SUIT || (exports.SUIT = {}));
|
|
56249
|
+
/**
|
|
56250
|
+
* Cost of ONE character of a paid table name, in micro-USDC ($0.10). The total
|
|
56251
|
+
* naming fee is `length * GAME_NAME_MICRO_PER_CHAR`, charged on top of the
|
|
56252
|
+
* game-creation cost and paid to validators. This is the SINGLE SOURCE OF TRUTH
|
|
56253
|
+
* for the price so the UI preview and the chain agree. (block52/pokerchain#337)
|
|
56254
|
+
*/
|
|
56255
|
+
const GAME_NAME_MICRO_PER_CHAR = 100000n;
|
|
56256
|
+
/** Maximum table-name length (code points); bounds the max fee at 32 * $0.10. */
|
|
56257
|
+
const MAX_GAME_NAME_LENGTH = 32;
|
|
56258
|
+
/**
|
|
56259
|
+
* Total naming fee (micro-USDC) for a table name: $0.10 per character. Counts
|
|
56260
|
+
* code points to match the chain's rune-based charge. An empty name is free.
|
|
56261
|
+
*/
|
|
56262
|
+
const computeGameNameFee = (name) => BigInt([...name].length) * GAME_NAME_MICRO_PER_CHAR;
|
|
56225
56263
|
// Constants for URL parameters
|
|
56226
56264
|
const KEYS = {
|
|
56227
56265
|
ACTION_TYPE: "action_type",
|
|
@@ -61126,6 +61164,79 @@ function requireTx () {
|
|
|
61126
61164
|
|
|
61127
61165
|
var txExports = requireTx();
|
|
61128
61166
|
|
|
61167
|
+
/**
|
|
61168
|
+
* Thrown when a transaction was broadcast and included in a block but its
|
|
61169
|
+
* EXECUTION failed (nonzero `DeliverTxResponse.code`). The hash, code and raw
|
|
61170
|
+
* log are retained so the failure can be looked up and shown. (#2609)
|
|
61171
|
+
*/
|
|
61172
|
+
class TxExecutionError extends Error {
|
|
61173
|
+
constructor(operation, result) {
|
|
61174
|
+
super(`Failed to ${operation}: transaction ${result.transactionHash} failed with code ${result.code}` +
|
|
61175
|
+
(result.rawLog ? ` — ${result.rawLog}` : ""));
|
|
61176
|
+
this.name = "TxExecutionError";
|
|
61177
|
+
this.transactionHash = result.transactionHash;
|
|
61178
|
+
this.code = result.code;
|
|
61179
|
+
this.rawLog = result.rawLog;
|
|
61180
|
+
}
|
|
61181
|
+
}
|
|
61182
|
+
/**
|
|
61183
|
+
* Assert that a broadcast transaction actually EXECUTED successfully.
|
|
61184
|
+
*
|
|
61185
|
+
* CosmJS resolves `signAndBroadcast` normally when execution fails — a nonzero
|
|
61186
|
+
* `DeliverTxResponse.code` is the only failure signal, and it is easy to miss
|
|
61187
|
+
* because nothing throws. Returning `result.transactionHash` without checking
|
|
61188
|
+
* reports "insufficient funds" and "invalid request" to the caller as success.
|
|
61189
|
+
*
|
|
61190
|
+
* Every SDK method that broadcasts and waits for inclusion goes through this.
|
|
61191
|
+
* The exception is `performActionSync`, which returns a CheckTx-only hash by
|
|
61192
|
+
* design and whose caller waits on a WebSocket push for the committed result —
|
|
61193
|
+
* see the comment there before adding a check to it.
|
|
61194
|
+
*/
|
|
61195
|
+
function assertExecuted(operation, result) {
|
|
61196
|
+
// A real DeliverTxResponse always carries `code`. If it is missing we cannot
|
|
61197
|
+
// tell success from failure, so fail closed and say why — reporting it as
|
|
61198
|
+
// "code undefined" would send someone hunting a chain error that does not
|
|
61199
|
+
// exist, when the actual problem is a malformed response or a partial mock.
|
|
61200
|
+
if (typeof result?.code !== "number") {
|
|
61201
|
+
throw new Error(`Failed to ${operation}: broadcast response has no execution code, so success cannot be confirmed ` +
|
|
61202
|
+
`(transaction ${result?.transactionHash ?? "unknown"})`);
|
|
61203
|
+
}
|
|
61204
|
+
if (result.code !== 0) {
|
|
61205
|
+
throw new TxExecutionError(operation, result);
|
|
61206
|
+
}
|
|
61207
|
+
}
|
|
61208
|
+
/**
|
|
61209
|
+
* Classify an error thrown by an SDK broadcast method. Returns `undefined` for
|
|
61210
|
+
* errors raised before any broadcast (argument validation, no wallet, signing)
|
|
61211
|
+
* or by another layer (REST queries, network) — those carry no transaction.
|
|
61212
|
+
*/
|
|
61213
|
+
function txFailurePhase(error) {
|
|
61214
|
+
if (error instanceof TxExecutionError) {
|
|
61215
|
+
return "execution-failed";
|
|
61216
|
+
}
|
|
61217
|
+
if (error instanceof stargate.BroadcastTxError) {
|
|
61218
|
+
return "not-broadcast";
|
|
61219
|
+
}
|
|
61220
|
+
if (error instanceof stargate.TimeoutError) {
|
|
61221
|
+
return "unknown";
|
|
61222
|
+
}
|
|
61223
|
+
return undefined;
|
|
61224
|
+
}
|
|
61225
|
+
/**
|
|
61226
|
+
* The hash of the transaction behind a failed broadcast call, when one exists:
|
|
61227
|
+
* the included-but-failed tx for `"execution-failed"`, the pending tx for
|
|
61228
|
+
* `"unknown"`. `"not-broadcast"` and pre-broadcast errors have none.
|
|
61229
|
+
*/
|
|
61230
|
+
function txFailureHash(error) {
|
|
61231
|
+
if (error instanceof TxExecutionError) {
|
|
61232
|
+
return error.transactionHash;
|
|
61233
|
+
}
|
|
61234
|
+
if (error instanceof stargate.TimeoutError) {
|
|
61235
|
+
return error.txId;
|
|
61236
|
+
}
|
|
61237
|
+
return undefined;
|
|
61238
|
+
}
|
|
61239
|
+
|
|
61129
61240
|
/**
|
|
61130
61241
|
* Default gas limit for all transactions
|
|
61131
61242
|
*/
|
|
@@ -61134,6 +61245,18 @@ const DEFAULT_GAS_LIMIT = 1000000;
|
|
|
61134
61245
|
// hand-building an unordered TxBody (signUnordered). Module-level so it's built
|
|
61135
61246
|
// once and shared with the stargate client's registry semantics.
|
|
61136
61247
|
const pokerRegistry = new protoSigning.Registry(msgTypes$u);
|
|
61248
|
+
// The chain dedups unordered txs on (signer, timeout_timestamp), so two txs
|
|
61249
|
+
// from one account must never share a timeout. Date has millisecond resolution
|
|
61250
|
+
// and a client fires blind + deal + action back to back, so track the last
|
|
61251
|
+
// timeout handed out per signer and keep it strictly increasing. Module-level:
|
|
61252
|
+
// callers rebuild the client (e.g. after a transport error) mid-session.
|
|
61253
|
+
const lastUnorderedTimeoutMs = new Map();
|
|
61254
|
+
function nextUnorderedTimeoutMs(signer, ttlSeconds) {
|
|
61255
|
+
const wanted = Date.now() + ttlSeconds * 1000;
|
|
61256
|
+
const timeoutMs = Math.max(wanted, (lastUnorderedTimeoutMs.get(signer) ?? 0) + 1);
|
|
61257
|
+
lastUnorderedTimeoutMs.set(signer, timeoutMs);
|
|
61258
|
+
return timeoutMs;
|
|
61259
|
+
}
|
|
61137
61260
|
/**
|
|
61138
61261
|
* Create a gasless fee object with specified gas limit
|
|
61139
61262
|
* Chain is configured with min-gas-prices = "0stake" so no fee tokens required
|
|
@@ -61159,6 +61282,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61159
61282
|
gasPrice: typeof config.gasPrice === 'string' ? config.gasPrice : (config.gasPrice?.toString() || COSMOS_CONSTANTS.DEFAULT_GAS_PRICE)
|
|
61160
61283
|
};
|
|
61161
61284
|
super(baseConfig);
|
|
61285
|
+
this.accountNumbers = new Map();
|
|
61162
61286
|
this.wallet = config.wallet;
|
|
61163
61287
|
// Handle gasPrice - convert string to GasPrice if needed
|
|
61164
61288
|
if (typeof config.gasPrice === 'string') {
|
|
@@ -61216,18 +61340,21 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61216
61340
|
const coins = [{ denom: denom, amount: amount.toString() }];
|
|
61217
61341
|
const fee = gaslessFee();
|
|
61218
61342
|
const result = await this.signingClient.sendTokens(fromAddress, toAddress, coins, fee, memo || "");
|
|
61343
|
+
assertExecuted("send tokens", result);
|
|
61219
61344
|
return result.transactionHash;
|
|
61220
61345
|
}
|
|
61221
61346
|
/**
|
|
61222
61347
|
* Send B52USDC tokens
|
|
61223
61348
|
*/
|
|
61224
61349
|
async sendB52USDC(fromAddress, toAddress, amount, memo) {
|
|
61225
|
-
|
|
61350
|
+
// `denom` is the 4th parameter — passing `memo` here put the memo text
|
|
61351
|
+
// into the coin denom and always sent an empty memo.
|
|
61352
|
+
return this.sendTokens(fromAddress, toAddress, amount, undefined, memo);
|
|
61226
61353
|
}
|
|
61227
61354
|
/**
|
|
61228
61355
|
* Create a new poker game
|
|
61229
61356
|
*/
|
|
61230
|
-
async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig) {
|
|
61357
|
+
async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig, name) {
|
|
61231
61358
|
// Validate SNG/Tournament config BEFORE any network work — fail fast.
|
|
61232
61359
|
// SNG/Tournament games are DEFINED by startingStack + blindLevelDuration.
|
|
61233
61360
|
// Refuse to create one with missing/zero values rather than silently
|
|
@@ -61276,6 +61403,9 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61276
61403
|
blindLevelDuration: sngConfig?.blindLevelDuration ?? 0,
|
|
61277
61404
|
// SNG flat entry fee (micro-units), skimmed to the creator at join time (poker-vm#2118)
|
|
61278
61405
|
entryFee: sngConfig?.entryFee ? Long.fromString(sngConfig.entryFee.toString(), true) : Long.UZERO,
|
|
61406
|
+
// Optional ENS-style table name (block52/pokerchain#337). Empty = unnamed
|
|
61407
|
+
// (no fee); a non-empty name costs $0.10/char and must be globally unique.
|
|
61408
|
+
name: name ?? "",
|
|
61279
61409
|
});
|
|
61280
61410
|
// Create the transaction message
|
|
61281
61411
|
const msg = {
|
|
@@ -61309,6 +61439,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61309
61439
|
});
|
|
61310
61440
|
try {
|
|
61311
61441
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61442
|
+
assertExecuted("create game", result);
|
|
61312
61443
|
console.log("✅ Game creation transaction successful:", result.transactionHash);
|
|
61313
61444
|
return result.transactionHash;
|
|
61314
61445
|
}
|
|
@@ -61346,6 +61477,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61346
61477
|
console.log("🪑 Joining game:", { gameId, seat, buyInAmount: buyInAmount.toString() });
|
|
61347
61478
|
try {
|
|
61348
61479
|
const result = await this.signingClient.signAndBroadcast(player, [msg], fee, memo);
|
|
61480
|
+
assertExecuted("join game", result);
|
|
61349
61481
|
console.log("✅ Join game transaction successful:", result.transactionHash);
|
|
61350
61482
|
return result.transactionHash;
|
|
61351
61483
|
}
|
|
@@ -61393,6 +61525,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61393
61525
|
console.log("🚪 Leaving game:", { gameId });
|
|
61394
61526
|
try {
|
|
61395
61527
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61528
|
+
assertExecuted("leave game", result);
|
|
61396
61529
|
console.log("✅ Leave game transaction successful:", result.transactionHash);
|
|
61397
61530
|
return result.transactionHash;
|
|
61398
61531
|
}
|
|
@@ -61425,6 +61558,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61425
61558
|
const memo = "Record hand end via SDK";
|
|
61426
61559
|
try {
|
|
61427
61560
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61561
|
+
assertExecuted("record hand end", result);
|
|
61428
61562
|
return result.transactionHash;
|
|
61429
61563
|
}
|
|
61430
61564
|
catch (error) {
|
|
@@ -61458,6 +61592,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61458
61592
|
console.log("🗑️ Deleting game:", { gameId });
|
|
61459
61593
|
try {
|
|
61460
61594
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61595
|
+
assertExecuted("delete game", result);
|
|
61461
61596
|
console.log("✅ Delete game transaction successful:", result.transactionHash);
|
|
61462
61597
|
return result.transactionHash;
|
|
61463
61598
|
}
|
|
@@ -61497,6 +61632,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61497
61632
|
console.log("🛑 Force-closing game:", { gameId });
|
|
61498
61633
|
try {
|
|
61499
61634
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
61635
|
+
assertExecuted("force close game", result);
|
|
61500
61636
|
console.log("✅ Force-close transaction successful:", result.transactionHash);
|
|
61501
61637
|
return result.transactionHash;
|
|
61502
61638
|
}
|
|
@@ -61545,6 +61681,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61545
61681
|
});
|
|
61546
61682
|
try {
|
|
61547
61683
|
const result = await this.signingClient.signAndBroadcast(player, [msg], fee, memo);
|
|
61684
|
+
assertExecuted("perform action", result);
|
|
61548
61685
|
console.log("✅ Action transaction successful:", result.transactionHash);
|
|
61549
61686
|
return result.transactionHash;
|
|
61550
61687
|
}
|
|
@@ -61577,6 +61714,11 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61577
61714
|
*
|
|
61578
61715
|
* Returns the tx hash on CheckTx success; throws if CheckTx
|
|
61579
61716
|
* rejects (invalid signature, malformed msg, insufficient gas).
|
|
61717
|
+
*
|
|
61718
|
+
* Deliberately NOT routed through `assertExecuted` (#2609): there is no
|
|
61719
|
+
* DeliverTx result to check at this point — the hash is a CheckTx receipt,
|
|
61720
|
+
* and the execution outcome arrives over the WebSocket. Every other
|
|
61721
|
+
* broadcasting method in this class waits for inclusion and must check.
|
|
61580
61722
|
*/
|
|
61581
61723
|
async performActionSync(gameId, action, amount = 0n, data) {
|
|
61582
61724
|
await this.initializeSigningClient();
|
|
@@ -61585,26 +61727,30 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61585
61727
|
}
|
|
61586
61728
|
const [account] = await this.wallet.getAccounts();
|
|
61587
61729
|
const player = account.address;
|
|
61588
|
-
// Same msg shape as performAction — only
|
|
61589
|
-
const msgPerformAction = {
|
|
61590
|
-
player,
|
|
61591
|
-
gameId,
|
|
61592
|
-
action,
|
|
61593
|
-
amount: Long.fromString(amount.toString(), true),
|
|
61594
|
-
data: data || ""
|
|
61595
|
-
};
|
|
61730
|
+
// Same msg shape as performAction — only signing + broadcast mode differ.
|
|
61596
61731
|
const msg = {
|
|
61597
61732
|
typeUrl: "/pokerchain.poker.v1.MsgPerformAction",
|
|
61598
|
-
value:
|
|
61733
|
+
value: {
|
|
61734
|
+
player,
|
|
61735
|
+
gameId,
|
|
61736
|
+
action,
|
|
61737
|
+
amount: Long.fromString(amount.toString(), true),
|
|
61738
|
+
data: data || ""
|
|
61739
|
+
}
|
|
61599
61740
|
};
|
|
61600
|
-
const fee = gaslessFee();
|
|
61601
|
-
const memo = `Poker action (sync): ${action}`;
|
|
61602
61741
|
try {
|
|
61603
|
-
//
|
|
61604
|
-
//
|
|
61742
|
+
// UNORDERED (#2619): gameplay txs carry no account sequence. Sync
|
|
61743
|
+
// broadcast returns at CheckTx, not at commit, so an ordered tx
|
|
61744
|
+
// signed before the previous one commits re-reads the same
|
|
61745
|
+
// committed sequence and is rejected with code 32 — blind + deal +
|
|
61746
|
+
// action from one account inside a block did exactly that. This is
|
|
61747
|
+
// the chain-direct twin of signPerformAction's fix (#247, ui#520).
|
|
61748
|
+
const { base64 } = await this.signUnordered(msg);
|
|
61749
|
+
// broadcastTxSync returns just the txhash, no DeliverTx result, and
|
|
61750
|
+
// throws BroadcastTxError when CheckTx rejects — the same contract
|
|
61751
|
+
// signAndBroadcastSync had. The caller waits on the WS push for the
|
|
61605
61752
|
// authoritative outcome.
|
|
61606
|
-
|
|
61607
|
-
return txHash;
|
|
61753
|
+
return await this.signingClient.broadcastTxSync(encoding.fromBase64(base64));
|
|
61608
61754
|
}
|
|
61609
61755
|
catch (error) {
|
|
61610
61756
|
console.error("❌ Action (sync) failed at CheckTx:", error);
|
|
@@ -61714,8 +61860,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61714
61860
|
const player = account.address;
|
|
61715
61861
|
// account_number + chainId are still needed for the sign doc; the
|
|
61716
61862
|
// SEQUENCE is not — unordered txs must sign with sequence 0.
|
|
61717
|
-
const
|
|
61718
|
-
const accountNumber = Number(accountInfo.account.account_number);
|
|
61863
|
+
const accountNumber = await this.unorderedAccountNumber(player);
|
|
61719
61864
|
const chainId = this.config.chainId;
|
|
61720
61865
|
// Body with unordered=true + timeout_timestamp, messages packed as Any
|
|
61721
61866
|
// via the poker registry. timeoutHeight stays 0 (we gate on timestamp).
|
|
@@ -61724,7 +61869,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61724
61869
|
memo: "",
|
|
61725
61870
|
timeoutHeight: Long.UZERO,
|
|
61726
61871
|
unordered: true,
|
|
61727
|
-
timeoutTimestamp: new Date(
|
|
61872
|
+
timeoutTimestamp: new Date(nextUnorderedTimeoutMs(player, ttlSeconds))
|
|
61728
61873
|
})).finish();
|
|
61729
61874
|
// AuthInfo with sequence 0 (required for unordered). CosmJS builds this
|
|
61730
61875
|
// — the pubkey/fee encoding is unchanged from an ordered tx.
|
|
@@ -61740,6 +61885,22 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61740
61885
|
})).finish());
|
|
61741
61886
|
return { base64, accountNumber };
|
|
61742
61887
|
}
|
|
61888
|
+
/**
|
|
61889
|
+
* account_number for the unordered sign doc. It is assigned once when the
|
|
61890
|
+
* account is created and never changes, so look it up once per signer —
|
|
61891
|
+
* performActionSync signs on every player action and shouldn't pay a REST
|
|
61892
|
+
* round trip (or inherit its failure modes) each time.
|
|
61893
|
+
*/
|
|
61894
|
+
async unorderedAccountNumber(player) {
|
|
61895
|
+
const cached = this.accountNumbers.get(player);
|
|
61896
|
+
if (cached !== undefined) {
|
|
61897
|
+
return cached;
|
|
61898
|
+
}
|
|
61899
|
+
const accountInfo = await this.getAccount(player);
|
|
61900
|
+
const accountNumber = Number(accountInfo.account.account_number);
|
|
61901
|
+
this.accountNumbers.set(player, accountNumber);
|
|
61902
|
+
return accountNumber;
|
|
61903
|
+
}
|
|
61743
61904
|
/**
|
|
61744
61905
|
* Sign-only MsgJoinGame: builds and signs the player's buy-in tx WITHOUT
|
|
61745
61906
|
* broadcasting, returning the base64 TxRaw for the gateway to relay
|
|
@@ -61838,6 +61999,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61838
61999
|
});
|
|
61839
62000
|
try {
|
|
61840
62001
|
const result = await this.signingClient.signAndBroadcast(player, [msg], fee, memo);
|
|
62002
|
+
assertExecuted("top up", result);
|
|
61841
62003
|
console.log("✅ Top-up transaction successful:", result.transactionHash);
|
|
61842
62004
|
return result.transactionHash;
|
|
61843
62005
|
}
|
|
@@ -61875,6 +62037,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61875
62037
|
});
|
|
61876
62038
|
try {
|
|
61877
62039
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
62040
|
+
assertExecuted("process deposit", result);
|
|
61878
62041
|
console.log("✅ Process deposit transaction successful:", result.transactionHash);
|
|
61879
62042
|
return result.transactionHash;
|
|
61880
62043
|
}
|
|
@@ -61914,6 +62077,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61914
62077
|
});
|
|
61915
62078
|
try {
|
|
61916
62079
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
62080
|
+
assertExecuted("initiate withdrawal", result);
|
|
61917
62081
|
console.log("✅ Withdrawal initiation successful:", result.transactionHash);
|
|
61918
62082
|
return result.transactionHash;
|
|
61919
62083
|
}
|
|
@@ -61950,6 +62114,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
61950
62114
|
});
|
|
61951
62115
|
try {
|
|
61952
62116
|
const result = await this.signingClient.signAndBroadcast(signer, [msg], fee, memo);
|
|
62117
|
+
assertExecuted("sign withdrawal", result);
|
|
61953
62118
|
console.log("✅ Withdrawal signing successful:", result.transactionHash);
|
|
61954
62119
|
return result.transactionHash;
|
|
61955
62120
|
}
|
|
@@ -62030,6 +62195,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
62030
62195
|
});
|
|
62031
62196
|
try {
|
|
62032
62197
|
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
62198
|
+
assertExecuted("register NFT avatar", result);
|
|
62033
62199
|
console.log("✅ NFT avatar registration successful:", result.transactionHash);
|
|
62034
62200
|
return result.transactionHash;
|
|
62035
62201
|
}
|
|
@@ -62218,7 +62384,9 @@ exports.COSMOS_CONSTANTS = COSMOS_CONSTANTS;
|
|
|
62218
62384
|
exports.Client = Client;
|
|
62219
62385
|
exports.CosmosClient = CosmosClient;
|
|
62220
62386
|
exports.Deck = Deck;
|
|
62387
|
+
exports.GAME_NAME_MICRO_PER_CHAR = GAME_NAME_MICRO_PER_CHAR;
|
|
62221
62388
|
exports.KEYS = KEYS;
|
|
62389
|
+
exports.MAX_GAME_NAME_LENGTH = MAX_GAME_NAME_LENGTH;
|
|
62222
62390
|
exports.MissingWalletError = MissingWalletError;
|
|
62223
62391
|
exports.Params = Params$c;
|
|
62224
62392
|
exports.PokerGameIntegration = PokerGameIntegration;
|
|
@@ -62228,8 +62396,11 @@ exports.SIT_IN_METHOD_POST_NOW = SIT_IN_METHOD_POST_NOW;
|
|
|
62228
62396
|
exports.SIT_OUT_METHOD_NEXT_BB = SIT_OUT_METHOD_NEXT_BB;
|
|
62229
62397
|
exports.SIT_OUT_METHOD_NEXT_HAND = SIT_OUT_METHOD_NEXT_HAND;
|
|
62230
62398
|
exports.SigningCosmosClient = SigningCosmosClient;
|
|
62399
|
+
exports.TxExecutionError = TxExecutionError;
|
|
62231
62400
|
exports.ValidatorBond = ValidatorBond;
|
|
62232
62401
|
exports.WithdrawalRequest = WithdrawalRequest;
|
|
62402
|
+
exports.assertExecuted = assertExecuted;
|
|
62403
|
+
exports.computeGameNameFee = computeGameNameFee;
|
|
62233
62404
|
exports.createSigningClientFromMnemonic = createSigningClientFromMnemonic;
|
|
62234
62405
|
exports.createWalletFromMnemonic = createWalletFromMnemonic;
|
|
62235
62406
|
exports.formatGameFormatDisplay = formatGameFormatDisplay;
|
|
@@ -62252,4 +62423,6 @@ exports.isValidPlayerAddress = isValidPlayerAddress;
|
|
|
62252
62423
|
exports.parseGameFormat = parseGameFormat;
|
|
62253
62424
|
exports.parseGameVariant = parseGameVariant;
|
|
62254
62425
|
exports.registry = registry;
|
|
62426
|
+
exports.txFailureHash = txFailureHash;
|
|
62427
|
+
exports.txFailurePhase = txFailurePhase;
|
|
62255
62428
|
//# sourceMappingURL=index.js.map
|