@dubsdotapp/expo 0.5.28 → 0.5.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/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +47 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +15 -2
- package/src/hooks/useCreateGame.ts +52 -0
- package/src/ui/game/JoinGameSheet.tsx +14 -7
package/dist/index.mjs
CHANGED
|
@@ -655,7 +655,12 @@ var DubsClient = class {
|
|
|
655
655
|
const query = qs.toString();
|
|
656
656
|
return this.request("GET", `/chat/messages${query ? `?${query}` : ""}`);
|
|
657
657
|
}
|
|
658
|
-
/**
|
|
658
|
+
/**
|
|
659
|
+
* Send a message to global chat. Mirrors the same payload accepted by
|
|
660
|
+
* the chat socket's `send_message` event so REST callers (e.g. the
|
|
661
|
+
* useCreateGame auto-share) can attach a `gameInvite` chip, GIF, P&L
|
|
662
|
+
* share, payment signature, or @mention IDs alongside the text.
|
|
663
|
+
*/
|
|
659
664
|
async sendChatMessage(params) {
|
|
660
665
|
return this.request("POST", "/chat/message", params);
|
|
661
666
|
}
|
|
@@ -2026,6 +2031,11 @@ async function signAndSendBase64Transaction(base64Tx, wallet, connection) {
|
|
|
2026
2031
|
}
|
|
2027
2032
|
|
|
2028
2033
|
// src/hooks/useCreateGame.ts
|
|
2034
|
+
function teamNickname(name) {
|
|
2035
|
+
if (!name) return "TBD";
|
|
2036
|
+
const parts = name.split(" ");
|
|
2037
|
+
return parts.length > 2 ? parts[parts.length - 1] : name;
|
|
2038
|
+
}
|
|
2029
2039
|
function useCreateGame() {
|
|
2030
2040
|
const { client, wallet, connection } = useDubs();
|
|
2031
2041
|
const [status, setStatus] = useState6("idle");
|
|
@@ -2073,6 +2083,35 @@ function useCreateGame() {
|
|
|
2073
2083
|
setData(result);
|
|
2074
2084
|
setStatus("success");
|
|
2075
2085
|
console.log("[useCreateGame] Complete!");
|
|
2086
|
+
try {
|
|
2087
|
+
const event = createResult.event;
|
|
2088
|
+
const home = event?.opponents?.[0]?.name ?? null;
|
|
2089
|
+
const away = event?.opponents?.[1]?.name ?? null;
|
|
2090
|
+
const teamLabel = params.teamChoice === "home" ? teamNickname(home) : params.teamChoice === "away" ? teamNickname(away) : "Draw";
|
|
2091
|
+
const message = `I just placed a ${params.wagerAmount} SOL bet on ${teamLabel} - Join me!`;
|
|
2092
|
+
const gameInvite = {
|
|
2093
|
+
gameId: createResult.gameId,
|
|
2094
|
+
gameAddress: createResult.gameAddress,
|
|
2095
|
+
title: event?.title,
|
|
2096
|
+
league: event?.league,
|
|
2097
|
+
gameType: "sports",
|
|
2098
|
+
buyIn: params.wagerAmount,
|
|
2099
|
+
status: "waiting",
|
|
2100
|
+
homeTeam: home,
|
|
2101
|
+
awayTeam: away,
|
|
2102
|
+
homeTeamBadge: event?.opponents?.[0]?.imageUrl ?? null,
|
|
2103
|
+
awayTeamBadge: event?.opponents?.[1]?.imageUrl ?? null,
|
|
2104
|
+
imageUrl: event?.media?.thumbnail ?? null,
|
|
2105
|
+
strThumb: event?.media?.thumbnail ?? null,
|
|
2106
|
+
strPoster: event?.media?.poster ?? null,
|
|
2107
|
+
strTimestamp: event?.startTime ?? null,
|
|
2108
|
+
creatorTeam: params.teamChoice,
|
|
2109
|
+
creatorWallet: params.playerWallet
|
|
2110
|
+
};
|
|
2111
|
+
await client.sendChatMessage({ message, gameInvite });
|
|
2112
|
+
} catch (chatErr) {
|
|
2113
|
+
console.warn("[useCreateGame] Auto chat-share failed (non-fatal):", chatErr);
|
|
2114
|
+
}
|
|
2076
2115
|
return result;
|
|
2077
2116
|
} catch (err) {
|
|
2078
2117
|
console.error("[useCreateGame] FAILED:", err);
|
|
@@ -6027,18 +6066,18 @@ function JoinGameSheet({
|
|
|
6027
6066
|
const awayBetsCount = bettors.filter((b) => b.team === "away").length;
|
|
6028
6067
|
const drawBetsCount = bettors.filter((b) => b.team === "draw").length;
|
|
6029
6068
|
const newPool = totalPool + wager;
|
|
6030
|
-
const
|
|
6031
|
-
const
|
|
6032
|
-
const
|
|
6069
|
+
const homeWith = homePool + wager;
|
|
6070
|
+
const awayWith = awayPool + wager;
|
|
6071
|
+
const drawWith = drawPool + wager;
|
|
6033
6072
|
return {
|
|
6034
|
-
homeOdds:
|
|
6035
|
-
awayOdds:
|
|
6036
|
-
drawOdds:
|
|
6073
|
+
homeOdds: homeWith > 0 ? (newPool / homeWith).toFixed(2) : "\u2014",
|
|
6074
|
+
awayOdds: awayWith > 0 ? (newPool / awayWith).toFixed(2) : "\u2014",
|
|
6075
|
+
drawOdds: drawWith > 0 ? (newPool / drawWith).toFixed(2) : "\u2014",
|
|
6037
6076
|
homeBets: homeBetsCount,
|
|
6038
6077
|
awayBets: awayBetsCount,
|
|
6039
6078
|
drawBets: drawBetsCount
|
|
6040
6079
|
};
|
|
6041
|
-
}, [totalPool, homePool, awayPool, drawPool, bettors, wager
|
|
6080
|
+
}, [totalPool, homePool, awayPool, drawPool, bettors, wager]);
|
|
6042
6081
|
const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : selectedTeam === "draw" ? drawOdds : "\u2014";
|
|
6043
6082
|
const potentialWinnings = selectedOdds !== "\u2014" ? formatSol(parseFloat(selectedOdds) * wager) : "\u2014";
|
|
6044
6083
|
const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";
|