@dubsdotapp/expo 0.2.32 → 0.2.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubsdotapp/expo",
3
- "version": "0.2.32",
3
+ "version": "0.2.33",
4
4
  "description": "React Native SDK for the Dubs betting platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/client.ts CHANGED
@@ -15,6 +15,8 @@ import type {
15
15
  ConfirmGameResult,
16
16
  BuildClaimParams,
17
17
  BuildClaimResult,
18
+ ConfirmClaimParams,
19
+ ConfirmClaimResult,
18
20
  GameDetail,
19
21
  GameListItem,
20
22
  GetGamesParams,
@@ -245,6 +247,20 @@ export class DubsClient {
245
247
  };
246
248
  }
247
249
 
250
+ async confirmClaim(gameId: string, params: ConfirmClaimParams): Promise<ConfirmClaimResult> {
251
+ const res = await this.request<{ success: true } & ConfirmClaimResult>(
252
+ 'POST',
253
+ `/games/${encodeURIComponent(gameId)}/claim/confirm`,
254
+ params,
255
+ );
256
+ return {
257
+ gameId: res.gameId,
258
+ signature: res.signature,
259
+ explorerUrl: res.explorerUrl,
260
+ message: res.message,
261
+ };
262
+ }
263
+
248
264
  // ── Game Queries ──
249
265
 
250
266
  async getGame(gameId: string): Promise<GameDetail> {
@@ -21,7 +21,7 @@ export function useClaim() {
21
21
  setData(null);
22
22
  }, []);
23
23
 
24
- const execute = useCallback(async (params: BuildClaimParams): Promise<ClaimMutationResult> => {
24
+ const execute = useCallback(async (params: BuildClaimParams & { amountClaimed?: number }): Promise<ClaimMutationResult> => {
25
25
  setStatus('building');
26
26
  setError(null);
27
27
  setData(null);
@@ -42,12 +42,20 @@ export function useClaim() {
42
42
  );
43
43
  console.log('[useClaim] Step 2 done. Signature:', signature);
44
44
 
45
- // Claims don't need backend confirmation the on-chain tx is the claim
46
- const explorerUrl = `https://solscan.io/tx/${signature}`;
45
+ // 3. Confirm claim with backend (records signature + amount in DB)
46
+ setStatus('confirming');
47
+ console.log('[useClaim] Step 3: Confirming claim...');
48
+ const confirmResult = await client.confirmClaim(params.gameId, {
49
+ playerWallet: params.playerWallet,
50
+ signature,
51
+ amountClaimed: params.amountClaimed,
52
+ });
53
+ console.log('[useClaim] Step 3 done.');
54
+
47
55
  const result: ClaimMutationResult = {
48
56
  gameId: params.gameId,
49
57
  signature,
50
- explorerUrl,
58
+ explorerUrl: confirmResult.explorerUrl,
51
59
  };
52
60
 
53
61
  setData(result);
package/src/index.ts CHANGED
@@ -31,6 +31,8 @@ export type {
31
31
  ConfirmGameResult,
32
32
  BuildClaimParams,
33
33
  BuildClaimResult,
34
+ ConfirmClaimParams,
35
+ ConfirmClaimResult,
34
36
  Bettor,
35
37
  GameDetail,
36
38
  GameMedia,
package/src/types.ts CHANGED
@@ -170,6 +170,21 @@ export interface BuildClaimResult {
170
170
  message: string;
171
171
  }
172
172
 
173
+ // ── Confirm Claim ──
174
+
175
+ export interface ConfirmClaimParams {
176
+ playerWallet: string;
177
+ signature: string;
178
+ amountClaimed?: number;
179
+ }
180
+
181
+ export interface ConfirmClaimResult {
182
+ gameId: string;
183
+ signature: string;
184
+ explorerUrl: string;
185
+ message: string;
186
+ }
187
+
173
188
  // ── Game Detail (returned by /games/:gameId) ──
174
189
 
175
190
  export interface GameMedia {
@@ -29,6 +29,7 @@ export interface ClaimPrizeSheetProps {
29
29
  const STATUS_LABELS: Record<string, string> = {
30
30
  building: 'Building transaction...',
31
31
  signing: 'Approve in wallet...',
32
+ confirming: 'Confirming...',
32
33
  success: 'Claimed!',
33
34
  };
34
35
 
@@ -113,11 +114,12 @@ export function ClaimPrizeSheet({
113
114
  await mutation.execute({
114
115
  playerWallet: wallet.publicKey.toBase58(),
115
116
  gameId,
117
+ amountClaimed: prizeAmount,
116
118
  });
117
119
  } catch {
118
120
  // Error is already captured in mutation state
119
121
  }
120
- }, [wallet.publicKey, mutation.execute, gameId]); // eslint-disable-line react-hooks/exhaustive-deps
122
+ }, [wallet.publicKey, mutation.execute, gameId, prizeAmount]); // eslint-disable-line react-hooks/exhaustive-deps
121
123
 
122
124
  const statusLabel = STATUS_LABELS[mutation.status] || '';
123
125