@dimcool/sdk 0.1.26 → 0.1.27

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
@@ -1287,57 +1287,30 @@ const signedTx = await sdk.wallet.signTransaction(unsignedTx);
1287
1287
 
1288
1288
  **Note:** The transaction amount is automatically set to match the lobby's `betAmount`. The transaction is partially signed by the fee payer (server) and requires the user's signature.
1289
1289
 
1290
- ### `submitDepositAndJoinQueue(lobbyId: string, signedTransaction: string, lobbies: Lobbies): Promise<Lobby>`
1290
+ ### `depositForLobbySync(lobbyId: string): Promise<DepositForLobbyResponse>`
1291
1291
 
1292
- Submit a signed deposit transaction and automatically join the queue when the deposit is confirmed. This is a convenience method that combines deposit submission, confirmation waiting, and queue joining.
1292
+ Zero-polling deposit variant using server-side `awaitConfirmation`. Only 2 HTTP calls total with no client-side polling. Ideal for agents and bots.
1293
1293
 
1294
1294
  ```typescript
1295
- const finalLobby = await sdk.escrow.submitDepositAndJoinQueue(
1296
- lobbyId,
1297
- signedTxBase64,
1298
- sdk.lobbies,
1299
- );
1295
+ const result = await sdk.escrow.depositForLobbySync(lobbyId);
1296
+ // result: { signature: string, status: 'confirmed', canProceedToQueue: true }
1300
1297
  ```
1301
1298
 
1302
1299
  **Parameters:**
1303
1300
 
1304
1301
  - `lobbyId: string` - The lobby ID
1305
- - `signedTransaction: string` - The signed transaction (base64 encoded)
1306
- - `lobbies: Lobbies` - The lobbies service instance (from `sdk.lobbies`)
1307
1302
 
1308
1303
  **Returns:**
1309
1304
 
1310
- - `Promise<Lobby>` - The lobby with updated status (will be 'queued' or 'active' if full)
1305
+ - `Promise<DepositForLobbyResponse>` - The deposit result with confirmed status
1311
1306
 
1312
1307
  **Behavior:**
1313
1308
 
1314
- 1. Submits the signed deposit transaction to the Solana network
1315
- 2. Polls deposit status until all deposits are confirmed (max 30 seconds)
1316
- 3. Automatically joins the matchmaking queue when deposits are confirmed
1317
- 4. Returns the updated lobby
1318
-
1319
- **Example:**
1320
-
1321
- ```typescript
1322
- // After signing the transaction from playAgain()
1323
- const signedTxBase64 = signedTx.serialize().toString('base64');
1324
- const finalLobby = await sdk.escrow.submitDepositAndJoinQueue(
1325
- lobby.id,
1326
- signedTxBase64,
1327
- sdk.lobbies,
1328
- );
1329
-
1330
- // Lobby is now in queue or active if full
1331
- console.log(`Lobby status: ${finalLobby.status}`);
1332
- ```
1333
-
1334
- **Error Handling:**
1309
+ 1. Calls `prepareAndStartDeposit` to prepare the unsigned transaction (1 HTTP call)
1310
+ 2. Signs the transaction locally and submits with `awaitConfirmation=true` (1 HTTP call)
1311
+ 3. Server waits for on-chain confirmation before returning
1335
1312
 
1336
- - Throws an error if deposit confirmation times out (30 seconds)
1337
- - Throws an error if deposit submission fails
1338
- - Throws an error if queue joining fails
1339
-
1340
- **Note:** This method is typically used after `playAgain()` to complete the "Play Again" flow in one call.
1313
+ **Note:** Requires `sdk.wallet.setSigner()` to be configured. The server auto-joins the matchmaking queue when all deposits are confirmed.
1341
1314
 
1342
1315
  ### `submitDeposit(lobbyId: string, signedTransaction: string): Promise<SubmitDepositResponse>`
1343
1316
 
@@ -1740,25 +1713,11 @@ const { lobby, unsignedTransaction } = await sdk.lobbies.playAgain(
1740
1713
  sdk.escrow,
1741
1714
  );
1742
1715
 
