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