@dimcool/sdk 0.1.26 → 0.1.28

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
@@ -916,6 +916,16 @@ var Admin = class {
916
916
  };
917
917
 
918
918
  // src/users.ts
919
+ function isFile(input) {
920
+ return typeof input.arrayBuffer === "function";
921
+ }
922
+ function buildFormDataFromPayload(payload) {
923
+ const formData = new FormData();
924
+ const part = payload.data instanceof Uint8Array ? payload.data : new Uint8Array(payload.data);
925
+ const blob = new Blob([part], { type: payload.mimeType });
926
+ formData.append("file", blob, payload.filename);
927
+ return formData;
928
+ }
919
929
  var Users = class {
920
930
  constructor(http, logger2) {
921
931
  this.http = http;
@@ -1002,14 +1012,22 @@ var Users = class {
1002
1012
  async updateProfile(data) {
1003
1013
  return this.http.patch("/users/me/profile", data);
1004
1014
  }
1005
- async uploadAvatar(file) {
1006
- const formData = new FormData();
1007
- formData.append("file", file);
1015
+ async uploadAvatar(input) {
1016
+ const payload = isFile(input) ? {
1017
+ data: new Uint8Array(await input.arrayBuffer()),
1018
+ mimeType: input.type,
1019
+ filename: input.name
1020
+ } : input;
1021
+ const formData = buildFormDataFromPayload(payload);
1008
1022
  return this.http.upload("/users/me/profile/avatar", formData);
1009
1023
  }
1010
- async uploadCoverImage(file) {
1011
- const formData = new FormData();
1012
- formData.append("file", file);
1024
+ async uploadCoverImage(input) {
1025
+ const payload = isFile(input) ? {
1026
+ data: new Uint8Array(await input.arrayBuffer()),
1027
+ mimeType: input.type,
1028
+ filename: input.name
1029
+ } : input;
1030
+ const formData = buildFormDataFromPayload(payload);
1013
1031
  return this.http.upload("/users/me/profile/cover", formData);
1014
1032
  }
1015
1033
  async removeAvatar() {
@@ -1153,19 +1171,18 @@ var Lobbies = class {
1153
1171
  return this.http.delete(`/lobbies/admin/${lobbyId}`);
1154
1172
  }
1155
1173
  /**
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
1174
+ * Play again: Create a new lobby and prepare deposit in one flow.
1175
+ * Returns the lobby and unsigned transaction that needs to be signed.
1158
1176
  * @param gameType - The game type to play again
1159
1177
  * @param betAmount - The bet amount (same as previous game)
1160
1178
  * @param escrow - The escrow service instance (from sdk.escrow)
1161
1179
  */
1162
1180
  async playAgain(gameType, betAmount, escrow) {
1163
1181
  const lobby = await this.createLobby(gameType, betAmount);
1164
- await escrow.startDeposits(lobby.id);
1165
- const prepareResponse = await escrow.prepareDepositTransaction(lobby.id);
1182
+ const { transaction } = await escrow.prepareAndStartDeposit(lobby.id);
1166
1183
  return {
1167
1184
  lobby,
1168
- unsignedTransaction: prepareResponse.transaction
1185
+ unsignedTransaction: transaction
1169
1186
  };
1170
1187
  }
1171
1188
  };
@@ -2057,6 +2074,17 @@ var Escrow = class {
2057
2074
  `/escrow/lobby/${lobbyId}/deposit/prepare`
2058
2075
  );
2059
2076
  }
2077
+ /**
2078
+ * Combined prepare-and-start: validates lobby, transitions waiting→preparing,
2079
+ * initializes depositStatus, and prepares the unsigned transaction in one call.
2080
+ * Eliminates one HTTP round-trip vs startDeposits() + prepareDepositTransaction().
2081
+ */
2082
+ async prepareAndStartDeposit(lobbyId) {
2083
+ return this.http.post(
2084
+ `/escrow/lobby/${lobbyId}/deposit/prepare-and-start`,
2085
+ {}
2086
+ );
2087
+ }
2060
2088
  /**
2061
2089
  * Submit a signed deposit transaction
2062
2090
  * The transaction will be submitted to the Solana network and confirmed
@@ -2087,7 +2115,7 @@ var Escrow = class {
2087
2115
  );
2088
2116
  }
2089
2117
  /**
2090
- * One-call lobby deposit: start deposits, prepare, sign, submit, and poll until
2118
+ * One-call lobby deposit: prepare-and-start, sign, submit, and poll until
2091
2119
  * the current user's deposit is confirmed. Requires sdk.wallet.setSigner() to be set.
2092
2120
  * Returns when all required deposits are confirmed and the lobby can proceed to queue.
2093
2121
  *
@@ -2099,8 +2127,7 @@ var Escrow = class {
2099
2127
  "No signer configured. Use sdk.wallet.setSigner(...) first."
2100
2128
  );
2101
2129
  }
2102
- await this.startDeposits(lobbyId);
2103
- const { transaction } = await this.prepareDepositTransaction(lobbyId);
2130
+ const { transaction } = await this.prepareAndStartDeposit(lobbyId);
2104
2131
  const unsignedTx = import_web35.Transaction.from(base64ToBytes(transaction));
2105
2132
  let signature;
2106
2133
  if (this.wallet.isSignAndSendMode()) {
@@ -2122,7 +2149,7 @@ var Escrow = class {
2122
2149
  if (status.allConfirmed && status.canProceedToQueue) {
2123
2150
  return {
2124
2151
  signature,
2125
- status: "pending",
2152
+ status: "confirmed",
2126
2153
  canProceedToQueue: true
2127
2154
  };
2128
2155
  }
@@ -2134,6 +2161,39 @@ var Escrow = class {
2134
2161
  canProceedToQueue: false
2135
2162
  };
2136
2163
  }
2164
+ /**
2165
+ * Zero-polling deposit variant using server-side awaitConfirmation.
2166
+ * 2 HTTP calls total, 0 client-side polling. Ideal for agents.
2167
+ *
2168
+ * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2169
+ */
2170
+ async depositForLobbySync(lobbyId) {
2171
+ if (!this.wallet.hasSigner()) {
2172
+ throw new Error(
2173
+ "No signer configured. Use sdk.wallet.setSigner(...) first."
2174
+ );
2175
+ }
2176
+ const { transaction } = await this.prepareAndStartDeposit(lobbyId);
2177
+ const unsignedTx = import_web35.Transaction.from(base64ToBytes(transaction));
2178
+ let signature;
2179
+ if (this.wallet.isSignAndSendMode()) {
2180
+ signature = await this.wallet.signAndSendTransaction(unsignedTx);
2181
+ await this.http.post(
2182
+ `/escrow/lobby/${lobbyId}/deposit/confirm-signature?awaitConfirmation=true`,
2183
+ { signature }
2184
+ );
2185
+ } else {
2186
+ const signedTx = await this.wallet.signTransaction(unsignedTx);
2187
+ const signedBase64 = bytesToBase64(
2188
+ signedTx.serialize({ requireAllSignatures: false })
2189
+ );
2190
+ const result = await this.http.post(`/escrow/lobby/${lobbyId}/deposit/submit?awaitConfirmation=true`, {
2191
+ signedTransaction: signedBase64
2192
+ });
2193
+ signature = result.signature;
2194
+ }
2195
+ return { signature, status: "confirmed", canProceedToQueue: true };
2196
+ }
2137
2197
  async claimLobbyDepositRefund(lobbyId, depositSignature) {
2138
2198
  return this.http.post(
2139
2199
  `/escrow/lobby/${lobbyId}/deposit/${depositSignature}/claim-refund`,
@@ -2146,33 +2206,6 @@ var Escrow = class {
2146
2206
  {}
2147
2207
  );
2148
2208
  }
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
2209
  };
2177
2210
 
2178
2211
  // src/daily.ts
@@ -2821,8 +2854,14 @@ var _StandaloneWsTransport = class _StandaloneWsTransport extends BaseWsTranspor
2821
2854
  connecting: false,
2822
2855
  error: null
2823
2856
  });
2857
+ const wasReconnect = this.reconnectAttempts > 0;
2824
2858
  this.reconnectAttempts = 0;
2825
2859
  this.onReconnect();
2860
+ if (wasReconnect) {
2861
+ this.dispatchEvent("connection:reconnected", {
2862
+ timestamp: Date.now()
2863
+ });
2864
+ }
2826
2865
  });
