@dubsdotapp/expo 0.5.27 → 0.5.29
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 +41 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/chat/provider.tsx +5 -2
- package/src/client.ts +15 -2
- package/src/hooks/useCreateGame.ts +52 -0
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);
|
|
@@ -8835,7 +8874,7 @@ function ChatProvider({ children, autoConnect = true }) {
|
|
|
8835
8874
|
const refreshMessages = useCallback35(async () => {
|
|
8836
8875
|
try {
|
|
8837
8876
|
const res = await client.getChatMessages({ limit: 30 });
|
|
8838
|
-
setMessages(res.messages);
|
|
8877
|
+
setMessages([...res.messages].reverse());
|
|
8839
8878
|
} catch (err) {
|
|
8840
8879
|
console.error("[Dubs:ChatProvider] Failed to load messages:", err);
|
|
8841
8880
|
}
|