@block52/poker-vm-sdk 1.1.10 → 1.1.12
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 +1 -0
- package/dist/IClient.d.ts.map +1 -1
- package/dist/index.d.ts +37 -0
- package/dist/index.esm.js +237 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +237 -0
- package/dist/index.js.map +1 -1
- package/dist/pokerchain.poker.v1/registry.d.ts.map +1 -1
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts +29 -0
- package/dist/pokerchain.poker.v1/types/pokerchain/poker/v1/tx.d.ts.map +1 -1
- package/dist/signingClient.d.ts +36 -0
- package/dist/signingClient.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/IClient.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface IClient {
|
|
|
25
25
|
joinGame(gameId: string, seat: number, buyInAmount: bigint): Promise<string>;
|
|
26
26
|
createGame(gameFormat: string, gameVariant: string, minPlayers: number, maxPlayers: number, minBuyInB52USDC: bigint, maxBuyInB52USDC: bigint, smallBlindB52USDC: bigint, bigBlindB52USDC: bigint, timeout: number): Promise<string>;
|
|
27
27
|
initiateWithdrawal(baseAddress: string, amount: bigint): Promise<string>;
|
|
28
|
+
signWithdrawal(nonce: string, validatorEthKeyHex: string): Promise<string>;
|
|
28
29
|
listWithdrawalRequests(cosmosAddress?: string): Promise<any[]>;
|
|
29
30
|
disconnect(): Promise<void>;
|
|
30
31
|
}
|
package/dist/IClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IClient.d.ts","sourceRoot":"","sources":["../src/IClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAExH,MAAM,WAAW,OAAO;IACpB,UAAU,CAAC,OAAO,EA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,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3E,sBAAsB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/D,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -46211,6 +46211,7 @@ interface IClient {
|
|
|
46211
46211
|
joinGame(gameId: string, seat: number, buyInAmount: bigint): Promise<string>;
|
|
46212
46212
|
createGame(gameFormat: string, gameVariant: string, minPlayers: number, maxPlayers: number, minBuyInB52USDC: bigint, maxBuyInB52USDC: bigint, smallBlindB52USDC: bigint, bigBlindB52USDC: bigint, timeout: number): Promise<string>;
|
|
46213
46213
|
initiateWithdrawal(baseAddress: string, amount: bigint): Promise<string>;
|
|
46214
|
+
signWithdrawal(nonce: string, validatorEthKeyHex: string): Promise<string>;
|
|
46214
46215
|
listWithdrawalRequests(cosmosAddress?: string): Promise<any[]>;
|
|
46215
46216
|
disconnect(): Promise<void>;
|
|
46216
46217
|
}
|
|
@@ -46422,6 +46423,11 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46422
46423
|
* Burns USDC on Cosmos and creates a withdrawal request that can be completed on Base
|
|
46423
46424
|
*/
|
|
46424
46425
|
initiateWithdrawal(baseAddress: string, amount: bigint): Promise<string>;
|
|
46426
|
+
/**
|
|
46427
|
+
* Sign a pending withdrawal request (validator/relayer operation)
|
|
46428
|
+
* Generates an ECDSA signature compatible with the Base chain CosmosBridge contract
|
|
46429
|
+
*/
|
|
46430
|
+
signWithdrawal(nonce: string, validatorEthKeyHex: string): Promise<string>;
|
|
46425
46431
|
/**
|
|
46426
46432
|
* Query a specific withdrawal request by nonce
|
|
46427
46433
|
*/
|
|
@@ -46455,6 +46461,37 @@ declare class SigningCosmosClient extends CosmosClient {
|
|
|
46455
46461
|
* Get the current wallet
|
|
46456
46462
|
*/
|
|
46457
46463
|
getWallet(): DirectSecp256k1HdWallet | undefined;
|
|
46464
|
+
/**
|
|
46465
|
+
* Register an NFT as the player's avatar
|
|
46466
|
+
*
|
|
46467
|
+
* This broadcasts a MsgRegisterNftAvatar transaction containing:
|
|
46468
|
+
* - The ETH address that owns the NFT
|
|
46469
|
+
* - The NFT contract address and token ID
|
|
46470
|
+
* - An ETH signature proving the ETH address owner authorizes this cosmos address
|
|
46471
|
+
* to use the NFT as their avatar
|
|
46472
|
+
*
|
|
46473
|
+
* The validator verifies the ETH signature via ecrecover and, if valid,
|
|
46474
|
+
* stores the mapping on-chain: cosmosAddress → (contractAddress, tokenId)
|
|
46475
|
+
*
|
|
46476
|
+
* @param ethAddress - The ETH address that owns the NFT
|
|
46477
|
+
* @param contractAddress - The NFT contract address on Ethereum/Base
|
|
46478
|
+
* @param tokenId - The NFT token ID
|
|
46479
|
+
* @param ethSignature - EIP-191 signature proving ETH address ownership
|
|
46480
|
+
* @returns Transaction hash
|
|
46481
|
+
*/
|
|
46482
|
+
registerNftAvatar(ethAddress: string, contractAddress: string, tokenId: string, ethSignature: string): Promise<string>;
|
|
46483
|
+
/**
|
|
46484
|
+
* Query a registered NFT avatar for a cosmos address
|
|
46485
|
+
*
|
|
46486
|
+
* @param cosmosAddress - The cosmos address to look up
|
|
46487
|
+
* @returns The NFT avatar data if registered, or null if not found
|
|
46488
|
+
*/
|
|
46489
|
+
queryNftAvatar(cosmosAddress: string): Promise<{
|
|
46490
|
+
cosmosAddress: string;
|
|
46491
|
+
ethAddress: string;
|
|
46492
|
+
contractAddress: string;
|
|
46493
|
+
tokenId: string;
|
|
46494
|
+
} | null>;
|
|
46458
46495
|
}
|
|
46459
46496
|
/**
|
|
46460
46497
|
* Create a signing client from a mnemonic
|
package/dist/index.esm.js
CHANGED
|
@@ -4167,6 +4167,119 @@ const MsgDeleteGame = {
|
|
|
4167
4167
|
return message;
|
|
4168
4168
|
},
|
|
4169
4169
|
};
|
|
4170
|
+
function createBaseMsgRegisterNftAvatar() {
|
|
4171
|
+
return { creator: "", ethAddress: "", contractAddress: "", tokenId: "", ethSignature: "" };
|
|
4172
|
+
}
|
|
4173
|
+
const MsgRegisterNftAvatar = {
|
|
4174
|
+
encode(message, writer = new BinaryWriter()) {
|
|
4175
|
+
if (message.creator !== "") {
|
|
4176
|
+
writer.uint32(10).string(message.creator);
|
|
4177
|
+
}
|
|
4178
|
+
if (message.ethAddress !== "") {
|
|
4179
|
+
writer.uint32(18).string(message.ethAddress);
|
|
4180
|
+
}
|
|
4181
|
+
if (message.contractAddress !== "") {
|
|
4182
|
+
writer.uint32(26).string(message.contractAddress);
|
|
4183
|
+
}
|
|
4184
|
+
if (message.tokenId !== "") {
|
|
4185
|
+
writer.uint32(34).string(message.tokenId);
|
|
4186
|
+
}
|
|
4187
|
+
if (message.ethSignature !== "") {
|
|
4188
|
+
writer.uint32(42).string(message.ethSignature);
|
|
4189
|
+
}
|
|
4190
|
+
return writer;
|
|
4191
|
+
},
|
|
4192
|
+
decode(input, length) {
|
|
4193
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
4194
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
4195
|
+
const message = createBaseMsgRegisterNftAvatar();
|
|
4196
|
+
while (reader.pos < end) {
|
|
4197
|
+
const tag = reader.uint32();
|
|
4198
|
+
switch (tag >>> 3) {
|
|
4199
|
+
case 1: {
|
|
4200
|
+
if (tag !== 10) {
|
|
4201
|
+
break;
|
|
4202
|
+
}
|
|
4203
|
+
message.creator = reader.string();
|
|
4204
|
+
continue;
|
|
4205
|
+
}
|
|
4206
|
+
case 2: {
|
|
4207
|
+
if (tag !== 18) {
|
|
4208
|
+
break;
|
|
4209
|
+
}
|
|
4210
|
+
message.ethAddress = reader.string();
|
|
4211
|
+
continue;
|
|
4212
|
+
}
|
|
4213
|
+
case 3: {
|
|
4214
|
+
if (tag !== 26) {
|
|
4215
|
+
break;
|
|
4216
|
+
}
|
|
4217
|
+
message.contractAddress = reader.string();
|
|
4218
|
+
continue;
|
|
4219
|
+
}
|
|
4220
|
+
case 4: {
|
|
4221
|
+
if (tag !== 34) {
|
|
4222
|
+
break;
|
|
4223
|
+
}
|
|
4224
|
+
message.tokenId = reader.string();
|
|
4225
|
+
continue;
|
|
4226
|
+
}
|
|
4227
|
+
case 5: {
|
|
4228
|
+
if (tag !== 42) {
|
|
4229
|
+
break;
|
|
4230
|
+
}
|
|
4231
|
+
message.ethSignature = reader.string();
|
|
4232
|
+
continue;
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
4236
|
+
break;
|
|
4237
|
+
}
|
|
4238
|
+
reader.skip(tag & 7);
|
|
4239
|
+
}
|
|
4240
|
+
return message;
|
|
4241
|
+
},
|
|
4242
|
+
fromJSON(object) {
|
|
4243
|
+
return {
|
|
4244
|
+
creator: isSet$2b(object.creator) ? globalThis.String(object.creator) : "",
|
|
4245
|
+
ethAddress: isSet$2b(object.ethAddress) ? globalThis.String(object.ethAddress) : "",
|
|
4246
|
+
contractAddress: isSet$2b(object.contractAddress) ? globalThis.String(object.contractAddress) : "",
|
|
4247
|
+
tokenId: isSet$2b(object.tokenId) ? globalThis.String(object.tokenId) : "",
|
|
4248
|
+
ethSignature: isSet$2b(object.ethSignature) ? globalThis.String(object.ethSignature) : "",
|
|
4249
|
+
};
|
|
4250
|
+
},
|
|
4251
|
+
toJSON(message) {
|
|
4252
|
+
const obj = {};
|
|
4253
|
+
if (message.creator !== "") {
|
|
4254
|
+
obj.creator = message.creator;
|
|
4255
|
+
}
|
|
4256
|
+
if (message.ethAddress !== "") {
|
|
4257
|
+
obj.ethAddress = message.ethAddress;
|
|
4258
|
+
}
|
|
4259
|
+
if (message.contractAddress !== "") {
|
|
4260
|
+
obj.contractAddress = message.contractAddress;
|
|
4261
|
+
}
|
|
4262
|
+
if (message.tokenId !== "") {
|
|
4263
|
+
obj.tokenId = message.tokenId;
|
|
4264
|
+
}
|
|
4265
|
+
if (message.ethSignature !== "") {
|
|
4266
|
+
obj.ethSignature = message.ethSignature;
|
|
4267
|
+
}
|
|
4268
|
+
return obj;
|
|
4269
|
+
},
|
|
4270
|
+
create(base) {
|
|
4271
|
+
return MsgRegisterNftAvatar.fromPartial(base ?? {});
|
|
4272
|
+
},
|
|
4273
|
+
fromPartial(object) {
|
|
4274
|
+
const message = createBaseMsgRegisterNftAvatar();
|
|
4275
|
+
message.creator = object.creator ?? "";
|
|
4276
|
+
message.ethAddress = object.ethAddress ?? "";
|
|
4277
|
+
message.contractAddress = object.contractAddress ?? "";
|
|
4278
|
+
message.tokenId = object.tokenId ?? "";
|
|
4279
|
+
message.ethSignature = object.ethSignature ?? "";
|
|
4280
|
+
return message;
|
|
4281
|
+
},
|
|
4282
|
+
};
|
|
4170
4283
|
function isSet$2b(value) {
|
|
4171
4284
|
return value !== null && value !== undefined;
|
|
4172
4285
|
}
|
|
@@ -4187,6 +4300,7 @@ const msgTypes$u = [
|
|
|
4187
4300
|
["/pokerchain.poker.v1.MsgUpdateEthBlockHeight", MsgUpdateEthBlockHeight],
|
|
4188
4301
|
["/pokerchain.poker.v1.MsgTopUp", MsgTopUp],
|
|
4189
4302
|
["/pokerchain.poker.v1.MsgDeleteGame", MsgDeleteGame],
|
|
4303
|
+
["/pokerchain.poker.v1.MsgRegisterNftAvatar", MsgRegisterNftAvatar],
|
|
4190
4304
|
];
|
|
4191
4305
|
|
|
4192
4306
|
/**
|
|
@@ -57962,6 +58076,42 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
57962
58076
|
throw error;
|
|
57963
58077
|
}
|
|
57964
58078
|
}
|
|
58079
|
+
/**
|
|
58080
|
+
* Sign a pending withdrawal request (validator/relayer operation)
|
|
58081
|
+
* Generates an ECDSA signature compatible with the Base chain CosmosBridge contract
|
|
58082
|
+
*/
|
|
58083
|
+
async signWithdrawal(nonce, validatorEthKeyHex) {
|
|
58084
|
+
await this.initializeSigningClient();
|
|
58085
|
+
if (!this.signingClient || !this.wallet) {
|
|
58086
|
+
throw new Error("Signing client not initialized");
|
|
58087
|
+
}
|
|
58088
|
+
const [account] = await this.wallet.getAccounts();
|
|
58089
|
+
const signer = account.address;
|
|
58090
|
+
const msgSignWithdrawal = {
|
|
58091
|
+
signer,
|
|
58092
|
+
nonce,
|
|
58093
|
+
validatorEthKeyHex
|
|
58094
|
+
};
|
|
58095
|
+
const msg = {
|
|
58096
|
+
typeUrl: "/pokerchain.poker.v1.MsgSignWithdrawal",
|
|
58097
|
+
value: msgSignWithdrawal
|
|
58098
|
+
};
|
|
58099
|
+
const fee = gaslessFee();
|
|
58100
|
+
const memo = "Sign pending withdrawal request";
|
|
58101
|
+
console.log("🔏 Signing withdrawal:", {
|
|
58102
|
+
signer,
|
|
58103
|
+
nonce
|
|
58104
|
+
});
|
|
58105
|
+
try {
|
|
58106
|
+
const result = await this.signingClient.signAndBroadcast(signer, [msg], fee, memo);
|
|
58107
|
+
console.log("✅ Withdrawal signing successful:", result.transactionHash);
|
|
58108
|
+
return result.transactionHash;
|
|
58109
|
+
}
|
|
58110
|
+
catch (error) {
|
|
58111
|
+
console.error("❌ Withdrawal signing failed:", error);
|
|
58112
|
+
throw error;
|
|
58113
|
+
}
|
|
58114
|
+
}
|
|
57965
58115
|
/**
|
|
57966
58116
|
* Query a specific withdrawal request by nonce
|
|
57967
58117
|
*/
|
|
@@ -58112,6 +58262,93 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
58112
58262
|
getWallet() {
|
|
58113
58263
|
return this.wallet;
|
|
58114
58264
|
}
|
|
58265
|
+
/**
|
|
58266
|
+
* Register an NFT as the player's avatar
|
|
58267
|
+
*
|
|
58268
|
+
* This broadcasts a MsgRegisterNftAvatar transaction containing:
|
|
58269
|
+
* - The ETH address that owns the NFT
|
|
58270
|
+
* - The NFT contract address and token ID
|
|
58271
|
+
* - An ETH signature proving the ETH address owner authorizes this cosmos address
|
|
58272
|
+
* to use the NFT as their avatar
|
|
58273
|
+
*
|
|
58274
|
+
* The validator verifies the ETH signature via ecrecover and, if valid,
|
|
58275
|
+
* stores the mapping on-chain: cosmosAddress → (contractAddress, tokenId)
|
|
58276
|
+
*
|
|
58277
|
+
* @param ethAddress - The ETH address that owns the NFT
|
|
58278
|
+
* @param contractAddress - The NFT contract address on Ethereum/Base
|
|
58279
|
+
* @param tokenId - The NFT token ID
|
|
58280
|
+
* @param ethSignature - EIP-191 signature proving ETH address ownership
|
|
58281
|
+
* @returns Transaction hash
|
|
58282
|
+
*/
|
|
58283
|
+
async registerNftAvatar(ethAddress, contractAddress, tokenId, ethSignature) {
|
|
58284
|
+
await this.initializeSigningClient();
|
|
58285
|
+
if (!this.signingClient || !this.wallet) {
|
|
58286
|
+
throw new Error("Signing client not initialized");
|
|
58287
|
+
}
|
|
58288
|
+
const [account] = await this.wallet.getAccounts();
|
|
58289
|
+
const creator = account.address;
|
|
58290
|
+
// Create the message object
|
|
58291
|
+
const msgRegisterNftAvatar = {
|
|
58292
|
+
creator,
|
|
58293
|
+
ethAddress,
|
|
58294
|
+
contractAddress,
|
|
58295
|
+
tokenId,
|
|
58296
|
+
ethSignature
|
|
58297
|
+
};
|
|
58298
|
+
// Create the transaction message
|
|
58299
|
+
const msg = {
|
|
58300
|
+
typeUrl: "/pokerchain.poker.v1.MsgRegisterNftAvatar",
|
|
58301
|
+
value: msgRegisterNftAvatar
|
|
58302
|
+
};
|
|
58303
|
+
const fee = gaslessFee();
|
|
58304
|
+
const memo = "Register NFT avatar via SDK";
|
|
58305
|
+
console.log("🖼️ Registering NFT avatar:", {
|
|
58306
|
+
creator,
|
|
58307
|
+
ethAddress,
|
|
58308
|
+
contractAddress,
|
|
58309
|
+
tokenId: tokenId.substring(0, 20) + (tokenId.length > 20 ? "..." : "")
|
|
58310
|
+
});
|
|
58311
|
+
try {
|
|
58312
|
+
const result = await this.signingClient.signAndBroadcast(creator, [msg], fee, memo);
|
|
58313
|
+
console.log("✅ NFT avatar registration successful:", result.transactionHash);
|
|
58314
|
+
return result.transactionHash;
|
|
58315
|
+
}
|
|
58316
|
+
catch (error) {
|
|
58317
|
+
console.error("❌ NFT avatar registration failed:", error);
|
|
58318
|
+
throw error;
|
|
58319
|
+
}
|
|
58320
|
+
}
|
|
58321
|
+
/**
|
|
58322
|
+
* Query a registered NFT avatar for a cosmos address
|
|
58323
|
+
*
|
|
58324
|
+
* @param cosmosAddress - The cosmos address to look up
|
|
58325
|
+
* @returns The NFT avatar data if registered, or null if not found
|
|
58326
|
+
*/
|
|
58327
|
+
async queryNftAvatar(cosmosAddress) {
|
|
58328
|
+
try {
|
|
58329
|
+
const response = await fetch(`${this.config.restEndpoint}/pokerchain/poker/nft_avatar/${encodeURIComponent(cosmosAddress)}`);
|
|
58330
|
+
if (!response.ok) {
|
|
58331
|
+
if (response.status === 404) {
|
|
58332
|
+
return null;
|
|
58333
|
+
}
|
|
58334
|
+
throw new Error(`Failed to query NFT avatar: ${response.statusText}`);
|
|
58335
|
+
}
|
|
58336
|
+
const data = await response.json();
|
|
58337
|
+
if (!data.contract_address || !data.token_id) {
|
|
58338
|
+
return null;
|
|
58339
|
+
}
|
|
58340
|
+
return {
|
|
58341
|
+
cosmosAddress: data.cosmos_address || cosmosAddress,
|
|
58342
|
+
ethAddress: data.eth_address || "",
|
|
58343
|
+
contractAddress: data.contract_address,
|
|
58344
|
+
tokenId: data.token_id
|
|
58345
|
+
};
|
|
58346
|
+
}
|
|
58347
|
+
catch (error) {
|
|
58348
|
+
console.error("❌ queryNftAvatar() failed:", error);
|
|
58349
|
+
throw error;
|
|
58350
|
+
}
|
|
58351
|
+
}
|
|
58115
58352
|
}
|
|
58116
58353
|
/**
|
|
58117
58354
|
* Create a signing client with a wallet
|