bomb-panic-sdk
v0.1.12
Published
Thin TypeScript helpers for Bomb Panic + GameHub flows. This SDK only builds transactions and parses on-chain data. You still sign/execute transactions with your wallet or server signer.
Downloads
66
Readme
Bomb Panic SDK (Local)
Thin TypeScript helpers for Bomb Panic + GameHub flows. This SDK only builds transactions and parses on-chain data. You still sign/execute transactions with your wallet or server signer.
Install / Import (local)
From the repo root:
import { SuiClient } from '@onelabs/sui/client';
import {
buildJoinAndReadyTx,
buildPassBombTx,
getLobbyRoomGamePairs,
getRoomAndGameParsed,
parseRoom,
type SdkConfig,
} from './sdk/index.js';Config
const sdkConfig: SdkConfig = {
packageId: '<PACKAGE_ID>',
coinType: '0x2::oct::OCT',
// optional overrides
randomId: '0x8',
clockId: '0x6',
};Paying With Non-Gas Coins
These helpers need a Coin<coinType> input for create_room (creation fee) and ready_to_play (entry fee).
If coinType is not your gas coin, you can either:
- pass a coin object id to split from, or
- pass
client+ownerso the SDK merges/splits for you.
Read Examples
const client = new SuiClient({ url: RPC_URL });
const pairs = await getLobbyRoomGamePairs(client, LOBBY_ID);
const roomIds = pairs.map(p => p.roomId);
const rooms = await client.multiGetObjects({
ids: roomIds,
options: { showContent: true, showType: true },
});
const parsedRooms = rooms
.map(r => parseRoom(r.data?.content))
.filter(Boolean);
const { room, game } = await getRoomAndGameParsed(client, ROOM_ID, GAME_STATE_ID);Tx Examples
const tx = await buildJoinAndReadyTx(sdkConfig, {
roomId: ROOM_ID,
gameStateId: GAME_STATE_ID,
entryFee: ENTRY_FEE,
});
await wallet.signAndExecuteTransaction({ transaction: tx });
const passTx = buildPassBombTx(sdkConfig, { gameStateId: GAME_STATE_ID });
await wallet.signAndExecuteTransaction({ transaction: passTx });Example: HACKATHON (non-gas coin)
const HACKATHON = '0x8b76fc2a2317d45118770cefed7e57171a08c477ed16283616b15f099391f120::hackathon::HACKATHON';
const hackConfig: SdkConfig = { packageId: '<PACKAGE_ID>', coinType: HACKATHON };
const createTx = await buildCreateRoomTx(hackConfig, {
gameRegistryId: GAME_REGISTRY_ID,
configId: CONFIG_ID,
entryFee: ENTRY_FEE,
maxPlayers: 4,
creationFee: 100,
client,
owner: WALLET_ADDRESS,
});
const readyTx = await buildReadyTx(hackConfig, {
roomId: ROOM_ID,
entryFee: ENTRY_FEE,
client,
owner: WALLET_ADDRESS,
});Notes
- Fee-paying helpers return
Promise<Transaction>(they may query/merge coins). - Read helpers return raw objects or parsed shapes for UI/DB use.
- See
docs/INTEGRATION_SHORT_SDK.mdfor full end-to-end usage.
