@block52/poker-vm-sdk 1.1.13 → 1.1.15

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,11 +4169,124 @@ 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
+ };
4172
4285
  function isSet$2b(value) {
4173
4286
  return value !== null && value !== undefined;
4174
4287
  }
4175
4288
 
4176
- // Note: Some Ignite-generated types need casting due to interface mismatch with cosmjs
4289
+ // Proto-generated MessageFns types need casting to cosmjs GeneratedType
4177
4290
  const msgTypes$u = [
4178
4291
  ["/pokerchain.poker.v1.MsgUpdateParams", MsgUpdateParams$d],
4179
4292
  ["/pokerchain.poker.v1.MsgCreateGame", MsgCreateGame],
@@ -4189,6 +4302,7 @@ const msgTypes$u = [
4189
4302
  ["/pokerchain.poker.v1.MsgUpdateEthBlockHeight", MsgUpdateEthBlockHeight],
4190
4303
  ["/pokerchain.poker.v1.MsgTopUp", MsgTopUp],
4191
4304
  ["/pokerchain.poker.v1.MsgDeleteGame", MsgDeleteGame],
4305
+ ["/pokerchain.poker.v1.MsgRegisterNftAvatar", MsgRegisterNftAvatar],
4192
4306
  ];
4193
4307
 
4194
4308
  /**
@@ -8123,6 +8237,7 @@ let HttpClient$u = class HttpClient {
8123
8237
  const requestParams = this.mergeRequestParams(params, secureParams);
8124
8238
  const responseFormat = (format && this.format) || void 0;
8125
8239
  if (type === ContentType$u.FormData && body && body !== null && typeof body === "object") {
8240
+ requestParams.headers = requestParams.headers || {};
8126
8241
  requestParams.headers.common = { Accept: "*/*" };
8127
8242
  requestParams.headers.post = {};
8128
8243
  requestParams.headers.put = {};
@@ -8558,7 +8673,7 @@ function isSet$2a(value) {
8558
8673
  const registry$q = new protoSigning.Registry(msgTypes$u);
8559
8674
  function getStructure$s(template) {
8560
8675
  const structure = { fields: [] };
8561
- for (let [key, value] of Object.entries(template)) {
8676
+ for (const [key, value] of Object.entries(template)) {
8562
8677
  let field = { name: key, type: typeof value };
8563
8678
  structure.fields.push(field);
8564
8679
  }
@@ -8883,7 +8998,7 @@ let SDKModule$u = class SDKModule {
8883
8998
  prefix: client.env.prefix ?? "cosmos",
8884
8999
  });
8885
9000
  this.tx = methods;
8886
- for (let m in methods) {
9001
+ for (const m in methods) {
8887
9002
  this.tx[m] = methods[m].bind(this.tx);
8888
9003
  }
8889
9004
  }
@@ -57475,6 +57590,9 @@ class CosmosClient {
57475
57590
  async initiateWithdrawal(baseAddress, amount) {
57476
57591
  throw new Error("Transaction signing not implemented in REST-only mode. Use a wallet implementation.");
57477
57592
  }
57593
+ async signWithdrawal(nonce, validatorEthKeyHex) {
57594
+ throw new Error("Transaction signing not implemented in REST-only mode. Use SigningCosmosClient instead.");
57595
+ }
57478
57596
  /**
57479
57597
  * List withdrawal requests via REST API
57480
57598
  */
@@ -58071,6 +58189,49 @@ class SigningCosmosClient extends CosmosClient {
58071
58189
  throw error;
58072
58190
  }
58073
58191
  }
58192
+ /**
58193
+ * Register an NFT avatar on-chain
58194
+ * Associates a cosmos address with an Ethereum NFT (contract + tokenId)
58195
+ * The validator verifies the ETH signature via ecrecover
58196
+ */
58197
+ async registerNftAvatar(ethAddress, contractAddress, tokenId, ethSignature) {
58198
+ await this.initializeSigningClient();
58199
+ if (!this.signingClient || !this.wallet) {
58200
+ throw new Error("Signing client not initialized");
58201
+ }
58202
+ const [account] = await this.wallet.getAccounts();
58203
+ const creator = account.address;
58204
+ // Create the message object
58205
+ const msgRegisterNftAvatar = {
58206
+ creator,
58207
+ ethAddress,
58208
+ contractAddress,
58209
+ tokenId,
58210
+ ethSignature
58211
+ };
58212
+ // Create the transaction message
58213
+ const msg = {
58214
+ typeUrl: "/pokerchain.poker.v1.MsgRegisterNftAvatar",
58215
+ value: msgRegisterNftAvatar
58216
+ };
58217
+ const fee = gaslessFee();
58218
+ const memo = "Register NFT avatar via SDK";
58219
+ console.log("🖼️ Registering NFT avatar:", {
58220
+ creator,
58221
+ ethAddress,
58222
+ contractAddress,
58223
+ tokenId
58224
+ });
58225
+ try {
58226
+ const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
58227
+ console.log("✅ NFT avatar registration successful:", result.transactionHash);
58228
+ return result.transactionHash;
58229
+ }
58230
+ catch (error) {
58231
+ console.error("❌ NFT avatar registration failed:", error);
58232
+ throw error;
58233
+ }
58234
+ }
58074
58235
  /**
58075
58236
  * Get next action index for a game - matches original client pattern
58076
58237
  * Checks previousActions array first, falls back to actionCount + 1