@block52/poker-vm-sdk 1.1.12 → 1.1.14

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.js CHANGED
@@ -4169,119 +4169,6 @@ const MsgDeleteGame = {
4169
4169
  return message;
4170
4170
  },
4171
4171
  };
4172
- function createBaseMsgRegisterNftAvatar() {
4173
- return { creator: "", ethAddress: "", contractAddress: "", tokenId: "", ethSignature: "" };
4174
- }
4175
- const MsgRegisterNftAvatar = {
4176
- encode(message, writer = new BinaryWriter()) {
4177
- if (message.creator !== "") {
4178
- writer.uint32(10).string(message.creator);
4179
- }
4180
- if (message.ethAddress !== "") {
4181
- writer.uint32(18).string(message.ethAddress);
4182
- }
4183
- if (message.contractAddress !== "") {
4184
- writer.uint32(26).string(message.contractAddress);
4185
- }
4186
- if (message.tokenId !== "") {
4187
- writer.uint32(34).string(message.tokenId);
4188
- }
4189
- if (message.ethSignature !== "") {
4190
- writer.uint32(42).string(message.ethSignature);
4191
- }
4192
- return writer;
4193
- },
4194
- decode(input, length) {
4195
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
4196
- const end = length === undefined ? reader.len : reader.pos + length;
4197
- const message = createBaseMsgRegisterNftAvatar();
4198
- while (reader.pos < end) {
4199
- const tag = reader.uint32();
4200
- switch (tag >>> 3) {
4201
- case 1: {
4202
- if (tag !== 10) {
4203
- break;
4204
- }
4205
- message.creator = reader.string();
4206
- continue;
4207
- }
4208
- case 2: {
4209
- if (tag !== 18) {
4210
- break;
4211
- }
4212
- message.ethAddress = reader.string();
4213
- continue;
4214
- }
4215
- case 3: {
4216
- if (tag !== 26) {
4217
- break;
4218
- }
4219
- message.contractAddress = reader.string();
4220
- continue;
4221
- }
4222
- case 4: {
4223
- if (tag !== 34) {
4224
- break;
4225
- }
4226
- message.tokenId = reader.string();
4227
- continue;
4228
- }
4229
- case 5: {
4230
- if (tag !== 42) {
4231
- break;
4232
- }
4233
- message.ethSignature = reader.string();
4234
- continue;
4235
- }
4236
- }
4237
- if ((tag & 7) === 4 || tag === 0) {
4238
- break;
4239
- }
4240
- reader.skip(tag & 7);
4241
- }
4242
- return message;
4243
- },
4244
- fromJSON(object) {
4245
- return {
4246
- creator: isSet$2b(object.creator) ? globalThis.String(object.creator) : "",
4247
- ethAddress: isSet$2b(object.ethAddress) ? globalThis.String(object.ethAddress) : "",
4248
- contractAddress: isSet$2b(object.contractAddress) ? globalThis.String(object.contractAddress) : "",
4249
- tokenId: isSet$2b(object.tokenId) ? globalThis.String(object.tokenId) : "",
4250
- ethSignature: isSet$2b(object.ethSignature) ? globalThis.String(object.ethSignature) : "",
4251
- };
4252
- },
4253
- toJSON(message) {
4254
- const obj = {};
4255
- if (message.creator !== "") {
4256
- obj.creator = message.creator;
4257
- }
4258
- if (message.ethAddress !== "") {
4259
- obj.ethAddress = message.ethAddress;
4260
- }
4261
- if (message.contractAddress !== "") {
4262
- obj.contractAddress = message.contractAddress;
4263
- }
4264
- if (message.tokenId !== "") {
4265
- obj.tokenId = message.tokenId;
4266
- }
4267
- if (message.ethSignature !== "") {
4268
- obj.ethSignature = message.ethSignature;
4269
- }
4270
- return obj;
4271
- },
4272
- create(base) {
4273
- return MsgRegisterNftAvatar.fromPartial(base ?? {});
4274
- },
4275
- fromPartial(object) {
4276
- const message = createBaseMsgRegisterNftAvatar();
4277
- message.creator = object.creator ?? "";
4278
- message.ethAddress = object.ethAddress ?? "";
4279
- message.contractAddress = object.contractAddress ?? "";
4280
- message.tokenId = object.tokenId ?? "";
4281
- message.ethSignature = object.ethSignature ?? "";
4282
- return message;
4283
- },
4284
- };
4285
4172
  function isSet$2b(value) {
4286
4173
  return value !== null && value !== undefined;
4287
4174
  }
@@ -4302,7 +4189,6 @@ const msgTypes$u = [
4302
4189
  ["/pokerchain.poker.v1.MsgUpdateEthBlockHeight", MsgUpdateEthBlockHeight],
4303
4190
  ["/pokerchain.poker.v1.MsgTopUp", MsgTopUp],
4304
4191
  ["/pokerchain.poker.v1.MsgDeleteGame", MsgDeleteGame],
4305
- ["/pokerchain.poker.v1.MsgRegisterNftAvatar", MsgRegisterNftAvatar],
4306
4192
  ];
4307
4193
 
