@dubsdotapp/expo 0.5.28 → 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 +40 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -1
- 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/dist/index.d.mts
CHANGED
|
@@ -706,10 +706,20 @@ declare class DubsClient {
|
|
|
706
706
|
messages: any[];
|
|
707
707
|
hasMore: boolean;
|
|
708
708
|
}>;
|
|
709
|
-
/**
|
|
709
|
+
/**
|
|
710
|
+
* Send a message to global chat. Mirrors the same payload accepted by
|
|
711
|
+
* the chat socket's `send_message` event so REST callers (e.g. the
|
|
712
|
+
* useCreateGame auto-share) can attach a `gameInvite` chip, GIF, P&L
|
|
713
|
+
* share, payment signature, or @mention IDs alongside the text.
|
|
714
|
+
*/
|
|
710
715
|
sendChatMessage(params: {
|
|
711
716
|
message: string;
|
|
712
717
|
replyToId?: number;
|
|
718
|
+
gameInvite?: Record<string, unknown>;
|
|
719
|
+
mentions?: number[];
|
|
720
|
+
gifUrl?: string;
|
|
721
|
+
pnlShare?: Record<string, unknown>;
|
|
722
|
+
paymentSignature?: string;
|
|
713
723
|
}): Promise<{
|
|
714
724
|
message: any;
|
|
715
725
|
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -706,10 +706,20 @@ declare class DubsClient {
|
|
|
706
706
|
messages: any[];
|
|
707
707
|
hasMore: boolean;
|
|
708
708
|
}>;
|
|
709
|
-
/**
|
|
709
|
+
/**
|
|
710
|
+
* Send a message to global chat. Mirrors the same payload accepted by
|
|
711
|
+
* the chat socket's `send_message` event so REST callers (e.g. the
|
|
712
|
+
* useCreateGame auto-share) can attach a `gameInvite` chip, GIF, P&L
|
|
713
|
+
* share, payment signature, or @mention IDs alongside the text.
|
|
714
|
+
*/
|
|
710
715
|
sendChatMessage(params: {
|
|
711
716
|
message: string;
|
|
712
717
|
replyToId?: number;
|
|
718
|
+
gameInvite?: Record<string, unknown>;
|
|
719
|
+
mentions?: number[];
|
|
720
|
+
gifUrl?: string;
|
|
721
|
+
pnlShare?: Record<string, unknown>;
|
|
722
|
+
paymentSignature?: string;
|
|
713
723
|
}): Promise<{
|
|
714
724
|
message: any;
|
|
715
725
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -767,7 +767,12 @@ var DubsClient = class {
|
|
|
767
767
|
const query = qs.toString();
|
|
768
768
|
return this.request("GET", `/chat/messages${query ? `?${query}` : ""}`);
|
|
769
769
|
}
|
|
770
|
-
/**
|
|
770
|
+
/**
|
|
771
|
+
* Send a message to global chat. Mirrors the same payload accepted by
|
|
772
|
+
* the chat socket's `send_message` event so REST callers (e.g. the
|
|
773
|
+
* useCreateGame auto-share) can attach a `gameInvite` chip, GIF, P&L
|
|
774
|
+
* share, payment signature, or @mention IDs alongside the text.
|
|
775
|
+
*/
|
|
771
776
|
async sendChatMessage(params) {
|
|
772
777
|
return this.request("POST", "/chat/message", params);
|
|
773
778
|
}
|
|
@@ -2118,6 +2123,11 @@ async function signAndSendBase64Transaction(base64Tx, wallet, connection) {
|
|
|
2118
2123
|
}
|
|
2119
2124
|
|
|
2120
2125
|
// src/hooks/useCreateGame.ts
|
|
2126
|
+
function teamNickname(name) {
|
|
2127
|
+
if (!name) return "TBD";
|
|
2128
|
+
const parts = name.split(" ");
|
|
2129
|
+
return parts.length > 2 ? parts[parts.length - 1] : name;
|
|
2130
|
+
}
|
|
2121
2131
|
function useCreateGame() {
|
|
2122
2132
|
const { client, wallet, connection } = useDubs();
|
|
2123
2133
|
const [status, setStatus] = (0, import_react7.useState)("idle");
|
|
@@ -2165,6 +2175,35 @@ function useCreateGame() {
|
|
|
2165
2175
|
setData(result);
|
|
2166
2176
|
setStatus("success");
|
|
2167
2177
|
console.log("[useCreateGame] Complete!");
|
|
2178
|
+
try {
|
|
2179
|
+
const event = createResult.event;
|
|
2180
|
+
const home = event?.opponents?.[0]?.name ?? null;
|
|
2181
|
+
const away = event?.opponents?.[1]?.name ?? null;
|
|
2182
|
+
const teamLabel = params.teamChoice === "home" ? teamNickname(home) : params.teamChoice === "away" ? teamNickname(away) : "Draw";
|
|
2183
|
+
const message = `I just placed a ${params.wagerAmount} SOL bet on ${teamLabel} - Join me!`;
|
|
2184
|
+
const gameInvite = {
|
|
2185
|
+
gameId: createResult.gameId,
|
|
2186
|
+
gameAddress: createResult.gameAddress,
|
|
2187
|
+
title: event?.title,
|
|
2188
|
+
league: event?.league,
|
|
2189
|
+
gameType: "sports",
|
|
2190
|
+
buyIn: params.wagerAmount,
|
|
2191
|
+
status: "waiting",
|
|
2192
|
+
homeTeam: home,
|
|
2193
|
+
awayTeam: away,
|
|
2194
|
+
homeTeamBadge: event?.opponents?.[0]?.imageUrl ?? null,
|
|
2195
|
+
awayTeamBadge: event?.opponents?.[1]?.imageUrl ?? null,
|
|
2196
|
+
imageUrl: event?.media?.thumbnail ?? null,
|
|
2197
|
+
strThumb: event?.media?.thumbnail ?? null,
|
|
2198
|
+
strPoster: event?.media?.poster ?? null,
|
|
2199
|
+
strTimestamp: event?.startTime ?? null,
|
|
2200
|
+
creatorTeam: params.teamChoice,
|
|
2201
|
+
creatorWallet: params.playerWallet
|
|
2202
|
+
};
|
|
2203
|
+
await client.sendChatMessage({ message, gameInvite });
|
|
2204
|
+
} catch (chatErr) {
|
|
2205
|
+
console.warn("[useCreateGame] Auto chat-share failed (non-fatal):", chatErr);
|
|
2206
|
+
}
|
|
2168
2207
|
return result;
|
|
2169
2208
|
} catch (err) {
|
|
2170
2209
|
console.error("[useCreateGame] FAILED:", err);
|