2827
2866
  socket.on("disconnect", (reason) => {
2828
2867
  this.updateConnectionState({ connected: false, connecting: false });
@@ -2970,7 +3009,8 @@ function createLobbyStore(transport) {
2970
3009
  const store = createSdkStore({
2971
3010
  lobbiesById: {},
2972
3011
  matchedEvent: null,
2973
- typingByLobbyId: {}
3012
+ typingByLobbyId: {},
3013
+ depositStatusByLobbyId: {}
2974
3014
  });
2975
3015
  const setBaseState = (lobbies) => {
2976
3016
  const lobbiesById = {};
@@ -3050,6 +3090,15 @@ function createLobbyStore(transport) {
3050
3090
  };
3051
3091
  });
3052
3092
  break;
3093
+ case "lobby:deposit:updated":
3094
+ store.updateState((state) => ({
3095
+ ...state,
3096
+ depositStatusByLobbyId: {
3097
+ ...state.depositStatusByLobbyId,
3098
+ [event.payload.lobbyId]: event.payload
3099
+ }
3100
+ }));
3101
+ break;
3053
3102
  case "lobby:typing:start":
3054
3103
  case "lobby:typing:stop":
3055
3104
  store.updateState((state) => {
@@ -3078,12 +3127,22 @@ function createLobbyStore(transport) {
3078
3127
  }
3079
3128
  }
3080
3129
  );
3130
+ const subscribeDepositUpdate = (lobbyId, callback) => store.subscribeSelector(
3131
+ (state) => state.depositStatusByLobbyId[lobbyId],
3132
+ () => {
3133
+ const data = store.getState().depositStatusByLobbyId[lobbyId];
3134
+ if (data) {
3135
+ callback(data);
3136
+ }
3137
+ }
3138
+ );
3081
3139
  return {
3082
3140
  store,
3083
3141
  setBaseState,
3084
3142
  applyWsEvent,
3085
3143
  joinLobby,
3086
- subscribeMatched
3144
+ subscribeMatched,
3145
+ subscribeDepositUpdate
3087
3146
  };
3088
3147
  }
3089
3148
 
@@ -3369,7 +3428,6 @@ function createGameActionsStore(transport) {
3369
3428
  ...current,
3370
3429
  roundState: {
3371
3430
  ...current.roundState,
3372
- phase: "completed",
3373
3431
  timeRemaining: 0,
3374
3432
  actions: timedOutUser ? {
3375
3433
  ...current.roundState.actions,
@@ -3414,6 +3472,22 @@ function createGameActionsStore(transport) {
3414
3472
  updateState(gameId, updated);
3415
3473
  break;
3416
3474
  }
3475
+ case "game:move": {
3476
+ const { gameId, fen, turn, currentPlayerId, status, winnerId } = event.payload;
3477
+ if (!gameId) return;
3478
+ const current = store.getState().statesByGameId[gameId];
3479
+ if (!isNonRpsState(current)) return;
3480
+ const updated = {
3481
+ ...current,
3482
+ fen,
3483
+ turn,
3484
+ currentPlayerId,
3485
+ status,
3486
+ ...winnerId != null && { winnerId }
3487
+ };
3488
+ updateState(gameId, updated);
3489
+ break;
3490
+ }
3417
3491
  case "game:state": {
3418
3492
  const gameId = event.payload.gameId ?? event.payload.state.gameId;
3419
3493
  if (!gameId) return;
@@ -3891,6 +3965,7 @@ var WS_EVENT_NAMES = [
3891
3965
  "lobby:queue:joined",
3892
3966
  "lobby:queue:cancelled",
3893
3967
  "lobby:matched",
3968
+ "lobby:deposit:updated",
3894
3969
  "lobby:typing:start",
3895
3970
  "lobby:typing:stop",
3896
3971
  "game:updated",
@@ -3967,6 +4042,11 @@ function decodeWsEvent(eventName, payload) {
3967
4042
  event: "lobby:matched",
3968
4043
  payload
3969
4044
  };
4045
+ case "lobby:deposit:updated":
4046
+ return {
4047
+ event: "lobby:deposit:updated",
4048
+ payload
4049
+ };
3970
4050
  case "lobby:typing:start":
3971
4051
  case "lobby:typing:stop":
3972
4052
  return {
package/dist/index.d.cts CHANGED
@@ -1079,6 +1079,12 @@ declare class Admin {
1079
1079
  }): Promise<PaginatedPlatformFees>;
1080
1080
  }
1081
1081
 
1082
+ /** Generic image upload payload (bytes + metadata). Used by agents/Node; browser callers can pass File. */
1083
+ interface ImageUploadPayload {
1084
+ data: Uint8Array | Buffer;
1085
+ mimeType: string;
1086
+ filename: string;
1087
+ }
1082
1088
  declare class Users {
1083
1089
  private http;
1084
1090
  private logger?;
@@ -1117,8 +1123,8 @@ declare class Users {
1117
1123
  bio?: string;
1118
1124
  username?: string;
1119
1125
  }): Promise<User>;
1120
- uploadAvatar(file: File): Promise<User>;
1121
- uploadCoverImage(file: File): Promise<User>;
1126
+ uploadAvatar(input: File | ImageUploadPayload): Promise<User>;
1127
+ uploadCoverImage(input: File | ImageUploadPayload): Promise<User>;
1122
1128
  removeAvatar(): Promise<User>;
1123
1129
  removeCoverImage(): Promise<User>;
1124
1130
  getAllFiles(): Promise<Array<{
@@ -1199,7 +1205,7 @@ interface QueueStats {
1199
1205
  totalQueuedLobbies: number;
1200
1206
  }
1201
1207
  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';
1208
+ 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
1209
  interface ChatMessageReply {
1204
1210
  id: string;
1205
1211
  userId?: string;
@@ -1264,15 +1270,14 @@ declare class Lobbies {
1264
1270
  message: string;
1265
1271
  }>;
1266
1272
  /**
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
1273
+ * Play again: Create a new lobby and prepare deposit in one flow.
1274
+ * Returns the lobby and unsigned transaction that needs to be signed.
1269
1275
  * @param gameType - The game type to play again
1270
1276
  * @param betAmount - The bet amount (same as previous game)
1271
1277
  * @param escrow - The escrow service instance (from sdk.escrow)
1272
1278
  */
1273
1279
  playAgain(gameType: string, betAmount: MoneyMinor, escrow: {
1274
- startDeposits: (id: string) => Promise<void>;
1275
- prepareDepositTransaction: (id: string) => Promise<{
1280
+ prepareAndStartDeposit: (id: string) => Promise<{
1276
1281
  transaction: string;
1277
1282
  message: string;
1278
1283
  }>;
@@ -1288,6 +1293,8 @@ interface GameType {
1288
1293
  maxPlayers: number;
1289
1294
  minPlayers: number;
1290
1295
  description?: string;
1296
+ /** Agent-facing instructions including game pace (how fast the game is). */
1297
+ detailedInstructions?: string;
1291
1298
  available: boolean;
1292
1299
  betOptions?: BetOption[];
1293
1300
  }
@@ -1418,6 +1425,7 @@ declare class Games {
1418
1425
  success: boolean;
1419
1426
  bothReady: boolean;
1420
1427
  newGameId?: string;
1428
+ newLobbyId?: string;
1421
1429
  }>;
1422
1430
  /**
1423
1431
  * Cancel a rematch request
@@ -1701,7 +1709,7 @@ declare class Tips {
1701
1709
  send(recipientUsername: string, amount: number): Promise<SendTipResponse>;
1702
1710
  }
1703
1711
 
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';
1712
+ 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
1713
  type GameTurnPayload = {
1706
1714
  turn: number;
1707
1715
  currentPlayerId: string;
@@ -1804,6 +1812,12 @@ type MarketResolvedPayload = {
1804
1812
  resolvedOutcome: string | null;
1805
1813
  isDraw: boolean;
1806
1814
  };
1815
+ type LobbyDepositUpdatedPayload = {
1816
+ lobbyId: string;
1817
+ userId: string;
1818
+ status: string;
1819
+ allConfirmed: boolean;
1820
+ };
1807
1821
  type WsEvent = {
1808
1822
  event: 'lobby:created';
1809
1823
  payload: Lobby;
@@ -1863,6 +1877,9 @@ type WsEvent = {
1863
1877
  gameType: string;
1864
1878
  matchedLobbies: Lobby[];
1865
1879
  };
1880
+ } | {
1881
+ event: 'lobby:deposit:updated';
1882
+ payload: LobbyDepositUpdatedPayload;
1866
1883
  } | {
1867
1884
  event: 'lobby:typing:start';
1868
1885
  payload: {
@@ -2137,6 +2154,12 @@ declare class Escrow {
2137
2154
  * Returns an unsigned transaction that needs to be signed by the user
2138
2155
  */
2139
2156
  prepareDepositTransaction(lobbyId: string): Promise<PrepareDepositResponse>;
2157
+ /**
2158
+ * Combined prepare-and-start: validates lobby, transitions waiting→preparing,
2159
+ * initializes depositStatus, and prepares the unsigned transaction in one call.
2160
+ * Eliminates one HTTP round-trip vs startDeposits() + prepareDepositTransaction().
2161
+ */
2162
+ prepareAndStartDeposit(lobbyId: string): Promise<PrepareDepositResponse>;
2140
2163
  /**
2141
2164
  * Submit a signed deposit transaction
2142
2165
  * The transaction will be submitted to the Solana network and confirmed
@@ -2153,13 +2176,20 @@ declare class Escrow {
2153
2176
  status: string;
2154
2177
  }>;
2155
2178
  /**
2156
- * One-call lobby deposit: start deposits, prepare, sign, submit, and poll until
2179
+ * One-call lobby deposit: prepare-and-start, sign, submit, and poll until
2157
2180
  * the current user's deposit is confirmed. Requires sdk.wallet.setSigner() to be set.
2158
2181
  * Returns when all required deposits are confirmed and the lobby can proceed to queue.
2159
2182
  *
2160
2183
  * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2161
2184
  */
2162
2185
  depositForLobby(lobbyId: string): Promise<DepositForLobbyResponse>;
2186
+ /**
2187
+ * Zero-polling deposit variant using server-side awaitConfirmation.
2188
+ * 2 HTTP calls total, 0 client-side polling. Ideal for agents.
2189
+ *
2190
+ * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2191
+ */
2192
+ depositForLobbySync(lobbyId: string): Promise<DepositForLobbyResponse>;
2163
2193
  claimLobbyDepositRefund(lobbyId: string, depositSignature: string): Promise<{
2164
2194
  signature: string;
2165
2195
  status: string;
@@ -2168,25 +2198,6 @@ declare class Escrow {
2168
2198
  signature: string;
2169
2199
  status: string;
2170
2200
  }>;
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
2201
  }
2191
2202
 
2192
2203
  interface DailyRoom {
@@ -2560,6 +2571,7 @@ type LobbyStoreState = {
2560
2571
  lobbiesById: Record<string, Lobby>;
2561
2572
  matchedEvent: LobbyMatchedEvent | null;
2562
2573
  typingByLobbyId: Record<string, string[]>;
2574
+ depositStatusByLobbyId: Record<string, LobbyDepositUpdatedPayload>;
2563
2575
  };
2564
2576
  type LobbyStore = {
2565
2577
  store: SdkStore<LobbyStoreState>;
@@ -2567,6 +2579,7 @@ type LobbyStore = {
2567
2579
  applyWsEvent: (event: WsEvent) => void;
2568
2580
  joinLobby: (lobbyId: string) => () => void;
2569
2581
  subscribeMatched: (callback: (event: LobbyMatchedEvent) => void) => () => void;
2582
+ subscribeDepositUpdate: (lobbyId: string, callback: (data: LobbyDepositUpdatedPayload) => void) => () => void;
2570
2583
  };
2571
2584
  declare function createLobbyStore(transport: WsTransport): LobbyStore;
2572
2585
 
@@ -2830,4 +2843,4 @@ declare class HttpClient implements IHttpClient {
2830
2843
  private payChallenge;
2831
2844
  }
2832
2845
 
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 };
2846
+ 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 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, 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
@@ -1079,6 +1079,12 @@ declare class Admin {
1079
1079
  }): Promise<PaginatedPlatformFees>;
1080
1080
  }
1081
1081
 
1082
+ /** Generic image upload payload (bytes + metadata). Used by agents/Node; browser callers can pass File. */
1083
+ interface ImageUploadPayload {
1084
+ data: Uint8Array | Buffer;
1085
+ mimeType: string;
1086
+ filename: string;
1087
+ }
1082
1088
  declare class Users {
1083
1089
  private http;
1084
1090
  private logger?;
@@ -1117,8 +1123,8 @@ declare class Users {
1117
1123
  bio?: string;
1118
1124
  username?: string;
1119
1125
  }): Promise<User>;
1120
- uploadAvatar(file: File): Promise<User>;
1121
- uploadCoverImage(file: File): Promise<User>;
1126
+ uploadAvatar(input: File | ImageUploadPayload): Promise<User>;
1127
+ uploadCoverImage(input: File | ImageUploadPayload): Promise<User>;
1122
1128
  removeAvatar(): Promise<User>;
1123
1129
  removeCoverImage(): Promise<User>;
1124
1130
  getAllFiles(): Promise<Array<{
@@ -1199,7 +1205,7 @@ interface QueueStats {
1199
1205
  totalQueuedLobbies: number;
1200
1206
  }
1201
1207
  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';
1208
+ 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
1209
  interface ChatMessageReply {
1204
1210
  id: string;
1205
1211
  userId?: string;
@@ -1264,15 +1270,14 @@ declare class Lobbies {
1264
1270
  message: string;
1265
1271
  }>;
1266
1272
  /**
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
1273
+ * Play again: Create a new lobby and prepare deposit in one flow.
1274
+ * Returns the lobby and unsigned transaction that needs to be signed.
1269
1275
  * @param gameType - The game type to play again
1270
1276
  * @param betAmount - The bet amount (same as previous game)
1271
1277
  * @param escrow - The escrow service instance (from sdk.escrow)
1272
1278
  */
1273
1279
  playAgain(gameType: string, betAmount: MoneyMinor, escrow: {
1274
- startDeposits: (id: string) => Promise<void>;
1275
- prepareDepositTransaction: (id: string) => Promise<{
1280
+ prepareAndStartDeposit: (id: string) => Promise<{
1276
1281
  transaction: string;
1277
1282
  message: string;
1278
1283
  }>;
@@ -1288,6 +1293,8 @@ interface GameType {
1288
1293
  maxPlayers: number;
1289
1294
  minPlayers: number;
1290
1295
  description?: string;
1296
+ /** Agent-facing instructions including game pace (how fast the game is). */
1297
+ detailedInstructions?: string;
1291
1298
  available: boolean;
1292
1299
  betOptions?: BetOption[];
1293
1300
  }
@@ -1418,6 +1425,7 @@ declare class Games {
1418
1425
  success: boolean;
1419
1426
  bothReady: boolean;
1420
1427
  newGameId?: string;
1428
+ newLobbyId?: string;
1421
1429
  }>;
1422
1430
  /**
1423
1431
  * Cancel a rematch request
@@ -1701,7 +1709,7 @@ declare class Tips {
1701
1709
  send(recipientUsername: string, amount: number): Promise<SendTipResponse>;
1702
1710
  }
1703
1711
 
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';
1712
+ 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
1713
  type GameTurnPayload = {
1706
1714
  turn: number;
1707
1715
  currentPlayerId: string;
@@ -1804,6 +1812,12 @@ type MarketResolvedPayload = {
1804
1812
  resolvedOutcome: string | null;
1805
1813
  isDraw: boolean;
1806
1814
  };
1815
+ type LobbyDepositUpdatedPayload = {
1816
+ lobbyId: string;
1817
+ userId: string;
1818
+ status: string;
1819
+ allConfirmed: boolean;
1820
+ };
1807
1821
  type WsEvent = {
1808
1822
  event: 'lobby:created';
1809
1823
  payload: Lobby;
@@ -1863,6 +1877,9 @@ type WsEvent = {
1863
1877
  gameType: string;
1864
1878
  matchedLobbies: Lobby[];
1865
1879
  };
1880
+ } | {
1881
+ event: 'lobby:deposit:updated';
1882
+ payload: LobbyDepositUpdatedPayload;
1866
1883
  } | {
1867
1884
  event: 'lobby:typing:start';
1868
1885
  payload: {
@@ -2137,6 +2154,12 @@ declare class Escrow {
2137
2154
  * Returns an unsigned transaction that needs to be signed by the user
2138
2155
  */
2139
2156
  prepareDepositTransaction(lobbyId: string): Promise<PrepareDepositResponse>;
2157
+ /**
2158
+ * Combined prepare-and-start: validates lobby, transitions waiting→preparing,
2159
+ * initializes depositStatus, and prepares the unsigned transaction in one call.
2160
+ * Eliminates one HTTP round-trip vs startDeposits() + prepareDepositTransaction().
2161
+ */
2162
+ prepareAndStartDeposit(lobbyId: string): Promise<PrepareDepositResponse>;
2140
2163
  /**
2141
2164
  * Submit a signed deposit transaction
2142
2165
  * The transaction will be submitted to the Solana network and confirmed
@@ -2153,13 +2176,20 @@ declare class Escrow {
2153
2176
  status: string;
2154
2177
  }>;
2155
2178
  /**
2156
- * One-call lobby deposit: start deposits, prepare, sign, submit, and poll until
2179
+ * One-call lobby deposit: prepare-and-start, sign, submit, and poll until
2157
2180
  * the current user's deposit is confirmed. Requires sdk.wallet.setSigner() to be set.
2158
2181
  * Returns when all required deposits are confirmed and the lobby can proceed to queue.
2159
2182
  *
2160
2183
  * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2161
2184
  */
2162
2185
  depositForLobby(lobbyId: string): Promise<DepositForLobbyResponse>;
2186
+ /**
2187
+ * Zero-polling deposit variant using server-side awaitConfirmation.
2188
+ * 2 HTTP calls total, 0 client-side polling. Ideal for agents.
2189
+ *
2190
+ * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2191
+ */
2192
+ depositForLobbySync(lobbyId: string): Promise<DepositForLobbyResponse>;
2163
2193
  claimLobbyDepositRefund(lobbyId: string, depositSignature: string): Promise<{
2164
2194
  signature: string;
2165
2195
  status: string;
@@ -2168,25 +2198,6 @@ declare class Escrow {
2168
2198
  signature: string;
2169
2199
  status: string;
2170
2200
  }>;
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
2201
  }
2191
2202
 
2192
2203
  interface DailyRoom {
@@ -2560,6 +2571,7 @@ type LobbyStoreState = {
2560
2571
  lobbiesById: Record<string, Lobby>;
2561
2572
  matchedEvent: LobbyMatchedEvent | null;
2562
2573
  typingByLobbyId: Record<string, string[]>;
2574
+ depositStatusByLobbyId: Record<string, LobbyDepositUpdatedPayload>;
2563
2575
  };
2564
2576
  type LobbyStore = {
2565
2577
  store: SdkStore<LobbyStoreState>;
@@ -2567,6 +2579,7 @@ type LobbyStore = {
2567
2579
  applyWsEvent: (event: WsEvent) => void;
2568
2580
  joinLobby: (lobbyId: string) => () => void;
2569
2581
  subscribeMatched: (callback: (event: LobbyMatchedEvent) => void) => () => void;
2582
+ subscribeDepositUpdate: (lobbyId: string, callback: (data: LobbyDepositUpdatedPayload) => void) => () => void;
2570
2583
  };
2571
2584
  declare function createLobbyStore(transport: WsTransport): LobbyStore;
2572
2585
 
@@ -2830,4 +2843,4 @@ declare class HttpClient implements IHttpClient {
2830
2843
  private payChallenge;
2831
2844
  }
2832
2845
 
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 };
2846
+ 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 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, 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
@@ -864,6 +864,16 @@ var Admin = class {
864
864
  };
865
865
 
866
866
  // src/users.ts
867
+ function isFile(input) {
868
+ return typeof input.arrayBuffer === "function";
869
+ }
870
+ function buildFormDataFromPayload(payload) {
871
+ const formData = new FormData();
872
+ const part = payload.data instanceof Uint8Array ? payload.data : new Uint8Array(payload.data);
873
+ const blob = new Blob([part], { type: payload.mimeType });
874
+ formData.append("file", blob, payload.filename);
875
+ return formData;
876
+ }
867
877
  var Users = class {
868
878
  constructor(http, logger2) {
869
879
  this.http = http;
@@ -950,14 +960,22 @@ var Users = class {
950
960
  async updateProfile(data) {
951
961
  return this.http.patch("/users/me/profile", data);
952
962
  }
953
- async uploadAvatar(file) {
954
- const formData = new FormData();
955
- formData.append("file", file);
963
+ async uploadAvatar(input) {
964
+ const payload = isFile(input) ? {
965
+ data: new Uint8Array(await input.arrayBuffer()),
966
+ mimeType: input.type,
967
+ filename: input.name
968
+ } : input;
969
+ const formData = buildFormDataFromPayload(payload);
956
970
  return this.http.upload("/users/me/profile/avatar", formData);
957
971
  }
958
- async uploadCoverImage(file) {
959
- const formData = new FormData();
960
- formData.append("file", file);
972
+ async uploadCoverImage(input) {
973
+ const payload = isFile(input) ? {
974
+ data: new Uint8Array(await input.arrayBuffer()),
975
+ mimeType: input.type,
976
+ filename: input.name
977
+ } : input;
978
+ const formData = buildFormDataFromPayload(payload);
961
979
  return this.http.upload("/users/me/profile/cover", formData);
962
980
  }
963
981
  async removeAvatar() {
@@ -1101,19 +1119,18 @@ var Lobbies = class {
1101
1119
  return this.http.delete(`/lobbies/admin/${lobbyId}`);
1102
1120
  }
1103
1121
  /**
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
1122
+ * Play again: Create a new lobby and prepare deposit in one flow.
1123
+ * Returns the lobby and unsigned transaction that needs to be signed.
1106
1124
  * @param gameType - The game type to play again
1107
1125
  * @param betAmount - The bet amount (same as previous game)
1108
1126
  * @param escrow - The escrow service instance (from sdk.escrow)
1109
1127
  */
1110
1128
  async playAgain(gameType, betAmount, escrow) {
1111
1129
  const lobby = await this.createLobby(gameType, betAmount);
1112
- await escrow.startDeposits(lobby.id);
1113
- const prepareResponse = await escrow.prepareDepositTransaction(lobby.id);
1130
+ const { transaction } = await escrow.prepareAndStartDeposit(lobby.id);
1114
1131
  return {
1115
1132
  lobby,
1116
- unsignedTransaction: prepareResponse.transaction
1133
+ unsignedTransaction: transaction
1117
1134
  };
1118
1135
  }
1119
1136
  };
@@ -2005,6 +2022,17 @@ var Escrow = class {
2005
2022
  `/escrow/lobby/${lobbyId}/deposit/prepare`
2006
2023
  );
2007
2024
  }
2025
+ /**
2026
+ * Combined prepare-and-start: validates lobby, transitions waiting→preparing,
2027
+ * initializes depositStatus, and prepares the unsigned transaction in one call.
2028
+ * Eliminates one HTTP round-trip vs startDeposits() + prepareDepositTransaction().
2029
+ */
2030
+ async prepareAndStartDeposit(lobbyId) {
2031
+ return this.http.post(
2032
+ `/escrow/lobby/${lobbyId}/deposit/prepare-and-start`,
2033
+ {}
2034
+ );
2035
+ }
2008
2036
  /**
2009
2037
  * Submit a signed deposit transaction
2010
2038
  * The transaction will be submitted to the Solana network and confirmed
@@ -2035,7 +2063,7 @@ var Escrow = class {
2035
2063
  );
2036
2064
  }
2037
2065
  /**
2038
- * One-call lobby deposit: start deposits, prepare, sign, submit, and poll until
2066
+ * One-call lobby deposit: prepare-and-start, sign, submit, and poll until
2039
2067
  * the current user's deposit is confirmed. Requires sdk.wallet.setSigner() to be set.
2040
2068
  * Returns when all required deposits are confirmed and the lobby can proceed to queue.
2041
2069
  *
@@ -2047,8 +2075,7 @@ var Escrow = class {
2047
2075
  "No signer configured. Use sdk.wallet.setSigner(...) first."
2048
2076
  );
2049
2077
  }
2050
- await this.startDeposits(lobbyId);
2051
- const { transaction } = await this.prepareDepositTransaction(lobbyId);
2078
+ const { transaction } = await this.prepareAndStartDeposit(lobbyId);
2052
2079
  const unsignedTx = Transaction5.from(base64ToBytes(transaction));
2053
2080
  let signature;
2054
2081
  if (this.wallet.isSignAndSendMode()) {
@@ -2070,7 +2097,7 @@ var Escrow = class {
2070
2097
  if (status.allConfirmed && status.canProceedToQueue) {
2071
2098
  return {
2072
2099
  signature,
2073
- status: "pending",
2100
+ status: "confirmed",
2074
2101
  canProceedToQueue: true
2075
2102
  };
2076
2103
  }
@@ -2082,6 +2109,39 @@ var Escrow = class {
2082
2109
  canProceedToQueue: false
2083
2110
  };
2084
2111
  }
2112
+ /**
2113
+ * Zero-polling deposit variant using server-side awaitConfirmation.
2114
+ * 2 HTTP calls total, 0 client-side polling. Ideal for agents.
2115
+ *
2116
+ * Automatically uses signAndSendTransaction or signTransaction based on signer capability.
2117
+ */
2118
+ async depositForLobbySync(lobbyId) {
2119
+ if (!this.wallet.hasSigner()) {
2120
+ throw new Error(
2121
+ "No signer configured. Use sdk.wallet.setSigner(...) first."
2122
+ );
2123
+ }
2124
+ const { transaction } = await this.prepareAndStartDeposit(lobbyId);
2125
+ const unsignedTx = Transaction5.from(base64ToBytes(transaction));
2126
+ let signature;
2127
+ if (this.wallet.isSignAndSendMode()) {
2128
+ signature = await this.wallet.signAndSendTransaction(unsignedTx);
2129
+ await this.http.post(
2130
+ `/escrow/lobby/${lobbyId}/deposit/confirm-signature?awaitConfirmation=true`,
2131
+ { signature }
2132
+ );
2133
+ } else {
2134
+ const signedTx = await this.wallet.signTransaction(unsignedTx);
2135
+ const signedBase64 = bytesToBase64(
2136
+ signedTx.serialize({ requireAllSignatures: false })
2137
+ );
2138
+ const result = await this.http.post(`/escrow/lobby/${lobbyId}/deposit/submit?awaitConfirmation=true`, {
2139
+ signedTransaction: signedBase64
2140
+ });
2141
+ signature = result.signature;
2142
+ }
2143
+ return { signature, status: "confirmed", canProceedToQueue: true };
2144
+ }
2085
2145
  async claimLobbyDepositRefund(lobbyId, depositSignature) {
2086
2146
  return this.http.post(
2087
2147
  `/escrow/lobby/${lobbyId}/deposit/${depositSignature}/claim-refund`,
@@ -2094,33 +2154,6 @@ var Escrow = class {
2094
2154
  {}
2095
2155
  );
2096
2156
  }
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
2157
  };
2125
2158
 
2126
2159
  // src/daily.ts
@@ -2769,8 +2802,14 @@ var _StandaloneWsTransport = class _StandaloneWsTransport extends BaseWsTranspor
2769
2802
  connecting: false,
2770
2803
  error: null
2771
2804
  });
2805
+ const wasReconnect = this.reconnectAttempts > 0;
2772
2806
  this.reconnectAttempts = 0;
2773
2807
  this.onReconnect();
2808
+ if (wasReconnect) {
2809
+ this.dispatchEvent("connection:reconnected", {
2810
+ timestamp: Date.now()
2811
+ });
2812
+ }
2774
2813
  });
2775
2814
  socket.on("disconnect", (reason) => {
2776
2815
  this.updateConnectionState({ connected: false, connecting: false });
@@ -2918,7 +2957,8 @@ function createLobbyStore(transport) {
2918
2957
  const store = createSdkStore({
2919
2958
  lobbiesById: {},
2920
2959
  matchedEvent: null,
2921
- typingByLobbyId: {}
2960
+ typingByLobbyId: {},
2961
+ depositStatusByLobbyId: {}
2922
2962
  });
2923
2963
  const setBaseState = (lobbies) => {
2924
2964
  const lobbiesById = {};
@@ -2998,6 +3038,15 @@ function createLobbyStore(transport) {
2998
3038
  };
2999
3039
  });
3000
3040
  break;
3041
+ case "lobby:deposit:updated":
3042
+ store.updateState((state) => ({
3043
+ ...state,
3044
+ depositStatusByLobbyId: {
3045
+ ...state.depositStatusByLobbyId,
3046
+ [event.payload.lobbyId]: event.payload
3047
+ }
3048
+ }));
3049
+ break;
3001
3050
  case "lobby:typing:start":
3002
3051
  case "lobby:typing:stop":
3003
3052
  store.updateState((state) => {
@@ -3026,12 +3075,22 @@ function createLobbyStore(transport) {
3026
3075
  }
3027
3076
  }
3028
3077
  );
3078
+ const subscribeDepositUpdate = (lobbyId, callback) => store.subscribeSelector(
3079
+ (state) => state.depositStatusByLobbyId[lobbyId],
3080
+ () => {
3081
+ const data = store.getState().depositStatusByLobbyId[lobbyId];
3082
+ if (data) {
3083
+ callback(data);
3084
+ }
3085
+ }
3086
+ );
3029
3087
  return {
3030
3088
  store,
3031
3089
  setBaseState,
3032
3090
  applyWsEvent,
3033
3091
  joinLobby,
3034
- subscribeMatched
3092
+ subscribeMatched,
3093
+ subscribeDepositUpdate
3035
3094
  };
3036
3095
  }
3037
3096
 
@@ -3317,7 +3376,6 @@ function createGameActionsStore(transport) {
3317
3376
  ...current,
3318
3377
  roundState: {
3319
3378
  ...current.roundState,
3320
- phase: "completed",
3321
3379
  timeRemaining: 0,
3322
3380
  actions: timedOutUser ? {
3323
3381
  ...current.roundState.actions,
@@ -3362,6 +3420,22 @@ function createGameActionsStore(transport) {
3362
3420
  updateState(gameId, updated);
3363
3421
  break;
3364
3422
  }
3423
+ case "game:move": {
3424
+ const { gameId, fen, turn, currentPlayerId, status, winnerId } = event.payload;
3425
+ if (!gameId) return;
3426
+ const current = store.getState().statesByGameId[gameId];
3427
+ if (!isNonRpsState(current)) return;
3428
+ const updated = {
3429
+ ...current,
3430
+ fen,
3431
+ turn,
3432
+ currentPlayerId,
3433
+ status,
3434
+ ...winnerId != null && { winnerId }
3435
+ };
3436
+ updateState(gameId, updated);
3437
+ break;
3438
+ }
3365
3439
  case "game:state": {
3366
3440
  const gameId = event.payload.gameId ?? event.payload.state.gameId;
3367
3441
  if (!gameId) return;
@@ -3839,6 +3913,7 @@ var WS_EVENT_NAMES = [
3839
3913
  "lobby:queue:joined",
3840
3914
  "lobby:queue:cancelled",
3841
3915
  "lobby:matched",
3916
+ "lobby:deposit:updated",
3842
3917
  "lobby:typing:start",
3843
3918
  "lobby:typing:stop",
3844
3919
  "game:updated",
@@ -3915,6 +3990,11 @@ function decodeWsEvent(eventName, payload) {
3915
3990
  event: "lobby:matched",
3916
3991
  payload
3917
3992
  };
3993
+ case "lobby:deposit:updated":
3994
+ return {
3995
+ event: "lobby:deposit:updated",
3996
+ payload
3997
+ };
3918
3998
  case "lobby:typing:start":
3919
3999
  case "lobby:typing:stop":
3920
4000
  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.28",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",