@dubsdotapp/expo 0.2.31 → 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/dist/index.d.mts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +325 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +334 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +16 -0
- package/src/hooks/useClaim.ts +12 -4
- package/src/index.ts +4 -1
- package/src/types.ts +15 -0
- package/src/ui/game/ClaimPrizeSheet.tsx +367 -0
- package/src/ui/game/index.ts +2 -0
- package/src/ui/index.ts +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -160,6 +160,17 @@ interface BuildClaimResult {
|
|
|
160
160
|
gameAddress: string;
|
|
161
161
|
message: string;
|
|
162
162
|
}
|
|
163
|
+
interface ConfirmClaimParams {
|
|
164
|
+
playerWallet: string;
|
|
165
|
+
signature: string;
|
|
166
|
+
amountClaimed?: number;
|
|
167
|
+
}
|
|
168
|
+
interface ConfirmClaimResult {
|
|
169
|
+
gameId: string;
|
|
170
|
+
signature: string;
|
|
171
|
+
explorerUrl: string;
|
|
172
|
+
message: string;
|
|
173
|
+
}
|
|
163
174
|
interface GameMedia {
|
|
164
175
|
poster: string | null;
|
|
165
176
|
thumbnail: string | null;
|
|
@@ -361,6 +372,7 @@ declare class DubsClient {
|
|
|
361
372
|
createCustomGame(params: CreateCustomGameParams): Promise<CreateCustomGameResult>;
|
|
362
373
|
confirmCustomGame(params: ConfirmGameParams): Promise<ConfirmGameResult>;
|
|
363
374
|
buildClaimTransaction(params: BuildClaimParams): Promise<BuildClaimResult>;
|
|
375
|
+
confirmClaim(gameId: string, params: ConfirmClaimParams): Promise<ConfirmClaimResult>;
|
|
364
376
|
getGame(gameId: string): Promise<GameDetail>;
|
|
365
377
|
getLiveScore(gameId: string): Promise<LiveScore | null>;
|
|
366
378
|
getGames(params?: GetGamesParams): Promise<GameListItem[]>;
|
|
@@ -720,7 +732,9 @@ interface ClaimMutationResult {
|
|
|
720
732
|
explorerUrl: string;
|
|
721
733
|
}
|
|
722
734
|
declare function useClaim(): {
|
|
723
|
-
execute: (params: BuildClaimParams
|
|
735
|
+
execute: (params: BuildClaimParams & {
|
|
736
|
+
amountClaimed?: number;
|
|
737
|
+
}) => Promise<ClaimMutationResult>;
|
|
724
738
|
status: MutationStatus;
|
|
725
739
|
error: Error | null;
|
|
726
740
|
data: ClaimMutationResult | null;
|
|
@@ -919,6 +933,18 @@ interface JoinGameSheetProps {
|
|
|
919
933
|
}
|
|
920
934
|
declare function JoinGameSheet({ visible, onDismiss, game, ImageComponent, shortName, homeColor, awayColor, onSuccess, onError, }: JoinGameSheetProps): react_jsx_runtime.JSX.Element;
|
|
921
935
|
|
|
936
|
+
interface ClaimPrizeSheetProps {
|
|
937
|
+
visible: boolean;
|
|
938
|
+
onDismiss: () => void;
|
|
939
|
+
gameId: string;
|
|
940
|
+
/** Prize amount in SOL */
|
|
941
|
+
prizeAmount: number;
|
|
942
|
+
/** Callbacks */
|
|
943
|
+
onSuccess?: (result: ClaimMutationResult) => void;
|
|
944
|
+
onError?: (error: Error) => void;
|
|
945
|
+
}
|
|
946
|
+
declare function ClaimPrizeSheet({ visible, onDismiss, gameId, prizeAmount, onSuccess, onError, }: ClaimPrizeSheetProps): react_jsx_runtime.JSX.Element;
|
|
947
|
+
|
|
922
948
|
/**
|
|
923
949
|
* Deserialize a base64-encoded transaction, sign via wallet adapter, send to Solana.
|
|
924
950
|
* Prefers signAndSendTransaction if available (MWA), otherwise falls back to
|
|
@@ -927,4 +953,4 @@ declare function JoinGameSheet({ visible, onDismiss, game, ImageComponent, short
|
|
|
927
953
|
*/
|
|
928
954
|
declare function signAndSendBase64Transaction(base64Tx: string, wallet: WalletAdapter, connection: Connection): Promise<string>;
|
|
929
955
|
|
|
930
|
-
export { AuthGate, type AuthGateProps, type AuthStatus, type AuthenticateParams, type AuthenticateResult, type Bettor, type BuildClaimParams, type BuildClaimResult, type CheckUsernameResult, type ClaimMutationResult, type ConfirmGameParams, type ConfirmGameResult, ConnectWalletScreen, type ConnectWalletScreenProps, type CreateCustomGameMutationResult, type CreateCustomGameParams, type CreateCustomGameResult, CreateCustomGameSheet, type CreateCustomGameSheetProps, type CreateGameMutationResult, type CreateGameParams, type CreateGameResult, DEFAULT_BASE_URL, DEFAULT_RPC_URL, type DeviceInfo, DubsApiError, type DubsAppUser, DubsClient, type DubsClientConfig, type DubsContextValue, type DubsNetwork, DubsProvider, type DubsProviderProps, type DubsPublicUser, type DubsTheme, type DubsUser, type EsportsMatchDetail, type EsportsMatchOpponent, type EsportsMatchResult, type EventMedia, type EventMeta, type EventStream, type GameDetail, type GameListItem, type GameListOpponent, type GameMedia, GamePoster, type GamePosterProps, type GetGamesParams, type GetNetworkGamesParams, type GetUpcomingEventsParams, JoinGameButton, type JoinGameButtonProps, type JoinGameMutationResult, type JoinGameParams, type JoinGameResult, JoinGameSheet, type JoinGameSheetProps, LivePoolsCard, type LivePoolsCardProps, type LiveScore, type LiveScoreCompetitor, type MutationResult, type MutationStatus, type MwaAdapterConfig, type MwaTransactFn, MwaWalletAdapter, NETWORK_CONFIG, type NonceResult, type Opponent, type Pagination, type ParsedError, PhantomDeeplinkAdapter, type PhantomDeeplinkAdapterConfig, type PhantomSession, PickWinnerCard, type PickWinnerCardProps, PlayersCard, type PlayersCardProps, type QueryResult, type RegisterParams, type RegisterResult, type RegistrationScreenProps, SOLANA_PROGRAM_ERRORS, STORAGE_KEYS, SettingsSheet, type SettingsSheetProps, type SolanaErrorCode, type TokenStorage, type UiConfig, type UnifiedEvent, type UseAuthResult, UserProfileCard, type UserProfileCardProps, type ValidateEventResult, type WalletAdapter, createSecureStoreStorage, getDeviceInfo, isSolanaSeeker, mergeTheme, parseSolanaError, signAndSendBase64Transaction, useAppConfig, useAuth, useClaim, useCreateCustomGame, useCreateGame, useDubs, useDubsTheme, useEvents, useGame, useGames, useJoinGame, useNetworkGames };
|
|
956
|
+
export { AuthGate, type AuthGateProps, type AuthStatus, type AuthenticateParams, type AuthenticateResult, type Bettor, type BuildClaimParams, type BuildClaimResult, type CheckUsernameResult, type ClaimMutationResult, ClaimPrizeSheet, type ClaimPrizeSheetProps, type ConfirmClaimParams, type ConfirmClaimResult, type ConfirmGameParams, type ConfirmGameResult, ConnectWalletScreen, type ConnectWalletScreenProps, type CreateCustomGameMutationResult, type CreateCustomGameParams, type CreateCustomGameResult, CreateCustomGameSheet, type CreateCustomGameSheetProps, type CreateGameMutationResult, type CreateGameParams, type CreateGameResult, DEFAULT_BASE_URL, DEFAULT_RPC_URL, type DeviceInfo, DubsApiError, type DubsAppUser, DubsClient, type DubsClientConfig, type DubsContextValue, type DubsNetwork, DubsProvider, type DubsProviderProps, type DubsPublicUser, type DubsTheme, type DubsUser, type EsportsMatchDetail, type EsportsMatchOpponent, type EsportsMatchResult, type EventMedia, type EventMeta, type EventStream, type GameDetail, type GameListItem, type GameListOpponent, type GameMedia, GamePoster, type GamePosterProps, type GetGamesParams, type GetNetworkGamesParams, type GetUpcomingEventsParams, JoinGameButton, type JoinGameButtonProps, type JoinGameMutationResult, type JoinGameParams, type JoinGameResult, JoinGameSheet, type JoinGameSheetProps, LivePoolsCard, type LivePoolsCardProps, type LiveScore, type LiveScoreCompetitor, type MutationResult, type MutationStatus, type MwaAdapterConfig, type MwaTransactFn, MwaWalletAdapter, NETWORK_CONFIG, type NonceResult, type Opponent, type Pagination, type ParsedError, PhantomDeeplinkAdapter, type PhantomDeeplinkAdapterConfig, type PhantomSession, PickWinnerCard, type PickWinnerCardProps, PlayersCard, type PlayersCardProps, type QueryResult, type RegisterParams, type RegisterResult, type RegistrationScreenProps, SOLANA_PROGRAM_ERRORS, STORAGE_KEYS, SettingsSheet, type SettingsSheetProps, type SolanaErrorCode, type TokenStorage, type UiConfig, type UnifiedEvent, type UseAuthResult, UserProfileCard, type UserProfileCardProps, type ValidateEventResult, type WalletAdapter, createSecureStoreStorage, getDeviceInfo, isSolanaSeeker, mergeTheme, parseSolanaError, signAndSendBase64Transaction, useAppConfig, useAuth, useClaim, useCreateCustomGame, useCreateGame, useDubs, useDubsTheme, useEvents, useGame, useGames, useJoinGame, useNetworkGames };
|
package/dist/index.d.ts
CHANGED
|
@@ -160,6 +160,17 @@ interface BuildClaimResult {
|
|
|
160
160
|
gameAddress: string;
|
|
161
161
|
message: string;
|
|
162
162
|
}
|
|
163
|
+
interface ConfirmClaimParams {
|
|
164
|
+
playerWallet: string;
|
|
165
|
+
signature: string;
|
|
166
|
+
amountClaimed?: number;
|
|
167
|
+
}
|
|
168
|
+
interface ConfirmClaimResult {
|
|
169
|
+
gameId: string;
|
|
170
|
+
signature: string;
|
|
171
|
+
explorerUrl: string;
|
|
172
|
+
message: string;
|
|
173
|
+
}
|
|
163
174
|
interface GameMedia {
|
|
164
175
|
poster: string | null;
|
|
165
176
|
thumbnail: string | null;
|
|
@@ -361,6 +372,7 @@ declare class DubsClient {
|
|
|
361
372
|
createCustomGame(params: CreateCustomGameParams): Promise<CreateCustomGameResult>;
|
|
362
373
|
confirmCustomGame(params: ConfirmGameParams): Promise<ConfirmGameResult>;
|
|
363
374
|
buildClaimTransaction(params: BuildClaimParams): Promise<BuildClaimResult>;
|
|
375
|
+
confirmClaim(gameId: string, params: ConfirmClaimParams): Promise<ConfirmClaimResult>;
|
|
364
376
|
getGame(gameId: string): Promise<GameDetail>;
|
|
365
377
|
getLiveScore(gameId: string): Promise<LiveScore | null>;
|
|
366
378
|
getGames(params?: GetGamesParams): Promise<GameListItem[]>;
|
|
@@ -720,7 +732,9 @@ interface ClaimMutationResult {
|
|
|
720
732
|
explorerUrl: string;
|
|
721
733
|
}
|
|
722
734
|
declare function useClaim(): {
|
|
723
|
-
execute: (params: BuildClaimParams
|
|
735
|
+
execute: (params: BuildClaimParams & {
|
|
736
|
+
amountClaimed?: number;
|
|
737
|
+
}) => Promise<ClaimMutationResult>;
|
|
724
738
|
status: MutationStatus;
|
|
725
739
|
error: Error | null;
|
|
726
740
|
data: ClaimMutationResult | null;
|
|
@@ -919,6 +933,18 @@ interface JoinGameSheetProps {
|
|
|
919
933
|
}
|
|
920
934
|
declare function JoinGameSheet({ visible, onDismiss, game, ImageComponent, shortName, homeColor, awayColor, onSuccess, onError, }: JoinGameSheetProps): react_jsx_runtime.JSX.Element;
|
|
921
935
|
|
|
936
|
+
interface ClaimPrizeSheetProps {
|
|
937
|
+
visible: boolean;
|
|
938
|
+
onDismiss: () => void;
|
|
939
|
+
gameId: string;
|
|
940
|
+
/** Prize amount in SOL */
|
|
941
|
+
prizeAmount: number;
|
|
942
|
+
/** Callbacks */
|
|
943
|
+
onSuccess?: (result: ClaimMutationResult) => void;
|
|
944
|
+
onError?: (error: Error) => void;
|
|
945
|
+
}
|
|
946
|
+
declare function ClaimPrizeSheet({ visible, onDismiss, gameId, prizeAmount, onSuccess, onError, }: ClaimPrizeSheetProps): react_jsx_runtime.JSX.Element;
|
|
947
|
+
|
|
922
948
|
/**
|
|
923
949
|
* Deserialize a base64-encoded transaction, sign via wallet adapter, send to Solana.
|
|
924
950
|
* Prefers signAndSendTransaction if available (MWA), otherwise falls back to
|
|
@@ -927,4 +953,4 @@ declare function JoinGameSheet({ visible, onDismiss, game, ImageComponent, short
|
|
|
927
953
|
*/
|
|
928
954
|
declare function signAndSendBase64Transaction(base64Tx: string, wallet: WalletAdapter, connection: Connection): Promise<string>;
|
|
929
955
|
|
|
930
|
-
export { AuthGate, type AuthGateProps, type AuthStatus, type AuthenticateParams, type AuthenticateResult, type Bettor, type BuildClaimParams, type BuildClaimResult, type CheckUsernameResult, type ClaimMutationResult, type ConfirmGameParams, type ConfirmGameResult, ConnectWalletScreen, type ConnectWalletScreenProps, type CreateCustomGameMutationResult, type CreateCustomGameParams, type CreateCustomGameResult, CreateCustomGameSheet, type CreateCustomGameSheetProps, type CreateGameMutationResult, type CreateGameParams, type CreateGameResult, DEFAULT_BASE_URL, DEFAULT_RPC_URL, type DeviceInfo, DubsApiError, type DubsAppUser, DubsClient, type DubsClientConfig, type DubsContextValue, type DubsNetwork, DubsProvider, type DubsProviderProps, type DubsPublicUser, type DubsTheme, type DubsUser, type EsportsMatchDetail, type EsportsMatchOpponent, type EsportsMatchResult, type EventMedia, type EventMeta, type EventStream, type GameDetail, type GameListItem, type GameListOpponent, type GameMedia, GamePoster, type GamePosterProps, type GetGamesParams, type GetNetworkGamesParams, type GetUpcomingEventsParams, JoinGameButton, type JoinGameButtonProps, type JoinGameMutationResult, type JoinGameParams, type JoinGameResult, JoinGameSheet, type JoinGameSheetProps, LivePoolsCard, type LivePoolsCardProps, type LiveScore, type LiveScoreCompetitor, type MutationResult, type MutationStatus, type MwaAdapterConfig, type MwaTransactFn, MwaWalletAdapter, NETWORK_CONFIG, type NonceResult, type Opponent, type Pagination, type ParsedError, PhantomDeeplinkAdapter, type PhantomDeeplinkAdapterConfig, type PhantomSession, PickWinnerCard, type PickWinnerCardProps, PlayersCard, type PlayersCardProps, type QueryResult, type RegisterParams, type RegisterResult, type RegistrationScreenProps, SOLANA_PROGRAM_ERRORS, STORAGE_KEYS, SettingsSheet, type SettingsSheetProps, type SolanaErrorCode, type TokenStorage, type UiConfig, type UnifiedEvent, type UseAuthResult, UserProfileCard, type UserProfileCardProps, type ValidateEventResult, type WalletAdapter, createSecureStoreStorage, getDeviceInfo, isSolanaSeeker, mergeTheme, parseSolanaError, signAndSendBase64Transaction, useAppConfig, useAuth, useClaim, useCreateCustomGame, useCreateGame, useDubs, useDubsTheme, useEvents, useGame, useGames, useJoinGame, useNetworkGames };
|
|
956
|
+
export { AuthGate, type AuthGateProps, type AuthStatus, type AuthenticateParams, type AuthenticateResult, type Bettor, type BuildClaimParams, type BuildClaimResult, type CheckUsernameResult, type ClaimMutationResult, ClaimPrizeSheet, type ClaimPrizeSheetProps, type ConfirmClaimParams, type ConfirmClaimResult, type ConfirmGameParams, type ConfirmGameResult, ConnectWalletScreen, type ConnectWalletScreenProps, type CreateCustomGameMutationResult, type CreateCustomGameParams, type CreateCustomGameResult, CreateCustomGameSheet, type CreateCustomGameSheetProps, type CreateGameMutationResult, type CreateGameParams, type CreateGameResult, DEFAULT_BASE_URL, DEFAULT_RPC_URL, type DeviceInfo, DubsApiError, type DubsAppUser, DubsClient, type DubsClientConfig, type DubsContextValue, type DubsNetwork, DubsProvider, type DubsProviderProps, type DubsPublicUser, type DubsTheme, type DubsUser, type EsportsMatchDetail, type EsportsMatchOpponent, type EsportsMatchResult, type EventMedia, type EventMeta, type EventStream, type GameDetail, type GameListItem, type GameListOpponent, type GameMedia, GamePoster, type GamePosterProps, type GetGamesParams, type GetNetworkGamesParams, type GetUpcomingEventsParams, JoinGameButton, type JoinGameButtonProps, type JoinGameMutationResult, type JoinGameParams, type JoinGameResult, JoinGameSheet, type JoinGameSheetProps, LivePoolsCard, type LivePoolsCardProps, type LiveScore, type LiveScoreCompetitor, type MutationResult, type MutationStatus, type MwaAdapterConfig, type MwaTransactFn, MwaWalletAdapter, NETWORK_CONFIG, type NonceResult, type Opponent, type Pagination, type ParsedError, PhantomDeeplinkAdapter, type PhantomDeeplinkAdapterConfig, type PhantomSession, PickWinnerCard, type PickWinnerCardProps, PlayersCard, type PlayersCardProps, type QueryResult, type RegisterParams, type RegisterResult, type RegistrationScreenProps, SOLANA_PROGRAM_ERRORS, STORAGE_KEYS, SettingsSheet, type SettingsSheetProps, type SolanaErrorCode, type TokenStorage, type UiConfig, type UnifiedEvent, type UseAuthResult, UserProfileCard, type UserProfileCardProps, type ValidateEventResult, type WalletAdapter, createSecureStoreStorage, getDeviceInfo, isSolanaSeeker, mergeTheme, parseSolanaError, signAndSendBase64Transaction, useAppConfig, useAuth, useClaim, useCreateCustomGame, useCreateGame, useDubs, useDubsTheme, useEvents, useGame, useGames, useJoinGame, useNetworkGames };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
AuthGate: () => AuthGate,
|
|
34
|
+
ClaimPrizeSheet: () => ClaimPrizeSheet,
|
|
34
35
|
ConnectWalletScreen: () => ConnectWalletScreen,
|
|
35
36
|
CreateCustomGameSheet: () => CreateCustomGameSheet,
|
|
36
37
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
@@ -372,6 +373,19 @@ var DubsClient = class {
|
|
|
372
373
|
message: res.message
|
|
373
374
|
};
|
|
374
375
|
}
|
|
376
|
+
async confirmClaim(gameId, params) {
|
|
377
|
+
const res = await this.request(
|
|
378
|
+
"POST",
|
|
379
|
+
`/games/${encodeURIComponent(gameId)}/claim/confirm`,
|
|
380
|
+
params
|
|
381
|
+
);
|
|
382
|
+
return {
|
|
383
|
+
gameId: res.gameId,
|
|
384
|
+
signature: res.signature,
|
|
385
|
+
explorerUrl: res.explorerUrl,
|
|
386
|
+
message: res.message
|
|
387
|
+
};
|
|
388
|
+
}
|
|
375
389
|
// ── Game Queries ──
|
|
376
390
|
async getGame(gameId) {
|
|
377
391
|
const res = await this.request(
|
|
@@ -1845,11 +1859,18 @@ function useClaim() {
|
|
|
1845
1859
|
connection
|
|
1846
1860
|
);
|
|
1847
1861
|
console.log("[useClaim] Step 2 done. Signature:", signature);
|
|
1848
|
-
|
|
1862
|
+
setStatus("confirming");
|
|
1863
|
+
console.log("[useClaim] Step 3: Confirming claim...");
|
|
1864
|
+
const confirmResult = await client.confirmClaim(params.gameId, {
|
|
1865
|
+
playerWallet: params.playerWallet,
|
|
1866
|
+
signature,
|
|
1867
|
+
amountClaimed: params.amountClaimed
|
|
1868
|
+
});
|
|
1869
|
+
console.log("[useClaim] Step 3 done.");
|
|
1849
1870
|
const result = {
|
|
1850
1871
|
gameId: params.gameId,
|
|
1851
1872
|
signature,
|
|
1852
|
-
explorerUrl
|
|
1873
|
+
explorerUrl: confirmResult.explorerUrl
|
|
1853
1874
|
};
|
|
1854
1875
|
setData(result);
|
|
1855
1876
|
setStatus("success");
|
|
@@ -4211,9 +4232,311 @@ var styles10 = import_react_native15.StyleSheet.create({
|
|
|
4211
4232
|
fontWeight: "700"
|
|
4212
4233
|
}
|
|
4213
4234
|
});
|
|
4235
|
+
|
|
4236
|
+
// src/ui/game/ClaimPrizeSheet.tsx
|
|
4237
|
+
var import_react22 = require("react");
|
|
4238
|
+
var import_react_native16 = require("react-native");
|
|
4239
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4240
|
+
var STATUS_LABELS4 = {
|
|
4241
|
+
building: "Building transaction...",
|
|
4242
|
+
signing: "Approve in wallet...",
|
|
4243
|
+
confirming: "Confirming...",
|
|
4244
|
+
success: "Claimed!"
|
|
4245
|
+
};
|
|
4246
|
+
function ClaimPrizeSheet({
|
|
4247
|
+
visible,
|
|
4248
|
+
onDismiss,
|
|
4249
|
+
gameId,
|
|
4250
|
+
prizeAmount,
|
|
4251
|
+
onSuccess,
|
|
4252
|
+
onError
|
|
4253
|
+
}) {
|
|
4254
|
+
const t = useDubsTheme();
|
|
4255
|
+
const { wallet } = useDubs();
|
|
4256
|
+
const mutation = useClaim();
|
|
4257
|
+
const overlayOpacity = (0, import_react22.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4258
|
+
const celebrationScale = (0, import_react22.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4259
|
+
const celebrationOpacity = (0, import_react22.useRef)(new import_react_native16.Animated.Value(0)).current;
|
|
4260
|
+
const [showCelebration, setShowCelebration] = (0, import_react22.useState)(false);
|
|
4261
|
+
(0, import_react22.useEffect)(() => {
|
|
4262
|
+
import_react_native16.Animated.timing(overlayOpacity, {
|
|
4263
|
+
toValue: visible ? 1 : 0,
|
|
4264
|
+
duration: 250,
|
|
4265
|
+
useNativeDriver: true
|
|
4266
|
+
}).start();
|
|
4267
|
+
}, [visible, overlayOpacity]);
|
|
4268
|
+
(0, import_react22.useEffect)(() => {
|
|
4269
|
+
if (visible) {
|
|
4270
|
+
mutation.reset();
|
|
4271
|
+
setShowCelebration(false);
|
|
4272
|
+
celebrationScale.setValue(0);
|
|
4273
|
+
celebrationOpacity.setValue(0);
|
|
4274
|
+
}
|
|
4275
|
+
}, [visible]);
|
|
4276
|
+
(0, import_react22.useEffect)(() => {
|
|
4277
|
+
if (mutation.status === "success" && mutation.data) {
|
|
4278
|
+
setShowCelebration(true);
|
|
4279
|
+
import_react_native16.Animated.parallel([
|
|
4280
|
+
import_react_native16.Animated.spring(celebrationScale, {
|
|
4281
|
+
toValue: 1,
|
|
4282
|
+
tension: 50,
|
|
4283
|
+
friction: 6,
|
|
4284
|
+
useNativeDriver: true
|
|
4285
|
+
}),
|
|
4286
|
+
import_react_native16.Animated.timing(celebrationOpacity, {
|
|
4287
|
+
toValue: 1,
|
|
4288
|
+
duration: 300,
|
|
4289
|
+
useNativeDriver: true
|
|
4290
|
+
})
|
|
4291
|
+
]).start();
|
|
4292
|
+
onSuccess?.(mutation.data);
|
|
4293
|
+
const timer = setTimeout(() => {
|
|
4294
|
+
onDismiss();
|
|
4295
|
+
}, 2500);
|
|
4296
|
+
return () => clearTimeout(timer);
|
|
4297
|
+
}
|
|
4298
|
+
}, [mutation.status, mutation.data]);
|
|
4299
|
+
(0, import_react22.useEffect)(() => {
|
|
4300
|
+
if (mutation.status === "error" && mutation.error) {
|
|
4301
|
+
onError?.(mutation.error);
|
|
4302
|
+
}
|
|
4303
|
+
}, [mutation.status, mutation.error]);
|
|
4304
|
+
const isMutating = mutation.status !== "idle" && mutation.status !== "success" && mutation.status !== "error";
|
|
4305
|
+
const canClaim = !isMutating && mutation.status !== "success" && !!wallet.publicKey;
|
|
4306
|
+
const handleClaim = (0, import_react22.useCallback)(async () => {
|
|
4307
|
+
if (!wallet.publicKey) return;
|
|
4308
|
+
try {
|
|
4309
|
+
await mutation.execute({
|
|
4310
|
+
playerWallet: wallet.publicKey.toBase58(),
|
|
4311
|
+
gameId,
|
|
4312
|
+
amountClaimed: prizeAmount
|
|
4313
|
+
});
|
|
4314
|
+
} catch {
|
|
4315
|
+
}
|
|
4316
|
+
}, [wallet.publicKey, mutation.execute, gameId, prizeAmount]);
|
|
4317
|
+
const statusLabel = STATUS_LABELS4[mutation.status] || "";
|
|
4318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
4319
|
+
import_react_native16.Modal,
|
|
4320
|
+
{
|
|
4321
|
+
visible,
|
|
4322
|
+
animationType: "slide",
|
|
4323
|
+
transparent: true,
|
|
4324
|
+
onRequestClose: onDismiss,
|
|
4325
|
+
children: [
|
|
4326
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Animated.View, { style: [styles11.overlay, { opacity: overlayOpacity }], children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.TouchableOpacity, { style: styles11.overlayTap, activeOpacity: 1, onPress: onDismiss }) }),
|
|
4327
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4328
|
+
import_react_native16.KeyboardAvoidingView,
|
|
4329
|
+
{
|
|
4330
|
+
style: styles11.keyboardView,
|
|
4331
|
+
behavior: import_react_native16.Platform.OS === "ios" ? "padding" : void 0,
|
|
4332
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.View, { style: styles11.sheetPositioner, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.View, { style: [styles11.sheet, { backgroundColor: t.background }], children: [
|
|
4333
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.View, { style: styles11.handleRow, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.View, { style: [styles11.handle, { backgroundColor: t.textMuted }] }) }),
|
|
4334
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.View, { style: styles11.header, children: [
|
|
4335
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: [styles11.headerTitle, { color: t.text }], children: showCelebration ? "Prize Claimed!" : "Claim Prize" }),
|
|
4336
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.TouchableOpacity, { onPress: onDismiss, activeOpacity: 0.8, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: [styles11.closeButton, { color: t.textMuted }], children: "\u2715" }) })
|
|
4337
|
+
] }),
|
|
4338
|
+
showCelebration && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
4339
|
+
import_react_native16.Animated.View,
|
|
4340
|
+
{
|
|
4341
|
+
style: [
|
|
4342
|
+
styles11.celebrationContainer,
|
|
4343
|
+
{
|
|
4344
|
+
opacity: celebrationOpacity,
|
|
4345
|
+
transform: [{ scale: celebrationScale }]
|
|
4346
|
+
}
|
|
4347
|
+
],
|
|
4348
|
+
children: [
|
|
4349
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: styles11.celebrationEmoji, children: "\u{1F3C6}" }),
|
|
4350
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.Text, { style: [styles11.celebrationText, { color: t.success }], children: [
|
|
4351
|
+
"+",
|
|
4352
|
+
prizeAmount,
|
|
4353
|
+
" SOL"
|
|
4354
|
+
] }),
|
|
4355
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: [styles11.celebrationSubtext, { color: t.textMuted }], children: "Winnings sent to your wallet" })
|
|
4356
|
+
]
|
|
4357
|
+
}
|
|
4358
|
+
),
|
|
4359
|
+
!showCelebration && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.View, { style: [styles11.summaryCard, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
4360
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.View, { style: styles11.summaryRow, children: [
|
|
4361
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: [styles11.summaryLabel, { color: t.textMuted }], children: "Prize" }),
|
|
4362
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.Text, { style: [styles11.summaryValue, { color: t.success }], children: [
|
|
4363
|
+
prizeAmount,
|
|
4364
|
+
" SOL"
|
|
4365
|
+
] })
|
|
4366
|
+
] }),
|
|
4367
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.View, { style: [styles11.summarySep, { backgroundColor: t.border }] }),
|
|
4368
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.View, { style: styles11.summaryRow, children: [
|
|
4369
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: [styles11.summaryLabel, { color: t.textMuted }], children: "Game" }),
|
|
4370
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
4371
|
+
import_react_native16.Text,
|
|
4372
|
+
{
|
|
4373
|
+
style: [styles11.summaryValue, { color: t.text }],
|
|
4374
|
+
numberOfLines: 1,
|
|
4375
|
+
children: [
|
|
4376
|
+
gameId.slice(0, 8),
|
|
4377
|
+
"...",
|
|
4378
|
+
gameId.slice(-4)
|
|
4379
|
+
]
|
|
4380
|
+
}
|
|
4381
|
+
)
|
|
4382
|
+
] })
|
|
4383
|
+
] }),
|
|
4384
|
+
mutation.error && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.View, { style: [styles11.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: [styles11.errorText, { color: t.errorText }], children: mutation.error.message }) }),
|
|
4385
|
+
!showCelebration && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4386
|
+
import_react_native16.TouchableOpacity,
|
|
4387
|
+
{
|
|
4388
|
+
style: [
|
|
4389
|
+
styles11.ctaButton,
|
|
4390
|
+
{ backgroundColor: canClaim ? t.success : t.border }
|
|
4391
|
+
],
|
|
4392
|
+
disabled: !canClaim,
|
|
4393
|
+
onPress: handleClaim,
|
|
4394
|
+
activeOpacity: 0.8,
|
|
4395
|
+
children: isMutating ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.View, { style: styles11.ctaLoading, children: [
|
|
4396
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.ActivityIndicator, { size: "small", color: "#FFFFFF" }),
|
|
4397
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: styles11.ctaText, children: statusLabel })
|
|
4398
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native16.Text, { style: [styles11.ctaText, !canClaim && { opacity: 0.5 }], children: [
|
|
4399
|
+
"Claim Prize \u2014 ",
|
|
4400
|
+
prizeAmount,
|
|
4401
|
+
" SOL"
|
|
4402
|
+
] })
|
|
4403
|
+
}
|
|
4404
|
+
),
|
|
4405
|
+
mutation.data?.explorerUrl && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native16.Text, { style: [styles11.explorerHint, { color: t.textMuted }], children: "View on Solscan" })
|
|
4406
|
+
] }) })
|
|
4407
|
+
}
|
|
4408
|
+
)
|
|
4409
|
+
]
|
|
4410
|
+
}
|
|
4411
|
+
);
|
|
4412
|
+
}
|
|
4413
|
+
var styles11 = import_react_native16.StyleSheet.create({
|
|
4414
|
+
overlay: {
|
|
4415
|
+
...import_react_native16.StyleSheet.absoluteFillObject,
|
|
4416
|
+
backgroundColor: "rgba(0,0,0,0.5)"
|
|
4417
|
+
},
|
|
4418
|
+
overlayTap: {
|
|
4419
|
+
flex: 1
|
|
4420
|
+
},
|
|
4421
|
+
keyboardView: {
|
|
4422
|
+
flex: 1,
|
|
4423
|
+
justifyContent: "flex-end"
|
|
4424
|
+
},
|
|
4425
|
+
sheetPositioner: {
|
|
4426
|
+
justifyContent: "flex-end"
|
|
4427
|
+
},
|
|
4428
|
+
sheet: {
|
|
4429
|
+
borderTopLeftRadius: 24,
|
|
4430
|
+
borderTopRightRadius: 24,
|
|
4431
|
+
paddingHorizontal: 20,
|
|
4432
|
+
paddingBottom: 40
|
|
4433
|
+
},
|
|
4434
|
+
handleRow: {
|
|
4435
|
+
alignItems: "center",
|
|
4436
|
+
paddingTop: 10,
|
|
4437
|
+
paddingBottom: 8
|
|
4438
|
+
},
|
|
4439
|
+
handle: {
|
|
4440
|
+
width: 36,
|
|
4441
|
+
height: 4,
|
|
4442
|
+
borderRadius: 2,
|
|
4443
|
+
opacity: 0.4
|
|
4444
|
+
},
|
|
4445
|
+
header: {
|
|
4446
|
+
flexDirection: "row",
|
|
4447
|
+
alignItems: "center",
|
|
4448
|
+
justifyContent: "space-between",
|
|
4449
|
+
paddingVertical: 12
|
|
4450
|
+
},
|
|
4451
|
+
headerTitle: {
|
|
4452
|
+
fontSize: 20,
|
|
4453
|
+
fontWeight: "700"
|
|
4454
|
+
},
|
|
4455
|
+
closeButton: {
|
|
4456
|
+
fontSize: 20,
|
|
4457
|
+
padding: 4
|
|
4458
|
+
},
|
|
4459
|
+
// Celebration
|
|
4460
|
+
celebrationContainer: {
|
|
4461
|
+
alignItems: "center",
|
|
4462
|
+
paddingVertical: 32,
|
|
4463
|
+
gap: 8
|
|
4464
|
+
},
|
|
4465
|
+
celebrationEmoji: {
|
|
4466
|
+
fontSize: 64
|
|
4467
|
+
},
|
|
4468
|
+
celebrationText: {
|
|
4469
|
+
fontSize: 32,
|
|
4470
|
+
fontWeight: "800"
|
|
4471
|
+
},
|
|
4472
|
+
celebrationSubtext: {
|
|
4473
|
+
fontSize: 14,
|
|
4474
|
+
marginTop: 4
|
|
4475
|
+
},
|
|
4476
|
+
// Summary
|
|
4477
|
+
summaryCard: {
|
|
4478
|
+
marginTop: 20,
|
|
4479
|
+
borderRadius: 16,
|
|
4480
|
+
borderWidth: 1,
|
|
4481
|
+
overflow: "hidden"
|
|
4482
|
+
},
|
|
4483
|
+
summaryRow: {
|
|
4484
|
+
flexDirection: "row",
|
|
4485
|
+
alignItems: "center",
|
|
4486
|
+
justifyContent: "space-between",
|
|
4487
|
+
paddingHorizontal: 16,
|
|
4488
|
+
paddingVertical: 14
|
|
4489
|
+
},
|
|
4490
|
+
summaryLabel: {
|
|
4491
|
+
fontSize: 14
|
|
4492
|
+
},
|
|
4493
|
+
summaryValue: {
|
|
4494
|
+
fontSize: 15,
|
|
4495
|
+
fontWeight: "700"
|
|
4496
|
+
},
|
|
4497
|
+
summarySep: {
|
|
4498
|
+
height: 1,
|
|
4499
|
+
marginHorizontal: 16
|
|
4500
|
+
},
|
|
4501
|
+
// Error
|
|
4502
|
+
errorBox: {
|
|
4503
|
+
marginTop: 16,
|
|
4504
|
+
borderRadius: 12,
|
|
4505
|
+
borderWidth: 1,
|
|
4506
|
+
padding: 12
|
|
4507
|
+
},
|
|
4508
|
+
errorText: {
|
|
4509
|
+
fontSize: 13,
|
|
4510
|
+
fontWeight: "500"
|
|
4511
|
+
},
|
|
4512
|
+
// CTA
|
|
4513
|
+
ctaButton: {
|
|
4514
|
+
marginTop: 20,
|
|
4515
|
+
height: 56,
|
|
4516
|
+
borderRadius: 14,
|
|
4517
|
+
justifyContent: "center",
|
|
4518
|
+
alignItems: "center"
|
|
4519
|
+
},
|
|
4520
|
+
ctaText: {
|
|
4521
|
+
color: "#FFFFFF",
|
|
4522
|
+
fontSize: 16,
|
|
4523
|
+
fontWeight: "700"
|
|
4524
|
+
},
|
|
4525
|
+
ctaLoading: {
|
|
4526
|
+
flexDirection: "row",
|
|
4527
|
+
alignItems: "center",
|
|
4528
|
+
gap: 10
|
|
4529
|
+
},
|
|
4530
|
+
explorerHint: {
|
|
4531
|
+
textAlign: "center",
|
|
4532
|
+
marginTop: 12,
|
|
4533
|
+
fontSize: 13
|
|
4534
|
+
}
|
|
4535
|
+
});
|
|
4214
4536
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4215
4537
|
0 && (module.exports = {
|
|
4216
4538
|
AuthGate,
|
|
4539
|
+
ClaimPrizeSheet,
|
|
4217
4540
|
ConnectWalletScreen,
|
|
4218
4541
|
CreateCustomGameSheet,
|
|
4219
4542
|
DEFAULT_BASE_URL,
|