@block52/poker-vm-sdk 1.16.0 → 1.17.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/IClient.d.ts +6 -4
- package/dist/IClient.d.ts.map +1 -1
- package/dist/cosmosClient.d.ts +7 -6
- package/dist/cosmosClient.d.ts.map +1 -1
- package/dist/index.d.ts +147 -56
- package/dist/index.esm.js +50 -94
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +50 -94
- package/dist/index.js.map +1 -1
- package/dist/pokerchain.poker.v1/registry.d.ts.map +1 -1
- package/dist/sdkTypes.d.ts +2 -29
- package/dist/sdkTypes.d.ts.map +1 -1
- package/dist/signingClient.d.ts +11 -12
- package/dist/signingClient.d.ts.map +1 -1
- package/dist/types/game.d.ts +2 -2
- package/dist/types/game.d.ts.map +1 -1
- package/dist/types/rest.d.ts +89 -0
- package/dist/types/rest.d.ts.map +1 -0
- package/dist/types.d.ts +2 -29
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -4471,24 +4471,33 @@ function isSet$2b(value) {
|
|
|
4471
4471
|
return value !== null && value !== undefined;
|
|
4472
4472
|
}
|
|
4473
4473
|
|
|
4474
|
-
|
|
4474
|
+
/**
|
|
4475
|
+
* Adapts a ts-proto MessageFns to cosmjs's GeneratedType (poker-vm#1939).
|
|
4476
|
+
* cosmjs types its writer as protobufjs's Writer class; ours is @bufbuild's
|
|
4477
|
+
* BinaryWriter, a different class with the same contract. The Registry only
|
|
4478
|
+
* calls fromPartial, encode(...).finish() and decode(bytes), all of which
|
|
4479
|
+
* MessageFns provides, so this is the one place that bridges the two. Both
|
|
4480
|
+
* writer types are classes with private members, so no structural adapter can
|
|
4481
|
+
* satisfy GeneratedType without this cast.
|
|
4482
|
+
*/
|
|
4483
|
+
const asGeneratedType = (fns) => fns;
|
|
4475
4484
|
const msgTypes$u = [
|
|
4476
|
-
["/pokerchain.poker.v1.MsgUpdateParams", MsgUpdateParams$d],
|
|
4477
|
-
["/pokerchain.poker.v1.MsgCreateGame", MsgCreateGame],
|
|
4478
|
-
["/pokerchain.poker.v1.MsgJoinGame", MsgJoinGame],
|
|
4479
|
-
["/pokerchain.poker.v1.MsgLeaveGame", MsgLeaveGame],
|
|
4480
|
-
["/pokerchain.poker.v1.MsgRecordHandEnd", MsgRecordHandEnd],
|
|
4481
|
-
["/pokerchain.poker.v1.MsgDealCards", MsgDealCards],
|
|
4482
|
-
["/pokerchain.poker.v1.MsgPerformAction", MsgPerformAction],
|
|
4483
|
-
["/pokerchain.poker.v1.MsgMint", MsgMint],
|
|
4484
|
-
["/pokerchain.poker.v1.MsgBurn", MsgBurn],
|
|
4485
|
-
["/pokerchain.poker.v1.MsgProcessDeposit", MsgProcessDeposit],
|
|
4486
|
-
["/pokerchain.poker.v1.MsgInitiateWithdrawal", MsgInitiateWithdrawal],
|
|
4487
|
-
["/pokerchain.poker.v1.MsgUpdateEthBlockHeight", MsgUpdateEthBlockHeight],
|
|
4488
|
-
["/pokerchain.poker.v1.MsgTopUp", MsgTopUp],
|
|
4489
|
-
["/pokerchain.poker.v1.MsgDeleteGame", MsgDeleteGame],
|
|
4490
|
-
["/pokerchain.poker.v1.MsgForceCloseGame", MsgForceCloseGame],
|
|
4491
|
-
["/pokerchain.poker.v1.MsgRegisterNftAvatar", MsgRegisterNftAvatar],
|
|
4485
|
+
["/pokerchain.poker.v1.MsgUpdateParams", asGeneratedType(MsgUpdateParams$d)],
|
|
4486
|
+
["/pokerchain.poker.v1.MsgCreateGame", asGeneratedType(MsgCreateGame)],
|
|
4487
|
+
["/pokerchain.poker.v1.MsgJoinGame", asGeneratedType(MsgJoinGame)],
|
|
4488
|
+
["/pokerchain.poker.v1.MsgLeaveGame", asGeneratedType(MsgLeaveGame)],
|
|
4489
|
+
["/pokerchain.poker.v1.MsgRecordHandEnd", asGeneratedType(MsgRecordHandEnd)],
|
|
4490
|
+
["/pokerchain.poker.v1.MsgDealCards", asGeneratedType(MsgDealCards)],
|
|
4491
|
+
["/pokerchain.poker.v1.MsgPerformAction", asGeneratedType(MsgPerformAction)],
|
|
4492
|
+
["/pokerchain.poker.v1.MsgMint", asGeneratedType(MsgMint)],
|
|
4493
|
+
["/pokerchain.poker.v1.MsgBurn", asGeneratedType(MsgBurn)],
|
|
4494
|
+
["/pokerchain.poker.v1.MsgProcessDeposit", asGeneratedType(MsgProcessDeposit)],
|
|
4495
|
+
["/pokerchain.poker.v1.MsgInitiateWithdrawal", asGeneratedType(MsgInitiateWithdrawal)],
|
|
4496
|
+
["/pokerchain.poker.v1.MsgUpdateEthBlockHeight", asGeneratedType(MsgUpdateEthBlockHeight)],
|
|
4497
|
+
["/pokerchain.poker.v1.MsgTopUp", asGeneratedType(MsgTopUp)],
|
|
4498
|
+
["/pokerchain.poker.v1.MsgDeleteGame", asGeneratedType(MsgDeleteGame)],
|
|
4499
|
+
["/pokerchain.poker.v1.MsgForceCloseGame", asGeneratedType(MsgForceCloseGame)],
|
|
4500
|
+
["/pokerchain.poker.v1.MsgRegisterNftAvatar", asGeneratedType(MsgRegisterNftAvatar)],
|
|
4492
4501
|
];
|
|
4493
4502
|
|
|
4494
4503
|
/**
|
|
@@ -58597,10 +58606,10 @@ class CosmosClient {
|
|
|
58597
58606
|
async getGameState(gameId) {
|
|
58598
58607
|
try {
|
|
58599
58608
|
const response = await this.restClient.get(`/block52/pokerchain/poker/v1/game_state/${gameId}`);
|
|
58600
|
-
if (response.data) {
|
|
58601
|
-
|
|
58609
|
+
if (!response.data) {
|
|
58610
|
+
throw new Error(`Empty game state response for ${gameId}`);
|
|
58602
58611
|
}
|
|
58603
|
-
return
|
|
58612
|
+
return response.data;
|
|
58604
58613
|
}
|
|
58605
58614
|
catch (error) {
|
|
58606
58615
|
console.error("Error fetching game state:", error);
|
|
@@ -58613,10 +58622,10 @@ class CosmosClient {
|
|
|
58613
58622
|
async getGame(gameId) {
|
|
58614
58623
|
try {
|
|
58615
58624
|
const response = await this.restClient.get(`/block52/pokerchain/poker/v1/game/${gameId}`);
|
|
58616
|
-
if (response.data) {
|
|
58617
|
-
|
|
58625
|
+
if (!response.data) {
|
|
58626
|
+
throw new Error(`Empty game response for ${gameId}`);
|
|
58618
58627
|
}
|
|
58619
|
-
return
|
|
58628
|
+
return response.data;
|
|
58620
58629
|
}
|
|
58621
58630
|
catch (error) {
|
|
58622
58631
|
console.error("Error fetching game:", error);
|
|
@@ -58663,9 +58672,11 @@ class CosmosClient {
|
|
|
58663
58672
|
}
|
|
58664
58673
|
catch (error) {
|
|
58665
58674
|
console.error("❌ [CosmosClient] Error listing games:");
|
|
58666
|
-
|
|
58667
|
-
|
|
58668
|
-
|
|
58675
|
+
if (axios.isAxiosError(error)) {
|
|
58676
|
+
console.error(" Message:", error.message);
|
|
58677
|
+
console.error(" Response status:", error.response?.status);
|
|
58678
|
+
console.error(" Response data:", error.response?.data);
|
|
58679
|
+
}
|
|
58669
58680
|
console.error(" Full error:", error);
|
|
58670
58681
|
throw error;
|
|
58671
58682
|
}
|
|
@@ -58771,9 +58782,10 @@ class CosmosClient {
|
|
|
58771
58782
|
*/
|
|
58772
58783
|
async listWithdrawalRequests(cosmosAddress) {
|
|
58773
58784
|
try {
|
|
58785
|
+
// The chain serves withdrawal_requests; list_withdrawal_requests is a 501 (poker-vm#1939).
|
|
58774
58786
|
const url = cosmosAddress
|
|
58775
|
-
? `/block52/pokerchain/poker/v1/
|
|
58776
|
-
: `/block52/pokerchain/poker/v1/
|
|
58787
|
+
? `/block52/pokerchain/poker/v1/withdrawal_requests?cosmos_address=${encodeURIComponent(cosmosAddress)}`
|
|
58788
|
+
: `/block52/pokerchain/poker/v1/withdrawal_requests`;
|
|
58777
58789
|
const response = await this.restClient.get(url);
|
|
58778
58790
|
return response.data.withdrawal_requests || [];
|
|
58779
58791
|
}
|
|
@@ -71806,7 +71818,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71806
71818
|
if (!denom) {
|
|
71807
71819
|
denom = this.config.denom;
|
|
71808
71820
|
}
|
|
71809
|
-
const coins = [{ denom
|
|
71821
|
+
const coins = [{ denom, amount: amount.toString() }];
|
|
71810
71822
|
const fee = gaslessFee();
|
|
71811
71823
|
const result = await this.signingClient.sendTokens(fromAddress, toAddress, coins, fee, memo || "");
|
|
71812
71824
|
assertExecuted("send tokens", result);
|
|
@@ -72658,84 +72670,28 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
72658
72670
|
}
|
|
72659
72671
|
}
|
|
72660
72672
|
/**
|
|
72661
|
-
*
|
|
72662
|
-
*
|
|
72663
|
-
*/
|
|
72664
|
-
async getNextActionIndex(gameId) {
|
|
72665
|
-
try {
|
|
72666
|
-
const gameState = await this.queryGameState(gameId);
|
|
72667
|
-
if (!gameState) {
|
|
72668
|
-
throw new Error("Game state not found");
|
|
72669
|
-
}
|
|
72670
|
-
let nextIndex;
|
|
72671
|
-
// Match original client logic exactly
|
|
72672
|
-
if (!gameState.previousActions || gameState.previousActions.length === 0) {
|
|
72673
|
-
nextIndex = gameState.actionCount + 1;
|
|
72674
|
-
console.log("📊 Action Index Calculation:", {
|
|
72675
|
-
gameId: gameId.substring(0, 20) + "...",
|
|
72676
|
-
method: "actionCount + 1",
|
|
72677
|
-
actionCount: gameState.actionCount,
|
|
72678
|
-
nextIndex,
|
|
72679
|
-
previousActionsLength: 0
|
|
72680
|
-
});
|
|
72681
|
-
}
|
|
72682
|
-
else {
|
|
72683
|
-
const lastAction = gameState.previousActions[gameState.previousActions.length - 1];
|
|
72684
|
-
nextIndex = lastAction.index + 1;
|
|
72685
|
-
console.log("📊 Action Index Calculation:", {
|
|
72686
|
-
gameId: gameId.substring(0, 20) + "...",
|
|
72687
|
-
method: "lastAction.index + 1",
|
|
72688
|
-
lastActionIndex: lastAction.index,
|
|
72689
|
-
nextIndex,
|
|
72690
|
-
previousActionsLength: gameState.previousActions.length,
|
|
72691
|
-
lastAction: {
|
|
72692
|
-
action: lastAction.action,
|
|
72693
|
-
player: lastAction.playerId?.substring(0, 10) + "...",
|
|
72694
|
-
round: lastAction.round
|
|
72695
|
-
}
|
|
72696
|
-
});
|
|
72697
|
-
}
|
|
72698
|
-
return nextIndex;
|
|
72699
|
-
}
|
|
72700
|
-
catch (error) {
|
|
72701
|
-
console.error(`Error getting next action index: ${error.message}`);
|
|
72702
|
-
throw error; // Rethrow to be handled by caller
|
|
72703
|
-
}
|
|
72704
|
-
}
|
|
72705
|
-
/**
|
|
72706
|
-
* Query all games from the blockchain
|
|
72673
|
+
* Query all games from the blockchain.
|
|
72674
|
+
* Same as listGames(); the old /pokerchain/poker/v1/games path is a 501 (poker-vm#1939).
|
|
72707
72675
|
*/
|
|
72708
72676
|
async queryGames() {
|
|
72709
|
-
|
|
72710
|
-
const response = await fetch(`${this.config.restEndpoint}/pokerchain/poker/v1/games`);
|
|
72711
|
-
if (!response.ok) {
|
|
72712
|
-
throw new Error(`Failed to query games: ${response.statusText}`);
|
|
72713
|
-
}
|
|
72714
|
-
const data = await response.json();
|
|
72715
|
-
// The response has games as a JSON string, need to parse it
|
|
72716
|
-
if (data.games) {
|
|
72717
|
-
return JSON.parse(data.games);
|
|
72718
|
-
}
|
|
72719
|
-
return [];
|
|
72720
|
-
}
|
|
72721
|
-
catch (error) {
|
|
72722
|
-
console.error("❌ queryGames() failed:", error);
|
|
72723
|
-
throw error;
|
|
72724
|
-
}
|
|
72677
|
+
return this.listGames();
|
|
72725
72678
|
}
|
|
72726
72679
|
/**
|
|
72727
|
-
* Query game state for a
|
|
72680
|
+
* Query the public game state for a game (hole cards masked), or null when the
|
|
72681
|
+
* chain has none. Uses game_state_public: the game_state query needs a signed
|
|
72682
|
+
* player address (poker-vm#1939).
|
|
72728
72683
|
*/
|
|
72729
72684
|
async queryGameState(gameId) {
|
|
72730
72685
|
try {
|
|
72731
|
-
const response = await fetch(`${this.config.restEndpoint}/block52/pokerchain/poker/v1/
|
|
72686
|
+
const response = await fetch(`${this.config.restEndpoint}/block52/pokerchain/poker/v1/game_state_public/${encodeURIComponent(gameId)}`);
|
|
72732
72687
|
if (!response.ok) {
|
|
72733
72688
|
throw new Error(`Failed to query game state: ${response.statusText}`);
|
|
72734
72689
|
}
|
|
72735
72690
|
const data = await response.json();
|
|
72736
72691
|
// The response has game_state as a JSON string, need to parse it
|
|
72737
72692
|
if (data.game_state) {
|
|
72738
|
-
|
|
72693
|
+
const state = JSON.parse(data.game_state);
|
|
72694
|
+
return state;
|
|
72739
72695
|
}
|
|
72740
72696
|
return null;
|
|
72741
72697
|
}
|