@dubsdotapp/expo 0.5.32 → 0.5.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 +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +82 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +25 -0
- package/src/hooks/useJoinGame.ts +3 -0
- package/src/types.ts +16 -0
- package/src/ui/game/JoinGameSheet.tsx +77 -4
package/dist/index.mjs
CHANGED
|
@@ -271,6 +271,19 @@ var DubsClient = class {
|
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
async joinGame(params) {
|
|
274
|
+
if (params.useCredit) {
|
|
275
|
+
const res2 = await this.request("POST", "/games/join-sponsored", {
|
|
276
|
+
gameId: params.gameId,
|
|
277
|
+
teamChoice: params.teamChoice
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
gameId: res2.gameId,
|
|
281
|
+
transaction: res2.transaction,
|
|
282
|
+
gameAddress: res2.gameAddress,
|
|
283
|
+
promoCode: res2.promoCode,
|
|
284
|
+
sponsorWallet: res2.sponsorWallet
|
|
285
|
+
};
|
|
286
|
+
}
|
|
274
287
|
const res = await this.request(
|
|
275
288
|
"POST",
|
|
276
289
|
"/games/join",
|
|
@@ -2170,7 +2183,10 @@ function useJoinGame() {
|
|
|
2170
2183
|
teamChoice: params.teamChoice,
|
|
2171
2184
|
wagerAmount: params.amount,
|
|
2172
2185
|
role: "joiner",
|
|
2173
|
-
gameAddress: joinResult.gameAddress
|
|
2186
|
+
gameAddress: joinResult.gameAddress,
|
|
2187
|
+
// Pass through when this was a sponsored join — server marks
|
|
2188
|
+
// the credit as used after the on-chain confirm succeeds.
|
|
2189
|
+
promoCode: joinResult.promoCode
|
|
2174
2190
|
};
|
|
2175
2191
|
console.log("[useJoinGame] Step 3: Confirming with backend...", confirmParams);
|
|
2176
2192
|
const confirmResult = await client.confirmGame(confirmParams);
|
|
@@ -6044,10 +6060,14 @@ function JoinGameSheet({
|
|
|
6044
6060
|
const t = useDubsTheme();
|
|
6045
6061
|
const { wallet } = useDubs();
|
|
6046
6062
|
const mutation = useJoinGame();
|
|
6063
|
+
const { credits, refetch: refetchCredits } = useCredits();
|
|
6047
6064
|
const isCustomGame = game.gameMode === CUSTOM_GAME_MODE;
|
|
6048
6065
|
const [selectedTeam, setSelectedTeam] = useState35(null);
|
|
6049
6066
|
const [wager, setWager] = useState35(game.buyIn);
|
|
6050
6067
|
const [showSuccess, setShowSuccess] = useState35(false);
|
|
6068
|
+
const [useCredit, setUseCredit] = useState35(false);
|
|
6069
|
+
const oldestCredit = credits.length > 0 ? credits[0] : null;
|
|
6070
|
+
const canUseCredit = !!oldestCredit && oldestCredit.amountSOL >= game.buyIn;
|
|
6051
6071
|
const overlayOpacity = useRef10(new Animated4.Value(0)).current;
|
|
6052
6072
|
const successScale = useRef10(new Animated4.Value(0)).current;
|
|
6053
6073
|
const successOpacity = useRef10(new Animated4.Value(0)).current;
|
|
@@ -6136,11 +6156,15 @@ function JoinGameSheet({
|
|
|
6136
6156
|
playerWallet: wallet.publicKey.toBase58(),
|
|
6137
6157
|
gameId: game.gameId,
|
|
6138
6158
|
teamChoice: selectedTeam,
|
|
6139
|
-
|
|
6159
|
+
// When useCredit is on, the on-chain instruction transfers
|
|
6160
|
+
// exactly the credit's amount; pass that as the wager.
|
|
6161
|
+
amount: useCredit && oldestCredit ? oldestCredit.amountSOL : wager,
|
|
6162
|
+
useCredit: useCredit && canUseCredit ? true : void 0
|
|
6140
6163
|
});
|
|
6164
|
+
if (useCredit) refetchCredits();
|
|
6141
6165
|
} catch {
|
|
6142
6166
|
}
|
|
6143
|
-
}, [selectedTeam, wallet.publicKey, mutation.execute, game.gameId, wager]);
|
|
6167
|
+
}, [selectedTeam, wallet.publicKey, mutation.execute, game.gameId, wager, useCredit, oldestCredit, canUseCredit, refetchCredits]);
|
|
6144
6168
|
const statusLabel = STATUS_LABELS3[mutation.status] || "";
|
|
6145
6169
|
return /* @__PURE__ */ jsxs15(
|
|
6146
6170
|
Modal3,
|
|
@@ -6343,7 +6367,26 @@ function JoinGameSheet({
|
|
|
6343
6367
|
] })
|
|
6344
6368
|
] })
|
|
6345
6369
|
] }),
|
|
6346
|
-
selectedTeam && !
|
|
6370
|
+
selectedTeam && !alreadyJoined && canUseCredit && oldestCredit && /* @__PURE__ */ jsxs15(
|
|
6371
|
+
TouchableOpacity11,
|
|
6372
|
+
{
|
|
6373
|
+
style: [styles15.creditRow, { backgroundColor: useCredit ? "#22C55E18" : t.surface, borderColor: useCredit ? "#22C55E" : t.border }],
|
|
6374
|
+
activeOpacity: 0.8,
|
|
6375
|
+
onPress: () => setUseCredit((v) => !v),
|
|
6376
|
+
children: [
|
|
6377
|
+
/* @__PURE__ */ jsxs15(View16, { style: styles15.creditRowText, children: [
|
|
6378
|
+
/* @__PURE__ */ jsxs15(Text16, { style: [styles15.creditTitle, { color: useCredit ? "#22C55E" : t.text }], children: [
|
|
6379
|
+
"\u{1F381} Use my ",
|
|
6380
|
+
formatSol(oldestCredit.amountSOL),
|
|
6381
|
+
" SOL credit"
|
|
6382
|
+
] }),
|
|
6383
|
+
/* @__PURE__ */ jsx18(Text16, { style: [styles15.creditSub, { color: t.textMuted }], children: useCredit ? "Treasury covers this bet \u2014 wager locked to credit amount" : `${credits.length} credit${credits.length === 1 ? "" : "s"} available from your streak` })
|
|
6384
|
+
] }),
|
|
6385
|
+
/* @__PURE__ */ jsx18(View16, { style: [styles15.creditCheckbox, useCredit && { backgroundColor: "#22C55E", borderColor: "#22C55E" }], children: useCredit && /* @__PURE__ */ jsx18(Text16, { style: styles15.creditCheck, children: "\u2713" }) })
|
|
6386
|
+
]
|
|
6387
|
+
}
|
|
6388
|
+
),
|
|
6389
|
+
selectedTeam && !isPoolModeEnabled && !alreadyJoined && !useCredit && /* @__PURE__ */ jsx18(
|
|
6347
6390
|
SolSlider,
|
|
6348
6391
|
{
|
|
6349
6392
|
value: wager,
|
|
@@ -6681,6 +6724,41 @@ var styles15 = StyleSheet16.create({
|
|
|
6681
6724
|
flexDirection: "row",
|
|
6682
6725
|
alignItems: "center",
|
|
6683
6726
|
gap: 10
|
|
6727
|
+
},
|
|
6728
|
+
creditRow: {
|
|
6729
|
+
flexDirection: "row",
|
|
6730
|
+
alignItems: "center",
|
|
6731
|
+
gap: 12,
|
|
6732
|
+
marginTop: 12,
|
|
6733
|
+
padding: 12,
|
|
6734
|
+
borderRadius: 12,
|
|
6735
|
+
borderWidth: 1.5
|
|
6736
|
+
},
|
|
6737
|
+
creditRowText: {
|
|
6738
|
+
flex: 1,
|
|
6739
|
+
gap: 2
|
|
6740
|
+
},
|
|
6741
|
+
creditTitle: {
|
|
6742
|
+
fontSize: 14,
|
|
6743
|
+
fontWeight: "700"
|
|
6744
|
+
},
|
|
6745
|
+
creditSub: {
|
|
6746
|
+
fontSize: 12,
|
|
6747
|
+
fontWeight: "500"
|
|
6748
|
+
},
|
|
6749
|
+
creditCheckbox: {
|
|
6750
|
+
width: 22,
|
|
6751
|
+
height: 22,
|
|
6752
|
+
borderRadius: 11,
|
|
6753
|
+
borderWidth: 2,
|
|
6754
|
+
borderColor: "#3A3A3C",
|
|
6755
|
+
alignItems: "center",
|
|
6756
|
+
justifyContent: "center"
|
|
6757
|
+
},
|
|
6758
|
+
creditCheck: {
|
|
6759
|
+
color: "#FFFFFF",
|
|
6760
|
+
fontSize: 14,
|
|
6761
|
+
fontWeight: "900"
|
|
6684
6762
|
}
|
|
6685
6763
|
});
|
|
6686
6764
|
|