@dimcool/sdk 0.1.31 → 0.1.32

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/README.md CHANGED
@@ -1572,6 +1572,8 @@ const newFlag = await sdk.featureFlags.createFeatureFlag('new-feature', false);
1572
1572
 
1573
1573
  Create a new game lobby.
1574
1574
 
1575
+ > **Note:** Creating a lobby automatically closes and refunds any existing open or queued lobby for this user. You do not need to manually leave or cancel a previous lobby first.
1576
+
1575
1577
  ```typescript
1576
1578
  const lobby = await sdk.lobbies.createLobby('rock-paper-scissors');
1577
1579
  // lobby: { id, gameType, status, creatorId, maxPlayers, players: [...], ... }
@@ -1729,51 +1731,6 @@ const lobby = await sdk.lobbies.cancelQueue('lobby-id');
1729
1731
 
1730
1732
  **Note:** The queue is automatically cancelled if any player leaves the lobby while it's in queue.
1731
1733
 
1732
- #### `playAgain(gameType: string, betAmount: number, escrow: Escrow): Promise<{ lobby: Lobby; unsignedTransaction: string }>`
1733
-
1734
- Create a new lobby, start deposits, and prepare a deposit transaction for playing again with the same bet amount. This is a convenience method that combines lobby creation, deposit initialization, and transaction preparation.
1735
-
1736
- ```typescript
1737
- const { lobby, unsignedTransaction } = await sdk.lobbies.playAgain(
1738
- 'rock-paper-scissors',
1739
- 25,
1740
- sdk.escrow,
1741
- );
1742
- ```
1743
-
1744
- **Parameters:**
1745
-
1746
- - `gameType: string` - The game type to play again (e.g., 'rock-paper-scissors')
1747
- - `betAmount: number` - The bet amount (same as previous game)
1748
- - `escrow: Escrow` - The escrow service instance (from `sdk.escrow`)
1749
-
1750
- **Returns:**
1751
-
1752
- - `Promise<{ lobby: Lobby; unsignedTransaction: string }>` - The created lobby and unsigned transaction (base64 encoded) that needs to be signed
1753
-
1754
- **Behavior:**
1755
-
1756
- 1. Creates a new lobby with the specified game type and bet amount
1757
- 2. Starts the deposit flow (transitions lobby to 'preparing' state)
1758
- 3. Prepares the deposit transaction
1759
- 4. Returns the lobby and unsigned transaction
1760
-
1761
- **Example:**
1762
-
1763
- ```typescript
1764
- // Play again with same bet amount
1765
- const { lobby, unsignedTransaction } = await sdk.lobbies.playAgain(
1766
- 'rock-paper-scissors',
1767
- 25,
1768
- sdk.escrow,
1769
- );
1770
-
1771
- // Deposit and wait for your own deposit to confirm (polls status endpoint)
1772
- const result = await sdk.escrow.depositForLobbySync(lobby.id);
1773
- ```
1774
-
1775
- **Note:** After `playAgain()`, use `depositForLobbySync()` (for agents) or `depositForLobby()` (for React hooks) to complete the deposit flow. The server auto-joins the matchmaking queue when all deposits are confirmed.
1776
-
1777
1734
  ### Admin Methods
1778
1735
 
1779
1736
  #### `getActiveLobbies(): Promise<Lobby[]>` (Admin Only)
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ var require_money = __commonJS({
35
35
  "../utils/dist/money.js"(exports2) {
36
36
  "use strict";
37
37
  Object.defineProperty(exports2, "__esModule", { value: true });
38
- exports2.SOL_LAMPORTS = exports2.MICRO_UNITS = void 0;
38
+ exports2.SOL_MINT = exports2.SOL_LAMPORTS = exports2.MICRO_UNITS = void 0;
39
39
  exports2.isSolMint = isSolMint;
40
40
  exports2.formatMoneyMinor = formatMoneyMinor2;
41
41
  exports2.toMajor = toMajor2;
@@ -48,12 +48,12 @@ var require_money = __commonJS({
48
48
  exports2.formatMoneyMinorCompact = formatMoneyMinorCompact;
49
49
  exports2.MICRO_UNITS = 1e6;
50
50
  exports2.SOL_LAMPORTS = 1e9;
51
- var SOL_MINT_LABEL = "SOL";
51
+ exports2.SOL_MINT = "SOL";
52
52
  var SOL_SYSTEM_PROGRAM = "11111111111111111111111111111111";
53
53
  function isSolMint(mint) {
54
54
  if (!mint)
55
55
  return false;
56
- return mint === SOL_MINT_LABEL || mint === SOL_SYSTEM_PROGRAM;
56
+ return mint === exports2.SOL_MINT || mint === SOL_SYSTEM_PROGRAM;
57
57
  }
58
58
  function formatMoneyMinor2(amountMinor, fractionDigits = 2) {
59
59
  return (amountMinor / exports2.MICRO_UNITS).toFixed(fractionDigits);
@@ -159,7 +159,7 @@ var require_dist = __commonJS({
159
159
  "../utils/dist/index.js"(exports2) {
160
160
  "use strict";
161
161
  Object.defineProperty(exports2, "__esModule", { value: true });
162
- exports2.formatMoneyMinorCompact = exports2.formatCurrencyPartsForToken = exports2.formatCurrencyParts = exports2.kformatMoney = exports2.kformat = exports2.formatSolMinor = exports2.toSolMajor = exports2.toMajor = exports2.formatMoneyMinor = exports2.isSolMint = exports2.SOL_LAMPORTS = exports2.MICRO_UNITS = void 0;
162
+ exports2.formatMoneyMinorCompact = exports2.formatCurrencyPartsForToken = exports2.formatCurrencyParts = exports2.kformatMoney = exports2.kformat = exports2.formatSolMinor = exports2.toSolMajor = exports2.toMajor = exports2.formatMoneyMinor = exports2.isSolMint = exports2.SOL_MINT = exports2.SOL_LAMPORTS = exports2.MICRO_UNITS = void 0;
163
163
  var money_1 = require_money();
164
164
  Object.defineProperty(exports2, "MICRO_UNITS", { enumerable: true, get: function() {
165
165
  return money_1.MICRO_UNITS;
@@ -167,6 +167,9 @@ var require_dist = __commonJS({
167
167
  Object.defineProperty(exports2, "SOL_LAMPORTS", { enumerable: true, get: function() {
168
168
  return money_1.SOL_LAMPORTS;
169
169
  } });
170
+ Object.defineProperty(exports2, "SOL_MINT", { enumerable: true, get: function() {
171
+ return money_1.SOL_MINT;
172
+ } });
170
173
  Object.defineProperty(exports2, "isSolMint", { enumerable: true, get: function() {
171
174
  return money_1.isSolMint;
172
175
  } });
@@ -209,7 +212,7 @@ __export(index_exports, {
209
212
  ESTIMATED_SOL_FEE_LAMPORTS: () => ESTIMATED_SOL_FEE_LAMPORTS,
210
213
  HttpClient: () => HttpClient,
211
214
  Leaderboards: () => Leaderboards,
212
- MICRO_UNITS: () => import_utils.MICRO_UNITS,
215
+ MICRO_UNITS: () => import_utils2.MICRO_UNITS,
213
216
  MIN_SOL_TRANSFER_AMOUNT: () => MIN_SOL_TRANSFER_AMOUNT,
214
217
  MIN_TRANSFER_AMOUNT: () => MIN_TRANSFER_AMOUNT,
215
218
  Markets: () => Markets,
@@ -220,7 +223,7 @@ __export(index_exports, {
220
223
  SDK: () => SDK,
221
224
  SDK_VERSION: () => SDK_VERSION,
222
225
  SOL_DECIMALS: () => SOL_DECIMALS,
223
- SOL_MINT: () => SOL_MINT,
226
+ SOL_MINT: () => import_utils.SOL_MINT,
224
227
  SharedWorkerTransport: () => SharedWorkerTransport,
225
228
  Spectate: () => Spectate,
226
229
  StandaloneWsTransport: () => StandaloneWsTransport,
@@ -239,11 +242,11 @@ __export(index_exports, {
239
242
  createLogger: () => createLogger,
240
243
  createNotificationsStore: () => createNotificationsStore,
241
244
  createSdkStore: () => createSdkStore,
242
- formatMoneyMinor: () => import_utils.formatMoneyMinor,
245
+ formatMoneyMinor: () => import_utils2.formatMoneyMinor,
243
246
  isRetryableError: () => isRetryableError,
244
247
  logger: () => logger,
245
248
  selectGameLifecycleState: () => selectGameLifecycleState,
246
- toMajor: () => import_utils.toMajor,
249
+ toMajor: () => import_utils2.toMajor,
247
250
  withRetry: () => withRetry
248
251
  });
249
252
  module.exports = __toCommonJS(index_exports);
@@ -1157,6 +1160,13 @@ var Lobbies = class {
1157
1160
  setLobbyStore(store) {
1158
1161
  this.lobbyStore = store;
1159
1162
  }
1163
+ /**
1164
+ * Create a new game lobby.
1165
+ *
1166
+ * **Important:** Creating a lobby automatically closes and refunds any
1167
+ * existing open or queued lobby for this user. You do not need to manually
1168
+ * leave or cancel a previous lobby before calling this.
1169
+ */
1160
1170
  async createLobby(gameType, betAmount) {
1161
1171
  return this.http.post("/lobbies", { gameType, betAmount });
1162
1172
  }
@@ -1220,21 +1230,6 @@ var Lobbies = class {
1220
1230
  async deleteLobby(lobbyId) {
1221
1231
  return this.http.delete(`/lobbies/admin/${lobbyId}`);
1222
1232
  }
1223
- /**
1224
- * Play again: Create a new lobby and prepare deposit in one flow.
1225
- * Returns the lobby and unsigned transaction that needs to be signed.
1226
- * @param gameType - The game type to play again
1227
- * @param betAmount - The bet amount (same as previous game)
1228
- * @param escrow - The escrow service instance (from sdk.escrow)
1229
- */
1230
- async playAgain(gameType, betAmount, escrow) {
1231
- const lobby = await this.createLobby(gameType, betAmount);
1232
- const { transaction } = await escrow.prepareAndStartDeposit(lobby.id);
1233
- return {
1234
- lobby,
1235
- unsignedTransaction: transaction
1236
- };
1237
- }
1238
1233
  };
1239
1234
 
1240
1235
  // src/games.ts
@@ -1773,11 +1768,11 @@ var Achievements = class {
1773
1768
 
1774
1769
  // src/wallet.ts
1775
1770
  var import_web32 = require("@solana/web3.js");
1771
+ var import_utils = __toESM(require_dist(), 1);
1776
1772
  var TRANSFER_FEE_MINOR = 1e4;
1777
1773
  var MIN_TRANSFER_AMOUNT = 5e4;
1778
1774
  var MIN_SOL_TRANSFER_AMOUNT = 1e6;
1779
1775
  var SOL_DECIMALS = 9;
1780
- var SOL_MINT = "SOL";
1781
1776
  var ESTIMATED_SOL_FEE_LAMPORTS = 1e4;
1782
1777
  var Wallet = class {
1783
1778
  constructor(http, logger2) {
@@ -5018,7 +5013,7 @@ var SharedWorkerTransport = class extends BaseWsTransport {
5018
5013
  };
5019
5014
 
5020
5015
  // src/utils/money.ts
5021
- var import_utils = __toESM(require_dist(), 1);
5016
+ var import_utils2 = __toESM(require_dist(), 1);
5022
5017
  // Annotate the CommonJS export names for ESM import in node:
5023
5018
  0 && (module.exports = {
5024
5019
  Admin,
package/dist/index.d.cts CHANGED
@@ -5,7 +5,7 @@ import { NimGameState, NimGameAction } from '@dimcool/nim';
5
5
  import { DotsAndBoxesGameState, DotsAndBoxesGameAction } from '@dimcool/dots-and-boxes';
6
6
  import { TicTacToeGameState, TicTacToeGameAction } from '@dimcool/tic-tac-toe';
7
7
  import { Connect4GameState, Connect4GameAction } from '@dimcool/connect-four';
8
- export { MICRO_UNITS, formatMoneyMinor, toMajor } from '@dimcool/utils';
8
+ export { MICRO_UNITS, SOL_MINT, formatMoneyMinor, toMajor } from '@dimcool/utils';
9
9
 
10
10
  /**
11
11
  * Interface for HTTP client implementations.
@@ -929,7 +929,7 @@ declare const TRANSFER_FEE_MINOR = 10000;
929
929
  declare const MIN_TRANSFER_AMOUNT = 50000;
930
930
  declare const MIN_SOL_TRANSFER_AMOUNT = 1000000;
931
931
  declare const SOL_DECIMALS = 9;
932
- declare const SOL_MINT = "SOL";
932
+
933
933
  declare const ESTIMATED_SOL_FEE_LAMPORTS = 10000;
934
934
  interface PrepareTransferRequest {
935
935
  senderAddress: string;
@@ -2094,6 +2094,13 @@ declare class Lobbies {
2094
2094
  constructor(http: IHttpClient, logger?: ILogger | undefined);
2095
2095
  /** Called by SDK after the store is created so mutations can update state directly. */
2096
2096
  setLobbyStore(store: LobbyStore): void;
2097
+ /**
2098
+ * Create a new game lobby.
2099
+ *
2100
+ * **Important:** Creating a lobby automatically closes and refunds any
2101
+ * existing open or queued lobby for this user. You do not need to manually
2102
+ * leave or cancel a previous lobby before calling this.
2103
+ */
2097
2104
  createLobby(gameType: string, betAmount?: MoneyMinor): Promise<Lobby>;
2098
2105
  getLobby(lobbyId: string): Promise<Lobby>;
2099
2106
  inviteFriend(lobbyId: string, friendId: string): Promise<{
@@ -2121,22 +2128,6 @@ declare class Lobbies {
2121
2128
  deleteLobby(lobbyId: string): Promise<{
2122
2129
  message: string;
2123
2130
  }>;
2124
- /**
2125
- * Play again: Create a new lobby and prepare deposit in one flow.
2126
- * Returns the lobby and unsigned transaction that needs to be signed.
2127
- * @param gameType - The game type to play again
2128
- * @param betAmount - The bet amount (same as previous game)
2129
- * @param escrow - The escrow service instance (from sdk.escrow)
2130
- */
2131
- playAgain(gameType: string, betAmount: MoneyMinor, escrow: {
2132
- prepareAndStartDeposit: (id: string) => Promise<{
2133
- transaction: string;
2134
- message: string;
2135
- }>;
2136
- }): Promise<{
2137
- lobby: Lobby;
2138
- unsignedTransaction: string;
2139
- }>;
2140
2131
  }
2141
2132
 
2142
2133
  /** A player currently in an active game; used for "Live now" and "Who to watch" UI. */
@@ -3057,4 +3048,4 @@ declare class HttpClient implements IHttpClient {
3057
3048
  private payChallenge;
3058
3049
  }
3059
3050
 
3060
- export { type AcceptChallengeResponse, type Achievement, Activity, type ActivityFeedItem, type ActivityFeedItemType, type ActivityFeedResponse, type ActivityFeedUser, Admin, type AdminDailyStats, type AdminDailyStatsItem, type AdminFeatureFlag, type AdminGameHistory, type AdminGameHistoryFeeBreakdown, type AdminGameHistoryFeePlayer, type AdminGameHistoryPlayer, type AdminMarketDailyStats, type AdminMarketDailyStatsItem, type AdminMarketDetail, type AdminMarketStats, type AdminStats, type AdminWalletActivityItem, type AdminWalletActivityResponse, type AnalyticsUserData, type ApiError, type AppNotification, type AppNotificationType, type ApplyReferralCodeResponse, type BalanceResponse, type BetOption, type BroadcastTipRequest, BrowserLocalStorage, Challenges, Chat, type ChatContext, type ChatContextType, type ChatMessage, type ChatMessageReply, type ChatMessageType, type ChatReaction, type ChatReadBy, type ChatState, type ChatStore, type ChatStoreState, type ChessCapturedPieces, type ChessClockTimes, type ClaimReferralRewardsResponse, type Connect4ClockTimes, type CreateChallengeRequest, type CreateChallengeResponse, type CreateLobbyRequest, type CreateTicketData, type CriticalIncident, type CriticalIncidentCategory, type CriticalIncidentImpactType, type CriticalIncidentSeverity, type CriticalIncidentStatus, type CriticalIncidentSummary, type CurrentGame, Daily, type DailyParticipant, type DailyRoom, type DailyToken, type DepositForLobbyResponse, type DepositStatus, type DepositStatusResponse, type DmThread, type DmThreadsStore, type DmThreadsStoreState, type DonateToGameResponse, ESTIMATED_SOL_FEE_LAMPORTS, Escrow, type EscrowSweepPreview, type EscrowSweepRecord, type FaucetResponse, type FeatureFlag, type FriendRequestItem, type FriendsStore, type FriendsStoreState, type FriendshipStatus, type Game, type GameActionsStore, type GameActionsStoreState, type GameHistoryItem, type GameLifecycleState, type GameMetrics, type GamePlayer, type GameStateResponse, type GameStore, type GameStoreState, type GameType, Games, type GenerateHandshakeResponse, type GetTicketsOptions, HttpClient, type IAnalyticsClient, type IHttpClient, type ILogger, type IStorage, type ImageUploadPayload, type InviteFriendRequest, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardRange, type LeaderboardResponse, Leaderboards, type LivePlayer, type LivePlayersPage, Lobbies, type Lobby, type LobbyDepositUpdatedPayload, type LobbyMatchedEvent, type LobbyPlayer, type LobbyStore, type LobbyStoreState, type LogLevel, type LoginResponse, MIN_SOL_TRANSFER_AMOUNT, MIN_TRANSFER_AMOUNT, type MarketBuyResult, type MarketPosition, type MarketSellResult, type MarketState, Markets, type MoneyMinor, NodeStorage, NoopAnalyticsClient, type NotificationEvent, type NotificationsStore, type NotificationsStoreState, type PaginatedCriticalIncidents, type PaginatedFriendRequests, type PaginatedFriends, type PaginatedNotificationsResponse, type PaginatedPlatformFees, type PaginatedReports, type PaginatedSearchUsers, type PaginatedSessions, type PaginatedSupportTickets, type PaginatedTransactionJobs, type PaginatedUsers, type PaymentRequiredChallenge, type PlatformFeeItem, type PrepareDepositResponse, type PrepareTipRequest, type PrepareTipResponse, type PrepareTransferRequest, type PrepareTransferResponse, type PublicUser, type QueueStats, type RedeemResult, type ReferralRewardItem, type ReferralRewardStatus, type ReferralRewardsResponse, type ReferralSummary, type ReferralTreeItem, type ReferralTreeResponse, Referrals, type Report, type ReportCount, type ReportStatus, type ReportUser, Reports, type RetryOptions, SDK, type SDKConfig, SDK_VERSION, SOL_DECIMALS, SOL_MINT, type SdkStore, type SdkUpgradeInfo, type SearchUser, type SendMessageRequest, type SendTipResponse, type SendTransferResponse, type Session, type SessionStats, SharedWorkerTransport, Spectate, type SpectatorMetrics, type SpectatorMetricsByUser, StandaloneWsTransport, type SubmitDepositResponse, type SubmitTransferRequest, type SubmitTransferResponse, Support, type SupportMessage, type SupportMessageSenderRole, type SupportTicket, type SupportTicketCategory, type SupportTicketPriority, type SupportTicketStatus, type SupportTicketUser, type SystemMessageType, TOKEN_KEY, TRANSFER_FEE_MINOR, type TicTacToeClockTimes, Tips, type TransactionJob, type TransactionJobStatus, type TransactionJobType, type TransactionQueueStats, type TransferToken, type TypingUser, type UpdateTicketData, type User, type UserAchievement, type UserActivity, type UserActivityStatus, type UserStats, type UsernameAvailabilityResponse, Users, type ValidAction, Wallet, type WalletActivityCounterpartyType, type WalletActivityDirection, type WalletActivityItem, type WalletActivityKind, type WalletActivityResponse, type WalletActivityStatus, type WalletClaimAction, type WalletMeta, type WalletResponse, type WalletSigner, type WsEvent, WsEventBus, type WsEventName, type WsTransport, type ConnectionState as WsTransportState, createChatStore, createDmThreadsStore, createFriendsStore, createGameActionsStore, createGameStore, createLobbyStore, createLogger, createNotificationsStore, createSdkStore, isRetryableError, logger, selectGameLifecycleState, withRetry };
3051
+ export { type AcceptChallengeResponse, type Achievement, Activity, type ActivityFeedItem, type ActivityFeedItemType, type ActivityFeedResponse, type ActivityFeedUser, Admin, type AdminDailyStats, type AdminDailyStatsItem, type AdminFeatureFlag, type AdminGameHistory, type AdminGameHistoryFeeBreakdown, type AdminGameHistoryFeePlayer, type AdminGameHistoryPlayer, type AdminMarketDailyStats, type AdminMarketDailyStatsItem, type AdminMarketDetail, type AdminMarketStats, type AdminStats, type AdminWalletActivityItem, type AdminWalletActivityResponse, type AnalyticsUserData, type ApiError, type AppNotification, type AppNotificationType, type ApplyReferralCodeResponse, type BalanceResponse, type BetOption, type BroadcastTipRequest, BrowserLocalStorage, Challenges, Chat, type ChatContext, type ChatContextType, type ChatMessage, type ChatMessageReply, type ChatMessageType, type ChatReaction, type ChatReadBy, type ChatState, type ChatStore, type ChatStoreState, type ChessCapturedPieces, type ChessClockTimes, type ClaimReferralRewardsResponse, type Connect4ClockTimes, type CreateChallengeRequest, type CreateChallengeResponse, type CreateLobbyRequest, type CreateTicketData, type CriticalIncident, type CriticalIncidentCategory, type CriticalIncidentImpactType, type CriticalIncidentSeverity, type CriticalIncidentStatus, type CriticalIncidentSummary, type CurrentGame, Daily, type DailyParticipant, type DailyRoom, type DailyToken, type DepositForLobbyResponse, type DepositStatus, type DepositStatusResponse, type DmThread, type DmThreadsStore, type DmThreadsStoreState, type DonateToGameResponse, ESTIMATED_SOL_FEE_LAMPORTS, Escrow, type EscrowSweepPreview, type EscrowSweepRecord, type FaucetResponse, type FeatureFlag, type FriendRequestItem, type FriendsStore, type FriendsStoreState, type FriendshipStatus, type Game, type GameActionsStore, type GameActionsStoreState, type GameHistoryItem, type GameLifecycleState, type GameMetrics, type GamePlayer, type GameStateResponse, type GameStore, type GameStoreState, type GameType, Games, type GenerateHandshakeResponse, type GetTicketsOptions, HttpClient, type IAnalyticsClient, type IHttpClient, type ILogger, type IStorage, type ImageUploadPayload, type InviteFriendRequest, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardRange, type LeaderboardResponse, Leaderboards, type LivePlayer, type LivePlayersPage, Lobbies, type Lobby, type LobbyDepositUpdatedPayload, type LobbyMatchedEvent, type LobbyPlayer, type LobbyStore, type LobbyStoreState, type LogLevel, type LoginResponse, MIN_SOL_TRANSFER_AMOUNT, MIN_TRANSFER_AMOUNT, type MarketBuyResult, type MarketPosition, type MarketSellResult, type MarketState, Markets, type MoneyMinor, NodeStorage, NoopAnalyticsClient, type NotificationEvent, type NotificationsStore, type NotificationsStoreState, type PaginatedCriticalIncidents, type PaginatedFriendRequests, type PaginatedFriends, type PaginatedNotificationsResponse, type PaginatedPlatformFees, type PaginatedReports, type PaginatedSearchUsers, type PaginatedSessions, type PaginatedSupportTickets, type PaginatedTransactionJobs, type PaginatedUsers, type PaymentRequiredChallenge, type PlatformFeeItem, type PrepareDepositResponse, type PrepareTipRequest, type PrepareTipResponse, type PrepareTransferRequest, type PrepareTransferResponse, type PublicUser, type QueueStats, type RedeemResult, type ReferralRewardItem, type ReferralRewardStatus, type ReferralRewardsResponse, type ReferralSummary, type ReferralTreeItem, type ReferralTreeResponse, Referrals, type Report, type ReportCount, type ReportStatus, type ReportUser, Reports, type RetryOptions, SDK, type SDKConfig, SDK_VERSION, SOL_DECIMALS, type SdkStore, type SdkUpgradeInfo, type SearchUser, type SendMessageRequest, type SendTipResponse, type SendTransferResponse, type Session, type SessionStats, SharedWorkerTransport, Spectate, type SpectatorMetrics, type SpectatorMetricsByUser, StandaloneWsTransport, type SubmitDepositResponse, type SubmitTransferRequest, type SubmitTransferResponse, Support, type SupportMessage, type SupportMessageSenderRole, type SupportTicket, type SupportTicketCategory, type SupportTicketPriority, type SupportTicketStatus, type SupportTicketUser, type SystemMessageType, TOKEN_KEY, TRANSFER_FEE_MINOR, type TicTacToeClockTimes, Tips, type TransactionJob, type TransactionJobStatus, type TransactionJobType, type TransactionQueueStats, type TransferToken, type TypingUser, type UpdateTicketData, type User, type UserAchievement, type UserActivity, type UserActivityStatus, type UserStats, type UsernameAvailabilityResponse, Users, type ValidAction, Wallet, type WalletActivityCounterpartyType, type WalletActivityDirection, type WalletActivityItem, type WalletActivityKind, type WalletActivityResponse, type WalletActivityStatus, type WalletClaimAction, type WalletMeta, type WalletResponse, type WalletSigner, type WsEvent, WsEventBus, type WsEventName, type WsTransport, type ConnectionState as WsTransportState, createChatStore, createDmThreadsStore, createFriendsStore, createGameActionsStore, createGameStore, createLobbyStore, createLogger, createNotificationsStore, createSdkStore, isRetryableError, logger, selectGameLifecycleState, withRetry };
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import { NimGameState, NimGameAction } from '@dimcool/nim';
5
5
  import { DotsAndBoxesGameState, DotsAndBoxesGameAction } from '@dimcool/dots-and-boxes';
6
6
  import { TicTacToeGameState, TicTacToeGameAction } from '@dimcool/tic-tac-toe';
7
7
  import { Connect4GameState, Connect4GameAction } from '@dimcool/connect-four';
8
- export { MICRO_UNITS, formatMoneyMinor, toMajor } from '@dimcool/utils';
8
+ export { MICRO_UNITS, SOL_MINT, formatMoneyMinor, toMajor } from '@dimcool/utils';
9
9
 
10
10
  /**
11
11
  * Interface for HTTP client implementations.
@@ -929,7 +929,7 @@ declare const TRANSFER_FEE_MINOR = 10000;
929
929
  declare const MIN_TRANSFER_AMOUNT = 50000;
930
930
  declare const MIN_SOL_TRANSFER_AMOUNT = 1000000;
931
931
  declare const SOL_DECIMALS = 9;
932
- declare const SOL_MINT = "SOL";
932
+
933
933
  declare const ESTIMATED_SOL_FEE_LAMPORTS = 10000;
934
934
  interface PrepareTransferRequest {
935
935
  senderAddress: string;
@@ -2094,6 +2094,13 @@ declare class Lobbies {
2094
2094
  constructor(http: IHttpClient, logger?: ILogger | undefined);
2095
2095
  /** Called by SDK after the store is created so mutations can update state directly. */
2096
2096
  setLobbyStore(store: LobbyStore): void;
2097
+ /**
2098
+ * Create a new game lobby.
2099
+ *
2100
+ * **Important:** Creating a lobby automatically closes and refunds any
2101
+ * existing open or queued lobby for this user. You do not need to manually
2102
+ * leave or cancel a previous lobby before calling this.
2103
+ */
2097
2104
  createLobby(gameType: string, betAmount?: MoneyMinor): Promise<Lobby>;
2098
2105
  getLobby(lobbyId: string): Promise<Lobby>;
2099
2106
  inviteFriend(lobbyId: string, friendId: string): Promise<{
@@ -2121,22 +2128,6 @@ declare class Lobbies {
2121
2128
  deleteLobby(lobbyId: string): Promise<{
2122
2129
  message: string;
2123
2130
  }>;
2124
- /**
2125
- * Play again: Create a new lobby and prepare deposit in one flow.
2126
- * Returns the lobby and unsigned transaction that needs to be signed.
2127
- * @param gameType - The game type to play again
2128
- * @param betAmount - The bet amount (same as previous game)
2129
- * @param escrow - The escrow service instance (from sdk.escrow)
2130
- */
2131
- playAgain(gameType: string, betAmount: MoneyMinor, escrow: {
2132
- prepareAndStartDeposit: (id: string) => Promise<{
2133
- transaction: string;
2134
- message: string;
2135
- }>;
2136
- }): Promise<{
2137
- lobby: Lobby;
2138
- unsignedTransaction: string;
2139
- }>;
2140
2131
  }
2141
2132
 
2142
2133
  /** A player currently in an active game; used for "Live now" and "Who to watch" UI. */
@@ -3057,4 +3048,4 @@ declare class HttpClient implements IHttpClient {
3057
3048
  private payChallenge;
3058
3049
  }
3059
3050
 
3060
- export { type AcceptChallengeResponse, type Achievement, Activity, type ActivityFeedItem, type ActivityFeedItemType, type ActivityFeedResponse, type ActivityFeedUser, Admin, type AdminDailyStats, type AdminDailyStatsItem, type AdminFeatureFlag, type AdminGameHistory, type AdminGameHistoryFeeBreakdown, type AdminGameHistoryFeePlayer, type AdminGameHistoryPlayer, type AdminMarketDailyStats, type AdminMarketDailyStatsItem, type AdminMarketDetail, type AdminMarketStats, type AdminStats, type AdminWalletActivityItem, type AdminWalletActivityResponse, type AnalyticsUserData, type ApiError, type AppNotification, type AppNotificationType, type ApplyReferralCodeResponse, type BalanceResponse, type BetOption, type BroadcastTipRequest, BrowserLocalStorage, Challenges, Chat, type ChatContext, type ChatContextType, type ChatMessage, type ChatMessageReply, type ChatMessageType, type ChatReaction, type ChatReadBy, type ChatState, type ChatStore, type ChatStoreState, type ChessCapturedPieces, type ChessClockTimes, type ClaimReferralRewardsResponse, type Connect4ClockTimes, type CreateChallengeRequest, type CreateChallengeResponse, type CreateLobbyRequest, type CreateTicketData, type CriticalIncident, type CriticalIncidentCategory, type CriticalIncidentImpactType, type CriticalIncidentSeverity, type CriticalIncidentStatus, type CriticalIncidentSummary, type CurrentGame, Daily, type DailyParticipant, type DailyRoom, type DailyToken, type DepositForLobbyResponse, type DepositStatus, type DepositStatusResponse, type DmThread, type DmThreadsStore, type DmThreadsStoreState, type DonateToGameResponse, ESTIMATED_SOL_FEE_LAMPORTS, Escrow, type EscrowSweepPreview, type EscrowSweepRecord, type FaucetResponse, type FeatureFlag, type FriendRequestItem, type FriendsStore, type FriendsStoreState, type FriendshipStatus, type Game, type GameActionsStore, type GameActionsStoreState, type GameHistoryItem, type GameLifecycleState, type GameMetrics, type GamePlayer, type GameStateResponse, type GameStore, type GameStoreState, type GameType, Games, type GenerateHandshakeResponse, type GetTicketsOptions, HttpClient, type IAnalyticsClient, type IHttpClient, type ILogger, type IStorage, type ImageUploadPayload, type InviteFriendRequest, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardRange, type LeaderboardResponse, Leaderboards, type LivePlayer, type LivePlayersPage, Lobbies, type Lobby, type LobbyDepositUpdatedPayload, type LobbyMatchedEvent, type LobbyPlayer, type LobbyStore, type LobbyStoreState, type LogLevel, type LoginResponse, MIN_SOL_TRANSFER_AMOUNT, MIN_TRANSFER_AMOUNT, type MarketBuyResult, type MarketPosition, type MarketSellResult, type MarketState, Markets, type MoneyMinor, NodeStorage, NoopAnalyticsClient, type NotificationEvent, type NotificationsStore, type NotificationsStoreState, type PaginatedCriticalIncidents, type PaginatedFriendRequests, type PaginatedFriends, type PaginatedNotificationsResponse, type PaginatedPlatformFees, type PaginatedReports, type PaginatedSearchUsers, type PaginatedSessions, type PaginatedSupportTickets, type PaginatedTransactionJobs, type PaginatedUsers, type PaymentRequiredChallenge, type PlatformFeeItem, type PrepareDepositResponse, type PrepareTipRequest, type PrepareTipResponse, type PrepareTransferRequest, type PrepareTransferResponse, type PublicUser, type QueueStats, type RedeemResult, type ReferralRewardItem, type ReferralRewardStatus, type ReferralRewardsResponse, type ReferralSummary, type ReferralTreeItem, type ReferralTreeResponse, Referrals, type Report, type ReportCount, type ReportStatus, type ReportUser, Reports, type RetryOptions, SDK, type SDKConfig, SDK_VERSION, SOL_DECIMALS, SOL_MINT, type SdkStore, type SdkUpgradeInfo, type SearchUser, type SendMessageRequest, type SendTipResponse, type SendTransferResponse, type Session, type SessionStats, SharedWorkerTransport, Spectate, type SpectatorMetrics, type SpectatorMetricsByUser, StandaloneWsTransport, type SubmitDepositResponse, type SubmitTransferRequest, type SubmitTransferResponse, Support, type SupportMessage, type SupportMessageSenderRole, type SupportTicket, type SupportTicketCategory, type SupportTicketPriority, type SupportTicketStatus, type SupportTicketUser, type SystemMessageType, TOKEN_KEY, TRANSFER_FEE_MINOR, type TicTacToeClockTimes, Tips, type TransactionJob, type TransactionJobStatus, type TransactionJobType, type TransactionQueueStats, type TransferToken, type TypingUser, type UpdateTicketData, type User, type UserAchievement, type UserActivity, type UserActivityStatus, type UserStats, type UsernameAvailabilityResponse, Users, type ValidAction, Wallet, type WalletActivityCounterpartyType, type WalletActivityDirection, type WalletActivityItem, type WalletActivityKind, type WalletActivityResponse, type WalletActivityStatus, type WalletClaimAction, type WalletMeta, type WalletResponse, type WalletSigner, type WsEvent, WsEventBus, type WsEventName, type WsTransport, type ConnectionState as WsTransportState, createChatStore, createDmThreadsStore, createFriendsStore, createGameActionsStore, createGameStore, createLobbyStore, createLogger, createNotificationsStore, createSdkStore, isRetryableError, logger, selectGameLifecycleState, withRetry };
3051
+ export { type AcceptChallengeResponse, type Achievement, Activity, type ActivityFeedItem, type ActivityFeedItemType, type ActivityFeedResponse, type ActivityFeedUser, Admin, type AdminDailyStats, type AdminDailyStatsItem, type AdminFeatureFlag, type AdminGameHistory, type AdminGameHistoryFeeBreakdown, type AdminGameHistoryFeePlayer, type AdminGameHistoryPlayer, type AdminMarketDailyStats, type AdminMarketDailyStatsItem, type AdminMarketDetail, type AdminMarketStats, type AdminStats, type AdminWalletActivityItem, type AdminWalletActivityResponse, type AnalyticsUserData, type ApiError, type AppNotification, type AppNotificationType, type ApplyReferralCodeResponse, type BalanceResponse, type BetOption, type BroadcastTipRequest, BrowserLocalStorage, Challenges, Chat, type ChatContext, type ChatContextType, type ChatMessage, type ChatMessageReply, type ChatMessageType, type ChatReaction, type ChatReadBy, type ChatState, type ChatStore, type ChatStoreState, type ChessCapturedPieces, type ChessClockTimes, type ClaimReferralRewardsResponse, type Connect4ClockTimes, type CreateChallengeRequest, type CreateChallengeResponse, type CreateLobbyRequest, type CreateTicketData, type CriticalIncident, type CriticalIncidentCategory, type CriticalIncidentImpactType, type CriticalIncidentSeverity, type CriticalIncidentStatus, type CriticalIncidentSummary, type CurrentGame, Daily, type DailyParticipant, type DailyRoom, type DailyToken, type DepositForLobbyResponse, type DepositStatus, type DepositStatusResponse, type DmThread, type DmThreadsStore, type DmThreadsStoreState, type DonateToGameResponse, ESTIMATED_SOL_FEE_LAMPORTS, Escrow, type EscrowSweepPreview, type EscrowSweepRecord, type FaucetResponse, type FeatureFlag, type FriendRequestItem, type FriendsStore, type FriendsStoreState, type FriendshipStatus, type Game, type GameActionsStore, type GameActionsStoreState, type GameHistoryItem, type GameLifecycleState, type GameMetrics, type GamePlayer, type GameStateResponse, type GameStore, type GameStoreState, type GameType, Games, type GenerateHandshakeResponse, type GetTicketsOptions, HttpClient, type IAnalyticsClient, type IHttpClient, type ILogger, type IStorage, type ImageUploadPayload, type InviteFriendRequest, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardRange, type LeaderboardResponse, Leaderboards, type LivePlayer, type LivePlayersPage, Lobbies, type Lobby, type LobbyDepositUpdatedPayload, type LobbyMatchedEvent, type LobbyPlayer, type LobbyStore, type LobbyStoreState, type LogLevel, type LoginResponse, MIN_SOL_TRANSFER_AMOUNT, MIN_TRANSFER_AMOUNT, type MarketBuyResult, type MarketPosition, type MarketSellResult, type MarketState, Markets, type MoneyMinor, NodeStorage, NoopAnalyticsClient, type NotificationEvent, type NotificationsStore, type NotificationsStoreState, type PaginatedCriticalIncidents, type PaginatedFriendRequests, type PaginatedFriends, type PaginatedNotificationsResponse, type PaginatedPlatformFees, type PaginatedReports, type PaginatedSearchUsers, type PaginatedSessions, type PaginatedSupportTickets, type PaginatedTransactionJobs, type PaginatedUsers, type PaymentRequiredChallenge, type PlatformFeeItem, type PrepareDepositResponse, type PrepareTipRequest, type PrepareTipResponse, type PrepareTransferRequest, type PrepareTransferResponse, type PublicUser, type QueueStats, type RedeemResult, type ReferralRewardItem, type ReferralRewardStatus, type ReferralRewardsResponse, type ReferralSummary, type ReferralTreeItem, type ReferralTreeResponse, Referrals, type Report, type ReportCount, type ReportStatus, type ReportUser, Reports, type RetryOptions, SDK, type SDKConfig, SDK_VERSION, SOL_DECIMALS, type SdkStore, type SdkUpgradeInfo, type SearchUser, type SendMessageRequest, type SendTipResponse, type SendTransferResponse, type Session, type SessionStats, SharedWorkerTransport, Spectate, type SpectatorMetrics, type SpectatorMetricsByUser, StandaloneWsTransport, type SubmitDepositResponse, type SubmitTransferRequest, type SubmitTransferResponse, Support, type SupportMessage, type SupportMessageSenderRole, type SupportTicket, type SupportTicketCategory, type SupportTicketPriority, type SupportTicketStatus, type SupportTicketUser, type SystemMessageType, TOKEN_KEY, TRANSFER_FEE_MINOR, type TicTacToeClockTimes, Tips, type TransactionJob, type TransactionJobStatus, type TransactionJobType, type TransactionQueueStats, type TransferToken, type TypingUser, type UpdateTicketData, type User, type UserAchievement, type UserActivity, type UserActivityStatus, type UserStats, type UsernameAvailabilityResponse, Users, type ValidAction, Wallet, type WalletActivityCounterpartyType, type WalletActivityDirection, type WalletActivityItem, type WalletActivityKind, type WalletActivityResponse, type WalletActivityStatus, type WalletClaimAction, type WalletMeta, type WalletResponse, type WalletSigner, type WsEvent, WsEventBus, type WsEventName, type WsTransport, type ConnectionState as WsTransportState, createChatStore, createDmThreadsStore, createFriendsStore, createGameActionsStore, createGameStore, createLobbyStore, createLogger, createNotificationsStore, createSdkStore, isRetryableError, logger, selectGameLifecycleState, withRetry };
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ var require_money = __commonJS({
29
29
  "../utils/dist/money.js"(exports) {
30
30
  "use strict";
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.SOL_LAMPORTS = exports.MICRO_UNITS = void 0;
32
+ exports.SOL_MINT = exports.SOL_LAMPORTS = exports.MICRO_UNITS = void 0;
33
33
  exports.isSolMint = isSolMint;
34
34
  exports.formatMoneyMinor = formatMoneyMinor2;
35
35
  exports.toMajor = toMajor2;
@@ -42,12 +42,12 @@ var require_money = __commonJS({
42
42
  exports.formatMoneyMinorCompact = formatMoneyMinorCompact;
43
43
  exports.MICRO_UNITS = 1e6;
44
44
  exports.SOL_LAMPORTS = 1e9;
45
- var SOL_MINT_LABEL = "SOL";
45
+ exports.SOL_MINT = "SOL";
46
46
  var SOL_SYSTEM_PROGRAM = "11111111111111111111111111111111";
47
47
  function isSolMint(mint) {
48
48
  if (!mint)
49
49
  return false;
50
- return mint === SOL_MINT_LABEL || mint === SOL_SYSTEM_PROGRAM;
50
+ return mint === exports.SOL_MINT || mint === SOL_SYSTEM_PROGRAM;
51
51
  }
52
52
  function formatMoneyMinor2(amountMinor, fractionDigits = 2) {
53
53
  return (amountMinor / exports.MICRO_UNITS).toFixed(fractionDigits);
@@ -153,7 +153,7 @@ var require_dist = __commonJS({
153
153
  "../utils/dist/index.js"(exports) {
154
154
  "use strict";
155
155
  Object.defineProperty(exports, "__esModule", { value: true });
156
- exports.formatMoneyMinorCompact = exports.formatCurrencyPartsForToken = exports.formatCurrencyParts = exports.kformatMoney = exports.kformat = exports.formatSolMinor = exports.toSolMajor = exports.toMajor = exports.formatMoneyMinor = exports.isSolMint = exports.SOL_LAMPORTS = exports.MICRO_UNITS = void 0;
156
+ exports.formatMoneyMinorCompact = exports.formatCurrencyPartsForToken = exports.formatCurrencyParts = exports.kformatMoney = exports.kformat = exports.formatSolMinor = exports.toSolMajor = exports.toMajor = exports.formatMoneyMinor = exports.isSolMint = exports.SOL_MINT = exports.SOL_LAMPORTS = exports.MICRO_UNITS = void 0;
157
157
  var money_1 = require_money();
158
158
  Object.defineProperty(exports, "MICRO_UNITS", { enumerable: true, get: function() {
159
159
  return money_1.MICRO_UNITS;
@@ -161,6 +161,9 @@ var require_dist = __commonJS({
161
161
  Object.defineProperty(exports, "SOL_LAMPORTS", { enumerable: true, get: function() {
162
162
  return money_1.SOL_LAMPORTS;
163
163
  } });
164
+ Object.defineProperty(exports, "SOL_MINT", { enumerable: true, get: function() {
165
+ return money_1.SOL_MINT;
166
+ } });
164
167
  Object.defineProperty(exports, "isSolMint", { enumerable: true, get: function() {
165
168
  return money_1.isSolMint;
166
169
  } });
@@ -1103,6 +1106,13 @@ var Lobbies = class {
1103
1106
  setLobbyStore(store) {
1104
1107
  this.lobbyStore = store;
1105
1108
  }
1109
+ /**
1110
+ * Create a new game lobby.
1111
+ *
1112
+ * **Important:** Creating a lobby automatically closes and refunds any
1113
+ * existing open or queued lobby for this user. You do not need to manually
1114
+ * leave or cancel a previous lobby before calling this.
1115
+ */
1106
1116
  async createLobby(gameType, betAmount) {
1107
1117
  return this.http.post("/lobbies", { gameType, betAmount });
1108
1118
  }
@@ -1166,21 +1176,6 @@ var Lobbies = class {
1166
1176
  async deleteLobby(lobbyId) {
1167
1177
  return this.http.delete(`/lobbies/admin/${lobbyId}`);
1168
1178
  }
1169
- /**
1170
- * Play again: Create a new lobby and prepare deposit in one flow.
1171
- * Returns the lobby and unsigned transaction that needs to be signed.
1172
- * @param gameType - The game type to play again
1173
- * @param betAmount - The bet amount (same as previous game)
1174
- * @param escrow - The escrow service instance (from sdk.escrow)
1175
- */
1176
- async playAgain(gameType, betAmount, escrow) {
1177
- const lobby = await this.createLobby(gameType, betAmount);
1178
- const { transaction } = await escrow.prepareAndStartDeposit(lobby.id);
1179
- return {
1180
- lobby,
1181
- unsignedTransaction: transaction
1182
- };
1183
- }
1184
1179
  };
1185
1180
 
1186
1181
  // src/games.ts
@@ -1719,11 +1714,11 @@ var Achievements = class {
1719
1714
 
1720
1715
  // src/wallet.ts
1721
1716
  import { Transaction as Transaction2 } from "@solana/web3.js";
1717
+ var import_utils = __toESM(require_dist(), 1);
1722
1718
  var TRANSFER_FEE_MINOR = 1e4;
1723
1719
  var MIN_TRANSFER_AMOUNT = 5e4;
1724
1720
  var MIN_SOL_TRANSFER_AMOUNT = 1e6;
1725
1721
  var SOL_DECIMALS = 9;
1726
- var SOL_MINT = "SOL";
1727
1722
  var ESTIMATED_SOL_FEE_LAMPORTS = 1e4;
1728
1723
  var Wallet = class {
1729
1724
  constructor(http, logger2) {
@@ -4964,10 +4959,11 @@ var SharedWorkerTransport = class extends BaseWsTransport {
4964
4959
  };
4965
4960
 
4966
4961
  // src/utils/money.ts
4967
- var import_utils = __toESM(require_dist(), 1);
4968
- var export_MICRO_UNITS = import_utils.MICRO_UNITS;
4969
- var export_formatMoneyMinor = import_utils.formatMoneyMinor;
4970
- var export_toMajor = import_utils.toMajor;
4962
+ var import_utils2 = __toESM(require_dist(), 1);
4963
+ var export_MICRO_UNITS = import_utils2.MICRO_UNITS;
4964
+ var export_SOL_MINT = import_utils.SOL_MINT;
4965
+ var export_formatMoneyMinor = import_utils2.formatMoneyMinor;
4966
+ var export_toMajor = import_utils2.toMajor;
4971
4967
  export {
4972
4968
  Admin,
4973
4969
  BrowserLocalStorage,
@@ -4986,7 +4982,7 @@ export {
4986
4982
  SDK,
4987
4983
  SDK_VERSION,
4988
4984
  SOL_DECIMALS,
4989
- SOL_MINT,
4985
+ export_SOL_MINT as SOL_MINT,
4990
4986
  SharedWorkerTransport,
4991
4987
  Spectate,
4992
4988
  StandaloneWsTransport,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimcool/sdk",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",