bomb-panic-sdk 0.1.1 → 0.1.3

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './types.js';
2
- export * from './parse.js';
3
- export * from './read.js';
4
- export * from './tx.js';
1
+ export * from "./read.js";
2
+ export * from "./parse.js";
3
+ export * from "./tx.js";
4
+ export * from "./types.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './types.js';
2
- export * from './parse.js';
3
- export * from './read.js';
4
- export * from './tx.js';
1
+ export * from "./read.js";
2
+ export * from "./parse.js";
3
+ export * from "./tx.js";
4
+ export * from "./types.js";
package/dist/parse.js CHANGED
@@ -61,7 +61,7 @@ export function parseRoom(content) {
61
61
  const entryFee = toBigInt(fields.entry_fee);
62
62
  const maxPlayers = Number(fields.max_players ?? 0);
63
63
  const playerCount = Number(fields.player_balances?.fields?.size ?? 0);
64
- const poolValue = toBigInt(fields.pool?.fields?.value ?? fields.pool?.value ?? 0);
64
+ const poolValue = toBigInt(fields.pool?.fields?.value ?? fields.pool?.value ?? fields.pool ?? 0);
65
65
  // Ready count: use ready_players table size
66
66
  // The table contains all players who have called ready_to_play (value=true means ready)
67
67
  // Since we can't iterate the table from serialized content, we use pool-based estimation
package/dist/tx.d.ts CHANGED
@@ -59,6 +59,13 @@ export declare function buildSettleRoundWithHubTx(config: SdkConfig, args: {
59
59
  roomId: string;
60
60
  gameCapId: string;
61
61
  }): Transaction;
62
+ export declare function buildResetRoomTx(config: SdkConfig, args: {
63
+ roomId: string;
64
+ gameCapId: string;
65
+ }): Transaction;
66
+ export declare function buildResetGameTx(config: SdkConfig, args: {
67
+ gameStateId: string;
68
+ }): Transaction;
62
69
  export declare function buildPrepareNextRoundTx(config: SdkConfig, args: {
63
70
  gameStateId: string;
64
71
  newRoomId: string;
package/dist/tx.js CHANGED
@@ -51,7 +51,11 @@ export function buildJoinTx(config, args) {
51
51
  }
52
52
  export function buildReadyTx(config, args) {
53
53
  const tx = new Transaction();
54
- const [entryCoin] = tx.splitCoins(tx.gas, [tx.pure.u64(toU64(args.entryFee))]);
54
+ // For OCT, we need to provide 2x entry fee to prove 50% balance
55
+ // The contract will take entry_fee and refund the rest
56
+ const isOCT = config.coinType === '0x2::oct::OCT';
57
+ const coinAmount = isOCT ? toU64(args.entryFee) * 2n : toU64(args.entryFee);
58
+ const [entryCoin] = tx.splitCoins(tx.gas, [tx.pure.u64(coinAmount)]);
55
59
  tx.moveCall({
56
60
  target: `${config.packageId}::gamehub::ready_to_play`,
57
61
  arguments: [tx.object(args.roomId), entryCoin],
@@ -61,7 +65,11 @@ export function buildReadyTx(config, args) {
61
65
  }
62
66
  export function buildJoinAndReadyTx(config, args) {
63
67
  const tx = new Transaction();
64
- const [entryCoin] = tx.splitCoins(tx.gas, [tx.pure.u64(toU64(args.entryFee))]);
68
+ // For OCT, we need to provide 2x entry fee to prove 50% balance
69
+ // The contract will take entry_fee and refund the rest
70
+ const isOCT = config.coinType === '0x2::oct::OCT';
71
+ const coinAmount = isOCT ? toU64(args.entryFee) * 2n : toU64(args.entryFee);
72
+ const [entryCoin] = tx.splitCoins(tx.gas, [tx.pure.u64(coinAmount)]);
65
73
  tx.moveCall({
66
74
  target: `${config.packageId}::gamehub::join_room`,
67
75
  arguments: [tx.object(args.roomId)],
@@ -81,7 +89,11 @@ export function buildJoinAndReadyTx(config, args) {
81
89
  }
82
90
  export function buildReadyNextRoundTx(config, args) {
83
91
  const tx = new Transaction();
84
- const [entryCoin] = tx.splitCoins(tx.gas, [tx.pure.u64(toU64(args.entryFee))]);
92
+ // For OCT, we need to provide 2x entry fee to prove 50% balance
93
+ // The contract will take entry_fee and refund the rest
94
+ const isOCT = config.coinType === '0x2::oct::OCT';
95
+ const coinAmount = isOCT ? toU64(args.entryFee) * 2n : toU64(args.entryFee);
96
+ const [entryCoin] = tx.splitCoins(tx.gas, [tx.pure.u64(coinAmount)]);
85
97
  tx.moveCall({
86
98
  target: `${config.packageId}::gamehub::join_room`,
87
99
  arguments: [tx.object(args.roomId)],
@@ -190,6 +202,24 @@ export function buildSettleRoundWithHubTx(config, args) {
190
202
  });
191
203
  return tx;
192
204
  }
205
+ export function buildResetRoomTx(config, args) {
206
+ const tx = new Transaction();
207
+ tx.moveCall({
208
+ target: `${config.packageId}::gamehub::reset_room`,
209
+ arguments: [tx.object(args.roomId), tx.object(args.gameCapId)],
210
+ typeArguments: [config.coinType],
211
+ });
212
+ return tx;
213
+ }
214
+ export function buildResetGameTx(config, args) {
215
+ const tx = new Transaction();
216
+ tx.moveCall({
217
+ target: `${config.packageId}::bomb_panic::reset_game`,
218
+ arguments: [tx.object(args.gameStateId)],
219
+ typeArguments: [config.coinType],
220
+ });
221
+ return tx;
222
+ }
193
223
  export function buildPrepareNextRoundTx(config, args) {
194
224
  const tx = new Transaction();
195
225
  tx.moveCall({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bomb-panic-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,5 +11,8 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "build": "tsc -p tsconfig.json"
14
+ },
15
+ "dependencies": {
16
+ "bomb-panic-sdk": "^0.1.1"
14
17
  }
15
18
  }