1743
- // Decode and sign the transaction
1744
- const binaryString = atob(unsignedTransaction);
1745
- const bytes = new Uint8Array(binaryString.length);
1746
- for (let i = 0; i < binaryString.length; i++) {
1747
- bytes[i] = binaryString.charCodeAt(i);
1748
- }
1749
- const unsignedTx = Transaction.from(bytes);
1750
- const signedTx = await sdk.wallet.signTransaction(unsignedTx);
1751
-
1752
- // Submit deposit and join queue
1753
- const signedTxBase64 = signedTx.serialize().toString('base64');
1754
- const finalLobby = await sdk.escrow.submitDepositAndJoinQueue(
1755
- lobby.id,
1756
- signedTxBase64,
1757
- sdk.lobbies,
1758
- );
1716
+ // Deposit using the sync (server-awaited) variant
1717
+ const result = await sdk.escrow.depositForLobbySync(lobby.id);
1759
1718
  ```
1760
1719
 
1761
- **Note:** After signing the transaction, use `submitDepositAndJoinQueue()` to complete the flow and automatically join the matchmaking queue.
1720
+ **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.
1762
1721
 
1763
1722
  ### Admin Methods
1764
1723
 
package/dist/index.cjs CHANGED
@@ -1153,19 +1153,18 @@ var Lobbies = class {
1153
1153
  return this.http.delete(`/lobbies/admin/${lobbyId}`);
1154
1154
  }
1155
1155
  /**
1156
- * Play again: Create a new lobby, start deposits, and prepare deposit transaction
1157
- * Returns the lobby and unsigned transaction that needs to be signed
1156
+ * Play again: Create a new lobby and prepare deposit in one flow.
1157
+ * Returns the lobby and unsigned transaction that needs to be signed.
1158
1158
  * @param gameType - The game type to play again
1159
1159
  * @param betAmount - The bet amount (same as previous game)
1160
1160
  * @param escrow - The escrow service instance (from sdk.escrow)
1161
1161
  */
1162
1162
  async playAgain(gameType, betAmount, escrow) {
1163
1163
  const lobby = await this.createLobby(gameType, betAmount);
1164
- await escrow.startDeposits(lobby.id);
1165
- const prepareResponse = await escrow.prepareDepositTransaction(lobby.id);
1164
+ const { transaction } = await escrow.prepareAndStartDeposit(lobby.id);
1166
1165
  return {
1167
1166
  lobby,
1168
- unsignedTransaction: prepareResponse.transaction
1167
+ unsignedTransaction: transaction
1169
1168
  };
1170
1169
  }
1171
1170
  };
@@ -2057,6 +2056,17 @@ var Escrow = class {
2057
2056
  `/escrow/lobby/${lobbyId}/deposit/prepare`
2058
2057
  );
2059
2058
  }
2059
+ /**
2060
+ * Combined prepare-and-start: validates lobby, transitions waiting→preparing,
2061
+ * initializes depositStatus, and prepares the unsigned transaction in one call.
2062
+ * Eliminates one HTTP round-trip vs startDeposits() + prepareDepositTransaction().
2063
+ */
2064
+ async prepareAndStartDeposit(lobbyId) {
2065
+ return this.http.post(
2066
+ `/escrow/lobby/${lobbyId}/deposit/prepare-and-start`,
2067
+ {}
2068
+ );
2069
+ }
2060
2070
  /**
2061
2071
  * Submit a signed deposit transaction
2062
2072
  * The transaction will be submitted to the Solana network and confirmed
@@ -2087,7 +2097,7 @@ var Escrow = class {
2087
2097
  );
2088
2098
  }
2089
2099
  /**
2090
- * One-call lobby deposit: start deposits, prepare, sign, submit, and poll until
2100
+ * One-call lobby deposit: prepare-and-start, sign, submit, and poll until
2091
2101
  * the current user's deposit is confirmed. Requires sdk.wallet.setSigner() to be set.
2092
2102
  * Returns when all required deposits are confirmed and the lobby can proceed to queue.
2093
2103
  *
@@ -2099,8 +2109,7 @@ var Escrow = class {
2099
2109
  "No signer configured. Use sdk.wallet.setSigner(...) first."
2100
2110
  );
2101
2111
  }
2102
- await this.startDeposits(lobbyId);
2103
- const { transaction } = await this.prepareDepositTransaction(lobbyId);
2112
+ const { transaction } = await this.prepareAndStartDeposit(lobbyId);
2104
2113
  const unsignedTx = import_web35.Transaction.from(base64ToBytes(transaction));
2105
2114
  let signature;
2106
2115
  if (this.wallet.isSignAndSendMode()) {
@@ -2122,7 +2131,7 @@ var Escrow = class {
2122
2131
  if (status.allConfirmed && status.canProceedToQueue) {
2123
2132
  return {
2124
2133
  signature,
2125
- status: "pending",
2134
+ status: "confirmed",
2126
2135
  canProceedToQueue: true
2127
2136
  };
2128
2137
  }
@@ -2134,6 +2143,39 @@ var Escrow = class {
2134
2143
  canProceedToQueue: false
2135
2144
  };
2136
2145
  }
2146
+ /**
2147
+ * Zero-polling deposit variant using server-side awaitConfirmation.
2148
+ * 2 HTTP calls total, 0 client-side polling. Ideal for agents.
2149
+ *
2150
+ * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2151
+ */
2152
+ async depositForLobbySync(lobbyId) {
2153
+ if (!this.wallet.hasSigner()) {
2154
+ throw new Error(
2155
+ "No signer configured. Use sdk.wallet.setSigner(...) first."
2156
+ );
2157
+ }
2158
+ const { transaction } = await this.prepareAndStartDeposit(lobbyId);
2159
+ const unsignedTx = import_web35.Transaction.from(base64ToBytes(transaction));
2160
+ let signature;
2161
+ if (this.wallet.isSignAndSendMode()) {
2162
+ signature = await this.wallet.signAndSendTransaction(unsignedTx);
2163
+ await this.http.post(
2164
+ `/escrow/lobby/${lobbyId}/deposit/confirm-signature?awaitConfirmation=true`,
2165
+ { signature }
2166
+ );
2167
+ } else {
2168
+ const signedTx = await this.wallet.signTransaction(unsignedTx);
2169
+ const signedBase64 = bytesToBase64(
2170
+ signedTx.serialize({ requireAllSignatures: false })
2171
+ );
2172
+ const result = await this.http.post(`/escrow/lobby/${lobbyId}/deposit/submit?awaitConfirmation=true`, {
2173
+ signedTransaction: signedBase64
2174
+ });
2175
+ signature = result.signature;
2176
+ }
2177
+ return { signature, status: "confirmed", canProceedToQueue: true };
2178
+ }
2137
2179
  async claimLobbyDepositRefund(lobbyId, depositSignature) {
2138
2180
  return this.http.post(
2139
2181
  `/escrow/lobby/${lobbyId}/deposit/${depositSignature}/claim-refund`,
@@ -2146,33 +2188,6 @@ var Escrow = class {
2146
2188
  {}
2147
2189
  );
2148
2190
  }
2149
- /**
2150
- * Submit a signed deposit transaction and wait until the lobby is queued/active.
2151
- *
2152
- * Note: the backend may auto-transition the lobby to the queue once deposits are confirmed.
2153
- * In that case, calling /join-queue from the client would be redundant and can fail with
2154
- * "Current status: queued".
2155
- * @param lobbyId - The lobby ID
2156
- * @param signedTransaction - The signed transaction (base64 encoded)
2157
- * @param lobbies - The lobbies service instance (from sdk.lobbies) to read lobby status
2158
- */
2159
- async submitDepositAndJoinQueue(lobbyId, signedTransaction, lobbies) {
2160
- await this.submitDeposit(lobbyId, signedTransaction);
2161
- const MAX_WAIT_TIME = 3e4;
2162
- const POLL_INTERVAL = 1e3;
2163
- const startTime = Date.now();
2164
- while (Date.now() - startTime < MAX_WAIT_TIME) {
2165
- const status = await this.getDepositStatus(lobbyId);
2166
- if (status.allConfirmed && status.canProceedToQueue) {
2167
- const lobby = await lobbies.getLobby(lobbyId);
2168
- if (lobby.status === "queued" || lobby.status === "active") {
2169
- return lobby;
2170
- }
2171
- }
2172
- await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
2173
- }
2174
- throw new Error("Deposit confirmation timeout");
2175
- }
2176
2191
  };
2177
2192
 
2178
2193
  // src/daily.ts
@@ -2821,8 +2836,14 @@ var _StandaloneWsTransport = class _StandaloneWsTransport extends BaseWsTranspor
2821
2836
  connecting: false,
2822
2837
  error: null
2823
2838
  });
2839
+ const wasReconnect = this.reconnectAttempts > 0;
2824
2840
  this.reconnectAttempts = 0;
2825
2841
  this.onReconnect();
2842
+ if (wasReconnect) {
2843
+ this.dispatchEvent("connection:reconnected", {
2844
+ timestamp: Date.now()
2845
+ });
2846
+ }
2826
2847
  });
2827
2848
  socket.on("disconnect", (reason) => {
2828
2849
  this.updateConnectionState({ connected: false, connecting: false });
@@ -2970,7 +2991,8 @@ function createLobbyStore(transport) {
2970
2991
  const store = createSdkStore({
2971
2992
  lobbiesById: {},
2972
2993
  matchedEvent: null,
2973
- typingByLobbyId: {}
2994
+ typingByLobbyId: {},
2995
+ depositStatusByLobbyId: {}
2974
2996
  });
2975
2997
  const setBaseState = (lobbies) => {
2976
2998
  const lobbiesById = {};
@@ -3050,6 +3072,15 @@ function createLobbyStore(transport) {
3050
3072
  };
3051
3073
  });
3052
3074
  break;
3075
+ case "lobby:deposit:updated":
3076
+ store.updateState((state) => ({
3077
+ ...state,
3078
+ depositStatusByLobbyId: {
3079
+ ...state.depositStatusByLobbyId,
3080
+ [event.payload.lobbyId]: event.payload
3081
+ }
3082
+ }));
3083
+ break;
3053
3084
  case "lobby:typing:start":
3054
3085
  case "lobby:typing:stop":
3055
3086
  store.updateState((state) => {
@@ -3078,12 +3109,22 @@ function createLobbyStore(transport) {
3078
3109
  }
3079
3110
  }
3080
3111
  );
3112
+ const subscribeDepositUpdate = (lobbyId, callback) => store.subscribeSelector(
3113
+ (state) => state.depositStatusByLobbyId[lobbyId],
3114
+ () => {
3115
+ const data = store.getState().depositStatusByLobbyId[lobbyId];
3116
+ if (data) {
3117
+ callback(data);
3118
+ }
3119
+ }
3120
+ );
3081
3121
  return {
3082
3122
  store,
3083
3123
  setBaseState,
3084
3124
  applyWsEvent,
3085
3125
  joinLobby,
3086
- subscribeMatched
3126
+ subscribeMatched,
3127
+ subscribeDepositUpdate
3087
3128
  };
3088
3129
  }
3089
3130
 
@@ -3369,7 +3410,6 @@ function createGameActionsStore(transport) {
3369
3410
  ...current,
3370
3411
  roundState: {
3371
3412
  ...current.roundState,
3372
- phase: "completed",
3373
3413
  timeRemaining: 0,
3374
3414
  actions: timedOutUser ? {
3375
3415
  ...current.roundState.actions,
@@ -3891,6 +3931,7 @@ var WS_EVENT_NAMES = [
3891
3931
  "lobby:queue:joined",
3892
3932
  "lobby:queue:cancelled",
3893
3933
  "lobby:matched",
3934
+ "lobby:deposit:updated",
3894
3935
  "lobby:typing:start",
3895
3936
  "lobby:typing:stop",
3896
3937
  "game:updated",
@@ -3967,6 +4008,11 @@ function decodeWsEvent(eventName, payload) {
3967
4008
  event: "lobby:matched",
3968
4009
  payload
3969
4010
  };
4011
+ case "lobby:deposit:updated":
4012
+ return {
4013
+ event: "lobby:deposit:updated",
4014
+ payload
4015
+ };
3970
4016
  case "lobby:typing:start":
3971
4017
  case "lobby:typing:stop":
3972
4018
  return {
package/dist/index.d.cts CHANGED
@@ -1199,7 +1199,7 @@ interface QueueStats {
1199
1199
  totalQueuedLobbies: number;
1200
1200
  }
1201
1201
  type ChatMessageType = 'user' | 'system';
1202
- type SystemMessageType = 'player_joined' | 'player_left' | 'bet_changed' | 'call_joined' | 'call_left' | 'global_help' | 'global_challenge' | 'global_tip' | 'spectator_donation';
1202
+ type SystemMessageType = 'player_joined' | 'player_left' | 'bet_changed' | 'call_joined' | 'call_left' | 'global_help' | 'global_challenge' | 'global_tip' | 'spectator_donation' | 'challenge_accepted' | 'challenge_declined';
1203
1203
  interface ChatMessageReply {
1204
1204
  id: string;
1205
1205
  userId?: string;
@@ -1264,15 +1264,14 @@ declare class Lobbies {
1264
1264
  message: string;
1265
1265
  }>;
1266
1266
  /**
1267
- * Play again: Create a new lobby, start deposits, and prepare deposit transaction
1268
- * Returns the lobby and unsigned transaction that needs to be signed
1267
+ * Play again: Create a new lobby and prepare deposit in one flow.
1268
+ * Returns the lobby and unsigned transaction that needs to be signed.
1269
1269
  * @param gameType - The game type to play again
1270
1270
  * @param betAmount - The bet amount (same as previous game)
1271
1271
  * @param escrow - The escrow service instance (from sdk.escrow)
1272
1272
  */
1273
1273
  playAgain(gameType: string, betAmount: MoneyMinor, escrow: {
1274
- startDeposits: (id: string) => Promise<void>;
1275
- prepareDepositTransaction: (id: string) => Promise<{
1274
+ prepareAndStartDeposit: (id: string) => Promise<{
1276
1275
  transaction: string;
1277
1276
  message: string;
1278
1277
  }>;
@@ -1288,6 +1287,8 @@ interface GameType {
1288
1287
  maxPlayers: number;
1289
1288
  minPlayers: number;
1290
1289
  description?: string;
1290
+ /** Agent-facing instructions including game pace (how fast the game is). */
1291
+ detailedInstructions?: string;
1291
1292
  available: boolean;
1292
1293
  betOptions?: BetOption[];
1293
1294
  }
@@ -1418,6 +1419,7 @@ declare class Games {
1418
1419
  success: boolean;
1419
1420
  bothReady: boolean;
1420
1421
  newGameId?: string;
1422
+ newLobbyId?: string;
1421
1423
  }>;
1422
1424
  /**
1423
1425
  * Cancel a rematch request
@@ -1701,7 +1703,7 @@ declare class Tips {
1701
1703
  send(recipientUsername: string, amount: number): Promise<SendTipResponse>;
1702
1704
  }
1703
1705
 
1704
- type WsEventName = 'lobby:created' | 'lobby:updated' | 'lobby:player:joined' | 'lobby:player:left' | 'lobby:player:connected' | 'lobby:player:disconnected' | 'lobby:bet:updated' | 'lobby:invitation' | 'lobby:deleted' | 'lobby:queue:joined' | 'lobby:queue:cancelled' | 'lobby:matched' | 'lobby:typing:start' | 'lobby:typing:stop' | 'game:updated' | 'game:completed' | 'game:paid' | 'game:abandoned' | 'game:turn' | 'game:move' | 'game:state' | 'game:player:connected' | 'game:player:disconnected' | 'game:rps:starting' | 'game:rps:round:started' | 'game:rps:action:received' | 'game:rps:timer:cutoff' | 'game:rps:round:reveal' | 'game:rps:round:completed' | 'game:rps:timeout' | 'game:rematch:requested' | 'game:rematch:cancelled' | 'game:rematch:started' | 'game:rematch:lobby:created' | 'game:pot:updated' | 'game:market:price:updated' | 'game:market:order:filled' | 'game:market:resolved' | 'spectator:count:updated' | 'chat:message' | 'chat:reaction' | 'chat:read' | 'chat:typing' | 'notification';
1706
+ type WsEventName = 'lobby:created' | 'lobby:updated' | 'lobby:player:joined' | 'lobby:player:left' | 'lobby:player:connected' | 'lobby:player:disconnected' | 'lobby:bet:updated' | 'lobby:invitation' | 'lobby:deleted' | 'lobby:queue:joined' | 'lobby:queue:cancelled' | 'lobby:matched' | 'lobby:deposit:updated' | 'lobby:typing:start' | 'lobby:typing:stop' | 'game:updated' | 'game:completed' | 'game:paid' | 'game:abandoned' | 'game:turn' | 'game:move' | 'game:state' | 'game:player:connected' | 'game:player:disconnected' | 'game:rps:starting' | 'game:rps:round:started' | 'game:rps:action:received' | 'game:rps:timer:cutoff' | 'game:rps:round:reveal' | 'game:rps:round:completed' | 'game:rps:timeout' | 'game:rematch:requested' | 'game:rematch:cancelled' | 'game:rematch:started' | 'game:rematch:lobby:created' | 'game:pot:updated' | 'game:market:price:updated' | 'game:market:order:filled' | 'game:market:resolved' | 'spectator:count:updated' | 'chat:message' | 'chat:reaction' | 'chat:read' | 'chat:typing' | 'notification';
1705
1707
  type GameTurnPayload = {
1706
1708
  turn: number;
1707
1709
  currentPlayerId: string;
@@ -1804,6 +1806,12 @@ type MarketResolvedPayload = {
1804
1806
  resolvedOutcome: string | null;
1805
1807
  isDraw: boolean;
1806
1808
  };
1809
+ type LobbyDepositUpdatedPayload = {
1810
+ lobbyId: string;
1811
+ userId: string;
1812
+ status: string;
1813
+ allConfirmed: boolean;
1814
+ };
1807
1815
  type WsEvent = {
1808
1816
  event: 'lobby:created';
1809
1817
  payload: Lobby;
@@ -1863,6 +1871,9 @@ type WsEvent = {
1863
1871
  gameType: string;
1864
1872
  matchedLobbies: Lobby[];
1865
1873
  };
1874
+ } | {
1875
+ event: 'lobby:deposit:updated';
1876
+ payload: LobbyDepositUpdatedPayload;
1866
1877
  } | {
1867
1878
  event: 'lobby:typing:start';
1868
1879
  payload: {
@@ -2137,6 +2148,12 @@ declare class Escrow {
2137
2148
  * Returns an unsigned transaction that needs to be signed by the user
2138
2149
  */
2139
2150
  prepareDepositTransaction(lobbyId: string): Promise<PrepareDepositResponse>;
2151
+ /**
2152
+ * Combined prepare-and-start: validates lobby, transitions waiting→preparing,
2153
+ * initializes depositStatus, and prepares the unsigned transaction in one call.
2154
+ * Eliminates one HTTP round-trip vs startDeposits() + prepareDepositTransaction().
2155
+ */
2156
+ prepareAndStartDeposit(lobbyId: string): Promise<PrepareDepositResponse>;
2140
2157
  /**
2141
2158
  * Submit a signed deposit transaction
2142
2159
  * The transaction will be submitted to the Solana network and confirmed
@@ -2153,13 +2170,20 @@ declare class Escrow {
2153
2170
  status: string;
2154
2171
  }>;
2155
2172
  /**
2156
- * One-call lobby deposit: start deposits, prepare, sign, submit, and poll until
2173
+ * One-call lobby deposit: prepare-and-start, sign, submit, and poll until
2157
2174
  * the current user's deposit is confirmed. Requires sdk.wallet.setSigner() to be set.
2158
2175
  * Returns when all required deposits are confirmed and the lobby can proceed to queue.
2159
2176
  *
2160
2177
  * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2161
2178
  */
2162
2179
  depositForLobby(lobbyId: string): Promise<DepositForLobbyResponse>;
2180
+ /**
2181
+ * Zero-polling deposit variant using server-side awaitConfirmation.
2182
+ * 2 HTTP calls total, 0 client-side polling. Ideal for agents.
2183
+ *
2184
+ * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2185
+ */
2186
+ depositForLobbySync(lobbyId: string): Promise<DepositForLobbyResponse>;
2163
2187
  claimLobbyDepositRefund(lobbyId: string, depositSignature: string): Promise<{
2164
2188
  signature: string;
2165
2189
  status: string;
@@ -2168,25 +2192,6 @@ declare class Escrow {
2168
2192
  signature: string;
2169
2193
  status: string;
2170
2194
  }>;
2171
- /**
2172
- * Submit a signed deposit transaction and wait until the lobby is queued/active.
2173
- *
2174
- * Note: the backend may auto-transition the lobby to the queue once deposits are confirmed.
2175
- * In that case, calling /join-queue from the client would be redundant and can fail with
2176
- * "Current status: queued".
2177
- * @param lobbyId - The lobby ID
2178
- * @param signedTransaction - The signed transaction (base64 encoded)
2179
- * @param lobbies - The lobbies service instance (from sdk.lobbies) to read lobby status
2180
- */
2181
- submitDepositAndJoinQueue(lobbyId: string, signedTransaction: string, lobbies: {
2182
- getLobby: (id: string) => Promise<{
2183
- id: string;
2184
- status: string;
2185
- }>;
2186
- }): Promise<{
2187
- id: string;
2188
- status: string;
2189
- }>;
2190
2195
  }
2191
2196
 
2192
2197
  interface DailyRoom {
@@ -2560,6 +2565,7 @@ type LobbyStoreState = {
2560
2565
  lobbiesById: Record<string, Lobby>;
2561
2566
  matchedEvent: LobbyMatchedEvent | null;
2562
2567
  typingByLobbyId: Record<string, string[]>;
2568
+ depositStatusByLobbyId: Record<string, LobbyDepositUpdatedPayload>;
2563
2569
  };
2564
2570
  type LobbyStore = {
2565
2571
  store: SdkStore<LobbyStoreState>;
@@ -2567,6 +2573,7 @@ type LobbyStore = {
2567
2573
  applyWsEvent: (event: WsEvent) => void;
2568
2574
  joinLobby: (lobbyId: string) => () => void;
2569
2575
  subscribeMatched: (callback: (event: LobbyMatchedEvent) => void) => () => void;
2576
+ subscribeDepositUpdate: (lobbyId: string, callback: (data: LobbyDepositUpdatedPayload) => void) => () => void;
2570
2577
  };
2571
2578
  declare function createLobbyStore(transport: WsTransport): LobbyStore;
2572
2579
 
@@ -2830,4 +2837,4 @@ declare class HttpClient implements IHttpClient {
2830
2837
  private payChallenge;
2831
2838
  }
2832
2839
 
2833
- export { type AcceptChallengeResponse, type Achievement, Activity, type ActivityFeedItem, type ActivityFeedItemType, type ActivityFeedResponse, type ActivityFeedUser, Admin, type AdminDailyStats, type AdminDailyStatsItem, type AdminGameHistory, type AdminGameHistoryFeeBreakdown, type AdminGameHistoryFeePlayer, type AdminGameHistoryPlayer, type AdminMarketDailyStats, type AdminMarketDailyStatsItem, type AdminMarketDetail, type AdminMarketStats, type AdminStats, type AdminWalletActivityItem, type AdminWalletActivityResponse, 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 ClaimReferralRewardsResponse, 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 GameMetrics, type GamePlayer, type GameStateResponse, type GameStore, type GameStoreState, type GameType, Games, type GenerateHandshakeResponse, type GetTicketsOptions, HttpClient, type IHttpClient, type ILogger, type IStorage, type InviteFriendRequest, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardRange, type LeaderboardResponse, Leaderboards, type LivePlayer, type LivePlayersPage, Lobbies, type Lobby, 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, type NotificationEvent, type NotificationsStore, type NotificationsStoreState, type PaginatedCriticalIncidents, 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, 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, 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, withRetry };
2840
+ export { type AcceptChallengeResponse, type Achievement, Activity, type ActivityFeedItem, type ActivityFeedItemType, type ActivityFeedResponse, type ActivityFeedUser, Admin, type AdminDailyStats, type AdminDailyStatsItem, type AdminGameHistory, type AdminGameHistoryFeeBreakdown, type AdminGameHistoryFeePlayer, type AdminGameHistoryPlayer, type AdminMarketDailyStats, type AdminMarketDailyStatsItem, type AdminMarketDetail, type AdminMarketStats, type AdminStats, type AdminWalletActivityItem, type AdminWalletActivityResponse, 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 ClaimReferralRewardsResponse, 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 GameMetrics, type GamePlayer, type GameStateResponse, type GameStore, type GameStoreState, type GameType, Games, type GenerateHandshakeResponse, type GetTicketsOptions, HttpClient, type IHttpClient, type ILogger, type IStorage, 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, type NotificationEvent, type NotificationsStore, type NotificationsStoreState, type PaginatedCriticalIncidents, 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, 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, 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, withRetry };
package/dist/index.d.ts CHANGED
@@ -1199,7 +1199,7 @@ interface QueueStats {
1199
1199
  totalQueuedLobbies: number;
1200
1200
  }
1201
1201
  type ChatMessageType = 'user' | 'system';
1202
- type SystemMessageType = 'player_joined' | 'player_left' | 'bet_changed' | 'call_joined' | 'call_left' | 'global_help' | 'global_challenge' | 'global_tip' | 'spectator_donation';
1202
+ type SystemMessageType = 'player_joined' | 'player_left' | 'bet_changed' | 'call_joined' | 'call_left' | 'global_help' | 'global_challenge' | 'global_tip' | 'spectator_donation' | 'challenge_accepted' | 'challenge_declined';
1203
1203
  interface ChatMessageReply {
1204
1204
  id: string;
1205
1205
  userId?: string;
@@ -1264,15 +1264,14 @@ declare class Lobbies {
1264
1264
  message: string;
1265
1265
  }>;
1266
1266
  /**
1267
- * Play again: Create a new lobby, start deposits, and prepare deposit transaction
1268
- * Returns the lobby and unsigned transaction that needs to be signed
1267
+ * Play again: Create a new lobby and prepare deposit in one flow.
1268
+ * Returns the lobby and unsigned transaction that needs to be signed.
1269
1269
  * @param gameType - The game type to play again
1270
1270
  * @param betAmount - The bet amount (same as previous game)
1271
1271
  * @param escrow - The escrow service instance (from sdk.escrow)
1272
1272
  */
1273
1273
  playAgain(gameType: string, betAmount: MoneyMinor, escrow: {
1274
- startDeposits: (id: string) => Promise<void>;
1275
- prepareDepositTransaction: (id: string) => Promise<{
1274
+ prepareAndStartDeposit: (id: string) => Promise<{
1276
1275
  transaction: string;
1277
1276
  message: string;
1278
1277
  }>;
@@ -1288,6 +1287,8 @@ interface GameType {
1288
1287
  maxPlayers: number;
1289
1288
  minPlayers: number;
1290
1289
  description?: string;
1290
+ /** Agent-facing instructions including game pace (how fast the game is). */
1291
+ detailedInstructions?: string;
1291
1292
  available: boolean;
1292
1293
  betOptions?: BetOption[];
1293
1294
  }
@@ -1418,6 +1419,7 @@ declare class Games {
1418
1419
  success: boolean;
1419
1420
  bothReady: boolean;
1420
1421
  newGameId?: string;
1422
+ newLobbyId?: string;
1421
1423
  }>;
1422
1424
  /**
1423
1425
  * Cancel a rematch request
@@ -1701,7 +1703,7 @@ declare class Tips {
1701
1703
  send(recipientUsername: string, amount: number): Promise<SendTipResponse>;
1702
1704
  }
1703
1705
 
1704
- type WsEventName = 'lobby:created' | 'lobby:updated' | 'lobby:player:joined' | 'lobby:player:left' | 'lobby:player:connected' | 'lobby:player:disconnected' | 'lobby:bet:updated' | 'lobby:invitation' | 'lobby:deleted' | 'lobby:queue:joined' | 'lobby:queue:cancelled' | 'lobby:matched' | 'lobby:typing:start' | 'lobby:typing:stop' | 'game:updated' | 'game:completed' | 'game:paid' | 'game:abandoned' | 'game:turn' | 'game:move' | 'game:state' | 'game:player:connected' | 'game:player:disconnected' | 'game:rps:starting' | 'game:rps:round:started' | 'game:rps:action:received' | 'game:rps:timer:cutoff' | 'game:rps:round:reveal' | 'game:rps:round:completed' | 'game:rps:timeout' | 'game:rematch:requested' | 'game:rematch:cancelled' | 'game:rematch:started' | 'game:rematch:lobby:created' | 'game:pot:updated' | 'game:market:price:updated' | 'game:market:order:filled' | 'game:market:resolved' | 'spectator:count:updated' | 'chat:message' | 'chat:reaction' | 'chat:read' | 'chat:typing' | 'notification';
1706
+ type WsEventName = 'lobby:created' | 'lobby:updated' | 'lobby:player:joined' | 'lobby:player:left' | 'lobby:player:connected' | 'lobby:player:disconnected' | 'lobby:bet:updated' | 'lobby:invitation' | 'lobby:deleted' | 'lobby:queue:joined' | 'lobby:queue:cancelled' | 'lobby:matched' | 'lobby:deposit:updated' | 'lobby:typing:start' | 'lobby:typing:stop' | 'game:updated' | 'game:completed' | 'game:paid' | 'game:abandoned' | 'game:turn' | 'game:move' | 'game:state' | 'game:player:connected' | 'game:player:disconnected' | 'game:rps:starting' | 'game:rps:round:started' | 'game:rps:action:received' | 'game:rps:timer:cutoff' | 'game:rps:round:reveal' | 'game:rps:round:completed' | 'game:rps:timeout' | 'game:rematch:requested' | 'game:rematch:cancelled' | 'game:rematch:started' | 'game:rematch:lobby:created' | 'game:pot:updated' | 'game:market:price:updated' | 'game:market:order:filled' | 'game:market:resolved' | 'spectator:count:updated' | 'chat:message' | 'chat:reaction' | 'chat:read' | 'chat:typing' | 'notification';
1705
1707
  type GameTurnPayload = {
1706
1708
  turn: number;
1707
1709
  currentPlayerId: string;
@@ -1804,6 +1806,12 @@ type MarketResolvedPayload = {
1804
1806
  resolvedOutcome: string | null;
1805
1807
  isDraw: boolean;
1806
1808
  };
1809
+ type LobbyDepositUpdatedPayload = {
1810
+ lobbyId: string;
1811
+ userId: string;
1812
+ status: string;
1813
+ allConfirmed: boolean;
1814
+ };
1807
1815
  type WsEvent = {
1808
1816
  event: 'lobby:created';
1809
1817
  payload: Lobby;
@@ -1863,6 +1871,9 @@ type WsEvent = {
1863
1871
  gameType: string;
1864
1872
  matchedLobbies: Lobby[];
1865
1873
  };
1874
+ } | {
1875
+ event: 'lobby:deposit:updated';
1876
+ payload: LobbyDepositUpdatedPayload;
1866
1877
  } | {
1867
1878
  event: 'lobby:typing:start';
1868
1879
  payload: {
@@ -2137,6 +2148,12 @@ declare class Escrow {
2137
2148
  * Returns an unsigned transaction that needs to be signed by the user
2138
2149
  */
2139
2150
  prepareDepositTransaction(lobbyId: string): Promise<PrepareDepositResponse>;
2151
+ /**
2152
+ * Combined prepare-and-start: validates lobby, transitions waiting→preparing,
2153
+ * initializes depositStatus, and prepares the unsigned transaction in one call.
2154
+ * Eliminates one HTTP round-trip vs startDeposits() + prepareDepositTransaction().
2155
+ */
2156
+ prepareAndStartDeposit(lobbyId: string): Promise<PrepareDepositResponse>;
2140
2157
  /**
2141
2158
  * Submit a signed deposit transaction
2142
2159
  * The transaction will be submitted to the Solana network and confirmed
@@ -2153,13 +2170,20 @@ declare class Escrow {
2153
2170
  status: string;
2154
2171
  }>;
2155
2172
  /**
2156
- * One-call lobby deposit: start deposits, prepare, sign, submit, and poll until
2173
+ * One-call lobby deposit: prepare-and-start, sign, submit, and poll until
2157
2174
  * the current user's deposit is confirmed. Requires sdk.wallet.setSigner() to be set.
2158
2175
  * Returns when all required deposits are confirmed and the lobby can proceed to queue.
2159
2176
  *
2160
2177
  * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2161
2178
  */
2162
2179
  depositForLobby(lobbyId: string): Promise<DepositForLobbyResponse>;
2180
+ /**
2181
+ * Zero-polling deposit variant using server-side awaitConfirmation.
2182
+ * 2 HTTP calls total, 0 client-side polling. Ideal for agents.
2183
+ *
2184
+ * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2185
+ */
2186
+ depositForLobbySync(lobbyId: string): Promise<DepositForLobbyResponse>;
2163
2187
  claimLobbyDepositRefund(lobbyId: string, depositSignature: string): Promise<{
2164
2188
  signature: string;
2165
2189
  status: string;
@@ -2168,25 +2192,6 @@ declare class Escrow {
2168
2192
  signature: string;
2169
2193
  status: string;
2170
2194
  }>;
2171
- /**
2172
- * Submit a signed deposit transaction and wait until the lobby is queued/active.
2173
- *
2174
- * Note: the backend may auto-transition the lobby to the queue once deposits are confirmed.
2175
- * In that case, calling /join-queue from the client would be redundant and can fail with
2176
- * "Current status: queued".
2177
- * @param lobbyId - The lobby ID
2178
- * @param signedTransaction - The signed transaction (base64 encoded)
2179
- * @param lobbies - The lobbies service instance (from sdk.lobbies) to read lobby status
2180
- */
2181
- submitDepositAndJoinQueue(lobbyId: string, signedTransaction: string, lobbies: {
2182
- getLobby: (id: string) => Promise<{
2183
- id: string;
2184
- status: string;
2185
- }>;
2186
- }): Promise<{
2187
- id: string;
2188
- status: string;
2189
- }>;
2190
2195
  }
2191
2196
 
2192
2197
  interface DailyRoom {
@@ -2560,6 +2565,7 @@ type LobbyStoreState = {
2560
2565
  lobbiesById: Record<string, Lobby>;
2561
2566
  matchedEvent: LobbyMatchedEvent | null;
2562
2567
  typingByLobbyId: Record<string, string[]>;
2568
+ depositStatusByLobbyId: Record<string, LobbyDepositUpdatedPayload>;
2563
2569
  };
2564
2570
  type LobbyStore = {
2565
2571
  store: SdkStore<LobbyStoreState>;
@@ -2567,6 +2573,7 @@ type LobbyStore = {
2567
2573
  applyWsEvent: (event: WsEvent) => void;
2568
2574
  joinLobby: (lobbyId: string) => () => void;
2569
2575
  subscribeMatched: (callback: (event: LobbyMatchedEvent) => void) => () => void;
2576
+ subscribeDepositUpdate: (lobbyId: string, callback: (data: LobbyDepositUpdatedPayload) => void) => () => void;
2570
2577
  };
2571
2578
  declare function createLobbyStore(transport: WsTransport): LobbyStore;
2572
2579
 
@@ -2830,4 +2837,4 @@ declare class HttpClient implements IHttpClient {
2830
2837
  private payChallenge;
2831
2838
  }
2832
2839
 
2833
- export { type AcceptChallengeResponse, type Achievement, Activity, type ActivityFeedItem, type ActivityFeedItemType, type ActivityFeedResponse, type ActivityFeedUser, Admin, type AdminDailyStats, type AdminDailyStatsItem, type AdminGameHistory, type AdminGameHistoryFeeBreakdown, type AdminGameHistoryFeePlayer, type AdminGameHistoryPlayer, type AdminMarketDailyStats, type AdminMarketDailyStatsItem, type AdminMarketDetail, type AdminMarketStats, type AdminStats, type AdminWalletActivityItem, type AdminWalletActivityResponse, 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 ClaimReferralRewardsResponse, 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 GameMetrics, type GamePlayer, type GameStateResponse, type GameStore, type GameStoreState, type GameType, Games, type GenerateHandshakeResponse, type GetTicketsOptions, HttpClient, type IHttpClient, type ILogger, type IStorage, type InviteFriendRequest, type LeaderboardEntry, type LeaderboardQuery, type LeaderboardRange, type LeaderboardResponse, Leaderboards, type LivePlayer, type LivePlayersPage, Lobbies, type Lobby, 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, type NotificationEvent, type NotificationsStore, type NotificationsStoreState, type PaginatedCriticalIncidents, 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, 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, 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, withRetry };
2840
+ export { type AcceptChallengeResponse, type Achievement, Activity, type ActivityFeedItem, type ActivityFeedItemType, type ActivityFeedResponse, type ActivityFeedUser, Admin, type AdminDailyStats, type AdminDailyStatsItem, type AdminGameHistory, type AdminGameHistoryFeeBreakdown, type AdminGameHistoryFeePlayer, type AdminGameHistoryPlayer, type AdminMarketDailyStats, type AdminMarketDailyStatsItem, type AdminMarketDetail, type AdminMarketStats, type AdminStats, type AdminWalletActivityItem, type AdminWalletActivityResponse, 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 ClaimReferralRewardsResponse, 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 GameMetrics, type GamePlayer, type GameStateResponse, type GameStore, type GameStoreState, type GameType, Games, type GenerateHandshakeResponse, type GetTicketsOptions, HttpClient, type IHttpClient, type ILogger, type IStorage, 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, type NotificationEvent, type NotificationsStore, type NotificationsStoreState, type PaginatedCriticalIncidents, 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, 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, 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, withRetry };
package/dist/index.js CHANGED
@@ -1101,19 +1101,18 @@ var Lobbies = class {
1101
1101
  return this.http.delete(`/lobbies/admin/${lobbyId}`);
1102
1102
  }
1103
1103
  /**
1104
- * Play again: Create a new lobby, start deposits, and prepare deposit transaction
1105
- * Returns the lobby and unsigned transaction that needs to be signed
1104
+ * Play again: Create a new lobby and prepare deposit in one flow.
1105
+ * Returns the lobby and unsigned transaction that needs to be signed.
1106
1106
  * @param gameType - The game type to play again
1107
1107
  * @param betAmount - The bet amount (same as previous game)
1108
1108
  * @param escrow - The escrow service instance (from sdk.escrow)
1109
1109
  */
1110
1110
  async playAgain(gameType, betAmount, escrow) {
1111
1111
  const lobby = await this.createLobby(gameType, betAmount);
1112
- await escrow.startDeposits(lobby.id);
1113
- const prepareResponse = await escrow.prepareDepositTransaction(lobby.id);
1112
+ const { transaction } = await escrow.prepareAndStartDeposit(lobby.id);
1114
1113
  return {
1115
1114
  lobby,
1116
- unsignedTransaction: prepareResponse.transaction
1115
+ unsignedTransaction: transaction
1117
1116
  };
1118
1117
  }
1119
1118
  };
@@ -2005,6 +2004,17 @@ var Escrow = class {
2005
2004
  `/escrow/lobby/${lobbyId}/deposit/prepare`
2006
2005
  );
2007
2006
  }
2007
+ /**
2008
+ * Combined prepare-and-start: validates lobby, transitions waiting→preparing,
2009
+ * initializes depositStatus, and prepares the unsigned transaction in one call.
2010
+ * Eliminates one HTTP round-trip vs startDeposits() + prepareDepositTransaction().
2011
+ */
2012
+ async prepareAndStartDeposit(lobbyId) {
2013
+ return this.http.post(
2014
+ `/escrow/lobby/${lobbyId}/deposit/prepare-and-start`,
2015
+ {}
2016
+ );
2017
+ }
2008
2018
  /**
2009
2019
  * Submit a signed deposit transaction
2010
2020
  * The transaction will be submitted to the Solana network and confirmed
@@ -2035,7 +2045,7 @@ var Escrow = class {
2035
2045
  );
2036
2046
  }
2037
2047
  /**
2038
- * One-call lobby deposit: start deposits, prepare, sign, submit, and poll until
2048
+ * One-call lobby deposit: prepare-and-start, sign, submit, and poll until
2039
2049
  * the current user's deposit is confirmed. Requires sdk.wallet.setSigner() to be set.
2040
2050
  * Returns when all required deposits are confirmed and the lobby can proceed to queue.
2041
2051
  *
@@ -2047,8 +2057,7 @@ var Escrow = class {
2047
2057
  "No signer configured. Use sdk.wallet.setSigner(...) first."
2048
2058
  );
2049
2059
  }
2050
- await this.startDeposits(lobbyId);
2051
- const { transaction } = await this.prepareDepositTransaction(lobbyId);
2060
+ const { transaction } = await this.prepareAndStartDeposit(lobbyId);
2052
2061
  const unsignedTx = Transaction5.from(base64ToBytes(transaction));
2053
2062
  let signature;
2054
2063
  if (this.wallet.isSignAndSendMode()) {
@@ -2070,7 +2079,7 @@ var Escrow = class {
2070
2079
  if (status.allConfirmed && status.canProceedToQueue) {
2071
2080
  return {
2072
2081
  signature,
2073
- status: "pending",
2082
+ status: "confirmed",
2074
2083
  canProceedToQueue: true
2075
2084
  };
2076
2085
  }
@@ -2082,6 +2091,39 @@ var Escrow = class {
2082
2091
  canProceedToQueue: false
2083
2092
  };
2084
2093
  }
2094
+ /**
2095
+ * Zero-polling deposit variant using server-side awaitConfirmation.
2096
+ * 2 HTTP calls total, 0 client-side polling. Ideal for agents.
2097
+ *
2098
+ * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2099
+ */
2100
+ async depositForLobbySync(lobbyId) {
2101
+ if (!this.wallet.hasSigner()) {
2102
+ throw new Error(
2103
+ "No signer configured. Use sdk.wallet.setSigner(...) first."
2104
+ );
2105
+ }
2106
+ const { transaction } = await this.prepareAndStartDeposit(lobbyId);
2107
+ const unsignedTx = Transaction5.from(base64ToBytes(transaction));
2108
+ let signature;
2109
+ if (this.wallet.isSignAndSendMode()) {
2110
+ signature = await this.wallet.signAndSendTransaction(unsignedTx);
2111
+ await this.http.post(
2112
+ `/escrow/lobby/${lobbyId}/deposit/confirm-signature?awaitConfirmation=true`,
2113
+ { signature }
2114
+ );
2115
+ } else {
2116
+ const signedTx = await this.wallet.signTransaction(unsignedTx);
2117
+ const signedBase64 = bytesToBase64(
2118
+ signedTx.serialize({ requireAllSignatures: false })
2119
+ );
2120
+ const result = await this.http.post(`/escrow/lobby/${lobbyId}/deposit/submit?awaitConfirmation=true`, {
2121
+ signedTransaction: signedBase64
2122
+ });
2123
+ signature = result.signature;
2124
+ }
2125
+ return { signature, status: "confirmed", canProceedToQueue: true };
2126
+ }
2085
2127
  async claimLobbyDepositRefund(lobbyId, depositSignature) {
2086
2128
  return this.http.post(
2087
2129
  `/escrow/lobby/${lobbyId}/deposit/${depositSignature}/claim-refund`,
@@ -2094,33 +2136,6 @@ var Escrow = class {
2094
2136
  {}
2095
2137
  );
2096
2138
  }
2097
- /**
2098
- * Submit a signed deposit transaction and wait until the lobby is queued/active.
2099
- *
2100
- * Note: the backend may auto-transition the lobby to the queue once deposits are confirmed.
2101
- * In that case, calling /join-queue from the client would be redundant and can fail with
2102
- * "Current status: queued".
2103
- * @param lobbyId - The lobby ID
2104
- * @param signedTransaction - The signed transaction (base64 encoded)
2105
- * @param lobbies - The lobbies service instance (from sdk.lobbies) to read lobby status
2106
- */
2107
- async submitDepositAndJoinQueue(lobbyId, signedTransaction, lobbies) {
2108
- await this.submitDeposit(lobbyId, signedTransaction);
2109
- const MAX_WAIT_TIME = 3e4;
2110
- const POLL_INTERVAL = 1e3;
2111
- const startTime = Date.now();
2112
- while (Date.now() - startTime < MAX_WAIT_TIME) {
2113
- const status = await this.getDepositStatus(lobbyId);
2114
- if (status.allConfirmed && status.canProceedToQueue) {
2115
- const lobby = await lobbies.getLobby(lobbyId);
2116
- if (lobby.status === "queued" || lobby.status === "active") {
2117
- return lobby;
2118
- }
2119
- }
2120
- await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
2121
- }
2122
- throw new Error("Deposit confirmation timeout");
2123
- }
2124
2139
  };
2125
2140
 
2126
2141
  // src/daily.ts
@@ -2769,8 +2784,14 @@ var _StandaloneWsTransport = class _StandaloneWsTransport extends BaseWsTranspor
2769
2784
  connecting: false,
2770
2785
  error: null
2771
2786
  });
2787
+ const wasReconnect = this.reconnectAttempts > 0;
2772
2788
  this.reconnectAttempts = 0;
2773
2789
  this.onReconnect();
2790
+ if (wasReconnect) {
2791
+ this.dispatchEvent("connection:reconnected", {
2792
+ timestamp: Date.now()
2793
+ });
2794
+ }
2774
2795
  });
2775
2796
  socket.on("disconnect", (reason) => {
2776
2797
  this.updateConnectionState({ connected: false, connecting: false });
@@ -2918,7 +2939,8 @@ function createLobbyStore(transport) {
2918
2939
  const store = createSdkStore({
2919
2940
  lobbiesById: {},
2920
2941
  matchedEvent: null,
2921
- typingByLobbyId: {}
2942
+ typingByLobbyId: {},
2943
+ depositStatusByLobbyId: {}
2922
2944
  });
2923
2945
  const setBaseState = (lobbies) => {
2924
2946
  const lobbiesById = {};
@@ -2998,6 +3020,15 @@ function createLobbyStore(transport) {
2998
3020
  };
2999
3021
  });
3000
3022
  break;
3023
+ case "lobby:deposit:updated":
3024
+ store.updateState((state) => ({
3025
+ ...state,
3026
+ depositStatusByLobbyId: {
3027
+ ...state.depositStatusByLobbyId,
3028
+ [event.payload.lobbyId]: event.payload
3029
+ }
3030
+ }));
3031
+ break;
3001
3032
  case "lobby:typing:start":
3002
3033
  case "lobby:typing:stop":
3003
3034
  store.updateState((state) => {
@@ -3026,12 +3057,22 @@ function createLobbyStore(transport) {
3026
3057
  }
3027
3058
  }
3028
3059
  );
3060
+ const subscribeDepositUpdate = (lobbyId, callback) => store.subscribeSelector(
3061
+ (state) => state.depositStatusByLobbyId[lobbyId],
3062
+ () => {
3063
+ const data = store.getState().depositStatusByLobbyId[lobbyId];
3064
+ if (data) {
3065
+ callback(data);
3066
+ }
3067
+ }
3068
+ );
3029
3069
  return {
3030
3070
  store,
3031
3071
  setBaseState,
3032
3072
  applyWsEvent,
3033
3073
  joinLobby,
3034
- subscribeMatched
3074
+ subscribeMatched,
3075
+ subscribeDepositUpdate
3035
3076
  };
3036
3077
  }
3037
3078
 
@@ -3317,7 +3358,6 @@ function createGameActionsStore(transport) {
3317
3358
  ...current,
3318
3359
  roundState: {
3319
3360
  ...current.roundState,
3320
- phase: "completed",
3321
3361
  timeRemaining: 0,
3322
3362
  actions: timedOutUser ? {
3323
3363
  ...current.roundState.actions,
@@ -3839,6 +3879,7 @@ var WS_EVENT_NAMES = [
3839
3879
  "lobby:queue:joined",
3840
3880
  "lobby:queue:cancelled",
3841
3881
  "lobby:matched",
3882
+ "lobby:deposit:updated",
3842
3883
  "lobby:typing:start",
3843
3884
  "lobby:typing:stop",
3844
3885
  "game:updated",
@@ -3915,6 +3956,11 @@ function decodeWsEvent(eventName, payload) {
3915
3956
  event: "lobby:matched",
3916
3957
  payload
3917
3958
  };
3959
+ case "lobby:deposit:updated":
3960
+ return {
3961
+ event: "lobby:deposit:updated",
3962
+ payload
3963
+ };
3918
3964
  case "lobby:typing:start":
3919
3965
  case "lobby:typing:stop":
3920
3966
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimcool/sdk",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",