@dimcool/sdk 0.1.28 → 0.1.30
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 +62 -7
- package/dist/index.cjs +430 -109
- package/dist/index.d.cts +610 -447
- package/dist/index.d.ts +610 -447
- package/dist/index.js +429 -109
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -376,6 +376,61 @@ Check if a user is a friend. Note: This is a helper method that may require addi
|
|
|
376
376
|
const isFriend = await sdk.users.isFriend('user-id');
|
|
377
377
|
```
|
|
378
378
|
|
|
379
|
+
#### `getIncomingFriendRequests(opts?: { limit?: number; cursor?: string }): Promise<PaginatedFriendRequests>`
|
|
380
|
+
|
|
381
|
+
List pending incoming friend requests for the authenticated user. Returns cursor-based pages of up to 100 items.
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
// First page (default limit 50)
|
|
385
|
+
const page1 = await sdk.users.getIncomingFriendRequests();
|
|
386
|
+
// page1: { items: FriendRequestItem[], nextCursor?: string }
|
|
387
|
+
|
|
388
|
+
// Next page
|
|
389
|
+
if (page1.nextCursor) {
|
|
390
|
+
const page2 = await sdk.users.getIncomingFriendRequests({
|
|
391
|
+
cursor: page1.nextCursor,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Custom page size
|
|
396
|
+
const small = await sdk.users.getIncomingFriendRequests({ limit: 10 });
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Each `FriendRequestItem` has the shape `{ id, user: PublicUser, mutualFriendsCount, createdAt }`.
|
|
400
|
+
|
|
401
|
+
#### `getOutgoingFriendRequests(opts?: { limit?: number; cursor?: string }): Promise<PaginatedFriendRequests>`
|
|
402
|
+
|
|
403
|
+
List pending outgoing friend requests sent by the authenticated user. Same pagination shape as `getIncomingFriendRequests`.
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
const page1 = await sdk.users.getOutgoingFriendRequests({ limit: 20 });
|
|
407
|
+
// page1: { items: FriendRequestItem[], nextCursor?: string }
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
#### `acceptFriendRequest(userId: string): Promise<{ message: string }>`
|
|
411
|
+
|
|
412
|
+
Accept a pending incoming friend request.
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
await sdk.users.acceptFriendRequest('user-id');
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
#### `declineFriendRequest(userId: string): Promise<{ message: string }>`
|
|
419
|
+
|
|
420
|
+
Decline a pending incoming friend request.
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
await sdk.users.declineFriendRequest('user-id');
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
#### `cancelFriendRequest(userId: string): Promise<{ message: string }>`
|
|
427
|
+
|
|
428
|
+
Cancel a pending outgoing friend request.
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
await sdk.users.cancelFriendRequest('user-id');
|
|
432
|
+
```
|
|
433
|
+
|
|
379
434
|
### Profile Management
|
|
380
435
|
|
|
381
436
|
#### `updateProfile(data: { name?: string, bio?: string, username?: string }): Promise<User>`
|
|
@@ -1289,11 +1344,11 @@ const signedTx = await sdk.wallet.signTransaction(unsignedTx);
|
|
|
1289
1344
|
|
|
1290
1345
|
### `depositForLobbySync(lobbyId: string): Promise<DepositForLobbyResponse>`
|
|
1291
1346
|
|
|
1292
|
-
|
|
1347
|
+
Agent-optimised deposit: prepare, sign, submit, then poll until **the calling user's own deposit** is confirmed. Returns as soon as your deposit is on-chain without waiting for the other player. The server auto-joins the matchmaking queue when all players have deposited.
|
|
1293
1348
|
|
|
1294
1349
|
```typescript
|
|
1295
1350
|
const result = await sdk.escrow.depositForLobbySync(lobbyId);
|
|
1296
|
-
// result: { signature: string, status: 'confirmed', canProceedToQueue:
|
|
1351
|
+
// result: { signature: string, status: 'confirmed', canProceedToQueue: boolean }
|
|
1297
1352
|
```
|
|
1298
1353
|
|
|
1299
1354
|
**Parameters:**
|
|
@@ -1302,15 +1357,15 @@ const result = await sdk.escrow.depositForLobbySync(lobbyId);
|
|
|
1302
1357
|
|
|
1303
1358
|
**Returns:**
|
|
1304
1359
|
|
|
1305
|
-
- `Promise<DepositForLobbyResponse>` - The deposit result
|
|
1360
|
+
- `Promise<DepositForLobbyResponse>` - The deposit result. `canProceedToQueue` is `true` only if all players have deposited by the time your deposit confirms.
|
|
1306
1361
|
|
|
1307
1362
|
**Behavior:**
|
|
1308
1363
|
|
|
1309
1364
|
1. Calls `prepareAndStartDeposit` to prepare the unsigned transaction (1 HTTP call)
|
|
1310
|
-
2. Signs
|
|
1311
|
-
3.
|
|
1365
|
+
2. Signs and submits the transaction (1 HTTP call)
|
|
1366
|
+
3. Polls `GET /escrow/lobby/:id/deposit/status` every second until the signature appears as confirmed (up to 60 seconds)
|
|
1312
1367
|
|
|
1313
|
-
**Note:** Requires `sdk.wallet.setSigner()` to be configured.
|
|
1368
|
+
**Note:** Requires `sdk.wallet.setSigner()` to be configured. Use `depositForLobby()` if you need to wait for all players before proceeding.
|
|
1314
1369
|
|
|
1315
1370
|
### `submitDeposit(lobbyId: string, signedTransaction: string): Promise<SubmitDepositResponse>`
|
|
1316
1371
|
|
|
@@ -1713,7 +1768,7 @@ const { lobby, unsignedTransaction } = await sdk.lobbies.playAgain(
|
|
|
1713
1768
|
sdk.escrow,
|
|
1714
1769
|
);
|
|
1715
1770
|
|
|
1716
|
-
// Deposit
|
|
1771
|
+
// Deposit and wait for your own deposit to confirm (polls status endpoint)
|
|
1717
1772
|
const result = await sdk.escrow.depositForLobbySync(lobby.id);
|
|
1718
1773
|
```
|
|
1719
1774
|
|