@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 CHANGED
@@ -706,10 +706,20 @@ declare class DubsClient {
706
706
  messages: any[];
707
707
  hasMore: boolean;
708
708
  }>;
709
- /** Send a message to global chat */
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
- /** Send a message to global chat */
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
- /** Send a message to global chat */
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);
@@ -6059,18 +6098,18 @@ function JoinGameSheet({
6059
6098
  const awayBetsCount = bettors.filter((b) => b.team === "away").length;
6060
6099
  const drawBetsCount = bettors.filter((b) => b.team === "draw").length;
6061
6100
  const newPool = totalPool + wager;
6062
- const newHome = homePool + (selectedTeam === "home" ? wager : 0);
6063
- const newAway = awayPool + (selectedTeam === "away" ? wager : 0);
6064
- const newDraw = drawPool + (selectedTeam === "draw" ? wager : 0);
6101
+ const homeWith = homePool + wager;
6102
+ const awayWith = awayPool + wager;
6103
+ const drawWith = drawPool + wager;
6065
6104
  return {
6066
- homeOdds: newHome > 0 ? (newPool / newHome).toFixed(2) : "\u2014",
6067
- awayOdds: newAway > 0 ? (newPool / newAway).toFixed(2) : "\u2014",
6068
- drawOdds: newDraw > 0 ? (newPool / newDraw).toFixed(2) : "\u2014",
6105
+ homeOdds: homeWith > 0 ? (newPool / homeWith).toFixed(2) : "\u2014",
6106
+ awayOdds: awayWith > 0 ? (newPool / awayWith).toFixed(2) : "\u2014",
6107
+ drawOdds: drawWith > 0 ? (newPool / drawWith).toFixed(2) : "\u2014",
6069
6108
  homeBets: homeBetsCount,
6070
6109
  awayBets: awayBetsCount,
6071
6110
  drawBets: drawBetsCount
6072
6111
  };
6073
- }, [totalPool, homePool, awayPool, drawPool, bettors, wager, selectedTeam]);
6112
+ }, [totalPool, homePool, awayPool, drawPool, bettors, wager]);
6074
6113
  const selectedOdds = selectedTeam === "home" ? homeOdds : selectedTeam === "away" ? awayOdds : selectedTeam === "draw" ? drawOdds : "\u2014";
6075
6114
  const potentialWinnings = selectedOdds !== "\u2014" ? formatSol(parseFloat(selectedOdds) * wager) : "\u2014";
6076
6115
  const homeName = shortName ? shortName(opponents[0]?.name) : opponents[0]?.name || "Home";