4308
4194
  /**
@@ -57911,6 +57797,40 @@ class SigningCosmosClient extends CosmosClient {
57911
57797
  throw error;
57912
57798
  }
57913
57799
  }
57800
+ /**
57801
+ * Delete a poker game
57802
+ * Only the game creator can delete a game, and the game must have no active players
57803
+ */
57804
+ async deleteGame(gameId) {
57805
+ await this.initializeSigningClient();
57806
+ if (!this.signingClient || !this.wallet) {
57807
+ throw new Error("Signing client not initialized");
57808
+ }
57809
+ const [account] = await this.wallet.getAccounts();
57810
+ const creator = account.address;
57811
+ // Create the message object
57812
+ const msgDeleteGame = {
57813
+ creator,
57814
+ gameId
57815
+ };
57816
+ // Create the transaction message
57817
+ const msg = {
57818
+ typeUrl: "/pokerchain.poker.v1.MsgDeleteGame",
57819
+ value: msgDeleteGame
57820
+ };
57821
+ const fee = gaslessFee();
57822
+ const memo = "Delete poker game via SDK";
57823
+ console.log("🗑️ Deleting game:", { gameId });
57824
+ try {
57825
+ const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
57826
+ console.log("✅ Delete game transaction successful:", result.transactionHash);
57827
+ return result.transactionHash;
57828
+ }
57829
+ catch (error) {
57830
+ console.error("❌ Delete game failed:", error);
57831
+ throw error;
57832
+ }
57833
+ }
57914
57834
  /**
57915
57835
  * Perform a game action (fold, call, raise, etc.)
57916
57836
  * The keeper calculates the action index automatically
@@ -58264,93 +58184,6 @@ class SigningCosmosClient extends CosmosClient {
58264
58184
  getWallet() {
58265
58185
  return this.wallet;
58266
58186
  }
58267
- /**
58268
- * Register an NFT as the player's avatar
58269
- *
58270
- * This broadcasts a MsgRegisterNftAvatar transaction containing:
58271
- * - The ETH address that owns the NFT
58272
- * - The NFT contract address and token ID
58273
- * - An ETH signature proving the ETH address owner authorizes this cosmos address
58274
- * to use the NFT as their avatar
58275
- *
58276
- * The validator verifies the ETH signature via ecrecover and, if valid,
58277
- * stores the mapping on-chain: cosmosAddress → (contractAddress, tokenId)
58278
- *
58279
- * @param ethAddress - The ETH address that owns the NFT
58280
- * @param contractAddress - The NFT contract address on Ethereum/Base
58281
- * @param tokenId - The NFT token ID
58282
- * @param ethSignature - EIP-191 signature proving ETH address ownership
58283
- * @returns Transaction hash
58284
- */
58285
- async registerNftAvatar(ethAddress, contractAddress, tokenId, ethSignature) {
58286
- await this.initializeSigningClient();
58287
- if (!this.signingClient || !this.wallet) {
58288
- throw new Error("Signing client not initialized");
58289
- }
58290
- const [account] = await this.wallet.getAccounts();
58291
- const creator = account.address;
58292
- // Create the message object
58293
- const msgRegisterNftAvatar = {
58294
- creator,
58295
- ethAddress,
58296
- contractAddress,
58297
- tokenId,
58298
- ethSignature
58299
- };
58300
- // Create the transaction message
58301
- const msg = {
58302
- typeUrl: "/pokerchain.poker.v1.MsgRegisterNftAvatar",
58303
- value: msgRegisterNftAvatar
58304
- };
58305
- const fee = gaslessFee();
58306
- const memo = "Register NFT avatar via SDK";
58307
- console.log("🖼️ Registering NFT avatar:", {
58308
- creator,
58309
- ethAddress,
58310
- contractAddress,
58311
- tokenId: tokenId.substring(0, 20) + (tokenId.length > 20 ? "..." : "")
58312
- });
58313
- try {
58314
- const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
58315
- console.log("✅ NFT avatar registration successful:", result.transactionHash);
58316
- return result.transactionHash;
58317
- }
58318
- catch (error) {
58319
- console.error("❌ NFT avatar registration failed:", error);
58320
- throw error;
58321
- }
58322
- }
58323
- /**
58324
- * Query a registered NFT avatar for a cosmos address
58325
- *
58326
- * @param cosmosAddress - The cosmos address to look up
58327
- * @returns The NFT avatar data if registered, or null if not found
58328
- */
58329
- async queryNftAvatar(cosmosAddress) {
58330
- try {
58331
- const response = await fetch(`${this.config.restEndpoint}/pokerchain/poker/nft_avatar/${encodeURIComponent(cosmosAddress)}`);
58332
- if (!response.ok) {
58333
- if (response.status === 404) {
58334
- return null;
58335
- }
58336
- throw new Error(`Failed to query NFT avatar: ${response.statusText}`);
58337
- }
58338
- const data = await response.json();
58339
- if (!data.contract_address || !data.token_id) {
58340
- return null;
58341
- }
58342
- return {
58343
- cosmosAddress: data.cosmos_address || cosmosAddress,
58344
- ethAddress: data.eth_address || "",
58345
- contractAddress: data.contract_address,
58346
- tokenId: data.token_id
58347
- };
58348
- }
58349
- catch (error) {
58350
- console.error("❌ queryNftAvatar() failed:", error);
58351
- throw error;
58352
- }
58353
- }
58354
58187
  }
58355
58188
  /**
58356
58189
  * Create a signing client with a wallet