@dubsdotapp/expo 0.2.71 → 0.2.73

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.mjs CHANGED
@@ -511,10 +511,14 @@ var DubsClient = class {
511
511
  return { ...SOLANA_PROGRAM_ERRORS };
512
512
  }
513
513
  // ── App Config ──
514
- /** Fetch the app's UI customization config (accent color, icon, tagline) */
514
+ /** Fetch the app's UI customization config (accent color, icon, tagline, environment) */
515
515
  async getAppConfig() {
516
516
  const res = await this.request("GET", "/apps/config");
517
- return res.data?.uiConfig || {};
517
+ const config = res.data?.uiConfig || {};
518
+ if (res.data?.environment) {
519
+ config.environment = res.data.environment;
520
+ }
521
+ return config;
518
522
  }
519
523
  };
520
524
 
@@ -1792,7 +1796,7 @@ function useCreateGame() {
1792
1796
  console.log("[useCreateGame] Step 2 done. Signature:", signature);
1793
1797
  setStatus("confirming");
1794
1798
  console.log("[useCreateGame] Step 3: Confirming with backend...");
1795
- await client.confirmGame({
1799
+ const confirmResult = await client.confirmGame({
1796
1800
  gameId: createResult.gameId,
1797
1801
  playerWallet: params.playerWallet,
1798
1802
  signature,
@@ -1802,12 +1806,11 @@ function useCreateGame() {
1802
1806
  gameAddress: createResult.gameAddress
1803
1807
  });
1804
1808
  console.log("[useCreateGame] Step 3 done.");
1805
- const explorerUrl = `https://solscan.io/tx/${signature}`;
1806
1809
  const result = {
1807
1810
  gameId: createResult.gameId,
1808
1811
  gameAddress: createResult.gameAddress,
1809
1812
  signature,
1810
- explorerUrl
1813
+ explorerUrl: confirmResult.explorerUrl
1811
1814
  };
1812
1815
  setData(result);
1813
1816
  setStatus("success");
@@ -1863,14 +1866,13 @@ function useJoinGame() {
1863
1866
  gameAddress: joinResult.gameAddress
1864
1867
  };
1865
1868
  console.log("[useJoinGame] Step 3: Confirming with backend...", confirmParams);
1866
- await client.confirmGame(confirmParams);
1869
+ const confirmResult = await client.confirmGame(confirmParams);
1867
1870
  console.log("[useJoinGame] Step 3 done. Backend confirmed.");
1868
- const explorerUrl = `https://solscan.io/tx/${signature}`;
1869
1871
  const result = {
1870
1872
  gameId: params.gameId,
1871
1873
  gameAddress: joinResult.gameAddress,
1872
1874
  signature,
1873
- explorerUrl
1875
+ explorerUrl: confirmResult.explorerUrl
1874
1876
  };
1875
1877
  setData(result);
1876
1878
  setStatus("success");
@@ -1988,7 +1990,7 @@ function useCreateCustomGame() {
1988
1990
  console.log("[useCreateCustomGame] Step 2 done. Signature:", signature);
1989
1991
  setStatus("confirming");
1990
1992
  console.log("[useCreateCustomGame] Step 3: Confirming with backend...");
1991
- await client.confirmCustomGame({
1993
+ const confirmResult = await client.confirmCustomGame({
1992
1994
  gameId: createResult.gameId,
1993
1995
  playerWallet: params.playerWallet,
1994
1996
  signature,
@@ -1998,12 +2000,11 @@ function useCreateCustomGame() {
1998
2000
  gameAddress: createResult.gameAddress
1999
2001
  });
2000
2002
  console.log("[useCreateCustomGame] Step 3 done.");
2001
- const explorerUrl = `https://solscan.io/tx/${signature}`;
2002
2003
  const result = {
2003
2004
  gameId: createResult.gameId,
2004
2005
  gameAddress: createResult.gameAddress,
2005
2006
  signature,
2006
- explorerUrl,
2007
+ explorerUrl: confirmResult.explorerUrl,
2007
2008
  buyIn: params.wagerAmount
2008
2009
  };
2009
2010
  setData(result);
@@ -3098,21 +3099,28 @@ function DubsProvider({
3098
3099
  const config = NETWORK_CONFIG[network];
3099
3100
  const baseUrl = baseUrlOverride || config.baseUrl;
3100
3101
  const rpcUrl = rpcUrlOverride || config.rpcUrl;
3101
- const cluster = config.cluster;
3102
3102
  const client = useMemo2(() => new DubsClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
3103
- const connection = useMemo2(() => new Connection2(rpcUrl, { commitment: "confirmed" }), [rpcUrl]);
3104
3103
  const storage = useMemo2(() => tokenStorage || createSecureStoreStorage(), [tokenStorage]);
3105
3104
  const [uiConfig, setUiConfig] = useState16(null);
3105
+ const [resolvedNetwork, setResolvedNetwork] = useState16(network);
3106
3106
  useEffect11(() => {
3107
- client.getAppConfig().then((config2) => {
3108
- console.log("[DubsProvider] UI config loaded:", JSON.stringify(config2));
3109
- setUiConfig(config2);
3107
+ client.getAppConfig().then((cfg) => {
3108
+ console.log("[DubsProvider] UI config loaded:", JSON.stringify(cfg));
3109
+ setUiConfig(cfg);
3110
+ if (cfg.environment === "sandbox" && network === "mainnet-beta" && !rpcUrlOverride) {
3111
+ console.log("[DubsProvider] Sandbox API key detected \u2014 auto-switching to devnet");
3112
+ setResolvedNetwork("devnet");
3113
+ }
3110
3114
  }).catch((err) => {
3111
3115
  console.log("[DubsProvider] UI config fetch failed, using defaults:", err?.message);
3112
3116
  setUiConfig({});
3113
3117
  });
3114
3118
  }, [client]);
3115
3119
  if (uiConfig === null) return null;
3120
+ const resolvedConfig = NETWORK_CONFIG[resolvedNetwork];
3121
+ const resolvedRpcUrl = rpcUrlOverride || resolvedConfig.rpcUrl;
3122
+ const cluster = resolvedConfig.cluster;
3123
+ const connection = useMemo2(() => new Connection2(resolvedRpcUrl, { commitment: "confirmed" }), [resolvedRpcUrl]);
3116
3124
  const themeOverrides = {};
3117
3125
  if (uiConfig.accentColor) {
3118
3126
  themeOverrides.accent = uiConfig.accentColor;
@@ -3125,7 +3133,7 @@ function DubsProvider({
3125
3133
  connection,
3126
3134
  wallet: externalWallet,
3127
3135
  appName: uiConfig.appName || appName,
3128
- network,
3136
+ network: resolvedNetwork,
3129
3137
  storage,
3130
3138
  managed,
3131
3139
  renderLoading,
@@ -3157,7 +3165,7 @@ function DubsProvider({
3157
3165
  connection,
3158
3166
  wallet: adapter,
3159
3167
  appName: uiConfig.appName || appName,
3160
- network,
3168
+ network: resolvedNetwork,
3161
3169
  storage,
3162
3170
  renderLoading,
3163
3171
  renderError,